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 | |||
@@ -460,4 +460,8 @@ void CalendarView::init() | |||
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 |
@@ -1835,4 +1839,44 @@ void CalendarView::setSyncEventsReadOnly() | |||
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 | { |
@@ -1965,5 +2009,22 @@ bool CalendarView::checkFileVersion(QString fn) | |||
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 | { |
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 @@ | |||
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; |
@@ -223,4 +224,8 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
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 | ||
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 | |||
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 | ||
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) : | |||
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 ); |
@@ -1858,5 +1858,5 @@ void MainWindow::save() | |||
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() ); |
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() | |||
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; |
@@ -113,4 +114,8 @@ Calendar::~Calendar() | |||
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 | { |
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: | |||
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 | /** |
@@ -303,8 +305,11 @@ public: | |||
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: |
@@ -335,4 +340,5 @@ public: | |||
335 | Incidence *mUndoIncidence; | 340 | Incidence *mUndoIncidence; |
336 | int mDefaultCalendar; | 341 | int mDefaultCalendar; |
342 | bool mDeleteIncidencesOnClose; | ||
337 | 343 | ||
338 | private: | 344 | private: |
@@ -344,4 +350,5 @@ private: | |||
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; |
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() | |||
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 | { |
@@ -757,4 +795,18 @@ void CalendarLocal::setCalendarEnabled( int id, bool 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 | { |
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 | |||
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 |
@@ -180,7 +181,8 @@ class CalendarLocal : public Calendar | |||
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 | ||