author | zautrix <zautrix> | 2004-10-17 18:08:43 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-17 18:08:43 (UTC) |
commit | 6f6d1d58938539215bb4fcb5b97cf9fb089a11ef (patch) (unidiff) | |
tree | 9937fe24c3fa3f29421b39a58b393e893a11636a | |
parent | d92f58ffa1937af8a4240b9d235da15f5f352769 (diff) | |
download | kdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.zip kdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.tar.gz kdepimpi-6f6d1d58938539215bb4fcb5b97cf9fb089a11ef.tar.bz2 |
more KDE sync fixes
-rw-r--r-- | kde2file/caldump/main.cpp | 38 | ||||
-rw-r--r-- | korganizer/calendarview.cpp | 29 | ||||
-rw-r--r-- | korganizer/calendarview.h | 1 | ||||
-rw-r--r-- | libkcal/calendar.cpp | 8 | ||||
-rw-r--r-- | libkcal/calendar.h | 2 |
5 files changed, 42 insertions, 36 deletions
diff --git a/kde2file/caldump/main.cpp b/kde2file/caldump/main.cpp index 755e792..be1735b 100644 --- a/kde2file/caldump/main.cpp +++ b/kde2file/caldump/main.cpp | |||
@@ -1,255 +1,253 @@ | |||
1 | /******************************************************************************* | 1 | /******************************************************************************* |
2 | * main.cpp * | 2 | * main.cpp * |
3 | * * | 3 | * * |
4 | * | 4 | * |
5 | * * | 5 | * * |
6 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program is free software; you can redistribute it and/or modify * |
7 | * it under the terms of the GNU General Public License as published by * | 7 | * it under the terms of the GNU General Public License as published by * |
8 | * the Free Software Foundation; either version 2 of the License, or * | 8 | * the Free Software Foundation; either version 2 of the License, or * |
9 | * (at your option) any later version. * | 9 | * (at your option) any later version. * |
10 | * * | 10 | * * |
11 | * This program is distributed in the hope that it will be useful, * | 11 | * This program 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 * | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
14 | * GNU General Public License for more details. * | 14 | * GNU General Public License for more details. * |
15 | * * | 15 | * * |
16 | * You should have received a copy of the GNU General Public License * | 16 | * You should have received a copy of the GNU General Public License * |
17 | * along with this program; if not, write to the Free Software * | 17 | * along with this program; if not, write to the Free Software * |
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * | 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
19 | * * | 19 | * * |
20 | * As a special exception, permission is given to link this program * | 20 | * As a special exception, permission is given to link this program * |
21 | * with any edition of Qt, and distribute the resulting executable, * | 21 | * with any edition of Qt, and distribute the resulting executable, * |
22 | * without including the source code for Qt in the source distribution. * | 22 | * without including the source code for Qt in the source distribution. * |
23 | * * | 23 | * * |
24 | ******************************************************************************/ | 24 | ******************************************************************************/ |
25 | 25 | ||
26 | #ifdef HAVE_CONFIG_H | 26 | #ifdef HAVE_CONFIG_H |
27 | #include "config.h" | 27 | #include "config.h" |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #if TIME_WITH_SYS_TIME | 30 | #if TIME_WITH_SYS_TIME |
31 | # include <sys/time.h> | 31 | # include <sys/time.h> |
32 | # include <time.h> | 32 | # include <time.h> |
33 | #else | 33 | #else |
34 | # if HAVE_SYS_TIME_H | 34 | # if HAVE_SYS_TIME_H |
35 | # include <sys/time.h> | 35 | # include <sys/time.h> |
36 | # else | 36 | # else |
37 | # include <time.h> | 37 | # include <time.h> |
38 | # endif | 38 | # endif |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #include <kcmdlineargs.h> | 41 | #include <kcmdlineargs.h> |
42 | #include <kaboutdata.h> | 42 | #include <kaboutdata.h> |
43 | #include <klocale.h> | 43 | #include <klocale.h> |
44 | #include <kglobal.h> | 44 | #include <kglobal.h> |
45 | #include <kconfig.h> | 45 | #include <kconfig.h> |
46 | #include <kstandarddirs.h> | 46 | #include <kstandarddirs.h> |
47 | #include <kdebug.h> | 47 | #include <kdebug.h> |
48 | 48 | ||
49 | #include <libkcal/calformat.h> | 49 | #include <libkcal/calformat.h> |
50 | #include <libkcal/calendarresources.h> | 50 | #include <libkcal/calendarresources.h> |
51 | #include <libkcal/resourcelocal.h> | 51 | #include <libkcal/resourcelocal.h> |
52 | #include <libkcal/filestorage.h> | 52 | #include <libkcal/filestorage.h> |
53 | #include <libkcal/icalformat.h> | 53 | #include <libkcal/icalformat.h> |
54 | 54 | ||
55 | #include <qdatetime.h> | 55 | #include <qdatetime.h> |
56 | #include <qfile.h> | 56 | #include <qfile.h> |
57 | #include <qdir.h> | 57 | #include <qdir.h> |
58 | #include <qapplication.h> | ||
58 | 59 | ||
59 | #include <stdlib.h> | 60 | #include <stdlib.h> |
60 | #include <iostream> | 61 | #include <iostream> |
61 | 62 | ||
62 | using namespace KCal; | 63 | using namespace KCal; |
63 | using namespace std; | 64 | using namespace std; |
64 | 65 | ||
65 | static const char progName[] = "kdecalendar"; | 66 | static const char progName[] = "kdecalendar"; |
66 | static const char progDisplay[] = "KDE_Calendar"; | 67 | static const char progDisplay[] = "KDE_Calendar"; |
67 | static const char progVersion[] = "33.1/3"; | 68 | static const char progVersion[] = "33.1/3"; |
68 | static const char progDesc[] = "A command line interface to KDE calendars"; | 69 | static const char progDesc[] = "A command line interface to KDE calendars"; |
69 | 70 | ||
70 | 71 | ||
71 | static KCmdLineOptions options[] = | 72 | static KCmdLineOptions options[] = |
72 | { | 73 | { |
73 | { "dump", | 74 | { "dump", |
74 | I18N_NOOP( "Dumps calendar" ), 0 }, | 75 | I18N_NOOP( "Dumps calendar" ), 0 }, |
75 | { "read", | 76 | { "read", |
76 | I18N_NOOP( "Reads calendar" ), 0 }, | 77 | I18N_NOOP( "Reads calendar" ), 0 }, |
77 | KCmdLineLastOption | 78 | KCmdLineLastOption |
78 | }; | 79 | }; |
79 | 80 | ||
80 | int main( int argc, char *argv[] ) | 81 | int main( int argc, char *argv[] ) |
81 | { | 82 | { |
82 | KAboutData aboutData( | 83 | KAboutData aboutData( |
83 | progName, // internal program name | 84 | progName, // internal program name |
84 | I18N_NOOP( progDisplay ), // displayable program name. | 85 | I18N_NOOP( progDisplay ), // displayable program name. |
85 | progVersion, // version string | 86 | progVersion, // version string |
86 | I18N_NOOP( progDesc ), // short porgram description | 87 | I18N_NOOP( progDesc ), // short porgram description |
87 | KAboutData::License_GPL, // license type | 88 | KAboutData::License_GPL, // license type |
88 | "(c) 2004, Lutz Rogowski", // copyright statement | 89 | "(c) 2004, Lutz Rogowski", // copyright statement |
89 | 0, // any free form text | 90 | 0, // any free form text |
90 | "", // program home page address | 91 | "", // program home page address |
91 | "bugs.kde.org" // bug report email address | 92 | "bugs.kde.org" // bug report email address |
92 | ); | 93 | ); |
93 | 94 | ||
94 | 95 | ||
95 | // KCmdLineArgs::init() final 'true' argument indicates no commandline options | 96 | // KCmdLineArgs::init() final 'true' argument indicates no commandline options |
96 | // for QApplication/KApplication (no KDE or Qt options) | 97 | // for QApplication/KApplication (no KDE or Qt options) |
97 | KCmdLineArgs::init( argc, argv, &aboutData, true ); | 98 | KCmdLineArgs::init( argc, argv, &aboutData, true ); |
98 | KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. | 99 | KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. |
99 | 100 | ||
100 | KInstance ins ( progName ); | 101 | KInstance ins ( progName ); |
101 | 102 | ||
102 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); | 103 | KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); |
103 | 104 | ||
104 | bool read = false; | 105 | bool read = false; |
105 | if ( args->isSet( "read" ) ) { | 106 | if ( args->isSet( "read" ) ) { |
106 | read = true; | 107 | read = true; |
107 | qDebug("read "); | 108 | qDebug("read "); |
108 | } | 109 | } |
109 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; | 110 | QString fileName = QDir::homeDirPath ()+"/.kdecalendardump.ics"; |
110 | CalendarResources *calendarResource = 0; | 111 | CalendarResources *calendarResource = 0; |
111 | CalendarLocal *localCalendar = 0; | 112 | CalendarLocal *localCalendar = 0; |
112 | KConfig c( locate( "config", "korganizerrc" ) ); | 113 | KConfig c( locate( "config", "korganizerrc" ) ); |
113 | c.setGroup( "Time & Date" ); | 114 | c.setGroup( "Time & Date" ); |
114 | QString tz = c.readEntry( "TimeZoneId" ); | 115 | QString tz = c.readEntry( "TimeZoneId" ); |
115 | calendarResource = new CalendarResources( tz ); | 116 | calendarResource = new CalendarResources( tz ); |
116 | calendarResource->readConfig(); | 117 | calendarResource->readConfig(); |
117 | calendarResource->load(); | 118 | calendarResource->load(); |
118 | qDebug("************************************* "); | 119 | qDebug("************************************* "); |
119 | qDebug("**************kdecaldump************* "); | 120 | qDebug("**************kdecaldump************* "); |
120 | qDebug("************************************* "); | 121 | qDebug("************************************* "); |
121 | qDebug("Using timezone ID: %s", calendarResource->timeZoneId().latin1()); | 122 | qDebug("Using timezone ID: %s", calendarResource->timeZoneId().latin1()); |
122 | 123 | ||
123 | if ( !read ) { | 124 | if ( !read ) { |
124 | localCalendar = new CalendarLocal(); | 125 | localCalendar = new CalendarLocal(); |
125 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); | 126 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); |
126 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); | 127 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); |
127 | Incidence::List::ConstIterator it; | 128 | Incidence::List::ConstIterator it; |
128 | int num = 0; | 129 | int num = 0; |
129 | for( it = allInc.begin(); it != allInc.end(); ++it ) { | 130 | for( it = allInc.begin(); it != allInc.end(); ++it ) { |
130 | ResourceCalendar * re = calendarResource->resource( (*it) ); | 131 | ResourceCalendar * re = calendarResource->resource( (*it) ); |
131 | if ( re && !re->readOnly() ) { | 132 | if ( re && !re->readOnly() ) { |
132 | ++num; | 133 | ++num; |
133 | Incidence* cl = (*it)->clone(); | 134 | Incidence* cl = (*it)->clone(); |
134 | cl->setLastModified( (*it)->lastModified() ); | 135 | cl->setLastModified( (*it)->lastModified() ); |
135 | if ( cl->type() == "Journal" ) | 136 | if ( cl->type() == "Journal" ) |
136 | localCalendar->addJournal( (Journal *) cl ); | 137 | localCalendar->addJournal( (Journal *) cl ); |
137 | else if ( cl->type() == "Todo" ) | 138 | else if ( cl->type() == "Todo" ) |
138 | localCalendar->addTodo( (Todo *) cl ); | 139 | localCalendar->addTodo( (Todo *) cl ); |
139 | else if ( cl->type() == "Event" ) | 140 | else if ( cl->type() == "Event" ) |
140 | localCalendar->addEvent( (Event *) cl ); | 141 | localCalendar->addEvent( (Event *) cl ); |
141 | } | 142 | } |
142 | } | 143 | } |
143 | 144 | ||
144 | FileStorage* storage = new FileStorage( calendarResource ); | 145 | FileStorage* storage = new FileStorage( calendarResource ); |
145 | storage->setFileName( fileName ); | 146 | storage->setFileName( fileName ); |
146 | storage->setSaveFormat( new ICalFormat() ); | 147 | storage->setSaveFormat( new ICalFormat() ); |
147 | storage->save(); | 148 | storage->save(); |
148 | delete storage; | 149 | delete storage; |
149 | qDebug("************************************* "); | 150 | qDebug("************************************* "); |
150 | qDebug("************kdecaldump*************** "); | 151 | qDebug("************kdecaldump*************** "); |
151 | qDebug("************************************* "); | 152 | qDebug("************************************* "); |
152 | qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); | 153 | qDebug("%d calendar entries dumped to file %s", num, fileName.latin1()); |
153 | 154 | ||
154 | } else { | 155 | } else { |
155 | qDebug("*************************load"); | 156 | qDebug("************load"); |
156 | localCalendar = new CalendarLocal(); | 157 | localCalendar = new CalendarLocal(); |
157 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); | 158 | localCalendar->setTimeZoneId( calendarResource->timeZoneId()); |
158 | FileStorage* storage = new FileStorage( localCalendar ); | 159 | FileStorage* storage = new FileStorage( localCalendar ); |
159 | storage->setFileName( fileName ); | 160 | storage->setFileName( fileName ); |
160 | int num = 0; | 161 | int num = 0; |
161 | int del = 0; | 162 | int del = 0; |
162 | int add = 0; | 163 | int add = 0; |
163 | if ( storage->load() ) { | 164 | if ( storage->load() ) { |
164 | qDebug("*************************loaded!"); | 165 | qDebug("***********loaded!"); |
165 | KCal::Incidence::List newInc = localCalendar->rawIncidences(); | 166 | KCal::Incidence::List newInc = localCalendar->rawIncidences(); |
166 | Incidence::List::ConstIterator it; | 167 | Incidence::List::ConstIterator it; |
167 | for( it = newInc.begin(); it != newInc.end(); ++it ) { | 168 | for( it = newInc.begin(); it != newInc.end(); ++it ) { |
168 | if ( (*it)->pilotId() > 0 ) { //changed | 169 | if ( (*it)->pilotId() > 1 ) { //changed |
169 | Incidence* cl = (*it)->clone(); | 170 | qDebug("*********pilot id %d %s ",(*it)->pilotId() ,(*it)->summary().latin1()); |
170 | Incidence *incOld = calendarResource->incidence( cl->uid() ); | 171 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); |
171 | ResourceCalendar * res = 0; | 172 | ResourceCalendar * res = 0; |
172 | if ( incOld ) | 173 | if ( incOld ) |
173 | res = calendarResource->resource( incOld ); | 174 | res = calendarResource->resource( incOld ); |
174 | if ( res ) { | 175 | if ( res ) { |
176 | Incidence* cl = (*it)->clone(); | ||
175 | cl->setPilotId( incOld->pilotId() ); | 177 | cl->setPilotId( incOld->pilotId() ); |
176 | ++num; | 178 | ++num; |
177 | if ( incOld->type() == "Journal" ) | 179 | if ( incOld->type() == "Journal" ) |
178 | calendarResource->deleteJournal( (Journal *) incOld ); | 180 | calendarResource->deleteJournal( (Journal *) incOld ); |
179 | else if ( incOld->type() == "Todo" ) | 181 | else if ( incOld->type() == "Todo" ) |
180 | calendarResource->deleteTodo( (Todo *) incOld ); | 182 | calendarResource->deleteTodo( (Todo *) incOld ); |
181 | else if ( incOld->type() == "Event" ) | 183 | else if ( incOld->type() == "Event" ) |
182 | calendarResource->deleteEvent( (Event *) incOld ); | 184 | calendarResource->deleteEvent( (Event *) incOld ); |
183 | 185 | qDebug("*********change incidence %s ",cl->summary().latin1()); | |
184 | if ( cl->type() == "Journal" ) | 186 | if ( cl->type() == "Journal" ) |
185 | calendarResource->addJournal( (Journal *) cl, res ); | 187 | calendarResource->addJournal( (Journal *) cl, res ); |
186 | else if ( cl->type() == "Todo" ) | 188 | else if ( cl->type() == "Todo" ) |
187 | calendarResource->addTodo( (Todo *) cl, res ); | 189 | calendarResource->addTodo( (Todo *) cl, res ); |
188 | else if ( cl->type() == "Event" ) | 190 | else if ( cl->type() == "Event" ) |
189 | calendarResource->addEvent( (Event *) cl, res ); | 191 | calendarResource->addEvent( (Event *) cl, res ); |
190 | 192 | ||
191 | } else { | 193 | } else { |
192 | if ( incOld ) { | 194 | Incidence* cl = (*it)->clone(); |
193 | qDebug("ERROR: no resource found for old incidence "); | 195 | qDebug("*********add incidence %s ",cl->summary().latin1()); |
194 | if ( incOld->type() == "Journal" ) | 196 | calendarResource->addIncidence( cl ); |
195 | calendarResource->deleteJournal( (Journal *) incOld ); | 197 | ++add; |
196 | else if ( incOld->type() == "Todo" ) | 198 | } |
197 | calendarResource->deleteTodo( (Todo *) incOld ); | 199 | } else { // maybe added |
198 | else if ( incOld->type() == "Event" ) | 200 | Incidence *incOld = calendarResource->incidence( (*it)->uid() ); |
199 | calendarResource->deleteEvent( (Event *) incOld ); | 201 | if ( !incOld ) { //added |
200 | 202 | Incidence* cl = (*it)->clone(); | |
201 | } | 203 | qDebug("*********add incidence %s ",cl->summary().latin1()); |
202 | calendarResource->addIncidence( cl ); | 204 | calendarResource->addIncidence( cl ); |
203 | ++add; | 205 | ++add; |
204 | } | 206 | } |
205 | } else { // added | ||
206 | Incidence* cl = (*it)->clone(); | ||
207 | calendarResource->addIncidence( cl ); | ||
208 | ++add; | ||
209 | } | 207 | } |
210 | } | 208 | } |
211 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); | 209 | KCal::Incidence::List allInc = calendarResource->rawIncidences(); |
212 | 210 | ||
213 | for( it = allInc.begin(); it != allInc.end(); ++it ) { | 211 | for( it = allInc.begin(); it != allInc.end(); ++it ) { |
214 | ResourceCalendar * re = calendarResource->resource( (*it) ); | 212 | ResourceCalendar * re = calendarResource->resource( (*it) ); |
215 | if ( re && !re->readOnly() ) { | 213 | if ( re && !re->readOnly() ) { |
216 | Incidence* cl = localCalendar->incidence( (*it)->uid() ); | 214 | Incidence* cl = localCalendar->incidence( (*it)->uid() ); |
217 | if ( !cl ) { | 215 | if ( !cl ) { |
218 | ++del; | 216 | ++del; |
219 | cl = (*it); | 217 | cl = (*it); |
220 | if ( cl->type() == "Journal" ) | 218 | if ( cl->type() == "Journal" ) |
221 | calendarResource->deleteJournal( (Journal *) cl ); | 219 | calendarResource->deleteJournal( (Journal *) cl ); |
222 | else if ( cl->type() == "Todo" ) | 220 | else if ( cl->type() == "Todo" ) |
223 | calendarResource->deleteTodo( (Todo *) cl ); | 221 | calendarResource->deleteTodo( (Todo *) cl ); |
224 | else if ( cl->type() == "Event" ) | 222 | else if ( cl->type() == "Event" ) |
225 | calendarResource->deleteEvent( (Event *) cl ); | 223 | calendarResource->deleteEvent( (Event *) cl ); |
226 | //QDateTime lm = cl->lastModified(); | 224 | //QDateTime lm = cl->lastModified(); |
227 | //cl->setResources( (*it)->resources() ); | 225 | //cl->setResources( (*it)->resources() ); |
228 | //cl->setLastModified(lm); | 226 | //cl->setLastModified(lm); |
229 | } | 227 | } |
230 | } | 228 | } |
231 | } | 229 | } |
232 | 230 | ||
233 | calendarResource->save(); | 231 | calendarResource->save(); |
234 | qDebug("************************************* "); | 232 | qDebug("************************************* "); |
235 | qDebug("************kdecaldump*************** "); | 233 | qDebug("************kdecaldump*************** "); |
236 | qDebug("************************************* "); | 234 | qDebug("************************************* "); |
237 | qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1()); | 235 | qDebug("Calendar entries\nchanged %d\ndeleted %d\nadded %d\nfrom file %s", num,del, add, fileName.latin1()); |
238 | 236 | ||
239 | } else | 237 | } else |
240 | qDebug("ERROR loading file %s",fileName.latin1() ); | 238 | qDebug("ERROR loading file %s",fileName.latin1() ); |
241 | 239 | ||
242 | } | 240 | } |
243 | 241 | ||
244 | if ( localCalendar ) { | 242 | if ( localCalendar ) { |
245 | localCalendar->close(); | 243 | localCalendar->close(); |
246 | delete localCalendar; | 244 | delete localCalendar; |
247 | } | 245 | } |
248 | if ( calendarResource ) { | 246 | if ( calendarResource ) { |
249 | calendarResource->close(); | 247 | calendarResource->close(); |
250 | delete calendarResource; | 248 | delete calendarResource; |
251 | } | 249 | } |
252 | 250 | ||
253 | qDebug("ente "); | 251 | qDebug("ente "); |
254 | return 0; | 252 | return 0; |
255 | } | 253 | } |
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index f727cd4..ff1db2c 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -568,810 +568,811 @@ void CalendarView::computeAlarm( QString msg ) | |||
568 | execl ( tempfilename.latin1(), 0 ); | 568 | execl ( tempfilename.latin1(), 0 ); |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | #else | 571 | #else |
572 | QProcess* p = new QProcess(); | 572 | QProcess* p = new QProcess(); |
573 | p->addArgument( tempfilename.latin1() ); | 573 | p->addArgument( tempfilename.latin1() ); |
574 | p->start(); | 574 | p->start(); |
575 | return; | 575 | return; |
576 | #endif | 576 | #endif |
577 | 577 | ||
578 | return; | 578 | return; |
579 | } | 579 | } |
580 | 580 | ||
581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 581 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
582 | } | 582 | } |
583 | if ( mess.left( 11 ) == "audio_alarm") { | 583 | if ( mess.left( 11 ) == "audio_alarm") { |
584 | bool error = false; | 584 | bool error = false; |
585 | int len = mess.mid( 11 ).find("+++"); | 585 | int len = mess.mid( 11 ).find("+++"); |
586 | if ( len < 2 ) | 586 | if ( len < 2 ) |
587 | error = true; | 587 | error = true; |
588 | else { | 588 | else { |
589 | tempfilename = mess.mid( 11, len ); | 589 | tempfilename = mess.mid( 11, len ); |
590 | if ( !QFile::exists( tempfilename ) ) | 590 | if ( !QFile::exists( tempfilename ) ) |
591 | error = true; | 591 | error = true; |
592 | } | 592 | } |
593 | if ( ! error ) { | 593 | if ( ! error ) { |
594 | filename = tempfilename; | 594 | filename = tempfilename; |
595 | } | 595 | } |
596 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 596 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
597 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 597 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
598 | } | 598 | } |
599 | if ( mess.left( 9 ) == "cal_alarm") { | 599 | if ( mess.left( 9 ) == "cal_alarm") { |
600 | mAlarmMessage = mess.mid( 9 ) ; | 600 | mAlarmMessage = mess.mid( 9 ) ; |
601 | } | 601 | } |
602 | 602 | ||
603 | startAlarm( mAlarmMessage, filename ); | 603 | startAlarm( mAlarmMessage, filename ); |
604 | 604 | ||
605 | 605 | ||
606 | } | 606 | } |
607 | 607 | ||
608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 608 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
609 | { | 609 | { |
610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 610 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
611 | 611 | ||
612 | mSuspendAlarmNotification = noti; | 612 | mSuspendAlarmNotification = noti; |
613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 613 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 614 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
615 | mSuspendTimer->start( ms , true ); | 615 | mSuspendTimer->start( ms , true ); |
616 | 616 | ||
617 | } | 617 | } |
618 | 618 | ||
619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 619 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
620 | { | 620 | { |
621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 621 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 622 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
623 | #ifndef DESKTOP_VERSION | 623 | #ifndef DESKTOP_VERSION |
624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 624 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); |
625 | #endif | 625 | #endif |
626 | return; | 626 | return; |
627 | } | 627 | } |
628 | int maxSec; | 628 | int maxSec; |
629 | //maxSec = 5; //testing only | 629 | //maxSec = 5; //testing only |
630 | maxSec = 86400+3600; // one day+1hour | 630 | maxSec = 86400+3600; // one day+1hour |
631 | mAlarmNotification = noti; | 631 | mAlarmNotification = noti; |
632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 632 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
633 | if ( sec > maxSec ) { | 633 | if ( sec > maxSec ) { |
634 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 634 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 635 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
636 | return; | 636 | return; |
637 | } else { | 637 | } else { |
638 | mRecheckAlarmTimer->stop(); | 638 | mRecheckAlarmTimer->stop(); |
639 | } | 639 | } |
640 | //qDebug("Alarm timer started with secs: %d ", sec); | 640 | //qDebug("Alarm timer started with secs: %d ", sec); |
641 | mAlarmTimer->start( sec *1000 , true ); | 641 | mAlarmTimer->start( sec *1000 , true ); |
642 | 642 | ||
643 | } | 643 | } |
644 | // called by mRecheckAlarmTimer to get next alarm | 644 | // called by mRecheckAlarmTimer to get next alarm |
645 | // we need this, because a QTimer has only a max range of 25 days | 645 | // we need this, because a QTimer has only a max range of 25 days |
646 | void CalendarView::recheckTimerAlarm() | 646 | void CalendarView::recheckTimerAlarm() |
647 | { | 647 | { |
648 | mAlarmTimer->stop(); | 648 | mAlarmTimer->stop(); |
649 | mRecheckAlarmTimer->stop(); | 649 | mRecheckAlarmTimer->stop(); |
650 | mCalendar->checkAlarmForIncidence( 0, true ); | 650 | mCalendar->checkAlarmForIncidence( 0, true ); |
651 | } | 651 | } |
652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 652 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
653 | { | 653 | { |
654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 654 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 655 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
656 | #ifndef DESKTOP_VERSION | 656 | #ifndef DESKTOP_VERSION |
657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 657 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
658 | #endif | 658 | #endif |
659 | return; | 659 | return; |
660 | } | 660 | } |
661 | mAlarmTimer->stop(); | 661 | mAlarmTimer->stop(); |
662 | } | 662 | } |
663 | void CalendarView::selectWeekNum ( int num ) | 663 | void CalendarView::selectWeekNum ( int num ) |
664 | { | 664 | { |
665 | dateNavigator()->selectWeek( num ); | 665 | dateNavigator()->selectWeek( num ); |
666 | mViewManager->showWeekView(); | 666 | mViewManager->showWeekView(); |
667 | } | 667 | } |
668 | KOViewManager *CalendarView::viewManager() | 668 | KOViewManager *CalendarView::viewManager() |
669 | { | 669 | { |
670 | return mViewManager; | 670 | return mViewManager; |
671 | } | 671 | } |
672 | 672 | ||
673 | KODialogManager *CalendarView::dialogManager() | 673 | KODialogManager *CalendarView::dialogManager() |
674 | { | 674 | { |
675 | return mDialogManager; | 675 | return mDialogManager; |
676 | } | 676 | } |
677 | 677 | ||
678 | QDate CalendarView::startDate() | 678 | QDate CalendarView::startDate() |
679 | { | 679 | { |
680 | DateList dates = mNavigator->selectedDates(); | 680 | DateList dates = mNavigator->selectedDates(); |
681 | 681 | ||
682 | return dates.first(); | 682 | return dates.first(); |
683 | } | 683 | } |
684 | 684 | ||
685 | QDate CalendarView::endDate() | 685 | QDate CalendarView::endDate() |
686 | { | 686 | { |
687 | DateList dates = mNavigator->selectedDates(); | 687 | DateList dates = mNavigator->selectedDates(); |
688 | 688 | ||
689 | return dates.last(); | 689 | return dates.last(); |
690 | } | 690 | } |
691 | 691 | ||
692 | 692 | ||
693 | void CalendarView::createPrinter() | 693 | void CalendarView::createPrinter() |
694 | { | 694 | { |
695 | #ifndef KORG_NOPRINTER | 695 | #ifndef KORG_NOPRINTER |
696 | if (!mCalPrinter) { | 696 | if (!mCalPrinter) { |
697 | mCalPrinter = new CalPrinter(this, mCalendar); | 697 | mCalPrinter = new CalPrinter(this, mCalendar); |
698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 698 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
699 | } | 699 | } |
700 | #endif | 700 | #endif |
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 | QDateTime localMod = local->lastModified(); | 728 | QDateTime localMod = local->lastModified(); |
729 | QDateTime remoteMod = remote->lastModified(); | 729 | QDateTime remoteMod = remote->lastModified(); |
730 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 730 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
731 | bool remCh, locCh; | 731 | bool remCh, locCh; |
732 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 732 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
733 | //if ( remCh ) | 733 | //if ( remCh ) |
734 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 734 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
735 | locCh = ( localMod > mLastCalendarSync ); | 735 | locCh = ( localMod > mLastCalendarSync ); |
736 | if ( !remCh && ! locCh ) { | 736 | if ( !remCh && ! locCh ) { |
737 | //qDebug("both not changed "); | 737 | //qDebug("both not changed "); |
738 | lastSync = localMod.addDays(1); | 738 | lastSync = localMod.addDays(1); |
739 | if ( mode <= SYNC_PREF_ASK ) | 739 | if ( mode <= SYNC_PREF_ASK ) |
740 | return 0; | 740 | return 0; |
741 | } else { | 741 | } else { |
742 | if ( locCh ) { | 742 | if ( locCh ) { |
743 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 743 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
744 | lastSync = localMod.addDays( -1 ); | 744 | lastSync = localMod.addDays( -1 ); |
745 | if ( !remCh ) | 745 | if ( !remCh ) |
746 | remoteMod = ( lastSync.addDays( -1 ) ); | 746 | remoteMod = ( lastSync.addDays( -1 ) ); |
747 | } else { | 747 | } else { |
748 | //qDebug(" not loc changed "); | 748 | //qDebug(" not loc changed "); |
749 | lastSync = localMod.addDays( 1 ); | 749 | lastSync = localMod.addDays( 1 ); |
750 | if ( remCh ) | 750 | if ( remCh ) |
751 | remoteMod =( lastSync.addDays( 1 ) ); | 751 | remoteMod =( lastSync.addDays( 1 ) ); |
752 | 752 | ||
753 | } | 753 | } |
754 | } | 754 | } |
755 | full = true; | 755 | full = true; |
756 | if ( mode < SYNC_PREF_ASK ) | 756 | if ( mode < SYNC_PREF_ASK ) |
757 | mode = SYNC_PREF_ASK; | 757 | mode = SYNC_PREF_ASK; |
758 | } else { | 758 | } else { |
759 | if ( localMod == remoteMod ) | 759 | if ( localMod == remoteMod ) |
760 | if ( local->revision() == remote->revision() ) | 760 | // if ( local->revision() == remote->revision() ) |
761 | return 0; | 761 | return 0; |
762 | 762 | ||
763 | } | 763 | } |
764 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 764 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
765 | 765 | ||
766 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 766 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
767 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 767 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
768 | //full = true; //debug only | 768 | //full = true; //debug only |
769 | if ( full ) { | 769 | if ( full ) { |
770 | bool equ = false; | 770 | bool equ = false; |
771 | if ( local->type() == "Event" ) { | 771 | if ( local->type() == "Event" ) { |
772 | equ = (*((Event*) local) == *((Event*) remote)); | 772 | equ = (*((Event*) local) == *((Event*) remote)); |
773 | } | 773 | } |
774 | else if ( local->type() =="Todo" ) | 774 | else if ( local->type() =="Todo" ) |
775 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 775 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
776 | else if ( local->type() =="Journal" ) | 776 | else if ( local->type() =="Journal" ) |
777 | equ = (*((Journal*) local) == *((Journal*) remote)); | 777 | equ = (*((Journal*) local) == *((Journal*) remote)); |
778 | if ( equ ) { | 778 | if ( equ ) { |
779 | //qDebug("equal "); | 779 | //qDebug("equal "); |
780 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 780 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
781 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 781 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
782 | } | 782 | } |
783 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 783 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
784 | return 0; | 784 | return 0; |
785 | 785 | ||
786 | }//else //debug only | 786 | }//else //debug only |
787 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 787 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
788 | } | 788 | } |
789 | int result; | 789 | int result; |
790 | bool localIsNew; | 790 | bool localIsNew; |
791 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); | 791 | //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); |
792 | 792 | ||
793 | if ( full && mode < SYNC_PREF_NEWEST ) | 793 | if ( full && mode < SYNC_PREF_NEWEST ) |
794 | mode = SYNC_PREF_ASK; | 794 | mode = SYNC_PREF_ASK; |
795 | 795 | ||
796 | switch( mode ) { | 796 | switch( mode ) { |
797 | case SYNC_PREF_LOCAL: | 797 | case SYNC_PREF_LOCAL: |
798 | if ( lastSync > remoteMod ) | 798 | if ( lastSync > remoteMod ) |
799 | return 1; | 799 | return 1; |
800 | if ( lastSync > localMod ) | 800 | if ( lastSync > localMod ) |
801 | return 2; | 801 | return 2; |
802 | return 1; | 802 | return 1; |
803 | break; | 803 | break; |
804 | case SYNC_PREF_REMOTE: | 804 | case SYNC_PREF_REMOTE: |
805 | if ( lastSync > remoteMod ) | 805 | if ( lastSync > remoteMod ) |
806 | return 1; | 806 | return 1; |
807 | if ( lastSync > localMod ) | 807 | if ( lastSync > localMod ) |
808 | return 2; | 808 | return 2; |
809 | return 2; | 809 | return 2; |
810 | break; | 810 | break; |
811 | case SYNC_PREF_NEWEST: | 811 | case SYNC_PREF_NEWEST: |
812 | if ( localMod > remoteMod ) | 812 | if ( localMod > remoteMod ) |
813 | return 1; | 813 | return 1; |
814 | else | 814 | else |
815 | return 2; | 815 | return 2; |
816 | break; | 816 | break; |
817 | case SYNC_PREF_ASK: | 817 | case SYNC_PREF_ASK: |
818 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 818 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
819 | if ( lastSync > remoteMod ) | 819 | if ( lastSync > remoteMod ) |
820 | return 1; | 820 | return 1; |
821 | if ( lastSync > localMod ) | 821 | if ( lastSync > localMod ) |
822 | return 2; | 822 | return 2; |
823 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 823 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
824 | localIsNew = localMod >= remoteMod; | 824 | localIsNew = localMod >= remoteMod; |
825 | if ( localIsNew ) | 825 | if ( localIsNew ) |
826 | getEventViewerDialog()->setColorMode( 1 ); | 826 | getEventViewerDialog()->setColorMode( 1 ); |
827 | else | 827 | else |
828 | getEventViewerDialog()->setColorMode( 2 ); | 828 | getEventViewerDialog()->setColorMode( 2 ); |
829 | getEventViewerDialog()->setIncidence(local); | 829 | getEventViewerDialog()->setIncidence(local); |
830 | if ( localIsNew ) | 830 | if ( localIsNew ) |
831 | getEventViewerDialog()->setColorMode( 2 ); | 831 | getEventViewerDialog()->setColorMode( 2 ); |
832 | else | 832 | else |
833 | getEventViewerDialog()->setColorMode( 1 ); | 833 | getEventViewerDialog()->setColorMode( 1 ); |
834 | getEventViewerDialog()->addIncidence(remote); | 834 | getEventViewerDialog()->addIncidence(remote); |
835 | getEventViewerDialog()->setColorMode( 0 ); | 835 | getEventViewerDialog()->setColorMode( 0 ); |
836 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 836 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
837 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 837 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
838 | getEventViewerDialog()->showMe(); | 838 | getEventViewerDialog()->showMe(); |
839 | result = getEventViewerDialog()->executeS( localIsNew ); | 839 | result = getEventViewerDialog()->executeS( localIsNew ); |
840 | return result; | 840 | return result; |
841 | 841 | ||
842 | break; | 842 | break; |
843 | case SYNC_PREF_FORCE_LOCAL: | 843 | case SYNC_PREF_FORCE_LOCAL: |
844 | return 1; | 844 | return 1; |
845 | break; | 845 | break; |
846 | case SYNC_PREF_FORCE_REMOTE: | 846 | case SYNC_PREF_FORCE_REMOTE: |
847 | return 2; | 847 | return 2; |
848 | break; | 848 | break; |
849 | 849 | ||
850 | default: | 850 | default: |
851 | // SYNC_PREF_TAKE_BOTH not implemented | 851 | // SYNC_PREF_TAKE_BOTH not implemented |
852 | break; | 852 | break; |
853 | } | 853 | } |
854 | return 0; | 854 | return 0; |
855 | } | 855 | } |
856 | Event* CalendarView::getLastSyncEvent() | 856 | Event* CalendarView::getLastSyncEvent() |
857 | { | 857 | { |
858 | Event* lse; | 858 | Event* lse; |
859 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 859 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
860 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 860 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
861 | if (!lse) { | 861 | if (!lse) { |
862 | lse = new Event(); | 862 | lse = new Event(); |
863 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 863 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
864 | QString sum = ""; | 864 | QString sum = ""; |
865 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 865 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
866 | sum = "E: "; | 866 | sum = "E: "; |
867 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 867 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
868 | lse->setDtStart( mLastCalendarSync ); | 868 | lse->setDtStart( mLastCalendarSync ); |
869 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 869 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
870 | lse->setCategories( i18n("SyncEvent") ); | 870 | lse->setCategories( i18n("SyncEvent") ); |
871 | lse->setReadOnly( true ); | 871 | lse->setReadOnly( true ); |
872 | mCalendar->addEvent( lse ); | 872 | mCalendar->addEvent( lse ); |
873 | } | 873 | } |
874 | 874 | ||
875 | return lse; | 875 | return lse; |
876 | 876 | ||
877 | } | 877 | } |
878 | 878 | ||
879 | // we check, if the to delete event has a id for a profile | 879 | // we check, if the to delete event has a id for a profile |
880 | // if yes, we set this id in the profile to delete | 880 | // if yes, we set this id in the profile to delete |
881 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 881 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
882 | { | 882 | { |
883 | if ( lastSync.count() == 0 ) { | 883 | if ( lastSync.count() == 0 ) { |
884 | //qDebug(" lastSync.count() == 0"); | 884 | //qDebug(" lastSync.count() == 0"); |
885 | return; | 885 | return; |
886 | } | 886 | } |
887 | if ( toDelete->type() == "Journal" ) | 887 | if ( toDelete->type() == "Journal" ) |
888 | return; | 888 | return; |
889 | 889 | ||
890 | Event* eve = lastSync.first(); | 890 | Event* eve = lastSync.first(); |
891 | 891 | ||
892 | while ( eve ) { | 892 | while ( eve ) { |
893 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 893 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
894 | if ( !id.isEmpty() ) { | 894 | if ( !id.isEmpty() ) { |
895 | QString des = eve->description(); | 895 | QString des = eve->description(); |
896 | QString pref = "e"; | 896 | QString pref = "e"; |
897 | if ( toDelete->type() == "Todo" ) | 897 | if ( toDelete->type() == "Todo" ) |
898 | pref = "t"; | 898 | pref = "t"; |
899 | des += pref+ id + ","; | 899 | des += pref+ id + ","; |
900 | eve->setReadOnly( false ); | 900 | eve->setReadOnly( false ); |
901 | eve->setDescription( des ); | 901 | eve->setDescription( des ); |
902 | //qDebug("setdes %s ", des.latin1()); | 902 | //qDebug("setdes %s ", des.latin1()); |
903 | eve->setReadOnly( true ); | 903 | eve->setReadOnly( true ); |
904 | } | 904 | } |
905 | eve = lastSync.next(); | 905 | eve = lastSync.next(); |
906 | } | 906 | } |
907 | 907 | ||
908 | } | 908 | } |
909 | void CalendarView::checkExternalId( Incidence * inc ) | 909 | void CalendarView::checkExternalId( Incidence * inc ) |
910 | { | 910 | { |
911 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 911 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
912 | checkExternSyncEvent( lastSync, inc ); | 912 | checkExternSyncEvent( lastSync, inc ); |
913 | 913 | ||
914 | } | 914 | } |
915 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 915 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
916 | { | 916 | { |
917 | bool syncOK = true; | 917 | bool syncOK = true; |
918 | int addedEvent = 0; | 918 | int addedEvent = 0; |
919 | int addedEventR = 0; | 919 | int addedEventR = 0; |
920 | int deletedEventR = 0; | 920 | int deletedEventR = 0; |
921 | int deletedEventL = 0; | 921 | int deletedEventL = 0; |
922 | int changedLocal = 0; | 922 | int changedLocal = 0; |
923 | int changedRemote = 0; | 923 | int changedRemote = 0; |
924 | //QPtrList<Event> el = local->rawEvents(); | 924 | //QPtrList<Event> el = local->rawEvents(); |
925 | Event* eventR; | 925 | Event* eventR; |
926 | QString uid; | 926 | QString uid; |
927 | int take; | 927 | int take; |
928 | Event* eventL; | 928 | Event* eventL; |
929 | Event* eventRSync; | 929 | Event* eventRSync; |
930 | Event* eventLSync; | 930 | Event* eventLSync; |
931 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 931 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
932 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 932 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
933 | bool fullDateRange = false; | 933 | bool fullDateRange = false; |
934 | local->resetTempSyncStat(); | 934 | local->resetTempSyncStat(); |
935 | #ifdef DESKTOP_VERSION | 935 | if ( mSyncKDE ) |
936 | //Needed for KDE - OL sync | 936 | remote->resetPilotStat(1); |
937 | local->resetPilotStat(); | ||
938 | remote->resetPilotStat(); | ||
939 | #endif | ||
940 | mLastCalendarSync = QDateTime::currentDateTime(); | 937 | mLastCalendarSync = QDateTime::currentDateTime(); |
941 | QDateTime modifiedCalendar = mLastCalendarSync;; | 938 | QDateTime modifiedCalendar = mLastCalendarSync;; |
942 | eventLSync = getLastSyncEvent(); | 939 | eventLSync = getLastSyncEvent(); |
943 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 940 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
944 | if ( eventR ) { | 941 | if ( eventR ) { |
945 | eventRSync = (Event*) eventR->clone(); | 942 | eventRSync = (Event*) eventR->clone(); |
946 | remote->deleteEvent(eventR ); | 943 | remote->deleteEvent(eventR ); |
947 | 944 | ||
948 | } else { | 945 | } else { |
949 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 946 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
950 | eventRSync = (Event*)eventLSync->clone(); | 947 | eventRSync = (Event*)eventLSync->clone(); |
951 | } else { | 948 | } else { |
952 | fullDateRange = true; | 949 | fullDateRange = true; |
953 | eventRSync = new Event(); | 950 | eventRSync = new Event(); |
954 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 951 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
955 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 952 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
956 | eventRSync->setDtStart( mLastCalendarSync ); | 953 | eventRSync->setDtStart( mLastCalendarSync ); |
957 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 954 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
958 | eventRSync->setCategories( i18n("SyncEvent") ); | 955 | eventRSync->setCategories( i18n("SyncEvent") ); |
959 | } | 956 | } |
960 | } | 957 | } |
961 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 958 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
962 | fullDateRange = true; | 959 | fullDateRange = true; |
963 | 960 | ||
964 | if ( ! fullDateRange ) { | 961 | if ( ! fullDateRange ) { |
965 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 962 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
966 | 963 | ||
967 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 964 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
968 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 965 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
969 | fullDateRange = true; | 966 | fullDateRange = true; |
970 | } | 967 | } |
971 | } | 968 | } |
972 | if ( fullDateRange ) | 969 | if ( fullDateRange && !mSyncKDE ) |
973 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 970 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
974 | else | 971 | else |
975 | mLastCalendarSync = eventLSync->dtStart(); | 972 | mLastCalendarSync = eventLSync->dtStart(); |
976 | // for resyncing if own file has changed | 973 | // for resyncing if own file has changed |
977 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 974 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
978 | mLastCalendarSync = loadedFileVersion; | 975 | mLastCalendarSync = loadedFileVersion; |
979 | qDebug("setting mLastCalendarSync "); | 976 | qDebug("setting mLastCalendarSync "); |
980 | } | 977 | } |
981 | //qDebug("*************************** "); | 978 | //qDebug("*************************** "); |
982 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); | 979 | qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); |
983 | QPtrList<Incidence> er = remote->rawIncidences(); | 980 | QPtrList<Incidence> er = remote->rawIncidences(); |
984 | Incidence* inR = er.first(); | 981 | Incidence* inR = er.first(); |
985 | Incidence* inL; | 982 | Incidence* inL; |
986 | QProgressBar bar( er.count(),0 ); | 983 | QProgressBar bar( er.count(),0 ); |
987 | bar.setCaption (i18n("Syncing - close to abort!") ); | 984 | bar.setCaption (i18n("Syncing - close to abort!") ); |
988 | 985 | ||
989 | int w = 300; | 986 | int w = 300; |
990 | if ( QApplication::desktop()->width() < 320 ) | 987 | if ( QApplication::desktop()->width() < 320 ) |
991 | w = 220; | 988 | w = 220; |
992 | int h = bar.sizeHint().height() ; | 989 | int h = bar.sizeHint().height() ; |
993 | int dw = QApplication::desktop()->width(); | 990 | int dw = QApplication::desktop()->width(); |
994 | int dh = QApplication::desktop()->height(); | 991 | int dh = QApplication::desktop()->height(); |
995 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 992 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
996 | bar.show(); | 993 | bar.show(); |
997 | int modulo = (er.count()/10)+1; | 994 | int modulo = (er.count()/10)+1; |
998 | int incCounter = 0; | 995 | int incCounter = 0; |
999 | while ( inR ) { | 996 | while ( inR ) { |
1000 | if ( ! bar.isVisible() ) | 997 | if ( ! bar.isVisible() ) |
1001 | return false; | 998 | return false; |
1002 | if ( incCounter % modulo == 0 ) | 999 | if ( incCounter % modulo == 0 ) |
1003 | bar.setProgress( incCounter ); | 1000 | bar.setProgress( incCounter ); |
1004 | ++incCounter; | 1001 | ++incCounter; |
1005 | uid = inR->uid(); | 1002 | uid = inR->uid(); |
1006 | bool skipIncidence = false; | 1003 | bool skipIncidence = false; |
1007 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1004 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1008 | skipIncidence = true; | 1005 | skipIncidence = true; |
1009 | QString idS; | 1006 | QString idS; |
1010 | qApp->processEvents(); | 1007 | qApp->processEvents(); |
1011 | if ( !skipIncidence ) { | 1008 | if ( !skipIncidence ) { |
1012 | inL = local->incidence( uid ); | 1009 | inL = local->incidence( uid ); |
1013 | if ( inL ) { // maybe conflict - same uid in both calendars | 1010 | if ( inL ) { // maybe conflict - same uid in both calendars |
1014 | int maxrev = inL->revision(); | 1011 | int maxrev = inL->revision(); |
1015 | if ( maxrev < inR->revision() ) | 1012 | if ( maxrev < inR->revision() ) |
1016 | maxrev = inR->revision(); | 1013 | maxrev = inR->revision(); |
1017 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1014 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1018 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1015 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1019 | if ( take == 3 ) | 1016 | if ( take == 3 ) |
1020 | return false; | 1017 | return false; |
1021 | if ( take == 1 ) {// take local | 1018 | if ( take == 1 ) {// take local |
1022 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1019 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1023 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1020 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1024 | else | 1021 | else |
1025 | idS = inR->IDStr(); | 1022 | idS = inR->IDStr(); |
1026 | remote->deleteIncidence( inR ); | 1023 | remote->deleteIncidence( inR ); |
1027 | if ( inL->revision() < maxrev ) | 1024 | if ( inL->revision() < maxrev ) |
1028 | inL->setRevision( maxrev ); | 1025 | inL->setRevision( maxrev ); |
1029 | inR = inL->clone(); | 1026 | inR = inL->clone(); |
1030 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1027 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1031 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1028 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1032 | inR->setIDStr( idS ); | 1029 | inR->setIDStr( idS ); |
1033 | remote->addIncidence( inR ); | 1030 | remote->addIncidence( inR ); |
1034 | #ifdef DESKTOP_VERSION | 1031 | if ( mSyncKDE ) |
1035 | inR->setPilotId( 1 ); | 1032 | inR->setPilotId( 2 ); |
1036 | #endif | ||
1037 | ++changedRemote; | 1033 | ++changedRemote; |
1038 | } else { | 1034 | } else { |
1039 | if ( inR->revision() < maxrev ) | 1035 | if ( inR->revision() < maxrev ) |
1040 | inR->setRevision( maxrev ); | 1036 | inR->setRevision( maxrev ); |
1041 | idS = inL->IDStr(); | 1037 | idS = inL->IDStr(); |
1038 | int pid = inL->pilotId(); | ||
1042 | local->deleteIncidence( inL ); | 1039 | local->deleteIncidence( inL ); |
1043 | inL = inR->clone(); | 1040 | inL = inR->clone(); |
1041 | if ( mSyncKDE ) | ||
1042 | inL->setPilotId( pid ); | ||
1044 | inL->setIDStr( idS ); | 1043 | inL->setIDStr( idS ); |
1045 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1044 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1046 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1045 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1047 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1046 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1048 | } | 1047 | } |
1049 | local->addIncidence( inL ); | 1048 | local->addIncidence( inL ); |
1050 | ++changedLocal; | 1049 | ++changedLocal; |
1051 | } | 1050 | } |
1052 | } | 1051 | } |
1053 | } else { // no conflict | 1052 | } else { // no conflict |
1054 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1053 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1055 | QString des = eventLSync->description(); | 1054 | QString des = eventLSync->description(); |
1056 | QString pref = "e"; | 1055 | QString pref = "e"; |
1057 | if ( inR->type() == "Todo" ) | 1056 | if ( inR->type() == "Todo" ) |
1058 | pref = "t"; | 1057 | pref = "t"; |
1059 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1058 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1060 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1059 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1061 | //remote->deleteIncidence( inR ); | 1060 | //remote->deleteIncidence( inR ); |
1062 | ++deletedEventR; | 1061 | ++deletedEventR; |
1063 | } else { | 1062 | } else { |
1064 | inR->setLastModified( modifiedCalendar ); | 1063 | inR->setLastModified( modifiedCalendar ); |
1065 | inL = inR->clone(); | 1064 | inL = inR->clone(); |
1066 | local->addIncidence( inL ); | 1065 | local->addIncidence( inL ); |
1067 | ++addedEvent; | 1066 | ++addedEvent; |
1068 | } | 1067 | } |
1069 | } else { | 1068 | } else { |
1070 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1069 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1071 | inR->setLastModified( modifiedCalendar ); | 1070 | inR->setLastModified( modifiedCalendar ); |
1072 | local->addIncidence( inR->clone() ); | 1071 | local->addIncidence( inR->clone() ); |
1073 | ++addedEvent; | 1072 | ++addedEvent; |
1074 | } else { | 1073 | } else { |
1075 | checkExternSyncEvent(eventRSyncSharp, inR); | 1074 | checkExternSyncEvent(eventRSyncSharp, inR); |
1076 | remote->deleteIncidence( inR ); | 1075 | remote->deleteIncidence( inR ); |
1077 | ++deletedEventR; | 1076 | ++deletedEventR; |
1078 | } | 1077 | } |
1079 | } | 1078 | } |
1080 | } | 1079 | } |
1081 | } | 1080 | } |
1082 | inR = er.next(); | 1081 | inR = er.next(); |
1083 | } | 1082 | } |
1084 | QPtrList<Incidence> el = local->rawIncidences(); | 1083 | QPtrList<Incidence> el = local->rawIncidences(); |
1085 | inL = el.first(); | 1084 | inL = el.first(); |
1086 | modulo = (el.count()/10)+1; | 1085 | modulo = (el.count()/10)+1; |
1087 | bar.setCaption (i18n("Add / remove events") ); | 1086 | bar.setCaption (i18n("Add / remove events") ); |
1088 | bar.setTotalSteps ( el.count() ) ; | 1087 | bar.setTotalSteps ( el.count() ) ; |
1089 | bar.show(); | 1088 | bar.show(); |
1090 | incCounter = 0; | 1089 | incCounter = 0; |
1091 | 1090 | ||
1092 | while ( inL ) { | 1091 | while ( inL ) { |
1093 | 1092 | ||
1094 | qApp->processEvents(); | 1093 | qApp->processEvents(); |
1095 | if ( ! bar.isVisible() ) | 1094 | if ( ! bar.isVisible() ) |
1096 | return false; | 1095 | return false; |
1097 | if ( incCounter % modulo == 0 ) | 1096 | if ( incCounter % modulo == 0 ) |
1098 | bar.setProgress( incCounter ); | 1097 | bar.setProgress( incCounter ); |
1099 | ++incCounter; | 1098 | ++incCounter; |
1100 | uid = inL->uid(); | 1099 | uid = inL->uid(); |
1101 | bool skipIncidence = false; | 1100 | bool skipIncidence = false; |
1102 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1101 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1103 | skipIncidence = true; | 1102 | skipIncidence = true; |
1104 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) | 1103 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) |
1105 | skipIncidence = true; | 1104 | skipIncidence = true; |
1106 | if ( !skipIncidence ) { | 1105 | if ( !skipIncidence ) { |
1107 | inR = remote->incidence( uid ); | 1106 | inR = remote->incidence( uid ); |
1108 | if ( ! inR ) { | 1107 | if ( ! inR ) { |
1109 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1108 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1110 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1109 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1111 | checkExternSyncEvent(eventLSyncSharp, inL); | 1110 | checkExternSyncEvent(eventLSyncSharp, inL); |
1112 | local->deleteIncidence( inL ); | 1111 | local->deleteIncidence( inL ); |
1113 | ++deletedEventL; | 1112 | ++deletedEventL; |
1114 | } else { | 1113 | } else { |
1115 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1114 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1116 | inL->removeID(mCurrentSyncDevice ); | 1115 | inL->removeID(mCurrentSyncDevice ); |
1117 | ++addedEventR; | 1116 | ++addedEventR; |
1118 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1117 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1119 | inL->setLastModified( modifiedCalendar ); | 1118 | inL->setLastModified( modifiedCalendar ); |
1120 | inR = inL->clone(); | 1119 | inR = inL->clone(); |
1121 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1120 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1122 | remote->addIncidence( inR ); | 1121 | remote->addIncidence( inR ); |
1123 | } | 1122 | } |
1124 | } | 1123 | } |
1125 | } else { | 1124 | } else { |
1126 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1125 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1127 | checkExternSyncEvent(eventLSyncSharp, inL); | 1126 | checkExternSyncEvent(eventLSyncSharp, inL); |
1128 | local->deleteIncidence( inL ); | 1127 | local->deleteIncidence( inL ); |
1129 | ++deletedEventL; | 1128 | ++deletedEventL; |
1130 | } else { | 1129 | } else { |
1131 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1130 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1132 | ++addedEventR; | 1131 | ++addedEventR; |
1133 | inL->setLastModified( modifiedCalendar ); | 1132 | inL->setLastModified( modifiedCalendar ); |
1134 | remote->addIncidence( inL->clone() ); | 1133 | remote->addIncidence( inL->clone() ); |
1135 | } | 1134 | } |
1136 | } | 1135 | } |
1137 | } | 1136 | } |
1138 | } | 1137 | } |
1139 | } | 1138 | } |
1140 | inL = el.next(); | 1139 | inL = el.next(); |
1141 | } | 1140 | } |
1142 | int delFut = 0; | 1141 | int delFut = 0; |
1143 | int remRem = 0; | 1142 | int remRem = 0; |
1144 | if ( mSyncManager->mWriteBackInFuture ) { | 1143 | if ( mSyncManager->mWriteBackInFuture ) { |
1145 | er = remote->rawIncidences(); | 1144 | er = remote->rawIncidences(); |
1146 | remRem = er.count(); | 1145 | remRem = er.count(); |
1147 | inR = er.first(); | 1146 | inR = er.first(); |
1148 | QDateTime dt; | 1147 | QDateTime dt; |
1149 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); | 1148 | QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); |
1150 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); | 1149 | QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); |
1151 | while ( inR ) { | 1150 | while ( inR ) { |
1152 | if ( inR->type() == "Todo" ) { | 1151 | if ( inR->type() == "Todo" ) { |
1153 | Todo * t = (Todo*)inR; | 1152 | Todo * t = (Todo*)inR; |
1154 | if ( t->hasDueDate() ) | 1153 | if ( t->hasDueDate() ) |
1155 | dt = t->dtDue(); | 1154 | dt = t->dtDue(); |
1156 | else | 1155 | else |
1157 | dt = cur.addSecs( 62 ); | 1156 | dt = cur.addSecs( 62 ); |
1158 | } | 1157 | } |
1159 | else if (inR->type() == "Event" ) { | 1158 | else if (inR->type() == "Event" ) { |
1160 | bool ok; | 1159 | bool ok; |
1161 | dt = inR->getNextOccurence( cur, &ok ); | 1160 | dt = inR->getNextOccurence( cur, &ok ); |
1162 | if ( !ok ) | 1161 | if ( !ok ) |
1163 | dt = cur.addSecs( -62 ); | 1162 | dt = cur.addSecs( -62 ); |
1164 | } | 1163 | } |
1165 | else | 1164 | else |
1166 | dt = inR->dtStart(); | 1165 | dt = inR->dtStart(); |
1167 | if ( dt < cur || dt > end ) { | 1166 | if ( dt < cur || dt > end ) { |
1168 | remote->deleteIncidence( inR ); | 1167 | remote->deleteIncidence( inR ); |
1169 | ++delFut; | 1168 | ++delFut; |
1170 | } | 1169 | } |
1171 | inR = er.next(); | 1170 | inR = er.next(); |
1172 | } | 1171 | } |
1173 | } | 1172 | } |
1174 | bar.hide(); | 1173 | bar.hide(); |
1175 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1174 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1176 | eventLSync->setReadOnly( false ); | 1175 | eventLSync->setReadOnly( false ); |
1177 | eventLSync->setDtStart( mLastCalendarSync ); | 1176 | eventLSync->setDtStart( mLastCalendarSync ); |
1178 | eventRSync->setDtStart( mLastCalendarSync ); | 1177 | eventRSync->setDtStart( mLastCalendarSync ); |
1179 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1178 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1180 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1179 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1181 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1180 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1182 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1181 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1183 | eventLSync->setReadOnly( true ); | 1182 | eventLSync->setReadOnly( true ); |
1184 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL) | 1183 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... |
1185 | remote->addEvent( eventRSync ); | 1184 | remote->addEvent( eventRSync ); |
1185 | else | ||
1186 | delete eventRSync; | ||
1186 | QString mes; | 1187 | QString mes; |
1187 | 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 ); | 1188 | 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 ); |
1188 | QString delmess; | 1189 | QString delmess; |
1189 | if ( delFut ) { | 1190 | if ( delFut ) { |
1190 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1191 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1191 | mes += delmess; | 1192 | mes += delmess; |
1192 | } | 1193 | } |
1193 | if ( mSyncManager->mShowSyncSummary ) { | 1194 | if ( mSyncManager->mShowSyncSummary ) { |
1194 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); | 1195 | KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); |
1195 | } | 1196 | } |
1196 | qDebug( mes ); | 1197 | qDebug( mes ); |
1197 | mCalendar->checkAlarmForIncidence( 0, true ); | 1198 | mCalendar->checkAlarmForIncidence( 0, true ); |
1198 | return syncOK; | 1199 | return syncOK; |
1199 | } | 1200 | } |
1200 | 1201 | ||
1201 | void CalendarView::setSyncDevice( QString s ) | 1202 | void CalendarView::setSyncDevice( QString s ) |
1202 | { | 1203 | { |
1203 | mCurrentSyncDevice= s; | 1204 | mCurrentSyncDevice= s; |
1204 | } | 1205 | } |
1205 | void CalendarView::setSyncName( QString s ) | 1206 | void CalendarView::setSyncName( QString s ) |
1206 | { | 1207 | { |
1207 | mCurrentSyncName= s; | 1208 | mCurrentSyncName= s; |
1208 | } | 1209 | } |
1209 | bool CalendarView::syncCalendar(QString filename, int mode) | 1210 | bool CalendarView::syncCalendar(QString filename, int mode) |
1210 | { | 1211 | { |
1211 | //qDebug("syncCalendar %s ", filename.latin1()); | 1212 | //qDebug("syncCalendar %s ", filename.latin1()); |
1212 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1213 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1213 | CalendarLocal* calendar = new CalendarLocal(); | 1214 | CalendarLocal* calendar = new CalendarLocal(); |
1214 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1215 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1215 | FileStorage* storage = new FileStorage( calendar ); | 1216 | FileStorage* storage = new FileStorage( calendar ); |
1216 | bool syncOK = false; | 1217 | bool syncOK = false; |
1217 | storage->setFileName( filename ); | 1218 | storage->setFileName( filename ); |
1218 | // qDebug("loading ... "); | 1219 | // qDebug("loading ... "); |
1219 | if ( storage->load() ) { | 1220 | if ( storage->load() ) { |
1220 | getEventViewerDialog()->setSyncMode( true ); | 1221 | getEventViewerDialog()->setSyncMode( true ); |
1221 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1222 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1222 | getEventViewerDialog()->setSyncMode( false ); | 1223 | getEventViewerDialog()->setSyncMode( false ); |
1223 | if ( syncOK ) { | 1224 | if ( syncOK ) { |
1224 | if ( mSyncManager->mWriteBackFile ) | 1225 | if ( mSyncManager->mWriteBackFile ) |
1225 | { | 1226 | { |
1226 | storage->setSaveFormat( new ICalFormat() ); | 1227 | storage->setSaveFormat( new ICalFormat() ); |
1227 | storage->save(); | 1228 | storage->save(); |
1228 | } | 1229 | } |
1229 | } | 1230 | } |
1230 | setModified( true ); | 1231 | setModified( true ); |
1231 | } | 1232 | } |
1232 | delete storage; | 1233 | delete storage; |
1233 | delete calendar; | 1234 | delete calendar; |
1234 | if ( syncOK ) | 1235 | if ( syncOK ) |
1235 | updateView(); | 1236 | updateView(); |
1236 | return syncOK; | 1237 | return syncOK; |
1237 | } | 1238 | } |
1238 | 1239 | ||
1239 | void CalendarView::syncExternal( int mode ) | 1240 | void CalendarView::syncExternal( int mode ) |
1240 | { | 1241 | { |
1241 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1242 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1242 | 1243 | ||
1243 | qApp->processEvents(); | 1244 | qApp->processEvents(); |
1244 | CalendarLocal* calendar = new CalendarLocal(); | 1245 | CalendarLocal* calendar = new CalendarLocal(); |
1245 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); | 1246 | calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); |
1246 | bool syncOK = false; | 1247 | bool syncOK = false; |
1247 | bool loadSuccess = false; | 1248 | bool loadSuccess = false; |
1248 | PhoneFormat* phoneFormat = 0; | 1249 | PhoneFormat* phoneFormat = 0; |
1249 | #ifndef DESKTOP_VERSION | 1250 | #ifndef DESKTOP_VERSION |
1250 | SharpFormat* sharpFormat = 0; | 1251 | SharpFormat* sharpFormat = 0; |
1251 | if ( mode == 0 ) { // sharp | 1252 | if ( mode == 0 ) { // sharp |
1252 | sharpFormat = new SharpFormat () ; | 1253 | sharpFormat = new SharpFormat () ; |
1253 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1254 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1254 | 1255 | ||
1255 | } else | 1256 | } else |
1256 | #endif | 1257 | #endif |
1257 | if ( mode == 1 ) { // phone | 1258 | if ( mode == 1 ) { // phone |
1258 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1259 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1259 | mSyncManager->mPhoneDevice, | 1260 | mSyncManager->mPhoneDevice, |
1260 | mSyncManager->mPhoneConnection, | 1261 | mSyncManager->mPhoneConnection, |
1261 | mSyncManager->mPhoneModel); | 1262 | mSyncManager->mPhoneModel); |
1262 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1263 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1263 | 1264 | ||
1264 | } else | 1265 | } else |
1265 | return; | 1266 | return; |
1266 | if ( loadSuccess ) { | 1267 | if ( loadSuccess ) { |
1267 | getEventViewerDialog()->setSyncMode( true ); | 1268 | getEventViewerDialog()->setSyncMode( true ); |
1268 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1269 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1269 | getEventViewerDialog()->setSyncMode( false ); | 1270 | getEventViewerDialog()->setSyncMode( false ); |
1270 | qApp->processEvents(); | 1271 | qApp->processEvents(); |
1271 | if ( syncOK ) { | 1272 | if ( syncOK ) { |
1272 | if ( mSyncManager->mWriteBackFile ) | 1273 | if ( mSyncManager->mWriteBackFile ) |
1273 | { | 1274 | { |
1274 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1275 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1275 | Incidence* inc = iL.first(); | 1276 | Incidence* inc = iL.first(); |
1276 | if ( phoneFormat ) { | 1277 | if ( phoneFormat ) { |
1277 | while ( inc ) { | 1278 | while ( inc ) { |
1278 | inc->removeID(mCurrentSyncDevice); | 1279 | inc->removeID(mCurrentSyncDevice); |
1279 | inc = iL.next(); | 1280 | inc = iL.next(); |
1280 | } | 1281 | } |
1281 | } | 1282 | } |
1282 | #ifndef DESKTOP_VERSION | 1283 | #ifndef DESKTOP_VERSION |
1283 | if ( sharpFormat ) | 1284 | if ( sharpFormat ) |
1284 | sharpFormat->save(calendar); | 1285 | sharpFormat->save(calendar); |
1285 | #endif | 1286 | #endif |
1286 | if ( phoneFormat ) | 1287 | if ( phoneFormat ) |
1287 | phoneFormat->save(calendar); | 1288 | phoneFormat->save(calendar); |
1288 | iL = calendar->rawIncidences(); | 1289 | iL = calendar->rawIncidences(); |
1289 | inc = iL.first(); | 1290 | inc = iL.first(); |
1290 | Incidence* loc; | 1291 | Incidence* loc; |
1291 | while ( inc ) { | 1292 | while ( inc ) { |
1292 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1293 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1293 | loc = mCalendar->incidence(inc->uid() ); | 1294 | loc = mCalendar->incidence(inc->uid() ); |
1294 | if ( loc ) { | 1295 | if ( loc ) { |
1295 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1296 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1296 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1297 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1297 | } | 1298 | } |
1298 | } | 1299 | } |
1299 | inc = iL.next(); | 1300 | inc = iL.next(); |
1300 | } | 1301 | } |
1301 | Incidence* lse = getLastSyncEvent(); | 1302 | Incidence* lse = getLastSyncEvent(); |
1302 | if ( lse ) { | 1303 | if ( lse ) { |
1303 | lse->setReadOnly( false ); | 1304 | lse->setReadOnly( false ); |
1304 | lse->setDescription( "" ); | 1305 | lse->setDescription( "" ); |
1305 | lse->setReadOnly( true ); | 1306 | lse->setReadOnly( true ); |
1306 | } | 1307 | } |
1307 | } | 1308 | } |
1308 | } | 1309 | } |
1309 | setModified( true ); | 1310 | setModified( true ); |
1310 | } else { | 1311 | } else { |
1311 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1312 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1312 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1313 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1313 | question, i18n("Ok")) ; | 1314 | question, i18n("Ok")) ; |
1314 | 1315 | ||
1315 | } | 1316 | } |
1316 | delete calendar; | 1317 | delete calendar; |
1317 | updateView(); | 1318 | updateView(); |
1318 | return ;//syncOK; | 1319 | return ;//syncOK; |
1319 | 1320 | ||
1320 | } | 1321 | } |
1321 | 1322 | ||
1322 | bool CalendarView::importBday() | 1323 | bool CalendarView::importBday() |
1323 | { | 1324 | { |
1324 | #ifndef KORG_NOKABC | 1325 | #ifndef KORG_NOKABC |
1325 | 1326 | ||
1326 | #ifdef DESKTOP_VERSION | 1327 | #ifdef DESKTOP_VERSION |
1327 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1328 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1328 | KABC::AddressBook::Iterator it; | 1329 | KABC::AddressBook::Iterator it; |
1329 | int count = 0; | 1330 | int count = 0; |
1330 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1331 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1331 | ++count; | 1332 | ++count; |
1332 | } | 1333 | } |
1333 | QProgressBar bar(count,0 ); | 1334 | QProgressBar bar(count,0 ); |
1334 | int w = 300; | 1335 | int w = 300; |
1335 | if ( QApplication::desktop()->width() < 320 ) | 1336 | if ( QApplication::desktop()->width() < 320 ) |
1336 | w = 220; | 1337 | w = 220; |
1337 | int h = bar.sizeHint().height() ; | 1338 | int h = bar.sizeHint().height() ; |
1338 | int dw = QApplication::desktop()->width(); | 1339 | int dw = QApplication::desktop()->width(); |
1339 | int dh = QApplication::desktop()->height(); | 1340 | int dh = QApplication::desktop()->height(); |
1340 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1341 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1341 | bar.show(); | 1342 | bar.show(); |
1342 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); | 1343 | bar.setCaption (i18n("Reading addressbook - close to abort!") ); |
1343 | qApp->processEvents(); | 1344 | qApp->processEvents(); |
1344 | count = 0; | 1345 | count = 0; |
1345 | int addCount = 0; | 1346 | int addCount = 0; |
1346 | KCal::Attendee* a = 0; | 1347 | KCal::Attendee* a = 0; |
1347 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1348 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1348 | if ( ! bar.isVisible() ) | 1349 | if ( ! bar.isVisible() ) |
1349 | return false; | 1350 | return false; |
1350 | bar.setProgress( count++ ); | 1351 | bar.setProgress( count++ ); |
1351 | qApp->processEvents(); | 1352 | qApp->processEvents(); |
1352 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); | 1353 | //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); |
1353 | if ( (*it).birthday().date().isValid() ){ | 1354 | if ( (*it).birthday().date().isValid() ){ |
1354 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1355 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1355 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) | 1356 | if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) |
1356 | ++addCount; | 1357 | ++addCount; |
1357 | } | 1358 | } |
1358 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); | 1359 | QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); |
1359 | if ( anni.isValid() ){ | 1360 | if ( anni.isValid() ){ |
1360 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; | 1361 | a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; |
1361 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) | 1362 | if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) |
1362 | ++addCount; | 1363 | ++addCount; |
1363 | } | 1364 | } |
1364 | } | 1365 | } |
1365 | updateView(); | 1366 | updateView(); |
1366 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); | 1367 | topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); |
1367 | #else //DESKTOP_VERSION | 1368 | #else //DESKTOP_VERSION |
1368 | 1369 | ||
1369 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 1370 | ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
1370 | // the result should now arrive through method insertBirthdays | 1371 | // the result should now arrive through method insertBirthdays |
1371 | 1372 | ||
1372 | #endif //DESKTOP_VERSION | 1373 | #endif //DESKTOP_VERSION |
1373 | 1374 | ||
1374 | #endif //KORG_NOKABC | 1375 | #endif //KORG_NOKABC |
1375 | 1376 | ||
1376 | 1377 | ||
1377 | return true; | 1378 | return true; |
@@ -3545,212 +3546,218 @@ void CalendarView::toggleAllDaySize() | |||
3545 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3546 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3546 | */ | 3547 | */ |
3547 | viewManager()->agendaView()->toggleAllDay(); | 3548 | viewManager()->agendaView()->toggleAllDay(); |
3548 | } | 3549 | } |
3549 | void CalendarView::toggleExpand() | 3550 | void CalendarView::toggleExpand() |
3550 | { | 3551 | { |
3551 | // if ( mLeftFrame->isHidden() ) { | 3552 | // if ( mLeftFrame->isHidden() ) { |
3552 | // mLeftFrame->show(); | 3553 | // mLeftFrame->show(); |
3553 | // emit calendarViewExpanded( false ); | 3554 | // emit calendarViewExpanded( false ); |
3554 | // } else { | 3555 | // } else { |
3555 | // mLeftFrame->hide(); | 3556 | // mLeftFrame->hide(); |
3556 | // emit calendarViewExpanded( true ); | 3557 | // emit calendarViewExpanded( true ); |
3557 | // } | 3558 | // } |
3558 | 3559 | ||
3559 | globalFlagBlockAgenda = 1; | 3560 | globalFlagBlockAgenda = 1; |
3560 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3561 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3561 | globalFlagBlockAgenda = 5; | 3562 | globalFlagBlockAgenda = 5; |
3562 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3563 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3563 | //mViewManager->showView( 0, true ); | 3564 | //mViewManager->showView( 0, true ); |
3564 | } | 3565 | } |
3565 | 3566 | ||
3566 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3567 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3567 | { | 3568 | { |
3568 | setModified( modified ); | 3569 | setModified( modified ); |
3569 | } | 3570 | } |
3570 | 3571 | ||
3571 | Todo *CalendarView::selectedTodo() | 3572 | Todo *CalendarView::selectedTodo() |
3572 | { | 3573 | { |
3573 | Incidence *incidence = currentSelection(); | 3574 | Incidence *incidence = currentSelection(); |
3574 | if ( incidence && incidence->type() == "Todo" ) { | 3575 | if ( incidence && incidence->type() == "Todo" ) { |
3575 | return static_cast<Todo *>( incidence ); | 3576 | return static_cast<Todo *>( incidence ); |
3576 | } | 3577 | } |
3577 | 3578 | ||
3578 | incidence = mTodoList->selectedIncidences().first(); | 3579 | incidence = mTodoList->selectedIncidences().first(); |
3579 | if ( incidence && incidence->type() == "Todo" ) { | 3580 | if ( incidence && incidence->type() == "Todo" ) { |
3580 | return static_cast<Todo *>( incidence ); | 3581 | return static_cast<Todo *>( incidence ); |
3581 | } | 3582 | } |
3582 | 3583 | ||
3583 | return 0; | 3584 | return 0; |
3584 | } | 3585 | } |
3585 | 3586 | ||
3586 | void CalendarView::dialogClosing(Incidence *in) | 3587 | void CalendarView::dialogClosing(Incidence *in) |
3587 | { | 3588 | { |
3588 | // mDialogList.remove(in); | 3589 | // mDialogList.remove(in); |
3589 | } | 3590 | } |
3590 | 3591 | ||
3591 | void CalendarView::showIncidence() | 3592 | void CalendarView::showIncidence() |
3592 | { | 3593 | { |
3593 | Incidence *incidence = currentSelection(); | 3594 | Incidence *incidence = currentSelection(); |
3594 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3595 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3595 | if ( incidence ) { | 3596 | if ( incidence ) { |
3596 | ShowIncidenceVisitor v; | 3597 | ShowIncidenceVisitor v; |
3597 | v.act( incidence, this ); | 3598 | v.act( incidence, this ); |
3598 | } | 3599 | } |
3599 | } | 3600 | } |
3600 | void CalendarView::editIncidenceDescription() | 3601 | void CalendarView::editIncidenceDescription() |
3601 | { | 3602 | { |
3602 | mFlagEditDescription = true; | 3603 | mFlagEditDescription = true; |
3603 | editIncidence(); | 3604 | editIncidence(); |
3604 | mFlagEditDescription = false; | 3605 | mFlagEditDescription = false; |
3605 | } | 3606 | } |
3606 | void CalendarView::editIncidence() | 3607 | void CalendarView::editIncidence() |
3607 | { | 3608 | { |
3608 | // qDebug("editIncidence() "); | 3609 | // qDebug("editIncidence() "); |
3609 | Incidence *incidence = currentSelection(); | 3610 | Incidence *incidence = currentSelection(); |
3610 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3611 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3611 | if ( incidence ) { | 3612 | if ( incidence ) { |
3612 | EditIncidenceVisitor v; | 3613 | EditIncidenceVisitor v; |
3613 | v.act( incidence, this ); | 3614 | v.act( incidence, this ); |
3614 | } | 3615 | } |
3615 | } | 3616 | } |
3616 | 3617 | ||
3617 | void CalendarView::deleteIncidence() | 3618 | void CalendarView::deleteIncidence() |
3618 | { | 3619 | { |
3619 | Incidence *incidence = currentSelection(); | 3620 | Incidence *incidence = currentSelection(); |
3620 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3621 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3621 | if ( incidence ) { | 3622 | if ( incidence ) { |
3622 | deleteIncidence(incidence); | 3623 | deleteIncidence(incidence); |
3623 | } | 3624 | } |
3624 | } | 3625 | } |
3625 | 3626 | ||
3626 | void CalendarView::showIncidence(Incidence *incidence) | 3627 | void CalendarView::showIncidence(Incidence *incidence) |
3627 | { | 3628 | { |
3628 | if ( incidence ) { | 3629 | if ( incidence ) { |
3629 | ShowIncidenceVisitor v; | 3630 | ShowIncidenceVisitor v; |
3630 | v.act( incidence, this ); | 3631 | v.act( incidence, this ); |
3631 | } | 3632 | } |
3632 | } | 3633 | } |
3633 | 3634 | ||
3634 | void CalendarView::editIncidence(Incidence *incidence) | 3635 | void CalendarView::editIncidence(Incidence *incidence) |
3635 | { | 3636 | { |
3636 | if ( incidence ) { | 3637 | if ( incidence ) { |
3637 | 3638 | ||
3638 | EditIncidenceVisitor v; | 3639 | EditIncidenceVisitor v; |
3639 | v.act( incidence, this ); | 3640 | v.act( incidence, this ); |
3640 | 3641 | ||
3641 | } | 3642 | } |
3642 | } | 3643 | } |
3643 | 3644 | ||
3644 | void CalendarView::deleteIncidence(Incidence *incidence) | 3645 | void CalendarView::deleteIncidence(Incidence *incidence) |
3645 | { | 3646 | { |
3646 | //qDebug(" CalendarView::deleteIncidence "); | 3647 | //qDebug(" CalendarView::deleteIncidence "); |
3647 | if ( incidence ) { | 3648 | if ( incidence ) { |
3648 | DeleteIncidenceVisitor v; | 3649 | DeleteIncidenceVisitor v; |
3649 | v.act( incidence, this ); | 3650 | v.act( incidence, this ); |
3650 | } | 3651 | } |
3651 | } | 3652 | } |
3652 | 3653 | ||
3653 | 3654 | ||
3654 | void CalendarView::lookForOutgoingMessages() | 3655 | void CalendarView::lookForOutgoingMessages() |
3655 | { | 3656 | { |
3656 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3657 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3657 | ogd->loadMessages(); | 3658 | ogd->loadMessages(); |
3658 | } | 3659 | } |
3659 | 3660 | ||
3660 | void CalendarView::lookForIncomingMessages() | 3661 | void CalendarView::lookForIncomingMessages() |
3661 | { | 3662 | { |
3662 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3663 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3663 | icd->retrieve(); | 3664 | icd->retrieve(); |
3664 | } | 3665 | } |
3665 | 3666 | ||
3666 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3667 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3667 | { | 3668 | { |
3668 | bool deleteTodo = true; | 3669 | bool deleteTodo = true; |
3669 | QPtrList<Incidence> subTodos; | 3670 | QPtrList<Incidence> subTodos; |
3670 | Incidence *aTodo; | 3671 | Incidence *aTodo; |
3671 | subTodos = t->relations(); | 3672 | subTodos = t->relations(); |
3672 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3673 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3673 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3674 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3674 | deleteTodo = false; | 3675 | deleteTodo = false; |
3675 | } | 3676 | } |
3676 | if ( deleteTodo ) { | 3677 | if ( deleteTodo ) { |
3677 | if ( t->isCompleted() ) { | 3678 | if ( t->isCompleted() ) { |
3678 | checkExternalId( t ); | 3679 | checkExternalId( t ); |
3679 | mCalendar->deleteTodo( t ); | 3680 | mCalendar->deleteTodo( t ); |
3680 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3681 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3681 | } | 3682 | } |
3682 | else | 3683 | else |
3683 | deleteTodo = false; | 3684 | deleteTodo = false; |
3684 | } | 3685 | } |
3685 | return deleteTodo; | 3686 | return deleteTodo; |
3686 | 3687 | ||
3687 | } | 3688 | } |
3688 | void CalendarView::purgeCompleted() | 3689 | void CalendarView::purgeCompleted() |
3689 | { | 3690 | { |
3690 | int result = KMessageBox::warningContinueCancel(this, | 3691 | int result = KMessageBox::warningContinueCancel(this, |
3691 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3692 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3692 | 3693 | ||
3693 | if (result == KMessageBox::Continue) { | 3694 | if (result == KMessageBox::Continue) { |
3694 | 3695 | ||
3695 | QPtrList<Todo> todoCal; | 3696 | QPtrList<Todo> todoCal; |
3696 | QPtrList<Todo> rootTodos; | 3697 | QPtrList<Todo> rootTodos; |
3697 | //QPtrList<Incidence> rel; | 3698 | //QPtrList<Incidence> rel; |
3698 | Todo *aTodo;//, *rTodo; | 3699 | Todo *aTodo;//, *rTodo; |
3699 | Incidence *rIncidence; | 3700 | Incidence *rIncidence; |
3700 | bool childDelete = false; | 3701 | bool childDelete = false; |
3701 | bool deletedOne = true; | 3702 | bool deletedOne = true; |
3702 | todoCal = calendar()->todos(); | 3703 | todoCal = calendar()->todos(); |
3703 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3704 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3704 | if ( !aTodo->relatedTo() ) | 3705 | if ( !aTodo->relatedTo() ) |
3705 | rootTodos.append( aTodo ); | 3706 | rootTodos.append( aTodo ); |
3706 | } | 3707 | } |
3707 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3708 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3708 | removeCompletedSubTodos( aTodo ); | 3709 | removeCompletedSubTodos( aTodo ); |
3709 | } | 3710 | } |
3710 | 3711 | ||
3711 | updateView(); | 3712 | updateView(); |
3712 | } | 3713 | } |
3713 | } | 3714 | } |
3714 | 3715 | ||
3715 | void CalendarView::slotCalendarChanged() | 3716 | void CalendarView::slotCalendarChanged() |
3716 | { | 3717 | { |
3717 | ; | 3718 | ; |
3718 | } | 3719 | } |
3719 | 3720 | ||
3720 | NavigatorBar *CalendarView::navigatorBar() | 3721 | NavigatorBar *CalendarView::navigatorBar() |
3721 | { | 3722 | { |
3722 | return mNavigatorBar; | 3723 | return mNavigatorBar; |
3723 | } | 3724 | } |
3724 | 3725 | ||
3725 | 3726 | ||
3726 | 3727 | ||
3727 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3728 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3728 | { | 3729 | { |
3729 | //qDebug(" alendarView::keyPressEvent "); | 3730 | //qDebug(" alendarView::keyPressEvent "); |
3730 | e->ignore(); | 3731 | e->ignore(); |
3731 | } | 3732 | } |
3732 | 3733 | ||
3733 | 3734 | ||
3734 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3735 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3735 | { | 3736 | { |
3736 | // mSyncManager = manager; | 3737 | // mSyncManager = manager; |
3738 | mSyncKDE = false; | ||
3739 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | ||
3740 | qDebug("SyncKDE request detected!"); | ||
3741 | mSyncKDE = true; | ||
3742 | } | ||
3737 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3743 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3738 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3744 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3739 | return syncCalendar( filename, mode ); | 3745 | return syncCalendar( filename, mode ); |
3740 | } | 3746 | } |
3741 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3747 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3742 | { | 3748 | { |
3749 | mSyncKDE = false; | ||
3743 | //mSyncManager = manager; | 3750 | //mSyncManager = manager; |
3744 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3751 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3745 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3752 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3746 | if ( resource == "sharp" ) | 3753 | if ( resource == "sharp" ) |
3747 | syncExternal( 0 ); | 3754 | syncExternal( 0 ); |
3748 | if ( resource == "phone" ) | 3755 | if ( resource == "phone" ) |
3749 | syncExternal( 1 ); | 3756 | syncExternal( 1 ); |
3750 | // pending setmodified | 3757 | // pending setmodified |
3751 | return true; | 3758 | return true; |
3752 | } | 3759 | } |
3753 | void CalendarView::setSyncManager(KSyncManager* manager) | 3760 | void CalendarView::setSyncManager(KSyncManager* manager) |
3754 | { | 3761 | { |
3755 | mSyncManager = manager; | 3762 | mSyncManager = manager; |
3756 | } | 3763 | } |
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 9f56cc8..1cd896d 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -298,306 +298,307 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
298 | 298 | ||
299 | void todoAdded(Todo *); | 299 | void todoAdded(Todo *); |
300 | void todoChanged(Todo *); | 300 | void todoChanged(Todo *); |
301 | void todoToBeDeleted(Todo *); | 301 | void todoToBeDeleted(Todo *); |
302 | void todoDeleted(); | 302 | void todoDeleted(); |
303 | 303 | ||
304 | void updateView(const QDate &start, const QDate &end); | 304 | void updateView(const QDate &start, const QDate &end); |
305 | void updateView(); | 305 | void updateView(); |
306 | 306 | ||
307 | /** Full update of visible todo views */ | 307 | /** Full update of visible todo views */ |
308 | void updateTodoViews(); | 308 | void updateTodoViews(); |
309 | 309 | ||
310 | void updateUnmanagedViews(); | 310 | void updateUnmanagedViews(); |
311 | 311 | ||
312 | /** cut the current appointment to the clipboard */ | 312 | /** cut the current appointment to the clipboard */ |
313 | void edit_cut(); | 313 | void edit_cut(); |
314 | 314 | ||
315 | /** copy the current appointment(s) to the clipboard */ | 315 | /** copy the current appointment(s) to the clipboard */ |
316 | void edit_copy(); | 316 | void edit_copy(); |
317 | 317 | ||
318 | /** paste the current vobject(s) in the clipboard buffer into calendar */ | 318 | /** paste the current vobject(s) in the clipboard buffer into calendar */ |
319 | void edit_paste(); | 319 | void edit_paste(); |
320 | 320 | ||
321 | /** edit viewing and configuration options. */ | 321 | /** edit viewing and configuration options. */ |
322 | void edit_options(); | 322 | void edit_options(); |
323 | /** | 323 | /** |
324 | Functions for printing, previewing a print, and setting up printing | 324 | Functions for printing, previewing a print, and setting up printing |
325 | parameters. | 325 | parameters. |
326 | */ | 326 | */ |
327 | void print(); | 327 | void print(); |
328 | void printSetup(); | 328 | void printSetup(); |
329 | void printPreview(); | 329 | void printPreview(); |
330 | 330 | ||
331 | /** Export as iCalendar file */ | 331 | /** Export as iCalendar file */ |
332 | void exportICalendar(); | 332 | void exportICalendar(); |
333 | 333 | ||
334 | /** Export as vCalendar file */ | 334 | /** Export as vCalendar file */ |
335 | bool exportVCalendar( QString fn); | 335 | bool exportVCalendar( QString fn); |
336 | 336 | ||
337 | /** pop up a dialog to show an existing appointment. */ | 337 | /** pop up a dialog to show an existing appointment. */ |
338 | void appointment_show(); | 338 | void appointment_show(); |
339 | /** | 339 | /** |
340 | * pop up an Appointment Dialog to edit an existing appointment.Get | 340 | * pop up an Appointment Dialog to edit an existing appointment.Get |
341 | * information on the appointment from the list of unique IDs that is | 341 | * information on the appointment from the list of unique IDs that is |
342 | * currently in the View, called currIds. | 342 | * currently in the View, called currIds. |
343 | */ | 343 | */ |
344 | void appointment_edit(); | 344 | void appointment_edit(); |
345 | /** | 345 | /** |
346 | * pop up dialog confirming deletion of currently selected event in the | 346 | * pop up dialog confirming deletion of currently selected event in the |
347 | * View. | 347 | * View. |
348 | */ | 348 | */ |
349 | void appointment_delete(); | 349 | void appointment_delete(); |
350 | 350 | ||
351 | /** mails the currently selected event to a particular user as a vCalendar | 351 | /** mails the currently selected event to a particular user as a vCalendar |
352 | attachment. */ | 352 | attachment. */ |
353 | void action_mail(); | 353 | void action_mail(); |
354 | 354 | ||
355 | /* frees a subtodo from it's relation */ | 355 | /* frees a subtodo from it's relation */ |
356 | void todo_unsub( Todo * ); | 356 | void todo_unsub( Todo * ); |
357 | void todo_resub( Todo * parent, Todo * sub ); | 357 | void todo_resub( Todo * parent, Todo * sub ); |
358 | 358 | ||
359 | /** Take ownership of selected event. */ | 359 | /** Take ownership of selected event. */ |
360 | void takeOverEvent(); | 360 | void takeOverEvent(); |
361 | 361 | ||
362 | /** Take ownership of all events in calendar. */ | 362 | /** Take ownership of all events in calendar. */ |
363 | void takeOverCalendar(); | 363 | void takeOverCalendar(); |
364 | 364 | ||
365 | /** query whether or not the calendar is "dirty". */ | 365 | /** query whether or not the calendar is "dirty". */ |
366 | bool isModified(); | 366 | bool isModified(); |
367 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ | 367 | /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ |
368 | void setModified(bool modified=true); | 368 | void setModified(bool modified=true); |
369 | 369 | ||
370 | /** query if the calendar is read-only. */ | 370 | /** query if the calendar is read-only. */ |
371 | bool isReadOnly(); | 371 | bool isReadOnly(); |
372 | /** set state of calendar to read-only */ | 372 | /** set state of calendar to read-only */ |
373 | void setReadOnly(bool readOnly=true); | 373 | void setReadOnly(bool readOnly=true); |
374 | 374 | ||
375 | void eventUpdated(Incidence *); | 375 | void eventUpdated(Incidence *); |
376 | 376 | ||
377 | /* iTIP scheduling actions */ | 377 | /* iTIP scheduling actions */ |
378 | void schedule_publish(Incidence *incidence = 0); | 378 | void schedule_publish(Incidence *incidence = 0); |
379 | void schedule_request(Incidence *incidence = 0); | 379 | void schedule_request(Incidence *incidence = 0); |
380 | void schedule_refresh(Incidence *incidence = 0); | 380 | void schedule_refresh(Incidence *incidence = 0); |
381 | void schedule_cancel(Incidence *incidence = 0); | 381 | void schedule_cancel(Incidence *incidence = 0); |
382 | void schedule_add(Incidence *incidence = 0); | 382 | void schedule_add(Incidence *incidence = 0); |
383 | void schedule_reply(Incidence *incidence = 0); | 383 | void schedule_reply(Incidence *incidence = 0); |
384 | void schedule_counter(Incidence *incidence = 0); | 384 | void schedule_counter(Incidence *incidence = 0); |
385 | void schedule_declinecounter(Incidence *incidence = 0); | 385 | void schedule_declinecounter(Incidence *incidence = 0); |
386 | void schedule_publish_freebusy(int daysToPublish = 30); | 386 | void schedule_publish_freebusy(int daysToPublish = 30); |
387 | 387 | ||
388 | void openAddressbook(); | 388 | void openAddressbook(); |
389 | 389 | ||
390 | void editFilters(); | 390 | void editFilters(); |
391 | void toggleFilerEnabled(); | 391 | void toggleFilerEnabled(); |
392 | QPtrList<CalFilter> filters(); | 392 | QPtrList<CalFilter> filters(); |
393 | void toggleFilter(); | 393 | void toggleFilter(); |
394 | void showFilter(bool visible); | 394 | void showFilter(bool visible); |
395 | void updateFilter(); | 395 | void updateFilter(); |
396 | void filterEdited(); | 396 | void filterEdited(); |
397 | void selectFilter( int ); | 397 | void selectFilter( int ); |
398 | KOFilterView *filterView(); | 398 | KOFilterView *filterView(); |
399 | 399 | ||
400 | void showIntro(); | 400 | void showIntro(); |
401 | 401 | ||
402 | /** Move the curdatepient view date to today */ | 402 | /** Move the curdatepient view date to today */ |
403 | void goToday(); | 403 | void goToday(); |
404 | 404 | ||
405 | /** Move to the next date(s) in the current view */ | 405 | /** Move to the next date(s) in the current view */ |
406 | void goNext(); | 406 | void goNext(); |
407 | 407 | ||
408 | /** Move to the previous date(s) in the current view */ | 408 | /** Move to the previous date(s) in the current view */ |
409 | void goPrevious(); | 409 | void goPrevious(); |
410 | /** Move to the next date(s) in the current view */ | 410 | /** Move to the next date(s) in the current view */ |
411 | void goNextMonth(); | 411 | void goNextMonth(); |
412 | 412 | ||
413 | /** Move to the previous date(s) in the current view */ | 413 | /** Move to the previous date(s) in the current view */ |
414 | void goPreviousMonth(); | 414 | void goPreviousMonth(); |
415 | 415 | ||
416 | void toggleExpand(); | 416 | void toggleExpand(); |
417 | void toggleDateNavigatorWidget(); | 417 | void toggleDateNavigatorWidget(); |
418 | void toggleAllDaySize(); | 418 | void toggleAllDaySize(); |
419 | void dialogClosing(Incidence *); | 419 | void dialogClosing(Incidence *); |
420 | 420 | ||
421 | /** Look for new messages in the inbox */ | 421 | /** Look for new messages in the inbox */ |
422 | void lookForIncomingMessages(); | 422 | void lookForIncomingMessages(); |
423 | /** Look for new messages in the outbox */ | 423 | /** Look for new messages in the outbox */ |
424 | void lookForOutgoingMessages(); | 424 | void lookForOutgoingMessages(); |
425 | 425 | ||
426 | void processMainViewSelection( Incidence * ); | 426 | void processMainViewSelection( Incidence * ); |
427 | void processTodoListSelection( Incidence * ); | 427 | void processTodoListSelection( Incidence * ); |
428 | 428 | ||
429 | void processIncidenceSelection( Incidence * ); | 429 | void processIncidenceSelection( Incidence * ); |
430 | 430 | ||
431 | void purgeCompleted(); | 431 | void purgeCompleted(); |
432 | bool removeCompletedSubTodos( Todo* ); | 432 | bool removeCompletedSubTodos( Todo* ); |
433 | void slotCalendarChanged(); | 433 | void slotCalendarChanged(); |
434 | bool importBday(); | 434 | bool importBday(); |
435 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); | 435 | bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); |
436 | bool importQtopia( const QString &categoriesFile, | 436 | bool importQtopia( const QString &categoriesFile, |
437 | const QString &datebookFile, | 437 | const QString &datebookFile, |
438 | const QString &tasklistFile ); | 438 | const QString &tasklistFile ); |
439 | void syncExternal( int mode ); | 439 | void syncExternal( int mode ); |
440 | void slotSelectPickerDate( QDate ) ; | 440 | void slotSelectPickerDate( QDate ) ; |
441 | void showDatePicker( ) ; | 441 | void showDatePicker( ) ; |
442 | void moveIncidence(Incidence *) ; | 442 | void moveIncidence(Incidence *) ; |
443 | void beamIncidence(Incidence *) ; | 443 | void beamIncidence(Incidence *) ; |
444 | void beamCalendar() ; | 444 | void beamCalendar() ; |
445 | void beamFilteredCalendar() ; | 445 | void beamFilteredCalendar() ; |
446 | void beamIncidenceList(QPtrList<Incidence>) ; | 446 | void beamIncidenceList(QPtrList<Incidence>) ; |
447 | void manageCategories(); | 447 | void manageCategories(); |
448 | int addCategories(); | 448 | int addCategories(); |
449 | void removeCategories(); | 449 | void removeCategories(); |
450 | void setSyncDevice( QString ); | 450 | void setSyncDevice( QString ); |
451 | void setSyncName( QString ); | 451 | void setSyncName( QString ); |
452 | protected slots: | 452 | protected slots: |
453 | void timerAlarm(); | 453 | void timerAlarm(); |
454 | void suspendAlarm(); | 454 | void suspendAlarm(); |
455 | void beamDone( Ir *ir ); | 455 | void beamDone( Ir *ir ); |
456 | /** Select a view or adapt the current view to display the specified dates. */ | 456 | /** Select a view or adapt the current view to display the specified dates. */ |
457 | void showDates( const KCal::DateList & ); | 457 | void showDates( const KCal::DateList & ); |
458 | void selectWeekNum ( int ); | 458 | void selectWeekNum ( int ); |
459 | 459 | ||
460 | public: | 460 | public: |
461 | // show a standard warning | 461 | // show a standard warning |
462 | // returns KMsgBox::yesNoCancel() | 462 | // returns KMsgBox::yesNoCancel() |
463 | int msgCalModified(); | 463 | int msgCalModified(); |
464 | virtual bool sync(KSyncManager* manager, QString filename, int mode); | 464 | virtual bool sync(KSyncManager* manager, QString filename, int mode); |
465 | 465 | ||
466 | virtual bool syncExternal(KSyncManager* manager, QString resource); | 466 | virtual bool syncExternal(KSyncManager* manager, QString resource); |
467 | void setSyncManager(KSyncManager* manager); | 467 | void setSyncManager(KSyncManager* manager); |
468 | void setLoadedFileVersion(QDateTime); | 468 | void setLoadedFileVersion(QDateTime); |
469 | bool checkFileVersion(QString fn); | 469 | bool checkFileVersion(QString fn); |
470 | bool checkFileChanged(QString fn); | 470 | bool checkFileChanged(QString fn); |
471 | Event* getLastSyncEvent(); | 471 | Event* getLastSyncEvent(); |
472 | /** Adapt navigation units correpsonding to step size of navigation of the | 472 | /** Adapt navigation units correpsonding to step size of navigation of the |
473 | * current view. | 473 | * current view. |
474 | */ | 474 | */ |
475 | void adaptNavigationUnits(); | 475 | void adaptNavigationUnits(); |
476 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); | 476 | bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); |
477 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); | 477 | int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); |
478 | //Attendee* getYourAttendee(Event *event); | 478 | //Attendee* getYourAttendee(Event *event); |
479 | protected: | 479 | protected: |
480 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 480 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
481 | 481 | ||
482 | // returns KMsgBox::OKCandel() | 482 | // returns KMsgBox::OKCandel() |
483 | int msgItemDelete(); | 483 | int msgItemDelete(); |
484 | void showEventEditor(); | 484 | void showEventEditor(); |
485 | void showTodoEditor(); | 485 | void showTodoEditor(); |
486 | void writeLocale(); | 486 | void writeLocale(); |
487 | Todo *selectedTodo(); | 487 | Todo *selectedTodo(); |
488 | 488 | ||
489 | private: | 489 | private: |
490 | bool mSyncKDE; | ||
490 | KSyncManager* mSyncManager; | 491 | KSyncManager* mSyncManager; |
491 | AlarmDialog * mAlarmDialog; | 492 | AlarmDialog * mAlarmDialog; |
492 | QString mAlarmNotification; | 493 | QString mAlarmNotification; |
493 | QString mSuspendAlarmNotification; | 494 | QString mSuspendAlarmNotification; |
494 | QTimer* mSuspendTimer; | 495 | QTimer* mSuspendTimer; |
495 | QTimer* mAlarmTimer; | 496 | QTimer* mAlarmTimer; |
496 | QTimer* mRecheckAlarmTimer; | 497 | QTimer* mRecheckAlarmTimer; |
497 | void computeAlarm( QString ); | 498 | void computeAlarm( QString ); |
498 | void startAlarm( QString, QString ); | 499 | void startAlarm( QString, QString ); |
499 | void setSyncEventsReadOnly(); | 500 | void setSyncEventsReadOnly(); |
500 | 501 | ||
501 | QDateTime loadedFileVersion; | 502 | QDateTime loadedFileVersion; |
502 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); | 503 | void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); |
503 | void checkExternalId( Incidence * inc ); | 504 | void checkExternalId( Incidence * inc ); |
504 | int mGlobalSyncMode; | 505 | int mGlobalSyncMode; |
505 | QString mCurrentSyncDevice; | 506 | QString mCurrentSyncDevice; |
506 | QString mCurrentSyncName; | 507 | QString mCurrentSyncName; |
507 | KOBeamPrefs* beamDialog; | 508 | KOBeamPrefs* beamDialog; |
508 | void init(); | 509 | void init(); |
509 | int mDatePickerMode; | 510 | int mDatePickerMode; |
510 | bool mFlagEditDescription; | 511 | bool mFlagEditDescription; |
511 | QDateTime mLastCalendarSync; | 512 | QDateTime mLastCalendarSync; |
512 | void createPrinter(); | 513 | void createPrinter(); |
513 | 514 | ||
514 | void calendarModified( bool, Calendar * ); | 515 | void calendarModified( bool, Calendar * ); |
515 | 516 | ||
516 | CalPrinter *mCalPrinter; | 517 | CalPrinter *mCalPrinter; |
517 | 518 | ||
518 | QSplitter *mPanner; | 519 | QSplitter *mPanner; |
519 | QSplitter *mLeftSplitter; | 520 | QSplitter *mLeftSplitter; |
520 | QWidget *mLeftFrame; | 521 | QWidget *mLeftFrame; |
521 | QWidgetStack *mRightFrame; | 522 | QWidgetStack *mRightFrame; |
522 | 523 | ||
523 | KDatePicker* mDatePicker; | 524 | KDatePicker* mDatePicker; |
524 | QVBox* mDateFrame; | 525 | QVBox* mDateFrame; |
525 | NavigatorBar *mNavigatorBar; | 526 | NavigatorBar *mNavigatorBar; |
526 | 527 | ||
527 | KDateNavigator *mDateNavigator; // widget showing small month view. | 528 | KDateNavigator *mDateNavigator; // widget showing small month view. |
528 | 529 | ||
529 | KOFilterView *mFilterView; | 530 | KOFilterView *mFilterView; |
530 | 531 | ||
531 | ResourceView *mResourceView; | 532 | ResourceView *mResourceView; |
532 | 533 | ||
533 | // calendar object for this viewing instance | 534 | // calendar object for this viewing instance |
534 | Calendar *mCalendar; | 535 | Calendar *mCalendar; |
535 | 536 | ||
536 | CalendarResourceManager *mResourceManager; | 537 | CalendarResourceManager *mResourceManager; |
537 | 538 | ||
538 | FileStorage *mStorage; | 539 | FileStorage *mStorage; |
539 | 540 | ||
540 | DateNavigator *mNavigator; | 541 | DateNavigator *mNavigator; |
541 | 542 | ||
542 | KOViewManager *mViewManager; | 543 | KOViewManager *mViewManager; |
543 | KODialogManager *mDialogManager; | 544 | KODialogManager *mDialogManager; |
544 | 545 | ||
545 | // Calendar filters | 546 | // Calendar filters |
546 | QPtrList<CalFilter> mFilters; | 547 | QPtrList<CalFilter> mFilters; |
547 | 548 | ||
548 | // various housekeeping variables. | 549 | // various housekeeping variables. |
549 | bool mModified; // flag indicating if calendar is modified | 550 | bool mModified; // flag indicating if calendar is modified |
550 | bool mReadOnly; // flag indicating if calendar is read-only | 551 | bool mReadOnly; // flag indicating if calendar is read-only |
551 | QDate mSaveSingleDate; | 552 | QDate mSaveSingleDate; |
552 | 553 | ||
553 | Incidence *mSelectedIncidence; | 554 | Incidence *mSelectedIncidence; |
554 | Incidence *mMoveIncidence; | 555 | Incidence *mMoveIncidence; |
555 | KOTodoView *mTodoList; | 556 | KOTodoView *mTodoList; |
556 | KOEventEditor * mEventEditor; | 557 | KOEventEditor * mEventEditor; |
557 | KOTodoEditor * mTodoEditor; | 558 | KOTodoEditor * mTodoEditor; |
558 | KOEventViewerDialog * mEventViewerDialog; | 559 | KOEventViewerDialog * mEventViewerDialog; |
559 | void keyPressEvent ( QKeyEvent *e) ; | 560 | void keyPressEvent ( QKeyEvent *e) ; |
560 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; | 561 | //QMap<Incidence*,KOIncidenceEditor*> mDialogList; |
561 | }; | 562 | }; |
562 | 563 | ||
563 | 564 | ||
564 | class CalendarViewVisitor : public Incidence::Visitor | 565 | class CalendarViewVisitor : public Incidence::Visitor |
565 | { | 566 | { |
566 | public: | 567 | public: |
567 | CalendarViewVisitor() : mView( 0 ) {} | 568 | CalendarViewVisitor() : mView( 0 ) {} |
568 | 569 | ||
569 | bool act( Incidence *incidence, CalendarView *view ) | 570 | bool act( Incidence *incidence, CalendarView *view ) |
570 | { | 571 | { |
571 | mView = view; | 572 | mView = view; |
572 | return incidence->accept( *this ); | 573 | return incidence->accept( *this ); |
573 | } | 574 | } |
574 | 575 | ||
575 | protected: | 576 | protected: |
576 | CalendarView *mView; | 577 | CalendarView *mView; |
577 | }; | 578 | }; |
578 | 579 | ||
579 | class ShowIncidenceVisitor : public CalendarViewVisitor | 580 | class ShowIncidenceVisitor : public CalendarViewVisitor |
580 | { | 581 | { |
581 | protected: | 582 | protected: |
582 | bool visit( Event *event ) { mView->showEvent( event ); return true; } | 583 | bool visit( Event *event ) { mView->showEvent( event ); return true; } |
583 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } | 584 | bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } |
584 | bool visit( Journal * j ) { mView->showJournal( j );return true; } | 585 | bool visit( Journal * j ) { mView->showJournal( j );return true; } |
585 | }; | 586 | }; |
586 | 587 | ||
587 | class EditIncidenceVisitor : public CalendarViewVisitor | 588 | class EditIncidenceVisitor : public CalendarViewVisitor |
588 | { | 589 | { |
589 | protected: | 590 | protected: |
590 | bool visit( Event *event ) { mView->editEvent( event ); return true; } | 591 | bool visit( Event *event ) { mView->editEvent( event ); return true; } |
591 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } | 592 | bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } |
592 | bool visit( Journal *j ) { mView->editJournal( j); return true; } | 593 | bool visit( Journal *j ) { mView->editJournal( j); return true; } |
593 | }; | 594 | }; |
594 | 595 | ||
595 | class DeleteIncidenceVisitor : public CalendarViewVisitor | 596 | class DeleteIncidenceVisitor : public CalendarViewVisitor |
596 | { | 597 | { |
597 | protected: | 598 | protected: |
598 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } | 599 | bool visit( Event *event ) { mView->deleteEvent( event ); return true; } |
599 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } | 600 | bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } |
600 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } | 601 | bool visit( Journal * j) {mView->deleteJournal( j ); return true; } |
601 | }; | 602 | }; |
602 | 603 | ||
603 | #endif | 604 | #endif |
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index eeb5f48..52daaaa 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -60,398 +60,398 @@ void Calendar::init() | |||
60 | mFilter = mDefaultFilter; | 60 | mFilter = mDefaultFilter; |
61 | mFilter->setEnabled(false); | 61 | mFilter->setEnabled(false); |
62 | 62 | ||
63 | // initialize random numbers. This is a hack, and not | 63 | // initialize random numbers. This is a hack, and not |
64 | // even that good of one at that. | 64 | // even that good of one at that. |
65 | // srandom(time(0)); | 65 | // srandom(time(0)); |
66 | 66 | ||
67 | // user information... | 67 | // user information... |
68 | setOwner(i18n("Unknown Name")); | 68 | setOwner(i18n("Unknown Name")); |
69 | setEmail(i18n("unknown@nowhere")); | 69 | setEmail(i18n("unknown@nowhere")); |
70 | 70 | ||
71 | #if 0 | 71 | #if 0 |
72 | tmpStr = KOPrefs::instance()->mTimeZone; | 72 | tmpStr = KOPrefs::instance()->mTimeZone; |
73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; | 73 | // kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; |
74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; | 74 | int dstSetting = KOPrefs::instance()->mDaylightSavings; |
75 | extern long int timezone; | 75 | extern long int timezone; |
76 | struct tm *now; | 76 | struct tm *now; |
77 | time_t curtime; | 77 | time_t curtime; |
78 | curtime = time(0); | 78 | curtime = time(0); |
79 | now = localtime(&curtime); | 79 | now = localtime(&curtime); |
80 | int hourOff = - ((timezone / 60) / 60); | 80 | int hourOff = - ((timezone / 60) / 60); |
81 | if (now->tm_isdst) | 81 | if (now->tm_isdst) |
82 | hourOff += 1; | 82 | hourOff += 1; |
83 | QString tzStr; | 83 | QString tzStr; |
84 | tzStr.sprintf("%.2d%.2d", | 84 | tzStr.sprintf("%.2d%.2d", |
85 | hourOff, | 85 | hourOff, |
86 | abs((timezone / 60) % 60)); | 86 | abs((timezone / 60) % 60)); |
87 | 87 | ||
88 | // if no time zone was in the config file, write what we just discovered. | 88 | // if no time zone was in the config file, write what we just discovered. |
89 | if (tmpStr.isEmpty()) { | 89 | if (tmpStr.isEmpty()) { |
90 | // KOPrefs::instance()->mTimeZone = tzStr; | 90 | // KOPrefs::instance()->mTimeZone = tzStr; |
91 | } else { | 91 | } else { |
92 | tzStr = tmpStr; | 92 | tzStr = tmpStr; |
93 | } | 93 | } |
94 | 94 | ||
95 | // if daylight savings has changed since last load time, we need | 95 | // if daylight savings has changed since last load time, we need |
96 | // to rewrite these settings to the config file. | 96 | // to rewrite these settings to the config file. |
97 | if ((now->tm_isdst && !dstSetting) || | 97 | if ((now->tm_isdst && !dstSetting) || |
98 | (!now->tm_isdst && dstSetting)) { | 98 | (!now->tm_isdst && dstSetting)) { |
99 | KOPrefs::instance()->mTimeZone = tzStr; | 99 | KOPrefs::instance()->mTimeZone = tzStr; |
100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; | 100 | KOPrefs::instance()->mDaylightSavings = now->tm_isdst; |
101 | } | 101 | } |
102 | 102 | ||
103 | setTimeZone(tzStr); | 103 | setTimeZone(tzStr); |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | // KOPrefs::instance()->writeConfig(); | 106 | // KOPrefs::instance()->writeConfig(); |
107 | } | 107 | } |
108 | 108 | ||
109 | Calendar::~Calendar() | 109 | Calendar::~Calendar() |
110 | { | 110 | { |
111 | delete mDefaultFilter; | 111 | delete mDefaultFilter; |
112 | } | 112 | } |
113 | 113 | ||
114 | const QString &Calendar::getOwner() const | 114 | const QString &Calendar::getOwner() const |
115 | { | 115 | { |
116 | return mOwner; | 116 | return mOwner; |
117 | } | 117 | } |
118 | 118 | ||
119 | void Calendar::setOwner(const QString &os) | 119 | void Calendar::setOwner(const QString &os) |
120 | { | 120 | { |
121 | int i; | 121 | int i; |
122 | mOwner = os; | 122 | mOwner = os; |
123 | i = mOwner.find(','); | 123 | i = mOwner.find(','); |
124 | if (i != -1) | 124 | if (i != -1) |
125 | mOwner = mOwner.left(i); | 125 | mOwner = mOwner.left(i); |
126 | 126 | ||
127 | setModified( true ); | 127 | setModified( true ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void Calendar::setTimeZone(const QString & tz) | 130 | void Calendar::setTimeZone(const QString & tz) |
131 | { | 131 | { |
132 | bool neg = FALSE; | 132 | bool neg = FALSE; |
133 | int hours, minutes; | 133 | int hours, minutes; |
134 | QString tmpStr(tz); | 134 | QString tmpStr(tz); |
135 | 135 | ||
136 | if (tmpStr.left(1) == "-") | 136 | if (tmpStr.left(1) == "-") |
137 | neg = TRUE; | 137 | neg = TRUE; |
138 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") | 138 | if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") |
139 | tmpStr.remove(0, 1); | 139 | tmpStr.remove(0, 1); |
140 | hours = tmpStr.left(2).toInt(); | 140 | hours = tmpStr.left(2).toInt(); |
141 | if (tmpStr.length() > 2) | 141 | if (tmpStr.length() > 2) |
142 | minutes = tmpStr.right(2).toInt(); | 142 | minutes = tmpStr.right(2).toInt(); |
143 | else | 143 | else |
144 | minutes = 0; | 144 | minutes = 0; |
145 | mTimeZone = (60*hours+minutes); | 145 | mTimeZone = (60*hours+minutes); |
146 | if (neg) | 146 | if (neg) |
147 | mTimeZone = -mTimeZone; | 147 | mTimeZone = -mTimeZone; |
148 | mLocalTime = false; | 148 | mLocalTime = false; |
149 | 149 | ||
150 | setModified( true ); | 150 | setModified( true ); |
151 | } | 151 | } |
152 | 152 | ||
153 | QString Calendar::getTimeZoneStr() const | 153 | QString Calendar::getTimeZoneStr() const |
154 | { | 154 | { |
155 | if (mLocalTime) | 155 | if (mLocalTime) |
156 | return ""; | 156 | return ""; |
157 | QString tmpStr; | 157 | QString tmpStr; |
158 | int hours = abs(mTimeZone / 60); | 158 | int hours = abs(mTimeZone / 60); |
159 | int minutes = abs(mTimeZone % 60); | 159 | int minutes = abs(mTimeZone % 60); |
160 | bool neg = mTimeZone < 0; | 160 | bool neg = mTimeZone < 0; |
161 | 161 | ||
162 | tmpStr.sprintf("%c%.2d%.2d", | 162 | tmpStr.sprintf("%c%.2d%.2d", |
163 | (neg ? '-' : '+'), | 163 | (neg ? '-' : '+'), |
164 | hours, minutes); | 164 | hours, minutes); |
165 | return tmpStr; | 165 | return tmpStr; |
166 | } | 166 | } |
167 | 167 | ||
168 | void Calendar::setTimeZone(int tz) | 168 | void Calendar::setTimeZone(int tz) |
169 | { | 169 | { |
170 | mTimeZone = tz; | 170 | mTimeZone = tz; |
171 | mLocalTime = false; | 171 | mLocalTime = false; |
172 | 172 | ||
173 | setModified( true ); | 173 | setModified( true ); |
174 | } | 174 | } |
175 | 175 | ||
176 | int Calendar::getTimeZone() const | 176 | int Calendar::getTimeZone() const |
177 | { | 177 | { |
178 | return mTimeZone; | 178 | return mTimeZone; |
179 | } | 179 | } |
180 | 180 | ||
181 | void Calendar::setTimeZoneId(const QString &id) | 181 | void Calendar::setTimeZoneId(const QString &id) |
182 | { | 182 | { |
183 | mTimeZoneId = id; | 183 | mTimeZoneId = id; |
184 | mLocalTime = false; | 184 | mLocalTime = false; |
185 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); | 185 | mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); |
186 | if ( mTimeZone > 1000) | 186 | if ( mTimeZone > 1000) |
187 | setLocalTime(); | 187 | setLocalTime(); |
188 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); | 188 | //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); |
189 | setModified( true ); | 189 | setModified( true ); |
190 | } | 190 | } |
191 | 191 | ||
192 | QString Calendar::timeZoneId() const | 192 | QString Calendar::timeZoneId() const |
193 | { | 193 | { |
194 | return mTimeZoneId; | 194 | return mTimeZoneId; |
195 | } | 195 | } |
196 | 196 | ||
197 | void Calendar::setLocalTime() | 197 | void Calendar::setLocalTime() |
198 | { | 198 | { |
199 | //qDebug("Calendar::setLocalTime() "); | 199 | //qDebug("Calendar::setLocalTime() "); |
200 | mLocalTime = true; | 200 | mLocalTime = true; |
201 | mTimeZone = 0; | 201 | mTimeZone = 0; |
202 | mTimeZoneId = ""; | 202 | mTimeZoneId = ""; |
203 | 203 | ||
204 | setModified( true ); | 204 | setModified( true ); |
205 | } | 205 | } |
206 | 206 | ||
207 | bool Calendar::isLocalTime() const | 207 | bool Calendar::isLocalTime() const |
208 | { | 208 | { |
209 | return mLocalTime; | 209 | return mLocalTime; |
210 | } | 210 | } |
211 | 211 | ||
212 | const QString &Calendar::getEmail() | 212 | const QString &Calendar::getEmail() |
213 | { | 213 | { |
214 | return mOwnerEmail; | 214 | return mOwnerEmail; |
215 | } | 215 | } |
216 | 216 | ||
217 | void Calendar::setEmail(const QString &e) | 217 | void Calendar::setEmail(const QString &e) |
218 | { | 218 | { |
219 | mOwnerEmail = e; | 219 | mOwnerEmail = e; |
220 | 220 | ||
221 | setModified( true ); | 221 | setModified( true ); |
222 | } | 222 | } |
223 | 223 | ||
224 | void Calendar::setFilter(CalFilter *filter) | 224 | void Calendar::setFilter(CalFilter *filter) |
225 | { | 225 | { |
226 | mFilter = filter; | 226 | mFilter = filter; |
227 | } | 227 | } |
228 | 228 | ||
229 | CalFilter *Calendar::filter() | 229 | CalFilter *Calendar::filter() |
230 | { | 230 | { |
231 | return mFilter; | 231 | return mFilter; |
232 | } | 232 | } |
233 | 233 | ||
234 | QPtrList<Incidence> Calendar::incidences() | 234 | QPtrList<Incidence> Calendar::incidences() |
235 | { | 235 | { |
236 | QPtrList<Incidence> incidences; | 236 | QPtrList<Incidence> incidences; |
237 | 237 | ||
238 | Incidence *i; | 238 | Incidence *i; |
239 | 239 | ||
240 | QPtrList<Event> e = events(); | 240 | QPtrList<Event> e = events(); |
241 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 241 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
242 | 242 | ||
243 | QPtrList<Todo> t = todos(); | 243 | QPtrList<Todo> t = todos(); |
244 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 244 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
245 | 245 | ||
246 | QPtrList<Journal> j = journals(); | 246 | QPtrList<Journal> j = journals(); |
247 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 247 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
248 | 248 | ||
249 | return incidences; | 249 | return incidences; |
250 | } | 250 | } |
251 | 251 | ||
252 | void Calendar::resetPilotStat() | 252 | void Calendar::resetPilotStat(int id ) |
253 | { | 253 | { |
254 | QPtrList<Incidence> incidences; | 254 | QPtrList<Incidence> incidences; |
255 | 255 | ||
256 | Incidence *i; | 256 | Incidence *i; |
257 | 257 | ||
258 | QPtrList<Event> e = rawEvents(); | 258 | QPtrList<Event> e = rawEvents(); |
259 | for( i = e.first(); i; i = e.next() ) i->setPilotId( 0 ); | 259 | for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); |
260 | 260 | ||
261 | QPtrList<Todo> t = rawTodos(); | 261 | QPtrList<Todo> t = rawTodos(); |
262 | for( i = t.first(); i; i = t.next() ) i->setPilotId( 0 ); | 262 | for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); |
263 | 263 | ||
264 | QPtrList<Journal> j = journals(); | 264 | QPtrList<Journal> j = journals(); |
265 | for( i = j.first(); i; i = j.next() ) i->setPilotId( 0 ); | 265 | for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); |
266 | } | 266 | } |
267 | void Calendar::resetTempSyncStat() | 267 | void Calendar::resetTempSyncStat() |
268 | { | 268 | { |
269 | QPtrList<Incidence> incidences; | 269 | QPtrList<Incidence> incidences; |
270 | 270 | ||
271 | Incidence *i; | 271 | Incidence *i; |
272 | 272 | ||
273 | QPtrList<Event> e = rawEvents(); | 273 | QPtrList<Event> e = rawEvents(); |
274 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 274 | for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
275 | 275 | ||
276 | QPtrList<Todo> t = rawTodos(); | 276 | QPtrList<Todo> t = rawTodos(); |
277 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 277 | for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
278 | 278 | ||
279 | QPtrList<Journal> j = journals(); | 279 | QPtrList<Journal> j = journals(); |
280 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 280 | for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
281 | } | 281 | } |
282 | QPtrList<Incidence> Calendar::rawIncidences() | 282 | QPtrList<Incidence> Calendar::rawIncidences() |
283 | { | 283 | { |
284 | QPtrList<Incidence> incidences; | 284 | QPtrList<Incidence> incidences; |
285 | 285 | ||
286 | Incidence *i; | 286 | Incidence *i; |
287 | 287 | ||
288 | QPtrList<Event> e = rawEvents(); | 288 | QPtrList<Event> e = rawEvents(); |
289 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); | 289 | for( i = e.first(); i; i = e.next() ) incidences.append( i ); |
290 | 290 | ||
291 | QPtrList<Todo> t = rawTodos(); | 291 | QPtrList<Todo> t = rawTodos(); |
292 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); | 292 | for( i = t.first(); i; i = t.next() ) incidences.append( i ); |
293 | 293 | ||
294 | QPtrList<Journal> j = journals(); | 294 | QPtrList<Journal> j = journals(); |
295 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); | 295 | for( i = j.first(); i; i = j.next() ) incidences.append( i ); |
296 | 296 | ||
297 | return incidences; | 297 | return incidences; |
298 | } | 298 | } |
299 | 299 | ||
300 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) | 300 | QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) |
301 | { | 301 | { |
302 | QPtrList<Event> el = rawEventsForDate(date,sorted); | 302 | QPtrList<Event> el = rawEventsForDate(date,sorted); |
303 | mFilter->apply(&el); | 303 | mFilter->apply(&el); |
304 | return el; | 304 | return el; |
305 | } | 305 | } |
306 | 306 | ||
307 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) | 307 | QPtrList<Event> Calendar::events( const QDateTime &qdt ) |
308 | { | 308 | { |
309 | QPtrList<Event> el = rawEventsForDate(qdt); | 309 | QPtrList<Event> el = rawEventsForDate(qdt); |
310 | mFilter->apply(&el); | 310 | mFilter->apply(&el); |
311 | return el; | 311 | return el; |
312 | } | 312 | } |
313 | 313 | ||
314 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, | 314 | QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, |
315 | bool inclusive) | 315 | bool inclusive) |
316 | { | 316 | { |
317 | QPtrList<Event> el = rawEvents(start,end,inclusive); | 317 | QPtrList<Event> el = rawEvents(start,end,inclusive); |
318 | mFilter->apply(&el); | 318 | mFilter->apply(&el); |
319 | return el; | 319 | return el; |
320 | } | 320 | } |
321 | 321 | ||
322 | QPtrList<Event> Calendar::events() | 322 | QPtrList<Event> Calendar::events() |
323 | { | 323 | { |
324 | QPtrList<Event> el = rawEvents(); | 324 | QPtrList<Event> el = rawEvents(); |
325 | mFilter->apply(&el); | 325 | mFilter->apply(&el); |
326 | return el; | 326 | return el; |
327 | } | 327 | } |
328 | 328 | ||
329 | 329 | ||
330 | bool Calendar::addIncidence(Incidence *i) | 330 | bool Calendar::addIncidence(Incidence *i) |
331 | { | 331 | { |
332 | Incidence::AddVisitor<Calendar> v(this); | 332 | Incidence::AddVisitor<Calendar> v(this); |
333 | 333 | ||
334 | return i->accept(v); | 334 | return i->accept(v); |
335 | } | 335 | } |
336 | void Calendar::deleteIncidence(Incidence *in) | 336 | void Calendar::deleteIncidence(Incidence *in) |
337 | { | 337 | { |
338 | if ( in->type() == "Event" ) | 338 | if ( in->type() == "Event" ) |
339 | deleteEvent( (Event*) in ); | 339 | deleteEvent( (Event*) in ); |
340 | else if ( in->type() =="Todo" ) | 340 | else if ( in->type() =="Todo" ) |
341 | deleteTodo( (Todo*) in); | 341 | deleteTodo( (Todo*) in); |
342 | else if ( in->type() =="Journal" ) | 342 | else if ( in->type() =="Journal" ) |
343 | deleteJournal( (Journal*) in ); | 343 | deleteJournal( (Journal*) in ); |
344 | } | 344 | } |
345 | 345 | ||
346 | Incidence* Calendar::incidence( const QString& uid ) | 346 | Incidence* Calendar::incidence( const QString& uid ) |
347 | { | 347 | { |
348 | Incidence* i; | 348 | Incidence* i; |
349 | 349 | ||
350 | if( (i = todo( uid )) != 0 ) | 350 | if( (i = todo( uid )) != 0 ) |
351 | return i; | 351 | return i; |
352 | if( (i = event( uid )) != 0 ) | 352 | if( (i = event( uid )) != 0 ) |
353 | return i; | 353 | return i; |
354 | if( (i = journal( uid )) != 0 ) | 354 | if( (i = journal( uid )) != 0 ) |
355 | return i; | 355 | return i; |
356 | 356 | ||
357 | return 0; | 357 | return 0; |
358 | } | 358 | } |
359 | 359 | ||
360 | QPtrList<Todo> Calendar::todos() | 360 | QPtrList<Todo> Calendar::todos() |
361 | { | 361 | { |
362 | QPtrList<Todo> tl = rawTodos(); | 362 | QPtrList<Todo> tl = rawTodos(); |
363 | mFilter->apply( &tl ); | 363 | mFilter->apply( &tl ); |
364 | return tl; | 364 | return tl; |
365 | } | 365 | } |
366 | 366 | ||
367 | // When this is called, the todo have already been added to the calendar. | 367 | // When this is called, the todo have already been added to the calendar. |
368 | // This method is only about linking related todos | 368 | // This method is only about linking related todos |
369 | void Calendar::setupRelations( Incidence *incidence ) | 369 | void Calendar::setupRelations( Incidence *incidence ) |
370 | { | 370 | { |
371 | QString uid = incidence->uid(); | 371 | QString uid = incidence->uid(); |
372 | //qDebug("Calendar::setupRelations "); | 372 | //qDebug("Calendar::setupRelations "); |
373 | // First, go over the list of orphans and see if this is their parent | 373 | // First, go over the list of orphans and see if this is their parent |
374 | while( Incidence* i = mOrphans[ uid ] ) { | 374 | while( Incidence* i = mOrphans[ uid ] ) { |
375 | mOrphans.remove( uid ); | 375 | mOrphans.remove( uid ); |
376 | i->setRelatedTo( incidence ); | 376 | i->setRelatedTo( incidence ); |
377 | incidence->addRelation( i ); | 377 | incidence->addRelation( i ); |
378 | mOrphanUids.remove( i->uid() ); | 378 | mOrphanUids.remove( i->uid() ); |
379 | } | 379 | } |
380 | 380 | ||
381 | // Now see about this incidences parent | 381 | // Now see about this incidences parent |
382 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { | 382 | if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { |
383 | // This incidence has a uid it is related to, but is not registered to it yet | 383 | // This incidence has a uid it is related to, but is not registered to it yet |
384 | // Try to find it | 384 | // Try to find it |
385 | Incidence* parent = this->incidence( incidence->relatedToUid() ); | 385 | Incidence* parent = this->incidence( incidence->relatedToUid() ); |
386 | if( parent ) { | 386 | if( parent ) { |
387 | // Found it | 387 | // Found it |
388 | incidence->setRelatedTo( parent ); | 388 | incidence->setRelatedTo( parent ); |
389 | parent->addRelation( incidence ); | 389 | parent->addRelation( incidence ); |
390 | } else { | 390 | } else { |
391 | // Not found, put this in the mOrphans list | 391 | // Not found, put this in the mOrphans list |
392 | mOrphans.insert( incidence->relatedToUid(), incidence ); | 392 | mOrphans.insert( incidence->relatedToUid(), incidence ); |
393 | mOrphanUids.insert( incidence->uid(), incidence ); | 393 | mOrphanUids.insert( incidence->uid(), incidence ); |
394 | } | 394 | } |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | // If a task with subtasks is deleted, move it's subtasks to the orphans list | 398 | // If a task with subtasks is deleted, move it's subtasks to the orphans list |
399 | void Calendar::removeRelations( Incidence *incidence ) | 399 | void Calendar::removeRelations( Incidence *incidence ) |
400 | { | 400 | { |
401 | // qDebug("Calendar::removeRelations "); | 401 | // qDebug("Calendar::removeRelations "); |
402 | QString uid = incidence->uid(); | 402 | QString uid = incidence->uid(); |
403 | 403 | ||
404 | QPtrList<Incidence> relations = incidence->relations(); | 404 | QPtrList<Incidence> relations = incidence->relations(); |
405 | for( Incidence* i = relations.first(); i; i = relations.next() ) | 405 | for( Incidence* i = relations.first(); i; i = relations.next() ) |
406 | if( !mOrphanUids.find( i->uid() ) ) { | 406 | if( !mOrphanUids.find( i->uid() ) ) { |
407 | mOrphans.insert( uid, i ); | 407 | mOrphans.insert( uid, i ); |
408 | mOrphanUids.insert( i->uid(), i ); | 408 | mOrphanUids.insert( i->uid(), i ); |
409 | i->setRelatedTo( 0 ); | 409 | i->setRelatedTo( 0 ); |
410 | i->setRelatedToUid( uid ); | 410 | i->setRelatedToUid( uid ); |
411 | } | 411 | } |
412 | 412 | ||
413 | // If this incidence is related to something else, tell that about it | 413 | // If this incidence is related to something else, tell that about it |
414 | if( incidence->relatedTo() ) | 414 | if( incidence->relatedTo() ) |
415 | incidence->relatedTo()->removeRelation( incidence ); | 415 | incidence->relatedTo()->removeRelation( incidence ); |
416 | 416 | ||
417 | // Remove this one from the orphans list | 417 | // Remove this one from the orphans list |
418 | if( mOrphanUids.remove( uid ) ) | 418 | if( mOrphanUids.remove( uid ) ) |
419 | // This incidence is located in the orphans list - it should be removed | 419 | // This incidence is located in the orphans list - it should be removed |
420 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { | 420 | if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { |
421 | // Removing wasn't that easy | 421 | // Removing wasn't that easy |
422 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { | 422 | for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { |
423 | if( it.current()->uid() == uid ) { | 423 | if( it.current()->uid() == uid ) { |
424 | mOrphans.remove( it.currentKey() ); | 424 | mOrphans.remove( it.currentKey() ); |
425 | break; | 425 | break; |
426 | } | 426 | } |
427 | } | 427 | } |
428 | } | 428 | } |
429 | } | 429 | } |
430 | 430 | ||
431 | void Calendar::registerObserver( Observer *observer ) | 431 | void Calendar::registerObserver( Observer *observer ) |
432 | { | 432 | { |
433 | mObserver = observer; | 433 | mObserver = observer; |
434 | mNewObserver = true; | 434 | mNewObserver = true; |
435 | } | 435 | } |
436 | 436 | ||
437 | void Calendar::setModified( bool modified ) | 437 | void Calendar::setModified( bool modified ) |
438 | { | 438 | { |
439 | if ( mObserver ) mObserver->calendarModified( modified, this ); | 439 | if ( mObserver ) mObserver->calendarModified( modified, this ); |
440 | if ( modified != mModified || mNewObserver ) { | 440 | if ( modified != mModified || mNewObserver ) { |
441 | mNewObserver = false; | 441 | mNewObserver = false; |
442 | // if ( mObserver ) mObserver->calendarModified( modified, this ); | 442 | // if ( mObserver ) mObserver->calendarModified( modified, this ); |
443 | mModified = modified; | 443 | mModified = modified; |
444 | } | 444 | } |
445 | } | 445 | } |
446 | 446 | ||
447 | void Calendar::setLoadedProductId( const QString &id ) | 447 | void Calendar::setLoadedProductId( const QString &id ) |
448 | { | 448 | { |
449 | mLoadedProductId = id; | 449 | mLoadedProductId = id; |
450 | } | 450 | } |
451 | 451 | ||
452 | QString Calendar::loadedProductId() | 452 | QString Calendar::loadedProductId() |
453 | { | 453 | { |
454 | return mLoadedProductId; | 454 | return mLoadedProductId; |
455 | } | 455 | } |
456 | 456 | ||
457 | //#include "calendar.moc" | 457 | //#include "calendar.moc" |
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index d5294eb..b801186 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -1,262 +1,262 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 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 | #ifndef CALENDAR_H | 22 | #ifndef CALENDAR_H |
23 | #define CALENDAR_H | 23 | #define CALENDAR_H |
24 | 24 | ||
25 | #include <qobject.h> | 25 | #include <qobject.h> |
26 | #include <qstring.h> | 26 | #include <qstring.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | #include <qptrlist.h> | 28 | #include <qptrlist.h> |
29 | #include <qdict.h> | 29 | #include <qdict.h> |
30 | 30 | ||
31 | #include "customproperties.h" | 31 | #include "customproperties.h" |
32 | #include "event.h" | 32 | #include "event.h" |
33 | #include "todo.h" | 33 | #include "todo.h" |
34 | #include "journal.h" | 34 | #include "journal.h" |
35 | #include "calfilter.h" | 35 | #include "calfilter.h" |
36 | 36 | ||
37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ | 37 | //#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ |
38 | 38 | ||
39 | class KConfig; | 39 | class KConfig; |
40 | 40 | ||
41 | namespace KCal { | 41 | namespace KCal { |
42 | 42 | ||
43 | 43 | ||
44 | /** | 44 | /** |
45 | This is the main "calendar" object class for KOrganizer. It holds | 45 | This is the main "calendar" object class for KOrganizer. It holds |
46 | information like all appointments/events, user information, etc. etc. | 46 | information like all appointments/events, user information, etc. etc. |
47 | one calendar is associated with each CalendarView (@see calendarview.h). | 47 | one calendar is associated with each CalendarView (@see calendarview.h). |
48 | This is an abstract base class defining the interface to a calendar. It is | 48 | This is an abstract base class defining the interface to a calendar. It is |
49 | implemented by subclasses like @see CalendarLocal, which use different | 49 | implemented by subclasses like @see CalendarLocal, which use different |
50 | methods to store and access the data. | 50 | methods to store and access the data. |
51 | 51 | ||
52 | Ownership of events etc. is handled by the following policy: As soon as an | 52 | Ownership of events etc. is handled by the following policy: As soon as an |
53 | event (or any other subclass of IncidenceBase) object is added to the | 53 | event (or any other subclass of IncidenceBase) object is added to the |
54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes | 54 | Calendar by addEvent() it is owned by the Calendar object. The Calendar takes |
55 | care of deleting it. All Events returned by the query functions are returned | 55 | care of deleting it. All Events returned by the query functions are returned |
56 | as pointers, that means all changes to the returned events are immediately | 56 | as pointers, that means all changes to the returned events are immediately |
57 | visible in the Calendar. You shouldn't delete any Event object you get from | 57 | visible in the Calendar. You shouldn't delete any Event object you get from |
58 | Calendar. | 58 | Calendar. |
59 | */ | 59 | */ |
60 | class Calendar : public QObject, public CustomProperties, | 60 | class Calendar : public QObject, public CustomProperties, |
61 | public IncidenceBase::Observer | 61 | public IncidenceBase::Observer |
62 | { | 62 | { |
63 | Q_OBJECT | 63 | Q_OBJECT |
64 | public: | 64 | public: |
65 | Calendar(); | 65 | Calendar(); |
66 | Calendar(const QString &timeZoneId); | 66 | Calendar(const QString &timeZoneId); |
67 | virtual ~Calendar(); | 67 | virtual ~Calendar(); |
68 | void deleteIncidence(Incidence *in); | 68 | void deleteIncidence(Incidence *in); |
69 | void resetTempSyncStat(); | 69 | void resetTempSyncStat(); |
70 | void resetPilotStat(); | 70 | void resetPilotStat(int id); |
71 | /** | 71 | /** |
72 | Clears out the current calendar, freeing all used memory etc. | 72 | Clears out the current calendar, freeing all used memory etc. |
73 | */ | 73 | */ |
74 | virtual void close() = 0; | 74 | virtual void close() = 0; |
75 | 75 | ||
76 | /** | 76 | /** |
77 | Sync changes in memory to persistant storage. | 77 | Sync changes in memory to persistant storage. |
78 | */ | 78 | */ |
79 | virtual void save() = 0; | 79 | virtual void save() = 0; |
80 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; | 80 | virtual QPtrList<Event> getExternLastSyncEvents() = 0; |
81 | virtual bool isSaving() { return false; } | 81 | virtual bool isSaving() { return false; } |
82 | 82 | ||
83 | /** | 83 | /** |
84 | Return the owner of the calendar's full name. | 84 | Return the owner of the calendar's full name. |
85 | */ | 85 | */ |
86 | const QString &getOwner() const; | 86 | const QString &getOwner() const; |
87 | /** | 87 | /** |
88 | Set the owner of the calendar. Should be owner's full name. | 88 | Set the owner of the calendar. Should be owner's full name. |
89 | */ | 89 | */ |
90 | void setOwner( const QString &os ); | 90 | void setOwner( const QString &os ); |
91 | /** | 91 | /** |
92 | Return the email address of the calendar owner. | 92 | Return the email address of the calendar owner. |
93 | */ | 93 | */ |
94 | const QString &getEmail(); | 94 | const QString &getEmail(); |
95 | /** | 95 | /** |
96 | Set the email address of the calendar owner. | 96 | Set the email address of the calendar owner. |
97 | */ | 97 | */ |
98 | void setEmail( const QString & ); | 98 | void setEmail( const QString & ); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | Set time zone from a timezone string (e.g. -2:00) | 101 | Set time zone from a timezone string (e.g. -2:00) |
102 | */ | 102 | */ |
103 | void setTimeZone( const QString &tz ); | 103 | void setTimeZone( const QString &tz ); |
104 | /** | 104 | /** |
105 | Set time zone from a minutes value (e.g. -60) | 105 | Set time zone from a minutes value (e.g. -60) |
106 | */ | 106 | */ |
107 | void setTimeZone( int tz ); | 107 | void setTimeZone( int tz ); |
108 | /** | 108 | /** |
109 | Return time zone as offest in minutes. | 109 | Return time zone as offest in minutes. |
110 | */ | 110 | */ |
111 | int getTimeZone() const; | 111 | int getTimeZone() const; |
112 | /** | 112 | /** |
113 | Compute an ISO 8601 format string from the time zone. | 113 | Compute an ISO 8601 format string from the time zone. |
114 | */ | 114 | */ |
115 | QString getTimeZoneStr() const; | 115 | QString getTimeZoneStr() const; |
116 | /** | 116 | /** |
117 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal | 117 | Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal |
118 | values). | 118 | values). |
119 | */ | 119 | */ |
120 | void setTimeZoneId( const QString & ); | 120 | void setTimeZoneId( const QString & ); |
121 | /** | 121 | /** |
122 | Return time zone id. | 122 | Return time zone id. |
123 | */ | 123 | */ |
124 | QString timeZoneId() const; | 124 | QString timeZoneId() const; |
125 | /** | 125 | /** |
126 | Use local time, not UTC or a time zone. | 126 | Use local time, not UTC or a time zone. |
127 | */ | 127 | */ |
128 | void setLocalTime(); | 128 | void setLocalTime(); |
129 | /** | 129 | /** |
130 | Return whether local time is being used. | 130 | Return whether local time is being used. |
131 | */ | 131 | */ |
132 | bool isLocalTime() const; | 132 | bool isLocalTime() const; |
133 | 133 | ||
134 | /** | 134 | /** |
135 | Add an incidence to calendar. | 135 | Add an incidence to calendar. |
136 | 136 | ||
137 | @return true on success, false on error. | 137 | @return true on success, false on error. |
138 | */ | 138 | */ |
139 | virtual bool addIncidence( Incidence * ); | 139 | virtual bool addIncidence( Incidence * ); |
140 | /** | 140 | /** |
141 | Return filtered list of all incidences of this calendar. | 141 | Return filtered list of all incidences of this calendar. |
142 | */ | 142 | */ |
143 | virtual QPtrList<Incidence> incidences(); | 143 | virtual QPtrList<Incidence> incidences(); |
144 | 144 | ||
145 | /** | 145 | /** |
146 | Return unfiltered list of all incidences of this calendar. | 146 | Return unfiltered list of all incidences of this calendar. |
147 | */ | 147 | */ |
148 | virtual QPtrList<Incidence> rawIncidences(); | 148 | virtual QPtrList<Incidence> rawIncidences(); |
149 | 149 | ||
150 | /** | 150 | /** |
151 | Adds a Event to this calendar object. | 151 | Adds a Event to this calendar object. |
152 | @param anEvent a pointer to the event to add | 152 | @param anEvent a pointer to the event to add |
153 | 153 | ||
154 | @return true on success, false on error. | 154 | @return true on success, false on error. |
155 | */ | 155 | */ |
156 | virtual bool addEventNoDup( Event *event ) = 0; | 156 | virtual bool addEventNoDup( Event *event ) = 0; |
157 | virtual bool addAnniversaryNoDup( Event *event ) = 0; | 157 | virtual bool addAnniversaryNoDup( Event *event ) = 0; |
158 | virtual bool addEvent( Event *anEvent ) = 0; | 158 | virtual bool addEvent( Event *anEvent ) = 0; |
159 | /** | 159 | /** |
160 | Delete event from calendar. | 160 | Delete event from calendar. |
161 | */ | 161 | */ |
162 | virtual void deleteEvent( Event * ) = 0; | 162 | virtual void deleteEvent( Event * ) = 0; |
163 | /** | 163 | /** |
164 | Retrieves an event on the basis of the unique string ID. | 164 | Retrieves an event on the basis of the unique string ID. |
165 | */ | 165 | */ |
166 | virtual Event *event( const QString &UniqueStr ) = 0; | 166 | virtual Event *event( const QString &UniqueStr ) = 0; |
167 | virtual Event *event( QString, QString ) = 0; | 167 | virtual Event *event( QString, QString ) = 0; |
168 | /** | 168 | /** |
169 | Builds and then returns a list of all events that match for the | 169 | Builds and then returns a list of all events that match for the |
170 | date specified. useful for dayView, etc. etc. | 170 | date specified. useful for dayView, etc. etc. |
171 | The calendar filter is applied. | 171 | The calendar filter is applied. |
172 | */ | 172 | */ |
173 | QPtrList<Event> events( const QDate &date, bool sorted = false); | 173 | QPtrList<Event> events( const QDate &date, bool sorted = false); |
174 | /** | 174 | /** |
175 | Get events, which occur on the given date. | 175 | Get events, which occur on the given date. |
176 | The calendar filter is applied. | 176 | The calendar filter is applied. |
177 | */ | 177 | */ |
178 | QPtrList<Event> events( const QDateTime &qdt ); | 178 | QPtrList<Event> events( const QDateTime &qdt ); |
179 | /** | 179 | /** |
180 | Get events in a range of dates. If inclusive is set to true, only events | 180 | Get events in a range of dates. If inclusive is set to true, only events |
181 | are returned, which are completely included in the range. | 181 | are returned, which are completely included in the range. |
182 | The calendar filter is applied. | 182 | The calendar filter is applied. |
183 | */ | 183 | */ |
184 | QPtrList<Event> events( const QDate &start, const QDate &end, | 184 | QPtrList<Event> events( const QDate &start, const QDate &end, |
185 | bool inclusive = false); | 185 | bool inclusive = false); |
186 | /** | 186 | /** |
187 | Return filtered list of all events in calendar. | 187 | Return filtered list of all events in calendar. |
188 | */ | 188 | */ |
189 | virtual QPtrList<Event> events(); | 189 | virtual QPtrList<Event> events(); |
190 | /** | 190 | /** |
191 | Return unfiltered list of all events in calendar. | 191 | Return unfiltered list of all events in calendar. |
192 | */ | 192 | */ |
193 | virtual QPtrList<Event> rawEvents() = 0; | 193 | virtual QPtrList<Event> rawEvents() = 0; |
194 | 194 | ||
195 | /** | 195 | /** |
196 | Add a todo to the todolist. | 196 | Add a todo to the todolist. |
197 | 197 | ||
198 | @return true on success, false on error. | 198 | @return true on success, false on error. |
199 | */ | 199 | */ |
200 | virtual bool addTodo( Todo *todo ) = 0; | 200 | virtual bool addTodo( Todo *todo ) = 0; |
201 | virtual bool addTodoNoDup( Todo *todo ) = 0; | 201 | virtual bool addTodoNoDup( Todo *todo ) = 0; |
202 | /** | 202 | /** |
203 | Remove a todo from the todolist. | 203 | Remove a todo from the todolist. |
204 | */ | 204 | */ |
205 | virtual void deleteTodo( Todo * ) = 0; | 205 | virtual void deleteTodo( Todo * ) = 0; |
206 | virtual void deleteJournal( Journal * ) = 0; | 206 | virtual void deleteJournal( Journal * ) = 0; |
207 | /** | 207 | /** |
208 | Return filterd list of todos. | 208 | Return filterd list of todos. |
209 | */ | 209 | */ |
210 | virtual QPtrList<Todo> todos(); | 210 | virtual QPtrList<Todo> todos(); |
211 | /** | 211 | /** |
212 | Searches todolist for an event with this unique string identifier, | 212 | Searches todolist for an event with this unique string identifier, |
213 | returns a pointer or null. | 213 | returns a pointer or null. |
214 | */ | 214 | */ |
215 | virtual Todo *todo( const QString &uid ) = 0; | 215 | virtual Todo *todo( const QString &uid ) = 0; |
216 | virtual Todo *todo( QString, QString ) = 0; | 216 | virtual Todo *todo( QString, QString ) = 0; |
217 | /** | 217 | /** |
218 | Returns list of todos due on the specified date. | 218 | Returns list of todos due on the specified date. |
219 | */ | 219 | */ |
220 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; | 220 | virtual QPtrList<Todo> todos( const QDate &date ) = 0; |
221 | /** | 221 | /** |
222 | Return unfiltered list of todos. | 222 | Return unfiltered list of todos. |
223 | */ | 223 | */ |
224 | virtual QPtrList<Todo> rawTodos() = 0; | 224 | virtual QPtrList<Todo> rawTodos() = 0; |
225 | 225 | ||
226 | /** | 226 | /** |
227 | Add a Journal entry to calendar. | 227 | Add a Journal entry to calendar. |
228 | 228 | ||
229 | @return true on success, false on error. | 229 | @return true on success, false on error. |
230 | */ | 230 | */ |
231 | virtual bool addJournal( Journal * ) = 0; | 231 | virtual bool addJournal( Journal * ) = 0; |
232 | /** | 232 | /** |
233 | Return Journal for given date. | 233 | Return Journal for given date. |
234 | */ | 234 | */ |
235 | virtual Journal *journal( const QDate & ) = 0; | 235 | virtual Journal *journal( const QDate & ) = 0; |
236 | /** | 236 | /** |
237 | Return Journal with given UID. | 237 | Return Journal with given UID. |
238 | */ | 238 | */ |
239 | virtual Journal *journal( const QString &UID ) = 0; | 239 | virtual Journal *journal( const QString &UID ) = 0; |
240 | /** | 240 | /** |
241 | Return list of all Journal entries. | 241 | Return list of all Journal entries. |
242 | */ | 242 | */ |
243 | virtual QPtrList<Journal> journals() = 0; | 243 | virtual QPtrList<Journal> journals() = 0; |
244 | 244 | ||
245 | /** | 245 | /** |
246 | Searches all incidence types for an incidence with this unique | 246 | Searches all incidence types for an incidence with this unique |
247 | string identifier, returns a pointer or null. | 247 | string identifier, returns a pointer or null. |
248 | */ | 248 | */ |
249 | Incidence* incidence( const QString&UID ); | 249 | Incidence* incidence( const QString&UID ); |
250 | 250 | ||
251 | /** | 251 | /** |
252 | Setup relations for an incidence. | 252 | Setup relations for an incidence. |
253 | */ | 253 | */ |
254 | virtual void setupRelations( Incidence * ); | 254 | virtual void setupRelations( Incidence * ); |
255 | /** | 255 | /** |
256 | Remove all relations to an incidence | 256 | Remove all relations to an incidence |
257 | */ | 257 | */ |
258 | virtual void removeRelations( Incidence * ); | 258 | virtual void removeRelations( Incidence * ); |
259 | 259 | ||
260 | /** | 260 | /** |
261 | Set calendar filter, which filters events for the events() functions. | 261 | Set calendar filter, which filters events for the events() functions. |
262 | The Filter object is owned by the caller. | 262 | The Filter object is owned by the caller. |