-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 | |||
@@ -10,96 +10,97 @@ | |||
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" ) ) { |
@@ -107,149 +108,146 @@ int main( int argc, char *argv[] ) | |||
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 | |||
@@ -712,97 +712,97 @@ void CalendarView::createPrinter() | |||
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; |
@@ -887,205 +887,204 @@ void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* t | |||
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 | ||
@@ -1136,98 +1135,100 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
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; |
@@ -3689,68 +3690,74 @@ 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 | |||
@@ -442,96 +442,97 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
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 | ||
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp index eeb5f48..52daaaa 100644 --- a/libkcal/calendar.cpp +++ b/libkcal/calendar.cpp | |||
@@ -204,110 +204,110 @@ void Calendar::setLocalTime() | |||
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 | ||
diff --git a/libkcal/calendar.h b/libkcal/calendar.h index d5294eb..b801186 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h | |||
@@ -22,97 +22,97 @@ | |||
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). |