summaryrefslogtreecommitdiffabout
Side-by-side diff
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
@@ -460,4 +460,8 @@ void CalendarView::init()
mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
+ connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
+ connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
+ connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
+ connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
mTodoList->setNavigator( mNavigator );
#if 0
@@ -1835,4 +1839,44 @@ void CalendarView::setSyncEventsReadOnly()
}
}
+
+bool CalendarView::loadCalendars()
+{
+ QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
+ KopiCalendarFile * cal = calendars.first();
+ mCalendar->setDefaultCalendar( 1 );
+ openCalendar( MainWindow::defaultFileName(), false );
+ cal = calendars.next();
+ while ( cal ) {
+ addCalendar( cal );
+ cal = calendars.next();
+ }
+ restoreCalendarSettings();
+ mCalendar->reInitAlarmSettings();
+ setSyncEventsReadOnly();
+ updateUnmanagedViews();
+ updateView();
+}
+bool CalendarView::restoreCalendarSettings()
+{
+ QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
+ KopiCalendarFile * cal = calendars.first();
+ while ( cal ) {
+ mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
+ mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
+ mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
+ if ( cal->isStandard )
+ mCalendar->setDefaultCalendar( cal->mCalNumber );
+ cal = calendars.next();
+ }
+}
+bool CalendarView::addCalendar( KopiCalendarFile * cal )
+{
+
+ if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber ))
+ return true;
+ qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
+ KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
+ return false;
+}
bool CalendarView::openCalendar(QString filename, bool merge)
{
@@ -1965,5 +2009,22 @@ bool CalendarView::checkFileVersion(QString fn)
return true;
}
-
+bool CalendarView::saveCalendars()
+{
+ QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
+ KopiCalendarFile * cal = calendars.first();
+ mCalendar->setDefaultCalendar( 1 );
+ mCalendar->setDefaultCalendarEnabledOnly();
+ saveCalendar( MainWindow::defaultFileName() );
+ cal = calendars.next();
+ while ( cal ) {
+ if ( !cal->isReadOnly ) {
+ mCalendar->setDefaultCalendar( cal->mCalNumber );
+ mCalendar->setDefaultCalendarEnabledOnly();
+ saveCalendar( cal->mFileName );
+ }
+ cal = calendars.next();
+ }
+ restoreCalendarSettings();
+}
bool 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
@@ -45,8 +45,9 @@
#include <ksyncmanager.h>
+//#include <koprefs.h>
class QWidgetStack;
class QSplitter;
-
+class KopiCalendarFile;
class CalPrinter;
class KOFilterView;
@@ -223,4 +224,8 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
*/
bool openCalendar(QString filename, bool merge=false);
+ bool loadCalendars();
+ bool saveCalendars();
+ bool restoreCalendarSettings();
+ bool addCalendar( KopiCalendarFile * );
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
@@ -67,5 +67,5 @@ class KONewCalPrefs : public QDialog
connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
- resize( 200, 200 );
+ //resize( 200, 200 );
}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 95e1607..f05ada5 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -309,5 +309,5 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
QTime neededSaveTime = QDateTime::currentDateTime().time();
- mView->openCalendar( defaultFileName() );
+ mView->loadCalendars();
int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
qDebug("KO: Calendar loading time: %d ms",msNeeded );
@@ -1858,5 +1858,5 @@ void MainWindow::save()
setCaption(i18n("KO/Pi:Saving Data to File ..." ));
qDebug("KO: Start saving data to file!");
- mView->saveCalendar( defaultFileName() );
+ mView->saveCalendars();
mCalendarModifiedFlag = false;
int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index f4350d9..5092d1a 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -54,4 +54,5 @@ void Calendar::init()
mNewObserver = false;
mUndoIncidence = 0;
+ mDeleteIncidencesOnClose = true;
mModified = false;
mDefaultCalendar = 1;
@@ -113,4 +114,8 @@ Calendar::~Calendar()
delete mUndoIncidence;
}
+void Calendar::setDontDeleteIncidencesOnClose ()
+{
+ mDeleteIncidencesOnClose = false;
+}
void 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
@@ -75,4 +75,6 @@ public:
*/
virtual void close() = 0;
+ virtual void addCalendar( Calendar* ) = 0;
+ virtual bool addCalendarFile( QString name, int id ) = 0;
/**
@@ -303,8 +305,11 @@ public:
*/
QString loadedProductId();
- void setDefaultCalendar( int );
int defaultCalendar();
+ void setDontDeleteIncidencesOnClose ();
+ public slots:
+ void setDefaultCalendar( int );
virtual void setCalendarEnabled( int id, bool enable ) = 0;
virtual void setAlarmEnabled( int id, bool enable ) = 0;
+ virtual void setReadOnly( int id, bool enable ) = 0;
virtual void setDefaultCalendarEnabledOnly() = 0;
signals:
@@ -335,4 +340,5 @@ public:
Incidence *mUndoIncidence;
int mDefaultCalendar;
+ bool mDeleteIncidencesOnClose;
private:
@@ -344,4 +350,5 @@ private:
bool mLocalTime; // use local time, not UTC or a time zone
+
CalFilter *mFilter;
CalFilter *mDefaultFilter;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index c5500bf..e48122a 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -66,7 +66,45 @@ void CalendarLocal::init()
CalendarLocal::~CalendarLocal()
{
- close();
+ if ( mDeleteIncidencesOnClose )
+ close();
+}
+bool CalendarLocal::addCalendarFile( QString name, int id )
+{
+ CalendarLocal calendar( timeZoneId() );
+ calendar.setDefaultCalendar( id );
+ if ( calendar.load( name ) ) {
+ addCalendar( &calendar );
+ return true;
+ }
+ return false;
+}
+void CalendarLocal::addCalendar( Calendar* cal )
+{
+ cal->setDontDeleteIncidencesOnClose();
+ {
+ QPtrList<Event> EventList = cal->rawEvents();
+ Event * ev = EventList.first();
+ while ( ev ) {
+ mEventList.append( ev );
+ ev = EventList.next();
+ }
+ }
+ {
+ QPtrList<Todo> TodoList = cal->rawTodos();
+ Todo * ev = TodoList.first();
+ while ( ev ) {
+ mTodoList.append( ev );
+ ev = TodoList.next();
+ }
+ }
+ {
+ QPtrList<Journal> JournalList = cal->journals();
+ Journal * ev = JournalList.first();
+ while ( ev ) {
+ mJournalList.append( ev );
+ ev = JournalList.next();
+ }
+ }
}
-
bool CalendarLocal::load( const QString &fileName )
{
@@ -757,4 +795,18 @@ void CalendarLocal::setCalendarEnabled( int id, bool enable )
}
+
+void CalendarLocal::setReadOnly( int id, bool enable )
+{
+ for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
+ if ( it->calID() == id ) it->setReadOnly( enable );
+
+ for ( Event *it = mEventList.first(); it; it = mEventList.next() )
+ if ( it->calID() == id ) it->setReadOnly( enable );
+
+ for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
+ if ( it->calID() == id ) it->setReadOnly( enable );
+
+}
+
void 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
@@ -44,5 +44,6 @@ class CalendarLocal : public Calendar
CalendarLocal( const QString &timeZoneId );
~CalendarLocal();
-
+ void addCalendar( Calendar* );
+ bool addCalendarFile( QString name, int id );
/**
Loads a calendar on disk in vCalendar or iCalendar format into the current
@@ -180,7 +181,8 @@ class CalendarLocal : public Calendar
Event *event( QString, QString );
-
+public slots:
void setCalendarEnabled( int id, bool enable );
void setAlarmEnabled( int id, bool enable );
+ void setReadOnly( int id, bool enable );
void setDefaultCalendarEnabledOnly();