author | zautrix <zautrix> | 2004-08-01 12:02:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-01 12:02:39 (UTC) |
commit | c31e99f265dbe8762efca20667f8ccd973840f8f (patch) (unidiff) | |
tree | 29e7fd6845d187f41f9d80e756611dc8bc182bdc | |
parent | e954cc1e29b129982e4d07c4f490d7e881597374 (diff) | |
download | kdepimpi-c31e99f265dbe8762efca20667f8ccd973840f8f.zip kdepimpi-c31e99f265dbe8762efca20667f8ccd973840f8f.tar.gz kdepimpi-c31e99f265dbe8762efca20667f8ccd973840f8f.tar.bz2 |
Changed zaurusstat to tempsyncstat
-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | libkcal/icalformatimpl.cpp | 8 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 12 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 6 | ||||
-rw-r--r-- | libkcal/sharpformat.cpp | 14 |
5 files changed, 18 insertions, 26 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index fd68dc4..b543eca 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,3503 +1,3503 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preston.brown@yale.edu) | 8 | Preston Brown (preston.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include "kosyncprefsdialog.h" | 61 | #include "kosyncprefsdialog.h" |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | 66 | ||
67 | #include <libkcal/vcaldrag.h> | 67 | #include <libkcal/vcaldrag.h> |
68 | #include <libkcal/icaldrag.h> | 68 | #include <libkcal/icaldrag.h> |
69 | #include <libkcal/icalformat.h> | 69 | #include <libkcal/icalformat.h> |
70 | #include <libkcal/vcalformat.h> | 70 | #include <libkcal/vcalformat.h> |
71 | #include <libkcal/scheduler.h> | 71 | #include <libkcal/scheduler.h> |
72 | #include <libkcal/calendarlocal.h> | 72 | #include <libkcal/calendarlocal.h> |
73 | #include <libkcal/journal.h> | 73 | #include <libkcal/journal.h> |
74 | #include <libkcal/calfilter.h> | 74 | #include <libkcal/calfilter.h> |
75 | #include <libkcal/attendee.h> | 75 | #include <libkcal/attendee.h> |
76 | #include <libkcal/dndfactory.h> | 76 | #include <libkcal/dndfactory.h> |
77 | #include <libkcal/freebusy.h> | 77 | #include <libkcal/freebusy.h> |
78 | #include <libkcal/filestorage.h> | 78 | #include <libkcal/filestorage.h> |
79 | #include <libkcal/calendarresources.h> | 79 | #include <libkcal/calendarresources.h> |
80 | #include <libkcal/qtopiaformat.h> | 80 | #include <libkcal/qtopiaformat.h> |
81 | #include "../kalarmd/alarmdialog.h" | 81 | #include "../kalarmd/alarmdialog.h" |
82 | 82 | ||
83 | #ifndef DESKTOP_VERSION | 83 | #ifndef DESKTOP_VERSION |
84 | #include <libkcal/sharpformat.h> | 84 | #include <libkcal/sharpformat.h> |
85 | #endif | 85 | #endif |
86 | #ifndef KORG_NOMAIL | 86 | #ifndef KORG_NOMAIL |
87 | #include "komailclient.h" | 87 | #include "komailclient.h" |
88 | #endif | 88 | #endif |
89 | #ifndef KORG_NOPRINTER | 89 | #ifndef KORG_NOPRINTER |
90 | #include "calprinter.h" | 90 | #include "calprinter.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPLUGINS | 92 | #ifndef KORG_NOPLUGINS |
93 | #include "kocore.h" | 93 | #include "kocore.h" |
94 | #endif | 94 | #endif |
95 | #include "koeventeditor.h" | 95 | #include "koeventeditor.h" |
96 | #include "kotodoeditor.h" | 96 | #include "kotodoeditor.h" |
97 | #include "koprefs.h" | 97 | #include "koprefs.h" |
98 | #include "koeventviewerdialog.h" | 98 | #include "koeventviewerdialog.h" |
99 | #include "publishdialog.h" | 99 | #include "publishdialog.h" |
100 | #include "kofilterview.h" | 100 | #include "kofilterview.h" |
101 | #include "koglobals.h" | 101 | #include "koglobals.h" |
102 | #include "koviewmanager.h" | 102 | #include "koviewmanager.h" |
103 | #include "koagendaview.h" | 103 | #include "koagendaview.h" |
104 | #include "kodialogmanager.h" | 104 | #include "kodialogmanager.h" |
105 | #include "outgoingdialog.h" | 105 | #include "outgoingdialog.h" |
106 | #include "incomingdialog.h" | 106 | #include "incomingdialog.h" |
107 | #include "statusdialog.h" | 107 | #include "statusdialog.h" |
108 | #include "kdatenavigator.h" | 108 | #include "kdatenavigator.h" |
109 | #include "kotodoview.h" | 109 | #include "kotodoview.h" |
110 | #include "datenavigator.h" | 110 | #include "datenavigator.h" |
111 | #include "resourceview.h" | 111 | #include "resourceview.h" |
112 | #include "navigatorbar.h" | 112 | #include "navigatorbar.h" |
113 | #include "searchdialog.h" | 113 | #include "searchdialog.h" |
114 | #include "mainwindow.h" | 114 | #include "mainwindow.h" |
115 | 115 | ||
116 | #include "calendarview.h" | 116 | #include "calendarview.h" |
117 | #ifndef DESKTOP_VERSION | 117 | #ifndef DESKTOP_VERSION |
118 | #include <qtopia/alarmserver.h> | 118 | #include <qtopia/alarmserver.h> |
119 | #endif | 119 | #endif |
120 | #ifndef _WIN32_ | 120 | #ifndef _WIN32_ |
121 | #include <stdlib.h> | 121 | #include <stdlib.h> |
122 | #include <stdio.h> | 122 | #include <stdio.h> |
123 | #include <unistd.h> | 123 | #include <unistd.h> |
124 | #else | 124 | #else |
125 | #include <qprocess.h> | 125 | #include <qprocess.h> |
126 | #endif | 126 | #endif |
127 | using namespace KOrg; | 127 | using namespace KOrg; |
128 | using namespace KCal; | 128 | using namespace KCal; |
129 | extern int globalFlagBlockAgenda; | 129 | extern int globalFlagBlockAgenda; |
130 | extern int globalFlagBlockStartup; | 130 | extern int globalFlagBlockStartup; |
131 | 131 | ||
132 | 132 | ||
133 | 133 | ||
134 | class KOBeamPrefs : public QDialog | 134 | class KOBeamPrefs : public QDialog |
135 | { | 135 | { |
136 | public: | 136 | public: |
137 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 137 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
138 | QDialog( parent, name, true ) | 138 | QDialog( parent, name, true ) |
139 | { | 139 | { |
140 | setCaption( i18n("Beam Options") ); | 140 | setCaption( i18n("Beam Options") ); |
141 | QVBoxLayout* lay = new QVBoxLayout( this ); | 141 | QVBoxLayout* lay = new QVBoxLayout( this ); |
142 | lay->setSpacing( 3 ); | 142 | lay->setSpacing( 3 ); |
143 | lay->setMargin( 3 ); | 143 | lay->setMargin( 3 ); |
144 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 144 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
145 | lay->addWidget( format ); | 145 | lay->addWidget( format ); |
146 | format->setExclusive ( true ) ; | 146 | format->setExclusive ( true ) ; |
147 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 147 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
148 | lay->addWidget( time ); time->setExclusive ( true ) ; | 148 | lay->addWidget( time ); time->setExclusive ( true ) ; |
149 | vcal = new QRadioButton(" vCalendar ", format ); | 149 | vcal = new QRadioButton(" vCalendar ", format ); |
150 | ical = new QRadioButton(" iCalendar ", format ); | 150 | ical = new QRadioButton(" iCalendar ", format ); |
151 | vcal->setChecked( true ); | 151 | vcal->setChecked( true ); |
152 | tz = new QRadioButton(i18n(" With timezone "), time ); | 152 | tz = new QRadioButton(i18n(" With timezone "), time ); |
153 | local = new QRadioButton(i18n(" Local time "), time ); | 153 | local = new QRadioButton(i18n(" Local time "), time ); |
154 | tz->setChecked( true ); | 154 | tz->setChecked( true ); |
155 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 155 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
156 | lay->addWidget( ok ); | 156 | lay->addWidget( ok ); |
157 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 157 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
158 | lay->addWidget( cancel ); | 158 | lay->addWidget( cancel ); |
159 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 159 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
160 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 160 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
161 | resize( 200, 200 ); | 161 | resize( 200, 200 ); |
162 | } | 162 | } |
163 | 163 | ||
164 | bool beamVcal() { return vcal->isChecked(); } | 164 | bool beamVcal() { return vcal->isChecked(); } |
165 | bool beamLocal() { return local->isChecked(); } | 165 | bool beamLocal() { return local->isChecked(); } |
166 | private: | 166 | private: |
167 | QRadioButton* vcal, *ical, *local, *tz; | 167 | QRadioButton* vcal, *ical, *local, *tz; |
168 | }; | 168 | }; |
169 | class KOCatPrefs : public QDialog | 169 | class KOCatPrefs : public QDialog |
170 | { | 170 | { |
171 | public: | 171 | public: |
172 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 172 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
173 | QDialog( parent, name, true ) | 173 | QDialog( parent, name, true ) |
174 | { | 174 | { |
175 | setCaption( i18n("Manage new Categories") ); | 175 | setCaption( i18n("Manage new Categories") ); |
176 | QVBoxLayout* lay = new QVBoxLayout( this ); | 176 | QVBoxLayout* lay = new QVBoxLayout( this ); |
177 | lay->setSpacing( 3 ); | 177 | lay->setSpacing( 3 ); |
178 | lay->setMargin( 3 ); | 178 | lay->setMargin( 3 ); |
179 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 179 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
180 | lay->addWidget( lab ); | 180 | lay->addWidget( lab ); |
181 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 181 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
182 | lay->addWidget( format ); | 182 | lay->addWidget( format ); |
183 | format->setExclusive ( true ) ; | 183 | format->setExclusive ( true ) ; |
184 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 184 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
185 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 185 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
186 | addCatBut->setChecked( true ); | 186 | addCatBut->setChecked( true ); |
187 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 187 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
188 | lay->addWidget( ok ); | 188 | lay->addWidget( ok ); |
189 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 189 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
190 | lay->addWidget( cancel ); | 190 | lay->addWidget( cancel ); |
191 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 191 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
192 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 192 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
193 | resize( 200, 200 ); | 193 | resize( 200, 200 ); |
194 | } | 194 | } |
195 | 195 | ||
196 | bool addCat() { return addCatBut->isChecked(); } | 196 | bool addCat() { return addCatBut->isChecked(); } |
197 | private: | 197 | private: |
198 | QRadioButton* addCatBut; | 198 | QRadioButton* addCatBut; |
199 | }; | 199 | }; |
200 | 200 | ||
201 | 201 | ||
202 | 202 | ||
203 | CalendarView::CalendarView( CalendarResources *calendar, | 203 | CalendarView::CalendarView( CalendarResources *calendar, |
204 | QWidget *parent, const char *name ) | 204 | QWidget *parent, const char *name ) |
205 | : CalendarViewBase( parent, name ), | 205 | : CalendarViewBase( parent, name ), |
206 | mCalendar( calendar ), | 206 | mCalendar( calendar ), |
207 | mResourceManager( calendar->resourceManager() ) | 207 | mResourceManager( calendar->resourceManager() ) |
208 | { | 208 | { |
209 | 209 | ||
210 | mEventEditor = 0; | 210 | mEventEditor = 0; |
211 | mTodoEditor = 0; | 211 | mTodoEditor = 0; |
212 | 212 | ||
213 | init(); | 213 | init(); |
214 | } | 214 | } |
215 | 215 | ||
216 | CalendarView::CalendarView( Calendar *calendar, | 216 | CalendarView::CalendarView( Calendar *calendar, |
217 | QWidget *parent, const char *name ) | 217 | QWidget *parent, const char *name ) |
218 | : CalendarViewBase( parent, name ), | 218 | : CalendarViewBase( parent, name ), |
219 | mCalendar( calendar ), | 219 | mCalendar( calendar ), |
220 | mResourceManager( 0 ) | 220 | mResourceManager( 0 ) |
221 | { | 221 | { |
222 | 222 | ||
223 | mEventEditor = 0; | 223 | mEventEditor = 0; |
224 | mTodoEditor = 0; | 224 | mTodoEditor = 0; |
225 | init();} | 225 | init();} |
226 | 226 | ||
227 | void CalendarView::init() | 227 | void CalendarView::init() |
228 | { | 228 | { |
229 | beamDialog = new KOBeamPrefs(); | 229 | beamDialog = new KOBeamPrefs(); |
230 | mDatePickerMode = 0; | 230 | mDatePickerMode = 0; |
231 | mCurrentSyncDevice = ""; | 231 | mCurrentSyncDevice = ""; |
232 | writeLocale(); | 232 | writeLocale(); |
233 | mViewManager = new KOViewManager( this ); | 233 | mViewManager = new KOViewManager( this ); |
234 | mDialogManager = new KODialogManager( this ); | 234 | mDialogManager = new KODialogManager( this ); |
235 | mEventViewerDialog = 0; | 235 | mEventViewerDialog = 0; |
236 | mModified = false; | 236 | mModified = false; |
237 | mReadOnly = false; | 237 | mReadOnly = false; |
238 | mSelectedIncidence = 0; | 238 | mSelectedIncidence = 0; |
239 | mSyncProfiles.setAutoDelete(true); | 239 | mSyncProfiles.setAutoDelete(true); |
240 | mCalPrinter = 0; | 240 | mCalPrinter = 0; |
241 | mFilters.setAutoDelete(true); | 241 | mFilters.setAutoDelete(true); |
242 | 242 | ||
243 | mCalendar->registerObserver( this ); | 243 | mCalendar->registerObserver( this ); |
244 | // TODO: Make sure that view is updated, when calendar is changed. | 244 | // TODO: Make sure that view is updated, when calendar is changed. |
245 | 245 | ||
246 | mStorage = new FileStorage( mCalendar ); | 246 | mStorage = new FileStorage( mCalendar ); |
247 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 247 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
248 | 248 | ||
249 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 249 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
250 | #ifndef KORG_NOSPLITTER | 250 | #ifndef KORG_NOSPLITTER |
251 | // create the main layout frames. | 251 | // create the main layout frames. |
252 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 252 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
253 | topLayout->addWidget(mPanner); | 253 | topLayout->addWidget(mPanner); |
254 | 254 | ||
255 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 255 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
256 | "CalendarView::LeftFrame"); | 256 | "CalendarView::LeftFrame"); |
257 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 257 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
258 | 258 | ||
259 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, | 259 | mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, |
260 | "CalendarView::DateNavigator", QDate::currentDate() ); | 260 | "CalendarView::DateNavigator", QDate::currentDate() ); |
261 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 261 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
262 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 262 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
263 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 263 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
264 | 264 | ||
265 | #ifdef KORG_NORESOURCEVIEW | 265 | #ifdef KORG_NORESOURCEVIEW |
266 | mResourceView = 0; | 266 | mResourceView = 0; |
267 | #else | 267 | #else |
268 | if ( mResourceManager ) { | 268 | if ( mResourceManager ) { |
269 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 269 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
270 | mResourceView->updateView(); | 270 | mResourceView->updateView(); |
271 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 271 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
272 | SLOT( updateView() ) ); | 272 | SLOT( updateView() ) ); |
273 | } else { | 273 | } else { |
274 | mResourceView = 0; | 274 | mResourceView = 0; |
275 | } | 275 | } |
276 | #endif | 276 | #endif |
277 | QWidget *rightBox = new QWidget( mPanner ); | 277 | QWidget *rightBox = new QWidget( mPanner ); |
278 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 278 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
279 | 279 | ||
280 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 280 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
281 | rightLayout->addWidget( mNavigatorBar ); | 281 | rightLayout->addWidget( mNavigatorBar ); |
282 | 282 | ||
283 | mRightFrame = new QWidgetStack( rightBox ); | 283 | mRightFrame = new QWidgetStack( rightBox ); |
284 | rightLayout->addWidget( mRightFrame, 1 ); | 284 | rightLayout->addWidget( mRightFrame, 1 ); |
285 | 285 | ||
286 | mLeftFrame = mLeftSplitter; | 286 | mLeftFrame = mLeftSplitter; |
287 | #else | 287 | #else |
288 | QWidget *mainBox = new QWidget( this ); | 288 | QWidget *mainBox = new QWidget( this ); |
289 | QWidget *leftFrame = new QWidget( mainBox ); | 289 | QWidget *leftFrame = new QWidget( mainBox ); |
290 | 290 | ||
291 | QBoxLayout * mainBoxLayout; | 291 | QBoxLayout * mainBoxLayout; |
292 | QBoxLayout * leftFrameLayout; | 292 | QBoxLayout * leftFrameLayout; |
293 | if ( KOPrefs::instance()->mVerticalScreen ) { | 293 | if ( KOPrefs::instance()->mVerticalScreen ) { |
294 | mainBoxLayout = new QVBoxLayout(mainBox); | 294 | mainBoxLayout = new QVBoxLayout(mainBox); |
295 | leftFrameLayout = new QHBoxLayout(leftFrame ); | 295 | leftFrameLayout = new QHBoxLayout(leftFrame ); |
296 | } else { | 296 | } else { |
297 | mainBoxLayout = new QHBoxLayout(mainBox); | 297 | mainBoxLayout = new QHBoxLayout(mainBox); |
298 | leftFrameLayout = new QVBoxLayout(leftFrame ); | 298 | leftFrameLayout = new QVBoxLayout(leftFrame ); |
299 | } | 299 | } |
300 | topLayout->addWidget( mainBox ); | 300 | topLayout->addWidget( mainBox ); |
301 | mainBoxLayout->addWidget (leftFrame); | 301 | mainBoxLayout->addWidget (leftFrame); |
302 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, | 302 | mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, |
303 | "CalendarView::DateNavigator", QDate::currentDate()); | 303 | "CalendarView::DateNavigator", QDate::currentDate()); |
304 | // mDateNavigator->blockSignals( true ); | 304 | // mDateNavigator->blockSignals( true ); |
305 | leftFrameLayout->addWidget( mDateNavigator ); | 305 | leftFrameLayout->addWidget( mDateNavigator ); |
306 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); | 306 | mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); |
307 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); | 307 | mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); |
308 | 308 | ||
309 | if ( QApplication::desktop()->width() < 480 ) { | 309 | if ( QApplication::desktop()->width() < 480 ) { |
310 | leftFrameLayout->addWidget(mFilterView); | 310 | leftFrameLayout->addWidget(mFilterView); |
311 | leftFrameLayout->addWidget(mTodoList, 2 ); | 311 | leftFrameLayout->addWidget(mTodoList, 2 ); |
312 | 312 | ||
313 | } else { | 313 | } else { |
314 | leftFrameLayout->addWidget(mTodoList,2 ); | 314 | leftFrameLayout->addWidget(mTodoList,2 ); |
315 | leftFrameLayout->addWidget(mFilterView ); | 315 | leftFrameLayout->addWidget(mFilterView ); |
316 | } | 316 | } |
317 | mFilterView->hide(); | 317 | mFilterView->hide(); |
318 | QWidget *rightBox = new QWidget( mainBox ); | 318 | QWidget *rightBox = new QWidget( mainBox ); |
319 | mainBoxLayout->addWidget ( rightBox, 10 ); | 319 | mainBoxLayout->addWidget ( rightBox, 10 ); |
320 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 320 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
321 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); | 321 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); |
322 | mRightFrame = new QWidgetStack( rightBox ); | 322 | mRightFrame = new QWidgetStack( rightBox ); |
323 | rightLayout->addWidget( mNavigatorBar ); | 323 | rightLayout->addWidget( mNavigatorBar ); |
324 | rightLayout->addWidget( mRightFrame, 10 ); | 324 | rightLayout->addWidget( mRightFrame, 10 ); |
325 | 325 | ||
326 | mLeftFrame = leftFrame; | 326 | mLeftFrame = leftFrame; |
327 | if ( KOPrefs::instance()->mVerticalScreen ) { | 327 | if ( KOPrefs::instance()->mVerticalScreen ) { |
328 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 328 | mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
329 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 329 | leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
330 | } else { | 330 | } else { |
331 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 331 | mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
332 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 332 | leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
333 | } | 333 | } |
334 | 334 | ||
335 | //qDebug("Calendarview Size %d %d ", width(), height()); | 335 | //qDebug("Calendarview Size %d %d ", width(), height()); |
336 | #endif | 336 | #endif |
337 | 337 | ||
338 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 338 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
339 | SLOT( showDates( const KCal::DateList & ) ) ); | 339 | SLOT( showDates( const KCal::DateList & ) ) ); |
340 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 340 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
341 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 341 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
342 | 342 | ||
343 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), | 343 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), |
344 | mNavigator, SLOT( selectPreviousYear() ) ); | 344 | mNavigator, SLOT( selectPreviousYear() ) ); |
345 | connect( mNavigatorBar, SIGNAL( goNextYear() ), | 345 | connect( mNavigatorBar, SIGNAL( goNextYear() ), |
346 | mNavigator, SLOT( selectNextYear() ) ); | 346 | mNavigator, SLOT( selectNextYear() ) ); |
347 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), | 347 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), |
348 | mNavigator, SLOT( selectPreviousMonth() ) ); | 348 | mNavigator, SLOT( selectPreviousMonth() ) ); |
349 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), | 349 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), |
350 | mNavigator, SLOT( selectNextMonth() ) ); | 350 | mNavigator, SLOT( selectNextMonth() ) ); |
351 | 351 | ||
352 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 352 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
353 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); | 353 | mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); |
354 | 354 | ||
355 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 355 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
356 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 356 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
357 | 357 | ||
358 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 358 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
359 | mNavigator, SLOT( selectPreviousYear() ) ); | 359 | mNavigator, SLOT( selectPreviousYear() ) ); |
360 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 360 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
361 | mNavigator, SLOT( selectNextYear() ) ); | 361 | mNavigator, SLOT( selectNextYear() ) ); |
362 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 362 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
363 | mNavigator, SLOT( selectPreviousMonth() ) ); | 363 | mNavigator, SLOT( selectPreviousMonth() ) ); |
364 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 364 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
365 | mNavigator, SLOT( selectNextMonth() ) ); | 365 | mNavigator, SLOT( selectNextMonth() ) ); |
366 | 366 | ||
367 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 367 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
368 | mNavigator, SLOT( selectPrevious() ) ); | 368 | mNavigator, SLOT( selectPrevious() ) ); |
369 | connect( mDateNavigator, SIGNAL( goNext() ), | 369 | connect( mDateNavigator, SIGNAL( goNext() ), |
370 | mNavigator, SLOT( selectNext() ) ); | 370 | mNavigator, SLOT( selectNext() ) ); |
371 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 371 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
372 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 372 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
373 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), | 373 | connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), |
374 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 374 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
375 | 375 | ||
376 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 376 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
377 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 377 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
378 | 378 | ||
379 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), | 379 | connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), |
380 | SLOT( eventAdded( Event *) ) ); | 380 | SLOT( eventAdded( Event *) ) ); |
381 | 381 | ||
382 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 382 | connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
383 | 383 | ||
384 | connect( this, SIGNAL( configChanged() ), | 384 | connect( this, SIGNAL( configChanged() ), |
385 | mDateNavigator, SLOT( updateConfig() ) ); | 385 | mDateNavigator, SLOT( updateConfig() ) ); |
386 | 386 | ||
387 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 387 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
388 | SLOT( newTodo() ) ); | 388 | SLOT( newTodo() ) ); |
389 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 389 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
390 | SLOT( newSubTodo( Todo * ) ) ); | 390 | SLOT( newSubTodo( Todo * ) ) ); |
391 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 391 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
392 | SLOT( editTodo( Todo * ) ) ); | 392 | SLOT( editTodo( Todo * ) ) ); |
393 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 393 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
394 | SLOT( showTodo( Todo *) ) ); | 394 | SLOT( showTodo( Todo *) ) ); |
395 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 395 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
396 | SLOT( deleteTodo( Todo *) ) ); | 396 | SLOT( deleteTodo( Todo *) ) ); |
397 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 397 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
398 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 398 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
399 | SLOT( purgeCompleted() ) ); | 399 | SLOT( purgeCompleted() ) ); |
400 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 400 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
401 | SIGNAL( todoModified( Todo *, int ) ) ); | 401 | SIGNAL( todoModified( Todo *, int ) ) ); |
402 | 402 | ||
403 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 403 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
404 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 404 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
405 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 405 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
406 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 406 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
407 | 407 | ||
408 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 408 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
409 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 409 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
410 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 410 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
411 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 411 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
412 | 412 | ||
413 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 413 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
414 | this, SLOT ( todo_unsub( Todo * ) ) ); | 414 | this, SLOT ( todo_unsub( Todo * ) ) ); |
415 | 415 | ||
416 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 416 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
417 | SLOT( updateTodo( Todo *, int ) ) ); | 417 | SLOT( updateTodo( Todo *, int ) ) ); |
418 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 418 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
419 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 419 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
420 | 420 | ||
421 | 421 | ||
422 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 422 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
423 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 423 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
424 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 424 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
425 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 425 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
426 | 426 | ||
427 | 427 | ||
428 | 428 | ||
429 | 429 | ||
430 | 430 | ||
431 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 431 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
432 | SLOT(checkClipboard())); | 432 | SLOT(checkClipboard())); |
433 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 433 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
434 | SLOT( processTodoListSelection( Incidence * ) ) ); | 434 | SLOT( processTodoListSelection( Incidence * ) ) ); |
435 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 435 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
436 | 436 | ||
437 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 437 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
438 | 438 | ||
439 | mDateFrame = new QVBox(0,0,WType_Popup); | 439 | mDateFrame = new QVBox(0,0,WType_Popup); |
440 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 440 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
441 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 441 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
442 | mDateFrame->setLineWidth(3); | 442 | mDateFrame->setLineWidth(3); |
443 | mDateFrame->hide(); | 443 | mDateFrame->hide(); |
444 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 444 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
445 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 445 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
446 | 446 | ||
447 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 447 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
448 | 448 | ||
449 | mEventEditor = mDialogManager->getEventEditor(); | 449 | mEventEditor = mDialogManager->getEventEditor(); |
450 | mTodoEditor = mDialogManager->getTodoEditor(); | 450 | mTodoEditor = mDialogManager->getTodoEditor(); |
451 | 451 | ||
452 | mFlagEditDescription = false; | 452 | mFlagEditDescription = false; |
453 | 453 | ||
454 | mSuspendTimer = new QTimer( this ); | 454 | mSuspendTimer = new QTimer( this ); |
455 | mAlarmTimer = new QTimer( this ); | 455 | mAlarmTimer = new QTimer( this ); |
456 | mRecheckAlarmTimer = new QTimer( this ); | 456 | mRecheckAlarmTimer = new QTimer( this ); |
457 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 457 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
458 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 458 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
459 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 459 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
460 | mAlarmDialog = new AlarmDialog( this ); | 460 | mAlarmDialog = new AlarmDialog( this ); |
461 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 461 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
462 | mAlarmDialog->setServerNotification( false ); | 462 | mAlarmDialog->setServerNotification( false ); |
463 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 463 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
464 | } | 464 | } |
465 | 465 | ||
466 | 466 | ||
467 | CalendarView::~CalendarView() | 467 | CalendarView::~CalendarView() |
468 | { | 468 | { |
469 | // kdDebug() << "~CalendarView()" << endl; | 469 | // kdDebug() << "~CalendarView()" << endl; |
470 | //qDebug("CalendarView::~CalendarView() "); | 470 | //qDebug("CalendarView::~CalendarView() "); |
471 | delete mDialogManager; | 471 | delete mDialogManager; |
472 | delete mViewManager; | 472 | delete mViewManager; |
473 | delete mStorage; | 473 | delete mStorage; |
474 | delete mDateFrame ; | 474 | delete mDateFrame ; |
475 | delete beamDialog; | 475 | delete beamDialog; |
476 | //kdDebug() << "~CalendarView() done" << endl; | 476 | //kdDebug() << "~CalendarView() done" << endl; |
477 | } | 477 | } |
478 | void CalendarView::timerAlarm() | 478 | void CalendarView::timerAlarm() |
479 | { | 479 | { |
480 | //qDebug("CalendarView::timerAlarm() "); | 480 | //qDebug("CalendarView::timerAlarm() "); |
481 | computeAlarm(mAlarmNotification ); | 481 | computeAlarm(mAlarmNotification ); |
482 | } | 482 | } |
483 | 483 | ||
484 | void CalendarView::suspendAlarm() | 484 | void CalendarView::suspendAlarm() |
485 | { | 485 | { |
486 | //qDebug(" CalendarView::suspendAlarm() "); | 486 | //qDebug(" CalendarView::suspendAlarm() "); |
487 | computeAlarm(mSuspendAlarmNotification ); | 487 | computeAlarm(mSuspendAlarmNotification ); |
488 | 488 | ||
489 | } | 489 | } |
490 | 490 | ||
491 | void CalendarView::startAlarm( QString mess , QString filename) | 491 | void CalendarView::startAlarm( QString mess , QString filename) |
492 | { | 492 | { |
493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 493 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 494 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
495 | 495 | ||
496 | } | 496 | } |
497 | 497 | ||
498 | void CalendarView::checkNextTimerAlarm() | 498 | void CalendarView::checkNextTimerAlarm() |
499 | { | 499 | { |
500 | mCalendar->checkAlarmForIncidence( 0, true ); | 500 | mCalendar->checkAlarmForIncidence( 0, true ); |
501 | } | 501 | } |
502 | 502 | ||
503 | void CalendarView::computeAlarm( QString msg ) | 503 | void CalendarView::computeAlarm( QString msg ) |
504 | { | 504 | { |
505 | 505 | ||
506 | QString mess = msg; | 506 | QString mess = msg; |
507 | QString mAlarmMessage = mess.mid( 9 ); | 507 | QString mAlarmMessage = mess.mid( 9 ); |
508 | QString filename = MainWindow::resourcePath(); | 508 | QString filename = MainWindow::resourcePath(); |
509 | filename += "koalarm.wav"; | 509 | filename += "koalarm.wav"; |
510 | QString tempfilename; | 510 | QString tempfilename; |
511 | if ( mess.left( 13 ) == "suspend_alarm") { | 511 | if ( mess.left( 13 ) == "suspend_alarm") { |
512 | bool error = false; | 512 | bool error = false; |
513 | int len = mess.mid( 13 ).find("+++"); | 513 | int len = mess.mid( 13 ).find("+++"); |
514 | if ( len < 2 ) | 514 | if ( len < 2 ) |
515 | error = true; | 515 | error = true; |
516 | else { | 516 | else { |
517 | tempfilename = mess.mid( 13, len ); | 517 | tempfilename = mess.mid( 13, len ); |
518 | if ( !QFile::exists( tempfilename ) ) | 518 | if ( !QFile::exists( tempfilename ) ) |
519 | error = true; | 519 | error = true; |
520 | } | 520 | } |
521 | if ( ! error ) { | 521 | if ( ! error ) { |
522 | filename = tempfilename; | 522 | filename = tempfilename; |
523 | } | 523 | } |
524 | mAlarmMessage = mess.mid( 13+len+3 ); | 524 | mAlarmMessage = mess.mid( 13+len+3 ); |
525 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 525 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
526 | startAlarm( mAlarmMessage, filename); | 526 | startAlarm( mAlarmMessage, filename); |
527 | return; | 527 | return; |
528 | } | 528 | } |
529 | if ( mess.left( 11 ) == "timer_alarm") { | 529 | if ( mess.left( 11 ) == "timer_alarm") { |
530 | //mTimerTime = 0; | 530 | //mTimerTime = 0; |
531 | startAlarm( mess.mid( 11 ), filename ); | 531 | startAlarm( mess.mid( 11 ), filename ); |
532 | return; | 532 | return; |
533 | } | 533 | } |
534 | if ( mess.left( 10 ) == "proc_alarm") { | 534 | if ( mess.left( 10 ) == "proc_alarm") { |
535 | bool error = false; | 535 | bool error = false; |
536 | int len = mess.mid( 10 ).find("+++"); | 536 | int len = mess.mid( 10 ).find("+++"); |
537 | if ( len < 2 ) | 537 | if ( len < 2 ) |
538 | error = true; | 538 | error = true; |
539 | else { | 539 | else { |
540 | tempfilename = mess.mid( 10, len ); | 540 | tempfilename = mess.mid( 10, len ); |
541 | if ( !QFile::exists( tempfilename ) ) | 541 | if ( !QFile::exists( tempfilename ) ) |
542 | error = true; | 542 | error = true; |
543 | } | 543 | } |
544 | if ( error ) { | 544 | if ( error ) { |
545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 545 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
546 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 546 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
547 | } else { | 547 | } else { |
548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 548 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
549 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 549 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
550 | #ifndef _WIN32_ | 550 | #ifndef _WIN32_ |
551 | if ( vfork () == 0 ) { | 551 | if ( vfork () == 0 ) { |
552 | execl ( tempfilename.latin1(), 0 ); | 552 | execl ( tempfilename.latin1(), 0 ); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | #else | 555 | #else |
556 | QProcess* p = new QProcess(); | 556 | QProcess* p = new QProcess(); |
557 | p->addArgument( tempfilename.latin1() ); | 557 | p->addArgument( tempfilename.latin1() ); |
558 | p->start(); | 558 | p->start(); |
559 | return; | 559 | return; |
560 | #endif | 560 | #endif |
561 | 561 | ||
562 | return; | 562 | return; |
563 | } | 563 | } |
564 | 564 | ||
565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 565 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
566 | } | 566 | } |
567 | if ( mess.left( 11 ) == "audio_alarm") { | 567 | if ( mess.left( 11 ) == "audio_alarm") { |
568 | bool error = false; | 568 | bool error = false; |
569 | int len = mess.mid( 11 ).find("+++"); | 569 | int len = mess.mid( 11 ).find("+++"); |
570 | if ( len < 2 ) | 570 | if ( len < 2 ) |
571 | error = true; | 571 | error = true; |
572 | else { | 572 | else { |
573 | tempfilename = mess.mid( 11, len ); | 573 | tempfilename = mess.mid( 11, len ); |
574 | if ( !QFile::exists( tempfilename ) ) | 574 | if ( !QFile::exists( tempfilename ) ) |
575 | error = true; | 575 | error = true; |
576 | } | 576 | } |
577 | if ( ! error ) { | 577 | if ( ! error ) { |
578 | filename = tempfilename; | 578 | filename = tempfilename; |
579 | } | 579 | } |
580 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 580 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
581 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 581 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 9 ) == "cal_alarm") { | 583 | if ( mess.left( 9 ) == "cal_alarm") { |
584 | mAlarmMessage = mess.mid( 9 ) ; | 584 | mAlarmMessage = mess.mid( 9 ) ; |
585 | } | 585 | } |
586 | 586 | ||
587 | startAlarm( mAlarmMessage, filename ); | 587 | startAlarm( mAlarmMessage, filename ); |
588 | 588 | ||
589 | 589 | ||
590 | } | 590 | } |
591 | 591 | ||
592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 592 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
593 | { | 593 | { |
594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 594 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
595 | 595 | ||
596 | mSuspendAlarmNotification = noti; | 596 | mSuspendAlarmNotification = noti; |
597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 597 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 598 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
599 | mSuspendTimer->start( ms , true ); | 599 | mSuspendTimer->start( ms , true ); |
600 | 600 | ||
601 | } | 601 | } |
602 | 602 | ||
603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 603 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
604 | { | 604 | { |
605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 605 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 606 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
607 | #ifndef DESKTOP_VERSION | 607 | #ifndef DESKTOP_VERSION |
608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 608 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
609 | #endif | 609 | #endif |
610 | return; | 610 | return; |
611 | } | 611 | } |
612 | int maxSec; | 612 | int maxSec; |
613 | //maxSec = 5; //testing only | 613 | //maxSec = 5; //testing only |
614 | maxSec = 86400+3600; // one day+1hour | 614 | maxSec = 86400+3600; // one day+1hour |
615 | mAlarmNotification = noti; | 615 | mAlarmNotification = noti; |
616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 616 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
617 | if ( sec > maxSec ) { | 617 | if ( sec > maxSec ) { |
618 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 618 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 619 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
620 | return; | 620 | return; |
621 | } else { | 621 | } else { |
622 | mRecheckAlarmTimer->stop(); | 622 | mRecheckAlarmTimer->stop(); |
623 | } | 623 | } |
624 | //qDebug("Alarm timer started with secs: %d ", sec); | 624 | //qDebug("Alarm timer started with secs: %d ", sec); |
625 | mAlarmTimer->start( sec *1000 , true ); | 625 | mAlarmTimer->start( sec *1000 , true ); |
626 | 626 | ||
627 | } | 627 | } |
628 | // called by mRecheckAlarmTimer to get next alarm | 628 | // called by mRecheckAlarmTimer to get next alarm |
629 | // we need this, because a QTimer has only a max range of 25 days | 629 | // we need this, because a QTimer has only a max range of 25 days |
630 | void CalendarView::recheckTimerAlarm() | 630 | void CalendarView::recheckTimerAlarm() |
631 | { | 631 | { |
632 | mAlarmTimer->stop(); | 632 | mAlarmTimer->stop(); |
633 | mRecheckAlarmTimer->stop(); | 633 | mRecheckAlarmTimer->stop(); |
634 | mCalendar->checkAlarmForIncidence( 0, true ); | 634 | mCalendar->checkAlarmForIncidence( 0, true ); |
635 | } | 635 | } |
636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 636 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
637 | { | 637 | { |
638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 638 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 639 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
640 | #ifndef DESKTOP_VERSION | 640 | #ifndef DESKTOP_VERSION |
641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 641 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
642 | #endif | 642 | #endif |
643 | return; | 643 | return; |
644 | } | 644 | } |
645 | mAlarmTimer->stop(); | 645 | mAlarmTimer->stop(); |
646 | } | 646 | } |
647 | void CalendarView::selectWeekNum ( int num ) | 647 | void CalendarView::selectWeekNum ( int num ) |
648 | { | 648 | { |
649 | dateNavigator()->selectWeek( num ); | 649 | dateNavigator()->selectWeek( num ); |
650 | mViewManager->showWeekView(); | 650 | mViewManager->showWeekView(); |
651 | } | 651 | } |
652 | KOViewManager *CalendarView::viewManager() | 652 | KOViewManager *CalendarView::viewManager() |
653 | { | 653 | { |
654 | return mViewManager; | 654 | return mViewManager; |
655 | } | 655 | } |
656 | 656 | ||
657 | KODialogManager *CalendarView::dialogManager() | 657 | KODialogManager *CalendarView::dialogManager() |
658 | { | 658 | { |
659 | return mDialogManager; | 659 | return mDialogManager; |
660 | } | 660 | } |
661 | 661 | ||
662 | QDate CalendarView::startDate() | 662 | QDate CalendarView::startDate() |
663 | { | 663 | { |
664 | DateList dates = mNavigator->selectedDates(); | 664 | DateList dates = mNavigator->selectedDates(); |
665 | 665 | ||
666 | return dates.first(); | 666 | return dates.first(); |
667 | } | 667 | } |
668 | 668 | ||
669 | QDate CalendarView::endDate() | 669 | QDate CalendarView::endDate() |
670 | { | 670 | { |
671 | DateList dates = mNavigator->selectedDates(); | 671 | DateList dates = mNavigator->selectedDates(); |
672 | 672 | ||
673 | return dates.last(); | 673 | return dates.last(); |
674 | } | 674 | } |
675 | 675 | ||
676 | 676 | ||
677 | void CalendarView::createPrinter() | 677 | void CalendarView::createPrinter() |
678 | { | 678 | { |
679 | #ifndef KORG_NOPRINTER | 679 | #ifndef KORG_NOPRINTER |
680 | if (!mCalPrinter) { | 680 | if (!mCalPrinter) { |
681 | mCalPrinter = new CalPrinter(this, mCalendar); | 681 | mCalPrinter = new CalPrinter(this, mCalendar); |
682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 682 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
683 | } | 683 | } |
684 | #endif | 684 | #endif |
685 | } | 685 | } |
686 | 686 | ||
687 | void CalendarView::confSync() | 687 | void CalendarView::confSync() |
688 | { | 688 | { |
689 | static KOSyncPrefsDialog* sp = 0; | 689 | static KOSyncPrefsDialog* sp = 0; |
690 | if ( ! sp ) { | 690 | if ( ! sp ) { |
691 | sp = new KOSyncPrefsDialog( this, "syncprefs", true ); | 691 | sp = new KOSyncPrefsDialog( this, "syncprefs", true ); |
692 | } | 692 | } |
693 | sp->usrReadConfig(); | 693 | sp->usrReadConfig(); |
694 | #ifndef DESKTOP_VERSION | 694 | #ifndef DESKTOP_VERSION |
695 | sp->showMaximized(); | 695 | sp->showMaximized(); |
696 | #else | 696 | #else |
697 | sp->show(); | 697 | sp->show(); |
698 | #endif | 698 | #endif |
699 | sp->exec(); | 699 | sp->exec(); |
700 | 700 | ||
701 | } | 701 | } |
702 | 702 | ||
703 | 703 | ||
704 | //KOPrefs::instance()->mWriteBackFile | 704 | //KOPrefs::instance()->mWriteBackFile |
705 | //KOPrefs::instance()->mWriteBackExistingOnly | 705 | //KOPrefs::instance()->mWriteBackExistingOnly |
706 | 706 | ||
707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 707 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 708 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 709 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 710 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 711 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 712 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
713 | 713 | ||
714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 714 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
715 | { | 715 | { |
716 | 716 | ||
717 | //void setZaurusId(int id); | 717 | //void setZaurusId(int id); |
718 | // int zaurusId() const; | 718 | // int zaurusId() const; |
719 | // void setZaurusUid(int id); | 719 | // void setZaurusUid(int id); |
720 | // int zaurusUid() const; | 720 | // int zaurusUid() const; |
721 | // void setZaurusStat(int id); | 721 | // void setZaurusStat(int id); |
722 | // int zaurusStat() const; | 722 | // int zaurusStat() const; |
723 | // 0 equal | 723 | // 0 equal |
724 | // 1 take local | 724 | // 1 take local |
725 | // 2 take remote | 725 | // 2 take remote |
726 | // 3 cancel | 726 | // 3 cancel |
727 | QDateTime lastSync = mLastCalendarSync; | 727 | QDateTime lastSync = mLastCalendarSync; |
728 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 728 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
729 | bool remCh, locCh; | 729 | bool remCh, locCh; |
730 | remCh = ( remote->zaurusUid() != local->zaurusUid() ); | 730 | remCh = ( remote->zaurusUid() != local->zaurusUid() ); |
731 | locCh = ( local->lastModified() > mLastCalendarSync ); | 731 | locCh = ( local->lastModified() > mLastCalendarSync ); |
732 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); | 732 | //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); |
733 | if ( !remCh && ! locCh ) { | 733 | if ( !remCh && ! locCh ) { |
734 | //qDebug("both not changed "); | 734 | //qDebug("both not changed "); |
735 | lastSync = local->lastModified().addDays(1); | 735 | lastSync = local->lastModified().addDays(1); |
736 | } else { | 736 | } else { |
737 | if ( locCh ) { | 737 | if ( locCh ) { |
738 | //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); | 738 | //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); |
739 | lastSync = local->lastModified().addDays( -1 ); | 739 | lastSync = local->lastModified().addDays( -1 ); |
740 | if ( !remCh ) | 740 | if ( !remCh ) |
741 | remote->setLastModified( lastSync.addDays( -1 ) ); | 741 | remote->setLastModified( lastSync.addDays( -1 ) ); |
742 | } else { | 742 | } else { |
743 | //qDebug(" not loc changed "); | 743 | //qDebug(" not loc changed "); |
744 | lastSync = local->lastModified().addDays( 1 ); | 744 | lastSync = local->lastModified().addDays( 1 ); |
745 | if ( remCh ) | 745 | if ( remCh ) |
746 | remote->setLastModified( lastSync.addDays( 1 ) ); | 746 | remote->setLastModified( lastSync.addDays( 1 ) ); |
747 | 747 | ||
748 | } | 748 | } |
749 | } | 749 | } |
750 | full = true; | 750 | full = true; |
751 | if ( mode < SYNC_PREF_ASK ) | 751 | if ( mode < SYNC_PREF_ASK ) |
752 | mode = SYNC_PREF_ASK; | 752 | mode = SYNC_PREF_ASK; |
753 | } else { | 753 | } else { |
754 | if ( local->lastModified() == remote->lastModified() ) | 754 | if ( local->lastModified() == remote->lastModified() ) |
755 | if ( local->revision() == remote->revision() ) | 755 | if ( local->revision() == remote->revision() ) |
756 | return 0; | 756 | return 0; |
757 | 757 | ||
758 | } | 758 | } |
759 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 759 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
760 | 760 | ||
761 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); | 761 | //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); |
762 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); | 762 | //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); |
763 | //full = true; //debug only | 763 | //full = true; //debug only |
764 | if ( full ) { | 764 | if ( full ) { |
765 | bool equ = false; | 765 | bool equ = false; |
766 | if ( local->type() == "Event" ) { | 766 | if ( local->type() == "Event" ) { |
767 | equ = (*((Event*) local) == *((Event*) remote)); | 767 | equ = (*((Event*) local) == *((Event*) remote)); |
768 | } | 768 | } |
769 | else if ( local->type() =="Todo" ) | 769 | else if ( local->type() =="Todo" ) |
770 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 770 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
771 | else if ( local->type() =="Journal" ) | 771 | else if ( local->type() =="Journal" ) |
772 | equ = (*((Journal*) local) == *((Journal*) remote)); | 772 | equ = (*((Journal*) local) == *((Journal*) remote)); |
773 | if ( equ ) { | 773 | if ( equ ) { |
774 | //qDebug("equal "); | 774 | //qDebug("equal "); |
775 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 775 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
776 | local->setZaurusUid( remote->zaurusUid() ); | 776 | local->setZaurusUid( remote->zaurusUid() ); |
777 | } | 777 | } |
778 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 778 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
779 | return 0; | 779 | return 0; |
780 | 780 | ||
781 | }//else //debug only | 781 | }//else //debug only |
782 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 782 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
783 | } | 783 | } |
784 | int result; | 784 | int result; |
785 | bool localIsNew; | 785 | bool localIsNew; |
786 | if ( full && mode < SYNC_PREF_NEWEST ) | 786 | if ( full && mode < SYNC_PREF_NEWEST ) |
787 | mode = SYNC_PREF_ASK; | 787 | mode = SYNC_PREF_ASK; |
788 | 788 | ||
789 | switch( mode ) { | 789 | switch( mode ) { |
790 | case SYNC_PREF_LOCAL: | 790 | case SYNC_PREF_LOCAL: |
791 | if ( lastSync > remote->lastModified() ) | 791 | if ( lastSync > remote->lastModified() ) |
792 | return 1; | 792 | return 1; |
793 | if ( lastSync > local->lastModified() ) | 793 | if ( lastSync > local->lastModified() ) |
794 | return 2; | 794 | return 2; |
795 | return 1; | 795 | return 1; |
796 | break; | 796 | break; |
797 | case SYNC_PREF_REMOTE: | 797 | case SYNC_PREF_REMOTE: |
798 | if ( lastSync > remote->lastModified() ) | 798 | if ( lastSync > remote->lastModified() ) |
799 | return 1; | 799 | return 1; |
800 | if ( lastSync > local->lastModified() ) | 800 | if ( lastSync > local->lastModified() ) |
801 | return 2; | 801 | return 2; |
802 | return 2; | 802 | return 2; |
803 | break; | 803 | break; |
804 | case SYNC_PREF_NEWEST: | 804 | case SYNC_PREF_NEWEST: |
805 | if ( local->lastModified() > remote->lastModified() ) | 805 | if ( local->lastModified() > remote->lastModified() ) |
806 | return 1; | 806 | return 1; |
807 | else | 807 | else |
808 | return 2; | 808 | return 2; |
809 | break; | 809 | break; |
810 | case SYNC_PREF_ASK: | 810 | case SYNC_PREF_ASK: |
811 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 811 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
812 | if ( lastSync > remote->lastModified() ) | 812 | if ( lastSync > remote->lastModified() ) |
813 | return 1; | 813 | return 1; |
814 | if ( lastSync > local->lastModified() ) | 814 | if ( lastSync > local->lastModified() ) |
815 | return 2; | 815 | return 2; |
816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); | 816 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); |
817 | localIsNew = local->lastModified() > remote->lastModified(); | 817 | localIsNew = local->lastModified() > remote->lastModified(); |
818 | if ( localIsNew ) | 818 | if ( localIsNew ) |
819 | getEventViewerDialog()->setColorMode( 1 ); | 819 | getEventViewerDialog()->setColorMode( 1 ); |
820 | else | 820 | else |
821 | getEventViewerDialog()->setColorMode( 2 ); | 821 | getEventViewerDialog()->setColorMode( 2 ); |
822 | getEventViewerDialog()->setIncidence(local); | 822 | getEventViewerDialog()->setIncidence(local); |
823 | if ( localIsNew ) | 823 | if ( localIsNew ) |
824 | getEventViewerDialog()->setColorMode( 2 ); | 824 | getEventViewerDialog()->setColorMode( 2 ); |
825 | else | 825 | else |
826 | getEventViewerDialog()->setColorMode( 1 ); | 826 | getEventViewerDialog()->setColorMode( 1 ); |
827 | getEventViewerDialog()->addIncidence(remote); | 827 | getEventViewerDialog()->addIncidence(remote); |
828 | getEventViewerDialog()->setColorMode( 0 ); | 828 | getEventViewerDialog()->setColorMode( 0 ); |
829 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 829 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
830 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 830 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
831 | getEventViewerDialog()->showMe(); | 831 | getEventViewerDialog()->showMe(); |
832 | result = getEventViewerDialog()->executeS( localIsNew ); | 832 | result = getEventViewerDialog()->executeS( localIsNew ); |
833 | return result; | 833 | return result; |
834 | 834 | ||
835 | break; | 835 | break; |
836 | case SYNC_PREF_FORCE_LOCAL: | 836 | case SYNC_PREF_FORCE_LOCAL: |
837 | return 1; | 837 | return 1; |
838 | break; | 838 | break; |
839 | case SYNC_PREF_FORCE_REMOTE: | 839 | case SYNC_PREF_FORCE_REMOTE: |
840 | return 2; | 840 | return 2; |
841 | break; | 841 | break; |
842 | 842 | ||
843 | default: | 843 | default: |
844 | // SYNC_PREF_TAKE_BOTH not implemented | 844 | // SYNC_PREF_TAKE_BOTH not implemented |
845 | break; | 845 | break; |
846 | } | 846 | } |
847 | return 0; | 847 | return 0; |
848 | } | 848 | } |
849 | Event* CalendarView::getLastSyncEvent() | 849 | Event* CalendarView::getLastSyncEvent() |
850 | { | 850 | { |
851 | Event* lse; | 851 | Event* lse; |
852 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 852 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
853 | lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); | 853 | lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); |
854 | if (!lse) { | 854 | if (!lse) { |
855 | lse = new Event(); | 855 | lse = new Event(); |
856 | lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); | 856 | lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); |
857 | lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); | 857 | lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); |
858 | lse->setDtStart( mLastCalendarSync ); | 858 | lse->setDtStart( mLastCalendarSync ); |
859 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 859 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
860 | lse->setCategories( i18n("SyncEvent") ); | 860 | lse->setCategories( i18n("SyncEvent") ); |
861 | lse->setReadOnly( true ); | 861 | lse->setReadOnly( true ); |
862 | mCalendar->addEvent( lse ); | 862 | mCalendar->addEvent( lse ); |
863 | } | 863 | } |
864 | 864 | ||
865 | return lse; | 865 | return lse; |
866 | 866 | ||
867 | } | 867 | } |
868 | void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) | 868 | void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) |
869 | { | 869 | { |
870 | if ( ! lastSync ) | 870 | if ( ! lastSync ) |
871 | return; | 871 | return; |
872 | if ( toDelete->zaurusId() < 0 ) | 872 | if ( toDelete->zaurusId() < 0 ) |
873 | return; | 873 | return; |
874 | if ( toDelete->type() == "Journal" ) | 874 | if ( toDelete->type() == "Journal" ) |
875 | return; | 875 | return; |
876 | QString des = lastSync->description(); | 876 | QString des = lastSync->description(); |
877 | QString pref = "e"; | 877 | QString pref = "e"; |
878 | if ( toDelete->type() == "Todo" ) | 878 | if ( toDelete->type() == "Todo" ) |
879 | pref = "t"; | 879 | pref = "t"; |
880 | des += pref+ QString::number ( toDelete->zaurusId() ) + ","; | 880 | des += pref+ QString::number ( toDelete->zaurusId() ) + ","; |
881 | lastSync->setReadOnly( false ); | 881 | lastSync->setReadOnly( false ); |
882 | lastSync->setDescription( des ); | 882 | lastSync->setDescription( des ); |
883 | lastSync->setReadOnly( true ); | 883 | lastSync->setReadOnly( true ); |
884 | 884 | ||
885 | } | 885 | } |
886 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 886 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
887 | { | 887 | { |
888 | bool syncOK = true; | 888 | bool syncOK = true; |
889 | int addedEvent = 0; | 889 | int addedEvent = 0; |
890 | int addedEventR = 0; | 890 | int addedEventR = 0; |
891 | int deletedEventR = 0; | 891 | int deletedEventR = 0; |
892 | int deletedEventL = 0; | 892 | int deletedEventL = 0; |
893 | int changedLocal = 0; | 893 | int changedLocal = 0; |
894 | int changedRemote = 0; | 894 | int changedRemote = 0; |
895 | //QPtrList<Event> el = local->rawEvents(); | 895 | //QPtrList<Event> el = local->rawEvents(); |
896 | Event* eventR; | 896 | Event* eventR; |
897 | QString uid; | 897 | QString uid; |
898 | int take; | 898 | int take; |
899 | Event* eventL; | 899 | Event* eventL; |
900 | Event* eventRSync; | 900 | Event* eventRSync; |
901 | Event* eventLSync; | 901 | Event* eventLSync; |
902 | Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); | 902 | Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); |
903 | Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); | 903 | Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); |
904 | bool fullDateRange = false; | 904 | bool fullDateRange = false; |
905 | mLastCalendarSync = QDateTime::currentDateTime(); | 905 | mLastCalendarSync = QDateTime::currentDateTime(); |
906 | QDateTime modifiedCalendar = mLastCalendarSync;; | 906 | QDateTime modifiedCalendar = mLastCalendarSync;; |
907 | eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); | 907 | eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); |
908 | if ( eventR ) { | 908 | if ( eventR ) { |
909 | eventRSync = (Event*) eventR->clone(); | 909 | eventRSync = (Event*) eventR->clone(); |
910 | remote->deleteEvent(eventR ); | 910 | remote->deleteEvent(eventR ); |
911 | 911 | ||
912 | } else { | 912 | } else { |
913 | fullDateRange = true; | 913 | fullDateRange = true; |
914 | eventRSync = new Event(); | 914 | eventRSync = new Event(); |
915 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 915 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
916 | eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); | 916 | eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); |
917 | eventRSync->setDtStart( mLastCalendarSync ); | 917 | eventRSync->setDtStart( mLastCalendarSync ); |
918 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 918 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
919 | eventRSync->setCategories( i18n("SyncEvent") ); | 919 | eventRSync->setCategories( i18n("SyncEvent") ); |
920 | } | 920 | } |
921 | eventLSync = getLastSyncEvent(); | 921 | eventLSync = getLastSyncEvent(); |
922 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 922 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
923 | fullDateRange = true; | 923 | fullDateRange = true; |
924 | 924 | ||
925 | if ( ! fullDateRange ) { | 925 | if ( ! fullDateRange ) { |
926 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 926 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
927 | 927 | ||
928 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 928 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
929 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 929 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
930 | fullDateRange = true; | 930 | fullDateRange = true; |
931 | } | 931 | } |
932 | } | 932 | } |
933 | if ( fullDateRange ) | 933 | if ( fullDateRange ) |
934 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 934 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
935 | else | 935 | else |
936 | mLastCalendarSync = eventLSync->dtStart(); | 936 | mLastCalendarSync = eventLSync->dtStart(); |
937 | // for resyncing if own file has changed | 937 | // for resyncing if own file has changed |
938 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 938 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
939 | mLastCalendarSync = loadedFileVersion; | 939 | mLastCalendarSync = loadedFileVersion; |
940 | qDebug("setting mLastCalendarSync "); | 940 | qDebug("setting mLastCalendarSync "); |
941 | } | 941 | } |
942 | //qDebug("*************************** "); | 942 | //qDebug("*************************** "); |
943 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 943 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
944 | QPtrList<Incidence> er = remote->rawIncidences(); | 944 | QPtrList<Incidence> er = remote->rawIncidences(); |
945 | Incidence* inR = er.first(); | 945 | Incidence* inR = er.first(); |
946 | Incidence* inL; | 946 | Incidence* inL; |
947 | QProgressBar bar( er.count(),0 ); | 947 | QProgressBar bar( er.count(),0 ); |
948 | bar.setCaption (i18n("Syncing - close to abort!") ); | 948 | bar.setCaption (i18n("Syncing - close to abort!") ); |
949 | 949 | ||
950 | int w = 300; | 950 | int w = 300; |
951 | if ( QApplication::desktop()->width() < 320 ) | 951 | if ( QApplication::desktop()->width() < 320 ) |
952 | w = 220; | 952 | w = 220; |
953 | int h = bar.sizeHint().height() ; | 953 | int h = bar.sizeHint().height() ; |
954 | int dw = QApplication::desktop()->width(); | 954 | int dw = QApplication::desktop()->width(); |
955 | int dh = QApplication::desktop()->height(); | 955 | int dh = QApplication::desktop()->height(); |
956 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 956 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
957 | bar.show(); | 957 | bar.show(); |
958 | int modulo = (er.count()/10)+1; | 958 | int modulo = (er.count()/10)+1; |
959 | int incCounter = 0; | 959 | int incCounter = 0; |
960 | while ( inR ) { | 960 | while ( inR ) { |
961 | if ( ! bar.isVisible() ) | 961 | if ( ! bar.isVisible() ) |
962 | return false; | 962 | return false; |
963 | if ( incCounter % modulo == 0 ) | 963 | if ( incCounter % modulo == 0 ) |
964 | bar.setProgress( incCounter ); | 964 | bar.setProgress( incCounter ); |
965 | ++incCounter; | 965 | ++incCounter; |
966 | uid = inR->uid(); | 966 | uid = inR->uid(); |
967 | bool skipIncidence = false; | 967 | bool skipIncidence = false; |
968 | if ( uid.left(21) == QString("last-syncEvent-device") ) | 968 | if ( uid.left(21) == QString("last-syncEvent-device") ) |
969 | skipIncidence = true; | 969 | skipIncidence = true; |
970 | 970 | ||
971 | qApp->processEvents(); | 971 | qApp->processEvents(); |
972 | if ( !skipIncidence ) { | 972 | if ( !skipIncidence ) { |
973 | inL = local->incidence( uid ); | 973 | inL = local->incidence( uid ); |
974 | if ( inL ) { // maybe conflict - same uid in both calendars | 974 | if ( inL ) { // maybe conflict - same uid in both calendars |
975 | int maxrev = inL->revision(); | 975 | int maxrev = inL->revision(); |
976 | if ( maxrev < inR->revision() ) | 976 | if ( maxrev < inR->revision() ) |
977 | maxrev = inR->revision(); | 977 | maxrev = inR->revision(); |
978 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 978 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
979 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 979 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
980 | if ( take == 3 ) | 980 | if ( take == 3 ) |
981 | return false; | 981 | return false; |
982 | if ( take == 1 ) {// take local | 982 | if ( take == 1 ) {// take local |
983 | inL->setZaurusUid( inR->zaurusUid() ); | 983 | inL->setZaurusUid( inR->zaurusUid() ); |
984 | remote->deleteIncidence( inR ); | 984 | remote->deleteIncidence( inR ); |
985 | if ( inL->revision() < maxrev ) | 985 | if ( inL->revision() < maxrev ) |
986 | inL->setRevision( maxrev ); | 986 | inL->setRevision( maxrev ); |
987 | remote->addIncidence( inL->clone() ); | 987 | remote->addIncidence( inL->clone() ); |
988 | ++changedRemote; | 988 | ++changedRemote; |
989 | } else { | 989 | } else { |
990 | if ( inR->revision() < maxrev ) | 990 | if ( inR->revision() < maxrev ) |
991 | inR->setRevision( maxrev ); | 991 | inR->setRevision( maxrev ); |
992 | local->deleteIncidence( inL ); | 992 | local->deleteIncidence( inL ); |
993 | local->addIncidence( inR->clone() ); | 993 | local->addIncidence( inR->clone() ); |
994 | ++changedLocal; | 994 | ++changedLocal; |
995 | } | 995 | } |
996 | } | 996 | } |
997 | } else { // no conflict | 997 | } else { // no conflict |
998 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 998 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
999 | QString des = eventLSync->description(); | 999 | QString des = eventLSync->description(); |
1000 | QString pref = "e"; | 1000 | QString pref = "e"; |
1001 | if ( inR->type() == "Todo" ) | 1001 | if ( inR->type() == "Todo" ) |
1002 | pref = "t"; | 1002 | pref = "t"; |
1003 | if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it | 1003 | if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it |
1004 | inR->setZaurusStat( SYNC_TEMPSTATE_DELETE ); | 1004 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1005 | //remote->deleteIncidence( inR ); | 1005 | //remote->deleteIncidence( inR ); |
1006 | ++deletedEventR; | 1006 | ++deletedEventR; |
1007 | } else { | 1007 | } else { |
1008 | inR->setLastModified( modifiedCalendar ); | 1008 | inR->setLastModified( modifiedCalendar ); |
1009 | local->addIncidence( inR->clone() ); | 1009 | local->addIncidence( inR->clone() ); |
1010 | ++addedEvent; | 1010 | ++addedEvent; |
1011 | } | 1011 | } |
1012 | } else { | 1012 | } else { |
1013 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1013 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1014 | inR->setLastModified( modifiedCalendar ); | 1014 | inR->setLastModified( modifiedCalendar ); |
1015 | local->addIncidence( inR->clone() ); | 1015 | local->addIncidence( inR->clone() ); |
1016 | ++addedEvent; | 1016 | ++addedEvent; |
1017 | } else { | 1017 | } else { |
1018 | checkSharpEvent(eventRSyncSharp, inR); | 1018 | checkSharpEvent(eventRSyncSharp, inR); |
1019 | remote->deleteIncidence( inR ); | 1019 | remote->deleteIncidence( inR ); |
1020 | ++deletedEventR; | 1020 | ++deletedEventR; |
1021 | } | 1021 | } |
1022 | } | 1022 | } |
1023 | } | 1023 | } |
1024 | } | 1024 | } |
1025 | inR = er.next(); | 1025 | inR = er.next(); |
1026 | } | 1026 | } |
1027 | QPtrList<Incidence> el = local->rawIncidences(); | 1027 | QPtrList<Incidence> el = local->rawIncidences(); |
1028 | inL = el.first(); | 1028 | inL = el.first(); |
1029 | modulo = (el.count()/10)+1; | 1029 | modulo = (el.count()/10)+1; |
1030 | bar.setCaption (i18n("Add / remove events") ); | 1030 | bar.setCaption (i18n("Add / remove events") ); |
1031 | bar.setTotalSteps ( el.count() ) ; | 1031 | bar.setTotalSteps ( el.count() ) ; |
1032 | bar.show(); | 1032 | bar.show(); |
1033 | incCounter = 0; | 1033 | incCounter = 0; |
1034 | 1034 | ||
1035 | while ( inL ) { | 1035 | while ( inL ) { |
1036 | 1036 | ||
1037 | qApp->processEvents(); | 1037 | qApp->processEvents(); |
1038 | if ( ! bar.isVisible() ) | 1038 | if ( ! bar.isVisible() ) |
1039 | return false; | 1039 | return false; |
1040 | if ( incCounter % modulo == 0 ) | 1040 | if ( incCounter % modulo == 0 ) |
1041 | bar.setProgress( incCounter ); | 1041 | bar.setProgress( incCounter ); |
1042 | ++incCounter; | 1042 | ++incCounter; |
1043 | uid = inL->uid(); | 1043 | uid = inL->uid(); |
1044 | bool skipIncidence = false; | 1044 | bool skipIncidence = false; |
1045 | if ( uid.left(21) == QString("last-syncEvent-device") ) | 1045 | if ( uid.left(21) == QString("last-syncEvent-device") ) |
1046 | skipIncidence = true; | 1046 | skipIncidence = true; |
1047 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1047 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1048 | skipIncidence = true; | 1048 | skipIncidence = true; |
1049 | if ( !skipIncidence ) { | 1049 | if ( !skipIncidence ) { |
1050 | inR = remote->incidence( uid ); | 1050 | inR = remote->incidence( uid ); |
1051 | if ( ! inR ) { | 1051 | if ( ! inR ) { |
1052 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1052 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1053 | if ( inL->zaurusId() >= 0 && mode != 4 ) { | 1053 | if ( inL->zaurusId() >= 0 && mode != 4 ) { |
1054 | local->deleteIncidence( inL ); | 1054 | local->deleteIncidence( inL ); |
1055 | ++deletedEventL; | 1055 | ++deletedEventL; |
1056 | } else { | 1056 | } else { |
1057 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1057 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1058 | inL->setZaurusId( -1 ); | 1058 | inL->setZaurusId( -1 ); |
1059 | ++addedEventR; | 1059 | ++addedEventR; |
1060 | inL->setLastModified( modifiedCalendar ); | 1060 | inL->setLastModified( modifiedCalendar ); |
1061 | remote->addIncidence( inL->clone() ); | 1061 | remote->addIncidence( inL->clone() ); |
1062 | } | 1062 | } |
1063 | } | 1063 | } |
1064 | } else { | 1064 | } else { |
1065 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1065 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1066 | checkSharpEvent(eventLSyncSharp, inL); | 1066 | checkSharpEvent(eventLSyncSharp, inL); |
1067 | local->deleteIncidence( inL ); | 1067 | local->deleteIncidence( inL ); |
1068 | ++deletedEventL; | 1068 | ++deletedEventL; |
1069 | } else { | 1069 | } else { |
1070 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { | 1070 | if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { |
1071 | ++addedEventR; | 1071 | ++addedEventR; |
1072 | inL->setLastModified( modifiedCalendar ); | 1072 | inL->setLastModified( modifiedCalendar ); |
1073 | remote->addIncidence( inL->clone() ); | 1073 | remote->addIncidence( inL->clone() ); |
1074 | } | 1074 | } |
1075 | } | 1075 | } |
1076 | } | 1076 | } |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | inL = el.next(); | 1079 | inL = el.next(); |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | bar.hide(); | 1082 | bar.hide(); |
1083 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1083 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1084 | eventLSync->setReadOnly( false ); | 1084 | eventLSync->setReadOnly( false ); |
1085 | eventLSync->setDtStart( mLastCalendarSync ); | 1085 | eventLSync->setDtStart( mLastCalendarSync ); |
1086 | eventRSync->setDtStart( mLastCalendarSync ); | 1086 | eventRSync->setDtStart( mLastCalendarSync ); |
1087 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1087 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1088 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1088 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1089 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1089 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1090 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1090 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1091 | eventLSync->setReadOnly( true ); | 1091 | eventLSync->setReadOnly( true ); |
1092 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1092 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) |
1093 | remote->addEvent( eventRSync ); | 1093 | remote->addEvent( eventRSync ); |
1094 | QString mes; | 1094 | QString mes; |
1095 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); | 1095 | mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); |
1096 | if ( KOPrefs::instance()->mShowSyncSummary ) { | 1096 | if ( KOPrefs::instance()->mShowSyncSummary ) { |
1097 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1097 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1098 | } | 1098 | } |
1099 | qDebug( mes ); | 1099 | qDebug( mes ); |
1100 | mCalendar->checkAlarmForIncidence( 0, true ); | 1100 | mCalendar->checkAlarmForIncidence( 0, true ); |
1101 | return syncOK; | 1101 | return syncOK; |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | void CalendarView::setSyncDevice( QString s ) | 1104 | void CalendarView::setSyncDevice( QString s ) |
1105 | { | 1105 | { |
1106 | mCurrentSyncDevice= s; | 1106 | mCurrentSyncDevice= s; |
1107 | } | 1107 | } |
1108 | void CalendarView::setSyncName( QString s ) | 1108 | void CalendarView::setSyncName( QString s ) |
1109 | { | 1109 | { |
1110 | mCurrentSyncName= s; | 1110 | mCurrentSyncName= s; |
1111 | } | 1111 | } |
1112 | bool CalendarView::syncCalendar(QString filename, int mode) | 1112 | bool CalendarView::syncCalendar(QString filename, int mode) |
1113 | { | 1113 | { |
1114 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1114 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1115 | CalendarLocal* calendar = new CalendarLocal(); | 1115 | CalendarLocal* calendar = new CalendarLocal(); |
1116 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1116 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1117 | FileStorage* storage = new FileStorage( calendar ); | 1117 | FileStorage* storage = new FileStorage( calendar ); |
1118 | bool syncOK = false; | 1118 | bool syncOK = false; |
1119 | storage->setFileName( filename ); | 1119 | storage->setFileName( filename ); |
1120 | // qDebug("loading ... "); | 1120 | // qDebug("loading ... "); |
1121 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1121 | if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1122 | getEventViewerDialog()->setSyncMode( true ); | 1122 | getEventViewerDialog()->setSyncMode( true ); |
1123 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1123 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1124 | getEventViewerDialog()->setSyncMode( false ); | 1124 | getEventViewerDialog()->setSyncMode( false ); |
1125 | if ( syncOK ) { | 1125 | if ( syncOK ) { |
1126 | if ( KOPrefs::instance()->mWriteBackFile ) | 1126 | if ( KOPrefs::instance()->mWriteBackFile ) |
1127 | { | 1127 | { |
1128 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1128 | storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1129 | storage->save(); | 1129 | storage->save(); |
1130 | } | 1130 | } |
1131 | } | 1131 | } |
1132 | setModified( true ); | 1132 | setModified( true ); |
1133 | } | 1133 | } |
1134 | delete storage; | 1134 | delete storage; |
1135 | delete calendar; | 1135 | delete calendar; |
1136 | if ( syncOK ) | 1136 | if ( syncOK ) |
1137 | updateView(); | 1137 | updateView(); |
1138 | return syncOK; | 1138 | return syncOK; |
1139 | } | 1139 | } |
1140 | void CalendarView::syncSharp() | 1140 | void CalendarView::syncSharp() |
1141 | { | 1141 | { |
1142 | #ifndef DESKTOP_VERSION | 1142 | #ifndef DESKTOP_VERSION |
1143 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1143 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1144 | //mCurrentSyncDevice = "sharp-DTM"; | 1144 | //mCurrentSyncDevice = "sharp-DTM"; |
1145 | if ( KOPrefs::instance()->mAskForPreferences ) | 1145 | if ( KOPrefs::instance()->mAskForPreferences ) |
1146 | edit_sync_options(); | 1146 | edit_sync_options(); |
1147 | qApp->processEvents(); | 1147 | qApp->processEvents(); |
1148 | CalendarLocal* calendar = new CalendarLocal(); | 1148 | CalendarLocal* calendar = new CalendarLocal(); |
1149 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1149 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1150 | bool syncOK = false; | 1150 | bool syncOK = false; |
1151 | SharpFormat sharpFormat; | 1151 | SharpFormat sharpFormat; |
1152 | if ( sharpFormat.load( calendar, mCalendar ) ) { | 1152 | if ( sharpFormat.load( calendar, mCalendar ) ) { |
1153 | getEventViewerDialog()->setSyncMode( true ); | 1153 | getEventViewerDialog()->setSyncMode( true ); |
1154 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1154 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1155 | getEventViewerDialog()->setSyncMode( false ); | 1155 | getEventViewerDialog()->setSyncMode( false ); |
1156 | qApp->processEvents(); | 1156 | qApp->processEvents(); |
1157 | if ( syncOK ) { | 1157 | if ( syncOK ) { |
1158 | if ( KOPrefs::instance()->mWriteBackFile ) | 1158 | if ( KOPrefs::instance()->mWriteBackFile ) |
1159 | { | 1159 | { |
1160 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1160 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1161 | Incidence* inc = iL.first(); | 1161 | Incidence* inc = iL.first(); |
1162 | /* obsolete | 1162 | /* obsolete |
1163 | while ( inc ) { | 1163 | while ( inc ) { |
1164 | inc->setZaurusStat( inc->revision () ); | 1164 | inc->setZaurusStat( inc->revision () ); |
1165 | inc = iL.next(); | 1165 | inc = iL.next(); |
1166 | } | 1166 | } |
1167 | */ | 1167 | */ |
1168 | // pending: clean last sync event description | 1168 | // pending: clean last sync event description |
1169 | sharpFormat.save(calendar); | 1169 | sharpFormat.save(calendar); |
1170 | iL = calendar->rawIncidences(); | 1170 | iL = calendar->rawIncidences(); |
1171 | inc = iL.first(); | 1171 | inc = iL.first(); |
1172 | Incidence* loc; | 1172 | Incidence* loc; |
1173 | while ( inc ) { | 1173 | while ( inc ) { |
1174 | if ( inc->zaurusStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1174 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1175 | loc = mCalendar->incidence(inc->uid() ); | 1175 | loc = mCalendar->incidence(inc->uid() ); |
1176 | if ( loc ) { | 1176 | if ( loc ) { |
1177 | loc->setZaurusId( inc->zaurusId() ); | 1177 | loc->setZaurusId( inc->zaurusId() ); |
1178 | loc->setZaurusUid( inc->zaurusUid() ); | 1178 | loc->setZaurusUid( inc->zaurusUid() ); |
1179 | } | 1179 | } |
1180 | } | 1180 | } |
1181 | inc = iL.next(); | 1181 | inc = iL.next(); |
1182 | } | 1182 | } |
1183 | Incidence* lse = getLastSyncEvent(); | 1183 | Incidence* lse = getLastSyncEvent(); |
1184 | if ( lse ) { | 1184 | if ( lse ) { |
1185 | lse->setReadOnly( false ); | 1185 | lse->setReadOnly( false ); |
1186 | lse->setDescription( "" ); | 1186 | lse->setDescription( "" ); |
1187 | lse->setReadOnly( true ); | 1187 | lse->setReadOnly( true ); |
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | } | 1190 | } |
1191 | setModified( true ); | 1191 | setModified( true ); |
1192 | } else { | 1192 | } else { |
1193 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1193 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1194 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1194 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1195 | question, i18n("Ok")) ; | 1195 | question, i18n("Ok")) ; |
1196 | 1196 | ||
1197 | } | 1197 | } |
1198 | delete calendar; | 1198 | delete calendar; |
1199 | updateView(); | 1199 | updateView(); |
1200 | return ;//syncOK; | 1200 | return ;//syncOK; |
1201 | #endif | 1201 | #endif |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | 1204 | ||
1205 | #include <kabc/stdaddressbook.h> | 1205 | #include <kabc/stdaddressbook.h> |
1206 | bool CalendarView::importBday() | 1206 | bool CalendarView::importBday() |
1207 | { | 1207 | { |
1208 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1208 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1209 | KABC::AddressBook::Iterator it; | 1209 | KABC::AddressBook::Iterator it; |
1210 | int count = 0; | 1210 | int count = 0; |
1211 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1211 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1212 | ++count; | 1212 | ++count; |
1213 | } | 1213 | } |
1214 | QProgressBar bar(count,0 ); | 1214 | QProgressBar bar(count,0 ); |
1215 | int w = 300; | 1215 | int w = 300; |
1216 | if ( QApplication::desktop()->width() < 320 ) | 1216 | if ( QApplication::desktop()->width() < 320 ) |
1217 | w = 220; | 1217 | w = 220; |
1218 | int h = bar.sizeHint().height() ; | 1218 | int h = bar.sizeHint().height() ; |
1219 | int dw = QApplication::desktop()->width(); | 1219 | int dw = QApplication::desktop()->width(); |
1220 | int dh = QApplication::desktop()->height(); | 1220 | int dh = QApplication::desktop()->height(); |
1221 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1221 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1222 | bar.show(); | 1222 | bar.show(); |
1223 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1223 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1224 | qApp->processEvents(); | 1224 | qApp->processEvents(); |
1225 | count = 0; | 1225 | count = 0; |
1226 | int addCount = 0; | 1226 | int addCount = 0; |
1227 | KCal::Attendee* a = 0; | 1227 | KCal::Attendee* a = 0; |
1228 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1228 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1229 | if ( ! bar.isVisible() ) | 1229 | if ( ! bar.isVisible() ) |
1230 | return false; | 1230 | return false; |
1231 | bar.setProgress( count++ ); | 1231 | bar.setProgress( count++ ); |
1232 | qApp->processEvents(); | 1232 | qApp->processEvents(); |
1233 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1233 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1234 | if ( (*it).birthday().date().isValid() ){ | 1234 | if ( (*it).birthday().date().isValid() ){ |
1235 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1235 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1236 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1236 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1237 | ++addCount; | 1237 | ++addCount; |
1238 | } | 1238 | } |
1239 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1239 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1240 | if ( anni.isValid() ){ | 1240 | if ( anni.isValid() ){ |
1241 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1241 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1242 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1242 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1243 | ++addCount; | 1243 | ++addCount; |
1244 | } | 1244 | } |
1245 | } | 1245 | } |
1246 | updateView(); | 1246 | updateView(); |
1247 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1247 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1248 | return true; | 1248 | return true; |
1249 | } | 1249 | } |
1250 | 1250 | ||
1251 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) | 1251 | bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) |
1252 | { | 1252 | { |
1253 | //qDebug("addAnni "); | 1253 | //qDebug("addAnni "); |
1254 | Event * ev = new Event(); | 1254 | Event * ev = new Event(); |
1255 | if ( a ) { | 1255 | if ( a ) { |
1256 | ev->addAttendee( a ); | 1256 | ev->addAttendee( a ); |
1257 | } | 1257 | } |
1258 | QString kind; | 1258 | QString kind; |
1259 | if ( birthday ) | 1259 | if ( birthday ) |
1260 | kind = i18n( "Birthday" ); | 1260 | kind = i18n( "Birthday" ); |
1261 | else | 1261 | else |
1262 | kind = i18n( "Anniversary" ); | 1262 | kind = i18n( "Anniversary" ); |
1263 | ev->setSummary( name + " - " + kind ); | 1263 | ev->setSummary( name + " - " + kind ); |
1264 | ev->setOrganizer( "nobody@nowhere" ); | 1264 | ev->setOrganizer( "nobody@nowhere" ); |
1265 | ev->setCategories( kind ); | 1265 | ev->setCategories( kind ); |
1266 | ev->setDtStart( QDateTime(date) ); | 1266 | ev->setDtStart( QDateTime(date) ); |
1267 | ev->setDtEnd( QDateTime(date) ); | 1267 | ev->setDtEnd( QDateTime(date) ); |
1268 | ev->setFloats( true ); | 1268 | ev->setFloats( true ); |
1269 | Recurrence * rec = ev->recurrence(); | 1269 | Recurrence * rec = ev->recurrence(); |
1270 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); | 1270 | rec->setYearly(Recurrence::rYearlyMonth,1,-1); |
1271 | rec->addYearlyNum( date.month() ); | 1271 | rec->addYearlyNum( date.month() ); |
1272 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { | 1272 | if ( !mCalendar->addAnniversaryNoDup( ev ) ) { |
1273 | delete ev; | 1273 | delete ev; |
1274 | return false; | 1274 | return false; |
1275 | } | 1275 | } |
1276 | return true; | 1276 | return true; |
1277 | 1277 | ||
1278 | } | 1278 | } |
1279 | bool CalendarView::importQtopia( const QString &categories, | 1279 | bool CalendarView::importQtopia( const QString &categories, |
1280 | const QString &datebook, | 1280 | const QString &datebook, |
1281 | const QString &todolist ) | 1281 | const QString &todolist ) |
1282 | { | 1282 | { |
1283 | 1283 | ||
1284 | QtopiaFormat qtopiaFormat; | 1284 | QtopiaFormat qtopiaFormat; |
1285 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1285 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1286 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); | 1286 | if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); |
1287 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); | 1287 | if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); |
1288 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); | 1288 | if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); |
1289 | 1289 | ||
1290 | updateView(); | 1290 | updateView(); |
1291 | return true; | 1291 | return true; |
1292 | 1292 | ||
1293 | #if 0 | 1293 | #if 0 |
1294 | mGlobalSyncMode = SYNC_MODE_QTOPIA; | 1294 | mGlobalSyncMode = SYNC_MODE_QTOPIA; |
1295 | mCurrentSyncDevice = "qtopia-XML"; | 1295 | mCurrentSyncDevice = "qtopia-XML"; |
1296 | if ( KOPrefs::instance()->mAskForPreferences ) | 1296 | if ( KOPrefs::instance()->mAskForPreferences ) |
1297 | edit_sync_options(); | 1297 | edit_sync_options(); |
1298 | qApp->processEvents(); | 1298 | qApp->processEvents(); |
1299 | CalendarLocal* calendar = new CalendarLocal(); | 1299 | CalendarLocal* calendar = new CalendarLocal(); |
1300 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1300 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1301 | bool syncOK = false; | 1301 | bool syncOK = false; |
1302 | QtopiaFormat qtopiaFormat; | 1302 | QtopiaFormat qtopiaFormat; |
1303 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); | 1303 | qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); |
1304 | bool loadOk = true; | 1304 | bool loadOk = true; |
1305 | if ( !categories.isEmpty() ) | 1305 | if ( !categories.isEmpty() ) |
1306 | loadOk = qtopiaFormat.load( calendar, categories ); | 1306 | loadOk = qtopiaFormat.load( calendar, categories ); |
1307 | if ( loadOk && !datebook.isEmpty() ) | 1307 | if ( loadOk && !datebook.isEmpty() ) |
1308 | loadOk = qtopiaFormat.load( calendar, datebook ); | 1308 | loadOk = qtopiaFormat.load( calendar, datebook ); |
1309 | if ( loadOk && !todolist.isEmpty() ) | 1309 | if ( loadOk && !todolist.isEmpty() ) |
1310 | loadOk = qtopiaFormat.load( calendar, todolist ); | 1310 | loadOk = qtopiaFormat.load( calendar, todolist ); |
1311 | 1311 | ||
1312 | if ( loadOk ) { | 1312 | if ( loadOk ) { |
1313 | getEventViewerDialog()->setSyncMode( true ); | 1313 | getEventViewerDialog()->setSyncMode( true ); |
1314 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); | 1314 | syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); |
1315 | getEventViewerDialog()->setSyncMode( false ); | 1315 | getEventViewerDialog()->setSyncMode( false ); |
1316 | qApp->processEvents(); | 1316 | qApp->processEvents(); |
1317 | if ( syncOK ) { | 1317 | if ( syncOK ) { |
1318 | if ( KOPrefs::instance()->mWriteBackFile ) | 1318 | if ( KOPrefs::instance()->mWriteBackFile ) |
1319 | { | 1319 | { |
1320 | // write back XML file | 1320 | // write back XML file |
1321 | 1321 | ||
1322 | } | 1322 | } |
1323 | setModified( true ); | 1323 | setModified( true ); |
1324 | } | 1324 | } |
1325 | } else { | 1325 | } else { |
1326 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; | 1326 | QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; |
1327 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), | 1327 | QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), |
1328 | question, i18n("Ok")) ; | 1328 | question, i18n("Ok")) ; |
1329 | } | 1329 | } |
1330 | delete calendar; | 1330 | delete calendar; |
1331 | updateView(); | 1331 | updateView(); |
1332 | return syncOK; | 1332 | return syncOK; |
1333 | 1333 | ||
1334 | 1334 | ||
1335 | #endif | 1335 | #endif |
1336 | 1336 | ||
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | void CalendarView::setSyncEventsReadOnly() | 1339 | void CalendarView::setSyncEventsReadOnly() |
1340 | { | 1340 | { |
1341 | Event * ev; | 1341 | Event * ev; |
1342 | QPtrList<Event> eL = mCalendar->rawEvents(); | 1342 | QPtrList<Event> eL = mCalendar->rawEvents(); |
1343 | ev = eL.first(); | 1343 | ev = eL.first(); |
1344 | while ( ev ) { | 1344 | while ( ev ) { |
1345 | if ( ev->uid().left(21) == QString("last-syncEvent-device") ) | 1345 | if ( ev->uid().left(21) == QString("last-syncEvent-device") ) |
1346 | ev->setReadOnly( true ); | 1346 | ev->setReadOnly( true ); |
1347 | ev = eL.next(); | 1347 | ev = eL.next(); |
1348 | } | 1348 | } |
1349 | } | 1349 | } |
1350 | bool CalendarView::openCalendar(QString filename, bool merge) | 1350 | bool CalendarView::openCalendar(QString filename, bool merge) |
1351 | { | 1351 | { |
1352 | 1352 | ||
1353 | if (filename.isEmpty()) { | 1353 | if (filename.isEmpty()) { |
1354 | return false; | 1354 | return false; |
1355 | } | 1355 | } |
1356 | 1356 | ||
1357 | if (!QFile::exists(filename)) { | 1357 | if (!QFile::exists(filename)) { |
1358 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); | 1358 | KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); |
1359 | return false; | 1359 | return false; |
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | globalFlagBlockAgenda = 1; | 1362 | globalFlagBlockAgenda = 1; |
1363 | if (!merge) mCalendar->close(); | 1363 | if (!merge) mCalendar->close(); |
1364 | 1364 | ||
1365 | mStorage->setFileName( filename ); | 1365 | mStorage->setFileName( filename ); |
1366 | 1366 | ||
1367 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { | 1367 | if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { |
1368 | if ( merge ) ;//setModified( true ); | 1368 | if ( merge ) ;//setModified( true ); |
1369 | else { | 1369 | else { |
1370 | //setModified( true ); | 1370 | //setModified( true ); |
1371 | mViewManager->setDocumentId( filename ); | 1371 | mViewManager->setDocumentId( filename ); |
1372 | mDialogManager->setDocumentId( filename ); | 1372 | mDialogManager->setDocumentId( filename ); |
1373 | mTodoList->setDocumentId( filename ); | 1373 | mTodoList->setDocumentId( filename ); |
1374 | } | 1374 | } |
1375 | globalFlagBlockAgenda = 2; | 1375 | globalFlagBlockAgenda = 2; |
1376 | // if ( getLastSyncEvent() ) | 1376 | // if ( getLastSyncEvent() ) |
1377 | // getLastSyncEvent()->setReadOnly( true ); | 1377 | // getLastSyncEvent()->setReadOnly( true ); |
1378 | mCalendar->reInitAlarmSettings(); | 1378 | mCalendar->reInitAlarmSettings(); |
1379 | setSyncEventsReadOnly(); | 1379 | setSyncEventsReadOnly(); |
1380 | updateUnmanagedViews(); | 1380 | updateUnmanagedViews(); |
1381 | updateView(); | 1381 | updateView(); |
1382 | if ( filename != MainWindow::defaultFileName() ) | 1382 | if ( filename != MainWindow::defaultFileName() ) |
1383 | saveCalendar( MainWindow::defaultFileName() ); | 1383 | saveCalendar( MainWindow::defaultFileName() ); |
1384 | loadedFileVersion = QDateTime::currentDateTime(); | 1384 | loadedFileVersion = QDateTime::currentDateTime(); |
1385 | return true; | 1385 | return true; |
1386 | } else { | 1386 | } else { |
1387 | // while failing to load, the calendar object could | 1387 | // while failing to load, the calendar object could |
1388 | // have become partially populated. Clear it out. | 1388 | // have become partially populated. Clear it out. |
1389 | if ( !merge ) mCalendar->close(); | 1389 | if ( !merge ) mCalendar->close(); |
1390 | 1390 | ||
1391 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); | 1391 | KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); |
1392 | 1392 | ||
1393 | globalFlagBlockAgenda = 2; | 1393 | globalFlagBlockAgenda = 2; |
1394 | updateView(); | 1394 | updateView(); |
1395 | } | 1395 | } |
1396 | return false; | 1396 | return false; |
1397 | } | 1397 | } |
1398 | void CalendarView::setLoadedFileVersion(QDateTime dt) | 1398 | void CalendarView::setLoadedFileVersion(QDateTime dt) |
1399 | { | 1399 | { |
1400 | loadedFileVersion = dt; | 1400 | loadedFileVersion = dt; |
1401 | } | 1401 | } |
1402 | bool CalendarView::checkFileChanged(QString fn) | 1402 | bool CalendarView::checkFileChanged(QString fn) |
1403 | { | 1403 | { |
1404 | QFileInfo finf ( fn ); | 1404 | QFileInfo finf ( fn ); |
1405 | if ( !finf.exists() ) | 1405 | if ( !finf.exists() ) |
1406 | return true; | 1406 | return true; |
1407 | QDateTime dt = finf.lastModified (); | 1407 | QDateTime dt = finf.lastModified (); |
1408 | if ( dt <= loadedFileVersion ) | 1408 | if ( dt <= loadedFileVersion ) |
1409 | return false; | 1409 | return false; |
1410 | return true; | 1410 | return true; |
1411 | 1411 | ||
1412 | } | 1412 | } |
1413 | bool CalendarView::checkFileVersion(QString fn) | 1413 | bool CalendarView::checkFileVersion(QString fn) |
1414 | { | 1414 | { |
1415 | QFileInfo finf ( fn ); | 1415 | QFileInfo finf ( fn ); |
1416 | if ( !finf.exists() ) | 1416 | if ( !finf.exists() ) |
1417 | return true; | 1417 | return true; |
1418 | QDateTime dt = finf.lastModified (); | 1418 | QDateTime dt = finf.lastModified (); |
1419 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); | 1419 | //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); |
1420 | //qDebug("file on disk version %s",dt.toString().latin1()); | 1420 | //qDebug("file on disk version %s",dt.toString().latin1()); |
1421 | if ( dt <= loadedFileVersion ) | 1421 | if ( dt <= loadedFileVersion ) |
1422 | return true; | 1422 | return true; |
1423 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , | 1423 | int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , |
1424 | i18n("KO/Pi Warning"),i18n("Overwrite"), | 1424 | i18n("KO/Pi Warning"),i18n("Overwrite"), |
1425 | i18n("Sync+save")); | 1425 | i18n("Sync+save")); |
1426 | 1426 | ||
1427 | if ( km == KMessageBox::Cancel ) | 1427 | if ( km == KMessageBox::Cancel ) |
1428 | return false; | 1428 | return false; |
1429 | if ( km == KMessageBox::Yes ) | 1429 | if ( km == KMessageBox::Yes ) |
1430 | return true; | 1430 | return true; |
1431 | 1431 | ||
1432 | setSyncDevice("deleteaftersync" ); | 1432 | setSyncDevice("deleteaftersync" ); |
1433 | KOPrefs::instance()->mAskForPreferences = true; | 1433 | KOPrefs::instance()->mAskForPreferences = true; |
1434 | KOPrefs::instance()->mSyncAlgoPrefs = 3; | 1434 | KOPrefs::instance()->mSyncAlgoPrefs = 3; |
1435 | KOPrefs::instance()->mWriteBackFile = false; | 1435 | KOPrefs::instance()->mWriteBackFile = false; |
1436 | KOPrefs::instance()->mWriteBackExistingOnly = false; | 1436 | KOPrefs::instance()->mWriteBackExistingOnly = false; |
1437 | KOPrefs::instance()->mShowSyncSummary = false; | 1437 | KOPrefs::instance()->mShowSyncSummary = false; |
1438 | syncCalendar( fn, 3 ); | 1438 | syncCalendar( fn, 3 ); |
1439 | Event * e = getLastSyncEvent(); | 1439 | Event * e = getLastSyncEvent(); |
1440 | mCalendar->deleteEvent ( e ); | 1440 | mCalendar->deleteEvent ( e ); |
1441 | updateView(); | 1441 | updateView(); |
1442 | return true; | 1442 | return true; |
1443 | } | 1443 | } |
1444 | 1444 | ||
1445 | bool CalendarView::saveCalendar( QString filename ) | 1445 | bool CalendarView::saveCalendar( QString filename ) |
1446 | { | 1446 | { |
1447 | 1447 | ||
1448 | // Store back all unsaved data into calendar object | 1448 | // Store back all unsaved data into calendar object |
1449 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); | 1449 | // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); |
1450 | if ( mViewManager->currentView() ) | 1450 | if ( mViewManager->currentView() ) |
1451 | mViewManager->currentView()->flushView(); | 1451 | mViewManager->currentView()->flushView(); |
1452 | 1452 | ||
1453 | //mStorage->setFileName( filename ); | 1453 | //mStorage->setFileName( filename ); |
1454 | 1454 | ||
1455 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 1455 | mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
1456 | mStorage->setFileName( filename ); | 1456 | mStorage->setFileName( filename ); |
1457 | bool success; | 1457 | bool success; |
1458 | success = mStorage->save(); | 1458 | success = mStorage->save(); |
1459 | if ( !success ) { | 1459 | if ( !success ) { |
1460 | return false; | 1460 | return false; |
1461 | } | 1461 | } |
1462 | 1462 | ||
1463 | return true; | 1463 | return true; |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | void CalendarView::closeCalendar() | 1466 | void CalendarView::closeCalendar() |
1467 | { | 1467 | { |
1468 | 1468 | ||
1469 | // child windows no longer valid | 1469 | // child windows no longer valid |
1470 | emit closingDown(); | 1470 | emit closingDown(); |
1471 | 1471 | ||
1472 | mCalendar->close(); | 1472 | mCalendar->close(); |
1473 | setModified(false); | 1473 | setModified(false); |
1474 | updateView(); | 1474 | updateView(); |
1475 | } | 1475 | } |
1476 | 1476 | ||
1477 | void CalendarView::archiveCalendar() | 1477 | void CalendarView::archiveCalendar() |
1478 | { | 1478 | { |
1479 | mDialogManager->showArchiveDialog(); | 1479 | mDialogManager->showArchiveDialog(); |
1480 | } | 1480 | } |
1481 | 1481 | ||
1482 | 1482 | ||
1483 | void CalendarView::readSettings() | 1483 | void CalendarView::readSettings() |
1484 | { | 1484 | { |
1485 | 1485 | ||
1486 | 1486 | ||
1487 | // mViewManager->showAgendaView(); | 1487 | // mViewManager->showAgendaView(); |
1488 | QString str; | 1488 | QString str; |
1489 | //qDebug("CalendarView::readSettings() "); | 1489 | //qDebug("CalendarView::readSettings() "); |
1490 | // read settings from the KConfig, supplying reasonable | 1490 | // read settings from the KConfig, supplying reasonable |
1491 | // defaults where none are to be found | 1491 | // defaults where none are to be found |
1492 | KConfig *config = KOGlobals::config(); | 1492 | KConfig *config = KOGlobals::config(); |
1493 | #ifndef KORG_NOSPLITTER | 1493 | #ifndef KORG_NOSPLITTER |
1494 | config->setGroup("KOrganizer Geometry"); | 1494 | config->setGroup("KOrganizer Geometry"); |
1495 | 1495 | ||
1496 | QValueList<int> sizes = config->readIntListEntry("Separator1"); | 1496 | QValueList<int> sizes = config->readIntListEntry("Separator1"); |
1497 | if (sizes.count() != 2) { | 1497 | if (sizes.count() != 2) { |
1498 | sizes << mDateNavigator->minimumSizeHint().width(); | 1498 | sizes << mDateNavigator->minimumSizeHint().width(); |
1499 | sizes << 300; | 1499 | sizes << 300; |
1500 | } | 1500 | } |
1501 | mPanner->setSizes(sizes); | 1501 | mPanner->setSizes(sizes); |
1502 | 1502 | ||
1503 | sizes = config->readIntListEntry("Separator2"); | 1503 | sizes = config->readIntListEntry("Separator2"); |
1504 | if ( ( mResourceView && sizes.count() == 4 ) || | 1504 | if ( ( mResourceView && sizes.count() == 4 ) || |
1505 | ( !mResourceView && sizes.count() == 3 ) ) { | 1505 | ( !mResourceView && sizes.count() == 3 ) ) { |
1506 | mLeftSplitter->setSizes(sizes); | 1506 | mLeftSplitter->setSizes(sizes); |
1507 | } | 1507 | } |
1508 | #endif | 1508 | #endif |
1509 | globalFlagBlockAgenda = 1; | 1509 | globalFlagBlockAgenda = 1; |
1510 | mViewManager->showAgendaView(); | 1510 | mViewManager->showAgendaView(); |
1511 | //mViewManager->readSettings( config ); | 1511 | //mViewManager->readSettings( config ); |
1512 | mTodoList->restoreLayout(config,QString("Todo Layout")); | 1512 | mTodoList->restoreLayout(config,QString("Todo Layout")); |
1513 | readFilterSettings(config); | 1513 | readFilterSettings(config); |
1514 | config->setGroup( "Views" ); | 1514 | config->setGroup( "Views" ); |
1515 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); | 1515 | int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); |
1516 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); | 1516 | if ( dateCount == 5 ) mNavigator->selectWorkWeek(); |
1517 | else if ( dateCount == 7 ) mNavigator->selectWeek(); | 1517 | else if ( dateCount == 7 ) mNavigator->selectWeek(); |
1518 | else mNavigator->selectDates( dateCount ); | 1518 | else mNavigator->selectDates( dateCount ); |
1519 | // mViewManager->readSettings( config ); | 1519 | // mViewManager->readSettings( config ); |
1520 | updateConfig(); | 1520 | updateConfig(); |
1521 | globalFlagBlockAgenda = 2; | 1521 | globalFlagBlockAgenda = 2; |
1522 | mViewManager->readSettings( config ); | 1522 | mViewManager->readSettings( config ); |
1523 | #ifdef DESKTOP_VERSION | 1523 | #ifdef DESKTOP_VERSION |
1524 | config->setGroup("WidgetLayout"); | 1524 | config->setGroup("WidgetLayout"); |
1525 | QStringList list; | 1525 | QStringList list; |
1526 | list = config->readListEntry("MainLayout"); | 1526 | list = config->readListEntry("MainLayout"); |
1527 | int x,y,w,h; | 1527 | int x,y,w,h; |
1528 | if ( ! list.isEmpty() ) { | 1528 | if ( ! list.isEmpty() ) { |
1529 | x = list[0].toInt(); | 1529 | x = list[0].toInt(); |
1530 | y = list[1].toInt(); | 1530 | y = list[1].toInt(); |
1531 | w = list[2].toInt(); | 1531 | w = list[2].toInt(); |
1532 | h = list[3].toInt(); | 1532 | h = list[3].toInt(); |
1533 | topLevelWidget()->setGeometry(x,y,w,h); | 1533 | topLevelWidget()->setGeometry(x,y,w,h); |
1534 | 1534 | ||
1535 | } else { | 1535 | } else { |
1536 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); | 1536 | topLevelWidget()->setGeometry( 40 ,40 , 640, 440); |
1537 | } | 1537 | } |
1538 | list = config->readListEntry("EditEventLayout"); | 1538 | list = config->readListEntry("EditEventLayout"); |
1539 | if ( ! list.isEmpty() ) { | 1539 | if ( ! list.isEmpty() ) { |
1540 | x = list[0].toInt(); | 1540 | x = list[0].toInt(); |
1541 | y = list[1].toInt(); | 1541 | y = list[1].toInt(); |
1542 | w = list[2].toInt(); | 1542 | w = list[2].toInt(); |
1543 | h = list[3].toInt(); | 1543 | h = list[3].toInt(); |
1544 | mEventEditor->setGeometry(x,y,w,h); | 1544 | mEventEditor->setGeometry(x,y,w,h); |
1545 | 1545 | ||
1546 | } | 1546 | } |
1547 | list = config->readListEntry("EditTodoLayout"); | 1547 | list = config->readListEntry("EditTodoLayout"); |
1548 | if ( ! list.isEmpty() ) { | 1548 | if ( ! list.isEmpty() ) { |
1549 | x = list[0].toInt(); | 1549 | x = list[0].toInt(); |
1550 | y = list[1].toInt(); | 1550 | y = list[1].toInt(); |
1551 | w = list[2].toInt(); | 1551 | w = list[2].toInt(); |
1552 | h = list[3].toInt(); | 1552 | h = list[3].toInt(); |
1553 | mTodoEditor->setGeometry(x,y,w,h); | 1553 | mTodoEditor->setGeometry(x,y,w,h); |
1554 | 1554 | ||
1555 | } | 1555 | } |
1556 | list = config->readListEntry("ViewerLayout"); | 1556 | list = config->readListEntry("ViewerLayout"); |
1557 | if ( ! list.isEmpty() ) { | 1557 | if ( ! list.isEmpty() ) { |
1558 | x = list[0].toInt(); | 1558 | x = list[0].toInt(); |
1559 | y = list[1].toInt(); | 1559 | y = list[1].toInt(); |
1560 | w = list[2].toInt(); | 1560 | w = list[2].toInt(); |
1561 | h = list[3].toInt(); | 1561 | h = list[3].toInt(); |
1562 | getEventViewerDialog()->setGeometry(x,y,w,h); | 1562 | getEventViewerDialog()->setGeometry(x,y,w,h); |
1563 | } | 1563 | } |
1564 | #endif | 1564 | #endif |
1565 | 1565 | ||
1566 | 1566 | ||
1567 | // pending read sync settings; | 1567 | // pending read sync settings; |
1568 | mSyncProfileNames.clear(); | 1568 | mSyncProfileNames.clear(); |
1569 | mSyncProfileNames << "Profile_1"; | 1569 | mSyncProfileNames << "Profile_1"; |
1570 | mSyncProfileNames << "Profile_2"; | 1570 | mSyncProfileNames << "Profile_2"; |
1571 | mSyncProfileNames << "Profile_3"; | 1571 | mSyncProfileNames << "Profile_3"; |
1572 | mSyncProfileNames << "Profile_4"; | 1572 | mSyncProfileNames << "Profile_4"; |
1573 | mSyncProfileNames << "Profile_5"; | 1573 | mSyncProfileNames << "Profile_5"; |
1574 | KSyncProfile* temp = new KSyncProfile (); | 1574 | KSyncProfile* temp = new KSyncProfile (); |
1575 | temp->setName("Profile_1" ); | 1575 | temp->setName("Profile_1" ); |
1576 | mSyncProfiles.append( temp ); | 1576 | mSyncProfiles.append( temp ); |
1577 | temp = new KSyncProfile (); | 1577 | temp = new KSyncProfile (); |
1578 | temp->setName("Profile_2" ); | 1578 | temp->setName("Profile_2" ); |
1579 | mSyncProfiles.append( temp ); | 1579 | mSyncProfiles.append( temp ); |
1580 | temp = new KSyncProfile (); | 1580 | temp = new KSyncProfile (); |
1581 | temp->setName("Profile_3" ); | 1581 | temp->setName("Profile_3" ); |
1582 | mSyncProfiles.append( temp ); | 1582 | mSyncProfiles.append( temp ); |
1583 | temp = new KSyncProfile (); | 1583 | temp = new KSyncProfile (); |
1584 | temp->setName("Profile_4" ); | 1584 | temp->setName("Profile_4" ); |
1585 | mSyncProfiles.append( temp ); | 1585 | mSyncProfiles.append( temp ); |
1586 | temp = new KSyncProfile (); | 1586 | temp = new KSyncProfile (); |
1587 | temp->setName("Profile_5" ); | 1587 | temp->setName("Profile_5" ); |
1588 | mSyncProfiles.append( temp ); | 1588 | mSyncProfiles.append( temp ); |
1589 | } | 1589 | } |
1590 | 1590 | ||
1591 | 1591 | ||
1592 | void CalendarView::writeSettings() | 1592 | void CalendarView::writeSettings() |
1593 | { | 1593 | { |
1594 | // kdDebug() << "CalendarView::writeSettings" << endl; | 1594 | // kdDebug() << "CalendarView::writeSettings" << endl; |
1595 | 1595 | ||
1596 | KConfig *config = KOGlobals::config(); | 1596 | KConfig *config = KOGlobals::config(); |
1597 | 1597 | ||
1598 | #ifndef KORG_NOSPLITTER | 1598 | #ifndef KORG_NOSPLITTER |
1599 | config->setGroup("KOrganizer Geometry"); | 1599 | config->setGroup("KOrganizer Geometry"); |
1600 | 1600 | ||
1601 | QValueList<int> list = mPanner->sizes(); | 1601 | QValueList<int> list = mPanner->sizes(); |
1602 | config->writeEntry("Separator1",list); | 1602 | config->writeEntry("Separator1",list); |
1603 | 1603 | ||
1604 | list = mLeftSplitter->sizes(); | 1604 | list = mLeftSplitter->sizes(); |
1605 | config->writeEntry("Separator2",list); | 1605 | config->writeEntry("Separator2",list); |
1606 | #endif | 1606 | #endif |
1607 | 1607 | ||
1608 | mViewManager->writeSettings( config ); | 1608 | mViewManager->writeSettings( config ); |
1609 | mTodoList->saveLayout(config,QString("Todo Layout")); | 1609 | mTodoList->saveLayout(config,QString("Todo Layout")); |
1610 | mDialogManager->writeSettings( config ); | 1610 | mDialogManager->writeSettings( config ); |
1611 | //KOPrefs::instance()->usrWriteConfig(); | 1611 | //KOPrefs::instance()->usrWriteConfig(); |
1612 | KOPrefs::instance()->writeConfig(); | 1612 | KOPrefs::instance()->writeConfig(); |
1613 | 1613 | ||
1614 | writeFilterSettings(config); | 1614 | writeFilterSettings(config); |
1615 | 1615 | ||
1616 | config->setGroup( "Views" ); | 1616 | config->setGroup( "Views" ); |
1617 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); | 1617 | config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); |
1618 | 1618 | ||
1619 | #ifdef DESKTOP_VERSION | 1619 | #ifdef DESKTOP_VERSION |
1620 | config->setGroup("WidgetLayout"); | 1620 | config->setGroup("WidgetLayout"); |
1621 | QStringList list ;//= config->readListEntry("MainLayout"); | 1621 | QStringList list ;//= config->readListEntry("MainLayout"); |
1622 | int x,y,w,h; | 1622 | int x,y,w,h; |
1623 | QWidget* wid; | 1623 | QWidget* wid; |
1624 | wid = topLevelWidget(); | 1624 | wid = topLevelWidget(); |
1625 | x = wid->geometry().x(); | 1625 | x = wid->geometry().x(); |
1626 | y = wid->geometry().y(); | 1626 | y = wid->geometry().y(); |
1627 | w = wid->width(); | 1627 | w = wid->width(); |
1628 | h = wid->height(); | 1628 | h = wid->height(); |
1629 | list.clear(); | 1629 | list.clear(); |
1630 | list << QString::number( x ); | 1630 | list << QString::number( x ); |
1631 | list << QString::number( y ); | 1631 | list << QString::number( y ); |
1632 | list << QString::number( w ); | 1632 | list << QString::number( w ); |
1633 | list << QString::number( h ); | 1633 | list << QString::number( h ); |
1634 | config->writeEntry("MainLayout",list ); | 1634 | config->writeEntry("MainLayout",list ); |
1635 | 1635 | ||
1636 | wid = mEventEditor; | 1636 | wid = mEventEditor; |
1637 | x = wid->geometry().x(); | 1637 | x = wid->geometry().x(); |
1638 | y = wid->geometry().y(); | 1638 | y = wid->geometry().y(); |
1639 | w = wid->width(); | 1639 | w = wid->width(); |
1640 | h = wid->height(); | 1640 | h = wid->height(); |
1641 | list.clear(); | 1641 | list.clear(); |
1642 | list << QString::number( x ); | 1642 | list << QString::number( x ); |
1643 | list << QString::number( y ); | 1643 | list << QString::number( y ); |
1644 | list << QString::number( w ); | 1644 | list << QString::number( w ); |
1645 | list << QString::number( h ); | 1645 | list << QString::number( h ); |
1646 | config->writeEntry("EditEventLayout",list ); | 1646 | config->writeEntry("EditEventLayout",list ); |
1647 | 1647 | ||
1648 | wid = mTodoEditor; | 1648 | wid = mTodoEditor; |
1649 | x = wid->geometry().x(); | 1649 | x = wid->geometry().x(); |
1650 | y = wid->geometry().y(); | 1650 | y = wid->geometry().y(); |
1651 | w = wid->width(); | 1651 | w = wid->width(); |
1652 | h = wid->height(); | 1652 | h = wid->height(); |
1653 | list.clear(); | 1653 | list.clear(); |
1654 | list << QString::number( x ); | 1654 | list << QString::number( x ); |
1655 | list << QString::number( y ); | 1655 | list << QString::number( y ); |
1656 | list << QString::number( w ); | 1656 | list << QString::number( w ); |
1657 | list << QString::number( h ); | 1657 | list << QString::number( h ); |
1658 | config->writeEntry("EditTodoLayout",list ); | 1658 | config->writeEntry("EditTodoLayout",list ); |
1659 | wid = getEventViewerDialog(); | 1659 | wid = getEventViewerDialog(); |
1660 | x = wid->geometry().x(); | 1660 | x = wid->geometry().x(); |
1661 | y = wid->geometry().y(); | 1661 | y = wid->geometry().y(); |
1662 | w = wid->width(); | 1662 | w = wid->width(); |
1663 | h = wid->height(); | 1663 | h = wid->height(); |
1664 | list.clear(); | 1664 | list.clear(); |
1665 | list << QString::number( x ); | 1665 | list << QString::number( x ); |
1666 | list << QString::number( y ); | 1666 | list << QString::number( y ); |
1667 | list << QString::number( w ); | 1667 | list << QString::number( w ); |
1668 | list << QString::number( h ); | 1668 | list << QString::number( h ); |
1669 | config->writeEntry("ViewerLayout",list ); | 1669 | config->writeEntry("ViewerLayout",list ); |
1670 | wid = mDialogManager->getSearchDialog(); | 1670 | wid = mDialogManager->getSearchDialog(); |
1671 | if ( wid ) { | 1671 | if ( wid ) { |
1672 | x = wid->geometry().x(); | 1672 | x = wid->geometry().x(); |
1673 | y = wid->geometry().y(); | 1673 | y = wid->geometry().y(); |
1674 | w = wid->width(); | 1674 | w = wid->width(); |
1675 | h = wid->height(); | 1675 | h = wid->height(); |
1676 | list.clear(); | 1676 | list.clear(); |
1677 | list << QString::number( x ); | 1677 | list << QString::number( x ); |
1678 | list << QString::number( y ); | 1678 | list << QString::number( y ); |
1679 | list << QString::number( w ); | 1679 | list << QString::number( w ); |
1680 | list << QString::number( h ); | 1680 | list << QString::number( h ); |
1681 | config->writeEntry("SearchLayout",list ); | 1681 | config->writeEntry("SearchLayout",list ); |
1682 | } | 1682 | } |
1683 | #endif | 1683 | #endif |
1684 | 1684 | ||
1685 | 1685 | ||
1686 | config->sync(); | 1686 | config->sync(); |
1687 | } | 1687 | } |
1688 | 1688 | ||
1689 | void CalendarView::readFilterSettings(KConfig *config) | 1689 | void CalendarView::readFilterSettings(KConfig *config) |
1690 | { | 1690 | { |
1691 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; | 1691 | // kdDebug() << "CalendarView::readFilterSettings()" << endl; |
1692 | 1692 | ||
1693 | mFilters.clear(); | 1693 | mFilters.clear(); |
1694 | 1694 | ||
1695 | config->setGroup("General"); | 1695 | config->setGroup("General"); |
1696 | QStringList filterList = config->readListEntry("CalendarFilters"); | 1696 | QStringList filterList = config->readListEntry("CalendarFilters"); |
1697 | 1697 | ||
1698 | QStringList::ConstIterator it = filterList.begin(); | 1698 | QStringList::ConstIterator it = filterList.begin(); |
1699 | QStringList::ConstIterator end = filterList.end(); | 1699 | QStringList::ConstIterator end = filterList.end(); |
1700 | while(it != end) { | 1700 | while(it != end) { |
1701 | // kdDebug() << " filter: " << (*it) << endl; | 1701 | // kdDebug() << " filter: " << (*it) << endl; |
1702 | 1702 | ||
1703 | CalFilter *filter; | 1703 | CalFilter *filter; |
1704 | filter = new CalFilter(*it); | 1704 | filter = new CalFilter(*it); |
1705 | config->setGroup("Filter_" + (*it)); | 1705 | config->setGroup("Filter_" + (*it)); |
1706 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); | 1706 | //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); |
1707 | filter->setCriteria(config->readNumEntry("Criteria",0)); | 1707 | filter->setCriteria(config->readNumEntry("Criteria",0)); |
1708 | filter->setCategoryList(config->readListEntry("CategoryList")); | 1708 | filter->setCategoryList(config->readListEntry("CategoryList")); |
1709 | mFilters.append(filter); | 1709 | mFilters.append(filter); |
1710 | 1710 | ||
1711 | ++it; | 1711 | ++it; |
1712 | } | 1712 | } |
1713 | 1713 | ||
1714 | if (mFilters.count() == 0) { | 1714 | if (mFilters.count() == 0) { |
1715 | CalFilter *filter = new CalFilter(i18n("Default")); | 1715 | CalFilter *filter = new CalFilter(i18n("Default")); |
1716 | mFilters.append(filter); | 1716 | mFilters.append(filter); |
1717 | } | 1717 | } |
1718 | mFilterView->updateFilters(); | 1718 | mFilterView->updateFilters(); |
1719 | config->setGroup("FilterView"); | 1719 | config->setGroup("FilterView"); |
1720 | 1720 | ||
1721 | mFilterView->blockSignals(true); | 1721 | mFilterView->blockSignals(true); |
1722 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); | 1722 | mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); |
1723 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); | 1723 | mFilterView->setSelectedFilter(config->readEntry("Current Filter")); |
1724 | mFilterView->blockSignals(false); | 1724 | mFilterView->blockSignals(false); |
1725 | // We do it manually to avoid it being done twice by the above calls | 1725 | // We do it manually to avoid it being done twice by the above calls |
1726 | updateFilter(); | 1726 | updateFilter(); |
1727 | } | 1727 | } |
1728 | 1728 | ||
1729 | void CalendarView::writeFilterSettings(KConfig *config) | 1729 | void CalendarView::writeFilterSettings(KConfig *config) |
1730 | { | 1730 | { |
1731 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; | 1731 | // kdDebug() << "CalendarView::writeFilterSettings()" << endl; |
1732 | 1732 | ||
1733 | QStringList filterList; | 1733 | QStringList filterList; |
1734 | 1734 | ||
1735 | CalFilter *filter = mFilters.first(); | 1735 | CalFilter *filter = mFilters.first(); |
1736 | while(filter) { | 1736 | while(filter) { |
1737 | // kdDebug() << " fn: " << filter->name() << endl; | 1737 | // kdDebug() << " fn: " << filter->name() << endl; |
1738 | filterList << filter->name(); | 1738 | filterList << filter->name(); |
1739 | config->setGroup("Filter_" + filter->name()); | 1739 | config->setGroup("Filter_" + filter->name()); |
1740 | config->writeEntry("Criteria",filter->criteria()); | 1740 | config->writeEntry("Criteria",filter->criteria()); |
1741 | config->writeEntry("CategoryList",filter->categoryList()); | 1741 | config->writeEntry("CategoryList",filter->categoryList()); |
1742 | filter = mFilters.next(); | 1742 | filter = mFilters.next(); |
1743 | } | 1743 | } |
1744 | config->setGroup("General"); | 1744 | config->setGroup("General"); |
1745 | config->writeEntry("CalendarFilters",filterList); | 1745 | config->writeEntry("CalendarFilters",filterList); |
1746 | 1746 | ||
1747 | config->setGroup("FilterView"); | 1747 | config->setGroup("FilterView"); |
1748 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); | 1748 | config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); |
1749 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); | 1749 | config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); |
1750 | } | 1750 | } |
1751 | 1751 | ||
1752 | 1752 | ||
1753 | void CalendarView::goToday() | 1753 | void CalendarView::goToday() |
1754 | { | 1754 | { |
1755 | mNavigator->selectToday(); | 1755 | mNavigator->selectToday(); |
1756 | } | 1756 | } |
1757 | 1757 | ||
1758 | void CalendarView::goNext() | 1758 | void CalendarView::goNext() |
1759 | { | 1759 | { |
1760 | mNavigator->selectNext(); | 1760 | mNavigator->selectNext(); |
1761 | } | 1761 | } |
1762 | 1762 | ||
1763 | void CalendarView::goPrevious() | 1763 | void CalendarView::goPrevious() |
1764 | { | 1764 | { |
1765 | mNavigator->selectPrevious(); | 1765 | mNavigator->selectPrevious(); |
1766 | } | 1766 | } |
1767 | void CalendarView::goNextMonth() | 1767 | void CalendarView::goNextMonth() |
1768 | { | 1768 | { |
1769 | mNavigator->selectNextMonth(); | 1769 | mNavigator->selectNextMonth(); |
1770 | } | 1770 | } |
1771 | 1771 | ||
1772 | void CalendarView::goPreviousMonth() | 1772 | void CalendarView::goPreviousMonth() |
1773 | { | 1773 | { |
1774 | mNavigator->selectPreviousMonth(); | 1774 | mNavigator->selectPreviousMonth(); |
1775 | } | 1775 | } |
1776 | void CalendarView::writeLocale() | 1776 | void CalendarView::writeLocale() |
1777 | { | 1777 | { |
1778 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); | 1778 | KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); |
1779 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); | 1779 | KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); |
1780 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); | 1780 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); |
1781 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); | 1781 | KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); |
1782 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; | 1782 | QString dummy = KOPrefs::instance()->mUserDateFormatLong; |
1783 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 1783 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
1784 | dummy = KOPrefs::instance()->mUserDateFormatShort; | 1784 | dummy = KOPrefs::instance()->mUserDateFormatShort; |
1785 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 1785 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
1786 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, | 1786 | KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, |
1787 | KOPrefs::instance()->mDaylightsavingStart, | 1787 | KOPrefs::instance()->mDaylightsavingStart, |
1788 | KOPrefs::instance()->mDaylightsavingEnd ); | 1788 | KOPrefs::instance()->mDaylightsavingEnd ); |
1789 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); | 1789 | KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); |
1790 | } | 1790 | } |
1791 | void CalendarView::updateConfig() | 1791 | void CalendarView::updateConfig() |
1792 | { | 1792 | { |
1793 | writeLocale(); | 1793 | writeLocale(); |
1794 | if ( KOPrefs::instance()->mUseAppColors ) | 1794 | if ( KOPrefs::instance()->mUseAppColors ) |
1795 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); | 1795 | QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); |
1796 | emit configChanged(); | 1796 | emit configChanged(); |
1797 | mTodoList->updateConfig(); | 1797 | mTodoList->updateConfig(); |
1798 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); | 1798 | // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); |
1799 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1799 | mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1800 | // To make the "fill window" configurations work | 1800 | // To make the "fill window" configurations work |
1801 | //mViewManager->raiseCurrentView(); | 1801 | //mViewManager->raiseCurrentView(); |
1802 | } | 1802 | } |
1803 | 1803 | ||
1804 | 1804 | ||
1805 | void CalendarView::eventChanged(Event *event) | 1805 | void CalendarView::eventChanged(Event *event) |
1806 | { | 1806 | { |
1807 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 1807 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
1808 | //updateUnmanagedViews(); | 1808 | //updateUnmanagedViews(); |
1809 | } | 1809 | } |
1810 | 1810 | ||
1811 | void CalendarView::eventAdded(Event *event) | 1811 | void CalendarView::eventAdded(Event *event) |
1812 | { | 1812 | { |
1813 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 1813 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
1814 | } | 1814 | } |
1815 | 1815 | ||
1816 | void CalendarView::eventToBeDeleted(Event *) | 1816 | void CalendarView::eventToBeDeleted(Event *) |
1817 | { | 1817 | { |
1818 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 1818 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
1819 | } | 1819 | } |
1820 | 1820 | ||
1821 | void CalendarView::eventDeleted() | 1821 | void CalendarView::eventDeleted() |
1822 | { | 1822 | { |
1823 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 1823 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
1824 | } | 1824 | } |
1825 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 1825 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
1826 | { | 1826 | { |
1827 | changeIncidenceDisplay((Incidence *)which, action); | 1827 | changeIncidenceDisplay((Incidence *)which, action); |
1828 | } | 1828 | } |
1829 | void CalendarView::checkZaurusId( int id, bool todo ) | 1829 | void CalendarView::checkZaurusId( int id, bool todo ) |
1830 | { | 1830 | { |
1831 | if ( id >= 0 ) { | 1831 | if ( id >= 0 ) { |
1832 | Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); | 1832 | Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); |
1833 | if ( lse ) { | 1833 | if ( lse ) { |
1834 | QString des = lse->description(); | 1834 | QString des = lse->description(); |
1835 | QString pref = "e"; | 1835 | QString pref = "e"; |
1836 | if ( todo ) | 1836 | if ( todo ) |
1837 | pref = "t"; | 1837 | pref = "t"; |
1838 | des += pref+ QString::number ( id ) + ","; | 1838 | des += pref+ QString::number ( id ) + ","; |
1839 | lse->setReadOnly( false ); | 1839 | lse->setReadOnly( false ); |
1840 | lse->setDescription( des ); | 1840 | lse->setDescription( des ); |
1841 | lse->setReadOnly( true ); | 1841 | lse->setReadOnly( true ); |
1842 | } | 1842 | } |
1843 | } | 1843 | } |
1844 | } | 1844 | } |
1845 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 1845 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
1846 | { | 1846 | { |
1847 | updateUnmanagedViews(); | 1847 | updateUnmanagedViews(); |
1848 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 1848 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
1849 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 1849 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
1850 | mCalendar->checkAlarmForIncidence( 0, true ); | 1850 | mCalendar->checkAlarmForIncidence( 0, true ); |
1851 | if ( mEventViewerDialog ) | 1851 | if ( mEventViewerDialog ) |
1852 | mEventViewerDialog->hide(); | 1852 | mEventViewerDialog->hide(); |
1853 | } | 1853 | } |
1854 | else | 1854 | else |
1855 | mCalendar->checkAlarmForIncidence( which , false ); | 1855 | mCalendar->checkAlarmForIncidence( which , false ); |
1856 | } | 1856 | } |
1857 | 1857 | ||
1858 | // most of the changeEventDisplays() right now just call the view's | 1858 | // most of the changeEventDisplays() right now just call the view's |
1859 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 1859 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
1860 | void CalendarView::changeEventDisplay(Event *which, int action) | 1860 | void CalendarView::changeEventDisplay(Event *which, int action) |
1861 | { | 1861 | { |
1862 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 1862 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
1863 | changeIncidenceDisplay((Incidence *)which, action); | 1863 | changeIncidenceDisplay((Incidence *)which, action); |
1864 | mDateNavigator->updateView(); | 1864 | mDateNavigator->updateView(); |
1865 | //mDialogManager->updateSearchDialog(); | 1865 | //mDialogManager->updateSearchDialog(); |
1866 | 1866 | ||
1867 | if (which) { | 1867 | if (which) { |
1868 | // If there is an event view visible update the display | 1868 | // If there is an event view visible update the display |
1869 | mViewManager->currentView()->changeEventDisplay(which,action); | 1869 | mViewManager->currentView()->changeEventDisplay(which,action); |
1870 | // TODO: check, if update needed | 1870 | // TODO: check, if update needed |
1871 | // if (which->getTodoStatus()) { | 1871 | // if (which->getTodoStatus()) { |
1872 | mTodoList->updateView(); | 1872 | mTodoList->updateView(); |
1873 | // } | 1873 | // } |
1874 | } else { | 1874 | } else { |
1875 | mViewManager->currentView()->updateView(); | 1875 | mViewManager->currentView()->updateView(); |
1876 | } | 1876 | } |
1877 | } | 1877 | } |
1878 | 1878 | ||
1879 | 1879 | ||
1880 | void CalendarView::updateTodoViews() | 1880 | void CalendarView::updateTodoViews() |
1881 | { | 1881 | { |
1882 | 1882 | ||
1883 | mTodoList->updateView(); | 1883 | mTodoList->updateView(); |
1884 | mViewManager->currentView()->updateView(); | 1884 | mViewManager->currentView()->updateView(); |
1885 | 1885 | ||
1886 | } | 1886 | } |
1887 | 1887 | ||
1888 | 1888 | ||
1889 | void CalendarView::updateView(const QDate &start, const QDate &end) | 1889 | void CalendarView::updateView(const QDate &start, const QDate &end) |
1890 | { | 1890 | { |
1891 | mTodoList->updateView(); | 1891 | mTodoList->updateView(); |
1892 | mViewManager->updateView(start, end); | 1892 | mViewManager->updateView(start, end); |
1893 | //mDateNavigator->updateView(); | 1893 | //mDateNavigator->updateView(); |
1894 | } | 1894 | } |
1895 | 1895 | ||
1896 | void CalendarView::updateView() | 1896 | void CalendarView::updateView() |
1897 | { | 1897 | { |
1898 | DateList tmpList = mNavigator->selectedDates(); | 1898 | DateList tmpList = mNavigator->selectedDates(); |
1899 | 1899 | ||
1900 | // We assume that the navigator only selects consecutive days. | 1900 | // We assume that the navigator only selects consecutive days. |
1901 | updateView( tmpList.first(), tmpList.last() ); | 1901 | updateView( tmpList.first(), tmpList.last() ); |
1902 | } | 1902 | } |
1903 | 1903 | ||
1904 | void CalendarView::updateUnmanagedViews() | 1904 | void CalendarView::updateUnmanagedViews() |
1905 | { | 1905 | { |
1906 | mDateNavigator->updateDayMatrix(); | 1906 | mDateNavigator->updateDayMatrix(); |
1907 | } | 1907 | } |
1908 | 1908 | ||
1909 | int CalendarView::msgItemDelete() | 1909 | int CalendarView::msgItemDelete() |
1910 | { | 1910 | { |
1911 | return KMessageBox::warningContinueCancel(this, | 1911 | return KMessageBox::warningContinueCancel(this, |
1912 | i18n("This item will be\npermanently deleted."), | 1912 | i18n("This item will be\npermanently deleted."), |
1913 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 1913 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
1914 | } | 1914 | } |
1915 | 1915 | ||
1916 | 1916 | ||
1917 | void CalendarView::edit_cut() | 1917 | void CalendarView::edit_cut() |
1918 | { | 1918 | { |
1919 | Event *anEvent=0; | 1919 | Event *anEvent=0; |
1920 | 1920 | ||
1921 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1921 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1922 | 1922 | ||
1923 | if (mViewManager->currentView()->isEventView()) { | 1923 | if (mViewManager->currentView()->isEventView()) { |
1924 | if ( incidence && incidence->type() == "Event" ) { | 1924 | if ( incidence && incidence->type() == "Event" ) { |
1925 | anEvent = static_cast<Event *>(incidence); | 1925 | anEvent = static_cast<Event *>(incidence); |
1926 | } | 1926 | } |
1927 | } | 1927 | } |
1928 | 1928 | ||
1929 | if (!anEvent) { | 1929 | if (!anEvent) { |
1930 | KNotifyClient::beep(); | 1930 | KNotifyClient::beep(); |
1931 | return; | 1931 | return; |
1932 | } | 1932 | } |
1933 | DndFactory factory( mCalendar ); | 1933 | DndFactory factory( mCalendar ); |
1934 | factory.cutEvent(anEvent); | 1934 | factory.cutEvent(anEvent); |
1935 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 1935 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
1936 | } | 1936 | } |
1937 | 1937 | ||
1938 | void CalendarView::edit_copy() | 1938 | void CalendarView::edit_copy() |
1939 | { | 1939 | { |
1940 | Event *anEvent=0; | 1940 | Event *anEvent=0; |
1941 | 1941 | ||
1942 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 1942 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
1943 | 1943 | ||
1944 | if (mViewManager->currentView()->isEventView()) { | 1944 | if (mViewManager->currentView()->isEventView()) { |
1945 | if ( incidence && incidence->type() == "Event" ) { | 1945 | if ( incidence && incidence->type() == "Event" ) { |
1946 | anEvent = static_cast<Event *>(incidence); | 1946 | anEvent = static_cast<Event *>(incidence); |
1947 | } | 1947 | } |
1948 | } | 1948 | } |
1949 | 1949 | ||
1950 | if (!anEvent) { | 1950 | if (!anEvent) { |
1951 | KNotifyClient::beep(); | 1951 | KNotifyClient::beep(); |
1952 | return; | 1952 | return; |
1953 | } | 1953 | } |
1954 | DndFactory factory( mCalendar ); | 1954 | DndFactory factory( mCalendar ); |
1955 | factory.copyEvent(anEvent); | 1955 | factory.copyEvent(anEvent); |
1956 | } | 1956 | } |
1957 | 1957 | ||
1958 | void CalendarView::edit_paste() | 1958 | void CalendarView::edit_paste() |
1959 | { | 1959 | { |
1960 | QDate date = mNavigator->selectedDates().first(); | 1960 | QDate date = mNavigator->selectedDates().first(); |
1961 | 1961 | ||
1962 | DndFactory factory( mCalendar ); | 1962 | DndFactory factory( mCalendar ); |
1963 | Event *pastedEvent = factory.pasteEvent( date ); | 1963 | Event *pastedEvent = factory.pasteEvent( date ); |
1964 | 1964 | ||
1965 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 1965 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
1966 | } | 1966 | } |
1967 | 1967 | ||
1968 | void CalendarView::edit_options() | 1968 | void CalendarView::edit_options() |
1969 | { | 1969 | { |
1970 | mDialogManager->showOptionsDialog(); | 1970 | mDialogManager->showOptionsDialog(); |
1971 | //writeSettings(); | 1971 | //writeSettings(); |
1972 | } | 1972 | } |
1973 | void CalendarView::edit_sync_options() | 1973 | void CalendarView::edit_sync_options() |
1974 | { | 1974 | { |
1975 | //mDialogManager->showSyncOptions(); | 1975 | //mDialogManager->showSyncOptions(); |
1976 | //KOPrefs::instance()->mSyncAlgoPrefs | 1976 | //KOPrefs::instance()->mSyncAlgoPrefs |
1977 | QDialog dia( this, "dia", true ); | 1977 | QDialog dia( this, "dia", true ); |
1978 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); | 1978 | dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); |
1979 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); | 1979 | QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); |
1980 | QVBoxLayout lay ( &dia ); | 1980 | QVBoxLayout lay ( &dia ); |
1981 | lay.setSpacing( 2 ); | 1981 | lay.setSpacing( 2 ); |
1982 | lay.setMargin( 3 ); | 1982 | lay.setMargin( 3 ); |
1983 | lay.addWidget(&gr); | 1983 | lay.addWidget(&gr); |
1984 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); | 1984 | QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); |
1985 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); | 1985 | QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); |
1986 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); | 1986 | QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); |
1987 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); | 1987 | QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); |
1988 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); | 1988 | QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); |
1989 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); | 1989 | QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); |
1990 | //QRadioButton both( i18n("Take both on conflict"), &gr ); | 1990 | //QRadioButton both( i18n("Take both on conflict"), &gr ); |
1991 | QPushButton pb ( "OK", &dia); | 1991 | QPushButton pb ( "OK", &dia); |
1992 | lay.addWidget( &pb ); | 1992 | lay.addWidget( &pb ); |
1993 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); | 1993 | connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); |
1994 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { | 1994 | switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { |
1995 | case 0: | 1995 | case 0: |
1996 | loc.setChecked( true); | 1996 | loc.setChecked( true); |
1997 | break; | 1997 | break; |
1998 | case 1: | 1998 | case 1: |
1999 | rem.setChecked( true ); | 1999 | rem.setChecked( true ); |
2000 | break; | 2000 | break; |
2001 | case 2: | 2001 | case 2: |
2002 | newest.setChecked( true); | 2002 | newest.setChecked( true); |
2003 | break; | 2003 | break; |
2004 | case 3: | 2004 | case 3: |
2005 | ask.setChecked( true); | 2005 | ask.setChecked( true); |
2006 | break; | 2006 | break; |
2007 | case 4: | 2007 | case 4: |
2008 | f_loc.setChecked( true); | 2008 | f_loc.setChecked( true); |
2009 | break; | 2009 | break; |
2010 | case 5: | 2010 | case 5: |
2011 | f_rem.setChecked( true); | 2011 | f_rem.setChecked( true); |
2012 | break; | 2012 | break; |
2013 | case 6: | 2013 | case 6: |
2014 | // both.setChecked( true); | 2014 | // both.setChecked( true); |
2015 | break; | 2015 | break; |
2016 | default: | 2016 | default: |
2017 | break; | 2017 | break; |
2018 | } | 2018 | } |
2019 | if ( dia.exec() ) { | 2019 | if ( dia.exec() ) { |
2020 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; | 2020 | KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; |
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | } | 2023 | } |
2024 | 2024 | ||
2025 | void CalendarView::slotSelectPickerDate( QDate d) | 2025 | void CalendarView::slotSelectPickerDate( QDate d) |
2026 | { | 2026 | { |
2027 | mDateFrame->hide(); | 2027 | mDateFrame->hide(); |
2028 | if ( mDatePickerMode == 1 ) { | 2028 | if ( mDatePickerMode == 1 ) { |
2029 | mNavigator->slotDaySelect( d ); | 2029 | mNavigator->slotDaySelect( d ); |
2030 | } else if ( mDatePickerMode == 2 ) { | 2030 | } else if ( mDatePickerMode == 2 ) { |
2031 | if ( mMoveIncidence->type() == "Todo" ) { | 2031 | if ( mMoveIncidence->type() == "Todo" ) { |
2032 | Todo * to = (Todo *) mMoveIncidence; | 2032 | Todo * to = (Todo *) mMoveIncidence; |
2033 | QTime tim; | 2033 | QTime tim; |
2034 | if ( to->hasDueDate() ) | 2034 | if ( to->hasDueDate() ) |
2035 | tim = to->dtDue().time(); | 2035 | tim = to->dtDue().time(); |
2036 | else { | 2036 | else { |
2037 | tim = QTime ( 0,0,0 ); | 2037 | tim = QTime ( 0,0,0 ); |
2038 | to->setFloats( true ); | 2038 | to->setFloats( true ); |
2039 | to->setHasDueDate( true ); | 2039 | to->setHasDueDate( true ); |
2040 | } | 2040 | } |
2041 | QDateTime dt ( d,tim ); | 2041 | QDateTime dt ( d,tim ); |
2042 | to->setDtDue( dt ); | 2042 | to->setDtDue( dt ); |
2043 | todoChanged( to ); | 2043 | todoChanged( to ); |
2044 | } else { | 2044 | } else { |
2045 | QTime tim = mMoveIncidence->dtStart().time(); | 2045 | QTime tim = mMoveIncidence->dtStart().time(); |
2046 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2046 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2047 | QDateTime dt ( d,tim ); | 2047 | QDateTime dt ( d,tim ); |
2048 | mMoveIncidence->setDtStart( dt ); | 2048 | mMoveIncidence->setDtStart( dt ); |
2049 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2049 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2050 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2050 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2051 | } | 2051 | } |
2052 | 2052 | ||
2053 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2053 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2054 | } | 2054 | } |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | void CalendarView::removeCategories() | 2057 | void CalendarView::removeCategories() |
2058 | { | 2058 | { |
2059 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2059 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2060 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2060 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2061 | QStringList catIncList; | 2061 | QStringList catIncList; |
2062 | QStringList newCatList; | 2062 | QStringList newCatList; |
2063 | Incidence* inc = incList.first(); | 2063 | Incidence* inc = incList.first(); |
2064 | int i; | 2064 | int i; |
2065 | int count = 0; | 2065 | int count = 0; |
2066 | while ( inc ) { | 2066 | while ( inc ) { |
2067 | newCatList.clear(); | 2067 | newCatList.clear(); |
2068 | catIncList = inc->categories() ; | 2068 | catIncList = inc->categories() ; |
2069 | for( i = 0; i< catIncList.count(); ++i ) { | 2069 | for( i = 0; i< catIncList.count(); ++i ) { |
2070 | if ( catList.contains (catIncList[i])) | 2070 | if ( catList.contains (catIncList[i])) |
2071 | newCatList.append( catIncList[i] ); | 2071 | newCatList.append( catIncList[i] ); |
2072 | } | 2072 | } |
2073 | newCatList.sort(); | 2073 | newCatList.sort(); |
2074 | inc->setCategories( newCatList.join(",") ); | 2074 | inc->setCategories( newCatList.join(",") ); |
2075 | inc = incList.next(); | 2075 | inc = incList.next(); |
2076 | } | 2076 | } |
2077 | } | 2077 | } |
2078 | 2078 | ||
2079 | int CalendarView::addCategories() | 2079 | int CalendarView::addCategories() |
2080 | { | 2080 | { |
2081 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2081 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2082 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2082 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2083 | QStringList catIncList; | 2083 | QStringList catIncList; |
2084 | Incidence* inc = incList.first(); | 2084 | Incidence* inc = incList.first(); |
2085 | int i; | 2085 | int i; |
2086 | int count = 0; | 2086 | int count = 0; |
2087 | while ( inc ) { | 2087 | while ( inc ) { |
2088 | catIncList = inc->categories() ; | 2088 | catIncList = inc->categories() ; |
2089 | for( i = 0; i< catIncList.count(); ++i ) { | 2089 | for( i = 0; i< catIncList.count(); ++i ) { |
2090 | if ( !catList.contains (catIncList[i])) { | 2090 | if ( !catList.contains (catIncList[i])) { |
2091 | catList.append( catIncList[i] ); | 2091 | catList.append( catIncList[i] ); |
2092 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2092 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2093 | ++count; | 2093 | ++count; |
2094 | } | 2094 | } |
2095 | } | 2095 | } |
2096 | inc = incList.next(); | 2096 | inc = incList.next(); |
2097 | } | 2097 | } |
2098 | catList.sort(); | 2098 | catList.sort(); |
2099 | KOPrefs::instance()->mCustomCategories = catList; | 2099 | KOPrefs::instance()->mCustomCategories = catList; |
2100 | return count; | 2100 | return count; |
2101 | } | 2101 | } |
2102 | 2102 | ||
2103 | void CalendarView::manageCategories() | 2103 | void CalendarView::manageCategories() |
2104 | { | 2104 | { |
2105 | KOCatPrefs* cp = new KOCatPrefs(); | 2105 | KOCatPrefs* cp = new KOCatPrefs(); |
2106 | cp->show(); | 2106 | cp->show(); |
2107 | int w =cp->sizeHint().width() ; | 2107 | int w =cp->sizeHint().width() ; |
2108 | int h = cp->sizeHint().height() ; | 2108 | int h = cp->sizeHint().height() ; |
2109 | int dw = QApplication::desktop()->width(); | 2109 | int dw = QApplication::desktop()->width(); |
2110 | int dh = QApplication::desktop()->height(); | 2110 | int dh = QApplication::desktop()->height(); |
2111 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2111 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2112 | if ( !cp->exec() ) { | 2112 | if ( !cp->exec() ) { |
2113 | delete cp; | 2113 | delete cp; |
2114 | return; | 2114 | return; |
2115 | } | 2115 | } |
2116 | int count = 0; | 2116 | int count = 0; |
2117 | if ( cp->addCat() ) { | 2117 | if ( cp->addCat() ) { |
2118 | count = addCategories(); | 2118 | count = addCategories(); |
2119 | if ( count ) { | 2119 | if ( count ) { |
2120 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2120 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2121 | writeSettings(); | 2121 | writeSettings(); |
2122 | } | 2122 | } |
2123 | } else { | 2123 | } else { |
2124 | removeCategories(); | 2124 | removeCategories(); |
2125 | updateView(); | 2125 | updateView(); |
2126 | } | 2126 | } |
2127 | delete cp; | 2127 | delete cp; |
2128 | } | 2128 | } |
2129 | 2129 | ||
2130 | void CalendarView::beamIncidence(Incidence * Inc) | 2130 | void CalendarView::beamIncidence(Incidence * Inc) |
2131 | { | 2131 | { |
2132 | QPtrList<Incidence> delSel ; | 2132 | QPtrList<Incidence> delSel ; |
2133 | delSel.append(Inc); | 2133 | delSel.append(Inc); |
2134 | beamIncidenceList( delSel ); | 2134 | beamIncidenceList( delSel ); |
2135 | } | 2135 | } |
2136 | void CalendarView::beamCalendar() | 2136 | void CalendarView::beamCalendar() |
2137 | { | 2137 | { |
2138 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2138 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2139 | //qDebug("beamCalendar() "); | 2139 | //qDebug("beamCalendar() "); |
2140 | beamIncidenceList( delSel ); | 2140 | beamIncidenceList( delSel ); |
2141 | } | 2141 | } |
2142 | void CalendarView::beamFilteredCalendar() | 2142 | void CalendarView::beamFilteredCalendar() |
2143 | { | 2143 | { |
2144 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2144 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2145 | //qDebug("beamFilteredCalendar() "); | 2145 | //qDebug("beamFilteredCalendar() "); |
2146 | beamIncidenceList( delSel ); | 2146 | beamIncidenceList( delSel ); |
2147 | } | 2147 | } |
2148 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2148 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2149 | { | 2149 | { |
2150 | if ( beamDialog->exec () == QDialog::Rejected ) | 2150 | if ( beamDialog->exec () == QDialog::Rejected ) |
2151 | return; | 2151 | return; |
2152 | 2152 | ||
2153 | QString fn = "/tmp/kopibeamfile"; | 2153 | QString fn = "/tmp/kopibeamfile"; |
2154 | QString mes; | 2154 | QString mes; |
2155 | bool createbup = true; | 2155 | bool createbup = true; |
2156 | if ( createbup ) { | 2156 | if ( createbup ) { |
2157 | QString description = "\n"; | 2157 | QString description = "\n"; |
2158 | CalendarLocal* cal = new CalendarLocal(); | 2158 | CalendarLocal* cal = new CalendarLocal(); |
2159 | if ( beamDialog->beamLocal() ) | 2159 | if ( beamDialog->beamLocal() ) |
2160 | cal->setLocalTime(); | 2160 | cal->setLocalTime(); |
2161 | else | 2161 | else |
2162 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 2162 | cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
2163 | Incidence *incidence = delSel.first(); | 2163 | Incidence *incidence = delSel.first(); |
2164 | bool addText = false; | 2164 | bool addText = false; |
2165 | if ( delSel.count() < 10 ) | 2165 | if ( delSel.count() < 10 ) |
2166 | addText = true; | 2166 | addText = true; |
2167 | else { | 2167 | else { |
2168 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2168 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2169 | } | 2169 | } |
2170 | while ( incidence ) { | 2170 | while ( incidence ) { |
2171 | Incidence *in = incidence->clone(); | 2171 | Incidence *in = incidence->clone(); |
2172 | if ( addText ) | 2172 | if ( addText ) |
2173 | description += in->summary() + "\n"; | 2173 | description += in->summary() + "\n"; |
2174 | cal->addIncidence( in ); | 2174 | cal->addIncidence( in ); |
2175 | incidence = delSel.next(); | 2175 | incidence = delSel.next(); |
2176 | } | 2176 | } |
2177 | if ( beamDialog->beamVcal() ) { | 2177 | if ( beamDialog->beamVcal() ) { |
2178 | fn += ".vcs"; | 2178 | fn += ".vcs"; |
2179 | FileStorage storage( cal, fn, new VCalFormat ); | 2179 | FileStorage storage( cal, fn, new VCalFormat ); |
2180 | storage.save(); | 2180 | storage.save(); |
2181 | } else { | 2181 | } else { |
2182 | fn += ".ics"; | 2182 | fn += ".ics"; |
2183 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 2183 | FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
2184 | storage.save(); | 2184 | storage.save(); |
2185 | } | 2185 | } |
2186 | delete cal; | 2186 | delete cal; |
2187 | mes = i18n("KO/Pi: Ready for beaming"); | 2187 | mes = i18n("KO/Pi: Ready for beaming"); |
2188 | setCaption(mes); | 2188 | setCaption(mes); |
2189 | 2189 | ||
2190 | #ifndef DESKTOP_VERSION | 2190 | #ifndef DESKTOP_VERSION |
2191 | Ir *ir = new Ir( this ); | 2191 | Ir *ir = new Ir( this ); |
2192 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2192 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2193 | ir->send( fn, description, "text/x-vCalendar" ); | 2193 | ir->send( fn, description, "text/x-vCalendar" ); |
2194 | #endif | 2194 | #endif |
2195 | } | 2195 | } |
2196 | } | 2196 | } |
2197 | void CalendarView::beamDone( Ir *ir ) | 2197 | void CalendarView::beamDone( Ir *ir ) |
2198 | { | 2198 | { |
2199 | #ifndef DESKTOP_VERSION | 2199 | #ifndef DESKTOP_VERSION |
2200 | delete ir; | 2200 | delete ir; |
2201 | #endif | 2201 | #endif |
2202 | } | 2202 | } |
2203 | 2203 | ||
2204 | void CalendarView::moveIncidence(Incidence * inc ) | 2204 | void CalendarView::moveIncidence(Incidence * inc ) |
2205 | { | 2205 | { |
2206 | if ( !inc ) return; | 2206 | if ( !inc ) return; |
2207 | // qDebug("showDatePickerForIncidence( ) "); | 2207 | // qDebug("showDatePickerForIncidence( ) "); |
2208 | if ( mDateFrame->isVisible() ) | 2208 | if ( mDateFrame->isVisible() ) |
2209 | mDateFrame->hide(); | 2209 | mDateFrame->hide(); |
2210 | else { | 2210 | else { |
2211 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2211 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2212 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2212 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2213 | int dw = QApplication::desktop()->width(); | 2213 | int dw = QApplication::desktop()->width(); |
2214 | int dh = QApplication::desktop()->height(); | 2214 | int dh = QApplication::desktop()->height(); |
2215 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2215 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2216 | mDateFrame->show(); | 2216 | mDateFrame->show(); |
2217 | } | 2217 | } |
2218 | mDatePickerMode = 2; | 2218 | mDatePickerMode = 2; |
2219 | mMoveIncidence = inc ; | 2219 | mMoveIncidence = inc ; |
2220 | QDate da; | 2220 | QDate da; |
2221 | if ( mMoveIncidence->type() == "Todo" ) { | 2221 | if ( mMoveIncidence->type() == "Todo" ) { |
2222 | Todo * to = (Todo *) mMoveIncidence; | 2222 | Todo * to = (Todo *) mMoveIncidence; |
2223 | if ( to->hasDueDate() ) | 2223 | if ( to->hasDueDate() ) |
2224 | da = to->dtDue().date(); | 2224 | da = to->dtDue().date(); |
2225 | else | 2225 | else |
2226 | da = QDate::currentDate(); | 2226 | da = QDate::currentDate(); |
2227 | } else { | 2227 | } else { |
2228 | da = mMoveIncidence->dtStart().date(); | 2228 | da = mMoveIncidence->dtStart().date(); |
2229 | } | 2229 | } |
2230 | mDatePicker->setDate( da ); | 2230 | mDatePicker->setDate( da ); |
2231 | } | 2231 | } |
2232 | void CalendarView::showDatePicker( ) | 2232 | void CalendarView::showDatePicker( ) |
2233 | { | 2233 | { |
2234 | //qDebug("CalendarView::showDatePicker( ) "); | 2234 | //qDebug("CalendarView::showDatePicker( ) "); |
2235 | if ( mDateFrame->isVisible() ) | 2235 | if ( mDateFrame->isVisible() ) |
2236 | mDateFrame->hide(); | 2236 | mDateFrame->hide(); |
2237 | else { | 2237 | else { |
2238 | int w =mDatePicker->sizeHint().width() ; | 2238 | int w =mDatePicker->sizeHint().width() ; |
2239 | int h = mDatePicker->sizeHint().height() ; | 2239 | int h = mDatePicker->sizeHint().height() ; |
2240 | int dw = QApplication::desktop()->width(); | 2240 | int dw = QApplication::desktop()->width(); |
2241 | int dh = QApplication::desktop()->height(); | 2241 | int dh = QApplication::desktop()->height(); |
2242 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2242 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2243 | mDateFrame->show(); | 2243 | mDateFrame->show(); |
2244 | } | 2244 | } |
2245 | mDatePickerMode = 1; | 2245 | mDatePickerMode = 1; |
2246 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2246 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2247 | } | 2247 | } |
2248 | 2248 | ||
2249 | void CalendarView::showEventEditor() | 2249 | void CalendarView::showEventEditor() |
2250 | { | 2250 | { |
2251 | #ifdef DESKTOP_VERSION | 2251 | #ifdef DESKTOP_VERSION |
2252 | mEventEditor->show(); | 2252 | mEventEditor->show(); |
2253 | #else | 2253 | #else |
2254 | mEventEditor->showMaximized(); | 2254 | mEventEditor->showMaximized(); |
2255 | #endif | 2255 | #endif |
2256 | } | 2256 | } |
2257 | void CalendarView::showTodoEditor() | 2257 | void CalendarView::showTodoEditor() |
2258 | { | 2258 | { |
2259 | #ifdef DESKTOP_VERSION | 2259 | #ifdef DESKTOP_VERSION |
2260 | mTodoEditor->show(); | 2260 | mTodoEditor->show(); |
2261 | #else | 2261 | #else |
2262 | mTodoEditor->showMaximized(); | 2262 | mTodoEditor->showMaximized(); |
2263 | #endif | 2263 | #endif |
2264 | } | 2264 | } |
2265 | void CalendarView::cancelIncidence(Incidence * inc ) | 2265 | void CalendarView::cancelIncidence(Incidence * inc ) |
2266 | { | 2266 | { |
2267 | inc->setCancelled( ! inc->cancelled() ); | 2267 | inc->setCancelled( ! inc->cancelled() ); |
2268 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2268 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2269 | updateView(); | 2269 | updateView(); |
2270 | } | 2270 | } |
2271 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2271 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2272 | { | 2272 | { |
2273 | Incidence * newInc = orgInc->clone(); | 2273 | Incidence * newInc = orgInc->clone(); |
2274 | newInc->recreate(); | 2274 | newInc->recreate(); |
2275 | 2275 | ||
2276 | if ( newInc->type() == "Todo" ) { | 2276 | if ( newInc->type() == "Todo" ) { |
2277 | Todo* t = (Todo*) newInc; | 2277 | Todo* t = (Todo*) newInc; |
2278 | mTodoEditor->editTodo( t ); | 2278 | mTodoEditor->editTodo( t ); |
2279 | showTodoEditor(); | 2279 | showTodoEditor(); |
2280 | if ( mTodoEditor->exec() ) { | 2280 | if ( mTodoEditor->exec() ) { |
2281 | mCalendar->addTodo( t ); | 2281 | mCalendar->addTodo( t ); |
2282 | updateView(); | 2282 | updateView(); |
2283 | } else { | 2283 | } else { |
2284 | delete t; | 2284 | delete t; |
2285 | } | 2285 | } |
2286 | } | 2286 | } |
2287 | else { | 2287 | else { |
2288 | Event* e = (Event*) newInc; | 2288 | Event* e = (Event*) newInc; |
2289 | mEventEditor->editEvent( e ); | 2289 | mEventEditor->editEvent( e ); |
2290 | showEventEditor(); | 2290 | showEventEditor(); |
2291 | if ( mEventEditor->exec() ) { | 2291 | if ( mEventEditor->exec() ) { |
2292 | mCalendar->addEvent( e ); | 2292 | mCalendar->addEvent( e ); |
2293 | updateView(); | 2293 | updateView(); |
2294 | } else { | 2294 | } else { |
2295 | delete e; | 2295 | delete e; |
2296 | } | 2296 | } |
2297 | } | 2297 | } |
2298 | } | 2298 | } |
2299 | 2299 | ||
2300 | void CalendarView::newEvent() | 2300 | void CalendarView::newEvent() |
2301 | { | 2301 | { |
2302 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2302 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2303 | KOAgendaView *aView = mViewManager->agendaView(); | 2303 | KOAgendaView *aView = mViewManager->agendaView(); |
2304 | if (aView) { | 2304 | if (aView) { |
2305 | if (aView->selectionStart().isValid()) { | 2305 | if (aView->selectionStart().isValid()) { |
2306 | if (aView->selectedIsAllDay()) { | 2306 | if (aView->selectedIsAllDay()) { |
2307 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2307 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2308 | } else { | 2308 | } else { |
2309 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2309 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2310 | } | 2310 | } |
2311 | return; | 2311 | return; |
2312 | } | 2312 | } |
2313 | } | 2313 | } |
2314 | 2314 | ||
2315 | QDate date = mNavigator->selectedDates().first(); | 2315 | QDate date = mNavigator->selectedDates().first(); |
2316 | QDateTime current = QDateTime::currentDateTime(); | 2316 | QDateTime current = QDateTime::currentDateTime(); |
2317 | if ( date <= current.date() ) { | 2317 | if ( date <= current.date() ) { |
2318 | int hour = current.time().hour() +1; | 2318 | int hour = current.time().hour() +1; |
2319 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2319 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2320 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2320 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2321 | } else | 2321 | } else |
2322 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2322 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2323 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2323 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2324 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2324 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2325 | } | 2325 | } |
2326 | 2326 | ||
2327 | void CalendarView::newEvent(QDateTime fh) | 2327 | void CalendarView::newEvent(QDateTime fh) |
2328 | { | 2328 | { |
2329 | newEvent(fh, | 2329 | newEvent(fh, |
2330 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2330 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2331 | } | 2331 | } |
2332 | 2332 | ||
2333 | void CalendarView::newEvent(QDate dt) | 2333 | void CalendarView::newEvent(QDate dt) |
2334 | { | 2334 | { |
2335 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2335 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2336 | QDateTime(dt, QTime(0,0,0)), true); | 2336 | QDateTime(dt, QTime(0,0,0)), true); |
2337 | } | 2337 | } |
2338 | 2338 | ||
2339 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2339 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2340 | { | 2340 | { |
2341 | 2341 | ||
2342 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2342 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2343 | if ( mFilterView->filtersEnabled() ) { | 2343 | if ( mFilterView->filtersEnabled() ) { |
2344 | CalFilter *filter = mFilterView->selectedFilter(); | 2344 | CalFilter *filter = mFilterView->selectedFilter(); |
2345 | if (filter && filter->showCategories()) { | 2345 | if (filter && filter->showCategories()) { |
2346 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2346 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2347 | } | 2347 | } |
2348 | if ( filter ) | 2348 | if ( filter ) |
2349 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2349 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2350 | } | 2350 | } |
2351 | showEventEditor(); | 2351 | showEventEditor(); |
2352 | } | 2352 | } |
2353 | void CalendarView::todoAdded(Todo * t) | 2353 | void CalendarView::todoAdded(Todo * t) |
2354 | { | 2354 | { |
2355 | 2355 | ||
2356 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2356 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2357 | updateTodoViews(); | 2357 | updateTodoViews(); |
2358 | } | 2358 | } |
2359 | void CalendarView::todoChanged(Todo * t) | 2359 | void CalendarView::todoChanged(Todo * t) |
2360 | { | 2360 | { |
2361 | emit todoModified( t, 4 ); | 2361 | emit todoModified( t, 4 ); |
2362 | // updateTodoViews(); | 2362 | // updateTodoViews(); |
2363 | } | 2363 | } |
2364 | void CalendarView::todoToBeDeleted(Todo *) | 2364 | void CalendarView::todoToBeDeleted(Todo *) |
2365 | { | 2365 | { |
2366 | //qDebug("todoToBeDeleted(Todo *) "); | 2366 | //qDebug("todoToBeDeleted(Todo *) "); |
2367 | updateTodoViews(); | 2367 | updateTodoViews(); |
2368 | } | 2368 | } |
2369 | void CalendarView::todoDeleted() | 2369 | void CalendarView::todoDeleted() |
2370 | { | 2370 | { |
2371 | //qDebug(" todoDeleted()"); | 2371 | //qDebug(" todoDeleted()"); |
2372 | updateTodoViews(); | 2372 | updateTodoViews(); |
2373 | } | 2373 | } |
2374 | 2374 | ||
2375 | 2375 | ||
2376 | 2376 | ||
2377 | void CalendarView::newTodo() | 2377 | void CalendarView::newTodo() |
2378 | { | 2378 | { |
2379 | 2379 | ||
2380 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2380 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2381 | if ( mFilterView->filtersEnabled() ) { | 2381 | if ( mFilterView->filtersEnabled() ) { |
2382 | CalFilter *filter = mFilterView->selectedFilter(); | 2382 | CalFilter *filter = mFilterView->selectedFilter(); |
2383 | if (filter && filter->showCategories()) { | 2383 | if (filter && filter->showCategories()) { |
2384 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2384 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2385 | } | 2385 | } |
2386 | if ( filter ) | 2386 | if ( filter ) |
2387 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2387 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2388 | } | 2388 | } |
2389 | showTodoEditor(); | 2389 | showTodoEditor(); |
2390 | } | 2390 | } |
2391 | 2391 | ||
2392 | void CalendarView::newSubTodo() | 2392 | void CalendarView::newSubTodo() |
2393 | { | 2393 | { |
2394 | Todo *todo = selectedTodo(); | 2394 | Todo *todo = selectedTodo(); |
2395 | if ( todo ) newSubTodo( todo ); | 2395 | if ( todo ) newSubTodo( todo ); |
2396 | } | 2396 | } |
2397 | 2397 | ||
2398 | void CalendarView::newSubTodo(Todo *parentEvent) | 2398 | void CalendarView::newSubTodo(Todo *parentEvent) |
2399 | { | 2399 | { |
2400 | 2400 | ||
2401 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2401 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2402 | showTodoEditor(); | 2402 | showTodoEditor(); |
2403 | } | 2403 | } |
2404 | 2404 | ||
2405 | void CalendarView::newFloatingEvent() | 2405 | void CalendarView::newFloatingEvent() |
2406 | { | 2406 | { |
2407 | DateList tmpList = mNavigator->selectedDates(); | 2407 | DateList tmpList = mNavigator->selectedDates(); |
2408 | QDate date = tmpList.first(); | 2408 | QDate date = tmpList.first(); |
2409 | 2409 | ||
2410 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2410 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2411 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2411 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2412 | } | 2412 | } |
2413 | 2413 | ||
2414 | 2414 | ||
2415 | void CalendarView::editEvent( Event *event ) | 2415 | void CalendarView::editEvent( Event *event ) |
2416 | { | 2416 | { |
2417 | 2417 | ||
2418 | if ( !event ) return; | 2418 | if ( !event ) return; |
2419 | if ( event->isReadOnly() ) { | 2419 | if ( event->isReadOnly() ) { |
2420 | showEvent( event ); | 2420 | showEvent( event ); |
2421 | return; | 2421 | return; |
2422 | } | 2422 | } |
2423 | mEventEditor->editEvent( event , mFlagEditDescription); | 2423 | mEventEditor->editEvent( event , mFlagEditDescription); |
2424 | showEventEditor(); | 2424 | showEventEditor(); |
2425 | } | 2425 | } |
2426 | void CalendarView::editJournal( Journal *jour ) | 2426 | void CalendarView::editJournal( Journal *jour ) |
2427 | { | 2427 | { |
2428 | if ( !jour ) return; | 2428 | if ( !jour ) return; |
2429 | mDialogManager->hideSearchDialog(); | 2429 | mDialogManager->hideSearchDialog(); |
2430 | mViewManager->showJournalView(); | 2430 | mViewManager->showJournalView(); |
2431 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2431 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2432 | } | 2432 | } |
2433 | void CalendarView::editTodo( Todo *todo ) | 2433 | void CalendarView::editTodo( Todo *todo ) |
2434 | { | 2434 | { |
2435 | if ( !todo ) return; | 2435 | if ( !todo ) return; |
2436 | 2436 | ||
2437 | if ( todo->isReadOnly() ) { | 2437 | if ( todo->isReadOnly() ) { |
2438 | showTodo( todo ); | 2438 | showTodo( todo ); |
2439 | return; | 2439 | return; |
2440 | } | 2440 | } |
2441 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2441 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2442 | showTodoEditor(); | 2442 | showTodoEditor(); |
2443 | 2443 | ||
2444 | } | 2444 | } |
2445 | 2445 | ||
2446 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2446 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2447 | { | 2447 | { |
2448 | if ( !mEventViewerDialog ) { | 2448 | if ( !mEventViewerDialog ) { |
2449 | mEventViewerDialog = new KOEventViewerDialog(this); | 2449 | mEventViewerDialog = new KOEventViewerDialog(this); |
2450 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2450 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2451 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2451 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2452 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2452 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2453 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2453 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2454 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2454 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2455 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2455 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2456 | mEventViewerDialog->resize( 640, 480 ); | 2456 | mEventViewerDialog->resize( 640, 480 ); |
2457 | 2457 | ||
2458 | } | 2458 | } |
2459 | return mEventViewerDialog; | 2459 | return mEventViewerDialog; |
2460 | } | 2460 | } |
2461 | void CalendarView::showEvent(Event *event) | 2461 | void CalendarView::showEvent(Event *event) |
2462 | { | 2462 | { |
2463 | getEventViewerDialog()->setEvent(event); | 2463 | getEventViewerDialog()->setEvent(event); |
2464 | getEventViewerDialog()->showMe(); | 2464 | getEventViewerDialog()->showMe(); |
2465 | } | 2465 | } |
2466 | 2466 | ||
2467 | void CalendarView::showTodo(Todo *event) | 2467 | void CalendarView::showTodo(Todo *event) |
2468 | { | 2468 | { |
2469 | getEventViewerDialog()->setTodo(event); | 2469 | getEventViewerDialog()->setTodo(event); |
2470 | getEventViewerDialog()->showMe(); | 2470 | getEventViewerDialog()->showMe(); |
2471 | } | 2471 | } |
2472 | void CalendarView::showJournal( Journal *jour ) | 2472 | void CalendarView::showJournal( Journal *jour ) |
2473 | { | 2473 | { |
2474 | getEventViewerDialog()->setJournal(jour); | 2474 | getEventViewerDialog()->setJournal(jour); |
2475 | getEventViewerDialog()->showMe(); | 2475 | getEventViewerDialog()->showMe(); |
2476 | 2476 | ||
2477 | } | 2477 | } |
2478 | // void CalendarView::todoModified (Todo *event, int changed) | 2478 | // void CalendarView::todoModified (Todo *event, int changed) |
2479 | // { | 2479 | // { |
2480 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2480 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2481 | // // kdDebug() << "Todo modified and open" << endl; | 2481 | // // kdDebug() << "Todo modified and open" << endl; |
2482 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2482 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2483 | // // temp->modified (changed); | 2483 | // // temp->modified (changed); |
2484 | 2484 | ||
2485 | // // } | 2485 | // // } |
2486 | 2486 | ||
2487 | // mViewManager->updateView(); | 2487 | // mViewManager->updateView(); |
2488 | // } | 2488 | // } |
2489 | 2489 | ||
2490 | void CalendarView::appointment_show() | 2490 | void CalendarView::appointment_show() |
2491 | { | 2491 | { |
2492 | Event *anEvent = 0; | 2492 | Event *anEvent = 0; |
2493 | 2493 | ||
2494 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2494 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2495 | 2495 | ||
2496 | if (mViewManager->currentView()->isEventView()) { | 2496 | if (mViewManager->currentView()->isEventView()) { |
2497 | if ( incidence && incidence->type() == "Event" ) { | 2497 | if ( incidence && incidence->type() == "Event" ) { |
2498 | anEvent = static_cast<Event *>(incidence); | 2498 | anEvent = static_cast<Event *>(incidence); |
2499 | } | 2499 | } |
2500 | } | 2500 | } |
2501 | 2501 | ||
2502 | if (!anEvent) { | 2502 | if (!anEvent) { |
2503 | KNotifyClient::beep(); | 2503 | KNotifyClient::beep(); |
2504 | return; | 2504 | return; |
2505 | } | 2505 | } |
2506 | 2506 | ||
2507 | showEvent(anEvent); | 2507 | showEvent(anEvent); |
2508 | } | 2508 | } |
2509 | 2509 | ||
2510 | void CalendarView::appointment_edit() | 2510 | void CalendarView::appointment_edit() |
2511 | { | 2511 | { |
2512 | Event *anEvent = 0; | 2512 | Event *anEvent = 0; |
2513 | 2513 | ||
2514 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2514 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2515 | 2515 | ||
2516 | if (mViewManager->currentView()->isEventView()) { | 2516 | if (mViewManager->currentView()->isEventView()) { |
2517 | if ( incidence && incidence->type() == "Event" ) { | 2517 | if ( incidence && incidence->type() == "Event" ) { |
2518 | anEvent = static_cast<Event *>(incidence); | 2518 | anEvent = static_cast<Event *>(incidence); |
2519 | } | 2519 | } |
2520 | } | 2520 | } |
2521 | 2521 | ||
2522 | if (!anEvent) { | 2522 | if (!anEvent) { |
2523 | KNotifyClient::beep(); | 2523 | KNotifyClient::beep(); |
2524 | return; | 2524 | return; |
2525 | } | 2525 | } |
2526 | 2526 | ||
2527 | editEvent(anEvent); | 2527 | editEvent(anEvent); |
2528 | } | 2528 | } |
2529 | 2529 | ||
2530 | void CalendarView::appointment_delete() | 2530 | void CalendarView::appointment_delete() |
2531 | { | 2531 | { |
2532 | Event *anEvent = 0; | 2532 | Event *anEvent = 0; |
2533 | 2533 | ||
2534 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2534 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2535 | 2535 | ||
2536 | if (mViewManager->currentView()->isEventView()) { | 2536 | if (mViewManager->currentView()->isEventView()) { |
2537 | if ( incidence && incidence->type() == "Event" ) { | 2537 | if ( incidence && incidence->type() == "Event" ) { |
2538 | anEvent = static_cast<Event *>(incidence); | 2538 | anEvent = static_cast<Event *>(incidence); |
2539 | } | 2539 | } |
2540 | } | 2540 | } |
2541 | 2541 | ||
2542 | if (!anEvent) { | 2542 | if (!anEvent) { |
2543 | KNotifyClient::beep(); | 2543 | KNotifyClient::beep(); |
2544 | return; | 2544 | return; |
2545 | } | 2545 | } |
2546 | 2546 | ||
2547 | deleteEvent(anEvent); | 2547 | deleteEvent(anEvent); |
2548 | } | 2548 | } |
2549 | 2549 | ||
2550 | void CalendarView::todo_unsub(Todo *anTodo ) | 2550 | void CalendarView::todo_unsub(Todo *anTodo ) |
2551 | { | 2551 | { |
2552 | // Todo *anTodo = selectedTodo(); | 2552 | // Todo *anTodo = selectedTodo(); |
2553 | if (!anTodo) return; | 2553 | if (!anTodo) return; |
2554 | if (!anTodo->relatedTo()) return; | 2554 | if (!anTodo->relatedTo()) return; |
2555 | anTodo->relatedTo()->removeRelation(anTodo); | 2555 | anTodo->relatedTo()->removeRelation(anTodo); |
2556 | anTodo->setRelatedTo(0); | 2556 | anTodo->setRelatedTo(0); |
2557 | anTodo->updated(); | 2557 | anTodo->updated(); |
2558 | anTodo->setRelatedToUid(""); | 2558 | anTodo->setRelatedToUid(""); |
2559 | setModified(true); | 2559 | setModified(true); |
2560 | updateView(); | 2560 | updateView(); |
2561 | } | 2561 | } |
2562 | 2562 | ||
2563 | void CalendarView::deleteTodo(Todo *todo) | 2563 | void CalendarView::deleteTodo(Todo *todo) |
2564 | { | 2564 | { |
2565 | if (!todo) { | 2565 | if (!todo) { |
2566 | KNotifyClient::beep(); | 2566 | KNotifyClient::beep(); |
2567 | return; | 2567 | return; |
2568 | } | 2568 | } |
2569 | if (KOPrefs::instance()->mConfirm) { | 2569 | if (KOPrefs::instance()->mConfirm) { |
2570 | switch (msgItemDelete()) { | 2570 | switch (msgItemDelete()) { |
2571 | case KMessageBox::Continue: // OK | 2571 | case KMessageBox::Continue: // OK |
2572 | if (!todo->relations().isEmpty()) { | 2572 | if (!todo->relations().isEmpty()) { |
2573 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2573 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2574 | i18n("Delete To-Do")); | 2574 | i18n("Delete To-Do")); |
2575 | } else { | 2575 | } else { |
2576 | checkZaurusId( todo->zaurusId(), true ); | 2576 | checkZaurusId( todo->zaurusId(), true ); |
2577 | calendar()->deleteTodo(todo); | 2577 | calendar()->deleteTodo(todo); |
2578 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2578 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2579 | updateView(); | 2579 | updateView(); |
2580 | } | 2580 | } |
2581 | break; | 2581 | break; |
2582 | } // switch | 2582 | } // switch |
2583 | } else { | 2583 | } else { |
2584 | if (!todo->relations().isEmpty()) { | 2584 | if (!todo->relations().isEmpty()) { |
2585 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2585 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2586 | i18n("Delete To-Do")); | 2586 | i18n("Delete To-Do")); |
2587 | } else { | 2587 | } else { |
2588 | checkZaurusId( todo->zaurusId(), true ); | 2588 | checkZaurusId( todo->zaurusId(), true ); |
2589 | mCalendar->deleteTodo(todo); | 2589 | mCalendar->deleteTodo(todo); |
2590 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2590 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2591 | updateView(); | 2591 | updateView(); |
2592 | } | 2592 | } |
2593 | } | 2593 | } |
2594 | emit updateSearchDialog(); | 2594 | emit updateSearchDialog(); |
2595 | } | 2595 | } |
2596 | void CalendarView::deleteJournal(Journal *jour) | 2596 | void CalendarView::deleteJournal(Journal *jour) |
2597 | { | 2597 | { |
2598 | if (!jour) { | 2598 | if (!jour) { |
2599 | KNotifyClient::beep(); | 2599 | KNotifyClient::beep(); |
2600 | return; | 2600 | return; |
2601 | } | 2601 | } |
2602 | if (KOPrefs::instance()->mConfirm) { | 2602 | if (KOPrefs::instance()->mConfirm) { |
2603 | switch (msgItemDelete()) { | 2603 | switch (msgItemDelete()) { |
2604 | case KMessageBox::Continue: // OK | 2604 | case KMessageBox::Continue: // OK |
2605 | calendar()->deleteJournal(jour); | 2605 | calendar()->deleteJournal(jour); |
2606 | updateView(); | 2606 | updateView(); |
2607 | break; | 2607 | break; |
2608 | } // switch | 2608 | } // switch |
2609 | } else { | 2609 | } else { |
2610 | calendar()->deleteJournal(jour);; | 2610 | calendar()->deleteJournal(jour);; |
2611 | updateView(); | 2611 | updateView(); |
2612 | } | 2612 | } |
2613 | emit updateSearchDialog(); | 2613 | emit updateSearchDialog(); |
2614 | } | 2614 | } |
2615 | 2615 | ||
2616 | void CalendarView::deleteEvent(Event *anEvent) | 2616 | void CalendarView::deleteEvent(Event *anEvent) |
2617 | { | 2617 | { |
2618 | if (!anEvent) { | 2618 | if (!anEvent) { |
2619 | KNotifyClient::beep(); | 2619 | KNotifyClient::beep(); |
2620 | return; | 2620 | return; |
2621 | } | 2621 | } |
2622 | 2622 | ||
2623 | if (anEvent->recurrence()->doesRecur()) { | 2623 | if (anEvent->recurrence()->doesRecur()) { |
2624 | QDate itemDate = mViewManager->currentSelectionDate(); | 2624 | QDate itemDate = mViewManager->currentSelectionDate(); |
2625 | int km; | 2625 | int km; |
2626 | if (!itemDate.isValid()) { | 2626 | if (!itemDate.isValid()) { |
2627 | //kdDebug() << "Date Not Valid" << endl; | 2627 | //kdDebug() << "Date Not Valid" << endl; |
2628 | if (KOPrefs::instance()->mConfirm) { | 2628 | if (KOPrefs::instance()->mConfirm) { |
2629 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2629 | km = KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2630 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2630 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2631 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2631 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2632 | if ( km == KMessageBox::Continue ) | 2632 | if ( km == KMessageBox::Continue ) |
2633 | km = KMessageBox::No; // No = all below | 2633 | km = KMessageBox::No; // No = all below |
2634 | } else | 2634 | } else |
2635 | km = KMessageBox::No; | 2635 | km = KMessageBox::No; |
2636 | } else { | 2636 | } else { |
2637 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + | 2637 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + |
2638 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2638 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2639 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2639 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2640 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2640 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2641 | i18n("All")); | 2641 | i18n("All")); |
2642 | } | 2642 | } |
2643 | switch(km) { | 2643 | switch(km) { |
2644 | 2644 | ||
2645 | case KMessageBox::No: // Continue // all | 2645 | case KMessageBox::No: // Continue // all |
2646 | //qDebug("KMessageBox::No "); | 2646 | //qDebug("KMessageBox::No "); |
2647 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2647 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2648 | schedule(Scheduler::Cancel,anEvent); | 2648 | schedule(Scheduler::Cancel,anEvent); |
2649 | 2649 | ||
2650 | checkZaurusId( anEvent->zaurusId()); | 2650 | checkZaurusId( anEvent->zaurusId()); |
2651 | mCalendar->deleteEvent(anEvent); | 2651 | mCalendar->deleteEvent(anEvent); |
2652 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2652 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2653 | break; | 2653 | break; |
2654 | 2654 | ||
2655 | // Disabled because it does not work | 2655 | // Disabled because it does not work |
2656 | //#if 0 | 2656 | //#if 0 |
2657 | case KMessageBox::Yes: // just this one | 2657 | case KMessageBox::Yes: // just this one |
2658 | //QDate qd = mNavigator->selectedDates().first(); | 2658 | //QDate qd = mNavigator->selectedDates().first(); |
2659 | //if (!qd.isValid()) { | 2659 | //if (!qd.isValid()) { |
2660 | // kdDebug() << "no date selected, or invalid date" << endl; | 2660 | // kdDebug() << "no date selected, or invalid date" << endl; |
2661 | // KNotifyClient::beep(); | 2661 | // KNotifyClient::beep(); |
2662 | // return; | 2662 | // return; |
2663 | //} | 2663 | //} |
2664 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2664 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2665 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2665 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2666 | anEvent->addExDate(itemDate); | 2666 | anEvent->addExDate(itemDate); |
2667 | int duration = anEvent->recurrence()->duration(); | 2667 | int duration = anEvent->recurrence()->duration(); |
2668 | if ( duration > 0 ) { | 2668 | if ( duration > 0 ) { |
2669 | anEvent->recurrence()->setDuration( duration - 1 ); | 2669 | anEvent->recurrence()->setDuration( duration - 1 ); |
2670 | } | 2670 | } |
2671 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2671 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2672 | } | 2672 | } |
2673 | break; | 2673 | break; |
2674 | //#endif | 2674 | //#endif |
2675 | } // switch | 2675 | } // switch |
2676 | } else { | 2676 | } else { |
2677 | if (KOPrefs::instance()->mConfirm) { | 2677 | if (KOPrefs::instance()->mConfirm) { |
2678 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + | 2678 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + |
2679 | i18n("\nAre you sure you want\nto delete this event?"), | 2679 | i18n("\nAre you sure you want\nto delete this event?"), |
2680 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2680 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2681 | case KMessageBox::Continue: // OK | 2681 | case KMessageBox::Continue: // OK |
2682 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2682 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2683 | schedule(Scheduler::Cancel,anEvent); | 2683 | schedule(Scheduler::Cancel,anEvent); |
2684 | checkZaurusId( anEvent->zaurusId()); | 2684 | checkZaurusId( anEvent->zaurusId()); |
2685 | mCalendar->deleteEvent(anEvent); | 2685 | mCalendar->deleteEvent(anEvent); |
2686 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2686 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2687 | break; | 2687 | break; |
2688 | } // switch | 2688 | } // switch |
2689 | } else { | 2689 | } else { |
2690 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2690 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2691 | schedule(Scheduler::Cancel,anEvent); | 2691 | schedule(Scheduler::Cancel,anEvent); |
2692 | checkZaurusId( anEvent->zaurusId()); | 2692 | checkZaurusId( anEvent->zaurusId()); |
2693 | mCalendar->deleteEvent(anEvent); | 2693 | mCalendar->deleteEvent(anEvent); |
2694 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2694 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2695 | } | 2695 | } |
2696 | } // if-else | 2696 | } // if-else |
2697 | emit updateSearchDialog(); | 2697 | emit updateSearchDialog(); |
2698 | } | 2698 | } |
2699 | 2699 | ||
2700 | bool CalendarView::deleteEvent(const QString &uid) | 2700 | bool CalendarView::deleteEvent(const QString &uid) |
2701 | { | 2701 | { |
2702 | Event *ev = mCalendar->event(uid); | 2702 | Event *ev = mCalendar->event(uid); |
2703 | if (ev) { | 2703 | if (ev) { |
2704 | deleteEvent(ev); | 2704 | deleteEvent(ev); |
2705 | return true; | 2705 | return true; |
2706 | } else { | 2706 | } else { |
2707 | return false; | 2707 | return false; |
2708 | } | 2708 | } |
2709 | } | 2709 | } |
2710 | 2710 | ||
2711 | /*****************************************************************************/ | 2711 | /*****************************************************************************/ |
2712 | 2712 | ||
2713 | void CalendarView::action_mail() | 2713 | void CalendarView::action_mail() |
2714 | { | 2714 | { |
2715 | #ifndef KORG_NOMAIL | 2715 | #ifndef KORG_NOMAIL |
2716 | KOMailClient mailClient; | 2716 | KOMailClient mailClient; |
2717 | 2717 | ||
2718 | Incidence *incidence = currentSelection(); | 2718 | Incidence *incidence = currentSelection(); |
2719 | 2719 | ||
2720 | if (!incidence) { | 2720 | if (!incidence) { |
2721 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2721 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2722 | return; | 2722 | return; |
2723 | } | 2723 | } |
2724 | if(incidence->attendeeCount() == 0 ) { | 2724 | if(incidence->attendeeCount() == 0 ) { |
2725 | KMessageBox::sorry(this, | 2725 | KMessageBox::sorry(this, |
2726 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2726 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2727 | return; | 2727 | return; |
2728 | } | 2728 | } |
2729 | 2729 | ||
2730 | CalendarLocal cal_tmp; | 2730 | CalendarLocal cal_tmp; |
2731 | Event *event = 0; | 2731 | Event *event = 0; |
2732 | Event *ev = 0; | 2732 | Event *ev = 0; |
2733 | if ( incidence && incidence->type() == "Event" ) { | 2733 | if ( incidence && incidence->type() == "Event" ) { |
2734 | event = static_cast<Event *>(incidence); | 2734 | event = static_cast<Event *>(incidence); |
2735 | ev = new Event(*event); | 2735 | ev = new Event(*event); |
2736 | cal_tmp.addEvent(ev); | 2736 | cal_tmp.addEvent(ev); |
2737 | } | 2737 | } |
2738 | ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); | 2738 | ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); |
2739 | QString attachment = mForm.toString( &cal_tmp ); | 2739 | QString attachment = mForm.toString( &cal_tmp ); |
2740 | if (ev) delete(ev); | 2740 | if (ev) delete(ev); |
2741 | 2741 | ||
2742 | mailClient.mailAttendees(currentSelection(), attachment); | 2742 | mailClient.mailAttendees(currentSelection(), attachment); |
2743 | 2743 | ||
2744 | #endif | 2744 | #endif |
2745 | 2745 | ||
2746 | #if 0 | 2746 | #if 0 |
2747 | Event *anEvent = 0; | 2747 | Event *anEvent = 0; |
2748 | if (mViewManager->currentView()->isEventView()) { | 2748 | if (mViewManager->currentView()->isEventView()) { |
2749 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 2749 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
2750 | } | 2750 | } |
2751 | 2751 | ||
2752 | if (!anEvent) { | 2752 | if (!anEvent) { |
2753 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 2753 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
2754 | return; | 2754 | return; |
2755 | } | 2755 | } |
2756 | if(anEvent->attendeeCount() == 0 ) { | 2756 | if(anEvent->attendeeCount() == 0 ) { |
2757 | KMessageBox::sorry(this, | 2757 | KMessageBox::sorry(this, |
2758 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 2758 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
2759 | return; | 2759 | return; |
2760 | } | 2760 | } |
2761 | 2761 | ||
2762 | mailobject.emailEvent(anEvent); | 2762 | mailobject.emailEvent(anEvent); |
2763 | #endif | 2763 | #endif |
2764 | } | 2764 | } |
2765 | 2765 | ||
2766 | 2766 | ||
2767 | void CalendarView::schedule_publish(Incidence *incidence) | 2767 | void CalendarView::schedule_publish(Incidence *incidence) |
2768 | { | 2768 | { |
2769 | Event *event = 0; | 2769 | Event *event = 0; |
2770 | Todo *todo = 0; | 2770 | Todo *todo = 0; |
2771 | 2771 | ||
2772 | if (incidence == 0) { | 2772 | if (incidence == 0) { |
2773 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 2773 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
2774 | if (incidence == 0) { | 2774 | if (incidence == 0) { |
2775 | incidence = mTodoList->selectedIncidences().first(); | 2775 | incidence = mTodoList->selectedIncidences().first(); |
2776 | } | 2776 | } |
2777 | } | 2777 | } |
2778 | if ( incidence && incidence->type() == "Event" ) { | 2778 | if ( incidence && incidence->type() == "Event" ) { |
2779 | event = static_cast<Event *>(incidence); | 2779 | event = static_cast<Event *>(incidence); |
2780 | } else { | 2780 | } else { |
2781 | if ( incidence && incidence->type() == "Todo" ) { | 2781 | if ( incidence && incidence->type() == "Todo" ) { |
2782 | todo = static_cast<Todo *>(incidence); | 2782 | todo = static_cast<Todo *>(incidence); |
2783 | } | 2783 | } |
2784 | } | 2784 | } |
2785 | 2785 | ||
2786 | if (!event && !todo) { | 2786 | if (!event && !todo) { |
2787 | KMessageBox::sorry(this,i18n("No event selected.")); | 2787 | KMessageBox::sorry(this,i18n("No event selected.")); |
2788 | return; | 2788 | return; |
2789 | } | 2789 | } |
2790 | 2790 | ||
2791 | PublishDialog *publishdlg = new PublishDialog(); | 2791 | PublishDialog *publishdlg = new PublishDialog(); |
2792 | if (incidence->attendeeCount()>0) { | 2792 | if (incidence->attendeeCount()>0) { |
2793 | QPtrList<Attendee> attendees = incidence->attendees(); | 2793 | QPtrList<Attendee> attendees = incidence->attendees(); |
2794 | attendees.first(); | 2794 | attendees.first(); |
2795 | while ( attendees.current()!=0 ) { | 2795 | while ( attendees.current()!=0 ) { |
2796 | publishdlg->addAttendee(attendees.current()); | 2796 | publishdlg->addAttendee(attendees.current()); |
2797 | attendees.next(); | 2797 | attendees.next(); |
2798 | } | 2798 | } |
2799 | } | 2799 | } |
2800 | bool send = true; | 2800 | bool send = true; |
2801 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 2801 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
2802 | if ( publishdlg->exec() != QDialog::Accepted ) | 2802 | if ( publishdlg->exec() != QDialog::Accepted ) |
2803 | send = false; | 2803 | send = false; |
2804 | } | 2804 | } |
2805 | if ( send ) { | 2805 | if ( send ) { |
2806 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 2806 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
2807 | if ( event ) { | 2807 | if ( event ) { |
2808 | Event *ev = new Event(*event); | 2808 | Event *ev = new Event(*event); |
2809 | ev->registerObserver(0); | 2809 | ev->registerObserver(0); |
2810 | ev->clearAttendees(); | 2810 | ev->clearAttendees(); |
2811 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 2811 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
2812 | delete(ev); | 2812 | delete(ev); |
2813 | } | 2813 | } |
2814 | } else { | 2814 | } else { |
2815 | if ( todo ) { | 2815 | if ( todo ) { |
2816 | Todo *ev = new Todo(*todo); | 2816 | Todo *ev = new Todo(*todo); |
2817 | ev->registerObserver(0); | 2817 | ev->registerObserver(0); |
2818 | ev->clearAttendees(); | 2818 | ev->clearAttendees(); |
2819 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 2819 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
2820 | delete(ev); | 2820 | delete(ev); |
2821 | } | 2821 | } |
2822 | } | 2822 | } |
2823 | } | 2823 | } |
2824 | } | 2824 | } |
2825 | delete publishdlg; | 2825 | delete publishdlg; |
2826 | } | 2826 | } |
2827 | 2827 | ||
2828 | void CalendarView::schedule_request(Incidence *incidence) | 2828 | void CalendarView::schedule_request(Incidence *incidence) |
2829 | { | 2829 | { |
2830 | schedule(Scheduler::Request,incidence); | 2830 | schedule(Scheduler::Request,incidence); |
2831 | } | 2831 | } |
2832 | 2832 | ||
2833 | void CalendarView::schedule_refresh(Incidence *incidence) | 2833 | void CalendarView::schedule_refresh(Incidence *incidence) |
2834 | { | 2834 | { |
2835 | schedule(Scheduler::Refresh,incidence); | 2835 | schedule(Scheduler::Refresh,incidence); |
2836 | } | 2836 | } |
2837 | 2837 | ||
2838 | void CalendarView::schedule_cancel(Incidence *incidence) | 2838 | void CalendarView::schedule_cancel(Incidence *incidence) |
2839 | { | 2839 | { |
2840 | schedule(Scheduler::Cancel,incidence); | 2840 | schedule(Scheduler::Cancel,incidence); |
2841 | } | 2841 | } |
2842 | 2842 | ||
2843 | void CalendarView::schedule_add(Incidence *incidence) | 2843 | void CalendarView::schedule_add(Incidence *incidence) |
2844 | { | 2844 | { |
2845 | schedule(Scheduler::Add,incidence); | 2845 | schedule(Scheduler::Add,incidence); |
2846 | } | 2846 | } |
2847 | 2847 | ||
2848 | void CalendarView::schedule_reply(Incidence *incidence) | 2848 | void CalendarView::schedule_reply(Incidence *incidence) |
2849 | { | 2849 | { |
2850 | schedule(Scheduler::Reply,incidence); | 2850 | schedule(Scheduler::Reply,incidence); |
2851 | } | 2851 | } |
2852 | 2852 | ||
2853 | void CalendarView::schedule_counter(Incidence *incidence) | 2853 | void CalendarView::schedule_counter(Incidence *incidence) |
2854 | { | 2854 | { |
2855 | schedule(Scheduler::Counter,incidence); | 2855 | schedule(Scheduler::Counter,incidence); |
2856 | } | 2856 | } |
2857 | 2857 | ||
2858 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 2858 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
2859 | { | 2859 | { |
2860 | schedule(Scheduler::Declinecounter,incidence); | 2860 | schedule(Scheduler::Declinecounter,incidence); |
2861 | } | 2861 | } |
2862 | 2862 | ||
2863 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 2863 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
2864 | { | 2864 | { |
2865 | QDateTime start = QDateTime::currentDateTime(); | 2865 | QDateTime start = QDateTime::currentDateTime(); |
2866 | QDateTime end = start.addDays(daysToPublish); | 2866 | QDateTime end = start.addDays(daysToPublish); |
2867 | 2867 | ||
2868 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 2868 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
2869 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 2869 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
2870 | 2870 | ||
2871 | 2871 | ||
2872 | PublishDialog *publishdlg = new PublishDialog(); | 2872 | PublishDialog *publishdlg = new PublishDialog(); |
2873 | if ( publishdlg->exec() == QDialog::Accepted ) { | 2873 | if ( publishdlg->exec() == QDialog::Accepted ) { |
2874 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 2874 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
2875 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 2875 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
2876 | delete(freebusy); | 2876 | delete(freebusy); |
2877 | } | 2877 | } |
2878 | } | 2878 | } |
2879 | delete publishdlg; | 2879 | delete publishdlg; |
2880 | } | 2880 | } |
2881 | 2881 | ||
2882 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 2882 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
2883 | { | 2883 | { |
2884 | Event *event = 0; | 2884 | Event *event = 0; |
2885 | Todo *todo = 0; | 2885 | Todo *todo = 0; |
2886 | 2886 | ||
2887 | if (incidence == 0) { | 2887 | if (incidence == 0) { |
2888 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 2888 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
2889 | if (incidence == 0) { | 2889 | if (incidence == 0) { |
2890 | incidence = mTodoList->selectedIncidences().first(); | 2890 | incidence = mTodoList->selectedIncidences().first(); |
2891 | } | 2891 | } |
2892 | } | 2892 | } |
2893 | if ( incidence && incidence->type() == "Event" ) { | 2893 | if ( incidence && incidence->type() == "Event" ) { |
2894 | event = static_cast<Event *>(incidence); | 2894 | event = static_cast<Event *>(incidence); |
2895 | } | 2895 | } |
2896 | if ( incidence && incidence->type() == "Todo" ) { | 2896 | if ( incidence && incidence->type() == "Todo" ) { |
2897 | todo = static_cast<Todo *>(incidence); | 2897 | todo = static_cast<Todo *>(incidence); |
2898 | } | 2898 | } |
2899 | 2899 | ||
2900 | if (!event && !todo) { | 2900 | if (!event && !todo) { |
2901 | KMessageBox::sorry(this,i18n("No event selected.")); | 2901 | KMessageBox::sorry(this,i18n("No event selected.")); |
2902 | return; | 2902 | return; |
2903 | } | 2903 | } |
2904 | 2904 | ||
2905 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 2905 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
2906 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 2906 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
2907 | return; | 2907 | return; |
2908 | } | 2908 | } |
2909 | 2909 | ||
2910 | Event *ev = 0; | 2910 | Event *ev = 0; |
2911 | if (event) ev = new Event(*event); | 2911 | if (event) ev = new Event(*event); |
2912 | Todo *to = 0; | 2912 | Todo *to = 0; |
2913 | if (todo) to = new Todo(*todo); | 2913 | if (todo) to = new Todo(*todo); |
2914 | 2914 | ||
2915 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 2915 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
2916 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 2916 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
2917 | if (!me) { | 2917 | if (!me) { |
2918 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 2918 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
2919 | return; | 2919 | return; |
2920 | } | 2920 | } |
2921 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 2921 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
2922 | StatusDialog *statdlg = new StatusDialog(this); | 2922 | StatusDialog *statdlg = new StatusDialog(this); |
2923 | if (!statdlg->exec()==QDialog::Accepted) return; | 2923 | if (!statdlg->exec()==QDialog::Accepted) return; |
2924 | me->setStatus( statdlg->status() ); | 2924 | me->setStatus( statdlg->status() ); |
2925 | delete(statdlg); | 2925 | delete(statdlg); |
2926 | } | 2926 | } |
2927 | Attendee *menew = new Attendee(*me); | 2927 | Attendee *menew = new Attendee(*me); |
2928 | if (ev) { | 2928 | if (ev) { |
2929 | ev->clearAttendees(); | 2929 | ev->clearAttendees(); |
2930 | ev->addAttendee(menew,false); | 2930 | ev->addAttendee(menew,false); |
2931 | } else { | 2931 | } else { |
2932 | if (to) { | 2932 | if (to) { |
2933 | todo->clearAttendees(); | 2933 | todo->clearAttendees(); |
2934 | todo->addAttendee(menew,false); | 2934 | todo->addAttendee(menew,false); |
2935 | } | 2935 | } |
2936 | } | 2936 | } |
2937 | } | 2937 | } |
2938 | 2938 | ||
2939 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 2939 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
2940 | if (ev) { | 2940 | if (ev) { |
2941 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 2941 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
2942 | } else { | 2942 | } else { |
2943 | if (to) { | 2943 | if (to) { |
2944 | if ( !dlg->addMessage(to,method) ) delete(to); | 2944 | if ( !dlg->addMessage(to,method) ) delete(to); |
2945 | } | 2945 | } |
2946 | } | 2946 | } |
2947 | } | 2947 | } |
2948 | 2948 | ||
2949 | void CalendarView::openAddressbook() | 2949 | void CalendarView::openAddressbook() |
2950 | { | 2950 | { |
2951 | KRun::runCommand("kaddressbook"); | 2951 | KRun::runCommand("kaddressbook"); |
2952 | } | 2952 | } |
2953 | 2953 | ||
2954 | void CalendarView::setModified(bool modified) | 2954 | void CalendarView::setModified(bool modified) |
2955 | { | 2955 | { |
2956 | if ( modified ) | 2956 | if ( modified ) |
2957 | emit signalmodified(); | 2957 | emit signalmodified(); |
2958 | if (mModified != modified) { | 2958 | if (mModified != modified) { |
2959 | mModified = modified; | 2959 | mModified = modified; |
2960 | emit modifiedChanged(mModified); | 2960 | emit modifiedChanged(mModified); |
2961 | } | 2961 | } |
2962 | } | 2962 | } |
2963 | 2963 | ||
2964 | bool CalendarView::isReadOnly() | 2964 | bool CalendarView::isReadOnly() |
2965 | { | 2965 | { |
2966 | return mReadOnly; | 2966 | return mReadOnly; |
2967 | } | 2967 | } |
2968 | 2968 | ||
2969 | void CalendarView::setReadOnly(bool readOnly) | 2969 | void CalendarView::setReadOnly(bool readOnly) |
2970 | { | 2970 | { |
2971 | if (mReadOnly != readOnly) { | 2971 | if (mReadOnly != readOnly) { |
2972 | mReadOnly = readOnly; | 2972 | mReadOnly = readOnly; |
2973 | emit readOnlyChanged(mReadOnly); | 2973 | emit readOnlyChanged(mReadOnly); |
2974 | } | 2974 | } |
2975 | } | 2975 | } |
2976 | 2976 | ||
2977 | bool CalendarView::isModified() | 2977 | bool CalendarView::isModified() |
2978 | { | 2978 | { |
2979 | return mModified; | 2979 | return mModified; |
2980 | } | 2980 | } |
2981 | 2981 | ||
2982 | void CalendarView::printSetup() | 2982 | void CalendarView::printSetup() |
2983 | { | 2983 | { |
2984 | #ifndef KORG_NOPRINTER | 2984 | #ifndef KORG_NOPRINTER |
2985 | createPrinter(); | 2985 | createPrinter(); |
2986 | 2986 | ||
2987 | mCalPrinter->setupPrinter(); | 2987 | mCalPrinter->setupPrinter(); |
2988 | #endif | 2988 | #endif |
2989 | } | 2989 | } |
2990 | 2990 | ||
2991 | void CalendarView::print() | 2991 | void CalendarView::print() |
2992 | { | 2992 | { |
2993 | #ifndef KORG_NOPRINTER | 2993 | #ifndef KORG_NOPRINTER |
2994 | createPrinter(); | 2994 | createPrinter(); |
2995 | 2995 | ||
2996 | DateList tmpDateList = mNavigator->selectedDates(); | 2996 | DateList tmpDateList = mNavigator->selectedDates(); |
2997 | mCalPrinter->print(CalPrinter::Month, | 2997 | mCalPrinter->print(CalPrinter::Month, |
2998 | tmpDateList.first(), tmpDateList.last()); | 2998 | tmpDateList.first(), tmpDateList.last()); |
2999 | #endif | 2999 | #endif |
3000 | } | 3000 | } |
3001 | 3001 | ||
3002 | void CalendarView::printPreview() | 3002 | void CalendarView::printPreview() |
3003 | { | 3003 | { |
3004 | #ifndef KORG_NOPRINTER | 3004 | #ifndef KORG_NOPRINTER |
3005 | kdDebug() << "CalendarView::printPreview()" << endl; | 3005 | kdDebug() << "CalendarView::printPreview()" << endl; |
3006 | 3006 | ||
3007 | createPrinter(); | 3007 | createPrinter(); |
3008 | 3008 | ||
3009 | DateList tmpDateList = mNavigator->selectedDates(); | 3009 | DateList tmpDateList = mNavigator->selectedDates(); |
3010 | 3010 | ||
3011 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3011 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3012 | tmpDateList.last()); | 3012 | tmpDateList.last()); |
3013 | #endif | 3013 | #endif |
3014 | } | 3014 | } |
3015 | 3015 | ||
3016 | void CalendarView::exportICalendar() | 3016 | void CalendarView::exportICalendar() |
3017 | { | 3017 | { |
3018 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3018 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3019 | 3019 | ||
3020 | // Force correct extension | 3020 | // Force correct extension |
3021 | if (filename.right(4) != ".ics") filename += ".ics"; | 3021 | if (filename.right(4) != ".ics") filename += ".ics"; |
3022 | 3022 | ||
3023 | FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); | 3023 | FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); |
3024 | storage.save(); | 3024 | storage.save(); |
3025 | } | 3025 | } |
3026 | 3026 | ||
3027 | bool CalendarView::exportVCalendar( QString filename ) | 3027 | bool CalendarView::exportVCalendar( QString filename ) |
3028 | { | 3028 | { |
3029 | if (mCalendar->journals().count() > 0) { | 3029 | if (mCalendar->journals().count() > 0) { |
3030 | int result = KMessageBox::warningContinueCancel(this, | 3030 | int result = KMessageBox::warningContinueCancel(this, |
3031 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3031 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3032 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3032 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3033 | true); | 3033 | true); |
3034 | if (result != KMessageBox::Continue) return false; | 3034 | if (result != KMessageBox::Continue) return false; |
3035 | } | 3035 | } |
3036 | 3036 | ||
3037 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3037 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3038 | 3038 | ||
3039 | // Force correct extension | 3039 | // Force correct extension |
3040 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3040 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3041 | 3041 | ||
3042 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3042 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3043 | return storage.save(); | 3043 | return storage.save(); |
3044 | 3044 | ||
3045 | } | 3045 | } |
3046 | 3046 | ||
3047 | void CalendarView::eventUpdated(Incidence *) | 3047 | void CalendarView::eventUpdated(Incidence *) |
3048 | { | 3048 | { |
3049 | setModified(); | 3049 | setModified(); |
3050 | // Don't call updateView here. The code, which has caused the update of the | 3050 | // Don't call updateView here. The code, which has caused the update of the |
3051 | // event is responsible for updating the view. | 3051 | // event is responsible for updating the view. |
3052 | // updateView(); | 3052 | // updateView(); |
3053 | } | 3053 | } |
3054 | 3054 | ||
3055 | void CalendarView::adaptNavigationUnits() | 3055 | void CalendarView::adaptNavigationUnits() |
3056 | { | 3056 | { |
3057 | if (mViewManager->currentView()->isEventView()) { | 3057 | if (mViewManager->currentView()->isEventView()) { |
3058 | int days = mViewManager->currentView()->currentDateCount(); | 3058 | int days = mViewManager->currentView()->currentDateCount(); |
3059 | if (days == 1) { | 3059 | if (days == 1) { |
3060 | emit changeNavStringPrev(i18n("&Previous Day")); | 3060 | emit changeNavStringPrev(i18n("&Previous Day")); |
3061 | emit changeNavStringNext(i18n("&Next Day")); | 3061 | emit changeNavStringNext(i18n("&Next Day")); |
3062 | } else { | 3062 | } else { |
3063 | emit changeNavStringPrev(i18n("&Previous Week")); | 3063 | emit changeNavStringPrev(i18n("&Previous Week")); |
3064 | emit changeNavStringNext(i18n("&Next Week")); | 3064 | emit changeNavStringNext(i18n("&Next Week")); |
3065 | } | 3065 | } |
3066 | } | 3066 | } |
3067 | } | 3067 | } |
3068 | 3068 | ||
3069 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3069 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3070 | { | 3070 | { |
3071 | if ( incidence ) mTodoList->clearSelection(); | 3071 | if ( incidence ) mTodoList->clearSelection(); |
3072 | processIncidenceSelection( incidence ); | 3072 | processIncidenceSelection( incidence ); |
3073 | } | 3073 | } |
3074 | 3074 | ||
3075 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3075 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3076 | { | 3076 | { |
3077 | if ( incidence && mViewManager->currentView() ) { | 3077 | if ( incidence && mViewManager->currentView() ) { |
3078 | mViewManager->currentView()->clearSelection(); | 3078 | mViewManager->currentView()->clearSelection(); |
3079 | } | 3079 | } |
3080 | processIncidenceSelection( incidence ); | 3080 | processIncidenceSelection( incidence ); |
3081 | } | 3081 | } |
3082 | 3082 | ||
3083 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3083 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3084 | { | 3084 | { |
3085 | if ( incidence == mSelectedIncidence ) return; | 3085 | if ( incidence == mSelectedIncidence ) return; |
3086 | 3086 | ||
3087 | mSelectedIncidence = incidence; | 3087 | mSelectedIncidence = incidence; |
3088 | 3088 | ||
3089 | emit incidenceSelected( mSelectedIncidence ); | 3089 | emit incidenceSelected( mSelectedIncidence ); |
3090 | 3090 | ||
3091 | if ( incidence && incidence->type() == "Event" ) { | 3091 | if ( incidence && incidence->type() == "Event" ) { |
3092 | Event *event = static_cast<Event *>( incidence ); | 3092 | Event *event = static_cast<Event *>( incidence ); |
3093 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3093 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3094 | emit organizerEventsSelected( true ); | 3094 | emit organizerEventsSelected( true ); |
3095 | } else { | 3095 | } else { |
3096 | emit organizerEventsSelected(false); | 3096 | emit organizerEventsSelected(false); |
3097 | } | 3097 | } |
3098 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3098 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3099 | KOPrefs::instance()->email() ) ) { | 3099 | KOPrefs::instance()->email() ) ) { |
3100 | emit groupEventsSelected( true ); | 3100 | emit groupEventsSelected( true ); |
3101 | } else { | 3101 | } else { |
3102 | emit groupEventsSelected(false); | 3102 | emit groupEventsSelected(false); |
3103 | } | 3103 | } |
3104 | return; | 3104 | return; |
3105 | } else { | 3105 | } else { |
3106 | if ( incidence && incidence->type() == "Todo" ) { | 3106 | if ( incidence && incidence->type() == "Todo" ) { |
3107 | emit todoSelected( true ); | 3107 | emit todoSelected( true ); |
3108 | Todo *event = static_cast<Todo *>( incidence ); | 3108 | Todo *event = static_cast<Todo *>( incidence ); |
3109 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3109 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3110 | emit organizerEventsSelected( true ); | 3110 | emit organizerEventsSelected( true ); |
3111 | } else { | 3111 | } else { |
3112 | emit organizerEventsSelected(false); | 3112 | emit organizerEventsSelected(false); |
3113 | } | 3113 | } |
3114 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3114 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3115 | KOPrefs::instance()->email() ) ) { | 3115 | KOPrefs::instance()->email() ) ) { |
3116 | emit groupEventsSelected( true ); | 3116 | emit groupEventsSelected( true ); |
3117 | } else { | 3117 | } else { |
3118 | emit groupEventsSelected(false); | 3118 | emit groupEventsSelected(false); |
3119 | } | 3119 | } |
3120 | return; | 3120 | return; |
3121 | } else { | 3121 | } else { |
3122 | emit todoSelected( false ); | 3122 | emit todoSelected( false ); |
3123 | emit organizerEventsSelected(false); | 3123 | emit organizerEventsSelected(false); |
3124 | emit groupEventsSelected(false); | 3124 | emit groupEventsSelected(false); |
3125 | } | 3125 | } |
3126 | return; | 3126 | return; |
3127 | } | 3127 | } |
3128 | 3128 | ||
3129 | /* if ( incidence && incidence->type() == "Todo" ) { | 3129 | /* if ( incidence && incidence->type() == "Todo" ) { |
3130 | emit todoSelected( true ); | 3130 | emit todoSelected( true ); |
3131 | } else { | 3131 | } else { |
3132 | emit todoSelected( false ); | 3132 | emit todoSelected( false ); |
3133 | }*/ | 3133 | }*/ |
3134 | } | 3134 | } |
3135 | 3135 | ||
3136 | 3136 | ||
3137 | void CalendarView::checkClipboard() | 3137 | void CalendarView::checkClipboard() |
3138 | { | 3138 | { |
3139 | #ifndef KORG_NODND | 3139 | #ifndef KORG_NODND |
3140 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3140 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3141 | emit pasteEnabled(true); | 3141 | emit pasteEnabled(true); |
3142 | } else { | 3142 | } else { |
3143 | emit pasteEnabled(false); | 3143 | emit pasteEnabled(false); |
3144 | } | 3144 | } |
3145 | #endif | 3145 | #endif |
3146 | } | 3146 | } |
3147 | 3147 | ||
3148 | void CalendarView::showDates(const DateList &selectedDates) | 3148 | void CalendarView::showDates(const DateList &selectedDates) |
3149 | { | 3149 | { |
3150 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3150 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3151 | 3151 | ||
3152 | if ( mViewManager->currentView() ) { | 3152 | if ( mViewManager->currentView() ) { |
3153 | updateView( selectedDates.first(), selectedDates.last() ); | 3153 | updateView( selectedDates.first(), selectedDates.last() ); |
3154 | } else { | 3154 | } else { |
3155 | mViewManager->showAgendaView(); | 3155 | mViewManager->showAgendaView(); |
3156 | } | 3156 | } |
3157 | 3157 | ||
3158 | QString selDates; | 3158 | QString selDates; |
3159 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3159 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3160 | if (selectedDates.first() < selectedDates.last() ) | 3160 | if (selectedDates.first() < selectedDates.last() ) |
3161 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3161 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3162 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3162 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3163 | 3163 | ||
3164 | } | 3164 | } |
3165 | 3165 | ||
3166 | void CalendarView::editFilters() | 3166 | void CalendarView::editFilters() |
3167 | { | 3167 | { |
3168 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3168 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3169 | 3169 | ||
3170 | CalFilter *filter = mFilters.first(); | 3170 | CalFilter *filter = mFilters.first(); |
3171 | while(filter) { | 3171 | while(filter) { |
3172 | kdDebug() << " Filter: " << filter->name() << endl; | 3172 | kdDebug() << " Filter: " << filter->name() << endl; |
3173 | filter = mFilters.next(); | 3173 | filter = mFilters.next(); |
3174 | } | 3174 | } |
3175 | 3175 | ||
3176 | mDialogManager->showFilterEditDialog(&mFilters); | 3176 | mDialogManager->showFilterEditDialog(&mFilters); |
3177 | } | 3177 | } |
3178 | void CalendarView::toggleFilter() | 3178 | void CalendarView::toggleFilter() |
3179 | { | 3179 | { |
3180 | showFilter(! mFilterView->isVisible()); | 3180 | showFilter(! mFilterView->isVisible()); |
3181 | } | 3181 | } |
3182 | 3182 | ||
3183 | void CalendarView::selectFilter( int fil ) | 3183 | void CalendarView::selectFilter( int fil ) |
3184 | { | 3184 | { |
3185 | mFilterView->setSelectedFilter( fil ); | 3185 | mFilterView->setSelectedFilter( fil ); |
3186 | } | 3186 | } |
3187 | void CalendarView::showFilter(bool visible) | 3187 | void CalendarView::showFilter(bool visible) |
3188 | { | 3188 | { |
3189 | if (visible) mFilterView->show(); | 3189 | if (visible) mFilterView->show(); |
3190 | else mFilterView->hide(); | 3190 | else mFilterView->hide(); |
3191 | } | 3191 | } |
3192 | void CalendarView::toggleFilerEnabled( ) | 3192 | void CalendarView::toggleFilerEnabled( ) |
3193 | { | 3193 | { |
3194 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3194 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3195 | if ( !mFilterView->filtersEnabled() ) | 3195 | if ( !mFilterView->filtersEnabled() ) |
3196 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3196 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3197 | 3197 | ||
3198 | } | 3198 | } |
3199 | void CalendarView::updateFilter() | 3199 | void CalendarView::updateFilter() |
3200 | { | 3200 | { |
3201 | CalFilter *filter = mFilterView->selectedFilter(); | 3201 | CalFilter *filter = mFilterView->selectedFilter(); |
3202 | if (filter) { | 3202 | if (filter) { |
3203 | if (mFilterView->filtersEnabled()) { | 3203 | if (mFilterView->filtersEnabled()) { |
3204 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3204 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); |
3205 | filter->setEnabled(true); | 3205 | filter->setEnabled(true); |
3206 | } | 3206 | } |
3207 | else filter->setEnabled(false); | 3207 | else filter->setEnabled(false); |
3208 | mCalendar->setFilter(filter); | 3208 | mCalendar->setFilter(filter); |
3209 | updateView(); | 3209 | updateView(); |
3210 | } | 3210 | } |
3211 | } | 3211 | } |
3212 | 3212 | ||
3213 | void CalendarView::filterEdited() | 3213 | void CalendarView::filterEdited() |
3214 | { | 3214 | { |
3215 | mFilterView->updateFilters(); | 3215 | mFilterView->updateFilters(); |
3216 | updateFilter(); | 3216 | updateFilter(); |
3217 | writeSettings(); | 3217 | writeSettings(); |
3218 | } | 3218 | } |
3219 | 3219 | ||
3220 | 3220 | ||
3221 | void CalendarView::takeOverEvent() | 3221 | void CalendarView::takeOverEvent() |
3222 | { | 3222 | { |
3223 | Incidence *incidence = currentSelection(); | 3223 | Incidence *incidence = currentSelection(); |
3224 | 3224 | ||
3225 | if (!incidence) return; | 3225 | if (!incidence) return; |
3226 | 3226 | ||
3227 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3227 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3228 | incidence->recreate(); | 3228 | incidence->recreate(); |
3229 | incidence->setReadOnly(false); | 3229 | incidence->setReadOnly(false); |
3230 | 3230 | ||
3231 | updateView(); | 3231 | updateView(); |
3232 | } | 3232 | } |
3233 | 3233 | ||
3234 | void CalendarView::takeOverCalendar() | 3234 | void CalendarView::takeOverCalendar() |
3235 | { | 3235 | { |
3236 | // TODO: Create Calendar::allIncidences() function and use it here | 3236 | // TODO: Create Calendar::allIncidences() function and use it here |
3237 | 3237 | ||
3238 | QPtrList<Event> events = mCalendar->events(); | 3238 | QPtrList<Event> events = mCalendar->events(); |
3239 | for(uint i=0; i<events.count(); ++i) { | 3239 | for(uint i=0; i<events.count(); ++i) { |
3240 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3240 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3241 | events.at(i)->recreate(); | 3241 | events.at(i)->recreate(); |
3242 | events.at(i)->setReadOnly(false); | 3242 | events.at(i)->setReadOnly(false); |
3243 | } | 3243 | } |
3244 | 3244 | ||
3245 | QPtrList<Todo> todos = mCalendar->todos(); | 3245 | QPtrList<Todo> todos = mCalendar->todos(); |
3246 | for(uint i=0; i<todos.count(); ++i) { | 3246 | for(uint i=0; i<todos.count(); ++i) { |
3247 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3247 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3248 | todos.at(i)->recreate(); | 3248 | todos.at(i)->recreate(); |
3249 | todos.at(i)->setReadOnly(false); | 3249 | todos.at(i)->setReadOnly(false); |
3250 | } | 3250 | } |
3251 | 3251 | ||
3252 | QPtrList<Journal> journals = mCalendar->journals(); | 3252 | QPtrList<Journal> journals = mCalendar->journals(); |
3253 | for(uint i=0; i<journals.count(); ++i) { | 3253 | for(uint i=0; i<journals.count(); ++i) { |
3254 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3254 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3255 | journals.at(i)->recreate(); | 3255 | journals.at(i)->recreate(); |
3256 | journals.at(i)->setReadOnly(false); | 3256 | journals.at(i)->setReadOnly(false); |
3257 | } | 3257 | } |
3258 | 3258 | ||
3259 | updateView(); | 3259 | updateView(); |
3260 | } | 3260 | } |
3261 | 3261 | ||
3262 | void CalendarView::showIntro() | 3262 | void CalendarView::showIntro() |
3263 | { | 3263 | { |
3264 | kdDebug() << "To be implemented." << endl; | 3264 | kdDebug() << "To be implemented." << endl; |
3265 | } | 3265 | } |
3266 | 3266 | ||
3267 | QWidgetStack *CalendarView::viewStack() | 3267 | QWidgetStack *CalendarView::viewStack() |
3268 | { | 3268 | { |
3269 | return mRightFrame; | 3269 | return mRightFrame; |
3270 | } | 3270 | } |
3271 | 3271 | ||
3272 | QWidget *CalendarView::leftFrame() | 3272 | QWidget *CalendarView::leftFrame() |
3273 | { | 3273 | { |
3274 | return mLeftFrame; | 3274 | return mLeftFrame; |
3275 | } | 3275 | } |
3276 | 3276 | ||
3277 | DateNavigator *CalendarView::dateNavigator() | 3277 | DateNavigator *CalendarView::dateNavigator() |
3278 | { | 3278 | { |
3279 | return mNavigator; | 3279 | return mNavigator; |
3280 | } | 3280 | } |
3281 | 3281 | ||
3282 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3282 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3283 | { | 3283 | { |
3284 | return mDateNavigator; | 3284 | return mDateNavigator; |
3285 | } | 3285 | } |
3286 | void CalendarView::toggleDateNavigatorWidget() | 3286 | void CalendarView::toggleDateNavigatorWidget() |
3287 | { | 3287 | { |
3288 | if (mDateNavigator->isVisible()) | 3288 | if (mDateNavigator->isVisible()) |
3289 | mDateNavigator->hide(); | 3289 | mDateNavigator->hide(); |
3290 | else | 3290 | else |
3291 | mDateNavigator->show(); | 3291 | mDateNavigator->show(); |
3292 | } | 3292 | } |
3293 | void CalendarView::addView(KOrg::BaseView *view) | 3293 | void CalendarView::addView(KOrg::BaseView *view) |
3294 | { | 3294 | { |
3295 | mViewManager->addView(view); | 3295 | mViewManager->addView(view); |
3296 | } | 3296 | } |
3297 | 3297 | ||
3298 | void CalendarView::showView(KOrg::BaseView *view) | 3298 | void CalendarView::showView(KOrg::BaseView *view) |
3299 | { | 3299 | { |
3300 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3300 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3301 | } | 3301 | } |
3302 | 3302 | ||
3303 | Incidence *CalendarView::currentSelection() | 3303 | Incidence *CalendarView::currentSelection() |
3304 | { | 3304 | { |
3305 | return mViewManager->currentSelection(); | 3305 | return mViewManager->currentSelection(); |
3306 | } | 3306 | } |
3307 | void CalendarView::toggleAllDaySize() | 3307 | void CalendarView::toggleAllDaySize() |
3308 | { | 3308 | { |
3309 | /* | 3309 | /* |
3310 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3310 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3311 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3311 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3312 | else | 3312 | else |
3313 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3313 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3314 | */ | 3314 | */ |
3315 | viewManager()->agendaView()->toggleAllDay(); | 3315 | viewManager()->agendaView()->toggleAllDay(); |
3316 | } | 3316 | } |
3317 | void CalendarView::toggleExpand() | 3317 | void CalendarView::toggleExpand() |
3318 | { | 3318 | { |
3319 | // if ( mLeftFrame->isHidden() ) { | 3319 | // if ( mLeftFrame->isHidden() ) { |
3320 | // mLeftFrame->show(); | 3320 | // mLeftFrame->show(); |
3321 | // emit calendarViewExpanded( false ); | 3321 | // emit calendarViewExpanded( false ); |
3322 | // } else { | 3322 | // } else { |
3323 | // mLeftFrame->hide(); | 3323 | // mLeftFrame->hide(); |
3324 | // emit calendarViewExpanded( true ); | 3324 | // emit calendarViewExpanded( true ); |
3325 | // } | 3325 | // } |
3326 | 3326 | ||
3327 | globalFlagBlockAgenda = 1; | 3327 | globalFlagBlockAgenda = 1; |
3328 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3328 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3329 | globalFlagBlockAgenda = 5; | 3329 | globalFlagBlockAgenda = 5; |
3330 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3330 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3331 | //mViewManager->showView( 0, true ); | 3331 | //mViewManager->showView( 0, true ); |
3332 | } | 3332 | } |
3333 | 3333 | ||
3334 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3334 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3335 | { | 3335 | { |
3336 | setModified( modified ); | 3336 | setModified( modified ); |
3337 | } | 3337 | } |
3338 | 3338 | ||
3339 | Todo *CalendarView::selectedTodo() | 3339 | Todo *CalendarView::selectedTodo() |
3340 | { | 3340 | { |
3341 | Incidence *incidence = currentSelection(); | 3341 | Incidence *incidence = currentSelection(); |
3342 | if ( incidence && incidence->type() == "Todo" ) { | 3342 | if ( incidence && incidence->type() == "Todo" ) { |
3343 | return static_cast<Todo *>( incidence ); | 3343 | return static_cast<Todo *>( incidence ); |
3344 | } | 3344 | } |
3345 | 3345 | ||
3346 | incidence = mTodoList->selectedIncidences().first(); | 3346 | incidence = mTodoList->selectedIncidences().first(); |
3347 | if ( incidence && incidence->type() == "Todo" ) { | 3347 | if ( incidence && incidence->type() == "Todo" ) { |
3348 | return static_cast<Todo *>( incidence ); | 3348 | return static_cast<Todo *>( incidence ); |
3349 | } | 3349 | } |
3350 | 3350 | ||
3351 | return 0; | 3351 | return 0; |
3352 | } | 3352 | } |
3353 | 3353 | ||
3354 | void CalendarView::dialogClosing(Incidence *in) | 3354 | void CalendarView::dialogClosing(Incidence *in) |
3355 | { | 3355 | { |
3356 | // mDialogList.remove(in); | 3356 | // mDialogList.remove(in); |
3357 | } | 3357 | } |
3358 | 3358 | ||
3359 | void CalendarView::showIncidence() | 3359 | void CalendarView::showIncidence() |
3360 | { | 3360 | { |
3361 | Incidence *incidence = currentSelection(); | 3361 | Incidence *incidence = currentSelection(); |
3362 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3362 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3363 | if ( incidence ) { | 3363 | if ( incidence ) { |
3364 | ShowIncidenceVisitor v; | 3364 | ShowIncidenceVisitor v; |
3365 | v.act( incidence, this ); | 3365 | v.act( incidence, this ); |
3366 | } | 3366 | } |
3367 | } | 3367 | } |
3368 | void CalendarView::editIncidenceDescription() | 3368 | void CalendarView::editIncidenceDescription() |
3369 | { | 3369 | { |
3370 | mFlagEditDescription = true; | 3370 | mFlagEditDescription = true; |
3371 | editIncidence(); | 3371 | editIncidence(); |
3372 | mFlagEditDescription = false; | 3372 | mFlagEditDescription = false; |
3373 | } | 3373 | } |
3374 | void CalendarView::editIncidence() | 3374 | void CalendarView::editIncidence() |
3375 | { | 3375 | { |
3376 | // qDebug("editIncidence() "); | 3376 | // qDebug("editIncidence() "); |
3377 | Incidence *incidence = currentSelection(); | 3377 | Incidence *incidence = currentSelection(); |
3378 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3378 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3379 | if ( incidence ) { | 3379 | if ( incidence ) { |
3380 | EditIncidenceVisitor v; | 3380 | EditIncidenceVisitor v; |
3381 | v.act( incidence, this ); | 3381 | v.act( incidence, this ); |
3382 | } | 3382 | } |
3383 | } | 3383 | } |
3384 | 3384 | ||
3385 | void CalendarView::deleteIncidence() | 3385 | void CalendarView::deleteIncidence() |
3386 | { | 3386 | { |
3387 | Incidence *incidence = currentSelection(); | 3387 | Incidence *incidence = currentSelection(); |
3388 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3388 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3389 | if ( incidence ) { | 3389 | if ( incidence ) { |
3390 | deleteIncidence(incidence); | 3390 | deleteIncidence(incidence); |
3391 | } | 3391 | } |
3392 | } | 3392 | } |
3393 | 3393 | ||
3394 | void CalendarView::showIncidence(Incidence *incidence) | 3394 | void CalendarView::showIncidence(Incidence *incidence) |
3395 | { | 3395 | { |
3396 | if ( incidence ) { | 3396 | if ( incidence ) { |
3397 | ShowIncidenceVisitor v; | 3397 | ShowIncidenceVisitor v; |
3398 | v.act( incidence, this ); | 3398 | v.act( incidence, this ); |
3399 | } | 3399 | } |
3400 | } | 3400 | } |
3401 | 3401 | ||
3402 | void CalendarView::editIncidence(Incidence *incidence) | 3402 | void CalendarView::editIncidence(Incidence *incidence) |
3403 | { | 3403 | { |
3404 | if ( incidence ) { | 3404 | if ( incidence ) { |
3405 | 3405 | ||
3406 | EditIncidenceVisitor v; | 3406 | EditIncidenceVisitor v; |
3407 | v.act( incidence, this ); | 3407 | v.act( incidence, this ); |
3408 | 3408 | ||
3409 | } | 3409 | } |
3410 | } | 3410 | } |
3411 | 3411 | ||
3412 | void CalendarView::deleteIncidence(Incidence *incidence) | 3412 | void CalendarView::deleteIncidence(Incidence *incidence) |
3413 | { | 3413 | { |
3414 | //qDebug(" CalendarView::deleteIncidence "); | 3414 | //qDebug(" CalendarView::deleteIncidence "); |
3415 | if ( incidence ) { | 3415 | if ( incidence ) { |
3416 | DeleteIncidenceVisitor v; | 3416 | DeleteIncidenceVisitor v; |
3417 | v.act( incidence, this ); | 3417 | v.act( incidence, this ); |
3418 | } | 3418 | } |
3419 | } | 3419 | } |
3420 | 3420 | ||
3421 | 3421 | ||
3422 | void CalendarView::lookForOutgoingMessages() | 3422 | void CalendarView::lookForOutgoingMessages() |
3423 | { | 3423 | { |
3424 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3424 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3425 | ogd->loadMessages(); | 3425 | ogd->loadMessages(); |
3426 | } | 3426 | } |
3427 | 3427 | ||
3428 | void CalendarView::lookForIncomingMessages() | 3428 | void CalendarView::lookForIncomingMessages() |
3429 | { | 3429 | { |
3430 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3430 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3431 | icd->retrieve(); | 3431 | icd->retrieve(); |
3432 | } | 3432 | } |
3433 | 3433 | ||
3434 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3434 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3435 | { | 3435 | { |
3436 | bool deleteTodo = true; | 3436 | bool deleteTodo = true; |
3437 | QPtrList<Incidence> subTodos; | 3437 | QPtrList<Incidence> subTodos; |
3438 | Incidence *aTodo; | 3438 | Incidence *aTodo; |
3439 | subTodos = t->relations(); | 3439 | subTodos = t->relations(); |
3440 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3440 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3441 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3441 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3442 | deleteTodo = false; | 3442 | deleteTodo = false; |
3443 | } | 3443 | } |
3444 | if ( deleteTodo ) { | 3444 | if ( deleteTodo ) { |
3445 | if ( t->isCompleted() ) { | 3445 | if ( t->isCompleted() ) { |
3446 | checkZaurusId( t->zaurusId(), true ); | 3446 | checkZaurusId( t->zaurusId(), true ); |
3447 | mCalendar->deleteTodo( t ); | 3447 | mCalendar->deleteTodo( t ); |
3448 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3448 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3449 | } | 3449 | } |
3450 | else | 3450 | else |
3451 | deleteTodo = false; | 3451 | deleteTodo = false; |
3452 | } | 3452 | } |
3453 | return deleteTodo; | 3453 | return deleteTodo; |
3454 | 3454 | ||
3455 | } | 3455 | } |
3456 | void CalendarView::purgeCompleted() | 3456 | void CalendarView::purgeCompleted() |
3457 | { | 3457 | { |
3458 | int result = KMessageBox::warningContinueCancel(this, | 3458 | int result = KMessageBox::warningContinueCancel(this, |
3459 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3459 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3460 | 3460 | ||
3461 | if (result == KMessageBox::Continue) { | 3461 | if (result == KMessageBox::Continue) { |
3462 | 3462 | ||
3463 | QPtrList<Todo> todoCal; | 3463 | QPtrList<Todo> todoCal; |
3464 | QPtrList<Todo> rootTodos; | 3464 | QPtrList<Todo> rootTodos; |
3465 | //QPtrList<Incidence> rel; | 3465 | //QPtrList<Incidence> rel; |
3466 | Todo *aTodo;//, *rTodo; | 3466 | Todo *aTodo;//, *rTodo; |
3467 | Incidence *rIncidence; | 3467 | Incidence *rIncidence; |
3468 | bool childDelete = false; | 3468 | bool childDelete = false; |
3469 | bool deletedOne = true; | 3469 | bool deletedOne = true; |
3470 | todoCal = calendar()->todos(); | 3470 | todoCal = calendar()->todos(); |
3471 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3471 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3472 | if ( !aTodo->relatedTo() ) | 3472 | if ( !aTodo->relatedTo() ) |
3473 | rootTodos.append( aTodo ); | 3473 | rootTodos.append( aTodo ); |
3474 | } | 3474 | } |
3475 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3475 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3476 | removeCompletedSubTodos( aTodo ); | 3476 | removeCompletedSubTodos( aTodo ); |
3477 | } | 3477 | } |
3478 | 3478 | ||
3479 | updateView(); | 3479 | updateView(); |
3480 | } | 3480 | } |
3481 | } | 3481 | } |
3482 | 3482 | ||
3483 | void CalendarView::slotCalendarChanged() | 3483 | void CalendarView::slotCalendarChanged() |
3484 | { | 3484 | { |
3485 | ; | 3485 | ; |
3486 | } | 3486 | } |
3487 | 3487 | ||
3488 | NavigatorBar *CalendarView::navigatorBar() | 3488 | NavigatorBar *CalendarView::navigatorBar() |
3489 | { | 3489 | { |
3490 | return mNavigatorBar; | 3490 | return mNavigatorBar; |
3491 | } | 3491 | } |
3492 | 3492 | ||
3493 | 3493 | ||
3494 | 3494 | ||
3495 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3495 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3496 | { | 3496 | { |
3497 | //qDebug(" alendarView::keyPressEvent "); | 3497 | //qDebug(" alendarView::keyPressEvent "); |
3498 | e->ignore(); | 3498 | e->ignore(); |
3499 | } | 3499 | } |
3500 | 3500 | ||
3501 | //#include "calendarview.moc" | 3501 | //#include "calendarview.moc" |
3502 | 3502 | ||
3503 | //#include "calendarviewbase.moc" | 3503 | //#include "calendarviewbase.moc" |
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp index 3437f45..df05ab3 100644 --- a/libkcal/icalformatimpl.cpp +++ b/libkcal/icalformatimpl.cpp | |||
@@ -1,2174 +1,2166 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <qdatetime.h> | 21 | #include <qdatetime.h> |
22 | #include <qstring.h> | 22 | #include <qstring.h> |
23 | #include <qptrlist.h> | 23 | #include <qptrlist.h> |
24 | #include <qfile.h> | 24 | #include <qfile.h> |
25 | 25 | ||
26 | #include <kdebug.h> | 26 | #include <kdebug.h> |
27 | #include <klocale.h> | 27 | #include <klocale.h> |
28 | #include <kglobal.h> | 28 | #include <kglobal.h> |
29 | 29 | ||
30 | extern "C" { | 30 | extern "C" { |
31 | #include <ical.h> | 31 | #include <ical.h> |
32 | #include <icalss.h> | 32 | #include <icalss.h> |
33 | #include <icalparser.h> | 33 | #include <icalparser.h> |
34 | #include <icalrestriction.h> | 34 | #include <icalrestriction.h> |
35 | } | 35 | } |
36 | 36 | ||
37 | #include "calendar.h" | 37 | #include "calendar.h" |
38 | #include "journal.h" | 38 | #include "journal.h" |
39 | #include "icalformat.h" | 39 | #include "icalformat.h" |
40 | #include "icalformatimpl.h" | 40 | #include "icalformatimpl.h" |
41 | #include "compat.h" | 41 | #include "compat.h" |
42 | 42 | ||
43 | #define _ICAL_VERSION "2.0" | 43 | #define _ICAL_VERSION "2.0" |
44 | 44 | ||
45 | using namespace KCal; | 45 | using namespace KCal; |
46 | 46 | ||
47 | const int gSecondsPerMinute = 60; | 47 | const int gSecondsPerMinute = 60; |
48 | const int gSecondsPerHour = gSecondsPerMinute * 60; | 48 | const int gSecondsPerHour = gSecondsPerMinute * 60; |
49 | const int gSecondsPerDay = gSecondsPerHour * 24; | 49 | const int gSecondsPerDay = gSecondsPerHour * 24; |
50 | const int gSecondsPerWeek = gSecondsPerDay * 7; | 50 | const int gSecondsPerWeek = gSecondsPerDay * 7; |
51 | 51 | ||
52 | ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) : | 52 | ICalFormatImpl::ICalFormatImpl( ICalFormat *parent ) : |
53 | mParent( parent ), mCalendarVersion( 0 ) | 53 | mParent( parent ), mCalendarVersion( 0 ) |
54 | { | 54 | { |
55 | mCompat = new Compat; | 55 | mCompat = new Compat; |
56 | } | 56 | } |
57 | 57 | ||
58 | ICalFormatImpl::~ICalFormatImpl() | 58 | ICalFormatImpl::~ICalFormatImpl() |
59 | { | 59 | { |
60 | delete mCompat; | 60 | delete mCompat; |
61 | } | 61 | } |
62 | 62 | ||
63 | class ToStringVisitor : public Incidence::Visitor | 63 | class ToStringVisitor : public Incidence::Visitor |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {} | 66 | ToStringVisitor( ICalFormatImpl *impl ) : mImpl( impl ), mComponent( 0 ) {} |
67 | 67 | ||
68 | bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; } | 68 | bool visit( Event *e ) { mComponent = mImpl->writeEvent( e ); return true; } |
69 | bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; } | 69 | bool visit( Todo *e ) { mComponent = mImpl->writeTodo( e ); return true; } |
70 | bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; } | 70 | bool visit( Journal *e ) { mComponent = mImpl->writeJournal( e ); return true; } |
71 | 71 | ||
72 | icalcomponent *component() { return mComponent; } | 72 | icalcomponent *component() { return mComponent; } |
73 | 73 | ||
74 | private: | 74 | private: |
75 | ICalFormatImpl *mImpl; | 75 | ICalFormatImpl *mImpl; |
76 | icalcomponent *mComponent; | 76 | icalcomponent *mComponent; |
77 | }; | 77 | }; |
78 | 78 | ||
79 | icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence) | 79 | icalcomponent *ICalFormatImpl::writeIncidence(Incidence *incidence) |
80 | { | 80 | { |
81 | ToStringVisitor v( this ); | 81 | ToStringVisitor v( this ); |
82 | incidence->accept(v); | 82 | incidence->accept(v); |
83 | return v.component(); | 83 | return v.component(); |
84 | } | 84 | } |
85 | 85 | ||
86 | icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) | 86 | icalcomponent *ICalFormatImpl::writeTodo(Todo *todo) |
87 | { | 87 | { |
88 | QString tmpStr; | 88 | QString tmpStr; |
89 | QStringList tmpStrList; | 89 | QStringList tmpStrList; |
90 | 90 | ||
91 | icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT); | 91 | icalcomponent *vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT); |
92 | 92 | ||
93 | writeIncidence(vtodo,todo); | 93 | writeIncidence(vtodo,todo); |
94 | 94 | ||
95 | // due date | 95 | // due date |
96 | if (todo->hasDueDate()) { | 96 | if (todo->hasDueDate()) { |
97 | icaltimetype due; | 97 | icaltimetype due; |
98 | if (todo->doesFloat()) { | 98 | if (todo->doesFloat()) { |
99 | due = writeICalDate(todo->dtDue().date()); | 99 | due = writeICalDate(todo->dtDue().date()); |
100 | } else { | 100 | } else { |
101 | due = writeICalDateTime(todo->dtDue()); | 101 | due = writeICalDateTime(todo->dtDue()); |
102 | } | 102 | } |
103 | icalcomponent_add_property(vtodo,icalproperty_new_due(due)); | 103 | icalcomponent_add_property(vtodo,icalproperty_new_due(due)); |
104 | } | 104 | } |
105 | 105 | ||
106 | // start time | 106 | // start time |
107 | if (todo->hasStartDate()) { | 107 | if (todo->hasStartDate()) { |
108 | icaltimetype start; | 108 | icaltimetype start; |
109 | if (todo->doesFloat()) { | 109 | if (todo->doesFloat()) { |
110 | // kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl; | 110 | // kdDebug(5800) << "§§ Incidence " << todo->summary() << " floats." << endl; |
111 | start = writeICalDate(todo->dtStart().date()); | 111 | start = writeICalDate(todo->dtStart().date()); |
112 | } else { | 112 | } else { |
113 | // kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; | 113 | // kdDebug(5800) << "§§ incidence " << todo->summary() << " has time." << endl; |
114 | start = writeICalDateTime(todo->dtStart()); | 114 | start = writeICalDateTime(todo->dtStart()); |
115 | } | 115 | } |
116 | icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); | 116 | icalcomponent_add_property(vtodo,icalproperty_new_dtstart(start)); |
117 | } | 117 | } |
118 | 118 | ||
119 | // completion date | 119 | // completion date |
120 | if (todo->isCompleted()) { | 120 | if (todo->isCompleted()) { |
121 | if (!todo->hasCompletedDate()) { | 121 | if (!todo->hasCompletedDate()) { |
122 | // If todo was created by KOrganizer <2.2 it has no correct completion | 122 | // If todo was created by KOrganizer <2.2 it has no correct completion |
123 | // date. Set it to now. | 123 | // date. Set it to now. |
124 | todo->setCompleted(QDateTime::currentDateTime()); | 124 | todo->setCompleted(QDateTime::currentDateTime()); |
125 | } | 125 | } |
126 | icaltimetype completed = writeICalDateTime(todo->completed()); | 126 | icaltimetype completed = writeICalDateTime(todo->completed()); |
127 | icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); | 127 | icalcomponent_add_property(vtodo,icalproperty_new_completed(completed)); |
128 | } | 128 | } |
129 | 129 | ||
130 | icalcomponent_add_property(vtodo, | 130 | icalcomponent_add_property(vtodo, |
131 | icalproperty_new_percentcomplete(todo->percentComplete())); | 131 | icalproperty_new_percentcomplete(todo->percentComplete())); |
132 | 132 | ||
133 | return vtodo; | 133 | return vtodo; |
134 | } | 134 | } |
135 | 135 | ||
136 | icalcomponent *ICalFormatImpl::writeEvent(Event *event) | 136 | icalcomponent *ICalFormatImpl::writeEvent(Event *event) |
137 | { | 137 | { |
138 | kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() | 138 | kdDebug(5800) << "Write Event '" << event->summary() << "' (" << event->uid() |
139 | << ")" << endl; | 139 | << ")" << endl; |
140 | 140 | ||
141 | QString tmpStr; | 141 | QString tmpStr; |
142 | QStringList tmpStrList; | 142 | QStringList tmpStrList; |
143 | 143 | ||
144 | icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); | 144 | icalcomponent *vevent = icalcomponent_new(ICAL_VEVENT_COMPONENT); |
145 | 145 | ||
146 | writeIncidence(vevent,event); | 146 | writeIncidence(vevent,event); |
147 | 147 | ||
148 | // start time | 148 | // start time |
149 | icaltimetype start; | 149 | icaltimetype start; |
150 | if (event->doesFloat()) { | 150 | if (event->doesFloat()) { |
151 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; | 151 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; |
152 | start = writeICalDate(event->dtStart().date()); | 152 | start = writeICalDate(event->dtStart().date()); |
153 | } else { | 153 | } else { |
154 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; | 154 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; |
155 | start = writeICalDateTime(event->dtStart()); | 155 | start = writeICalDateTime(event->dtStart()); |
156 | } | 156 | } |
157 | icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); | 157 | icalcomponent_add_property(vevent,icalproperty_new_dtstart(start)); |
158 | 158 | ||
159 | if (event->hasEndDate()) { | 159 | if (event->hasEndDate()) { |
160 | // end time | 160 | // end time |
161 | icaltimetype end; | 161 | icaltimetype end; |
162 | if (event->doesFloat()) { | 162 | if (event->doesFloat()) { |
163 | // kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; | 163 | // kdDebug(5800) << "§§ Event " << event->summary() << " floats." << endl; |
164 | // +1 day because end date is non-inclusive. | 164 | // +1 day because end date is non-inclusive. |
165 | end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); | 165 | end = writeICalDate( event->dtEnd().date().addDays( 1 ) ); |
166 | } else { | 166 | } else { |
167 | // kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; | 167 | // kdDebug(5800) << "§§ Event " << event->summary() << " has time." << endl; |
168 | end = writeICalDateTime(event->dtEnd()); | 168 | end = writeICalDateTime(event->dtEnd()); |
169 | } | 169 | } |
170 | icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); | 170 | icalcomponent_add_property(vevent,icalproperty_new_dtend(end)); |
171 | } | 171 | } |
172 | 172 | ||
173 | // TODO: attachments, resources | 173 | // TODO: attachments, resources |
174 | #if 0 | 174 | #if 0 |
175 | // attachments | 175 | // attachments |
176 | tmpStrList = anEvent->attachments(); | 176 | tmpStrList = anEvent->attachments(); |
177 | for ( QStringList::Iterator it = tmpStrList.begin(); | 177 | for ( QStringList::Iterator it = tmpStrList.begin(); |
178 | it != tmpStrList.end(); | 178 | it != tmpStrList.end(); |
179 | ++it ) | 179 | ++it ) |
180 | addPropValue(vevent, VCAttachProp, (*it).utf8()); | 180 | addPropValue(vevent, VCAttachProp, (*it).utf8()); |
181 | 181 | ||
182 | // resources | 182 | // resources |
183 | tmpStrList = anEvent->resources(); | 183 | tmpStrList = anEvent->resources(); |
184 | tmpStr = tmpStrList.join(";"); | 184 | tmpStr = tmpStrList.join(";"); |
185 | if (!tmpStr.isEmpty()) | 185 | if (!tmpStr.isEmpty()) |
186 | addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); | 186 | addPropValue(vevent, VCResourcesProp, tmpStr.utf8()); |
187 | 187 | ||
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | // Transparency | 190 | // Transparency |
191 | switch( event->transparency() ) { | 191 | switch( event->transparency() ) { |
192 | case Event::Transparent: | 192 | case Event::Transparent: |
193 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); | 193 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_TRANSPARENT)); |
194 | break; | 194 | break; |
195 | case Event::Opaque: | 195 | case Event::Opaque: |
196 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); | 196 | icalcomponent_add_property(vevent, icalproperty_new_transp(ICAL_TRANSP_OPAQUE)); |
197 | break; | 197 | break; |
198 | } | 198 | } |
199 | 199 | ||
200 | return vevent; | 200 | return vevent; |
201 | } | 201 | } |
202 | 202 | ||
203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, | 203 | icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy, |
204 | Scheduler::Method method) | 204 | Scheduler::Method method) |
205 | { | 205 | { |
206 | #if QT_VERSION >= 300 | 206 | #if QT_VERSION >= 300 |
207 | kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: " | 207 | kdDebug(5800) << "icalformatimpl: writeFreeBusy: startDate: " |
208 | << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: " | 208 | << freebusy->dtStart().toString("ddd MMMM d yyyy: h:m:s ap") << " End Date: " |
209 | << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl; | 209 | << freebusy->dtEnd().toString("ddd MMMM d yyyy: h:m:s ap") << endl; |
210 | #endif | 210 | #endif |
211 | 211 | ||
212 | icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); | 212 | icalcomponent *vfreebusy = icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); |
213 | 213 | ||
214 | writeIncidenceBase(vfreebusy,freebusy); | 214 | writeIncidenceBase(vfreebusy,freebusy); |
215 | 215 | ||
216 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( | 216 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( |
217 | writeICalDateTime(freebusy->dtStart()))); | 217 | writeICalDateTime(freebusy->dtStart()))); |
218 | 218 | ||
219 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( | 219 | icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( |
220 | writeICalDateTime(freebusy->dtEnd()))); | 220 | writeICalDateTime(freebusy->dtEnd()))); |
221 | 221 | ||
222 | if (method == Scheduler::Request) { | 222 | if (method == Scheduler::Request) { |
223 | icalcomponent_add_property(vfreebusy,icalproperty_new_uid( | 223 | icalcomponent_add_property(vfreebusy,icalproperty_new_uid( |
224 | freebusy->uid().utf8())); | 224 | freebusy->uid().utf8())); |
225 | } | 225 | } |
226 | 226 | ||
227 | //Loops through all the periods in the freebusy object | 227 | //Loops through all the periods in the freebusy object |
228 | QValueList<Period> list = freebusy->busyPeriods(); | 228 | QValueList<Period> list = freebusy->busyPeriods(); |
229 | QValueList<Period>::Iterator it; | 229 | QValueList<Period>::Iterator it; |
230 | icalperiodtype period; | 230 | icalperiodtype period; |
231 | for (it = list.begin(); it!= list.end(); ++it) { | 231 | for (it = list.begin(); it!= list.end(); ++it) { |
232 | period.start = writeICalDateTime((*it).start()); | 232 | period.start = writeICalDateTime((*it).start()); |
233 | period.end = writeICalDateTime((*it).end()); | 233 | period.end = writeICalDateTime((*it).end()); |
234 | icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); | 234 | icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); |
235 | } | 235 | } |
236 | 236 | ||
237 | return vfreebusy; | 237 | return vfreebusy; |
238 | } | 238 | } |
239 | 239 | ||
240 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) | 240 | icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) |
241 | { | 241 | { |
242 | icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); | 242 | icalcomponent *vjournal = icalcomponent_new(ICAL_VJOURNAL_COMPONENT); |
243 | 243 | ||
244 | writeIncidence(vjournal,journal); | 244 | writeIncidence(vjournal,journal); |
245 | 245 | ||
246 | // start time | 246 | // start time |
247 | if (journal->dtStart().isValid()) { | 247 | if (journal->dtStart().isValid()) { |
248 | icaltimetype start; | 248 | icaltimetype start; |
249 | if (journal->doesFloat()) { | 249 | if (journal->doesFloat()) { |
250 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; | 250 | // kdDebug(5800) << "§§ Incidence " << event->summary() << " floats." << endl; |
251 | start = writeICalDate(journal->dtStart().date()); | 251 | start = writeICalDate(journal->dtStart().date()); |
252 | } else { | 252 | } else { |
253 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; | 253 | // kdDebug(5800) << "§§ incidence " << event->summary() << " has time." << endl; |
254 | start = writeICalDateTime(journal->dtStart()); | 254 | start = writeICalDateTime(journal->dtStart()); |
255 | } | 255 | } |
256 | icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); | 256 | icalcomponent_add_property(vjournal,icalproperty_new_dtstart(start)); |
257 | } | 257 | } |
258 | 258 | ||
259 | return vjournal; | 259 | return vjournal; |
260 | } | 260 | } |
261 | 261 | ||
262 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) | 262 | void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence) |
263 | { | 263 | { |
264 | // pilot sync stuff | 264 | // pilot sync stuff |
265 | // TODO: move this application-specific code to kpilot | 265 | // TODO: move this application-specific code to kpilot |
266 | if (incidence->pilotId()) { | 266 | if (incidence->pilotId()) { |
267 | incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); | 267 | incidence->setNonKDECustomProperty("X-PILOTID", QString::number(incidence->pilotId())); |
268 | incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); | 268 | incidence->setNonKDECustomProperty("X-PILOTSTAT", QString::number(incidence->syncStatus())); |
269 | } | 269 | } |
270 | if (incidence->zaurusId() >= 0) { | 270 | if (incidence->zaurusId() >= 0) { |
271 | incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId())); | 271 | incidence->setNonKDECustomProperty("X-ZAURUSID", QString::number(incidence->zaurusId())); |
272 | } | 272 | } |
273 | 273 | ||
274 | if (incidence->zaurusUid() > 0) { | 274 | if (incidence->zaurusUid() > 0) { |
275 | incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid())); | 275 | incidence->setNonKDECustomProperty("X-ZAURUSUID", QString::number(incidence->zaurusUid())); |
276 | } | 276 | } |
277 | if (incidence->zaurusStat() > 0) { | ||
278 | incidence->setNonKDECustomProperty("X-ZAURUSSTAT", QString::number(incidence->zaurusStat())); | ||
279 | } | ||
280 | 277 | ||
281 | writeIncidenceBase(parent,incidence); | 278 | writeIncidenceBase(parent,incidence); |
282 | if (incidence->cancelled()) { | 279 | if (incidence->cancelled()) { |
283 | icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); | 280 | icalcomponent_add_property(parent,icalproperty_new_status(ICAL_STATUS_CANCELLED)); |
284 | } | 281 | } |
285 | 282 | ||
286 | // creation date | 283 | // creation date |
287 | icalcomponent_add_property(parent,icalproperty_new_created( | 284 | icalcomponent_add_property(parent,icalproperty_new_created( |
288 | writeICalDateTime(incidence->created()))); | 285 | writeICalDateTime(incidence->created()))); |
289 | 286 | ||
290 | // unique id | 287 | // unique id |
291 | icalcomponent_add_property(parent,icalproperty_new_uid( | 288 | icalcomponent_add_property(parent,icalproperty_new_uid( |
292 | incidence->uid().utf8())); | 289 | incidence->uid().utf8())); |
293 | 290 | ||
294 | // revision | 291 | // revision |
295 | icalcomponent_add_property(parent,icalproperty_new_sequence( | 292 | icalcomponent_add_property(parent,icalproperty_new_sequence( |
296 | incidence->revision())); | 293 | incidence->revision())); |
297 | 294 | ||
298 | // last modification date | 295 | // last modification date |
299 | icalcomponent_add_property(parent,icalproperty_new_lastmodified( | 296 | icalcomponent_add_property(parent,icalproperty_new_lastmodified( |
300 | writeICalDateTime(incidence->lastModified()))); | 297 | writeICalDateTime(incidence->lastModified()))); |
301 | 298 | ||
302 | // description | 299 | // description |
303 | if (!incidence->description().isEmpty()) { | 300 | if (!incidence->description().isEmpty()) { |
304 | icalcomponent_add_property(parent,icalproperty_new_description( | 301 | icalcomponent_add_property(parent,icalproperty_new_description( |
305 | incidence->description().utf8())); | 302 | incidence->description().utf8())); |
306 | } | 303 | } |
307 | 304 | ||
308 | // summary | 305 | // summary |
309 | if (!incidence->summary().isEmpty()) { | 306 | if (!incidence->summary().isEmpty()) { |
310 | icalcomponent_add_property(parent,icalproperty_new_summary( | 307 | icalcomponent_add_property(parent,icalproperty_new_summary( |
311 | incidence->summary().utf8())); | 308 | incidence->summary().utf8())); |
312 | } | 309 | } |
313 | 310 | ||
314 | // location | 311 | // location |
315 | if (!incidence->location().isEmpty()) { | 312 | if (!incidence->location().isEmpty()) { |
316 | icalcomponent_add_property(parent,icalproperty_new_location( | 313 | icalcomponent_add_property(parent,icalproperty_new_location( |
317 | incidence->location().utf8())); | 314 | incidence->location().utf8())); |
318 | } | 315 | } |
319 | 316 | ||
320 | // TODO: | 317 | // TODO: |
321 | // status | 318 | // status |
322 | // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); | 319 | // addPropValue(parent, VCStatusProp, incidence->getStatusStr().utf8()); |
323 | 320 | ||
324 | // secrecy | 321 | // secrecy |
325 | enum icalproperty_class classInt; | 322 | enum icalproperty_class classInt; |
326 | switch (incidence->secrecy()) { | 323 | switch (incidence->secrecy()) { |
327 | case Incidence::SecrecyPublic: | 324 | case Incidence::SecrecyPublic: |
328 | classInt = ICAL_CLASS_PUBLIC; | 325 | classInt = ICAL_CLASS_PUBLIC; |
329 | break; | 326 | break; |
330 | case Incidence::SecrecyConfidential: | 327 | case Incidence::SecrecyConfidential: |
331 | classInt = ICAL_CLASS_CONFIDENTIAL; | 328 | classInt = ICAL_CLASS_CONFIDENTIAL; |
332 | break; | 329 | break; |
333 | case Incidence::SecrecyPrivate: | 330 | case Incidence::SecrecyPrivate: |
334 | classInt =ICAL_CLASS_PRIVATE ; | 331 | classInt =ICAL_CLASS_PRIVATE ; |
335 | default: | 332 | default: |
336 | classInt =ICAL_CLASS_PRIVATE ; | 333 | classInt =ICAL_CLASS_PRIVATE ; |
337 | break; | 334 | break; |
338 | } | 335 | } |
339 | icalcomponent_add_property(parent,icalproperty_new_class(classInt)); | 336 | icalcomponent_add_property(parent,icalproperty_new_class(classInt)); |
340 | 337 | ||
341 | // priority | 338 | // priority |
342 | icalcomponent_add_property(parent,icalproperty_new_priority( | 339 | icalcomponent_add_property(parent,icalproperty_new_priority( |
343 | incidence->priority())); | 340 | incidence->priority())); |
344 | 341 | ||
345 | // categories | 342 | // categories |
346 | QStringList categories = incidence->categories(); | 343 | QStringList categories = incidence->categories(); |
347 | QStringList::Iterator it; | 344 | QStringList::Iterator it; |
348 | for(it = categories.begin(); it != categories.end(); ++it ) { | 345 | for(it = categories.begin(); it != categories.end(); ++it ) { |
349 | icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); | 346 | icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); |
350 | } | 347 | } |
351 | // TODO: Ensure correct concatenation of categories properties. | 348 | // TODO: Ensure correct concatenation of categories properties. |
352 | 349 | ||
353 | /* | 350 | /* |
354 | // categories | 351 | // categories |
355 | tmpStrList = incidence->getCategories(); | 352 | tmpStrList = incidence->getCategories(); |
356 | tmpStr = ""; | 353 | tmpStr = ""; |
357 | QString catStr; | 354 | QString catStr; |
358 | for ( QStringList::Iterator it = tmpStrList.begin(); | 355 | for ( QStringList::Iterator it = tmpStrList.begin(); |
359 | it != tmpStrList.end(); | 356 | it != tmpStrList.end(); |
360 | ++it ) { | 357 | ++it ) { |
361 | catStr = *it; | 358 | catStr = *it; |
362 | if (catStr[0] == ' ') | 359 | if (catStr[0] == ' ') |
363 | tmpStr += catStr.mid(1); | 360 | tmpStr += catStr.mid(1); |
364 | else | 361 | else |
365 | tmpStr += catStr; | 362 | tmpStr += catStr; |
366 | // this must be a ';' character as the vCalendar specification requires! | 363 | // this must be a ';' character as the vCalendar specification requires! |
367 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 364 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
368 | // read in. | 365 | // read in. |
369 | tmpStr += ";"; | 366 | tmpStr += ";"; |
370 | } | 367 | } |
371 | if (!tmpStr.isEmpty()) { | 368 | if (!tmpStr.isEmpty()) { |
372 | tmpStr.truncate(tmpStr.length()-1); | 369 | tmpStr.truncate(tmpStr.length()-1); |
373 | icalcomponent_add_property(parent,icalproperty_new_categories( | 370 | icalcomponent_add_property(parent,icalproperty_new_categories( |
374 | writeText(incidence->getCategories().join(";")))); | 371 | writeText(incidence->getCategories().join(";")))); |
375 | } | 372 | } |
376 | */ | 373 | */ |
377 | 374 | ||
378 | // related event | 375 | // related event |
379 | if (incidence->relatedTo()) { | 376 | if (incidence->relatedTo()) { |
380 | icalcomponent_add_property(parent,icalproperty_new_relatedto( | 377 | icalcomponent_add_property(parent,icalproperty_new_relatedto( |
381 | incidence->relatedTo()->uid().utf8())); | 378 | incidence->relatedTo()->uid().utf8())); |
382 | } | 379 | } |
383 | 380 | ||
384 | // recurrence rule stuff | 381 | // recurrence rule stuff |
385 | Recurrence *recur = incidence->recurrence(); | 382 | Recurrence *recur = incidence->recurrence(); |
386 | if (recur->doesRecur()) { | 383 | if (recur->doesRecur()) { |
387 | 384 | ||
388 | icalcomponent_add_property(parent,writeRecurrenceRule(recur)); | 385 | icalcomponent_add_property(parent,writeRecurrenceRule(recur)); |
389 | } | 386 | } |
390 | 387 | ||
391 | // recurrence excpetion dates | 388 | // recurrence excpetion dates |
392 | DateList dateList = incidence->exDates(); | 389 | DateList dateList = incidence->exDates(); |
393 | DateList::ConstIterator exIt; | 390 | DateList::ConstIterator exIt; |
394 | for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { | 391 | for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { |
395 | icalcomponent_add_property(parent,icalproperty_new_exdate( | 392 | icalcomponent_add_property(parent,icalproperty_new_exdate( |
396 | writeICalDate(*exIt))); | 393 | writeICalDate(*exIt))); |
397 | } | 394 | } |
398 | 395 | ||
399 | // attachments | 396 | // attachments |
400 | QPtrList<Attachment> attachments = incidence->attachments(); | 397 | QPtrList<Attachment> attachments = incidence->attachments(); |
401 | for (Attachment *at = attachments.first(); at; at = attachments.next()) | 398 | for (Attachment *at = attachments.first(); at; at = attachments.next()) |
402 | icalcomponent_add_property(parent,writeAttachment(at)); | 399 | icalcomponent_add_property(parent,writeAttachment(at)); |
403 | 400 | ||
404 | // alarms | 401 | // alarms |
405 | QPtrList<Alarm> alarms = incidence->alarms(); | 402 | QPtrList<Alarm> alarms = incidence->alarms(); |
406 | Alarm* alarm; | 403 | Alarm* alarm; |
407 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 404 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
408 | if (alarm->enabled()) { | 405 | if (alarm->enabled()) { |
409 | kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; | 406 | kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; |
410 | icalcomponent_add_component(parent,writeAlarm(alarm)); | 407 | icalcomponent_add_component(parent,writeAlarm(alarm)); |
411 | } | 408 | } |
412 | } | 409 | } |
413 | 410 | ||
414 | // duration | 411 | // duration |
415 | 412 | ||
416 | // turned off as it always is set to PTS0 (and must not occur together with DTEND | 413 | // turned off as it always is set to PTS0 (and must not occur together with DTEND |
417 | 414 | ||
418 | // if (incidence->hasDuration()) { | 415 | // if (incidence->hasDuration()) { |
419 | // icaldurationtype duration; | 416 | // icaldurationtype duration; |
420 | // duration = writeICalDuration(incidence->duration()); | 417 | // duration = writeICalDuration(incidence->duration()); |
421 | // icalcomponent_add_property(parent,icalproperty_new_duration(duration)); | 418 | // icalcomponent_add_property(parent,icalproperty_new_duration(duration)); |
422 | // } | 419 | // } |
423 | } | 420 | } |
424 | 421 | ||
425 | void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 422 | void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) |
426 | { | 423 | { |
427 | icalcomponent_add_property(parent,icalproperty_new_dtstamp( | 424 | icalcomponent_add_property(parent,icalproperty_new_dtstamp( |
428 | writeICalDateTime(QDateTime::currentDateTime()))); | 425 | writeICalDateTime(QDateTime::currentDateTime()))); |
429 | 426 | ||
430 | // organizer stuff | 427 | // organizer stuff |
431 | icalcomponent_add_property(parent,icalproperty_new_organizer( | 428 | icalcomponent_add_property(parent,icalproperty_new_organizer( |
432 | ("MAILTO:" + incidenceBase->organizer()).utf8())); | 429 | ("MAILTO:" + incidenceBase->organizer()).utf8())); |
433 | 430 | ||
434 | // attendees | 431 | // attendees |
435 | if (incidenceBase->attendeeCount() != 0) { | 432 | if (incidenceBase->attendeeCount() != 0) { |
436 | QPtrList<Attendee> al = incidenceBase->attendees(); | 433 | QPtrList<Attendee> al = incidenceBase->attendees(); |
437 | QPtrListIterator<Attendee> ai(al); | 434 | QPtrListIterator<Attendee> ai(al); |
438 | for (; ai.current(); ++ai) { | 435 | for (; ai.current(); ++ai) { |
439 | icalcomponent_add_property(parent,writeAttendee(ai.current())); | 436 | icalcomponent_add_property(parent,writeAttendee(ai.current())); |
440 | } | 437 | } |
441 | } | 438 | } |
442 | 439 | ||
443 | // custom properties | 440 | // custom properties |
444 | writeCustomProperties(parent, incidenceBase); | 441 | writeCustomProperties(parent, incidenceBase); |
445 | } | 442 | } |
446 | 443 | ||
447 | void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) | 444 | void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) |
448 | { | 445 | { |
449 | QMap<QCString, QString> custom = properties->customProperties(); | 446 | QMap<QCString, QString> custom = properties->customProperties(); |
450 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { | 447 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { |
451 | icalproperty *p = icalproperty_new_x(c.data().utf8()); | 448 | icalproperty *p = icalproperty_new_x(c.data().utf8()); |
452 | icalproperty_set_x_name(p,c.key()); | 449 | icalproperty_set_x_name(p,c.key()); |
453 | icalcomponent_add_property(parent,p); | 450 | icalcomponent_add_property(parent,p); |
454 | } | 451 | } |
455 | } | 452 | } |
456 | 453 | ||
457 | icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) | 454 | icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) |
458 | { | 455 | { |
459 | icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); | 456 | icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); |
460 | 457 | ||
461 | if (!attendee->name().isEmpty()) { | 458 | if (!attendee->name().isEmpty()) { |
462 | icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); | 459 | icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); |
463 | } | 460 | } |
464 | 461 | ||
465 | 462 | ||
466 | icalproperty_add_parameter(p,icalparameter_new_rsvp( | 463 | icalproperty_add_parameter(p,icalparameter_new_rsvp( |
467 | attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); | 464 | attendee->RSVP() ? ICAL_RSVP_TRUE : ICAL_RSVP_FALSE )); |
468 | 465 | ||
469 | icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; | 466 | icalparameter_partstat status = ICAL_PARTSTAT_NEEDSACTION; |
470 | switch (attendee->status()) { | 467 | switch (attendee->status()) { |
471 | default: | 468 | default: |
472 | case Attendee::NeedsAction: | 469 | case Attendee::NeedsAction: |
473 | status = ICAL_PARTSTAT_NEEDSACTION; | 470 | status = ICAL_PARTSTAT_NEEDSACTION; |
474 | break; | 471 | break; |
475 | case Attendee::Accepted: | 472 | case Attendee::Accepted: |
476 | status = ICAL_PARTSTAT_ACCEPTED; | 473 | status = ICAL_PARTSTAT_ACCEPTED; |
477 | break; | 474 | break; |
478 | case Attendee::Declined: | 475 | case Attendee::Declined: |
479 | status = ICAL_PARTSTAT_DECLINED; | 476 | status = ICAL_PARTSTAT_DECLINED; |
480 | break; | 477 | break; |
481 | case Attendee::Tentative: | 478 | case Attendee::Tentative: |
482 | status = ICAL_PARTSTAT_TENTATIVE; | 479 | status = ICAL_PARTSTAT_TENTATIVE; |
483 | break; | 480 | break; |
484 | case Attendee::Delegated: | 481 | case Attendee::Delegated: |
485 | status = ICAL_PARTSTAT_DELEGATED; | 482 | status = ICAL_PARTSTAT_DELEGATED; |
486 | break; | 483 | break; |
487 | case Attendee::Completed: | 484 | case Attendee::Completed: |
488 | status = ICAL_PARTSTAT_COMPLETED; | 485 | status = ICAL_PARTSTAT_COMPLETED; |
489 | break; | 486 | break; |
490 | case Attendee::InProcess: | 487 | case Attendee::InProcess: |
491 | status = ICAL_PARTSTAT_INPROCESS; | 488 | status = ICAL_PARTSTAT_INPROCESS; |
492 | break; | 489 | break; |
493 | } | 490 | } |
494 | icalproperty_add_parameter(p,icalparameter_new_partstat(status)); | 491 | icalproperty_add_parameter(p,icalparameter_new_partstat(status)); |
495 | 492 | ||
496 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; | 493 | icalparameter_role role = ICAL_ROLE_REQPARTICIPANT; |
497 | switch (attendee->role()) { | 494 | switch (attendee->role()) { |
498 | case Attendee::Chair: | 495 | case Attendee::Chair: |
499 | role = ICAL_ROLE_CHAIR; | 496 | role = ICAL_ROLE_CHAIR; |
500 | break; | 497 | break; |
501 | default: | 498 | default: |
502 | case Attendee::ReqParticipant: | 499 | case Attendee::ReqParticipant: |
503 | role = ICAL_ROLE_REQPARTICIPANT; | 500 | role = ICAL_ROLE_REQPARTICIPANT; |
504 | break; | 501 | break; |
505 | case Attendee::OptParticipant: | 502 | case Attendee::OptParticipant: |
506 | role = ICAL_ROLE_OPTPARTICIPANT; | 503 | role = ICAL_ROLE_OPTPARTICIPANT; |
507 | break; | 504 | break; |
508 | case Attendee::NonParticipant: | 505 | case Attendee::NonParticipant: |
509 | role = ICAL_ROLE_NONPARTICIPANT; | 506 | role = ICAL_ROLE_NONPARTICIPANT; |
510 | break; | 507 | break; |
511 | } | 508 | } |
512 | icalproperty_add_parameter(p,icalparameter_new_role(role)); | 509 | icalproperty_add_parameter(p,icalparameter_new_role(role)); |
513 | 510 | ||
514 | if (!attendee->uid().isEmpty()) { | 511 | if (!attendee->uid().isEmpty()) { |
515 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); | 512 | icalparameter* icalparameter_uid = icalparameter_new_x(attendee->uid().utf8()); |
516 | icalparameter_set_xname(icalparameter_uid,"X-UID"); | 513 | icalparameter_set_xname(icalparameter_uid,"X-UID"); |
517 | icalproperty_add_parameter(p,icalparameter_uid); | 514 | icalproperty_add_parameter(p,icalparameter_uid); |
518 | } | 515 | } |
519 | 516 | ||
520 | return p; | 517 | return p; |
521 | } | 518 | } |
522 | 519 | ||
523 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) | 520 | icalproperty *ICalFormatImpl::writeAttachment(Attachment *att) |
524 | { | 521 | { |
525 | #if 0 | 522 | #if 0 |
526 | icalattachtype* attach = icalattachtype_new(); | 523 | icalattachtype* attach = icalattachtype_new(); |
527 | if (att->isURI()) | 524 | if (att->isURI()) |
528 | icalattachtype_set_url(attach, att->uri().utf8().data()); | 525 | icalattachtype_set_url(attach, att->uri().utf8().data()); |
529 | else | 526 | else |
530 | icalattachtype_set_base64(attach, att->data(), 0); | 527 | icalattachtype_set_base64(attach, att->data(), 0); |
531 | #endif | 528 | #endif |
532 | icalattach *attach; | 529 | icalattach *attach; |
533 | if (att->isURI()) | 530 | if (att->isURI()) |
534 | attach = icalattach_new_from_url( att->uri().utf8().data()); | 531 | attach = icalattach_new_from_url( att->uri().utf8().data()); |
535 | else | 532 | else |
536 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); | 533 | attach = icalattach_new_from_data ( (unsigned char *)att->data(), 0, 0); |
537 | icalproperty *p = icalproperty_new_attach(attach); | 534 | icalproperty *p = icalproperty_new_attach(attach); |
538 | if (!att->mimeType().isEmpty()) | 535 | if (!att->mimeType().isEmpty()) |
539 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); | 536 | icalproperty_add_parameter(p,icalparameter_new_fmttype(att->mimeType().utf8().data())); |
540 | 537 | ||
541 | if (att->isBinary()) { | 538 | if (att->isBinary()) { |
542 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); | 539 | icalproperty_add_parameter(p,icalparameter_new_value(ICAL_VALUE_BINARY)); |
543 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); | 540 | icalproperty_add_parameter(p,icalparameter_new_encoding(ICAL_ENCODING_BASE64)); |
544 | } | 541 | } |
545 | return p; | 542 | return p; |
546 | } | 543 | } |
547 | 544 | ||
548 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) | 545 | icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) |
549 | { | 546 | { |
550 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; | 547 | // kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; |
551 | 548 | ||
552 | icalrecurrencetype r; | 549 | icalrecurrencetype r; |
553 | 550 | ||
554 | icalrecurrencetype_clear(&r); | 551 | icalrecurrencetype_clear(&r); |
555 | 552 | ||
556 | int index = 0; | 553 | int index = 0; |
557 | int index2 = 0; | 554 | int index2 = 0; |
558 | 555 | ||
559 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 556 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
560 | QPtrList<int> tmpDays; | 557 | QPtrList<int> tmpDays; |
561 | int *tmpDay; | 558 | int *tmpDay; |
562 | Recurrence::rMonthPos *tmpPos; | 559 | Recurrence::rMonthPos *tmpPos; |
563 | bool datetime = false; | 560 | bool datetime = false; |
564 | int day; | 561 | int day; |
565 | int i; | 562 | int i; |
566 | 563 | ||
567 | switch(recur->doesRecur()) { | 564 | switch(recur->doesRecur()) { |
568 | case Recurrence::rMinutely: | 565 | case Recurrence::rMinutely: |
569 | r.freq = ICAL_MINUTELY_RECURRENCE; | 566 | r.freq = ICAL_MINUTELY_RECURRENCE; |
570 | datetime = true; | 567 | datetime = true; |
571 | break; | 568 | break; |
572 | case Recurrence::rHourly: | 569 | case Recurrence::rHourly: |
573 | r.freq = ICAL_HOURLY_RECURRENCE; | 570 | r.freq = ICAL_HOURLY_RECURRENCE; |
574 | datetime = true; | 571 | datetime = true; |
575 | break; | 572 | break; |
576 | case Recurrence::rDaily: | 573 | case Recurrence::rDaily: |
577 | r.freq = ICAL_DAILY_RECURRENCE; | 574 | r.freq = ICAL_DAILY_RECURRENCE; |
578 | break; | 575 | break; |
579 | case Recurrence::rWeekly: | 576 | case Recurrence::rWeekly: |
580 | r.freq = ICAL_WEEKLY_RECURRENCE; | 577 | r.freq = ICAL_WEEKLY_RECURRENCE; |
581 | r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); | 578 | r.week_start = static_cast<icalrecurrencetype_weekday>(recur->weekStart()%7 + 1); |
582 | for (i = 0; i < 7; i++) { | 579 | for (i = 0; i < 7; i++) { |
583 | if (recur->days().testBit(i)) { | 580 | if (recur->days().testBit(i)) { |
584 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 581 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
585 | r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); | 582 | r.by_day[index++] = icalrecurrencetype_day_day_of_week(day); |
586 | } | 583 | } |
587 | } | 584 | } |
588 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 585 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
589 | break; | 586 | break; |
590 | case Recurrence::rMonthlyPos: | 587 | case Recurrence::rMonthlyPos: |
591 | r.freq = ICAL_MONTHLY_RECURRENCE; | 588 | r.freq = ICAL_MONTHLY_RECURRENCE; |
592 | 589 | ||
593 | tmpPositions = recur->monthPositions(); | 590 | tmpPositions = recur->monthPositions(); |
594 | for (tmpPos = tmpPositions.first(); | 591 | for (tmpPos = tmpPositions.first(); |
595 | tmpPos; | 592 | tmpPos; |
596 | tmpPos = tmpPositions.next()) { | 593 | tmpPos = tmpPositions.next()) { |
597 | for (i = 0; i < 7; i++) { | 594 | for (i = 0; i < 7; i++) { |
598 | if (tmpPos->rDays.testBit(i)) { | 595 | if (tmpPos->rDays.testBit(i)) { |
599 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 596 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
600 | day += tmpPos->rPos*8; | 597 | day += tmpPos->rPos*8; |
601 | if (tmpPos->negative) day = -day; | 598 | if (tmpPos->negative) day = -day; |
602 | r.by_day[index++] = day; | 599 | r.by_day[index++] = day; |
603 | } | 600 | } |
604 | } | 601 | } |
605 | } | 602 | } |
606 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 603 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
607 | break; | 604 | break; |
608 | case Recurrence::rMonthlyDay: | 605 | case Recurrence::rMonthlyDay: |
609 | r.freq = ICAL_MONTHLY_RECURRENCE; | 606 | r.freq = ICAL_MONTHLY_RECURRENCE; |
610 | 607 | ||
611 | tmpDays = recur->monthDays(); | 608 | tmpDays = recur->monthDays(); |
612 | for (tmpDay = tmpDays.first(); | 609 | for (tmpDay = tmpDays.first(); |
613 | tmpDay; | 610 | tmpDay; |
614 | tmpDay = tmpDays.next()) { | 611 | tmpDay = tmpDays.next()) { |
615 | r.by_month_day[index++] = icalrecurrencetype_day_position(*tmpDay*8);//*tmpDay); | 612 | r.by_month_day[index++] = icalrecurrencetype_day_position(*tmpDay*8);//*tmpDay); |
616 | } | 613 | } |
617 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 614 | // r.by_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
618 | break; | 615 | break; |
619 | case Recurrence::rYearlyMonth: | 616 | case Recurrence::rYearlyMonth: |
620 | case Recurrence::rYearlyPos: | 617 | case Recurrence::rYearlyPos: |
621 | r.freq = ICAL_YEARLY_RECURRENCE; | 618 | r.freq = ICAL_YEARLY_RECURRENCE; |
622 | 619 | ||
623 | tmpDays = recur->yearNums(); | 620 | tmpDays = recur->yearNums(); |
624 | for (tmpDay = tmpDays.first(); | 621 | for (tmpDay = tmpDays.first(); |
625 | tmpDay; | 622 | tmpDay; |
626 | tmpDay = tmpDays.next()) { | 623 | tmpDay = tmpDays.next()) { |
627 | r.by_month[index++] = *tmpDay; | 624 | r.by_month[index++] = *tmpDay; |
628 | } | 625 | } |
629 | // r.by_set_pos[index] = ICAL_RECURRENCE_ARRAY_MAX; | 626 | // r.by_set_pos[index] = ICAL_RECURRENCE_ARRAY_MAX; |
630 | if (recur->doesRecur() == Recurrence::rYearlyPos) { | 627 | if (recur->doesRecur() == Recurrence::rYearlyPos) { |
631 | tmpPositions = recur->monthPositions(); | 628 | tmpPositions = recur->monthPositions(); |
632 | for (tmpPos = tmpPositions.first(); | 629 | for (tmpPos = tmpPositions.first(); |
633 | tmpPos; | 630 | tmpPos; |
634 | tmpPos = tmpPositions.next()) { | 631 | tmpPos = tmpPositions.next()) { |
635 | for (i = 0; i < 7; i++) { | 632 | for (i = 0; i < 7; i++) { |
636 | if (tmpPos->rDays.testBit(i)) { | 633 | if (tmpPos->rDays.testBit(i)) { |
637 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 | 634 | day = (i + 1)%7 + 1; // convert from Monday=0 to Sunday=1 |
638 | day += tmpPos->rPos*8; | 635 | day += tmpPos->rPos*8; |
639 | if (tmpPos->negative) day = -day; | 636 | if (tmpPos->negative) day = -day; |
640 | r.by_day[index2++] = day; | 637 | r.by_day[index2++] = day; |
641 | } | 638 | } |
642 | } | 639 | } |
643 | } | 640 | } |
644 | // r.by_day[index2] = ICAL_RECURRENCE_ARRAY_MAX; | 641 | // r.by_day[index2] = ICAL_RECURRENCE_ARRAY_MAX; |
645 | } | 642 | } |
646 | break; | 643 | break; |
647 | case Recurrence::rYearlyDay: | 644 | case Recurrence::rYearlyDay: |
648 | r.freq = ICAL_YEARLY_RECURRENCE; | 645 | r.freq = ICAL_YEARLY_RECURRENCE; |
649 | 646 | ||
650 | tmpDays = recur->yearNums(); | 647 | tmpDays = recur->yearNums(); |
651 | for (tmpDay = tmpDays.first(); | 648 | for (tmpDay = tmpDays.first(); |
652 | tmpDay; | 649 | tmpDay; |
653 | tmpDay = tmpDays.next()) { | 650 | tmpDay = tmpDays.next()) { |
654 | r.by_year_day[index++] = *tmpDay; | 651 | r.by_year_day[index++] = *tmpDay; |
655 | } | 652 | } |
656 | // r.by_year_day[index] = ICAL_RECURRENCE_ARRAY_MAX; | 653 | // r.by_year_day[index] = ICAL_RECURRENCE_ARRAY_MAX; |
657 | break; | 654 | break; |
658 | default: | 655 | default: |
659 | r.freq = ICAL_NO_RECURRENCE; | 656 | r.freq = ICAL_NO_RECURRENCE; |
660 | kdDebug(5800) << "ICalFormatImpl::writeRecurrence(): no recurrence" << endl; | 657 | kdDebug(5800) << "ICalFormatImpl::writeRecurrence(): no recurrence" << endl; |
661 | break; | 658 | break; |
662 | } | 659 | } |
663 | 660 | ||
664 | r.interval = recur->frequency(); | 661 | r.interval = recur->frequency(); |
665 | 662 | ||
666 | if (recur->duration() > 0) { | 663 | if (recur->duration() > 0) { |
667 | r.count = recur->duration(); | 664 | r.count = recur->duration(); |
668 | } else if (recur->duration() == -1) { | 665 | } else if (recur->duration() == -1) { |
669 | r.count = 0; | 666 | r.count = 0; |
670 | } else { | 667 | } else { |
671 | if (datetime) | 668 | if (datetime) |
672 | r.until = writeICalDateTime(recur->endDateTime()); | 669 | r.until = writeICalDateTime(recur->endDateTime()); |
673 | else | 670 | else |
674 | r.until = writeICalDate(recur->endDate()); | 671 | r.until = writeICalDate(recur->endDate()); |
675 | } | 672 | } |
676 | 673 | ||
677 | // Debug output | 674 | // Debug output |
678 | #if 0 | 675 | #if 0 |
679 | const char *str = icalrecurrencetype_as_string(&r); | 676 | const char *str = icalrecurrencetype_as_string(&r); |
680 | if (str) { | 677 | if (str) { |
681 | kdDebug(5800) << " String: " << str << endl; | 678 | kdDebug(5800) << " String: " << str << endl; |
682 | } else { | 679 | } else { |
683 | kdDebug(5800) << " No String" << endl; | 680 | kdDebug(5800) << " No String" << endl; |
684 | } | 681 | } |
685 | #endif | 682 | #endif |
686 | 683 | ||
687 | return icalproperty_new_rrule(r); | 684 | return icalproperty_new_rrule(r); |
688 | } | 685 | } |
689 | 686 | ||
690 | icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) | 687 | icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm) |
691 | { | 688 | { |
692 | icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT); | 689 | icalcomponent *a = icalcomponent_new(ICAL_VALARM_COMPONENT); |
693 | 690 | ||
694 | icalproperty_action action; | 691 | icalproperty_action action; |
695 | icalattach *attach = 0; | 692 | icalattach *attach = 0; |
696 | 693 | ||
697 | switch (alarm->type()) { | 694 | switch (alarm->type()) { |
698 | case Alarm::Procedure: | 695 | case Alarm::Procedure: |
699 | action = ICAL_ACTION_PROCEDURE; | 696 | action = ICAL_ACTION_PROCEDURE; |
700 | attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() ); | 697 | attach = icalattach_new_from_url( QFile::encodeName(alarm->programFile()).data() ); |
701 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 698 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
702 | if (!alarm->programArguments().isEmpty()) { | 699 | if (!alarm->programArguments().isEmpty()) { |
703 | icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8())); | 700 | icalcomponent_add_property(a,icalproperty_new_description(alarm->programArguments().utf8())); |
704 | } | 701 | } |
705 | break; | 702 | break; |
706 | case Alarm::Audio: | 703 | case Alarm::Audio: |
707 | action = ICAL_ACTION_AUDIO; | 704 | action = ICAL_ACTION_AUDIO; |
708 | if (!alarm->audioFile().isEmpty()) { | 705 | if (!alarm->audioFile().isEmpty()) { |
709 | attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); | 706 | attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); |
710 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 707 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
711 | } | 708 | } |
712 | break; | 709 | break; |
713 | case Alarm::Email: { | 710 | case Alarm::Email: { |
714 | action = ICAL_ACTION_EMAIL; | 711 | action = ICAL_ACTION_EMAIL; |
715 | QValueList<Person> addresses = alarm->mailAddresses(); | 712 | QValueList<Person> addresses = alarm->mailAddresses(); |
716 | for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { | 713 | for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { |
717 | icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); | 714 | icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); |
718 | if (!(*ad).name().isEmpty()) { | 715 | if (!(*ad).name().isEmpty()) { |
719 | icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); | 716 | icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); |
720 | } | 717 | } |
721 | icalcomponent_add_property(a,p); | 718 | icalcomponent_add_property(a,p); |
722 | } | 719 | } |
723 | icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); | 720 | icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); |
724 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); | 721 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); |
725 | QStringList attachments = alarm->mailAttachments(); | 722 | QStringList attachments = alarm->mailAttachments(); |
726 | if (attachments.count() > 0) { | 723 | if (attachments.count() > 0) { |
727 | for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { | 724 | for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { |
728 | attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); | 725 | attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); |
729 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); | 726 | icalcomponent_add_property(a,icalproperty_new_attach(attach)); |
730 | } | 727 | } |
731 | } | 728 | } |
732 | break; | 729 | break; |
733 | } | 730 | } |
734 | case Alarm::Display: | 731 | case Alarm::Display: |
735 | action = ICAL_ACTION_DISPLAY; | 732 | action = ICAL_ACTION_DISPLAY; |
736 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); | 733 | icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); |
737 | break; | 734 | break; |
738 | case Alarm::Invalid: | 735 | case Alarm::Invalid: |
739 | default: | 736 | default: |
740 | kdDebug(5800) << "Unknown type of alarm" << endl; | 737 | kdDebug(5800) << "Unknown type of alarm" << endl; |
741 | action = ICAL_ACTION_NONE; | 738 | action = ICAL_ACTION_NONE; |
742 | break; | 739 | break; |
743 | } | 740 | } |
744 | icalcomponent_add_property(a,icalproperty_new_action(action)); | 741 | icalcomponent_add_property(a,icalproperty_new_action(action)); |
745 | 742 | ||
746 | // Trigger time | 743 | // Trigger time |
747 | icaltriggertype trigger; | 744 | icaltriggertype trigger; |
748 | if ( alarm->hasTime() ) { | 745 | if ( alarm->hasTime() ) { |
749 | trigger.time = writeICalDateTime(alarm->time()); | 746 | trigger.time = writeICalDateTime(alarm->time()); |
750 | trigger.duration = icaldurationtype_null_duration(); | 747 | trigger.duration = icaldurationtype_null_duration(); |
751 | } else { | 748 | } else { |
752 | trigger.time = icaltime_null_time(); | 749 | trigger.time = icaltime_null_time(); |
753 | Duration offset; | 750 | Duration offset; |
754 | if ( alarm->hasStartOffset() ) | 751 | if ( alarm->hasStartOffset() ) |
755 | offset = alarm->startOffset(); | 752 | offset = alarm->startOffset(); |
756 | else | 753 | else |
757 | offset = alarm->endOffset(); | 754 | offset = alarm->endOffset(); |
758 | trigger.duration = icaldurationtype_from_int( offset.asSeconds() ); | 755 | trigger.duration = icaldurationtype_from_int( offset.asSeconds() ); |
759 | } | 756 | } |
760 | icalproperty *p = icalproperty_new_trigger(trigger); | 757 | icalproperty *p = icalproperty_new_trigger(trigger); |
761 | if ( alarm->hasEndOffset() ) | 758 | if ( alarm->hasEndOffset() ) |
762 | icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END)); | 759 | icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END)); |
763 | icalcomponent_add_property(a,p); | 760 | icalcomponent_add_property(a,p); |
764 | 761 | ||
765 | // Repeat count and duration | 762 | // Repeat count and duration |
766 | if (alarm->repeatCount()) { | 763 | if (alarm->repeatCount()) { |
767 | icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount())); | 764 | icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount())); |
768 | icalcomponent_add_property(a,icalproperty_new_duration( | 765 | icalcomponent_add_property(a,icalproperty_new_duration( |
769 | icaldurationtype_from_int(alarm->snoozeTime()*60))); | 766 | icaldurationtype_from_int(alarm->snoozeTime()*60))); |
770 | } | 767 | } |
771 | 768 | ||
772 | // Custom properties | 769 | // Custom properties |
773 | QMap<QCString, QString> custom = alarm->customProperties(); | 770 | QMap<QCString, QString> custom = alarm->customProperties(); |
774 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { | 771 | for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { |
775 | icalproperty *p = icalproperty_new_x(c.data().utf8()); | 772 | icalproperty *p = icalproperty_new_x(c.data().utf8()); |
776 | icalproperty_set_x_name(p,c.key()); | 773 | icalproperty_set_x_name(p,c.key()); |
777 | icalcomponent_add_property(a,p); | 774 | icalcomponent_add_property(a,p); |
778 | } | 775 | } |
779 | 776 | ||
780 | return a; | 777 | return a; |
781 | } | 778 | } |
782 | 779 | ||
783 | Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo) | 780 | Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo) |
784 | { | 781 | { |
785 | Todo *todo = new Todo; | 782 | Todo *todo = new Todo; |
786 | 783 | ||
787 | readIncidence(vtodo,todo); | 784 | readIncidence(vtodo,todo); |
788 | 785 | ||
789 | icalproperty *p = icalcomponent_get_first_property(vtodo,ICAL_ANY_PROPERTY); | 786 | icalproperty *p = icalcomponent_get_first_property(vtodo,ICAL_ANY_PROPERTY); |
790 | 787 | ||
791 | // int intvalue; | 788 | // int intvalue; |
792 | icaltimetype icaltime; | 789 | icaltimetype icaltime; |
793 | 790 | ||
794 | QStringList categories; | 791 | QStringList categories; |
795 | 792 | ||
796 | while (p) { | 793 | while (p) { |
797 | icalproperty_kind kind = icalproperty_isa(p); | 794 | icalproperty_kind kind = icalproperty_isa(p); |
798 | switch (kind) { | 795 | switch (kind) { |
799 | 796 | ||
800 | case ICAL_DUE_PROPERTY: // due date | 797 | case ICAL_DUE_PROPERTY: // due date |
801 | icaltime = icalproperty_get_due(p); | 798 | icaltime = icalproperty_get_due(p); |
802 | if (icaltime.is_date) { | 799 | if (icaltime.is_date) { |
803 | todo->setDtDue(QDateTime(readICalDate(icaltime),QTime(0,0,0))); | 800 | todo->setDtDue(QDateTime(readICalDate(icaltime),QTime(0,0,0))); |
804 | todo->setFloats(true); | 801 | todo->setFloats(true); |
805 | 802 | ||
806 | } else { | 803 | } else { |
807 | todo->setDtDue(readICalDateTime(icaltime)); | 804 | todo->setDtDue(readICalDateTime(icaltime)); |
808 | todo->setFloats(false); | 805 | todo->setFloats(false); |
809 | } | 806 | } |
810 | todo->setHasDueDate(true); | 807 | todo->setHasDueDate(true); |
811 | break; | 808 | break; |
812 | 809 | ||
813 | case ICAL_COMPLETED_PROPERTY: // completion date | 810 | case ICAL_COMPLETED_PROPERTY: // completion date |
814 | icaltime = icalproperty_get_completed(p); | 811 | icaltime = icalproperty_get_completed(p); |
815 | todo->setCompleted(readICalDateTime(icaltime)); | 812 | todo->setCompleted(readICalDateTime(icaltime)); |
816 | break; | 813 | break; |
817 | 814 | ||
818 | case ICAL_PERCENTCOMPLETE_PROPERTY: // Percent completed | 815 | case ICAL_PERCENTCOMPLETE_PROPERTY: // Percent completed |
819 | todo->setPercentComplete(icalproperty_get_percentcomplete(p)); | 816 | todo->setPercentComplete(icalproperty_get_percentcomplete(p)); |
820 | break; | 817 | break; |
821 | 818 | ||
822 | case ICAL_RELATEDTO_PROPERTY: // related todo (parent) | 819 | case ICAL_RELATEDTO_PROPERTY: // related todo (parent) |
823 | todo->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); | 820 | todo->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); |
824 | mTodosRelate.append(todo); | 821 | mTodosRelate.append(todo); |
825 | break; | 822 | break; |
826 | 823 | ||
827 | case ICAL_DTSTART_PROPERTY: | 824 | case ICAL_DTSTART_PROPERTY: |
828 | // Flag that todo has start date. Value is read in by readIncidence(). | 825 | // Flag that todo has start date. Value is read in by readIncidence(). |
829 | todo->setHasStartDate(true); | 826 | todo->setHasStartDate(true); |
830 | break; | 827 | break; |
831 | 828 | ||
832 | default: | 829 | default: |
833 | // kdDebug(5800) << "ICALFormat::readTodo(): Unknown property: " << kind | 830 | // kdDebug(5800) << "ICALFormat::readTodo(): Unknown property: " << kind |
834 | // << endl; | 831 | // << endl; |
835 | break; | 832 | break; |
836 | } | 833 | } |
837 | 834 | ||
838 | p = icalcomponent_get_next_property(vtodo,ICAL_ANY_PROPERTY); | 835 | p = icalcomponent_get_next_property(vtodo,ICAL_ANY_PROPERTY); |
839 | } | 836 | } |
840 | 837 | ||
841 | return todo; | 838 | return todo; |
842 | } | 839 | } |
843 | 840 | ||
844 | Event *ICalFormatImpl::readEvent(icalcomponent *vevent) | 841 | Event *ICalFormatImpl::readEvent(icalcomponent *vevent) |
845 | { | 842 | { |
846 | Event *event = new Event; | 843 | Event *event = new Event; |
847 | event->setFloats(false); | 844 | event->setFloats(false); |
848 | 845 | ||
849 | readIncidence(vevent,event); | 846 | readIncidence(vevent,event); |
850 | 847 | ||
851 | icalproperty *p = icalcomponent_get_first_property(vevent,ICAL_ANY_PROPERTY); | 848 | icalproperty *p = icalcomponent_get_first_property(vevent,ICAL_ANY_PROPERTY); |
852 | 849 | ||
853 | // int intvalue; | 850 | // int intvalue; |
854 | icaltimetype icaltime; | 851 | icaltimetype icaltime; |
855 | 852 | ||
856 | QStringList categories; | 853 | QStringList categories; |
857 | QString transparency; | 854 | QString transparency; |
858 | 855 | ||
859 | while (p) { | 856 | while (p) { |
860 | icalproperty_kind kind = icalproperty_isa(p); | 857 | icalproperty_kind kind = icalproperty_isa(p); |
861 | switch (kind) { | 858 | switch (kind) { |
862 | 859 | ||
863 | case ICAL_DTEND_PROPERTY: // start date and time | 860 | case ICAL_DTEND_PROPERTY: // start date and time |
864 | icaltime = icalproperty_get_dtend(p); | 861 | icaltime = icalproperty_get_dtend(p); |
865 | if (icaltime.is_date) { | 862 | if (icaltime.is_date) { |
866 | event->setFloats( true ); | 863 | event->setFloats( true ); |
867 | // End date is non-inclusive | 864 | // End date is non-inclusive |
868 | QDate endDate = readICalDate( icaltime ).addDays( -1 ); | 865 | QDate endDate = readICalDate( icaltime ).addDays( -1 ); |
869 | mCompat->fixFloatingEnd( endDate ); | 866 | mCompat->fixFloatingEnd( endDate ); |
870 | if ( endDate < event->dtStart().date() ) { | 867 | if ( endDate < event->dtStart().date() ) { |
871 | endDate = event->dtStart().date(); | 868 | endDate = event->dtStart().date(); |
872 | } | 869 | } |
873 | event->setDtEnd( QDateTime( endDate, QTime( 0, 0, 0 ) ) ); | 870 | event->setDtEnd( QDateTime( endDate, QTime( 0, 0, 0 ) ) ); |
874 | } else { | 871 | } else { |
875 | event->setDtEnd(readICalDateTime(icaltime)); | 872 | event->setDtEnd(readICalDateTime(icaltime)); |
876 | } | 873 | } |
877 | break; | 874 | break; |
878 | 875 | ||
879 | // TODO: | 876 | // TODO: |
880 | // at this point, there should be at least a start or end time. | 877 | // at this point, there should be at least a start or end time. |
881 | // fix up for events that take up no time but have a time associated | 878 | // fix up for events that take up no time but have a time associated |
882 | #if 0 | 879 | #if 0 |
883 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) | 880 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) |
884 | anEvent->setDtStart(anEvent->dtEnd()); | 881 | anEvent->setDtStart(anEvent->dtEnd()); |
885 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) | 882 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) |
886 | anEvent->setDtEnd(anEvent->dtStart()); | 883 | anEvent->setDtEnd(anEvent->dtStart()); |
887 | #endif | 884 | #endif |
888 | 885 | ||
889 | // TODO: exdates | 886 | // TODO: exdates |
890 | #if 0 | 887 | #if 0 |
891 | // recurrence exceptions | 888 | // recurrence exceptions |
892 | if ((vo = isAPropertyOf(vevent, VCExDateProp)) != 0) { | 889 | if ((vo = isAPropertyOf(vevent, VCExDateProp)) != 0) { |
893 | anEvent->setExDates(s = fakeCString(vObjectUStringZValue(vo))); | 890 | anEvent->setExDates(s = fakeCString(vObjectUStringZValue(vo))); |
894 | deleteStr(s); | 891 | deleteStr(s); |
895 | } | 892 | } |
896 | #endif | 893 | #endif |
897 | 894 | ||
898 | #if 0 | 895 | #if 0 |
899 | // secrecy | 896 | // secrecy |
900 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { | 897 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { |
901 | anEvent->setSecrecy(s = fakeCString(vObjectUStringZValue(vo))); | 898 | anEvent->setSecrecy(s = fakeCString(vObjectUStringZValue(vo))); |
902 | deleteStr(s); | 899 | deleteStr(s); |
903 | } | 900 | } |
904 | else | 901 | else |
905 | anEvent->setSecrecy("PUBLIC"); | 902 | anEvent->setSecrecy("PUBLIC"); |
906 | 903 | ||
907 | // attachments | 904 | // attachments |
908 | tmpStrList.clear(); | 905 | tmpStrList.clear(); |
909 | initPropIterator(&voi, vevent); | 906 | initPropIterator(&voi, vevent); |
910 | while (moreIteration(&voi)) { | 907 | while (moreIteration(&voi)) { |
911 | vo = nextVObject(&voi); | 908 | vo = nextVObject(&voi); |
912 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { | 909 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { |
913 | tmpStrList.append(s = fakeCString(vObjectUStringZValue(vo))); | 910 | tmpStrList.append(s = fakeCString(vObjectUStringZValue(vo))); |
914 | deleteStr(s); | 911 | deleteStr(s); |
915 | } | 912 | } |
916 | } | 913 | } |
917 | anEvent->setAttachments(tmpStrList); | 914 | anEvent->setAttachments(tmpStrList); |
918 | 915 | ||
919 | // resources | 916 | // resources |
920 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 917 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
921 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 918 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
922 | deleteStr(s); | 919 | deleteStr(s); |
923 | tmpStrList.clear(); | 920 | tmpStrList.clear(); |
924 | index1 = 0; | 921 | index1 = 0; |
925 | index2 = 0; | 922 | index2 = 0; |
926 | QString resource; | 923 | QString resource; |
927 | while ((index2 = resources.find(';', index1)) != -1) { | 924 | while ((index2 = resources.find(';', index1)) != -1) { |
928 | resource = resources.mid(index1, (index2 - index1)); | 925 | resource = resources.mid(index1, (index2 - index1)); |
929 | tmpStrList.append(resource); | 926 | tmpStrList.append(resource); |
930 | index1 = index2; | 927 | index1 = index2; |
931 | } | 928 | } |
932 | anEvent->setResources(tmpStrList); | 929 | anEvent->setResources(tmpStrList); |
933 | } | 930 | } |
934 | #endif | 931 | #endif |
935 | 932 | ||
936 | case ICAL_RELATEDTO_PROPERTY: // releated event (parent) | 933 | case ICAL_RELATEDTO_PROPERTY: // releated event (parent) |
937 | event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); | 934 | event->setRelatedToUid(QString::fromUtf8(icalproperty_get_relatedto(p))); |
938 | mEventsRelate.append(event); | 935 | mEventsRelate.append(event); |
939 | break; | 936 | break; |
940 | 937 | ||
941 | case ICAL_TRANSP_PROPERTY: // Transparency | 938 | case ICAL_TRANSP_PROPERTY: // Transparency |
942 | if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) | 939 | if(icalproperty_get_transp(p) == ICAL_TRANSP_TRANSPARENT ) |
943 | event->setTransparency( Event::Transparent ); | 940 | event->setTransparency( Event::Transparent ); |
944 | else | 941 | else |
945 | event->setTransparency( Event::Opaque ); | 942 | event->setTransparency( Event::Opaque ); |
946 | break; | 943 | break; |
947 | 944 | ||
948 | default: | 945 | default: |
949 | // kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind | 946 | // kdDebug(5800) << "ICALFormat::readEvent(): Unknown property: " << kind |
950 | // << endl; | 947 | // << endl; |
951 | break; | 948 | break; |
952 | } | 949 | } |
953 | 950 | ||
954 | p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); | 951 | p = icalcomponent_get_next_property(vevent,ICAL_ANY_PROPERTY); |
955 | } | 952 | } |
956 | 953 | ||
957 | QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); | 954 | QString msade = event->nonKDECustomProperty("X-MICROSOFT-CDO-ALLDAYEVENT"); |
958 | if (!msade.isNull()) { | 955 | if (!msade.isNull()) { |
959 | bool floats = (msade == QString::fromLatin1("TRUE")); | 956 | bool floats = (msade == QString::fromLatin1("TRUE")); |
960 | kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; | 957 | kdDebug(5800) << "ICALFormat::readEvent(): all day event: " << floats << endl; |
961 | event->setFloats(floats); | 958 | event->setFloats(floats); |
962 | if (floats) { | 959 | if (floats) { |
963 | QDateTime endDate = event->dtEnd(); | 960 | QDateTime endDate = event->dtEnd(); |
964 | event->setDtEnd(endDate.addDays(-1)); | 961 | event->setDtEnd(endDate.addDays(-1)); |
965 | } | 962 | } |
966 | } | 963 | } |
967 | 964 | ||
968 | // some stupid vCal exporters ignore the standard and use Description | 965 | // some stupid vCal exporters ignore the standard and use Description |
969 | // instead of Summary for the default field. Correct for this. | 966 | // instead of Summary for the default field. Correct for this. |
970 | if (event->summary().isEmpty() && | 967 | if (event->summary().isEmpty() && |
971 | !(event->description().isEmpty())) { | 968 | !(event->description().isEmpty())) { |
972 | QString tmpStr = event->description().simplifyWhiteSpace(); | 969 | QString tmpStr = event->description().simplifyWhiteSpace(); |
973 | event->setDescription(""); | 970 | event->setDescription(""); |
974 | event->setSummary(tmpStr); | 971 | event->setSummary(tmpStr); |
975 | } | 972 | } |
976 | 973 | ||
977 | return event; | 974 | return event; |
978 | } | 975 | } |
979 | 976 | ||
980 | FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy) | 977 | FreeBusy *ICalFormatImpl::readFreeBusy(icalcomponent *vfreebusy) |
981 | { | 978 | { |
982 | FreeBusy *freebusy = new FreeBusy; | 979 | FreeBusy *freebusy = new FreeBusy; |
983 | 980 | ||
984 | readIncidenceBase(vfreebusy,freebusy); | 981 | readIncidenceBase(vfreebusy,freebusy); |
985 | 982 | ||
986 | icalproperty *p = icalcomponent_get_first_property(vfreebusy,ICAL_ANY_PROPERTY); | 983 | icalproperty *p = icalcomponent_get_first_property(vfreebusy,ICAL_ANY_PROPERTY); |
987 | 984 | ||
988 | icaltimetype icaltime; | 985 | icaltimetype icaltime; |
989 | icalperiodtype icalperiod; | 986 | icalperiodtype icalperiod; |
990 | QDateTime period_start, period_end; | 987 | QDateTime period_start, period_end; |
991 | 988 | ||
992 | while (p) { | 989 | while (p) { |
993 | icalproperty_kind kind = icalproperty_isa(p); | 990 | icalproperty_kind kind = icalproperty_isa(p); |
994 | switch (kind) { | 991 | switch (kind) { |
995 | 992 | ||
996 | case ICAL_DTSTART_PROPERTY: // start date and time | 993 | case ICAL_DTSTART_PROPERTY: // start date and time |
997 | icaltime = icalproperty_get_dtstart(p); | 994 | icaltime = icalproperty_get_dtstart(p); |
998 | freebusy->setDtStart(readICalDateTime(icaltime)); | 995 | freebusy->setDtStart(readICalDateTime(icaltime)); |
999 | break; | 996 | break; |
1000 | 997 | ||
1001 | case ICAL_DTEND_PROPERTY: // start End Date and Time | 998 | case ICAL_DTEND_PROPERTY: // start End Date and Time |
1002 | icaltime = icalproperty_get_dtend(p); | 999 | icaltime = icalproperty_get_dtend(p); |
1003 | freebusy->setDtEnd(readICalDateTime(icaltime)); | 1000 | freebusy->setDtEnd(readICalDateTime(icaltime)); |
1004 | break; | 1001 | break; |
1005 | 1002 | ||
1006 | case ICAL_FREEBUSY_PROPERTY: //Any FreeBusy Times | 1003 | case ICAL_FREEBUSY_PROPERTY: //Any FreeBusy Times |
1007 | icalperiod = icalproperty_get_freebusy(p); | 1004 | icalperiod = icalproperty_get_freebusy(p); |
1008 | period_start = readICalDateTime(icalperiod.start); | 1005 | period_start = readICalDateTime(icalperiod.start); |
1009 | period_end = readICalDateTime(icalperiod.end); | 1006 | period_end = readICalDateTime(icalperiod.end); |
1010 | freebusy->addPeriod(period_start, period_end); | 1007 | freebusy->addPeriod(period_start, period_end); |
1011 | break; | 1008 | break; |
1012 | 1009 | ||
1013 | default: | 1010 | default: |
1014 | kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1011 | kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1015 | << endl; | 1012 | << endl; |
1016 | break; | 1013 | break; |
1017 | } | 1014 | } |
1018 | p = icalcomponent_get_next_property(vfreebusy,ICAL_ANY_PROPERTY); | 1015 | p = icalcomponent_get_next_property(vfreebusy,ICAL_ANY_PROPERTY); |
1019 | } | 1016 | } |
1020 | 1017 | ||
1021 | return freebusy; | 1018 | return freebusy; |
1022 | } | 1019 | } |
1023 | 1020 | ||
1024 | Journal *ICalFormatImpl::readJournal(icalcomponent *vjournal) | 1021 | Journal *ICalFormatImpl::readJournal(icalcomponent *vjournal) |
1025 | { | 1022 | { |
1026 | Journal *journal = new Journal; | 1023 | Journal *journal = new Journal; |
1027 | 1024 | ||
1028 | readIncidence(vjournal,journal); | 1025 | readIncidence(vjournal,journal); |
1029 | 1026 | ||
1030 | return journal; | 1027 | return journal; |
1031 | } | 1028 | } |
1032 | 1029 | ||
1033 | Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) | 1030 | Attendee *ICalFormatImpl::readAttendee(icalproperty *attendee) |
1034 | { | 1031 | { |
1035 | icalparameter *p = 0; | 1032 | icalparameter *p = 0; |
1036 | 1033 | ||
1037 | QString email = QString::fromUtf8(icalproperty_get_attendee(attendee)); | 1034 | QString email = QString::fromUtf8(icalproperty_get_attendee(attendee)); |
1038 | 1035 | ||
1039 | QString name; | 1036 | QString name; |
1040 | QString uid = QString::null; | 1037 | QString uid = QString::null; |
1041 | p = icalproperty_get_first_parameter(attendee,ICAL_CN_PARAMETER); | 1038 | p = icalproperty_get_first_parameter(attendee,ICAL_CN_PARAMETER); |
1042 | if (p) { | 1039 | if (p) { |
1043 | name = QString::fromUtf8(icalparameter_get_cn(p)); | 1040 | name = QString::fromUtf8(icalparameter_get_cn(p)); |
1044 | } else { | 1041 | } else { |
1045 | } | 1042 | } |
1046 | 1043 | ||
1047 | bool rsvp=false; | 1044 | bool rsvp=false; |
1048 | p = icalproperty_get_first_parameter(attendee,ICAL_RSVP_PARAMETER); | 1045 | p = icalproperty_get_first_parameter(attendee,ICAL_RSVP_PARAMETER); |
1049 | if (p) { | 1046 | if (p) { |
1050 | icalparameter_rsvp rsvpParameter = icalparameter_get_rsvp(p); | 1047 | icalparameter_rsvp rsvpParameter = icalparameter_get_rsvp(p); |
1051 | if (rsvpParameter == ICAL_RSVP_TRUE) rsvp = true; | 1048 | if (rsvpParameter == ICAL_RSVP_TRUE) rsvp = true; |
1052 | } | 1049 | } |
1053 | 1050 | ||
1054 | Attendee::PartStat status = Attendee::NeedsAction; | 1051 | Attendee::PartStat status = Attendee::NeedsAction; |
1055 | p = icalproperty_get_first_parameter(attendee,ICAL_PARTSTAT_PARAMETER); | 1052 | p = icalproperty_get_first_parameter(attendee,ICAL_PARTSTAT_PARAMETER); |
1056 | if (p) { | 1053 | if (p) { |
1057 | icalparameter_partstat partStatParameter = icalparameter_get_partstat(p); | 1054 | icalparameter_partstat partStatParameter = icalparameter_get_partstat(p); |
1058 | switch(partStatParameter) { | 1055 | switch(partStatParameter) { |
1059 | default: | 1056 | default: |
1060 | case ICAL_PARTSTAT_NEEDSACTION: | 1057 | case ICAL_PARTSTAT_NEEDSACTION: |
1061 | status = Attendee::NeedsAction; | 1058 | status = Attendee::NeedsAction; |
1062 | break; | 1059 | break; |
1063 | case ICAL_PARTSTAT_ACCEPTED: | 1060 | case ICAL_PARTSTAT_ACCEPTED: |
1064 | status = Attendee::Accepted; | 1061 | status = Attendee::Accepted; |
1065 | break; | 1062 | break; |
1066 | case ICAL_PARTSTAT_DECLINED: | 1063 | case ICAL_PARTSTAT_DECLINED: |
1067 | status = Attendee::Declined; | 1064 | status = Attendee::Declined; |
1068 | break; | 1065 | break; |
1069 | case ICAL_PARTSTAT_TENTATIVE: | 1066 | case ICAL_PARTSTAT_TENTATIVE: |
1070 | status = Attendee::Tentative; | 1067 | status = Attendee::Tentative; |
1071 | break; | 1068 | break; |
1072 | case ICAL_PARTSTAT_DELEGATED: | 1069 | case ICAL_PARTSTAT_DELEGATED: |
1073 | status = Attendee::Delegated; | 1070 | status = Attendee::Delegated; |
1074 | break; | 1071 | break; |
1075 | case ICAL_PARTSTAT_COMPLETED: | 1072 | case ICAL_PARTSTAT_COMPLETED: |
1076 | status = Attendee::Completed; | 1073 | status = Attendee::Completed; |
1077 | break; | 1074 | break; |
1078 | case ICAL_PARTSTAT_INPROCESS: | 1075 | case ICAL_PARTSTAT_INPROCESS: |
1079 | status = Attendee::InProcess; | 1076 | status = Attendee::InProcess; |
1080 | break; | 1077 | break; |
1081 | } | 1078 | } |
1082 | } | 1079 | } |
1083 | 1080 | ||
1084 | Attendee::Role role = Attendee::ReqParticipant; | 1081 | Attendee::Role role = Attendee::ReqParticipant; |
1085 | p = icalproperty_get_first_parameter(attendee,ICAL_ROLE_PARAMETER); | 1082 | p = icalproperty_get_first_parameter(attendee,ICAL_ROLE_PARAMETER); |
1086 | if (p) { | 1083 | if (p) { |
1087 | icalparameter_role roleParameter = icalparameter_get_role(p); | 1084 | icalparameter_role roleParameter = icalparameter_get_role(p); |
1088 | switch(roleParameter) { | 1085 | switch(roleParameter) { |
1089 | case ICAL_ROLE_CHAIR: | 1086 | case ICAL_ROLE_CHAIR: |
1090 | role = Attendee::Chair; | 1087 | role = Attendee::Chair; |
1091 | break; | 1088 | break; |
1092 | default: | 1089 | default: |
1093 | case ICAL_ROLE_REQPARTICIPANT: | 1090 | case ICAL_ROLE_REQPARTICIPANT: |
1094 | role = Attendee::ReqParticipant; | 1091 | role = Attendee::ReqParticipant; |
1095 | break; | 1092 | break; |
1096 | case ICAL_ROLE_OPTPARTICIPANT: | 1093 | case ICAL_ROLE_OPTPARTICIPANT: |
1097 | role = Attendee::OptParticipant; | 1094 | role = Attendee::OptParticipant; |
1098 | break; | 1095 | break; |
1099 | case ICAL_ROLE_NONPARTICIPANT: | 1096 | case ICAL_ROLE_NONPARTICIPANT: |
1100 | role = Attendee::NonParticipant; | 1097 | role = Attendee::NonParticipant; |
1101 | break; | 1098 | break; |
1102 | } | 1099 | } |
1103 | } | 1100 | } |
1104 | 1101 | ||
1105 | p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); | 1102 | p = icalproperty_get_first_parameter(attendee,ICAL_X_PARAMETER); |
1106 | uid = icalparameter_get_xvalue(p); | 1103 | uid = icalparameter_get_xvalue(p); |
1107 | // This should be added, but there seems to be a libical bug here. | 1104 | // This should be added, but there seems to be a libical bug here. |
1108 | /*while (p) { | 1105 | /*while (p) { |
1109 | // if (icalparameter_get_xname(p) == "X-UID") { | 1106 | // if (icalparameter_get_xname(p) == "X-UID") { |
1110 | uid = icalparameter_get_xvalue(p); | 1107 | uid = icalparameter_get_xvalue(p); |
1111 | p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); | 1108 | p = icalproperty_get_next_parameter(attendee,ICAL_X_PARAMETER); |
1112 | } */ | 1109 | } */ |
1113 | 1110 | ||
1114 | return new Attendee( name, email, rsvp, status, role, uid ); | 1111 | return new Attendee( name, email, rsvp, status, role, uid ); |
1115 | } | 1112 | } |
1116 | 1113 | ||
1117 | Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) | 1114 | Attachment *ICalFormatImpl::readAttachment(icalproperty *attach) |
1118 | { | 1115 | { |
1119 | icalattach *a = icalproperty_get_attach(attach); | 1116 | icalattach *a = icalproperty_get_attach(attach); |
1120 | icalparameter_value v = ICAL_VALUE_NONE; | 1117 | icalparameter_value v = ICAL_VALUE_NONE; |
1121 | icalparameter_encoding e = ICAL_ENCODING_NONE; | 1118 | icalparameter_encoding e = ICAL_ENCODING_NONE; |
1122 | 1119 | ||
1123 | Attachment *attachment = 0; | 1120 | Attachment *attachment = 0; |
1124 | /* | 1121 | /* |
1125 | icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); | 1122 | icalparameter *vp = icalproperty_get_first_parameter(attach, ICAL_VALUE_PARAMETER); |
1126 | if (vp) | 1123 | if (vp) |
1127 | v = icalparameter_get_value(vp); | 1124 | v = icalparameter_get_value(vp); |
1128 | 1125 | ||
1129 | icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); | 1126 | icalparameter *ep = icalproperty_get_first_parameter(attach, ICAL_ENCODING_PARAMETER); |
1130 | if (ep) | 1127 | if (ep) |
1131 | e = icalparameter_get_encoding(ep); | 1128 | e = icalparameter_get_encoding(ep); |
1132 | */ | 1129 | */ |
1133 | int isurl = icalattach_get_is_url (a); | 1130 | int isurl = icalattach_get_is_url (a); |
1134 | if (isurl == 0) | 1131 | if (isurl == 0) |
1135 | attachment = new Attachment((const char*)icalattach_get_data(a)); | 1132 | attachment = new Attachment((const char*)icalattach_get_data(a)); |
1136 | else { | 1133 | else { |
1137 | attachment = new Attachment(QString(icalattach_get_url(a))); | 1134 | attachment = new Attachment(QString(icalattach_get_url(a))); |
1138 | } | 1135 | } |
1139 | 1136 | ||
1140 | icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); | 1137 | icalparameter *p = icalproperty_get_first_parameter(attach, ICAL_FMTTYPE_PARAMETER); |
1141 | if (p) | 1138 | if (p) |
1142 | attachment->setMimeType(QString(icalparameter_get_fmttype(p))); | 1139 | attachment->setMimeType(QString(icalparameter_get_fmttype(p))); |
1143 | 1140 | ||
1144 | return attachment; | 1141 | return attachment; |
1145 | } | 1142 | } |
1146 | #include <qtextcodec.h> | 1143 | #include <qtextcodec.h> |
1147 | void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) | 1144 | void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence) |
1148 | { | 1145 | { |
1149 | readIncidenceBase(parent,incidence); | 1146 | readIncidenceBase(parent,incidence); |
1150 | 1147 | ||
1151 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1148 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1152 | bool readrec = false; | 1149 | bool readrec = false; |
1153 | const char *text; | 1150 | const char *text; |
1154 | int intvalue; | 1151 | int intvalue; |
1155 | icaltimetype icaltime; | 1152 | icaltimetype icaltime; |
1156 | icaldurationtype icalduration; | 1153 | icaldurationtype icalduration; |
1157 | struct icalrecurrencetype rectype; | 1154 | struct icalrecurrencetype rectype; |
1158 | QStringList categories; | 1155 | QStringList categories; |
1159 | 1156 | ||
1160 | while (p) { | 1157 | while (p) { |
1161 | icalproperty_kind kind = icalproperty_isa(p); | 1158 | icalproperty_kind kind = icalproperty_isa(p); |
1162 | switch (kind) { | 1159 | switch (kind) { |
1163 | 1160 | ||
1164 | case ICAL_CREATED_PROPERTY: | 1161 | case ICAL_CREATED_PROPERTY: |
1165 | icaltime = icalproperty_get_created(p); | 1162 | icaltime = icalproperty_get_created(p); |
1166 | incidence->setCreated(readICalDateTime(icaltime)); | 1163 | incidence->setCreated(readICalDateTime(icaltime)); |
1167 | break; | 1164 | break; |
1168 | 1165 | ||
1169 | case ICAL_SEQUENCE_PROPERTY: // sequence | 1166 | case ICAL_SEQUENCE_PROPERTY: // sequence |
1170 | intvalue = icalproperty_get_sequence(p); | 1167 | intvalue = icalproperty_get_sequence(p); |
1171 | incidence->setRevision(intvalue); | 1168 | incidence->setRevision(intvalue); |
1172 | break; | 1169 | break; |
1173 | 1170 | ||
1174 | case ICAL_LASTMODIFIED_PROPERTY: // last modification date | 1171 | case ICAL_LASTMODIFIED_PROPERTY: // last modification date |
1175 | icaltime = icalproperty_get_lastmodified(p); | 1172 | icaltime = icalproperty_get_lastmodified(p); |
1176 | incidence->setLastModified(readICalDateTime(icaltime)); | 1173 | incidence->setLastModified(readICalDateTime(icaltime)); |
1177 | break; | 1174 | break; |
1178 | 1175 | ||
1179 | case ICAL_DTSTART_PROPERTY: // start date and time | 1176 | case ICAL_DTSTART_PROPERTY: // start date and time |
1180 | icaltime = icalproperty_get_dtstart(p); | 1177 | icaltime = icalproperty_get_dtstart(p); |
1181 | if (icaltime.is_date) { | 1178 | if (icaltime.is_date) { |
1182 | incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0))); | 1179 | incidence->setDtStart(QDateTime(readICalDate(icaltime),QTime(0,0,0))); |
1183 | incidence->setFloats(true); | 1180 | incidence->setFloats(true); |
1184 | } else { | 1181 | } else { |
1185 | incidence->setDtStart(readICalDateTime(icaltime)); | 1182 | incidence->setDtStart(readICalDateTime(icaltime)); |
1186 | } | 1183 | } |
1187 | break; | 1184 | break; |
1188 | 1185 | ||
1189 | case ICAL_DURATION_PROPERTY: // start date and time | 1186 | case ICAL_DURATION_PROPERTY: // start date and time |
1190 | icalduration = icalproperty_get_duration(p); | 1187 | icalduration = icalproperty_get_duration(p); |
1191 | incidence->setDuration(readICalDuration(icalduration)); | 1188 | incidence->setDuration(readICalDuration(icalduration)); |
1192 | break; | 1189 | break; |
1193 | 1190 | ||
1194 | case ICAL_DESCRIPTION_PROPERTY: // description | 1191 | case ICAL_DESCRIPTION_PROPERTY: // description |
1195 | text = icalproperty_get_description(p); | 1192 | text = icalproperty_get_description(p); |
1196 | incidence->setDescription(QString::fromUtf8(text)); | 1193 | incidence->setDescription(QString::fromUtf8(text)); |
1197 | break; | 1194 | break; |
1198 | 1195 | ||
1199 | case ICAL_SUMMARY_PROPERTY: // summary | 1196 | case ICAL_SUMMARY_PROPERTY: // summary |
1200 | { | 1197 | { |
1201 | text = icalproperty_get_summary(p); | 1198 | text = icalproperty_get_summary(p); |
1202 | incidence->setSummary(QString::fromUtf8(text)); | 1199 | incidence->setSummary(QString::fromUtf8(text)); |
1203 | } | 1200 | } |
1204 | break; | 1201 | break; |
1205 | case ICAL_STATUS_PROPERTY: // summary | 1202 | case ICAL_STATUS_PROPERTY: // summary |
1206 | { | 1203 | { |
1207 | if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) | 1204 | if ( ICAL_STATUS_CANCELLED == icalproperty_get_status(p) ) |
1208 | incidence->setCancelled( true ); | 1205 | incidence->setCancelled( true ); |
1209 | } | 1206 | } |
1210 | break; | 1207 | break; |
1211 | 1208 | ||
1212 | case ICAL_LOCATION_PROPERTY: // location | 1209 | case ICAL_LOCATION_PROPERTY: // location |
1213 | text = icalproperty_get_location(p); | 1210 | text = icalproperty_get_location(p); |
1214 | incidence->setLocation(QString::fromUtf8(text)); | 1211 | incidence->setLocation(QString::fromUtf8(text)); |
1215 | break; | 1212 | break; |
1216 | 1213 | ||
1217 | #if 0 | 1214 | #if 0 |
1218 | // status | 1215 | // status |
1219 | if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { | 1216 | if ((vo = isAPropertyOf(vincidence, VCStatusProp)) != 0) { |
1220 | incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); | 1217 | incidence->setStatus(s = fakeCString(vObjectUStringZValue(vo))); |
1221 | deleteStr(s); | 1218 | deleteStr(s); |
1222 | } | 1219 | } |
1223 | else | 1220 | else |
1224 | incidence->setStatus("NEEDS ACTION"); | 1221 | incidence->setStatus("NEEDS ACTION"); |
1225 | #endif | 1222 | #endif |
1226 | 1223 | ||
1227 | case ICAL_PRIORITY_PROPERTY: // priority | 1224 | case ICAL_PRIORITY_PROPERTY: // priority |
1228 | intvalue = icalproperty_get_priority(p); | 1225 | intvalue = icalproperty_get_priority(p); |
1229 | incidence->setPriority(intvalue); | 1226 | incidence->setPriority(intvalue); |
1230 | break; | 1227 | break; |
1231 | 1228 | ||
1232 | case ICAL_CATEGORIES_PROPERTY: // categories | 1229 | case ICAL_CATEGORIES_PROPERTY: // categories |
1233 | text = icalproperty_get_categories(p); | 1230 | text = icalproperty_get_categories(p); |
1234 | categories.append(QString::fromUtf8(text)); | 1231 | categories.append(QString::fromUtf8(text)); |
1235 | break; | 1232 | break; |
1236 | //******************************************* | 1233 | //******************************************* |
1237 | case ICAL_RRULE_PROPERTY: | 1234 | case ICAL_RRULE_PROPERTY: |
1238 | // we do need (maybe )start datetime of incidence for recurrence | 1235 | // we do need (maybe )start datetime of incidence for recurrence |
1239 | // such that we can read recurrence only after we read incidence completely | 1236 | // such that we can read recurrence only after we read incidence completely |
1240 | readrec = true; | 1237 | readrec = true; |
1241 | rectype = icalproperty_get_rrule(p); | 1238 | rectype = icalproperty_get_rrule(p); |
1242 | break; | 1239 | break; |
1243 | 1240 | ||
1244 | case ICAL_EXDATE_PROPERTY: | 1241 | case ICAL_EXDATE_PROPERTY: |
1245 | icaltime = icalproperty_get_exdate(p); | 1242 | icaltime = icalproperty_get_exdate(p); |
1246 | incidence->addExDate(readICalDate(icaltime)); | 1243 | incidence->addExDate(readICalDate(icaltime)); |
1247 | break; | 1244 | break; |
1248 | 1245 | ||
1249 | case ICAL_CLASS_PROPERTY: { | 1246 | case ICAL_CLASS_PROPERTY: { |
1250 | int inttext = icalproperty_get_class(p); | 1247 | int inttext = icalproperty_get_class(p); |
1251 | if (inttext == ICAL_CLASS_PUBLIC ) { | 1248 | if (inttext == ICAL_CLASS_PUBLIC ) { |
1252 | incidence->setSecrecy(Incidence::SecrecyPublic); | 1249 | incidence->setSecrecy(Incidence::SecrecyPublic); |
1253 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { | 1250 | } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { |
1254 | incidence->setSecrecy(Incidence::SecrecyConfidential); | 1251 | incidence->setSecrecy(Incidence::SecrecyConfidential); |
1255 | } else { | 1252 | } else { |
1256 | incidence->setSecrecy(Incidence::SecrecyPrivate); | 1253 | incidence->setSecrecy(Incidence::SecrecyPrivate); |
1257 | } | 1254 | } |
1258 | } | 1255 | } |
1259 | break; | 1256 | break; |
1260 | 1257 | ||
1261 | case ICAL_ATTACH_PROPERTY: // attachments | 1258 | case ICAL_ATTACH_PROPERTY: // attachments |
1262 | incidence->addAttachment(readAttachment(p)); | 1259 | incidence->addAttachment(readAttachment(p)); |
1263 | break; | 1260 | break; |
1264 | 1261 | ||
1265 | default: | 1262 | default: |
1266 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind | 1263 | // kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind |
1267 | // << endl; | 1264 | // << endl; |
1268 | break; | 1265 | break; |
1269 | } | 1266 | } |
1270 | 1267 | ||
1271 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1268 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1272 | } | 1269 | } |
1273 | if ( readrec ) { | 1270 | if ( readrec ) { |
1274 | readRecurrenceRule(rectype,incidence); | 1271 | readRecurrenceRule(rectype,incidence); |
1275 | } | 1272 | } |
1276 | // kpilot stuff | 1273 | // kpilot stuff |
1277 | // TODO: move this application-specific code to kpilot | 1274 | // TODO: move this application-specific code to kpilot |
1278 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); | 1275 | QString kp = incidence->nonKDECustomProperty("X-PILOTID"); |
1279 | if (!kp.isNull()) { | 1276 | if (!kp.isNull()) { |
1280 | incidence->setPilotId(kp.toInt()); | 1277 | incidence->setPilotId(kp.toInt()); |
1281 | } | 1278 | } |
1282 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); | 1279 | kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); |
1283 | if (!kp.isNull()) { | 1280 | if (!kp.isNull()) { |
1284 | incidence->setSyncStatus(kp.toInt()); | 1281 | incidence->setSyncStatus(kp.toInt()); |
1285 | } | 1282 | } |
1286 | kp = incidence->nonKDECustomProperty("X-ZAURUSID"); | 1283 | kp = incidence->nonKDECustomProperty("X-ZAURUSID"); |
1287 | if (!kp.isNull()) { | 1284 | if (!kp.isNull()) { |
1288 | incidence->setZaurusId(kp.toInt()); | 1285 | incidence->setZaurusId(kp.toInt()); |
1289 | } | 1286 | } |
1290 | 1287 | ||
1291 | kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); | 1288 | kp = incidence->nonKDECustomProperty("X-ZAURUSUID"); |
1292 | if (!kp.isNull()) { | 1289 | if (!kp.isNull()) { |
1293 | incidence->setZaurusUid(kp.toInt()); | 1290 | incidence->setZaurusUid(kp.toInt()); |
1294 | } | 1291 | } |
1295 | 1292 | ||
1296 | kp = incidence->nonKDECustomProperty("X-ZAURUSSTAT"); | ||
1297 | if (!kp.isNull()) { | ||
1298 | incidence->setZaurusStat(kp.toInt()); | ||
1299 | } | ||
1300 | |||
1301 | // Cancel backwards compatibility mode for subsequent changes by the application | 1293 | // Cancel backwards compatibility mode for subsequent changes by the application |
1302 | incidence->recurrence()->setCompatVersion(); | 1294 | incidence->recurrence()->setCompatVersion(); |
1303 | 1295 | ||
1304 | // add categories | 1296 | // add categories |
1305 | incidence->setCategories(categories); | 1297 | incidence->setCategories(categories); |
1306 | 1298 | ||
1307 | // iterate through all alarms | 1299 | // iterate through all alarms |
1308 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); | 1300 | for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); |
1309 | alarm; | 1301 | alarm; |
1310 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { | 1302 | alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { |
1311 | readAlarm(alarm,incidence); | 1303 | readAlarm(alarm,incidence); |
1312 | } | 1304 | } |
1313 | } | 1305 | } |
1314 | 1306 | ||
1315 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) | 1307 | void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) |
1316 | { | 1308 | { |
1317 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); | 1309 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); |
1318 | 1310 | ||
1319 | while (p) { | 1311 | while (p) { |
1320 | icalproperty_kind kind = icalproperty_isa(p); | 1312 | icalproperty_kind kind = icalproperty_isa(p); |
1321 | switch (kind) { | 1313 | switch (kind) { |
1322 | 1314 | ||
1323 | case ICAL_UID_PROPERTY: // unique id | 1315 | case ICAL_UID_PROPERTY: // unique id |
1324 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); | 1316 | incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); |
1325 | break; | 1317 | break; |
1326 | 1318 | ||
1327 | case ICAL_ORGANIZER_PROPERTY: // organizer | 1319 | case ICAL_ORGANIZER_PROPERTY: // organizer |
1328 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); | 1320 | incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); |
1329 | break; | 1321 | break; |
1330 | 1322 | ||
1331 | case ICAL_ATTENDEE_PROPERTY: // attendee | 1323 | case ICAL_ATTENDEE_PROPERTY: // attendee |
1332 | incidenceBase->addAttendee(readAttendee(p)); | 1324 | incidenceBase->addAttendee(readAttendee(p)); |
1333 | break; | 1325 | break; |
1334 | 1326 | ||
1335 | default: | 1327 | default: |
1336 | break; | 1328 | break; |
1337 | } | 1329 | } |
1338 | 1330 | ||
1339 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); | 1331 | p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); |
1340 | } | 1332 | } |
1341 | 1333 | ||
1342 | // custom properties | 1334 | // custom properties |
1343 | readCustomProperties(parent, incidenceBase); | 1335 | readCustomProperties(parent, incidenceBase); |
1344 | } | 1336 | } |
1345 | 1337 | ||
1346 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) | 1338 | void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) |
1347 | { | 1339 | { |
1348 | QMap<QCString, QString> customProperties; | 1340 | QMap<QCString, QString> customProperties; |
1349 | 1341 | ||
1350 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); | 1342 | icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); |
1351 | 1343 | ||
1352 | while (p) { | 1344 | while (p) { |
1353 | QString value = QString::fromUtf8(icalproperty_get_x(p)); | 1345 | QString value = QString::fromUtf8(icalproperty_get_x(p)); |
1354 | customProperties[icalproperty_get_x_name(p)] = value; | 1346 | customProperties[icalproperty_get_x_name(p)] = value; |
1355 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); | 1347 | //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); |
1356 | 1348 | ||
1357 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); | 1349 | p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); |
1358 | } | 1350 | } |
1359 | 1351 | ||
1360 | properties->setCustomProperties(customProperties); | 1352 | properties->setCustomProperties(customProperties); |
1361 | } | 1353 | } |
1362 | 1354 | ||
1363 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) | 1355 | void ICalFormatImpl::readRecurrenceRule(struct icalrecurrencetype rrule,Incidence *incidence) |
1364 | { | 1356 | { |
1365 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; | 1357 | // kdDebug(5800) << "Read recurrence for " << incidence->summary() << endl; |
1366 | 1358 | ||
1367 | Recurrence *recur = incidence->recurrence(); | 1359 | Recurrence *recur = incidence->recurrence(); |
1368 | recur->setCompatVersion(mCalendarVersion); | 1360 | recur->setCompatVersion(mCalendarVersion); |
1369 | recur->unsetRecurs(); | 1361 | recur->unsetRecurs(); |
1370 | 1362 | ||
1371 | struct icalrecurrencetype r = rrule; | 1363 | struct icalrecurrencetype r = rrule; |
1372 | 1364 | ||
1373 | dumpIcalRecurrence(r); | 1365 | dumpIcalRecurrence(r); |
1374 | readRecurrence( r, recur, incidence); | 1366 | readRecurrence( r, recur, incidence); |
1375 | } | 1367 | } |
1376 | 1368 | ||
1377 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) | 1369 | void ICalFormatImpl::readRecurrence( const struct icalrecurrencetype &r, Recurrence* recur, Incidence *incidence) |
1378 | { | 1370 | { |
1379 | int wkst; | 1371 | int wkst; |
1380 | int index = 0; | 1372 | int index = 0; |
1381 | short day = 0; | 1373 | short day = 0; |
1382 | QBitArray qba(7); | 1374 | QBitArray qba(7); |
1383 | int frequ = r.freq; | 1375 | int frequ = r.freq; |
1384 | int interv = r.interval; | 1376 | int interv = r.interval; |
1385 | // preprocessing for odd recurrence definitions | 1377 | // preprocessing for odd recurrence definitions |
1386 | 1378 | ||
1387 | if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { | 1379 | if ( r.freq == ICAL_MONTHLY_RECURRENCE ) { |
1388 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1380 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1389 | interv = 12; | 1381 | interv = 12; |
1390 | } | 1382 | } |
1391 | } | 1383 | } |
1392 | if ( r.freq == ICAL_YEARLY_RECURRENCE ) { | 1384 | if ( r.freq == ICAL_YEARLY_RECURRENCE ) { |
1393 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1385 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX && r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1394 | frequ = ICAL_MONTHLY_RECURRENCE; | 1386 | frequ = ICAL_MONTHLY_RECURRENCE; |
1395 | interv = 12* r.interval; | 1387 | interv = 12* r.interval; |
1396 | } | 1388 | } |
1397 | } | 1389 | } |
1398 | 1390 | ||
1399 | switch (frequ) { | 1391 | switch (frequ) { |
1400 | case ICAL_MINUTELY_RECURRENCE: | 1392 | case ICAL_MINUTELY_RECURRENCE: |
1401 | if (!icaltime_is_null_time(r.until)) { | 1393 | if (!icaltime_is_null_time(r.until)) { |
1402 | recur->setMinutely(interv,readICalDateTime(r.until)); | 1394 | recur->setMinutely(interv,readICalDateTime(r.until)); |
1403 | } else { | 1395 | } else { |
1404 | if (r.count == 0) | 1396 | if (r.count == 0) |
1405 | recur->setMinutely(interv,-1); | 1397 | recur->setMinutely(interv,-1); |
1406 | else | 1398 | else |
1407 | recur->setMinutely(interv,r.count); | 1399 | recur->setMinutely(interv,r.count); |
1408 | } | 1400 | } |
1409 | break; | 1401 | break; |
1410 | case ICAL_HOURLY_RECURRENCE: | 1402 | case ICAL_HOURLY_RECURRENCE: |
1411 | if (!icaltime_is_null_time(r.until)) { | 1403 | if (!icaltime_is_null_time(r.until)) { |
1412 | recur->setHourly(interv,readICalDateTime(r.until)); | 1404 | recur->setHourly(interv,readICalDateTime(r.until)); |
1413 | } else { | 1405 | } else { |
1414 | if (r.count == 0) | 1406 | if (r.count == 0) |
1415 | recur->setHourly(interv,-1); | 1407 | recur->setHourly(interv,-1); |
1416 | else | 1408 | else |
1417 | recur->setHourly(interv,r.count); | 1409 | recur->setHourly(interv,r.count); |
1418 | } | 1410 | } |
1419 | break; | 1411 | break; |
1420 | case ICAL_DAILY_RECURRENCE: | 1412 | case ICAL_DAILY_RECURRENCE: |
1421 | if (!icaltime_is_null_time(r.until)) { | 1413 | if (!icaltime_is_null_time(r.until)) { |
1422 | recur->setDaily(interv,readICalDate(r.until)); | 1414 | recur->setDaily(interv,readICalDate(r.until)); |
1423 | } else { | 1415 | } else { |
1424 | if (r.count == 0) | 1416 | if (r.count == 0) |
1425 | recur->setDaily(interv,-1); | 1417 | recur->setDaily(interv,-1); |
1426 | else | 1418 | else |
1427 | recur->setDaily(interv,r.count); | 1419 | recur->setDaily(interv,r.count); |
1428 | } | 1420 | } |
1429 | break; | 1421 | break; |
1430 | case ICAL_WEEKLY_RECURRENCE: | 1422 | case ICAL_WEEKLY_RECURRENCE: |
1431 | // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; | 1423 | // kdDebug(5800) << "WEEKLY_RECURRENCE" << endl; |
1432 | wkst = (r.week_start + 5)%7 + 1; | 1424 | wkst = (r.week_start + 5)%7 + 1; |
1433 | if (!icaltime_is_null_time(r.until)) { | 1425 | if (!icaltime_is_null_time(r.until)) { |
1434 | recur->setWeekly(interv,qba,readICalDate(r.until),wkst); | 1426 | recur->setWeekly(interv,qba,readICalDate(r.until),wkst); |
1435 | } else { | 1427 | } else { |
1436 | if (r.count == 0) | 1428 | if (r.count == 0) |
1437 | recur->setWeekly(interv,qba,-1,wkst); | 1429 | recur->setWeekly(interv,qba,-1,wkst); |
1438 | else | 1430 | else |
1439 | recur->setWeekly(interv,qba,r.count,wkst); | 1431 | recur->setWeekly(interv,qba,r.count,wkst); |
1440 | } | 1432 | } |
1441 | if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { | 1433 | if ( r.by_day[0] == ICAL_RECURRENCE_ARRAY_MAX) { |
1442 | int wday = incidence->dtStart().date().dayOfWeek ()-1; | 1434 | int wday = incidence->dtStart().date().dayOfWeek ()-1; |
1443 | //qDebug("weekly error found "); | 1435 | //qDebug("weekly error found "); |
1444 | qba.setBit(wday); | 1436 | qba.setBit(wday); |
1445 | } else { | 1437 | } else { |
1446 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1438 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1447 | // kdDebug(5800) << " " << day << endl; | 1439 | // kdDebug(5800) << " " << day << endl; |
1448 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1440 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1449 | } | 1441 | } |
1450 | } | 1442 | } |
1451 | break; | 1443 | break; |
1452 | case ICAL_MONTHLY_RECURRENCE: | 1444 | case ICAL_MONTHLY_RECURRENCE: |
1453 | 1445 | ||
1454 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1446 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1455 | if (!icaltime_is_null_time(r.until)) { | 1447 | if (!icaltime_is_null_time(r.until)) { |
1456 | recur->setMonthly(Recurrence::rMonthlyPos,interv, | 1448 | recur->setMonthly(Recurrence::rMonthlyPos,interv, |
1457 | readICalDate(r.until)); | 1449 | readICalDate(r.until)); |
1458 | } else { | 1450 | } else { |
1459 | if (r.count == 0) | 1451 | if (r.count == 0) |
1460 | recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); | 1452 | recur->setMonthly(Recurrence::rMonthlyPos,interv,-1); |
1461 | else | 1453 | else |
1462 | recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); | 1454 | recur->setMonthly(Recurrence::rMonthlyPos,interv,r.count); |
1463 | } | 1455 | } |
1464 | bool useSetPos = false; | 1456 | bool useSetPos = false; |
1465 | short pos = 0; | 1457 | short pos = 0; |
1466 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1458 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1467 | // kdDebug(5800) << "----a " << index << ": " << day << endl; | 1459 | // kdDebug(5800) << "----a " << index << ": " << day << endl; |
1468 | pos = icalrecurrencetype_day_position(day); | 1460 | pos = icalrecurrencetype_day_position(day); |
1469 | if (pos) { | 1461 | if (pos) { |
1470 | day = icalrecurrencetype_day_day_of_week(day); | 1462 | day = icalrecurrencetype_day_day_of_week(day); |
1471 | QBitArray ba(7); // don't wipe qba | 1463 | QBitArray ba(7); // don't wipe qba |
1472 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1464 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1473 | recur->addMonthlyPos(pos,ba); | 1465 | recur->addMonthlyPos(pos,ba); |
1474 | } else { | 1466 | } else { |
1475 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1467 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1476 | useSetPos = true; | 1468 | useSetPos = true; |
1477 | } | 1469 | } |
1478 | } | 1470 | } |
1479 | if (useSetPos) { | 1471 | if (useSetPos) { |
1480 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1472 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1481 | recur->addMonthlyPos(r.by_set_pos[0],qba); | 1473 | recur->addMonthlyPos(r.by_set_pos[0],qba); |
1482 | } | 1474 | } |
1483 | } | 1475 | } |
1484 | } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1476 | } else if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1485 | if (!icaltime_is_null_time(r.until)) { | 1477 | if (!icaltime_is_null_time(r.until)) { |
1486 | recur->setMonthly(Recurrence::rMonthlyDay,interv, | 1478 | recur->setMonthly(Recurrence::rMonthlyDay,interv, |
1487 | readICalDate(r.until)); | 1479 | readICalDate(r.until)); |
1488 | } else { | 1480 | } else { |
1489 | if (r.count == 0) | 1481 | if (r.count == 0) |
1490 | recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); | 1482 | recur->setMonthly(Recurrence::rMonthlyDay,interv,-1); |
1491 | else | 1483 | else |
1492 | recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); | 1484 | recur->setMonthly(Recurrence::rMonthlyDay,interv,r.count); |
1493 | } | 1485 | } |
1494 | while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1486 | while((day = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1495 | // kdDebug(5800) << "----b " << day << endl; | 1487 | // kdDebug(5800) << "----b " << day << endl; |
1496 | recur->addMonthlyDay(day); | 1488 | recur->addMonthlyDay(day); |
1497 | } | 1489 | } |
1498 | } | 1490 | } |
1499 | break; | 1491 | break; |
1500 | case ICAL_YEARLY_RECURRENCE: | 1492 | case ICAL_YEARLY_RECURRENCE: |
1501 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1493 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1502 | //qDebug(" YEARLY DAY OF YEAR"); | 1494 | //qDebug(" YEARLY DAY OF YEAR"); |
1503 | if (!icaltime_is_null_time(r.until)) { | 1495 | if (!icaltime_is_null_time(r.until)) { |
1504 | recur->setYearly(Recurrence::rYearlyDay,interv, | 1496 | recur->setYearly(Recurrence::rYearlyDay,interv, |
1505 | readICalDate(r.until)); | 1497 | readICalDate(r.until)); |
1506 | } else { | 1498 | } else { |
1507 | if (r.count == 0) | 1499 | if (r.count == 0) |
1508 | recur->setYearly(Recurrence::rYearlyDay,interv,-1); | 1500 | recur->setYearly(Recurrence::rYearlyDay,interv,-1); |
1509 | else | 1501 | else |
1510 | recur->setYearly(Recurrence::rYearlyDay,interv,r.count); | 1502 | recur->setYearly(Recurrence::rYearlyDay,interv,r.count); |
1511 | } | 1503 | } |
1512 | while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1504 | while((day = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1513 | recur->addYearlyNum(day); | 1505 | recur->addYearlyNum(day); |
1514 | } | 1506 | } |
1515 | } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { | 1507 | } else if ( true /*r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX*/) { |
1516 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1508 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1517 | qDebug("YEARLY POS NOT SUPPORTED BY GUI"); | 1509 | qDebug("YEARLY POS NOT SUPPORTED BY GUI"); |
1518 | if (!icaltime_is_null_time(r.until)) { | 1510 | if (!icaltime_is_null_time(r.until)) { |
1519 | recur->setYearly(Recurrence::rYearlyPos,interv, | 1511 | recur->setYearly(Recurrence::rYearlyPos,interv, |
1520 | readICalDate(r.until)); | 1512 | readICalDate(r.until)); |
1521 | } else { | 1513 | } else { |
1522 | if (r.count == 0) | 1514 | if (r.count == 0) |
1523 | recur->setYearly(Recurrence::rYearlyPos,interv,-1); | 1515 | recur->setYearly(Recurrence::rYearlyPos,interv,-1); |
1524 | else | 1516 | else |
1525 | recur->setYearly(Recurrence::rYearlyPos,interv,r.count); | 1517 | recur->setYearly(Recurrence::rYearlyPos,interv,r.count); |
1526 | } | 1518 | } |
1527 | bool useSetPos = false; | 1519 | bool useSetPos = false; |
1528 | short pos = 0; | 1520 | short pos = 0; |
1529 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1521 | while((day = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1530 | // kdDebug(5800) << "----a " << index << ": " << day << endl; | 1522 | // kdDebug(5800) << "----a " << index << ": " << day << endl; |
1531 | pos = icalrecurrencetype_day_position(day); | 1523 | pos = icalrecurrencetype_day_position(day); |
1532 | if (pos) { | 1524 | if (pos) { |
1533 | day = icalrecurrencetype_day_day_of_week(day); | 1525 | day = icalrecurrencetype_day_day_of_week(day); |
1534 | QBitArray ba(7); // don't wipe qba | 1526 | QBitArray ba(7); // don't wipe qba |
1535 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1527 | ba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1536 | recur->addYearlyMonthPos(pos,ba); | 1528 | recur->addYearlyMonthPos(pos,ba); |
1537 | } else { | 1529 | } else { |
1538 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 | 1530 | qba.setBit((day+5)%7); // convert from Sunday=1 to Monday=0 |
1539 | useSetPos = true; | 1531 | useSetPos = true; |
1540 | } | 1532 | } |
1541 | } | 1533 | } |
1542 | if (useSetPos) { | 1534 | if (useSetPos) { |
1543 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 1535 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
1544 | recur->addYearlyMonthPos(r.by_set_pos[0],qba); | 1536 | recur->addYearlyMonthPos(r.by_set_pos[0],qba); |
1545 | } | 1537 | } |
1546 | } | 1538 | } |
1547 | } else { | 1539 | } else { |
1548 | //qDebug("YEARLY MONTH "); | 1540 | //qDebug("YEARLY MONTH "); |
1549 | if (!icaltime_is_null_time(r.until)) { | 1541 | if (!icaltime_is_null_time(r.until)) { |
1550 | recur->setYearly(Recurrence::rYearlyMonth,interv, | 1542 | recur->setYearly(Recurrence::rYearlyMonth,interv, |
1551 | readICalDate(r.until)); | 1543 | readICalDate(r.until)); |
1552 | } else { | 1544 | } else { |
1553 | if (r.count == 0) | 1545 | if (r.count == 0) |
1554 | recur->setYearly(Recurrence::rYearlyMonth,interv,-1); | 1546 | recur->setYearly(Recurrence::rYearlyMonth,interv,-1); |
1555 | else | 1547 | else |
1556 | recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); | 1548 | recur->setYearly(Recurrence::rYearlyMonth,interv,r.count); |
1557 | } | 1549 | } |
1558 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { | 1550 | if ( r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX ) { |
1559 | index = 0; | 1551 | index = 0; |
1560 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 1552 | while((day = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
1561 | recur->addYearlyNum(day); | 1553 | recur->addYearlyNum(day); |
1562 | } | 1554 | } |
1563 | } else { | 1555 | } else { |
1564 | recur->addYearlyNum(incidence->dtStart().date().month()); | 1556 | recur->addYearlyNum(incidence->dtStart().date().month()); |
1565 | } | 1557 | } |
1566 | } | 1558 | } |
1567 | 1559 | ||
1568 | } | 1560 | } |
1569 | break; | 1561 | break; |
1570 | default: | 1562 | default: |
1571 | ; | 1563 | ; |
1572 | break; | 1564 | break; |
1573 | } | 1565 | } |
1574 | } | 1566 | } |
1575 | 1567 | ||
1576 | void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) | 1568 | void ICalFormatImpl::readAlarm(icalcomponent *alarm,Incidence *incidence) |
1577 | { | 1569 | { |
1578 | //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; | 1570 | //kdDebug(5800) << "Read alarm for " << incidence->summary() << endl; |
1579 | 1571 | ||
1580 | Alarm* ialarm = incidence->newAlarm(); | 1572 | Alarm* ialarm = incidence->newAlarm(); |
1581 | ialarm->setRepeatCount(0); | 1573 | ialarm->setRepeatCount(0); |
1582 | ialarm->setEnabled(true); | 1574 | ialarm->setEnabled(true); |
1583 | 1575 | ||
1584 | // Determine the alarm's action type | 1576 | // Determine the alarm's action type |
1585 | icalproperty *p = icalcomponent_get_first_property(alarm,ICAL_ACTION_PROPERTY); | 1577 | icalproperty *p = icalcomponent_get_first_property(alarm,ICAL_ACTION_PROPERTY); |
1586 | if ( !p ) { | 1578 | if ( !p ) { |
1587 | return; | 1579 | return; |
1588 | } | 1580 | } |
1589 | 1581 | ||
1590 | icalproperty_action action = icalproperty_get_action(p); | 1582 | icalproperty_action action = icalproperty_get_action(p); |
1591 | Alarm::Type type = Alarm::Display; | 1583 | Alarm::Type type = Alarm::Display; |
1592 | switch ( action ) { | 1584 | switch ( action ) { |
1593 | case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; | 1585 | case ICAL_ACTION_DISPLAY: type = Alarm::Display; break; |
1594 | case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; | 1586 | case ICAL_ACTION_AUDIO: type = Alarm::Audio; break; |
1595 | case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; | 1587 | case ICAL_ACTION_PROCEDURE: type = Alarm::Procedure; break; |
1596 | case ICAL_ACTION_EMAIL: type = Alarm::Email; break; | 1588 | case ICAL_ACTION_EMAIL: type = Alarm::Email; break; |
1597 | default: | 1589 | default: |
1598 | ; | 1590 | ; |
1599 | return; | 1591 | return; |
1600 | } | 1592 | } |
1601 | ialarm->setType(type); | 1593 | ialarm->setType(type); |
1602 | 1594 | ||
1603 | p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); | 1595 | p = icalcomponent_get_first_property(alarm,ICAL_ANY_PROPERTY); |
1604 | while (p) { | 1596 | while (p) { |
1605 | icalproperty_kind kind = icalproperty_isa(p); | 1597 | icalproperty_kind kind = icalproperty_isa(p); |
1606 | 1598 | ||
1607 | switch (kind) { | 1599 | switch (kind) { |
1608 | case ICAL_TRIGGER_PROPERTY: { | 1600 | case ICAL_TRIGGER_PROPERTY: { |
1609 | icaltriggertype trigger = icalproperty_get_trigger(p); | 1601 | icaltriggertype trigger = icalproperty_get_trigger(p); |
1610 | if (icaltime_is_null_time(trigger.time)) { | 1602 | if (icaltime_is_null_time(trigger.time)) { |
1611 | if (icaldurationtype_is_null_duration(trigger.duration)) { | 1603 | if (icaldurationtype_is_null_duration(trigger.duration)) { |
1612 | kdDebug(5800) << "ICalFormatImpl::readAlarm(): Trigger has no time and no duration." << endl; | 1604 | kdDebug(5800) << "ICalFormatImpl::readAlarm(): Trigger has no time and no duration." << endl; |
1613 | } else { | 1605 | } else { |
1614 | Duration duration = icaldurationtype_as_int( trigger.duration ); | 1606 | Duration duration = icaldurationtype_as_int( trigger.duration ); |
1615 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_RELATED_PARAMETER); | 1607 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_RELATED_PARAMETER); |
1616 | if (param && icalparameter_get_related(param) == ICAL_RELATED_END) | 1608 | if (param && icalparameter_get_related(param) == ICAL_RELATED_END) |
1617 | ialarm->setEndOffset(duration); | 1609 | ialarm->setEndOffset(duration); |
1618 | else | 1610 | else |
1619 | ialarm->setStartOffset(duration); | 1611 | ialarm->setStartOffset(duration); |
1620 | } | 1612 | } |
1621 | } else { | 1613 | } else { |
1622 | ialarm->setTime(readICalDateTime(trigger.time)); | 1614 | ialarm->setTime(readICalDateTime(trigger.time)); |
1623 | } | 1615 | } |
1624 | break; | 1616 | break; |
1625 | } | 1617 | } |
1626 | case ICAL_DURATION_PROPERTY: { | 1618 | case ICAL_DURATION_PROPERTY: { |
1627 | icaldurationtype duration = icalproperty_get_duration(p); | 1619 | icaldurationtype duration = icalproperty_get_duration(p); |
1628 | ialarm->setSnoozeTime(icaldurationtype_as_int(duration)/60); | 1620 | ialarm->setSnoozeTime(icaldurationtype_as_int(duration)/60); |
1629 | break; | 1621 | break; |
1630 | } | 1622 | } |
1631 | case ICAL_REPEAT_PROPERTY: | 1623 | case ICAL_REPEAT_PROPERTY: |
1632 | ialarm->setRepeatCount(icalproperty_get_repeat(p)); | 1624 | ialarm->setRepeatCount(icalproperty_get_repeat(p)); |
1633 | break; | 1625 | break; |
1634 | 1626 | ||
1635 | // Only in DISPLAY and EMAIL and PROCEDURE alarms | 1627 | // Only in DISPLAY and EMAIL and PROCEDURE alarms |
1636 | case ICAL_DESCRIPTION_PROPERTY: { | 1628 | case ICAL_DESCRIPTION_PROPERTY: { |
1637 | QString description = QString::fromUtf8(icalproperty_get_description(p)); | 1629 | QString description = QString::fromUtf8(icalproperty_get_description(p)); |
1638 | switch ( action ) { | 1630 | switch ( action ) { |
1639 | case ICAL_ACTION_DISPLAY: | 1631 | case ICAL_ACTION_DISPLAY: |
1640 | ialarm->setText( description ); | 1632 | ialarm->setText( description ); |
1641 | break; | 1633 | break; |
1642 | case ICAL_ACTION_PROCEDURE: | 1634 | case ICAL_ACTION_PROCEDURE: |
1643 | ialarm->setProgramArguments( description ); | 1635 | ialarm->setProgramArguments( description ); |
1644 | break; | 1636 | break; |
1645 | case ICAL_ACTION_EMAIL: | 1637 | case ICAL_ACTION_EMAIL: |
1646 | ialarm->setMailText( description ); | 1638 | ialarm->setMailText( description ); |
1647 | break; | 1639 | break; |
1648 | default: | 1640 | default: |
1649 | break; | 1641 | break; |
1650 | } | 1642 | } |
1651 | break; | 1643 | break; |
1652 | } | 1644 | } |
1653 | // Only in EMAIL alarm | 1645 | // Only in EMAIL alarm |
1654 | case ICAL_SUMMARY_PROPERTY: | 1646 | case ICAL_SUMMARY_PROPERTY: |
1655 | ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); | 1647 | ialarm->setMailSubject(QString::fromUtf8(icalproperty_get_summary(p))); |
1656 | break; | 1648 | break; |
1657 | 1649 | ||
1658 | // Only in EMAIL alarm | 1650 | // Only in EMAIL alarm |
1659 | case ICAL_ATTENDEE_PROPERTY: { | 1651 | case ICAL_ATTENDEE_PROPERTY: { |
1660 | QString email = QString::fromUtf8(icalproperty_get_attendee(p)); | 1652 | QString email = QString::fromUtf8(icalproperty_get_attendee(p)); |
1661 | QString name; | 1653 | QString name; |
1662 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); | 1654 | icalparameter *param = icalproperty_get_first_parameter(p,ICAL_CN_PARAMETER); |
1663 | if (param) { | 1655 | if (param) { |
1664 | name = QString::fromUtf8(icalparameter_get_cn(param)); | 1656 | name = QString::fromUtf8(icalparameter_get_cn(param)); |
1665 | } | 1657 | } |
1666 | ialarm->addMailAddress(Person(name, email)); | 1658 | ialarm->addMailAddress(Person(name, email)); |
1667 | break; | 1659 | break; |
1668 | } | 1660 | } |
1669 | // Only in AUDIO and EMAIL and PROCEDURE alarms | 1661 | // Only in AUDIO and EMAIL and PROCEDURE alarms |
1670 | case ICAL_ATTACH_PROPERTY: { | 1662 | case ICAL_ATTACH_PROPERTY: { |
1671 | icalattach *attach = icalproperty_get_attach(p); | 1663 | icalattach *attach = icalproperty_get_attach(p); |
1672 | QString url = QFile::decodeName(icalattach_get_url(attach)); | 1664 | QString url = QFile::decodeName(icalattach_get_url(attach)); |
1673 | switch ( action ) { | 1665 | switch ( action ) { |
1674 | case ICAL_ACTION_AUDIO: | 1666 | case ICAL_ACTION_AUDIO: |
1675 | ialarm->setAudioFile( url ); | 1667 | ialarm->setAudioFile( url ); |
1676 | break; | 1668 | break; |
1677 | case ICAL_ACTION_PROCEDURE: | 1669 | case ICAL_ACTION_PROCEDURE: |
1678 | ialarm->setProgramFile( url ); | 1670 | ialarm->setProgramFile( url ); |
1679 | break; | 1671 | break; |
1680 | case ICAL_ACTION_EMAIL: | 1672 | case ICAL_ACTION_EMAIL: |
1681 | ialarm->addMailAttachment( url ); | 1673 | ialarm->addMailAttachment( url ); |
1682 | break; | 1674 | break; |
1683 | default: | 1675 | default: |
1684 | break; | 1676 | break; |
1685 | } | 1677 | } |
1686 | break; | 1678 | break; |
1687 | } | 1679 | } |
1688 | default: | 1680 | default: |
1689 | break; | 1681 | break; |
1690 | } | 1682 | } |
1691 | 1683 | ||
1692 | p = icalcomponent_get_next_property(alarm,ICAL_ANY_PROPERTY); | 1684 | p = icalcomponent_get_next_property(alarm,ICAL_ANY_PROPERTY); |
1693 | } | 1685 | } |
1694 | 1686 | ||
1695 | // custom properties | 1687 | // custom properties |
1696 | readCustomProperties(alarm, ialarm); | 1688 | readCustomProperties(alarm, ialarm); |
1697 | 1689 | ||
1698 | // TODO: check for consistency of alarm properties | 1690 | // TODO: check for consistency of alarm properties |
1699 | } | 1691 | } |
1700 | 1692 | ||
1701 | icaltimetype ICalFormatImpl::writeICalDate(const QDate &date) | 1693 | icaltimetype ICalFormatImpl::writeICalDate(const QDate &date) |
1702 | { | 1694 | { |
1703 | icaltimetype t; | 1695 | icaltimetype t; |
1704 | 1696 | ||
1705 | t.year = date.year(); | 1697 | t.year = date.year(); |
1706 | t.month = date.month(); | 1698 | t.month = date.month(); |
1707 | t.day = date.day(); | 1699 | t.day = date.day(); |
1708 | 1700 | ||
1709 | t.hour = 0; | 1701 | t.hour = 0; |
1710 | t.minute = 0; | 1702 | t.minute = 0; |
1711 | t.second = 0; | 1703 | t.second = 0; |
1712 | 1704 | ||
1713 | t.is_date = 1; | 1705 | t.is_date = 1; |
1714 | 1706 | ||
1715 | t.is_utc = 0; | 1707 | t.is_utc = 0; |
1716 | 1708 | ||
1717 | t.zone = 0; | 1709 | t.zone = 0; |
1718 | 1710 | ||
1719 | return t; | 1711 | return t; |
1720 | } | 1712 | } |
1721 | 1713 | ||
1722 | icaltimetype ICalFormatImpl::writeICalDateTime(const QDateTime &dt ) | 1714 | icaltimetype ICalFormatImpl::writeICalDateTime(const QDateTime &dt ) |
1723 | { | 1715 | { |
1724 | icaltimetype t; | 1716 | icaltimetype t; |
1725 | t.is_date = 0; | 1717 | t.is_date = 0; |
1726 | t.zone = 0; | 1718 | t.zone = 0; |
1727 | QDateTime datetime; | 1719 | QDateTime datetime; |
1728 | if ( mParent->utc() ) { | 1720 | if ( mParent->utc() ) { |
1729 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 1721 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
1730 | datetime = dt.addSecs ( -offset*60); | 1722 | datetime = dt.addSecs ( -offset*60); |
1731 | t.is_utc = 1; | 1723 | t.is_utc = 1; |
1732 | } | 1724 | } |
1733 | else { | 1725 | else { |
1734 | datetime = dt; | 1726 | datetime = dt; |
1735 | t.is_utc = 0; | 1727 | t.is_utc = 0; |
1736 | 1728 | ||
1737 | } | 1729 | } |
1738 | t.year = datetime.date().year(); | 1730 | t.year = datetime.date().year(); |
1739 | t.month = datetime.date().month(); | 1731 | t.month = datetime.date().month(); |
1740 | t.day = datetime.date().day(); | 1732 | t.day = datetime.date().day(); |
1741 | 1733 | ||
1742 | t.hour = datetime.time().hour(); | 1734 | t.hour = datetime.time().hour(); |
1743 | t.minute = datetime.time().minute(); | 1735 | t.minute = datetime.time().minute(); |
1744 | t.second = datetime.time().second(); | 1736 | t.second = datetime.time().second(); |
1745 | 1737 | ||
1746 | //qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); | 1738 | //qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); |
1747 | 1739 | ||
1748 | // if ( mParent->utc() ) { | 1740 | // if ( mParent->utc() ) { |
1749 | // datetime = KGlobal::locale()->localTime( dt ); | 1741 | // datetime = KGlobal::locale()->localTime( dt ); |
1750 | // qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); | 1742 | // qDebug("*** time %s localtime %s ",dt .toString().latin1() ,datetime .toString().latin1() ); |
1751 | // if (mParent->timeZoneId().isEmpty()) | 1743 | // if (mParent->timeZoneId().isEmpty()) |
1752 | // t = icaltime_as_utc(t, 0); | 1744 | // t = icaltime_as_utc(t, 0); |
1753 | // else | 1745 | // else |
1754 | // t = icaltime_as_utc(t,mParent->timeZoneId().local8Bit()); | 1746 | // t = icaltime_as_utc(t,mParent->timeZoneId().local8Bit()); |
1755 | // } | 1747 | // } |
1756 | 1748 | ||
1757 | return t; | 1749 | return t; |
1758 | } | 1750 | } |
1759 | 1751 | ||
1760 | QDateTime ICalFormatImpl::readICalDateTime(icaltimetype t) | 1752 | QDateTime ICalFormatImpl::readICalDateTime(icaltimetype t) |
1761 | { | 1753 | { |
1762 | QDateTime dt (QDate(t.year,t.month,t.day), | 1754 | QDateTime dt (QDate(t.year,t.month,t.day), |
1763 | QTime(t.hour,t.minute,t.second) ); | 1755 | QTime(t.hour,t.minute,t.second) ); |
1764 | 1756 | ||
1765 | if (t.is_utc) { | 1757 | if (t.is_utc) { |
1766 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 1758 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
1767 | dt = dt.addSecs ( offset*60); | 1759 | dt = dt.addSecs ( offset*60); |
1768 | } | 1760 | } |
1769 | 1761 | ||
1770 | return dt; | 1762 | return dt; |
1771 | } | 1763 | } |
1772 | 1764 | ||
1773 | QDate ICalFormatImpl::readICalDate(icaltimetype t) | 1765 | QDate ICalFormatImpl::readICalDate(icaltimetype t) |
1774 | { | 1766 | { |
1775 | return QDate(t.year,t.month,t.day); | 1767 | return QDate(t.year,t.month,t.day); |
1776 | } | 1768 | } |
1777 | 1769 | ||
1778 | icaldurationtype ICalFormatImpl::writeICalDuration(int seconds) | 1770 | icaldurationtype ICalFormatImpl::writeICalDuration(int seconds) |
1779 | { | 1771 | { |
1780 | icaldurationtype d; | 1772 | icaldurationtype d; |
1781 | 1773 | ||
1782 | d.weeks = seconds % gSecondsPerWeek; | 1774 | d.weeks = seconds % gSecondsPerWeek; |
1783 | seconds -= d.weeks * gSecondsPerWeek; | 1775 | seconds -= d.weeks * gSecondsPerWeek; |
1784 | d.days = seconds % gSecondsPerDay; | 1776 | d.days = seconds % gSecondsPerDay; |
1785 | seconds -= d.days * gSecondsPerDay; | 1777 | seconds -= d.days * gSecondsPerDay; |
1786 | d.hours = seconds % gSecondsPerHour; | 1778 | d.hours = seconds % gSecondsPerHour; |
1787 | seconds -= d.hours * gSecondsPerHour; | 1779 | seconds -= d.hours * gSecondsPerHour; |
1788 | d.minutes = seconds % gSecondsPerMinute; | 1780 | d.minutes = seconds % gSecondsPerMinute; |
1789 | seconds -= d.minutes * gSecondsPerMinute; | 1781 | seconds -= d.minutes * gSecondsPerMinute; |
1790 | d.seconds = seconds; | 1782 | d.seconds = seconds; |
1791 | d.is_neg = 0; | 1783 | d.is_neg = 0; |
1792 | 1784 | ||
1793 | return d; | 1785 | return d; |
1794 | } | 1786 | } |
1795 | 1787 | ||
1796 | int ICalFormatImpl::readICalDuration(icaldurationtype d) | 1788 | int ICalFormatImpl::readICalDuration(icaldurationtype d) |
1797 | { | 1789 | { |
1798 | int result = 0; | 1790 | int result = 0; |
1799 | 1791 | ||
1800 | result += d.weeks * gSecondsPerWeek; | 1792 | result += d.weeks * gSecondsPerWeek; |
1801 | result += d.days * gSecondsPerDay; | 1793 | result += d.days * gSecondsPerDay; |
1802 | result += d.hours * gSecondsPerHour; | 1794 | result += d.hours * gSecondsPerHour; |
1803 | result += d.minutes * gSecondsPerMinute; | 1795 | result += d.minutes * gSecondsPerMinute; |
1804 | result += d.seconds; | 1796 | result += d.seconds; |
1805 | 1797 | ||
1806 | if (d.is_neg) result *= -1; | 1798 | if (d.is_neg) result *= -1; |
1807 | 1799 | ||
1808 | return result; | 1800 | return result; |
1809 | } | 1801 | } |
1810 | 1802 | ||
1811 | icalcomponent *ICalFormatImpl::createCalendarComponent(Calendar *cal) | 1803 | icalcomponent *ICalFormatImpl::createCalendarComponent(Calendar *cal) |
1812 | { | 1804 | { |
1813 | icalcomponent *calendar; | 1805 | icalcomponent *calendar; |
1814 | 1806 | ||
1815 | // Root component | 1807 | // Root component |
1816 | calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT); | 1808 | calendar = icalcomponent_new(ICAL_VCALENDAR_COMPONENT); |
1817 | 1809 | ||
1818 | icalproperty *p; | 1810 | icalproperty *p; |
1819 | 1811 | ||
1820 | // Product Identifier | 1812 | // Product Identifier |
1821 | p = icalproperty_new_prodid(CalFormat::productId().utf8()); | 1813 | p = icalproperty_new_prodid(CalFormat::productId().utf8()); |
1822 | icalcomponent_add_property(calendar,p); | 1814 | icalcomponent_add_property(calendar,p); |
1823 | 1815 | ||
1824 | // TODO: Add time zone | 1816 | // TODO: Add time zone |
1825 | 1817 | ||
1826 | // iCalendar version (2.0) | 1818 | // iCalendar version (2.0) |
1827 | p = icalproperty_new_version(const_cast<char *>(_ICAL_VERSION)); | 1819 | p = icalproperty_new_version(const_cast<char *>(_ICAL_VERSION)); |
1828 | icalcomponent_add_property(calendar,p); | 1820 | icalcomponent_add_property(calendar,p); |
1829 | 1821 | ||
1830 | // Custom properties | 1822 | // Custom properties |
1831 | if( cal != 0 ) | 1823 | if( cal != 0 ) |
1832 | writeCustomProperties(calendar, cal); | 1824 | writeCustomProperties(calendar, cal); |
1833 | 1825 | ||
1834 | return calendar; | 1826 | return calendar; |
1835 | } | 1827 | } |
1836 | 1828 | ||
1837 | 1829 | ||
1838 | 1830 | ||
1839 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. | 1831 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. |
1840 | // and break it down from its tree-like format into the dictionary format | 1832 | // and break it down from its tree-like format into the dictionary format |
1841 | // that is used internally in the ICalFormatImpl. | 1833 | // that is used internally in the ICalFormatImpl. |
1842 | bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar) | 1834 | bool ICalFormatImpl::populate( Calendar *cal, icalcomponent *calendar) |
1843 | { | 1835 | { |
1844 | // this function will populate the caldict dictionary and other event | 1836 | // this function will populate the caldict dictionary and other event |
1845 | // lists. It turns vevents into Events and then inserts them. | 1837 | // lists. It turns vevents into Events and then inserts them. |
1846 | 1838 | ||
1847 | if (!calendar) return false; | 1839 | if (!calendar) return false; |
1848 | 1840 | ||
1849 | // TODO: check for METHOD | 1841 | // TODO: check for METHOD |
1850 | #if 0 | 1842 | #if 0 |
1851 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { | 1843 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { |
1852 | char *methodType = 0; | 1844 | char *methodType = 0; |
1853 | methodType = fakeCString(vObjectUStringZValue(curVO)); | 1845 | methodType = fakeCString(vObjectUStringZValue(curVO)); |
1854 | if (mEnableDialogs) | 1846 | if (mEnableDialogs) |
1855 | KMessageBox::information(mTopWidget, | 1847 | KMessageBox::information(mTopWidget, |
1856 | i18n("This calendar is an iTIP transaction of type \"%1\".") | 1848 | i18n("This calendar is an iTIP transaction of type \"%1\".") |
1857 | .arg(methodType), | 1849 | .arg(methodType), |
1858 | i18n("%1: iTIP Transaction").arg(CalFormat::application())); | 1850 | i18n("%1: iTIP Transaction").arg(CalFormat::application())); |
1859 | delete methodType; | 1851 | delete methodType; |
1860 | } | 1852 | } |
1861 | #endif | 1853 | #endif |
1862 | 1854 | ||
1863 | icalproperty *p; | 1855 | icalproperty *p; |
1864 | 1856 | ||
1865 | p = icalcomponent_get_first_property(calendar,ICAL_PRODID_PROPERTY); | 1857 | p = icalcomponent_get_first_property(calendar,ICAL_PRODID_PROPERTY); |
1866 | if (!p) { | 1858 | if (!p) { |
1867 | // TODO: does no PRODID really matter? | 1859 | // TODO: does no PRODID really matter? |
1868 | // mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 1860 | // mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
1869 | // return false; | 1861 | // return false; |
1870 | mLoadedProductId = ""; | 1862 | mLoadedProductId = ""; |
1871 | mCalendarVersion = 0; | 1863 | mCalendarVersion = 0; |
1872 | } else { | 1864 | } else { |
1873 | mLoadedProductId = QString::fromUtf8(icalproperty_get_prodid(p)); | 1865 | mLoadedProductId = QString::fromUtf8(icalproperty_get_prodid(p)); |
1874 | mCalendarVersion = CalFormat::calendarVersion(mLoadedProductId); | 1866 | mCalendarVersion = CalFormat::calendarVersion(mLoadedProductId); |
1875 | 1867 | ||
1876 | delete mCompat; | 1868 | delete mCompat; |
1877 | mCompat = CompatFactory::createCompat( mLoadedProductId ); | 1869 | mCompat = CompatFactory::createCompat( mLoadedProductId ); |
1878 | } | 1870 | } |
1879 | 1871 | ||
1880 | // TODO: check for unknown PRODID | 1872 | // TODO: check for unknown PRODID |
1881 | #if 0 | 1873 | #if 0 |
1882 | if (!mCalendarVersion | 1874 | if (!mCalendarVersion |
1883 | && CalFormat::productId() != mLoadedProductId) { | 1875 | && CalFormat::productId() != mLoadedProductId) { |
1884 | // warn the user that we might have trouble reading non-known calendar. | 1876 | // warn the user that we might have trouble reading non-known calendar. |
1885 | if (mEnableDialogs) | 1877 | if (mEnableDialogs) |
1886 | KMessageBox::information(mTopWidget, | 1878 | KMessageBox::information(mTopWidget, |
1887 | i18n("This vCalendar file was not created by KOrganizer " | 1879 | i18n("This vCalendar file was not created by KOrganizer " |
1888 | "or any other product we support. Loading anyway..."), | 1880 | "or any other product we support. Loading anyway..."), |
1889 | i18n("%1: Unknown vCalendar Vendor").arg(CalFormat::application())); | 1881 | i18n("%1: Unknown vCalendar Vendor").arg(CalFormat::application())); |
1890 | } | 1882 | } |
1891 | #endif | 1883 | #endif |
1892 | 1884 | ||
1893 | p = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY); | 1885 | p = icalcomponent_get_first_property(calendar,ICAL_VERSION_PROPERTY); |
1894 | if (!p) { | 1886 | if (!p) { |
1895 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 1887 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
1896 | return false; | 1888 | return false; |
1897 | } else { | 1889 | } else { |
1898 | const char *version = icalproperty_get_version(p); | 1890 | const char *version = icalproperty_get_version(p); |
1899 | 1891 | ||
1900 | if (strcmp(version,"1.0") == 0) { | 1892 | if (strcmp(version,"1.0") == 0) { |
1901 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersion1, | 1893 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersion1, |
1902 | i18n("Expected iCalendar format"))); | 1894 | i18n("Expected iCalendar format"))); |
1903 | return false; | 1895 | return false; |
1904 | } else if (strcmp(version,"2.0") != 0) { | 1896 | } else if (strcmp(version,"2.0") != 0) { |
1905 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 1897 | mParent->setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
1906 | return false; | 1898 | return false; |
1907 | } | 1899 | } |
1908 | } | 1900 | } |
1909 | 1901 | ||
1910 | 1902 | ||
1911 | // TODO: check for calendar format version | 1903 | // TODO: check for calendar format version |
1912 | #if 0 | 1904 | #if 0 |
1913 | // warn the user we might have trouble reading this unknown version. | 1905 | // warn the user we might have trouble reading this unknown version. |
1914 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1906 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1915 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1907 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1916 | if (strcmp(_VCAL_VERSION, s) != 0) | 1908 | if (strcmp(_VCAL_VERSION, s) != 0) |
1917 | if (mEnableDialogs) | 1909 | if (mEnableDialogs) |
1918 | KMessageBox::sorry(mTopWidget, | 1910 | KMessageBox::sorry(mTopWidget, |
1919 | i18n("This vCalendar file has version %1.\n" | 1911 | i18n("This vCalendar file has version %1.\n" |
1920 | "We only support %2.") | 1912 | "We only support %2.") |
1921 | .arg(s).arg(_VCAL_VERSION), | 1913 | .arg(s).arg(_VCAL_VERSION), |
1922 | i18n("%1: Unknown vCalendar Version").arg(CalFormat::application())); | 1914 | i18n("%1: Unknown vCalendar Version").arg(CalFormat::application())); |
1923 | deleteStr(s); | 1915 | deleteStr(s); |
1924 | } | 1916 | } |
1925 | #endif | 1917 | #endif |
1926 | 1918 | ||
1927 | // custom properties | 1919 | // custom properties |
1928 | readCustomProperties(calendar, cal); | 1920 | readCustomProperties(calendar, cal); |
1929 | 1921 | ||
1930 | // TODO: set time zone | 1922 | // TODO: set time zone |
1931 | #if 0 | 1923 | #if 0 |
1932 | // set the time zone | 1924 | // set the time zone |
1933 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1925 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1934 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1926 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1935 | cal->setTimeZone(s); | 1927 | cal->setTimeZone(s); |
1936 | deleteStr(s); | 1928 | deleteStr(s); |
1937 | } | 1929 | } |
1938 | #endif | 1930 | #endif |
1939 | 1931 | ||
1940 | // Store all events with a relatedTo property in a list for post-processing | 1932 | // Store all events with a relatedTo property in a list for post-processing |
1941 | mEventsRelate.clear(); | 1933 | mEventsRelate.clear(); |
1942 | mTodosRelate.clear(); | 1934 | mTodosRelate.clear(); |
1943 | // TODO: make sure that only actually added ecvens go to this lists. | 1935 | // TODO: make sure that only actually added ecvens go to this lists. |
1944 | 1936 | ||
1945 | icalcomponent *c; | 1937 | icalcomponent *c; |
1946 | 1938 | ||
1947 | // Iterate through all todos | 1939 | // Iterate through all todos |
1948 | c = icalcomponent_get_first_component(calendar,ICAL_VTODO_COMPONENT); | 1940 | c = icalcomponent_get_first_component(calendar,ICAL_VTODO_COMPONENT); |
1949 | while (c) { | 1941 | while (c) { |
1950 | // kdDebug(5800) << "----Todo found" << endl; | 1942 | // kdDebug(5800) << "----Todo found" << endl; |
1951 | Todo *todo = readTodo(c); | 1943 | Todo *todo = readTodo(c); |
1952 | if (!cal->todo(todo->uid())) cal->addTodo(todo); | 1944 | if (!cal->todo(todo->uid())) cal->addTodo(todo); |
1953 | c = icalcomponent_get_next_component(calendar,ICAL_VTODO_COMPONENT); | 1945 | c = icalcomponent_get_next_component(calendar,ICAL_VTODO_COMPONENT); |
1954 | } | 1946 | } |
1955 | 1947 | ||
1956 | // Iterate through all events | 1948 | // Iterate through all events |
1957 | c = icalcomponent_get_first_component(calendar,ICAL_VEVENT_COMPONENT); | 1949 | c = icalcomponent_get_first_component(calendar,ICAL_VEVENT_COMPONENT); |
1958 | while (c) { | 1950 | while (c) { |
1959 | // kdDebug(5800) << "----Event found" << endl; | 1951 | // kdDebug(5800) << "----Event found" << endl; |
1960 | Event *event = readEvent(c); | 1952 | Event *event = readEvent(c); |
1961 | if (!cal->event(event->uid())) cal->addEvent(event); | 1953 | if (!cal->event(event->uid())) cal->addEvent(event); |
1962 | c = icalcomponent_get_next_component(calendar,ICAL_VEVENT_COMPONENT); | 1954 | c = icalcomponent_get_next_component(calendar,ICAL_VEVENT_COMPONENT); |
1963 | } | 1955 | } |
1964 | 1956 | ||
1965 | // Iterate through all journals | 1957 | // Iterate through all journals |
1966 | c = icalcomponent_get_first_component(calendar,ICAL_VJOURNAL_COMPONENT); | 1958 | c = icalcomponent_get_first_component(calendar,ICAL_VJOURNAL_COMPONENT); |
1967 | while (c) { | 1959 | while (c) { |
1968 | // kdDebug(5800) << "----Journal found" << endl; | 1960 | // kdDebug(5800) << "----Journal found" << endl; |
1969 | Journal *journal = readJournal(c); | 1961 | Journal *journal = readJournal(c); |
1970 | if (!cal->journal(journal->uid())) cal->addJournal(journal); | 1962 | if (!cal->journal(journal->uid())) cal->addJournal(journal); |
1971 | c = icalcomponent_get_next_component(calendar,ICAL_VJOURNAL_COMPONENT); | 1963 | c = icalcomponent_get_next_component(calendar,ICAL_VJOURNAL_COMPONENT); |
1972 | } | 1964 | } |
1973 | 1965 | ||
1974 | #if 0 | 1966 | #if 0 |
1975 | initPropIterator(&i, vcal); | 1967 | initPropIterator(&i, vcal); |
1976 | 1968 | ||
1977 | // go through all the vobjects in the vcal | 1969 | // go through all the vobjects in the vcal |
1978 | while (moreIteration(&i)) { | 1970 | while (moreIteration(&i)) { |
1979 | curVO = nextVObject(&i); | 1971 | curVO = nextVObject(&i); |
1980 | 1972 | ||
1981 | /************************************************************************/ | 1973 | /************************************************************************/ |
1982 | 1974 | ||
1983 | // now, check to see that the object is an event or todo. | 1975 | // now, check to see that the object is an event or todo. |
1984 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1976 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1985 | 1977 | ||
1986 | if ((curVOProp = isAPropertyOf(curVO, KPilotStatusProp)) != 0) { | 1978 | if ((curVOProp = isAPropertyOf(curVO, KPilotStatusProp)) != 0) { |
1987 | char *s; | 1979 | char *s; |
1988 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1980 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1989 | // check to see if event was deleted by the kpilot conduit | 1981 | // check to see if event was deleted by the kpilot conduit |
1990 | if (atoi(s) == Event::SYNCDEL) { | 1982 | if (atoi(s) == Event::SYNCDEL) { |
1991 | deleteStr(s); | 1983 | deleteStr(s); |
1992 | goto SKIP; | 1984 | goto SKIP; |
1993 | } | 1985 | } |
1994 | deleteStr(s); | 1986 | deleteStr(s); |
1995 | } | 1987 | } |
1996 | 1988 | ||
1997 | // this code checks to see if we are trying to read in an event | 1989 | // this code checks to see if we are trying to read in an event |
1998 | // that we already find to be in the calendar. If we find this | 1990 | // that we already find to be in the calendar. If we find this |
1999 | // to be the case, we skip the event. | 1991 | // to be the case, we skip the event. |
2000 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 1992 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
2001 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 1993 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
2002 | QString tmpStr(s); | 1994 | QString tmpStr(s); |
2003 | deleteStr(s); | 1995 | deleteStr(s); |
2004 | 1996 | ||
2005 | if (cal->event(tmpStr)) { | 1997 | if (cal->event(tmpStr)) { |
2006 | goto SKIP; | 1998 | goto SKIP; |
2007 | } | 1999 | } |
2008 | if (cal->todo(tmpStr)) { | 2000 | if (cal->todo(tmpStr)) { |
2009 | goto SKIP; | 2001 | goto SKIP; |
2010 | } | 2002 | } |
2011 | } | 2003 | } |
2012 | 2004 | ||
2013 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && | 2005 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && |
2014 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { | 2006 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { |
2015 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 2007 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
2016 | goto SKIP; | 2008 | goto SKIP; |
2017 | } | 2009 | } |
2018 | 2010 | ||
2019 | anEvent = VEventToEvent(curVO); | 2011 | anEvent = VEventToEvent(curVO); |
2020 | // we now use addEvent instead of insertEvent so that the | 2012 | // we now use addEvent instead of insertEvent so that the |
2021 | // signal/slot get connected. | 2013 | // signal/slot get connected. |
2022 | if (anEvent) | 2014 | if (anEvent) |
2023 | cal->addEvent(anEvent); | 2015 | cal->addEvent(anEvent); |
2024 | else { | 2016 | else { |
2025 | // some sort of error must have occurred while in translation. | 2017 | // some sort of error must have occurred while in translation. |
2026 | goto SKIP; | 2018 | goto SKIP; |
2027 | } | 2019 | } |
2028 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { | 2020 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { |
2029 | anEvent = VTodoToEvent(curVO); | 2021 | anEvent = VTodoToEvent(curVO); |
2030 | cal->addTodo(anEvent); | 2022 | cal->addTodo(anEvent); |
2031 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || | 2023 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || |
2032 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || | 2024 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || |
2033 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { | 2025 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { |
2034 | // do nothing, we know these properties and we want to skip them. | 2026 | // do nothing, we know these properties and we want to skip them. |
2035 | // we have either already processed them or are ignoring them. | 2027 | // we have either already processed them or are ignoring them. |
2036 | ; | 2028 | ; |
2037 | } else { | 2029 | } else { |
2038 | ; | 2030 | ; |
2039 | } | 2031 | } |
2040 | SKIP: | 2032 | SKIP: |
2041 | ; | 2033 | ; |
2042 | } // while | 2034 | } // while |
2043 | #endif | 2035 | #endif |
2044 | 2036 | ||
2045 | // Post-Process list of events with relations, put Event objects in relation | 2037 | // Post-Process list of events with relations, put Event objects in relation |
2046 | Event *ev; | 2038 | Event *ev; |
2047 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { | 2039 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { |
2048 | ev->setRelatedTo(cal->event(ev->relatedToUid())); | 2040 | ev->setRelatedTo(cal->event(ev->relatedToUid())); |
2049 | } | 2041 | } |
2050 | Todo *todo; | 2042 | Todo *todo; |
2051 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { | 2043 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { |
2052 | todo->setRelatedTo(cal->todo(todo->relatedToUid())); | 2044 | todo->setRelatedTo(cal->todo(todo->relatedToUid())); |
2053 | } | 2045 | } |
2054 | 2046 | ||
2055 | return true; | 2047 | return true; |
2056 | } | 2048 | } |
2057 | 2049 | ||
2058 | QString ICalFormatImpl::extractErrorProperty(icalcomponent *c) | 2050 | QString ICalFormatImpl::extractErrorProperty(icalcomponent *c) |
2059 | { | 2051 | { |
2060 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " | 2052 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " |
2061 | // << icalcomponent_as_ical_string(c) << endl; | 2053 | // << icalcomponent_as_ical_string(c) << endl; |
2062 | 2054 | ||
2063 | QString errorMessage; | 2055 | QString errorMessage; |
2064 | 2056 | ||
2065 | icalproperty *error; | 2057 | icalproperty *error; |
2066 | error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY); | 2058 | error = icalcomponent_get_first_property(c,ICAL_XLICERROR_PROPERTY); |
2067 | while(error) { | 2059 | while(error) { |
2068 | errorMessage += icalproperty_get_xlicerror(error); | 2060 | errorMessage += icalproperty_get_xlicerror(error); |
2069 | errorMessage += "\n"; | 2061 | errorMessage += "\n"; |
2070 | error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY); | 2062 | error = icalcomponent_get_next_property(c,ICAL_XLICERROR_PROPERTY); |
2071 | } | 2063 | } |
2072 | 2064 | ||
2073 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl; | 2065 | // kdDebug(5800) << "ICalFormatImpl:extractErrorProperty: " << errorMessage << endl; |
2074 | 2066 | ||
2075 | return errorMessage; | 2067 | return errorMessage; |
2076 | } | 2068 | } |
2077 | 2069 | ||
2078 | void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r) | 2070 | void ICalFormatImpl::dumpIcalRecurrence(icalrecurrencetype r) |
2079 | { | 2071 | { |
2080 | int i; | 2072 | int i; |
2081 | 2073 | ||
2082 | 2074 | ||
2083 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2075 | if (r.by_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2084 | int index = 0; | 2076 | int index = 0; |
2085 | QString out = " By Day: "; | 2077 | QString out = " By Day: "; |
2086 | while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2078 | while((i = r.by_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2087 | out.append(QString::number(i) + " "); | 2079 | out.append(QString::number(i) + " "); |
2088 | } | 2080 | } |
2089 | } | 2081 | } |
2090 | if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2082 | if (r.by_month_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2091 | int index = 0; | 2083 | int index = 0; |
2092 | QString out = " By Month Day: "; | 2084 | QString out = " By Month Day: "; |
2093 | while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2085 | while((i = r.by_month_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2094 | out.append(QString::number(i) + " "); | 2086 | out.append(QString::number(i) + " "); |
2095 | } | 2087 | } |
2096 | } | 2088 | } |
2097 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2089 | if (r.by_year_day[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2098 | int index = 0; | 2090 | int index = 0; |
2099 | QString out = " By Year Day: "; | 2091 | QString out = " By Year Day: "; |
2100 | while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2092 | while((i = r.by_year_day[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2101 | out.append(QString::number(i) + " "); | 2093 | out.append(QString::number(i) + " "); |
2102 | } | 2094 | } |
2103 | } | 2095 | } |
2104 | if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2096 | if (r.by_month[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2105 | int index = 0; | 2097 | int index = 0; |
2106 | QString out = " By Month: "; | 2098 | QString out = " By Month: "; |
2107 | while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2099 | while((i = r.by_month[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2108 | out.append(QString::number(i) + " "); | 2100 | out.append(QString::number(i) + " "); |
2109 | } | 2101 | } |
2110 | } | 2102 | } |
2111 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { | 2103 | if (r.by_set_pos[0] != ICAL_RECURRENCE_ARRAY_MAX) { |
2112 | int index = 0; | 2104 | int index = 0; |
2113 | QString out = " By Set Pos: "; | 2105 | QString out = " By Set Pos: "; |
2114 | while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { | 2106 | while((i = r.by_set_pos[index++]) != ICAL_RECURRENCE_ARRAY_MAX) { |
2115 | out.append(QString::number(i) + " "); | 2107 | out.append(QString::number(i) + " "); |
2116 | } | 2108 | } |
2117 | } | 2109 | } |
2118 | } | 2110 | } |
2119 | 2111 | ||
2120 | icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence, | 2112 | icalcomponent *ICalFormatImpl::createScheduleComponent(IncidenceBase *incidence, |
2121 | Scheduler::Method method) | 2113 | Scheduler::Method method) |
2122 | { | 2114 | { |
2123 | icalcomponent *message = createCalendarComponent(); | 2115 | icalcomponent *message = createCalendarComponent(); |
2124 | 2116 | ||
2125 | icalproperty_method icalmethod = ICAL_METHOD_NONE; | 2117 | icalproperty_method icalmethod = ICAL_METHOD_NONE; |
2126 | 2118 | ||
2127 | switch (method) { | 2119 | switch (method) { |
2128 | case Scheduler::Publish: | 2120 | case Scheduler::Publish: |
2129 | icalmethod = ICAL_METHOD_PUBLISH; | 2121 | icalmethod = ICAL_METHOD_PUBLISH; |
2130 | break; | 2122 | break; |
2131 | case Scheduler::Request: | 2123 | case Scheduler::Request: |
2132 | icalmethod = ICAL_METHOD_REQUEST; | 2124 | icalmethod = ICAL_METHOD_REQUEST; |
2133 | break; | 2125 | break; |
2134 | case Scheduler::Refresh: | 2126 | case Scheduler::Refresh: |
2135 | icalmethod = ICAL_METHOD_REFRESH; | 2127 | icalmethod = ICAL_METHOD_REFRESH; |
2136 | break; | 2128 | break; |
2137 | case Scheduler::Cancel: | 2129 | case Scheduler::Cancel: |
2138 | icalmethod = ICAL_METHOD_CANCEL; | 2130 | icalmethod = ICAL_METHOD_CANCEL; |
2139 | break; | 2131 | break; |
2140 | case Scheduler::Add: | 2132 | case Scheduler::Add: |
2141 | icalmethod = ICAL_METHOD_ADD; | 2133 | icalmethod = ICAL_METHOD_ADD; |
2142 | break; | 2134 | break; |
2143 | case Scheduler::Reply: | 2135 | case Scheduler::Reply: |
2144 | icalmethod = ICAL_METHOD_REPLY; | 2136 | icalmethod = ICAL_METHOD_REPLY; |
2145 | break; | 2137 | break; |
2146 | case Scheduler::Counter: | 2138 | case Scheduler::Counter: |
2147 | icalmethod = ICAL_METHOD_COUNTER; | 2139 | icalmethod = ICAL_METHOD_COUNTER; |
2148 | break; | 2140 | break; |
2149 | case Scheduler::Declinecounter: | 2141 | case Scheduler::Declinecounter: |
2150 | icalmethod = ICAL_METHOD_DECLINECOUNTER; | 2142 | icalmethod = ICAL_METHOD_DECLINECOUNTER; |
2151 | break; | 2143 | break; |
2152 | default: | 2144 | default: |
2153 | 2145 | ||
2154 | return message; | 2146 | return message; |
2155 | } | 2147 | } |
2156 | 2148 | ||
2157 | icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); | 2149 | icalcomponent_add_property(message,icalproperty_new_method(icalmethod)); |
2158 | 2150 | ||
2159 | // TODO: check, if dynamic cast is required | 2151 | // TODO: check, if dynamic cast is required |
2160 | if(incidence->type() == "Todo") { | 2152 | if(incidence->type() == "Todo") { |
2161 | Todo *todo = static_cast<Todo *>(incidence); | 2153 | Todo *todo = static_cast<Todo *>(incidence); |
2162 | icalcomponent_add_component(message,writeTodo(todo)); | 2154 | icalcomponent_add_component(message,writeTodo(todo)); |
2163 | } | 2155 | } |
2164 | if(incidence->type() == "Event") { | 2156 | if(incidence->type() == "Event") { |
2165 | Event *event = static_cast<Event *>(incidence); | 2157 | Event *event = static_cast<Event *>(incidence); |
2166 | icalcomponent_add_component(message,writeEvent(event)); | 2158 | icalcomponent_add_component(message,writeEvent(event)); |
2167 | } | 2159 | } |
2168 | if(incidence->type() == "FreeBusy") { | 2160 | if(incidence->type() == "FreeBusy") { |
2169 | FreeBusy *freebusy = static_cast<FreeBusy *>(incidence); | 2161 | FreeBusy *freebusy = static_cast<FreeBusy *>(incidence); |
2170 | icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); | 2162 | icalcomponent_add_component(message,writeFreeBusy(freebusy, method)); |
2171 | } | 2163 | } |
2172 | 2164 | ||
2173 | return message; | 2165 | return message; |
2174 | } | 2166 | } |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 9479048..707d666 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -1,393 +1,393 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidencebase.h" | 27 | #include "incidencebase.h" |
28 | 28 | ||
29 | using namespace KCal; | 29 | using namespace KCal; |
30 | 30 | ||
31 | IncidenceBase::IncidenceBase() : | 31 | IncidenceBase::IncidenceBase() : |
32 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), | 32 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), |
33 | mPilotId(0), mSyncStatus(SYNCMOD) | 33 | mPilotId(0), mSyncStatus(SYNCMOD) |
34 | { | 34 | { |
35 | setUid(CalFormat::createUniqueId()); | 35 | setUid(CalFormat::createUniqueId()); |
36 | mOrganizer = ""; | 36 | mOrganizer = ""; |
37 | mFloats = false; | 37 | mFloats = false; |
38 | mDuration = 0; | 38 | mDuration = 0; |
39 | mHasDuration = false; | 39 | mHasDuration = false; |
40 | mPilotId = 0; | 40 | mPilotId = 0; |
41 | mZaurusId = -1; | 41 | mZaurusId = -1; |
42 | mZaurusUid = 0; | 42 | mZaurusUid = 0; |
43 | mZaurusStat = 0; | 43 | mTempSyncStat = 0; |
44 | mSyncStatus = 0; | 44 | mSyncStatus = 0; |
45 | mAttendees.setAutoDelete( true ); | 45 | mAttendees.setAutoDelete( true ); |
46 | } | 46 | } |
47 | 47 | ||
48 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 48 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
49 | CustomProperties( i ) | 49 | CustomProperties( i ) |
50 | { | 50 | { |
51 | mReadOnly = i.mReadOnly; | 51 | mReadOnly = i.mReadOnly; |
52 | mDtStart = i.mDtStart; | 52 | mDtStart = i.mDtStart; |
53 | mDuration = i.mDuration; | 53 | mDuration = i.mDuration; |
54 | mHasDuration = i.mHasDuration; | 54 | mHasDuration = i.mHasDuration; |
55 | mOrganizer = i.mOrganizer; | 55 | mOrganizer = i.mOrganizer; |
56 | mUid = i.mUid; | 56 | mUid = i.mUid; |
57 | QPtrList<Attendee> attendees = i.attendees(); | 57 | QPtrList<Attendee> attendees = i.attendees(); |
58 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 58 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
59 | mAttendees.append( new Attendee( *a ) ); | 59 | mAttendees.append( new Attendee( *a ) ); |
60 | } | 60 | } |
61 | mFloats = i.mFloats; | 61 | mFloats = i.mFloats; |
62 | mLastModified = i.mLastModified; | 62 | mLastModified = i.mLastModified; |
63 | mPilotId = i.mPilotId; | 63 | mPilotId = i.mPilotId; |
64 | mZaurusId = i.mZaurusId; | 64 | mZaurusId = i.mZaurusId; |
65 | mZaurusUid = i.mZaurusUid; | 65 | mZaurusUid = i.mZaurusUid; |
66 | mZaurusStat = i.mZaurusStat; | 66 | mTempSyncStat = i.mTempSyncStat; |
67 | mSyncStatus = i.mSyncStatus; | 67 | mSyncStatus = i.mSyncStatus; |
68 | 68 | ||
69 | // The copied object is a new one, so it isn't observed by the observer | 69 | // The copied object is a new one, so it isn't observed by the observer |
70 | // of the original object. | 70 | // of the original object. |
71 | mObservers.clear(); | 71 | mObservers.clear(); |
72 | 72 | ||
73 | mAttendees.setAutoDelete( true ); | 73 | mAttendees.setAutoDelete( true ); |
74 | } | 74 | } |
75 | 75 | ||
76 | IncidenceBase::~IncidenceBase() | 76 | IncidenceBase::~IncidenceBase() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 81 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
82 | { | 82 | { |
83 | 83 | ||
84 | if( i1.attendees().count() != i2.attendees().count() ) { | 84 | if( i1.attendees().count() != i2.attendees().count() ) { |
85 | return false; // no need to check further | 85 | return false; // no need to check further |
86 | } | 86 | } |
87 | if ( i1.attendees().count() > 0 ) { | 87 | if ( i1.attendees().count() > 0 ) { |
88 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 88 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
89 | while ( a1 ) { | 89 | while ( a1 ) { |
90 | if ( !( (*a1) == (*a2)) ) | 90 | if ( !( (*a1) == (*a2)) ) |
91 | { | 91 | { |
92 | //qDebug("Attendee not equal "); | 92 | //qDebug("Attendee not equal "); |
93 | return false; | 93 | return false; |
94 | } | 94 | } |
95 | a1 = i1.attendees().next(); | 95 | a1 = i1.attendees().next(); |
96 | a2 = i2.attendees().next(); | 96 | a2 = i2.attendees().next(); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | //if ( i1.dtStart() != i2.dtStart() ) | 99 | //if ( i1.dtStart() != i2.dtStart() ) |
100 | // return false; | 100 | // return false; |
101 | #if 0 | 101 | #if 0 |
102 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); | 102 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); |
103 | qDebug("1 %d ",i1.duration() == i2.duration() ); | 103 | qDebug("1 %d ",i1.duration() == i2.duration() ); |
104 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 104 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
105 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 105 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
106 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 106 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
107 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 107 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
108 | 108 | ||
109 | #endif | 109 | #endif |
110 | return ( i1.organizer() == i2.organizer() && | 110 | return ( i1.organizer() == i2.organizer() && |
111 | // i1.uid() == i2.uid() && | 111 | // i1.uid() == i2.uid() && |
112 | // Don't compare lastModified, otherwise the operator is not | 112 | // Don't compare lastModified, otherwise the operator is not |
113 | // of much use. We are not comparing for identity, after all. | 113 | // of much use. We are not comparing for identity, after all. |
114 | i1.doesFloat() == i2.doesFloat() && | 114 | i1.doesFloat() == i2.doesFloat() && |
115 | i1.duration() == i2.duration() && | 115 | i1.duration() == i2.duration() && |
116 | i1.hasDuration() == i2.hasDuration() && | 116 | i1.hasDuration() == i2.hasDuration() && |
117 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); | 117 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); |
118 | // no need to compare mObserver | 118 | // no need to compare mObserver |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | 122 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) |
123 | { | 123 | { |
124 | QTime t = dt.time(); | 124 | QTime t = dt.time(); |
125 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 125 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
126 | return dt; | 126 | return dt; |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | void IncidenceBase::setUid(const QString &uid) | 130 | void IncidenceBase::setUid(const QString &uid) |
131 | { | 131 | { |
132 | mUid = uid; | 132 | mUid = uid; |
133 | updated(); | 133 | updated(); |
134 | } | 134 | } |
135 | 135 | ||
136 | QString IncidenceBase::uid() const | 136 | QString IncidenceBase::uid() const |
137 | { | 137 | { |
138 | return mUid; | 138 | return mUid; |
139 | } | 139 | } |
140 | 140 | ||
141 | void IncidenceBase::setLastModified(const QDateTime &lm) | 141 | void IncidenceBase::setLastModified(const QDateTime &lm) |
142 | { | 142 | { |
143 | // DON'T! updated() because we call this from | 143 | // DON'T! updated() because we call this from |
144 | // Calendar::updateEvent(). | 144 | // Calendar::updateEvent(). |
145 | mLastModified = getEvenTime(lm); | 145 | mLastModified = getEvenTime(lm); |
146 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); | 146 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); |
147 | } | 147 | } |
148 | 148 | ||
149 | QDateTime IncidenceBase::lastModified() const | 149 | QDateTime IncidenceBase::lastModified() const |
150 | { | 150 | { |
151 | return mLastModified; | 151 | return mLastModified; |
152 | } | 152 | } |
153 | 153 | ||
154 | void IncidenceBase::setOrganizer(const QString &o) | 154 | void IncidenceBase::setOrganizer(const QString &o) |
155 | { | 155 | { |
156 | // we don't check for readonly here, because it is | 156 | // we don't check for readonly here, because it is |
157 | // possible that by setting the organizer we are changing | 157 | // possible that by setting the organizer we are changing |
158 | // the event's readonly status... | 158 | // the event's readonly status... |
159 | mOrganizer = o; | 159 | mOrganizer = o; |
160 | if (mOrganizer.left(7).upper() == "MAILTO:") | 160 | if (mOrganizer.left(7).upper() == "MAILTO:") |
161 | mOrganizer = mOrganizer.remove(0,7); | 161 | mOrganizer = mOrganizer.remove(0,7); |
162 | 162 | ||
163 | updated(); | 163 | updated(); |
164 | } | 164 | } |
165 | 165 | ||
166 | QString IncidenceBase::organizer() const | 166 | QString IncidenceBase::organizer() const |
167 | { | 167 | { |
168 | return mOrganizer; | 168 | return mOrganizer; |
169 | } | 169 | } |
170 | 170 | ||
171 | void IncidenceBase::setReadOnly( bool readOnly ) | 171 | void IncidenceBase::setReadOnly( bool readOnly ) |
172 | { | 172 | { |
173 | mReadOnly = readOnly; | 173 | mReadOnly = readOnly; |
174 | } | 174 | } |
175 | 175 | ||
176 | void IncidenceBase::setDtStart(const QDateTime &dtStart) | 176 | void IncidenceBase::setDtStart(const QDateTime &dtStart) |
177 | { | 177 | { |
178 | // if (mReadOnly) return; | 178 | // if (mReadOnly) return; |
179 | mDtStart = getEvenTime(dtStart); | 179 | mDtStart = getEvenTime(dtStart); |
180 | updated(); | 180 | updated(); |
181 | } | 181 | } |
182 | 182 | ||
183 | QDateTime IncidenceBase::dtStart() const | 183 | QDateTime IncidenceBase::dtStart() const |
184 | { | 184 | { |
185 | return mDtStart; | 185 | return mDtStart; |
186 | } | 186 | } |
187 | 187 | ||
188 | QString IncidenceBase::dtStartTimeStr() const | 188 | QString IncidenceBase::dtStartTimeStr() const |
189 | { | 189 | { |
190 | return KGlobal::locale()->formatTime(dtStart().time()); | 190 | return KGlobal::locale()->formatTime(dtStart().time()); |
191 | } | 191 | } |
192 | 192 | ||
193 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const | 193 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const |
194 | { | 194 | { |
195 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 195 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
196 | } | 196 | } |
197 | 197 | ||
198 | QString IncidenceBase::dtStartStr(bool shortfmt) const | 198 | QString IncidenceBase::dtStartStr(bool shortfmt) const |
199 | { | 199 | { |
200 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); | 200 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); |
201 | } | 201 | } |
202 | 202 | ||
203 | 203 | ||
204 | bool IncidenceBase::doesFloat() const | 204 | bool IncidenceBase::doesFloat() const |
205 | { | 205 | { |
206 | return mFloats; | 206 | return mFloats; |
207 | } | 207 | } |
208 | 208 | ||
209 | void IncidenceBase::setFloats(bool f) | 209 | void IncidenceBase::setFloats(bool f) |
210 | { | 210 | { |
211 | if (mReadOnly) return; | 211 | if (mReadOnly) return; |
212 | mFloats = f; | 212 | mFloats = f; |
213 | updated(); | 213 | updated(); |
214 | } | 214 | } |
215 | 215 | ||
216 | 216 | ||
217 | void IncidenceBase::addAttendee(Attendee *a, bool doupdate) | 217 | void IncidenceBase::addAttendee(Attendee *a, bool doupdate) |
218 | { | 218 | { |
219 | if (mReadOnly) return; | 219 | if (mReadOnly) return; |
220 | if (a->name().left(7).upper() == "MAILTO:") | 220 | if (a->name().left(7).upper() == "MAILTO:") |
221 | a->setName(a->name().remove(0,7)); | 221 | a->setName(a->name().remove(0,7)); |
222 | 222 | ||
223 | mAttendees.append(a); | 223 | mAttendees.append(a); |
224 | if (doupdate) updated(); | 224 | if (doupdate) updated(); |
225 | } | 225 | } |
226 | 226 | ||
227 | #if 0 | 227 | #if 0 |
228 | void IncidenceBase::removeAttendee(Attendee *a) | 228 | void IncidenceBase::removeAttendee(Attendee *a) |
229 | { | 229 | { |
230 | if (mReadOnly) return; | 230 | if (mReadOnly) return; |
231 | mAttendees.removeRef(a); | 231 | mAttendees.removeRef(a); |
232 | updated(); | 232 | updated(); |
233 | } | 233 | } |
234 | 234 | ||
235 | void IncidenceBase::removeAttendee(const char *n) | 235 | void IncidenceBase::removeAttendee(const char *n) |
236 | { | 236 | { |
237 | Attendee *a; | 237 | Attendee *a; |
238 | 238 | ||
239 | if (mReadOnly) return; | 239 | if (mReadOnly) return; |
240 | for (a = mAttendees.first(); a; a = mAttendees.next()) | 240 | for (a = mAttendees.first(); a; a = mAttendees.next()) |
241 | if (a->getName() == n) { | 241 | if (a->getName() == n) { |
242 | mAttendees.remove(); | 242 | mAttendees.remove(); |
243 | break; | 243 | break; |
244 | } | 244 | } |
245 | } | 245 | } |
246 | #endif | 246 | #endif |
247 | 247 | ||
248 | void IncidenceBase::clearAttendees() | 248 | void IncidenceBase::clearAttendees() |
249 | { | 249 | { |
250 | if (mReadOnly) return; | 250 | if (mReadOnly) return; |
251 | mAttendees.clear(); | 251 | mAttendees.clear(); |
252 | } | 252 | } |
253 | 253 | ||
254 | #if 0 | 254 | #if 0 |
255 | Attendee *IncidenceBase::getAttendee(const char *n) const | 255 | Attendee *IncidenceBase::getAttendee(const char *n) const |
256 | { | 256 | { |
257 | QPtrListIterator<Attendee> qli(mAttendees); | 257 | QPtrListIterator<Attendee> qli(mAttendees); |
258 | 258 | ||
259 | qli.toFirst(); | 259 | qli.toFirst(); |
260 | while (qli) { | 260 | while (qli) { |
261 | if (qli.current()->getName() == n) | 261 | if (qli.current()->getName() == n) |
262 | return qli.current(); | 262 | return qli.current(); |
263 | ++qli; | 263 | ++qli; |
264 | } | 264 | } |
265 | return 0L; | 265 | return 0L; |
266 | } | 266 | } |
267 | #endif | 267 | #endif |
268 | 268 | ||
269 | Attendee *IncidenceBase::attendeeByMail(const QString &email) | 269 | Attendee *IncidenceBase::attendeeByMail(const QString &email) |
270 | { | 270 | { |
271 | QPtrListIterator<Attendee> qli(mAttendees); | 271 | QPtrListIterator<Attendee> qli(mAttendees); |
272 | 272 | ||
273 | qli.toFirst(); | 273 | qli.toFirst(); |
274 | while (qli) { | 274 | while (qli) { |
275 | if (qli.current()->email() == email) | 275 | if (qli.current()->email() == email) |
276 | return qli.current(); | 276 | return qli.current(); |
277 | ++qli; | 277 | ++qli; |
278 | } | 278 | } |
279 | return 0L; | 279 | return 0L; |
280 | } | 280 | } |
281 | 281 | ||
282 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) | 282 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) |
283 | { | 283 | { |
284 | QPtrListIterator<Attendee> qli(mAttendees); | 284 | QPtrListIterator<Attendee> qli(mAttendees); |
285 | 285 | ||
286 | QStringList mails = emails; | 286 | QStringList mails = emails; |
287 | if (!email.isEmpty()) { | 287 | if (!email.isEmpty()) { |
288 | mails.append(email); | 288 | mails.append(email); |
289 | } | 289 | } |
290 | qli.toFirst(); | 290 | qli.toFirst(); |
291 | while (qli) { | 291 | while (qli) { |
292 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { | 292 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { |
293 | if (qli.current()->email() == *it) | 293 | if (qli.current()->email() == *it) |
294 | return qli.current(); | 294 | return qli.current(); |
295 | } | 295 | } |
296 | 296 | ||
297 | ++qli; | 297 | ++qli; |
298 | } | 298 | } |
299 | return 0L; | 299 | return 0L; |
300 | } | 300 | } |
301 | 301 | ||
302 | void IncidenceBase::setDuration(int seconds) | 302 | void IncidenceBase::setDuration(int seconds) |
303 | { | 303 | { |
304 | mDuration = seconds; | 304 | mDuration = seconds; |
305 | setHasDuration(true); | 305 | setHasDuration(true); |
306 | } | 306 | } |
307 | 307 | ||
308 | int IncidenceBase::duration() const | 308 | int IncidenceBase::duration() const |
309 | { | 309 | { |
310 | return mDuration; | 310 | return mDuration; |
311 | } | 311 | } |
312 | 312 | ||
313 | void IncidenceBase::setHasDuration(bool b) | 313 | void IncidenceBase::setHasDuration(bool b) |
314 | { | 314 | { |
315 | mHasDuration = b; | 315 | mHasDuration = b; |
316 | } | 316 | } |
317 | 317 | ||
318 | bool IncidenceBase::hasDuration() const | 318 | bool IncidenceBase::hasDuration() const |
319 | { | 319 | { |
320 | return mHasDuration; | 320 | return mHasDuration; |
321 | } | 321 | } |
322 | 322 | ||
323 | void IncidenceBase::setSyncStatus(int stat) | 323 | void IncidenceBase::setSyncStatus(int stat) |
324 | { | 324 | { |
325 | if (mReadOnly) return; | 325 | if (mReadOnly) return; |
326 | mSyncStatus = stat; | 326 | mSyncStatus = stat; |
327 | } | 327 | } |
328 | 328 | ||
329 | int IncidenceBase::syncStatus() const | 329 | int IncidenceBase::syncStatus() const |
330 | { | 330 | { |
331 | return mSyncStatus; | 331 | return mSyncStatus; |
332 | } | 332 | } |
333 | 333 | ||
334 | void IncidenceBase::setPilotId( int id ) | 334 | void IncidenceBase::setPilotId( int id ) |
335 | { | 335 | { |
336 | if (mReadOnly) return; | 336 | if (mReadOnly) return; |
337 | mPilotId = id; | 337 | mPilotId = id; |
338 | } | 338 | } |
339 | 339 | ||
340 | int IncidenceBase::pilotId() const | 340 | int IncidenceBase::pilotId() const |
341 | { | 341 | { |
342 | return mPilotId; | 342 | return mPilotId; |
343 | } | 343 | } |
344 | void IncidenceBase::setZaurusId( int id ) | 344 | void IncidenceBase::setZaurusId( int id ) |
345 | { | 345 | { |
346 | if (mReadOnly) return; | 346 | if (mReadOnly) return; |
347 | mZaurusId = id; | 347 | mZaurusId = id; |
348 | } | 348 | } |
349 | 349 | ||
350 | int IncidenceBase::zaurusId() const | 350 | int IncidenceBase::zaurusId() const |
351 | { | 351 | { |
352 | return mZaurusId; | 352 | return mZaurusId; |
353 | } | 353 | } |
354 | 354 | ||
355 | int IncidenceBase::zaurusUid() const | 355 | int IncidenceBase::zaurusUid() const |
356 | { | 356 | { |
357 | return mZaurusUid; | 357 | return mZaurusUid; |
358 | } | 358 | } |
359 | void IncidenceBase::setZaurusUid( int id ) | 359 | void IncidenceBase::setZaurusUid( int id ) |
360 | { | 360 | { |
361 | if (mReadOnly) return; | 361 | if (mReadOnly) return; |
362 | mZaurusUid = id; | 362 | mZaurusUid = id; |
363 | } | 363 | } |
364 | 364 | ||
365 | int IncidenceBase::zaurusStat() const | 365 | int IncidenceBase::tempSyncStat() const |
366 | { | 366 | { |
367 | return mZaurusStat; | 367 | return mTempSyncStat; |
368 | } | 368 | } |
369 | void IncidenceBase::setZaurusStat( int id ) | 369 | void IncidenceBase::setTempSyncStat( int id ) |
370 | { | 370 | { |
371 | if (mReadOnly) return; | 371 | if (mReadOnly) return; |
372 | mZaurusStat = id; | 372 | mTempSyncStat = id; |
373 | } | 373 | } |
374 | 374 | ||
375 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 375 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
376 | { | 376 | { |
377 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 377 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
378 | } | 378 | } |
379 | 379 | ||
380 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 380 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
381 | { | 381 | { |
382 | mObservers.remove( observer ); | 382 | mObservers.remove( observer ); |
383 | } | 383 | } |
384 | 384 | ||
385 | void IncidenceBase::updated() | 385 | void IncidenceBase::updated() |
386 | { | 386 | { |
387 | QPtrListIterator<Observer> it(mObservers); | 387 | QPtrListIterator<Observer> it(mObservers); |
388 | while( it.current() ) { | 388 | while( it.current() ) { |
389 | Observer *o = it.current(); | 389 | Observer *o = it.current(); |
390 | ++it; | 390 | ++it; |
391 | o->incidenceUpdated( this ); | 391 | o->incidenceUpdated( this ); |
392 | } | 392 | } |
393 | } | 393 | } |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index 0ab7eef..ce6e254 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -1,170 +1,170 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | #ifndef KCAL_INCIDENCEBASE_H | 20 | #ifndef KCAL_INCIDENCEBASE_H |
21 | #define KCAL_INCIDENCEBASE_H | 21 | #define KCAL_INCIDENCEBASE_H |
22 | // | 22 | // |
23 | // Incidence - base class of calendaring components | 23 | // Incidence - base class of calendaring components |
24 | // | 24 | // |
25 | 25 | ||
26 | #include <qdatetime.h> | 26 | #include <qdatetime.h> |
27 | #include <qstringlist.h> | 27 | #include <qstringlist.h> |
28 | #include <qvaluelist.h> | 28 | #include <qvaluelist.h> |
29 | #include <qptrlist.h> | 29 | #include <qptrlist.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "attendee.h" | 32 | #include "attendee.h" |
33 | 33 | ||
34 | namespace KCal { | 34 | namespace KCal { |
35 | 35 | ||
36 | typedef QValueList<QDate> DateList; | 36 | typedef QValueList<QDate> DateList; |
37 | 37 | ||
38 | /** | 38 | /** |
39 | This class provides the base class common to all calendar components. | 39 | This class provides the base class common to all calendar components. |
40 | */ | 40 | */ |
41 | class IncidenceBase : public CustomProperties | 41 | class IncidenceBase : public CustomProperties |
42 | { | 42 | { |
43 | public: | 43 | public: |
44 | class Observer { | 44 | class Observer { |
45 | public: | 45 | public: |
46 | virtual void incidenceUpdated( IncidenceBase * ) = 0; | 46 | virtual void incidenceUpdated( IncidenceBase * ) = 0; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | IncidenceBase(); | 49 | IncidenceBase(); |
50 | IncidenceBase(const IncidenceBase &); | 50 | IncidenceBase(const IncidenceBase &); |
51 | virtual ~IncidenceBase(); | 51 | virtual ~IncidenceBase(); |
52 | 52 | ||
53 | virtual QCString type() const = 0; | 53 | virtual QCString type() const = 0; |
54 | 54 | ||
55 | /** Set the unique id for the event */ | 55 | /** Set the unique id for the event */ |
56 | void setUid(const QString &); | 56 | void setUid(const QString &); |
57 | /** Return the unique id for the event */ | 57 | /** Return the unique id for the event */ |
58 | QString uid() const; | 58 | QString uid() const; |
59 | 59 | ||
60 | /** Sets the time the incidence was last modified. */ | 60 | /** Sets the time the incidence was last modified. */ |
61 | void setLastModified(const QDateTime &lm); | 61 | void setLastModified(const QDateTime &lm); |
62 | /** Return the time the incidence was last modified. */ | 62 | /** Return the time the incidence was last modified. */ |
63 | QDateTime lastModified() const; | 63 | QDateTime lastModified() const; |
64 | 64 | ||
65 | /** sets the organizer for the event */ | 65 | /** sets the organizer for the event */ |
66 | void setOrganizer(const QString &o); | 66 | void setOrganizer(const QString &o); |
67 | QString organizer() const; | 67 | QString organizer() const; |
68 | 68 | ||
69 | /** Set readonly status. */ | 69 | /** Set readonly status. */ |
70 | virtual void setReadOnly( bool ); | 70 | virtual void setReadOnly( bool ); |
71 | /** Return if the object is read-only. */ | 71 | /** Return if the object is read-only. */ |
72 | bool isReadOnly() const { return mReadOnly; } | 72 | bool isReadOnly() const { return mReadOnly; } |
73 | 73 | ||
74 | /** for setting the event's starting date/time with a QDateTime. */ | 74 | /** for setting the event's starting date/time with a QDateTime. */ |
75 | virtual void setDtStart(const QDateTime &dtStart); | 75 | virtual void setDtStart(const QDateTime &dtStart); |
76 | /** returns an event's starting date/time as a QDateTime. */ | 76 | /** returns an event's starting date/time as a QDateTime. */ |
77 | QDateTime dtStart() const; | 77 | QDateTime dtStart() const; |
78 | /** returns an event's starting time as a string formatted according to the | 78 | /** returns an event's starting time as a string formatted according to the |
79 | users locale settings */ | 79 | users locale settings */ |
80 | QString dtStartTimeStr() const; | 80 | QString dtStartTimeStr() const; |
81 | /** returns an event's starting date as a string formatted according to the | 81 | /** returns an event's starting date as a string formatted according to the |
82 | users locale settings */ | 82 | users locale settings */ |
83 | QString dtStartDateStr(bool shortfmt=true) const; | 83 | QString dtStartDateStr(bool shortfmt=true) const; |
84 | /** returns an event's starting date and time as a string formatted according | 84 | /** returns an event's starting date and time as a string formatted according |
85 | to the users locale settings */ | 85 | to the users locale settings */ |
86 | QString dtStartStr(bool shortfmt=true) const; | 86 | QString dtStartStr(bool shortfmt=true) const; |
87 | 87 | ||
88 | virtual void setDuration(int seconds); | 88 | virtual void setDuration(int seconds); |
89 | int duration() const; | 89 | int duration() const; |
90 | void setHasDuration(bool); | 90 | void setHasDuration(bool); |
91 | bool hasDuration() const; | 91 | bool hasDuration() const; |
92 | 92 | ||
93 | /** Return true or false depending on whether the incidence "floats," | 93 | /** Return true or false depending on whether the incidence "floats," |
94 | * i.e. has a date but no time attached to it. */ | 94 | * i.e. has a date but no time attached to it. */ |
95 | bool doesFloat() const; | 95 | bool doesFloat() const; |
96 | /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ | 96 | /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ |
97 | void setFloats(bool f); | 97 | void setFloats(bool f); |
98 | 98 | ||
99 | /** | 99 | /** |
100 | Add Attendee to this incidence. IncidenceBase takes ownership of the | 100 | Add Attendee to this incidence. IncidenceBase takes ownership of the |
101 | Attendee object. | 101 | Attendee object. |
102 | */ | 102 | */ |
103 | void addAttendee(Attendee *a, bool doupdate=true ); | 103 | void addAttendee(Attendee *a, bool doupdate=true ); |
104 | // void removeAttendee(Attendee *a); | 104 | // void removeAttendee(Attendee *a); |
105 | // void removeAttendee(const char *n); | 105 | // void removeAttendee(const char *n); |
106 | /** Remove all Attendees. */ | 106 | /** Remove all Attendees. */ |
107 | void clearAttendees(); | 107 | void clearAttendees(); |
108 | /** Return list of attendees. */ | 108 | /** Return list of attendees. */ |
109 | QPtrList<Attendee> attendees() const { return mAttendees; }; | 109 | QPtrList<Attendee> attendees() const { return mAttendees; }; |
110 | /** Return number of attendees. */ | 110 | /** Return number of attendees. */ |
111 | int attendeeCount() const { return mAttendees.count(); }; | 111 | int attendeeCount() const { return mAttendees.count(); }; |
112 | /** Return the Attendee with this email */ | 112 | /** Return the Attendee with this email */ |
113 | Attendee* attendeeByMail(const QString &); | 113 | Attendee* attendeeByMail(const QString &); |
114 | /** Return first Attendee with one of this emails */ | 114 | /** Return first Attendee with one of this emails */ |
115 | Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); | 115 | Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); |
116 | 116 | ||
117 | /** pilot syncronization states */ | 117 | /** pilot syncronization states */ |
118 | enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; | 118 | enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; |
119 | /** Set synchronisation satus. */ | 119 | /** Set synchronisation satus. */ |
120 | void setSyncStatus(int stat); | 120 | void setSyncStatus(int stat); |
121 | /** Return synchronisation status. */ | 121 | /** Return synchronisation status. */ |
122 | int syncStatus() const; | 122 | int syncStatus() const; |
123 | 123 | ||
124 | /** Set Pilot Id. */ | 124 | /** Set Pilot Id. */ |
125 | void setPilotId(int id); | 125 | void setPilotId(int id); |
126 | /** Return Pilot Id. */ | 126 | /** Return Pilot Id. */ |
127 | int pilotId() const; | 127 | int pilotId() const; |
128 | 128 | ||
129 | void setZaurusId(int id); | 129 | void setZaurusId(int id); |
130 | int zaurusId() const; | 130 | int zaurusId() const; |
131 | void setZaurusUid(int id); | 131 | void setZaurusUid(int id); |
132 | int zaurusUid() const; | 132 | int zaurusUid() const; |
133 | void setZaurusStat(int id); | 133 | void setTempSyncStat(int id); |
134 | int zaurusStat() const; | 134 | int tempSyncStat() const; |
135 | 135 | ||
136 | void registerObserver( Observer * ); | 136 | void registerObserver( Observer * ); |
137 | void unRegisterObserver( Observer * ); | 137 | void unRegisterObserver( Observer * ); |
138 | void updated(); | 138 | void updated(); |
139 | 139 | ||
140 | protected: | 140 | protected: |
141 | bool mReadOnly; | 141 | bool mReadOnly; |
142 | QDateTime getEvenTime( QDateTime ); | 142 | QDateTime getEvenTime( QDateTime ); |
143 | 143 | ||
144 | private: | 144 | private: |
145 | // base components | 145 | // base components |
146 | QDateTime mDtStart; | 146 | QDateTime mDtStart; |
147 | QString mOrganizer; | 147 | QString mOrganizer; |
148 | QString mUid; | 148 | QString mUid; |
149 | QDateTime mLastModified; | 149 | QDateTime mLastModified; |
150 | QPtrList<Attendee> mAttendees; | 150 | QPtrList<Attendee> mAttendees; |
151 | 151 | ||
152 | bool mFloats; | 152 | bool mFloats; |
153 | 153 | ||
154 | int mDuration; | 154 | int mDuration; |
155 | bool mHasDuration; | 155 | bool mHasDuration; |
156 | int mZaurusId; | 156 | int mZaurusId; |
157 | int mZaurusUid; | 157 | int mZaurusUid; |
158 | int mZaurusStat; | 158 | int mTempSyncStat; |
159 | 159 | ||
160 | // PILOT SYNCHRONIZATION STUFF | 160 | // PILOT SYNCHRONIZATION STUFF |
161 | int mPilotId; // unique id for pilot sync | 161 | int mPilotId; // unique id for pilot sync |
162 | int mSyncStatus; // status (for sync) | 162 | int mSyncStatus; // status (for sync) |
163 | 163 | ||
164 | QPtrList<Observer> mObservers; | 164 | QPtrList<Observer> mObservers; |
165 | }; | 165 | }; |
166 | 166 | ||
167 | bool operator==( const IncidenceBase&, const IncidenceBase& ); | 167 | bool operator==( const IncidenceBase&, const IncidenceBase& ); |
168 | } | 168 | } |
169 | 169 | ||
170 | #endif | 170 | #endif |
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp index 973f19d..d39d2dd 100644 --- a/libkcal/sharpformat.cpp +++ b/libkcal/sharpformat.cpp | |||
@@ -1,1008 +1,1008 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qxml.h> | 32 | #include <qxml.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | 38 | ||
39 | #include "calendar.h" | 39 | #include "calendar.h" |
40 | #include "alarm.h" | 40 | #include "alarm.h" |
41 | #include "recurrence.h" | 41 | #include "recurrence.h" |
42 | #include "calendarlocal.h" | 42 | #include "calendarlocal.h" |
43 | 43 | ||
44 | #include "sharpformat.h" | 44 | #include "sharpformat.h" |
45 | #include "syncdefines.h" | 45 | #include "syncdefines.h" |
46 | 46 | ||
47 | using namespace KCal; | 47 | using namespace KCal; |
48 | 48 | ||
49 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY | 49 | //CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY |
50 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 50 | // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
51 | 51 | ||
52 | //ARSD silentalarm = 0 | 52 | //ARSD silentalarm = 0 |
53 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly | 53 | // 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly |
54 | // 12 RFRQ | 54 | // 12 RFRQ |
55 | // 13 RPOS pos = 4. monday in month | 55 | // 13 RPOS pos = 4. monday in month |
56 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun | 56 | // 14 RDYS days: 1 mon/ 2 tue .. 64 sun |
57 | // 15 REND 0 = no end/ 1 = end | 57 | // 15 REND 0 = no end/ 1 = end |
58 | // 16 REDT rec end dt | 58 | // 16 REDT rec end dt |
59 | //ALSD | 59 | //ALSD |
60 | //ALED | 60 | //ALED |
61 | //MDAY | 61 | //MDAY |
62 | 62 | ||
63 | class SharpParser : public QObject | 63 | class SharpParser : public QObject |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { | 66 | SharpParser( Calendar *calendar ) : mCalendar( calendar ) { |
67 | oldCategories = 0; | 67 | oldCategories = 0; |
68 | } | 68 | } |
69 | 69 | ||
70 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) | 70 | bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) |
71 | { | 71 | { |
72 | int i = 1; | 72 | int i = 1; |
73 | bool skip = true; | 73 | bool skip = true; |
74 | int max = attList.count() -2; | 74 | int max = attList.count() -2; |
75 | while ( i < max ) { | 75 | while ( i < max ) { |
76 | if ( !attList[i].isEmpty() ) { | 76 | if ( !attList[i].isEmpty() ) { |
77 | skip = false; | 77 | skip = false; |
78 | break; | 78 | break; |
79 | } | 79 | } |
80 | ++i ; | 80 | ++i ; |
81 | } | 81 | } |
82 | if ( skip ) | 82 | if ( skip ) |
83 | return false; | 83 | return false; |
84 | ulong cSum = SharpFormat::getCsum(attList ); | 84 | ulong cSum = SharpFormat::getCsum(attList ); |
85 | 85 | ||
86 | if ( qName == "Event" ) { | 86 | if ( qName == "Event" ) { |
87 | Event *event; | 87 | Event *event; |
88 | event = existingCalendar->event( attList[0].toInt() ); | 88 | event = existingCalendar->event( attList[0].toInt() ); |
89 | if ( event ) | 89 | if ( event ) |
90 | event = (Event*)event->clone(); | 90 | event = (Event*)event->clone(); |
91 | else | 91 | else |
92 | event = new Event; | 92 | event = new Event; |
93 | event->setZaurusId( attList[0].toInt() ); | 93 | event->setZaurusId( attList[0].toInt() ); |
94 | event->setZaurusUid( cSum ); | 94 | event->setZaurusUid( cSum ); |
95 | event->setZaurusStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 95 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
96 | 96 | ||
97 | event->setSummary( attList[2] ); | 97 | event->setSummary( attList[2] ); |
98 | event->setLocation( attList[3] ); | 98 | event->setLocation( attList[3] ); |
99 | event->setDescription( attList[4] ); | 99 | event->setDescription( attList[4] ); |
100 | if ( attList[7] == "1" ) { | 100 | if ( attList[7] == "1" ) { |
101 | event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); | 101 | event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) )); |
102 | event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); | 102 | event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 ))); |
103 | event->setFloats( true ); | 103 | event->setFloats( true ); |
104 | } else { | 104 | } else { |
105 | event->setFloats( false ); | 105 | event->setFloats( false ); |
106 | event->setDtStart( fromString( attList[5] ) ); | 106 | event->setDtStart( fromString( attList[5] ) ); |
107 | event->setDtEnd( fromString( attList[6] )); | 107 | event->setDtEnd( fromString( attList[6] )); |
108 | } | 108 | } |
109 | 109 | ||
110 | QString rtype = attList[11]; | 110 | QString rtype = attList[11]; |
111 | if ( rtype != "255" ) { | 111 | if ( rtype != "255" ) { |
112 | // qDebug("recurs "); | 112 | // qDebug("recurs "); |
113 | QDate startDate = event->dtStart().date(); | 113 | QDate startDate = event->dtStart().date(); |
114 | 114 | ||
115 | QString freqStr = attList[12]; | 115 | QString freqStr = attList[12]; |
116 | int freq = freqStr.toInt(); | 116 | int freq = freqStr.toInt(); |
117 | 117 | ||
118 | QString hasEndDateStr = attList[15] ; | 118 | QString hasEndDateStr = attList[15] ; |
119 | bool hasEndDate = hasEndDateStr == "1"; | 119 | bool hasEndDate = hasEndDateStr == "1"; |
120 | 120 | ||
121 | QString endDateStr = attList[16]; | 121 | QString endDateStr = attList[16]; |
122 | QDate endDate = fromString( endDateStr ).date(); | 122 | QDate endDate = fromString( endDateStr ).date(); |
123 | 123 | ||
124 | QString weekDaysStr = attList[14]; | 124 | QString weekDaysStr = attList[14]; |
125 | uint weekDaysNum = weekDaysStr.toInt(); | 125 | uint weekDaysNum = weekDaysStr.toInt(); |
126 | 126 | ||
127 | QBitArray weekDays( 7 ); | 127 | QBitArray weekDays( 7 ); |
128 | int i; | 128 | int i; |
129 | int bb = 1; | 129 | int bb = 1; |
130 | for( i = 1; i <= 7; ++i ) { | 130 | for( i = 1; i <= 7; ++i ) { |
131 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 131 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
132 | bb = 2 << (i-1); | 132 | bb = 2 << (i-1); |
133 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 133 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
134 | } | 134 | } |
135 | // qDebug("next "); | 135 | // qDebug("next "); |
136 | QString posStr = attList[13]; | 136 | QString posStr = attList[13]; |
137 | int pos = posStr.toInt(); | 137 | int pos = posStr.toInt(); |
138 | Recurrence *r = event->recurrence(); | 138 | Recurrence *r = event->recurrence(); |
139 | 139 | ||
140 | if ( rtype == "0" ) { | 140 | if ( rtype == "0" ) { |
141 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 141 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
142 | else r->setDaily( freq, -1 ); | 142 | else r->setDaily( freq, -1 ); |
143 | } else if ( rtype == "1" ) { | 143 | } else if ( rtype == "1" ) { |
144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 144 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
145 | else r->setWeekly( freq, weekDays, -1 ); | 145 | else r->setWeekly( freq, weekDays, -1 ); |
146 | } else if ( rtype == "3" ) { | 146 | } else if ( rtype == "3" ) { |
147 | if ( hasEndDate ) | 147 | if ( hasEndDate ) |
148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 148 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
149 | else | 149 | else |
150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 150 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
151 | r->addMonthlyDay( startDate.day() ); | 151 | r->addMonthlyDay( startDate.day() ); |
152 | } else if ( rtype == "2" ) { | 152 | } else if ( rtype == "2" ) { |
153 | if ( hasEndDate ) | 153 | if ( hasEndDate ) |
154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 154 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
155 | else | 155 | else |
156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 156 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
157 | QBitArray days( 7 ); | 157 | QBitArray days( 7 ); |
158 | days.fill( false ); | 158 | days.fill( false ); |
159 | days.setBit( startDate.dayOfWeek() - 1 ); | 159 | days.setBit( startDate.dayOfWeek() - 1 ); |
160 | r->addMonthlyPos( pos, days ); | 160 | r->addMonthlyPos( pos, days ); |
161 | } else if ( rtype == "4" ) { | 161 | } else if ( rtype == "4" ) { |
162 | if ( hasEndDate ) | 162 | if ( hasEndDate ) |
163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 163 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
164 | else | 164 | else |
165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 165 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
166 | r->addYearlyNum( startDate.month() ); | 166 | r->addYearlyNum( startDate.month() ); |
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | QString categoryList = attList[1] ; | 170 | QString categoryList = attList[1] ; |
171 | event->setCategories( lookupCategories( categoryList ) ); | 171 | event->setCategories( lookupCategories( categoryList ) ); |
172 | 172 | ||
173 | // strange 0 semms to mean: alarm enabled | 173 | // strange 0 semms to mean: alarm enabled |
174 | if ( attList[8] == "0" ) { | 174 | if ( attList[8] == "0" ) { |
175 | Alarm *alarm; | 175 | Alarm *alarm; |
176 | if ( event->alarms().count() > 0 ) | 176 | if ( event->alarms().count() > 0 ) |
177 | alarm = event->alarms().first(); | 177 | alarm = event->alarms().first(); |
178 | else { | 178 | else { |
179 | alarm = new Alarm( event ); | 179 | alarm = new Alarm( event ); |
180 | event->addAlarm( alarm ); | 180 | event->addAlarm( alarm ); |
181 | } | 181 | } |
182 | alarm->setType( Alarm::Audio ); | 182 | alarm->setType( Alarm::Audio ); |
183 | alarm->setEnabled( true ); | 183 | alarm->setEnabled( true ); |
184 | int alarmOffset = attList[9].toInt(); | 184 | int alarmOffset = attList[9].toInt(); |
185 | alarm->setStartOffset( alarmOffset * -60 ); | 185 | alarm->setStartOffset( alarmOffset * -60 ); |
186 | } | 186 | } |
187 | 187 | ||
188 | mCalendar->addEvent( event); | 188 | mCalendar->addEvent( event); |
189 | } else if ( qName == "Todo" ) { | 189 | } else if ( qName == "Todo" ) { |
190 | Todo *todo; | 190 | Todo *todo; |
191 | 191 | ||
192 | todo = existingCalendar->todo( attList[0].toInt() ); | 192 | todo = existingCalendar->todo( attList[0].toInt() ); |
193 | if (todo ) | 193 | if (todo ) |
194 | todo = (Todo*)todo->clone(); | 194 | todo = (Todo*)todo->clone(); |
195 | else | 195 | else |
196 | todo = new Todo; | 196 | todo = new Todo; |
197 | 197 | ||
198 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 | 198 | //CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 |
199 | // 0 1 2 3 4 5 6 7 8 | 199 | // 0 1 2 3 4 5 6 7 8 |
200 | //1,,,,,1,4,Loch zumachen,"" | 200 | //1,,,,,1,4,Loch zumachen,"" |
201 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " | 201 | //3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " |
202 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes | 202 | //2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes |
203 | 203 | ||
204 | todo->setZaurusId( attList[0].toInt() ); | 204 | todo->setZaurusId( attList[0].toInt() ); |
205 | todo->setZaurusUid( cSum ); | 205 | todo->setZaurusUid( cSum ); |
206 | todo->setZaurusStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 206 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
207 | 207 | ||
208 | todo->setSummary( attList[7] ); | 208 | todo->setSummary( attList[7] ); |
209 | todo->setDescription( attList[8]); | 209 | todo->setDescription( attList[8]); |
210 | 210 | ||
211 | int priority = attList[6].toInt(); | 211 | int priority = attList[6].toInt(); |
212 | if ( priority == 0 ) priority = 3; | 212 | if ( priority == 0 ) priority = 3; |
213 | todo->setPriority( priority ); | 213 | todo->setPriority( priority ); |
214 | 214 | ||
215 | QString categoryList = attList[1]; | 215 | QString categoryList = attList[1]; |
216 | todo->setCategories( lookupCategories( categoryList ) ); | 216 | todo->setCategories( lookupCategories( categoryList ) ); |
217 | 217 | ||
218 | 218 | ||
219 | 219 | ||
220 | QString hasDateStr = attList[3]; // due | 220 | QString hasDateStr = attList[3]; // due |
221 | if ( !hasDateStr.isEmpty() ) { | 221 | if ( !hasDateStr.isEmpty() ) { |
222 | if ( hasDateStr.right(6) == "000000" ) { | 222 | if ( hasDateStr.right(6) == "000000" ) { |
223 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); | 223 | todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); |
224 | todo->setFloats( true ); | 224 | todo->setFloats( true ); |
225 | } | 225 | } |
226 | else { | 226 | else { |
227 | todo->setDtDue( fromString( hasDateStr ) ); | 227 | todo->setDtDue( fromString( hasDateStr ) ); |
228 | todo->setFloats( false ); | 228 | todo->setFloats( false ); |
229 | } | 229 | } |
230 | 230 | ||
231 | todo->setHasDueDate( true ); | 231 | todo->setHasDueDate( true ); |
232 | } | 232 | } |
233 | hasDateStr = attList[2];//start | 233 | hasDateStr = attList[2];//start |
234 | if ( !hasDateStr.isEmpty() ) { | 234 | if ( !hasDateStr.isEmpty() ) { |
235 | 235 | ||
236 | todo->setDtStart( fromString( hasDateStr ) ); | 236 | todo->setDtStart( fromString( hasDateStr ) ); |
237 | todo->setHasStartDate( true); | 237 | todo->setHasStartDate( true); |
238 | } else | 238 | } else |
239 | todo->setHasStartDate( false ); | 239 | todo->setHasStartDate( false ); |
240 | hasDateStr = attList[4];//completed | 240 | hasDateStr = attList[4];//completed |
241 | if ( !hasDateStr.isEmpty() ) { | 241 | if ( !hasDateStr.isEmpty() ) { |
242 | todo->setCompleted(fromString( hasDateStr ) ); | 242 | todo->setCompleted(fromString( hasDateStr ) ); |
243 | } | 243 | } |
244 | QString completedStr = attList[5]; | 244 | QString completedStr = attList[5]; |
245 | if ( completedStr == "0" ) | 245 | if ( completedStr == "0" ) |
246 | todo->setCompleted( true ); | 246 | todo->setCompleted( true ); |
247 | else | 247 | else |
248 | todo->setCompleted( false ); | 248 | todo->setCompleted( false ); |
249 | mCalendar->addTodo( todo ); | 249 | mCalendar->addTodo( todo ); |
250 | 250 | ||
251 | } else if ( qName == "Category" ) { | 251 | } else if ( qName == "Category" ) { |
252 | /* | 252 | /* |
253 | QString id = attributes.value( "id" ); | 253 | QString id = attributes.value( "id" ); |
254 | QString name = attributes.value( "name" ); | 254 | QString name = attributes.value( "name" ); |
255 | setCategory( id, name ); | 255 | setCategory( id, name ); |
256 | */ | 256 | */ |
257 | } | 257 | } |
258 | //qDebug("end "); | 258 | //qDebug("end "); |
259 | return true; | 259 | return true; |
260 | } | 260 | } |
261 | 261 | ||
262 | 262 | ||
263 | void setCategoriesList ( QStringList * c ) | 263 | void setCategoriesList ( QStringList * c ) |
264 | { | 264 | { |
265 | oldCategories = c; | 265 | oldCategories = c; |
266 | } | 266 | } |
267 | 267 | ||
268 | QDateTime fromString ( QString s, bool useTz = true ) { | 268 | QDateTime fromString ( QString s, bool useTz = true ) { |
269 | QDateTime dt; | 269 | QDateTime dt; |
270 | int y,m,t,h,min,sec; | 270 | int y,m,t,h,min,sec; |
271 | y = s.mid(0,4).toInt(); | 271 | y = s.mid(0,4).toInt(); |
272 | m = s.mid(4,2).toInt(); | 272 | m = s.mid(4,2).toInt(); |
273 | t = s.mid(6,2).toInt(); | 273 | t = s.mid(6,2).toInt(); |
274 | h = s.mid(9,2).toInt(); | 274 | h = s.mid(9,2).toInt(); |
275 | min = s.mid(11,2).toInt(); | 275 | min = s.mid(11,2).toInt(); |
276 | sec = s.mid(13,2).toInt(); | 276 | sec = s.mid(13,2).toInt(); |
277 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 277 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
278 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 278 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
279 | if ( useTz ) | 279 | if ( useTz ) |
280 | dt = dt.addSecs ( offset*60); | 280 | dt = dt.addSecs ( offset*60); |
281 | return dt; | 281 | return dt; |
282 | 282 | ||
283 | } | 283 | } |
284 | protected: | 284 | protected: |
285 | QDateTime toDateTime( const QString &value ) | 285 | QDateTime toDateTime( const QString &value ) |
286 | { | 286 | { |
287 | QDateTime dt; | 287 | QDateTime dt; |
288 | dt.setTime_t( value.toUInt() ); | 288 | dt.setTime_t( value.toUInt() ); |
289 | 289 | ||
290 | return dt; | 290 | return dt; |
291 | } | 291 | } |
292 | 292 | ||
293 | QStringList lookupCategories( const QString &categoryList ) | 293 | QStringList lookupCategories( const QString &categoryList ) |
294 | { | 294 | { |
295 | QStringList categoryIds = QStringList::split( ";", categoryList ); | 295 | QStringList categoryIds = QStringList::split( ";", categoryList ); |
296 | QStringList categories; | 296 | QStringList categories; |
297 | QStringList::ConstIterator it; | 297 | QStringList::ConstIterator it; |
298 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { | 298 | for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { |
299 | QString cate = category( *it ); | 299 | QString cate = category( *it ); |
300 | if ( oldCategories ) { | 300 | if ( oldCategories ) { |
301 | if ( ! oldCategories->contains( cate ) ) | 301 | if ( ! oldCategories->contains( cate ) ) |
302 | oldCategories->append( cate ); | 302 | oldCategories->append( cate ); |
303 | } | 303 | } |
304 | categories.append(cate ); | 304 | categories.append(cate ); |
305 | } | 305 | } |
306 | return categories; | 306 | return categories; |
307 | } | 307 | } |
308 | 308 | ||
309 | private: | 309 | private: |
310 | Calendar *mCalendar; | 310 | Calendar *mCalendar; |
311 | QStringList * oldCategories; | 311 | QStringList * oldCategories; |
312 | static QString category( const QString &id ) | 312 | static QString category( const QString &id ) |
313 | { | 313 | { |
314 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); | 314 | QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); |
315 | if ( it == mCategoriesMap.end() ) return id; | 315 | if ( it == mCategoriesMap.end() ) return id; |
316 | else return *it; | 316 | else return *it; |
317 | } | 317 | } |
318 | 318 | ||
319 | static void setCategory( const QString &id, const QString &name ) | 319 | static void setCategory( const QString &id, const QString &name ) |
320 | { | 320 | { |
321 | mCategoriesMap.insert( id, name ); | 321 | mCategoriesMap.insert( id, name ); |
322 | } | 322 | } |
323 | 323 | ||
324 | static QMap<QString,QString> mCategoriesMap; | 324 | static QMap<QString,QString> mCategoriesMap; |
325 | }; | 325 | }; |
326 | 326 | ||
327 | QMap<QString,QString> SharpParser::mCategoriesMap; | 327 | QMap<QString,QString> SharpParser::mCategoriesMap; |
328 | 328 | ||
329 | SharpFormat::SharpFormat() | 329 | SharpFormat::SharpFormat() |
330 | { | 330 | { |
331 | mCategories = 0; | 331 | mCategories = 0; |
332 | } | 332 | } |
333 | 333 | ||
334 | SharpFormat::~SharpFormat() | 334 | SharpFormat::~SharpFormat() |
335 | { | 335 | { |
336 | } | 336 | } |
337 | ulong SharpFormat::getCsum( const QStringList & attList) | 337 | ulong SharpFormat::getCsum( const QStringList & attList) |
338 | { | 338 | { |
339 | int max = attList.count() -1; | 339 | int max = attList.count() -1; |
340 | ulong cSum = 0; | 340 | ulong cSum = 0; |
341 | int j,k,i; | 341 | int j,k,i; |
342 | int add; | 342 | int add; |
343 | for ( i = 1; i < max ; ++i ) { | 343 | for ( i = 1; i < max ; ++i ) { |
344 | QString s = attList[i]; | 344 | QString s = attList[i]; |
345 | if ( ! s.isEmpty() ){ | 345 | if ( ! s.isEmpty() ){ |
346 | j = s.length(); | 346 | j = s.length(); |
347 | for ( k = 0; k < j; ++k ) { | 347 | for ( k = 0; k < j; ++k ) { |
348 | int mul = k +1; | 348 | int mul = k +1; |
349 | add = s[k].unicode (); | 349 | add = s[k].unicode (); |
350 | if ( k < 16 ) | 350 | if ( k < 16 ) |
351 | mul = mul * mul; | 351 | mul = mul * mul; |
352 | add = add * mul *i*i*i; | 352 | add = add * mul *i*i*i; |
353 | cSum += add; | 353 | cSum += add; |
354 | } | 354 | } |
355 | } | 355 | } |
356 | } | 356 | } |
357 | return cSum; | 357 | return cSum; |
358 | 358 | ||
359 | } | 359 | } |
360 | #include <stdlib.h> | 360 | #include <stdlib.h> |
361 | #define DEBUGMODE false | 361 | #define DEBUGMODE false |
362 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) | 362 | bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) |
363 | { | 363 | { |
364 | 364 | ||
365 | 365 | ||
366 | bool debug = DEBUGMODE; | 366 | bool debug = DEBUGMODE; |
367 | //debug = true; | 367 | //debug = true; |
368 | QString text; | 368 | QString text; |
369 | QString codec = "utf8"; | 369 | QString codec = "utf8"; |
370 | QLabel status ( i18n("Reading events ..."), 0 ); | 370 | QLabel status ( i18n("Reading events ..."), 0 ); |
371 | 371 | ||
372 | int w = status.sizeHint().width()+20 ; | 372 | int w = status.sizeHint().width()+20 ; |
373 | if ( w < 200 ) w = 200; | 373 | if ( w < 200 ) w = 200; |
374 | int h = status.sizeHint().height()+20 ; | 374 | int h = status.sizeHint().height()+20 ; |
375 | int dw = QApplication::desktop()->width(); | 375 | int dw = QApplication::desktop()->width(); |
376 | int dh = QApplication::desktop()->height(); | 376 | int dh = QApplication::desktop()->height(); |
377 | status.setCaption(i18n("Reading DTM Data") ); | 377 | status.setCaption(i18n("Reading DTM Data") ); |
378 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 378 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
379 | status.show(); | 379 | status.show(); |
380 | status.raise(); | 380 | status.raise(); |
381 | qApp->processEvents(); | 381 | qApp->processEvents(); |
382 | QString fileName; | 382 | QString fileName; |
383 | if ( ! debug ) { | 383 | if ( ! debug ) { |
384 | fileName = "/tmp/kopitempout"; | 384 | fileName = "/tmp/kopitempout"; |
385 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; | 385 | QString command ="db2file datebook -r -c "+ codec + " > " + fileName; |
386 | system ( command.latin1() ); | 386 | system ( command.latin1() ); |
387 | } else { | 387 | } else { |
388 | fileName = "/tmp/events.txt"; | 388 | fileName = "/tmp/events.txt"; |
389 | 389 | ||
390 | } | 390 | } |
391 | QFile file( fileName ); | 391 | QFile file( fileName ); |
392 | if (!file.open( IO_ReadOnly ) ) { | 392 | if (!file.open( IO_ReadOnly ) ) { |
393 | return false; | 393 | return false; |
394 | 394 | ||
395 | } | 395 | } |
396 | QTextStream ts( &file ); | 396 | QTextStream ts( &file ); |
397 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 397 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
398 | text = ts.read(); | 398 | text = ts.read(); |
399 | file.close(); | 399 | file.close(); |
400 | status.setText( i18n("Processing events ...") ); | 400 | status.setText( i18n("Processing events ...") ); |
401 | status.raise(); | 401 | status.raise(); |
402 | qApp->processEvents(); | 402 | qApp->processEvents(); |
403 | fromString2Cal( calendar, existngCal, text, "Event" ); | 403 | fromString2Cal( calendar, existngCal, text, "Event" ); |
404 | status.setText( i18n("Reading todos ...") ); | 404 | status.setText( i18n("Reading todos ...") ); |
405 | qApp->processEvents(); | 405 | qApp->processEvents(); |
406 | if ( ! debug ) { | 406 | if ( ! debug ) { |
407 | fileName = "/tmp/kopitempout"; | 407 | fileName = "/tmp/kopitempout"; |
408 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; | 408 | QString command = "db2file todo -r -c " + codec+ " > " + fileName; |
409 | system ( command.latin1() ); | 409 | system ( command.latin1() ); |
410 | } else { | 410 | } else { |
411 | fileName = "/tmp/todo.txt"; | 411 | fileName = "/tmp/todo.txt"; |
412 | } | 412 | } |
413 | file.setName( fileName ); | 413 | file.setName( fileName ); |
414 | if (!file.open( IO_ReadOnly ) ) { | 414 | if (!file.open( IO_ReadOnly ) ) { |
415 | return false; | 415 | return false; |
416 | 416 | ||
417 | } | 417 | } |
418 | ts.setDevice( &file ); | 418 | ts.setDevice( &file ); |
419 | text = ts.read(); | 419 | text = ts.read(); |
420 | file.close(); | 420 | file.close(); |
421 | 421 | ||
422 | status.setText( i18n("Processing todos ...") ); | 422 | status.setText( i18n("Processing todos ...") ); |
423 | status.raise(); | 423 | status.raise(); |
424 | qApp->processEvents(); | 424 | qApp->processEvents(); |
425 | fromString2Cal( calendar, existngCal, text, "Todo" ); | 425 | fromString2Cal( calendar, existngCal, text, "Todo" ); |
426 | return true; | 426 | return true; |
427 | } | 427 | } |
428 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) | 428 | int SharpFormat::getNumFromRecord( QString answer, Incidence* inc ) |
429 | { | 429 | { |
430 | int retval = -1; | 430 | int retval = -1; |
431 | QStringList templist; | 431 | QStringList templist; |
432 | QString tempString; | 432 | QString tempString; |
433 | int start = 0; | 433 | int start = 0; |
434 | int len = answer.length(); | 434 | int len = answer.length(); |
435 | int end = answer.find ("\n",start)+1; | 435 | int end = answer.find ("\n",start)+1; |
436 | bool ok = true; | 436 | bool ok = true; |
437 | start = end; | 437 | start = end; |
438 | int ccc = 0; | 438 | int ccc = 0; |
439 | while ( start > 0 ) { | 439 | while ( start > 0 ) { |
440 | templist.clear(); | 440 | templist.clear(); |
441 | ok = true; | 441 | ok = true; |
442 | int loopCount = 0; | 442 | int loopCount = 0; |
443 | while ( ok ) { | 443 | while ( ok ) { |
444 | ++loopCount; | 444 | ++loopCount; |
445 | if ( loopCount > 25 ) { | 445 | if ( loopCount > 25 ) { |
446 | qDebug("KO: Error in while loop"); | 446 | qDebug("KO: Error in while loop"); |
447 | ok = false; | 447 | ok = false; |
448 | start = 0; | 448 | start = 0; |
449 | break; | 449 | break; |
450 | } | 450 | } |
451 | if ( ok ) | 451 | if ( ok ) |
452 | tempString = getPart( answer, ok, start ); | 452 | tempString = getPart( answer, ok, start ); |
453 | if ( start >= len || start == 0 ) { | 453 | if ( start >= len || start == 0 ) { |
454 | start = 0; | 454 | start = 0; |
455 | ok = false; | 455 | ok = false; |
456 | } | 456 | } |
457 | if ( tempString.right(1) =="\n" ) | 457 | if ( tempString.right(1) =="\n" ) |
458 | tempString = tempString.left( tempString.length()-1); | 458 | tempString = tempString.left( tempString.length()-1); |
459 | 459 | ||
460 | templist.append( tempString ); | 460 | templist.append( tempString ); |
461 | } | 461 | } |
462 | ++ccc; | 462 | ++ccc; |
463 | if ( ccc == 2 && loopCount < 25 ) { | 463 | if ( ccc == 2 && loopCount < 25 ) { |
464 | start = 0; | 464 | start = 0; |
465 | bool ok; | 465 | bool ok; |
466 | int newnum = templist[0].toInt( &ok ); | 466 | int newnum = templist[0].toInt( &ok ); |
467 | if ( ok && newnum > 0) { | 467 | if ( ok && newnum > 0) { |
468 | retval = newnum; | 468 | retval = newnum; |
469 | inc->setZaurusId( newnum ); | 469 | inc->setZaurusId( newnum ); |
470 | inc->setZaurusUid( getCsum( templist ) ); | 470 | inc->setZaurusUid( getCsum( templist ) ); |
471 | inc->setZaurusStat( SYNC_TEMPSTATE_NEW_ID ); | 471 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
472 | } | 472 | } |
473 | } | 473 | } |
474 | } | 474 | } |
475 | //qDebug("getNumFromRecord returning : %d ", retval); | 475 | //qDebug("getNumFromRecord returning : %d ", retval); |
476 | return retval; | 476 | return retval; |
477 | } | 477 | } |
478 | bool SharpFormat::save( Calendar *calendar) | 478 | bool SharpFormat::save( Calendar *calendar) |
479 | { | 479 | { |
480 | 480 | ||
481 | QLabel status ( i18n("Processing/adding events ..."), 0 ); | 481 | QLabel status ( i18n("Processing/adding events ..."), 0 ); |
482 | int w = status.sizeHint().width()+20 ; | 482 | int w = status.sizeHint().width()+20 ; |
483 | if ( w < 200 ) w = 200; | 483 | if ( w < 200 ) w = 200; |
484 | int h = status.sizeHint().height()+20 ; | 484 | int h = status.sizeHint().height()+20 ; |
485 | int dw = QApplication::desktop()->width(); | 485 | int dw = QApplication::desktop()->width(); |
486 | int dh = QApplication::desktop()->height(); | 486 | int dh = QApplication::desktop()->height(); |
487 | status.setCaption(i18n("Writing DTM Data") ); | 487 | status.setCaption(i18n("Writing DTM Data") ); |
488 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 488 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
489 | status.show(); | 489 | status.show(); |
490 | status.raise(); | 490 | status.raise(); |
491 | qApp->processEvents(); | 491 | qApp->processEvents(); |
492 | bool debug = DEBUGMODE; | 492 | bool debug = DEBUGMODE; |
493 | QString codec = "utf8"; | 493 | QString codec = "utf8"; |
494 | QString answer; | 494 | QString answer; |
495 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; | 495 | QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; |
496 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; | 496 | QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; |
497 | QString command; | 497 | QString command; |
498 | QPtrList<Event> er = calendar->rawEvents(); | 498 | QPtrList<Event> er = calendar->rawEvents(); |
499 | Event* ev = er.first(); | 499 | Event* ev = er.first(); |
500 | QString fileName = "/tmp/kopitempout"; | 500 | QString fileName = "/tmp/kopitempout"; |
501 | int i = 0; | 501 | int i = 0; |
502 | QString changeString = ePrefix; | 502 | QString changeString = ePrefix; |
503 | QString deleteString = ePrefix; | 503 | QString deleteString = ePrefix; |
504 | bool deleteEnt = false; | 504 | bool deleteEnt = false; |
505 | bool changeEnt = false; | 505 | bool changeEnt = false; |
506 | QString message = i18n("Processing event # "); | 506 | QString message = i18n("Processing event # "); |
507 | int procCount = 0; | 507 | int procCount = 0; |
508 | while ( ev ) { | 508 | while ( ev ) { |
509 | //qDebug("i %d ", ++i); | 509 | //qDebug("i %d ", ++i); |
510 | if ( ev->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 510 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
511 | status.setText ( message + QString::number ( ++procCount ) ); | 511 | status.setText ( message + QString::number ( ++procCount ) ); |
512 | qApp->processEvents(); | 512 | qApp->processEvents(); |
513 | QString eString = getEventString( ev ); | 513 | QString eString = getEventString( ev ); |
514 | if ( ev->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 514 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
515 | // deleting empty strings does not work. | 515 | // deleting empty strings does not work. |
516 | // we write first and x and then delete the record with the x | 516 | // we write first and x and then delete the record with the x |
517 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 517 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
518 | changeString += eString + "\n"; | 518 | changeString += eString + "\n"; |
519 | deleteString += eString + "\n"; | 519 | deleteString += eString + "\n"; |
520 | deleteEnt = true; | 520 | deleteEnt = true; |
521 | changeEnt = true; | 521 | changeEnt = true; |
522 | } | 522 | } |
523 | else if ( ev->zaurusId() == -1 ) { // add new | 523 | else if ( ev->zaurusId() == -1 ) { // add new |
524 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 524 | command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
525 | system ( command.utf8() ); | 525 | system ( command.utf8() ); |
526 | QFile file( fileName ); | 526 | QFile file( fileName ); |
527 | if (!file.open( IO_ReadOnly ) ) { | 527 | if (!file.open( IO_ReadOnly ) ) { |
528 | return false; | 528 | return false; |
529 | 529 | ||
530 | } | 530 | } |
531 | QTextStream ts( &file ); | 531 | QTextStream ts( &file ); |
532 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 532 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
533 | answer = ts.read(); | 533 | answer = ts.read(); |
534 | file.close(); | 534 | file.close(); |
535 | //qDebug("answer \n%s ", answer.latin1()); | 535 | //qDebug("answer \n%s ", answer.latin1()); |
536 | getNumFromRecord( answer, ev ) ; | 536 | getNumFromRecord( answer, ev ) ; |
537 | 537 | ||
538 | } | 538 | } |
539 | else { // change existing | 539 | else { // change existing |
540 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); | 540 | //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); |
541 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 541 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
542 | changeString += eString + "\n"; | 542 | changeString += eString + "\n"; |
543 | changeEnt = true; | 543 | changeEnt = true; |
544 | 544 | ||
545 | } | 545 | } |
546 | } | 546 | } |
547 | ev = er.next(); | 547 | ev = er.next(); |
548 | } | 548 | } |
549 | status.setText ( i18n("Changing events ...") ); | 549 | status.setText ( i18n("Changing events ...") ); |
550 | qApp->processEvents(); | 550 | qApp->processEvents(); |
551 | //qDebug("changing... "); | 551 | //qDebug("changing... "); |
552 | if ( changeEnt ) { | 552 | if ( changeEnt ) { |
553 | QFile file( fileName ); | 553 | QFile file( fileName ); |
554 | if (!file.open( IO_WriteOnly ) ) { | 554 | if (!file.open( IO_WriteOnly ) ) { |
555 | return false; | 555 | return false; |
556 | 556 | ||
557 | } | 557 | } |
558 | QTextStream ts( &file ); | 558 | QTextStream ts( &file ); |
559 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 559 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
560 | ts << changeString ; | 560 | ts << changeString ; |
561 | file.close(); | 561 | file.close(); |
562 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; | 562 | command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; |
563 | system ( command.latin1() ); | 563 | system ( command.latin1() ); |
564 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | 564 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); |
565 | 565 | ||
566 | } | 566 | } |
567 | status.setText ( i18n("Deleting events ...") ); | 567 | status.setText ( i18n("Deleting events ...") ); |
568 | qApp->processEvents(); | 568 | qApp->processEvents(); |
569 | //qDebug("deleting... "); | 569 | //qDebug("deleting... "); |
570 | if ( deleteEnt ) { | 570 | if ( deleteEnt ) { |
571 | QFile file( fileName ); | 571 | QFile file( fileName ); |
572 | if (!file.open( IO_WriteOnly ) ) { | 572 | if (!file.open( IO_WriteOnly ) ) { |
573 | return false; | 573 | return false; |
574 | 574 | ||
575 | } | 575 | } |
576 | QTextStream ts( &file ); | 576 | QTextStream ts( &file ); |
577 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 577 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
578 | ts << deleteString; | 578 | ts << deleteString; |
579 | file.close(); | 579 | file.close(); |
580 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; | 580 | command = "db2file datebook -d -c " + codec+ " < "+ fileName; |
581 | system ( command.latin1() ); | 581 | system ( command.latin1() ); |
582 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 582 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
583 | } | 583 | } |
584 | 584 | ||
585 | 585 | ||
586 | changeString = tPrefix; | 586 | changeString = tPrefix; |
587 | deleteString = tPrefix; | 587 | deleteString = tPrefix; |
588 | status.setText ( i18n("Processing todos ...") ); | 588 | status.setText ( i18n("Processing todos ...") ); |
589 | qApp->processEvents(); | 589 | qApp->processEvents(); |
590 | QPtrList<Todo> tl = calendar->rawTodos(); | 590 | QPtrList<Todo> tl = calendar->rawTodos(); |
591 | Todo* to = tl.first(); | 591 | Todo* to = tl.first(); |
592 | i = 0; | 592 | i = 0; |
593 | message = i18n("Processing todo # "); | 593 | message = i18n("Processing todo # "); |
594 | procCount = 0; | 594 | procCount = 0; |
595 | while ( to ) { | 595 | while ( to ) { |
596 | if ( to->zaurusStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 596 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
597 | status.setText ( message + QString::number ( ++procCount ) ); | 597 | status.setText ( message + QString::number ( ++procCount ) ); |
598 | qApp->processEvents(); | 598 | qApp->processEvents(); |
599 | QString eString = getTodoString( to ); | 599 | QString eString = getTodoString( to ); |
600 | if ( to->zaurusStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 600 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
601 | // deleting empty strings does not work. | 601 | // deleting empty strings does not work. |
602 | // we write first and x and then delete the record with the x | 602 | // we write first and x and then delete the record with the x |
603 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); | 603 | eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); |
604 | changeString += eString + "\n"; | 604 | changeString += eString + "\n"; |
605 | deleteString += eString + "\n"; | 605 | deleteString += eString + "\n"; |
606 | deleteEnt = true; | 606 | deleteEnt = true; |
607 | changeEnt = true; | 607 | changeEnt = true; |
608 | } | 608 | } |
609 | else if ( to->zaurusId() == -1 ) { // add new | 609 | else if ( to->zaurusId() == -1 ) { // add new |
610 | command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; | 610 | command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName; |
611 | system ( command.utf8() ); | 611 | system ( command.utf8() ); |
612 | QFile file( fileName ); | 612 | QFile file( fileName ); |
613 | if (!file.open( IO_ReadOnly ) ) { | 613 | if (!file.open( IO_ReadOnly ) ) { |
614 | return false; | 614 | return false; |
615 | 615 | ||
616 | } | 616 | } |
617 | QTextStream ts( &file ); | 617 | QTextStream ts( &file ); |
618 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 618 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
619 | answer = ts.read(); | 619 | answer = ts.read(); |
620 | file.close(); | 620 | file.close(); |
621 | //qDebug("answer \n%s ", answer.latin1()); | 621 | //qDebug("answer \n%s ", answer.latin1()); |
622 | getNumFromRecord( answer, to ) ; | 622 | getNumFromRecord( answer, to ) ; |
623 | 623 | ||
624 | } | 624 | } |
625 | else { // change existing | 625 | else { // change existing |
626 | //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); | 626 | //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); |
627 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; | 627 | //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; |
628 | changeString += eString + "\n"; | 628 | changeString += eString + "\n"; |
629 | changeEnt = true; | 629 | changeEnt = true; |
630 | 630 | ||
631 | } | 631 | } |
632 | } | 632 | } |
633 | 633 | ||
634 | to = tl.next(); | 634 | to = tl.next(); |
635 | } | 635 | } |
636 | status.setText ( i18n("Changing todos ...") ); | 636 | status.setText ( i18n("Changing todos ...") ); |
637 | qApp->processEvents(); | 637 | qApp->processEvents(); |
638 | //qDebug("changing... "); | 638 | //qDebug("changing... "); |
639 | if ( changeEnt ) { | 639 | if ( changeEnt ) { |
640 | QFile file( fileName ); | 640 | QFile file( fileName ); |
641 | if (!file.open( IO_WriteOnly ) ) { | 641 | if (!file.open( IO_WriteOnly ) ) { |
642 | return false; | 642 | return false; |
643 | 643 | ||
644 | } | 644 | } |
645 | QTextStream ts( &file ); | 645 | QTextStream ts( &file ); |
646 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 646 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
647 | ts << changeString ; | 647 | ts << changeString ; |
648 | file.close(); | 648 | file.close(); |
649 | command = "db2file todo -w -g -c " + codec+ " < "+ fileName; | 649 | command = "db2file todo -w -g -c " + codec+ " < "+ fileName; |
650 | system ( command.latin1() ); | 650 | system ( command.latin1() ); |
651 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); | 651 | //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); |
652 | 652 | ||
653 | } | 653 | } |
654 | status.setText ( i18n("Deleting todos ...") ); | 654 | status.setText ( i18n("Deleting todos ...") ); |
655 | qApp->processEvents(); | 655 | qApp->processEvents(); |
656 | //qDebug("deleting... "); | 656 | //qDebug("deleting... "); |
657 | if ( deleteEnt ) { | 657 | if ( deleteEnt ) { |
658 | QFile file( fileName ); | 658 | QFile file( fileName ); |
659 | if (!file.open( IO_WriteOnly ) ) { | 659 | if (!file.open( IO_WriteOnly ) ) { |
660 | return false; | 660 | return false; |
661 | 661 | ||
662 | } | 662 | } |
663 | QTextStream ts( &file ); | 663 | QTextStream ts( &file ); |
664 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 664 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
665 | ts << deleteString; | 665 | ts << deleteString; |
666 | file.close(); | 666 | file.close(); |
667 | command = "db2file todo -d -c " + codec+ " < "+ fileName; | 667 | command = "db2file todo -d -c " + codec+ " < "+ fileName; |
668 | system ( command.latin1() ); | 668 | system ( command.latin1() ); |
669 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); | 669 | // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); |
670 | } | 670 | } |
671 | 671 | ||
672 | return true; | 672 | return true; |
673 | } | 673 | } |
674 | QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) | 674 | QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) |
675 | { | 675 | { |
676 | QString datestr; | 676 | QString datestr; |
677 | QString timestr; | 677 | QString timestr; |
678 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 678 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
679 | QDateTime dt; | 679 | QDateTime dt; |
680 | if (useTZ) | 680 | if (useTZ) |
681 | dt = dti.addSecs ( -(offset*60)); | 681 | dt = dti.addSecs ( -(offset*60)); |
682 | else | 682 | else |
683 | dt = dti; | 683 | dt = dti; |
684 | if(dt.date().isValid()){ | 684 | if(dt.date().isValid()){ |
685 | const QDate& date = dt.date(); | 685 | const QDate& date = dt.date(); |
686 | datestr.sprintf("%04d%02d%02d", | 686 | datestr.sprintf("%04d%02d%02d", |
687 | date.year(), date.month(), date.day()); | 687 | date.year(), date.month(), date.day()); |
688 | } | 688 | } |
689 | if(dt.time().isValid()){ | 689 | if(dt.time().isValid()){ |
690 | const QTime& time = dt.time(); | 690 | const QTime& time = dt.time(); |
691 | timestr.sprintf("T%02d%02d%02d", | 691 | timestr.sprintf("T%02d%02d%02d", |
692 | time.hour(), time.minute(), time.second()); | 692 | time.hour(), time.minute(), time.second()); |
693 | } | 693 | } |
694 | return datestr + timestr; | 694 | return datestr + timestr; |
695 | } | 695 | } |
696 | QString SharpFormat::getEventString( Event* event ) | 696 | QString SharpFormat::getEventString( Event* event ) |
697 | { | 697 | { |
698 | QStringList list; | 698 | QStringList list; |
699 | list.append( QString::number(event->zaurusId() ) ); | 699 | list.append( QString::number(event->zaurusId() ) ); |
700 | list.append( event->categories().join(",") ); | 700 | list.append( event->categories().join(",") ); |
701 | if ( !event->summary().isEmpty() ) | 701 | if ( !event->summary().isEmpty() ) |
702 | list.append( event->summary() ); | 702 | list.append( event->summary() ); |
703 | else | 703 | else |
704 | list.append("" ); | 704 | list.append("" ); |
705 | if ( !event->location().isEmpty() ) | 705 | if ( !event->location().isEmpty() ) |
706 | list.append( event->location() ); | 706 | list.append( event->location() ); |
707 | else | 707 | else |
708 | list.append("" ); | 708 | list.append("" ); |
709 | if ( !event->description().isEmpty() ) | 709 | if ( !event->description().isEmpty() ) |
710 | list.append( event->description() ); | 710 | list.append( event->description() ); |
711 | else | 711 | else |
712 | list.append( "" ); | 712 | list.append( "" ); |
713 | if ( event->doesFloat () ) { | 713 | if ( event->doesFloat () ) { |
714 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); | 714 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); |
715 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 | 715 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 |
716 | list.append( "1" ); | 716 | list.append( "1" ); |
717 | 717 | ||
718 | } | 718 | } |
719 | else { | 719 | else { |
720 | list.append( dtToString( event->dtStart()) ); | 720 | list.append( dtToString( event->dtStart()) ); |
721 | list.append( dtToString( event->dtEnd()) ); //6 | 721 | list.append( dtToString( event->dtEnd()) ); //6 |
722 | list.append( "0" ); | 722 | list.append( "0" ); |
723 | } | 723 | } |
724 | bool noAlarm = true; | 724 | bool noAlarm = true; |
725 | if ( event->alarms().count() > 0 ) { | 725 | if ( event->alarms().count() > 0 ) { |
726 | Alarm * al = event->alarms().first(); | 726 | Alarm * al = event->alarms().first(); |
727 | if ( al->enabled() ) { | 727 | if ( al->enabled() ) { |
728 | noAlarm = false; | 728 | noAlarm = false; |
729 | list.append( "0" ); // yes, 0 == alarm | 729 | list.append( "0" ); // yes, 0 == alarm |
730 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); | 730 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); |
731 | if ( al->type() == Alarm::Audio ) | 731 | if ( al->type() == Alarm::Audio ) |
732 | list.append( "1" ); // type audio | 732 | list.append( "1" ); // type audio |
733 | else | 733 | else |
734 | list.append( "0" ); // type silent | 734 | list.append( "0" ); // type silent |
735 | } | 735 | } |
736 | } | 736 | } |
737 | if ( noAlarm ) { | 737 | if ( noAlarm ) { |
738 | list.append( "1" ); // yes, 1 == no alarm | 738 | list.append( "1" ); // yes, 1 == no alarm |
739 | list.append( "0" ); // no alarm offset | 739 | list.append( "0" ); // no alarm offset |
740 | list.append( "1" ); // type | 740 | list.append( "1" ); // type |
741 | } | 741 | } |
742 | // next is: 11 | 742 | // next is: 11 |
743 | // next is: 11-16 are recurrence | 743 | // next is: 11-16 are recurrence |
744 | Recurrence* rec = event->recurrence(); | 744 | Recurrence* rec = event->recurrence(); |
745 | 745 | ||
746 | bool writeEndDate = false; | 746 | bool writeEndDate = false; |
747 | switch ( rec->doesRecur() ) | 747 | switch ( rec->doesRecur() ) |
748 | { | 748 | { |
749 | case Recurrence::rDaily: // 0 | 749 | case Recurrence::rDaily: // 0 |
750 | list.append( "0" ); | 750 | list.append( "0" ); |
751 | list.append( QString::number( rec->frequency() ));//12 | 751 | list.append( QString::number( rec->frequency() ));//12 |
752 | list.append( "0" ); | 752 | list.append( "0" ); |
753 | list.append( "0" ); | 753 | list.append( "0" ); |
754 | writeEndDate = true; | 754 | writeEndDate = true; |
755 | break; | 755 | break; |
756 | case Recurrence::rWeekly:// 1 | 756 | case Recurrence::rWeekly:// 1 |
757 | list.append( "1" ); | 757 | list.append( "1" ); |
758 | list.append( QString::number( rec->frequency()) );//12 | 758 | list.append( QString::number( rec->frequency()) );//12 |
759 | list.append( "0" ); | 759 | list.append( "0" ); |
760 | { | 760 | { |
761 | int days = 0; | 761 | int days = 0; |
762 | QBitArray weekDays = rec->days(); | 762 | QBitArray weekDays = rec->days(); |
763 | int i; | 763 | int i; |
764 | for( i = 1; i <= 7; ++i ) { | 764 | for( i = 1; i <= 7; ++i ) { |
765 | if ( weekDays[i-1] ) { | 765 | if ( weekDays[i-1] ) { |
766 | days += 1 << (i-1); | 766 | days += 1 << (i-1); |
767 | } | 767 | } |
768 | } | 768 | } |
769 | list.append( QString::number( days ) ); | 769 | list.append( QString::number( days ) ); |
770 | } | 770 | } |
771 | //pending weekdays | 771 | //pending weekdays |
772 | writeEndDate = true; | 772 | writeEndDate = true; |
773 | 773 | ||
774 | break; | 774 | break; |
775 | case Recurrence::rMonthlyPos:// 2 | 775 | case Recurrence::rMonthlyPos:// 2 |
776 | list.append( "2" ); | 776 | list.append( "2" ); |
777 | list.append( QString::number( rec->frequency()) );//12 | 777 | list.append( QString::number( rec->frequency()) );//12 |
778 | 778 | ||
779 | writeEndDate = true; | 779 | writeEndDate = true; |
780 | { | 780 | { |
781 | int count = 1; | 781 | int count = 1; |
782 | QPtrList<Recurrence::rMonthPos> rmp; | 782 | QPtrList<Recurrence::rMonthPos> rmp; |
783 | rmp = rec->monthPositions(); | 783 | rmp = rec->monthPositions(); |
784 | if ( rmp.first()->negative ) | 784 | if ( rmp.first()->negative ) |
785 | count = 5 - rmp.first()->rPos - 1; | 785 | count = 5 - rmp.first()->rPos - 1; |
786 | else | 786 | else |
787 | count = rmp.first()->rPos - 1; | 787 | count = rmp.first()->rPos - 1; |
788 | list.append( QString::number( count ) ); | 788 | list.append( QString::number( count ) ); |
789 | 789 | ||
790 | } | 790 | } |
791 | 791 | ||
792 | list.append( "0" ); | 792 | list.append( "0" ); |
793 | break; | 793 | break; |
794 | case Recurrence::rMonthlyDay:// 3 | 794 | case Recurrence::rMonthlyDay:// 3 |
795 | list.append( "3" ); | 795 | list.append( "3" ); |
796 | list.append( QString::number( rec->frequency()) );//12 | 796 | list.append( QString::number( rec->frequency()) );//12 |
797 | list.append( "0" ); | 797 | list.append( "0" ); |
798 | list.append( "0" ); | 798 | list.append( "0" ); |
799 | writeEndDate = true; | 799 | writeEndDate = true; |
800 | break; | 800 | break; |
801 | case Recurrence::rYearlyMonth://4 | 801 | case Recurrence::rYearlyMonth://4 |
802 | list.append( "4" ); | 802 | list.append( "4" ); |
803 | list.append( QString::number( rec->frequency()) );//12 | 803 | list.append( QString::number( rec->frequency()) );//12 |
804 | list.append( "0" ); | 804 | list.append( "0" ); |
805 | list.append( "0" ); | 805 | list.append( "0" ); |
806 | writeEndDate = true; | 806 | writeEndDate = true; |
807 | break; | 807 | break; |
808 | 808 | ||
809 | default: | 809 | default: |
810 | list.append( "255" ); | 810 | list.append( "255" ); |
811 | list.append( QString() ); | 811 | list.append( QString() ); |
812 | list.append( "0" ); | 812 | list.append( "0" ); |
813 | list.append( QString() ); | 813 | list.append( QString() ); |
814 | list.append( "0" ); | 814 | list.append( "0" ); |
815 | list.append( "20991231T000000" ); | 815 | list.append( "20991231T000000" ); |
816 | break; | 816 | break; |
817 | } | 817 | } |
818 | if ( writeEndDate ) { | 818 | if ( writeEndDate ) { |
819 | 819 | ||
820 | if ( rec->endDate().isValid() ) { // 15 + 16 | 820 | if ( rec->endDate().isValid() ) { // 15 + 16 |
821 | list.append( "1" ); | 821 | list.append( "1" ); |
822 | list.append( dtToString( rec->endDate()) ); | 822 | list.append( dtToString( rec->endDate()) ); |
823 | } else { | 823 | } else { |
824 | list.append( "0" ); | 824 | list.append( "0" ); |
825 | list.append( "20991231T000000" ); | 825 | list.append( "20991231T000000" ); |
826 | } | 826 | } |
827 | 827 | ||
828 | } | 828 | } |
829 | if ( event->doesFloat () ) { | 829 | if ( event->doesFloat () ) { |
830 | list.append( dtToString( event->dtStart(), false ).left( 8 )); | 830 | list.append( dtToString( event->dtStart(), false ).left( 8 )); |
831 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 | 831 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 |
832 | 832 | ||
833 | } | 833 | } |
834 | else { | 834 | else { |
835 | list.append( QString() ); | 835 | list.append( QString() ); |
836 | list.append( QString() ); | 836 | list.append( QString() ); |
837 | 837 | ||
838 | } | 838 | } |
839 | if (event->dtStart().date() == event->dtEnd().date() ) | 839 | if (event->dtStart().date() == event->dtEnd().date() ) |
840 | list.append( "0" ); | 840 | list.append( "0" ); |
841 | else | 841 | else |
842 | list.append( "1" ); | 842 | list.append( "1" ); |
843 | 843 | ||
844 | 844 | ||
845 | for(QStringList::Iterator it=list.begin(); | 845 | for(QStringList::Iterator it=list.begin(); |
846 | it!=list.end(); ++it){ | 846 | it!=list.end(); ++it){ |
847 | QString& s = (*it); | 847 | QString& s = (*it); |
848 | s.replace(QRegExp("\""), "\"\""); | 848 | s.replace(QRegExp("\""), "\"\""); |
849 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 849 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
850 | s.prepend('\"'); | 850 | s.prepend('\"'); |
851 | s.append('\"'); | 851 | s.append('\"'); |
852 | } else if(s.isEmpty() && !s.isNull()){ | 852 | } else if(s.isEmpty() && !s.isNull()){ |
853 | s = "\"\""; | 853 | s = "\"\""; |
854 | } | 854 | } |
855 | } | 855 | } |
856 | return list.join(","); | 856 | return list.join(","); |
857 | 857 | ||
858 | 858 | ||
859 | } | 859 | } |
860 | QString SharpFormat::getTodoString( Todo* todo ) | 860 | QString SharpFormat::getTodoString( Todo* todo ) |
861 | { | 861 | { |
862 | QStringList list; | 862 | QStringList list; |
863 | list.append( QString::number( todo->zaurusId() ) ); | 863 | list.append( QString::number( todo->zaurusId() ) ); |
864 | list.append( todo->categories().join(",") ); | 864 | list.append( todo->categories().join(",") ); |
865 | 865 | ||
866 | if ( todo->hasStartDate() ) { | 866 | if ( todo->hasStartDate() ) { |
867 | list.append( dtToString( todo->dtStart()) ); | 867 | list.append( dtToString( todo->dtStart()) ); |
868 | } else | 868 | } else |
869 | list.append( QString() ); | 869 | list.append( QString() ); |
870 | 870 | ||
871 | if ( todo->hasDueDate() ) { | 871 | if ( todo->hasDueDate() ) { |
872 | QTime tim; | 872 | QTime tim; |
873 | if ( todo->doesFloat()) { | 873 | if ( todo->doesFloat()) { |
874 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; | 874 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; |
875 | } else { | 875 | } else { |
876 | list.append( dtToString(todo->dtDue() ) ); | 876 | list.append( dtToString(todo->dtDue() ) ); |
877 | } | 877 | } |
878 | } else | 878 | } else |
879 | list.append( QString() ); | 879 | list.append( QString() ); |
880 | 880 | ||
881 | if ( todo->isCompleted() ) { | 881 | if ( todo->isCompleted() ) { |
882 | list.append( dtToString( todo->completed()) ); | 882 | list.append( dtToString( todo->completed()) ); |
883 | list.append( "0" ); // yes 0 == completed | 883 | list.append( "0" ); // yes 0 == completed |
884 | } else { | 884 | } else { |
885 | list.append( dtToString( todo->completed()) ); | 885 | list.append( dtToString( todo->completed()) ); |
886 | list.append( "1" ); | 886 | list.append( "1" ); |
887 | } | 887 | } |
888 | list.append( QString::number( todo->priority() )); | 888 | list.append( QString::number( todo->priority() )); |
889 | if( ! todo->summary().isEmpty() ) | 889 | if( ! todo->summary().isEmpty() ) |
890 | list.append( todo->summary() ); | 890 | list.append( todo->summary() ); |
891 | else | 891 | else |
892 | list.append( "" ); | 892 | list.append( "" ); |
893 | if (! todo->description().isEmpty() ) | 893 | if (! todo->description().isEmpty() ) |
894 | list.append( todo->description() ); | 894 | list.append( todo->description() ); |
895 | else | 895 | else |
896 | list.append( "" ); | 896 | list.append( "" ); |
897 | for(QStringList::Iterator it=list.begin(); | 897 | for(QStringList::Iterator it=list.begin(); |
898 | it!=list.end(); ++it){ | 898 | it!=list.end(); ++it){ |
899 | QString& s = (*it); | 899 | QString& s = (*it); |
900 | s.replace(QRegExp("\""), "\"\""); | 900 | s.replace(QRegExp("\""), "\"\""); |
901 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 901 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
902 | s.prepend('\"'); | 902 | s.prepend('\"'); |
903 | s.append('\"'); | 903 | s.append('\"'); |
904 | } else if(s.isEmpty() && !s.isNull()){ | 904 | } else if(s.isEmpty() && !s.isNull()){ |
905 | s = "\"\""; | 905 | s = "\"\""; |
906 | } | 906 | } |
907 | } | 907 | } |
908 | return list.join(","); | 908 | return list.join(","); |
909 | } | 909 | } |
910 | QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) | 910 | QString SharpFormat::getPart( const QString & text, bool &ok, int &start ) |
911 | { | 911 | { |
912 | //qDebug("start %d ", start); | 912 | //qDebug("start %d ", start); |
913 | 913 | ||
914 | QString retval =""; | 914 | QString retval =""; |
915 | if ( text.at(start) == '"' ) { | 915 | if ( text.at(start) == '"' ) { |
916 | if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { | 916 | if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) { |
917 | start = start +2; | 917 | start = start +2; |
918 | if ( text.mid( start,1) == "," ) { | 918 | if ( text.mid( start,1) == "," ) { |
919 | start += 1; | 919 | start += 1; |
920 | } | 920 | } |
921 | retval = ""; | 921 | retval = ""; |
922 | if ( text.mid( start,1) == "\n" ) { | 922 | if ( text.mid( start,1) == "\n" ) { |
923 | start += 1; | 923 | start += 1; |
924 | ok = false; | 924 | ok = false; |
925 | } | 925 | } |
926 | return retval; | 926 | return retval; |
927 | } | 927 | } |
928 | int hk = start+1; | 928 | int hk = start+1; |
929 | hk = text.find ('"',hk); | 929 | hk = text.find ('"',hk); |
930 | while ( text.at(hk+1) == '"' ) | 930 | while ( text.at(hk+1) == '"' ) |
931 | hk = text.find ('"',hk+2); | 931 | hk = text.find ('"',hk+2); |
932 | retval = text.mid( start+1, hk-start-1); | 932 | retval = text.mid( start+1, hk-start-1); |
933 | start = hk+1; | 933 | start = hk+1; |
934 | retval.replace( QRegExp("\"\""), "\""); | 934 | retval.replace( QRegExp("\"\""), "\""); |
935 | if ( text.mid( start,1) == "," ) { | 935 | if ( text.mid( start,1) == "," ) { |
936 | start += 1; | 936 | start += 1; |
937 | } | 937 | } |
938 | if ( text.mid( start,1) == "\n" ) { | 938 | if ( text.mid( start,1) == "\n" ) { |
939 | start += 1; | 939 | start += 1; |
940 | ok = false; | 940 | ok = false; |
941 | } | 941 | } |
942 | //qDebug("retval***%s*** ",retval.latin1() ); | 942 | //qDebug("retval***%s*** ",retval.latin1() ); |
943 | return retval; | 943 | return retval; |
944 | 944 | ||
945 | } else { | 945 | } else { |
946 | int nl = text.find ("\n",start); | 946 | int nl = text.find ("\n",start); |
947 | int kom = text.find (',',start); | 947 | int kom = text.find (',',start); |
948 | if ( kom < nl ) { | 948 | if ( kom < nl ) { |
949 | // qDebug("kom < nl %d ", kom); | 949 | // qDebug("kom < nl %d ", kom); |
950 | retval = text.mid(start, kom-start); | 950 | retval = text.mid(start, kom-start); |
951 | start = kom+1; | 951 | start = kom+1; |
952 | return retval; | 952 | return retval; |
953 | } else { | 953 | } else { |
954 | if ( nl == kom ) { | 954 | if ( nl == kom ) { |
955 | // qDebug(" nl == kom "); | 955 | // qDebug(" nl == kom "); |
956 | start = 0; | 956 | start = 0; |
957 | ok = false; | 957 | ok = false; |
958 | return "0"; | 958 | return "0"; |
959 | } | 959 | } |
960 | // qDebug(" nl < kom ", nl); | 960 | // qDebug(" nl < kom ", nl); |
961 | retval = text.mid( start, nl-start); | 961 | retval = text.mid( start, nl-start); |
962 | ok = false; | 962 | ok = false; |
963 | start = nl+1; | 963 | start = nl+1; |
964 | return retval; | 964 | return retval; |
965 | } | 965 | } |
966 | } | 966 | } |
967 | } | 967 | } |
968 | bool SharpFormat::fromString( Calendar *calendar, const QString & text) | 968 | bool SharpFormat::fromString( Calendar *calendar, const QString & text) |
969 | { | 969 | { |
970 | return false; | 970 | return false; |
971 | } | 971 | } |
972 | bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) | 972 | bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, const QString & text, const QString & type) |
973 | { | 973 | { |
974 | // qDebug("test %s ", text.latin1()); | 974 | // qDebug("test %s ", text.latin1()); |
975 | QStringList templist; | 975 | QStringList templist; |
976 | QString tempString; | 976 | QString tempString; |
977 | int start = 0; | 977 | int start = 0; |
978 | int len = text.length(); | 978 | int len = text.length(); |
979 | int end = text.find ("\n",start)+1; | 979 | int end = text.find ("\n",start)+1; |
980 | bool ok = true; | 980 | bool ok = true; |
981 | start = end; | 981 | start = end; |
982 | SharpParser handler( calendar ); | 982 | SharpParser handler( calendar ); |
983 | handler.setCategoriesList( mCategories ); | 983 | handler.setCategoriesList( mCategories ); |
984 | while ( start > 0 ) { | 984 | while ( start > 0 ) { |
985 | templist.clear(); | 985 | templist.clear(); |
986 | ok = true; | 986 | ok = true; |
987 | while ( ok ) { | 987 | while ( ok ) { |
988 | tempString = getPart( text, ok, start ); | 988 | tempString = getPart( text, ok, start ); |
989 | if ( start >= len || start == 0 ) { | 989 | if ( start >= len || start == 0 ) { |
990 | start = 0; | 990 | start = 0; |
991 | ok = false; | 991 | ok = false; |
992 | } | 992 | } |
993 | if ( tempString.right(1) =="\n" ) | 993 | if ( tempString.right(1) =="\n" ) |
994 | tempString = tempString.left( tempString.length()-1); | 994 | tempString = tempString.left( tempString.length()-1); |
995 | //if ( ok ) | 995 | //if ( ok ) |
996 | templist.append( tempString ); | 996 | templist.append( tempString ); |
997 | //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); | 997 | //qDebug("%d ---%s---", templist.count(),tempString.latin1() ); |
998 | } | 998 | } |
999 | handler.startElement( existingCalendar, templist, type ); | 999 | handler.startElement( existingCalendar, templist, type ); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | return false; | 1002 | return false; |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | QString SharpFormat::toString( Calendar * ) | 1005 | QString SharpFormat::toString( Calendar * ) |
1006 | { | 1006 | { |
1007 | return QString::null; | 1007 | return QString::null; |
1008 | } | 1008 | } |