author | zautrix <zautrix> | 2005-06-13 10:51:47 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-13 10:51:47 (UTC) |
commit | 4f3ff02932b39bf16b9692c3cb69c101a28b4616 (patch) (unidiff) | |
tree | bae36a7e654c788a0994bb353f3997b495e2459c | |
parent | 2be8214908c52298ba79c8058d340edca5a8b417 (diff) | |
download | kdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.zip kdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.tar.gz kdepimpi-4f3ff02932b39bf16b9692c3cb69c101a28b4616.tar.bz2 |
fixx
-rw-r--r-- | korganizer/calendarview.cpp | 63 | ||||
-rw-r--r-- | korganizer/calendarview.h | 7 | ||||
-rw-r--r-- | korganizer/kofilterview.cpp | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 4 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 5 | ||||
-rw-r--r-- | libkcal/calendar.h | 9 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 56 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 6 |
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() | |||
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 ) { |
@@ -1834,6 +1838,46 @@ void CalendarView::setSyncEventsReadOnly() | |||
1834 | ev = eL.next(); | 1838 | ev = eL.next(); |
1835 | } | 1839 | } |
1836 | } | 1840 | } |
1841 | |||
1842 | bool 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 | } | ||
1859 | bool 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 | } | ||
1872 | bool 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 | } | ||
1837 | bool CalendarView::openCalendar(QString filename, bool merge) | 1881 | bool CalendarView::openCalendar(QString filename, bool merge) |
1838 | { | 1882 | { |
1839 | 1883 | ||
@@ -1964,7 +2008,24 @@ bool CalendarView::checkFileVersion(QString fn) | |||
1964 | updateView(); | 2008 | updateView(); |
1965 | return true; | 2009 | return true; |
1966 | } | 2010 | } |
1967 | 2011 | bool 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 | } | ||
1968 | bool CalendarView::saveCalendar( QString filename ) | 2029 | bool CalendarView::saveCalendar( QString filename ) |
1969 | { | 2030 | { |
1970 | 2031 | ||
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 @@ | |||
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 | ||
48 | class QWidgetStack; | 49 | class QWidgetStack; |
49 | class QSplitter; | 50 | class QSplitter; |
50 | 51 | class KopiCalendarFile; | |
51 | class CalPrinter; | 52 | class CalPrinter; |
52 | class KOFilterView; | 53 | class KOFilterView; |
53 | class KOCalEditView; | 54 | class KOCalEditView; |
@@ -222,6 +223,10 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
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 | /** |
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 | |||
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(); } |
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) : | |||
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 | ||
@@ -1857,7 +1857,7 @@ void MainWindow::save() | |||
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 ); |
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() | |||
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 |
@@ -112,6 +113,10 @@ Calendar::~Calendar() | |||
112 | if ( mUndoIncidence ) | 113 | if ( mUndoIncidence ) |
113 | delete mUndoIncidence; | 114 | delete mUndoIncidence; |
114 | } | 115 | } |
116 | void Calendar::setDontDeleteIncidencesOnClose () | ||
117 | { | ||
118 | mDeleteIncidencesOnClose = false; | ||
119 | } | ||
115 | void Calendar::setDefaultCalendar( int d ) | 120 | void Calendar::setDefaultCalendar( int d ) |
116 | { | 121 | { |
117 | mDefaultCalendar = d; | 122 | 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: | |||
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. |
@@ -302,10 +304,13 @@ public: | |||
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(); |
@@ -334,6 +339,7 @@ public: | |||
334 | Incidence *mNextAlarmIncidence; | 339 | Incidence *mNextAlarmIncidence; |
335 | Incidence *mUndoIncidence; | 340 | Incidence *mUndoIncidence; |
336 | int mDefaultCalendar; | 341 | int mDefaultCalendar; |
342 | bool mDeleteIncidencesOnClose; | ||
337 | 343 | ||
338 | private: | 344 | private: |
339 | void init(); | 345 | void init(); |
@@ -343,6 +349,7 @@ private: | |||
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 | ||
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() | |||
65 | 65 | ||
66 | CalendarLocal::~CalendarLocal() | 66 | CalendarLocal::~CalendarLocal() |
67 | { | 67 | { |
68 | close(); | 68 | if ( mDeleteIncidencesOnClose ) |
69 | close(); | ||
70 | } | ||
71 | bool 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 | } | ||
81 | void 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 | |||
71 | bool CalendarLocal::load( const QString &fileName ) | 109 | bool CalendarLocal::load( const QString &fileName ) |
72 | { | 110 | { |
73 | FileStorage storage( this, fileName ); | 111 | FileStorage storage( this, fileName ); |
@@ -756,6 +794,20 @@ void CalendarLocal::setCalendarEnabled( int id, bool enable ) | |||
756 | if ( it->calID() == id ) it->setCalEnabled( enable ); | 794 | if ( it->calID() == id ) it->setCalEnabled( enable ); |
757 | 795 | ||
758 | } | 796 | } |
797 | |||
798 | void 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 | |||
759 | void CalendarLocal::setAlarmEnabled( int id, bool enable ) | 811 | void 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() ) |
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 | |||
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. |
@@ -179,9 +180,10 @@ class CalendarLocal : public Calendar | |||
179 | Todo *todo( QString, QString ); | 180 | Todo *todo( QString, QString ); |
180 | Event *event( QString, QString ); | 181 | Event *event( QString, QString ); |
181 | 182 | ||
182 | 183 | public 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: |