summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-13 10:51:47 (UTC)
committer zautrix <zautrix>2005-06-13 10:51:47 (UTC)
commit4f3ff02932b39bf16b9692c3cb69c101a28b4616 (patch) (side-by-side diff)
treebae36a7e654c788a0994bb353f3997b495e2459c
parent2be8214908c52298ba79c8058d340edca5a8b417 (diff)
downloadkdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.zip
kdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.tar.gz
kdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.tar.bz2
fixx
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
@@ -459,6 +459,10 @@ void CalendarView::init()
mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
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
if ( QApplication::desktop()->width() < 480 ) {
@@ -1834,6 +1838,46 @@ void CalendarView::setSyncEventsReadOnly()
ev = eL.next();
}
}
+
+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)
{
@@ -1964,7 +2008,24 @@ bool CalendarView::checkFileVersion(QString fn)
updateView();
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
@@ -44,10 +44,11 @@
#include <korganizer/calendarviewbase.h>
#include <ksyncmanager.h>
+//#include <koprefs.h>
class QWidgetStack;
class QSplitter;
-
+class KopiCalendarFile;
class CalPrinter;
class KOFilterView;
class KOCalEditView;
@@ -222,6 +223,10 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
loading. Return true, if calendar could be successfully loaded.
*/
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
@@ -66,7 +66,7 @@ class KONewCalPrefs : public QDialog
lay->addWidget( cancel );
connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
- resize( 200, 200 );
+ //resize( 200, 200 );
}
QString calName() { return nameE->text(); }
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 95e1607..f05ada5 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -308,7 +308,7 @@ 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 );
@@ -1857,7 +1857,7 @@ void MainWindow::save()
QTime neededSaveTime = QDateTime::currentDateTime().time();
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() );
qDebug("KO: Needed %d ms for saving.",msNeeded );
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index f4350d9..5092d1a 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -53,6 +53,7 @@ void Calendar::init()
mObserver = 0;
mNewObserver = false;
mUndoIncidence = 0;
+ mDeleteIncidencesOnClose = true;
mModified = false;
mDefaultCalendar = 1;
// Setup default filter, which does nothing
@@ -112,6 +113,10 @@ Calendar::~Calendar()
if ( mUndoIncidence )
delete mUndoIncidence;
}
+void Calendar::setDontDeleteIncidencesOnClose ()
+{
+ mDeleteIncidencesOnClose = false;
+}
void Calendar::setDefaultCalendar( int d )
{
mDefaultCalendar = d;
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4c6760f..73f82bb 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -74,6 +74,8 @@ public:
Clears out the current calendar, freeing all used memory etc.
*/
virtual void close() = 0;
+ virtual void addCalendar( Calendar* ) = 0;
+ virtual bool addCalendarFile( QString name, int id ) = 0;
/**
Sync changes in memory to persistant storage.
@@ -302,10 +304,13 @@ public:
QString::null, if no calendar has been loaded.
*/
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:
void calendarChanged();
@@ -334,6 +339,7 @@ public:
Incidence *mNextAlarmIncidence;
Incidence *mUndoIncidence;
int mDefaultCalendar;
+ bool mDeleteIncidencesOnClose;
private:
void init();
@@ -343,6 +349,7 @@ private:
int mTimeZone; // timezone OFFSET from GMT (MINUTES)
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
@@ -65,9 +65,47 @@ 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 )
{
FileStorage storage( this, fileName );
@@ -756,6 +794,20 @@ void CalendarLocal::setCalendarEnabled( int id, bool enable )
if ( it->calID() == id ) it->setCalEnabled( 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 )
{
for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index b25fcbe..65f6aa7 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -43,7 +43,8 @@ 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
calendar. Any information already present is lost.
@@ -179,9 +180,10 @@ class CalendarLocal : public Calendar
Todo *todo( QString, QString );
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();
protected: