-rw-r--r-- | korganizer/calendarview.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8d992b9..4b82aa8 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1,1603 +1,1605 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | 3 | ||
4 | Requires the Qt and KDE widget libraries, available at no cost at | 4 | Requires the Qt and KDE widget libraries, available at no cost at |
5 | http://www.troll.no and http://www.kde.org respectively | 5 | http://www.troll.no and http://www.kde.org respectively |
6 | 6 | ||
7 | Copyright (c) 1997, 1998, 1999 | 7 | Copyright (c) 1997, 1998, 1999 |
8 | Preston Brown (preton.brown@yale.edu) | 8 | Preston Brown (preton.brown@yale.edu) |
9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) | 9 | Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) |
10 | Ian Dawes (iadawes@globalserve.net) | 10 | Ian Dawes (iadawes@globalserve.net) |
11 | Laszlo Boloni (boloni@cs.purdue.edu) | 11 | Laszlo Boloni (boloni@cs.purdue.edu) |
12 | 12 | ||
13 | Copyright (c) 2000, 2001, 2002 | 13 | Copyright (c) 2000, 2001, 2002 |
14 | Cornelius Schumacher <schumacher@kde.org> | 14 | Cornelius Schumacher <schumacher@kde.org> |
15 | 15 | ||
16 | This program is free software; you can redistribute it and/or modify | 16 | This program is free software; you can redistribute it and/or modify |
17 | it under the terms of the GNU General Public License as published by | 17 | it under the terms of the GNU General Public License as published by |
18 | the Free Software Foundation; either version 2 of the License, or | 18 | the Free Software Foundation; either version 2 of the License, or |
19 | (at your option) any later version. | 19 | (at your option) any later version. |
20 | 20 | ||
21 | This program is distributed in the hope that it will be useful, | 21 | This program is distributed in the hope that it will be useful, |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the | 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the |
24 | GNU General Public License for more details. | 24 | GNU General Public License for more details. |
25 | 25 | ||
26 | You should have received a copy of the GNU General Public License | 26 | You should have received a copy of the GNU General Public License |
27 | along with this program; if not, write to the Free Software | 27 | along with this program; if not, write to the Free Software |
28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 28 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
32 | 32 | ||
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qradiobutton.h> | 34 | #include <qradiobutton.h> |
35 | #include <qbuttongroup.h> | 35 | #include <qbuttongroup.h> |
36 | #include <qlayout.h> | 36 | #include <qlayout.h> |
37 | #include <qclipboard.h> | 37 | #include <qclipboard.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qprogressbar.h> | 40 | #include <qprogressbar.h> |
41 | #include <qmultilineedit.h> | 41 | #include <qmultilineedit.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | #include <qptrlist.h> | 44 | #include <qptrlist.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qdir.h> | 48 | #include <qdir.h> |
49 | #ifndef KORG_NOSPLITTER | 49 | #ifndef KORG_NOSPLITTER |
50 | #include <qsplitter.h> | 50 | #include <qsplitter.h> |
51 | #endif | 51 | #endif |
52 | 52 | ||
53 | #include <kglobal.h> | 53 | #include <kglobal.h> |
54 | #include <kdebug.h> | 54 | #include <kdebug.h> |
55 | #include <kstandarddirs.h> | 55 | #include <kstandarddirs.h> |
56 | #include <kfiledialog.h> | 56 | #include <kfiledialog.h> |
57 | #include <kmessagebox.h> | 57 | #include <kmessagebox.h> |
58 | #include <knotifyclient.h> | 58 | #include <knotifyclient.h> |
59 | #include <kconfig.h> | 59 | #include <kconfig.h> |
60 | 60 | ||
61 | #include <libkdepim/ksyncprefsdialog.h> | 61 | #include <libkdepim/ksyncprefsdialog.h> |
62 | #include <krun.h> | 62 | #include <krun.h> |
63 | #include <kdirwatch.h> | 63 | #include <kdirwatch.h> |
64 | #include <libkdepim/kdatepicker.h> | 64 | #include <libkdepim/kdatepicker.h> |
65 | #include <libkdepim/ksyncprofile.h> | 65 | #include <libkdepim/ksyncprofile.h> |
66 | #include <libkdepim/kpimglobalprefs.h> | 66 | #include <libkdepim/kpimglobalprefs.h> |
67 | 67 | ||
68 | #include <libkcal/vcaldrag.h> | 68 | #include <libkcal/vcaldrag.h> |
69 | #include <libkcal/icaldrag.h> | 69 | #include <libkcal/icaldrag.h> |
70 | #include <libkcal/icalformat.h> | 70 | #include <libkcal/icalformat.h> |
71 | #include <libkcal/vcalformat.h> | 71 | #include <libkcal/vcalformat.h> |
72 | #include <libkcal/scheduler.h> | 72 | #include <libkcal/scheduler.h> |
73 | #include <libkcal/calendarlocal.h> | 73 | #include <libkcal/calendarlocal.h> |
74 | #include <libkcal/journal.h> | 74 | #include <libkcal/journal.h> |
75 | #include <libkcal/calfilter.h> | 75 | #include <libkcal/calfilter.h> |
76 | #include <libkcal/attendee.h> | 76 | #include <libkcal/attendee.h> |
77 | #include <libkcal/dndfactory.h> | 77 | #include <libkcal/dndfactory.h> |
78 | #include <libkcal/freebusy.h> | 78 | #include <libkcal/freebusy.h> |
79 | #include <libkcal/filestorage.h> | 79 | #include <libkcal/filestorage.h> |
80 | #include <libkcal/calendarresources.h> | 80 | #include <libkcal/calendarresources.h> |
81 | #include <libkcal/qtopiaformat.h> | 81 | #include <libkcal/qtopiaformat.h> |
82 | #include "../kalarmd/alarmdialog.h" | 82 | #include "../kalarmd/alarmdialog.h" |
83 | 83 | ||
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | #include <libkcal/sharpformat.h> | 85 | #include <libkcal/sharpformat.h> |
86 | #include <externalapphandler.h> | 86 | #include <externalapphandler.h> |
87 | #endif | 87 | #endif |
88 | #include <libkcal/phoneformat.h> | 88 | #include <libkcal/phoneformat.h> |
89 | #ifndef KORG_NOMAIL | 89 | #ifndef KORG_NOMAIL |
90 | #include "komailclient.h" | 90 | #include "komailclient.h" |
91 | #endif | 91 | #endif |
92 | #ifndef KORG_NOPRINTER | 92 | #ifndef KORG_NOPRINTER |
93 | #include "calprinter.h" | 93 | #include "calprinter.h" |
94 | #endif | 94 | #endif |
95 | #ifndef KORG_NOPLUGINS | 95 | #ifndef KORG_NOPLUGINS |
96 | #include "kocore.h" | 96 | #include "kocore.h" |
97 | #endif | 97 | #endif |
98 | #include "koeventeditor.h" | 98 | #include "koeventeditor.h" |
99 | #include "kotodoeditor.h" | 99 | #include "kotodoeditor.h" |
100 | #include "koprefs.h" | 100 | #include "koprefs.h" |
101 | #include "koeventviewerdialog.h" | 101 | #include "koeventviewerdialog.h" |
102 | #include "publishdialog.h" | 102 | #include "publishdialog.h" |
103 | #include "kofilterview.h" | 103 | #include "kofilterview.h" |
104 | #include "koglobals.h" | 104 | #include "koglobals.h" |
105 | #include "koviewmanager.h" | 105 | #include "koviewmanager.h" |
106 | #include "koagendaview.h" | 106 | #include "koagendaview.h" |
107 | #include "kodialogmanager.h" | 107 | #include "kodialogmanager.h" |
108 | #include "outgoingdialog.h" | 108 | #include "outgoingdialog.h" |
109 | #include "incomingdialog.h" | 109 | #include "incomingdialog.h" |
110 | #include "datenavigatorcontainer.h" | 110 | #include "datenavigatorcontainer.h" |
111 | #include "statusdialog.h" | 111 | #include "statusdialog.h" |
112 | #include "kdatenavigator.h" | 112 | #include "kdatenavigator.h" |
113 | #include "kotodoview.h" | 113 | #include "kotodoview.h" |
114 | #include "datenavigator.h" | 114 | #include "datenavigator.h" |
115 | #include "resourceview.h" | 115 | #include "resourceview.h" |
116 | #include "navigatorbar.h" | 116 | #include "navigatorbar.h" |
117 | #include "searchdialog.h" | 117 | #include "searchdialog.h" |
118 | #include "mainwindow.h" | 118 | #include "mainwindow.h" |
119 | 119 | ||
120 | #include "calendarview.h" | 120 | #include "calendarview.h" |
121 | #ifndef DESKTOP_VERSION | 121 | #ifndef DESKTOP_VERSION |
122 | #include <qtopia/alarmserver.h> | 122 | #include <qtopia/alarmserver.h> |
123 | #endif | 123 | #endif |
124 | #ifndef _WIN32_ | 124 | #ifndef _WIN32_ |
125 | #include <stdlib.h> | 125 | #include <stdlib.h> |
126 | #include <stdio.h> | 126 | #include <stdio.h> |
127 | #include <unistd.h> | 127 | #include <unistd.h> |
128 | #else | 128 | #else |
129 | #include <qprocess.h> | 129 | #include <qprocess.h> |
130 | #endif | 130 | #endif |
131 | 131 | ||
132 | #ifdef DESKTOP_VERSION | 132 | #ifdef DESKTOP_VERSION |
133 | #include <kabc/stdaddressbook.h> | 133 | #include <kabc/stdaddressbook.h> |
134 | #endif | 134 | #endif |
135 | using namespace KOrg; | 135 | using namespace KOrg; |
136 | using namespace KCal; | 136 | using namespace KCal; |
137 | extern int globalFlagBlockAgenda; | 137 | extern int globalFlagBlockAgenda; |
138 | extern int globalFlagBlockStartup; | 138 | extern int globalFlagBlockStartup; |
139 | 139 | ||
140 | 140 | ||
141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) | 141 | MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) |
142 | 142 | ||
143 | { | 143 | { |
144 | mAlarms = alarms; | 144 | mAlarms = alarms; |
145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); | 145 | viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); |
146 | QString mText = "<table width=\"100%\">\n"; | 146 | QString mText = "<table width=\"100%\">\n"; |
147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 147 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
148 | #ifdef DESKTOP_VERSION | 148 | #ifdef DESKTOP_VERSION |
149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; | 149 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; |
150 | #else | 150 | #else |
151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; | 151 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; |
152 | #endif | 152 | #endif |
153 | // mText += "<img src=\""; | 153 | // mText += "<img src=\""; |
154 | // mText += ipath; | 154 | // mText += ipath; |
155 | // mText += "\">"; | 155 | // mText += "\">"; |
156 | //mEventDate = QDate::currentDate(); | 156 | //mEventDate = QDate::currentDate(); |
157 | #ifdef DESKTOP_VERSION | 157 | #ifdef DESKTOP_VERSION |
158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; | 158 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; |
159 | #else | 159 | #else |
160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; | 160 | mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; |
161 | #endif | 161 | #endif |
162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 162 | //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
163 | 163 | ||
164 | Incidence * inc = getNextInc( start ); | 164 | Incidence * inc = getNextInc( start ); |
165 | int time = 0; | 165 | int time = 0; |
166 | //mText += "<table>"; | 166 | //mText += "<table>"; |
167 | while ( inc ) { | 167 | while ( inc ) { |
168 | QDateTime dt ; | 168 | QDateTime dt ; |
169 | QString tempText = "<a "; | 169 | QString tempText = "<a "; |
170 | bool ok; | 170 | bool ok; |
171 | dt = inc->getNextOccurence( start, &ok ); | 171 | dt = inc->getNextOccurence( start, &ok ); |
172 | if ( !ok ) continue; | 172 | if ( !ok ) continue; |
173 | if ( inc->typeID() == eventID ) { | 173 | if ( inc->typeID() == eventID ) { |
174 | tempText += "href=\"event:"; | 174 | tempText += "href=\"event:"; |
175 | } else if ( inc->typeID() == todoID ) { | 175 | } else if ( inc->typeID() == todoID ) { |
176 | tempText += "href=\"todo:"; | 176 | tempText += "href=\"todo:"; |
177 | } | 177 | } |
178 | tempText += inc->uid() + "\">"; | 178 | tempText += inc->uid() + "\">"; |
179 | if ( inc->typeID() == todoID ) | 179 | if ( inc->typeID() == todoID ) |
180 | tempText += i18n("Todo: "); | 180 | tempText += i18n("Todo: "); |
181 | if ( inc->summary().length() > 0 ) | 181 | if ( inc->summary().length() > 0 ) |
182 | tempText += inc->summary(); | 182 | tempText += inc->summary(); |
183 | else | 183 | else |
184 | tempText += i18n("-no summary-"); | 184 | tempText += i18n("-no summary-"); |
185 | QString timestr; | 185 | QString timestr; |
186 | if (!inc->doesFloat()) | 186 | if (!inc->doesFloat()) |
187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; | 187 | timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; |
188 | else | 188 | else |
189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; | 189 | timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; |
190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { | 190 | if ( dt.date() < QDate::currentDate() && time == 0 ) { |
191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; | 191 | mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; |
192 | mText += "<table>"; | 192 | mText += "<table>"; |
193 | time = 1; | 193 | time = 1; |
194 | } | 194 | } |
195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { | 195 | if ( dt.date() == QDate::currentDate() && time <= 1 ) { |
196 | if ( time > 0 ) | 196 | if ( time > 0 ) |
197 | mText +="</table>"; | 197 | mText +="</table>"; |
198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; | 198 | mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; |
199 | mText += "<table>"; | 199 | mText += "<table>"; |
200 | time = 2; | 200 | time = 2; |
201 | 201 | ||
202 | } | 202 | } |
203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { | 203 | if ( dt.date() > QDate::currentDate() && time <= 2 ) { |
204 | if ( time > 0 ) | 204 | if ( time > 0 ) |
205 | mText +="</table>"; | 205 | mText +="</table>"; |
206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; | 206 | mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; |
207 | mText += "<table>"; | 207 | mText += "<table>"; |
208 | time = 3; | 208 | time = 3; |
209 | } | 209 | } |
210 | mText +="<tr><td><b>"; | 210 | mText +="<tr><td><b>"; |
211 | mText += timestr; | 211 | mText += timestr; |
212 | mText += "</b></td><td>"; | 212 | mText += "</b></td><td>"; |
213 | mText += tempText; | 213 | mText += tempText; |
214 | mText += "</td></tr>\n"; | 214 | mText += "</td></tr>\n"; |
215 | inc = getNextInc( start ); | 215 | inc = getNextInc( start ); |
216 | } | 216 | } |
217 | mText +="</table>"; | 217 | mText +="</table>"; |
218 | setText( mText ); | 218 | setText( mText ); |
219 | } | 219 | } |
220 | 220 | ||
221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() | 221 | MissedAlarmTextBrowser::~MissedAlarmTextBrowser() |
222 | { | 222 | { |
223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); | 223 | //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); |
224 | } | 224 | } |
225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) | 225 | Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) |
226 | { | 226 | { |
227 | QDateTime dt ; | 227 | QDateTime dt ; |
228 | Incidence * retInc; | 228 | Incidence * retInc; |
229 | Incidence * inc = mAlarms.first(); | 229 | Incidence * inc = mAlarms.first(); |
230 | if ( inc == 0 ) | 230 | if ( inc == 0 ) |
231 | return 0; | 231 | return 0; |
232 | bool ok; | 232 | bool ok; |
233 | dt = inc->getNextOccurence( start, &ok ); | 233 | dt = inc->getNextOccurence( start, &ok ); |
234 | if ( ! ok ) return 0; | 234 | if ( ! ok ) return 0; |
235 | QDateTime dtn ; | 235 | QDateTime dtn ; |
236 | retInc = inc; | 236 | retInc = inc; |
237 | inc = mAlarms.next(); | 237 | inc = mAlarms.next(); |
238 | while ( inc ) { | 238 | while ( inc ) { |
239 | dtn = inc->getNextOccurence( start, &ok ); | 239 | dtn = inc->getNextOccurence( start, &ok ); |
240 | if ( ! ok ) return 0; | 240 | if ( ! ok ) return 0; |
241 | if ( dtn < dt ) { | 241 | if ( dtn < dt ) { |
242 | dt = dtn; | 242 | dt = dtn; |
243 | retInc = inc; | 243 | retInc = inc; |
244 | } | 244 | } |
245 | inc = mAlarms.next(); | 245 | inc = mAlarms.next(); |
246 | } | 246 | } |
247 | mAlarms.remove( retInc ); | 247 | mAlarms.remove( retInc ); |
248 | return retInc; | 248 | return retInc; |
249 | 249 | ||
250 | } | 250 | } |
251 | void MissedAlarmTextBrowser::setSource(const QString & n) | 251 | void MissedAlarmTextBrowser::setSource(const QString & n) |
252 | { | 252 | { |
253 | if (n.startsWith("event:")) { | 253 | if (n.startsWith("event:")) { |
254 | #ifdef DESKTOP_VERSION | 254 | #ifdef DESKTOP_VERSION |
255 | emit showIncidence(n.mid(8)); | 255 | emit showIncidence(n.mid(8)); |
256 | #else | 256 | #else |
257 | emit showIncidence(n.mid(6)); | 257 | emit showIncidence(n.mid(6)); |
258 | #endif | 258 | #endif |
259 | return; | 259 | return; |
260 | } else if (n.startsWith("todo:")) { | 260 | } else if (n.startsWith("todo:")) { |
261 | #ifdef DESKTOP_VERSION | 261 | #ifdef DESKTOP_VERSION |
262 | emit showIncidence(n.mid(7)); | 262 | emit showIncidence(n.mid(7)); |
263 | #else | 263 | #else |
264 | emit showIncidence(n.mid(5)); | 264 | emit showIncidence(n.mid(5)); |
265 | #endif | 265 | #endif |
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | 269 | ||
270 | 270 | ||
271 | class KOBeamPrefs : public QDialog | 271 | class KOBeamPrefs : public QDialog |
272 | { | 272 | { |
273 | public: | 273 | public: |
274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : | 274 | KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : |
275 | QDialog( parent, name, true ) | 275 | QDialog( parent, name, true ) |
276 | { | 276 | { |
277 | setCaption( i18n("Beam Options") ); | 277 | setCaption( i18n("Beam Options") ); |
278 | QVBoxLayout* lay = new QVBoxLayout( this ); | 278 | QVBoxLayout* lay = new QVBoxLayout( this ); |
279 | lay->setSpacing( 3 ); | 279 | lay->setSpacing( 3 ); |
280 | lay->setMargin( 3 ); | 280 | lay->setMargin( 3 ); |
281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); | 281 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); |
282 | lay->addWidget( format ); | 282 | lay->addWidget( format ); |
283 | format->setExclusive ( true ) ; | 283 | format->setExclusive ( true ) ; |
284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); | 284 | QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); |
285 | lay->addWidget( time ); time->setExclusive ( true ) ; | 285 | lay->addWidget( time ); time->setExclusive ( true ) ; |
286 | vcal = new QRadioButton(" vCalendar ", format ); | 286 | vcal = new QRadioButton(" vCalendar ", format ); |
287 | ical = new QRadioButton(" iCalendar ", format ); | 287 | ical = new QRadioButton(" iCalendar ", format ); |
288 | vcal->setChecked( true ); | 288 | vcal->setChecked( true ); |
289 | tz = new QRadioButton(i18n(" With timezone "), time ); | 289 | tz = new QRadioButton(i18n(" With timezone "), time ); |
290 | local = new QRadioButton(i18n(" Local time "), time ); | 290 | local = new QRadioButton(i18n(" Local time "), time ); |
291 | tz->setChecked( true ); | 291 | tz->setChecked( true ); |
292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); | 292 | QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); |
293 | lay->addWidget( ok ); | 293 | lay->addWidget( ok ); |
294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 294 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
295 | lay->addWidget( cancel ); | 295 | lay->addWidget( cancel ); |
296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 296 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 297 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
298 | resize( 200, 200 ); | 298 | resize( 200, 200 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | bool beamVcal() { return vcal->isChecked(); } | 301 | bool beamVcal() { return vcal->isChecked(); } |
302 | bool beamLocal() { return local->isChecked(); } | 302 | bool beamLocal() { return local->isChecked(); } |
303 | private: | 303 | private: |
304 | QRadioButton* vcal, *ical, *local, *tz; | 304 | QRadioButton* vcal, *ical, *local, *tz; |
305 | }; | 305 | }; |
306 | class KOCatPrefs : public QDialog | 306 | class KOCatPrefs : public QDialog |
307 | { | 307 | { |
308 | public: | 308 | public: |
309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : | 309 | KOCatPrefs( QWidget *parent=0, const char *name=0 ) : |
310 | QDialog( parent, name, true ) | 310 | QDialog( parent, name, true ) |
311 | { | 311 | { |
312 | setCaption( i18n("Manage new Categories") ); | 312 | setCaption( i18n("Manage new Categories") ); |
313 | QVBoxLayout* lay = new QVBoxLayout( this ); | 313 | QVBoxLayout* lay = new QVBoxLayout( this ); |
314 | lay->setSpacing( 3 ); | 314 | lay->setSpacing( 3 ); |
315 | lay->setMargin( 3 ); | 315 | lay->setMargin( 3 ); |
316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); | 316 | QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); |
317 | lay->addWidget( lab ); | 317 | lay->addWidget( lab ); |
318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); | 318 | QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); |
319 | lay->addWidget( format ); | 319 | lay->addWidget( format ); |
320 | format->setExclusive ( true ) ; | 320 | format->setExclusive ( true ) ; |
321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); | 321 | addCatBut = new QRadioButton(i18n("Add to category list"), format ); |
322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); | 322 | new QRadioButton(i18n("Remove from Events/Todos"), format ); |
323 | addCatBut->setChecked( true ); | 323 | addCatBut->setChecked( true ); |
324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); | 324 | QPushButton * ok = new QPushButton( i18n("OK"), this ); |
325 | lay->addWidget( ok ); | 325 | lay->addWidget( ok ); |
326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); | 326 | QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); |
327 | lay->addWidget( cancel ); | 327 | lay->addWidget( cancel ); |
328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); | 328 | connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); |
329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); | 329 | connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); |
330 | resize( 200, 200 ); | 330 | resize( 200, 200 ); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool addCat() { return addCatBut->isChecked(); } | 333 | bool addCat() { return addCatBut->isChecked(); } |
334 | private: | 334 | private: |
335 | QRadioButton* addCatBut; | 335 | QRadioButton* addCatBut; |
336 | }; | 336 | }; |
337 | 337 | ||
338 | 338 | ||
339 | 339 | ||
340 | CalendarView::CalendarView( CalendarResources *calendar, | 340 | CalendarView::CalendarView( CalendarResources *calendar, |
341 | QWidget *parent, const char *name ) | 341 | QWidget *parent, const char *name ) |
342 | : CalendarViewBase( parent, name ), | 342 | : CalendarViewBase( parent, name ), |
343 | mCalendar( calendar ), | 343 | mCalendar( calendar ), |
344 | mResourceManager( calendar->resourceManager() ) | 344 | mResourceManager( calendar->resourceManager() ) |
345 | { | 345 | { |
346 | 346 | ||
347 | mEventEditor = 0; | 347 | mEventEditor = 0; |
348 | mTodoEditor = 0; | 348 | mTodoEditor = 0; |
349 | 349 | ||
350 | init(); | 350 | init(); |
351 | } | 351 | } |
352 | 352 | ||
353 | CalendarView::CalendarView( Calendar *calendar, | 353 | CalendarView::CalendarView( Calendar *calendar, |
354 | QWidget *parent, const char *name ) | 354 | QWidget *parent, const char *name ) |
355 | : CalendarViewBase( parent, name ), | 355 | : CalendarViewBase( parent, name ), |
356 | mCalendar( calendar ), | 356 | mCalendar( calendar ), |
357 | mResourceManager( 0 ) | 357 | mResourceManager( 0 ) |
358 | { | 358 | { |
359 | 359 | ||
360 | mEventEditor = 0; | 360 | mEventEditor = 0; |
361 | mTodoEditor = 0; | 361 | mTodoEditor = 0; |
362 | init(); | 362 | init(); |
363 | } | 363 | } |
364 | 364 | ||
365 | void CalendarView::init() | 365 | void CalendarView::init() |
366 | { | 366 | { |
367 | mNextAlarmDateTime = QDateTime::currentDateTime(); | 367 | mNextAlarmDateTime = QDateTime::currentDateTime(); |
368 | setFocusPolicy ( NoFocus ); | 368 | setFocusPolicy ( NoFocus ); |
369 | mViewerCallerIsSearchDialog = false; | 369 | mViewerCallerIsSearchDialog = false; |
370 | mBlockShowDates = false; | 370 | mBlockShowDates = false; |
371 | beamDialog = new KOBeamPrefs(); | 371 | beamDialog = new KOBeamPrefs(); |
372 | mDatePickerMode = 0; | 372 | mDatePickerMode = 0; |
373 | mCurrentSyncDevice = ""; | 373 | mCurrentSyncDevice = ""; |
374 | writeLocale(); | 374 | writeLocale(); |
375 | mViewManager = new KOViewManager( this ); | 375 | mViewManager = new KOViewManager( this ); |
376 | mDialogManager = new KODialogManager( this ); | 376 | mDialogManager = new KODialogManager( this ); |
377 | mEventViewerDialog = 0; | 377 | mEventViewerDialog = 0; |
378 | mModified = false; | 378 | mModified = false; |
379 | mReadOnly = false; | 379 | mReadOnly = false; |
380 | mSelectedIncidence = 0; | 380 | mSelectedIncidence = 0; |
381 | mCalPrinter = 0; | 381 | mCalPrinter = 0; |
382 | mFilters.setAutoDelete(true); | 382 | mFilters.setAutoDelete(true); |
383 | 383 | ||
384 | mCalendar->registerObserver( this ); | 384 | mCalendar->registerObserver( this ); |
385 | // TODO: Make sure that view is updated, when calendar is changed. | 385 | // TODO: Make sure that view is updated, when calendar is changed. |
386 | 386 | ||
387 | mStorage = new FileStorage( mCalendar ); | 387 | mStorage = new FileStorage( mCalendar ); |
388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); | 388 | mNavigator = new DateNavigator( this, "datevav", mViewManager ); |
389 | 389 | ||
390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); | 390 | QBoxLayout *topLayout = (QBoxLayout*)layout(); |
391 | #ifndef KORG_NOSPLITTER | 391 | #ifndef KORG_NOSPLITTER |
392 | // create the main layout frames. | 392 | // create the main layout frames. |
393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); | 393 | mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); |
394 | topLayout->addWidget(mPanner); | 394 | topLayout->addWidget(mPanner); |
395 | 395 | ||
396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, | 396 | mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, |
397 | "CalendarView::LeftFrame"); | 397 | "CalendarView::LeftFrame"); |
398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); | 398 | mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); |
399 | 399 | ||
400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, | 400 | mDateNavigator = new DateNavigatorContainer( mLeftSplitter, |
401 | "CalendarView::DateNavigator" ); | 401 | "CalendarView::DateNavigator" ); |
402 | 402 | ||
403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); | 403 | mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); |
404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); | 404 | mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); |
405 | mTodoList->setNavigator( mNavigator ); | 405 | mTodoList->setNavigator( mNavigator ); |
406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); | 406 | mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); |
407 | 407 | ||
408 | #ifdef KORG_NORESOURCEVIEW | 408 | #ifdef KORG_NORESOURCEVIEW |
409 | mResourceView = 0; | 409 | mResourceView = 0; |
410 | #else | 410 | #else |
411 | if ( mResourceManager ) { | 411 | if ( mResourceManager ) { |
412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); | 412 | mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); |
413 | mResourceView->updateView(); | 413 | mResourceView->updateView(); |
414 | connect( mResourceView, SIGNAL( resourcesChanged() ), | 414 | connect( mResourceView, SIGNAL( resourcesChanged() ), |
415 | SLOT( updateView() ) ); | 415 | SLOT( updateView() ) ); |
416 | } else { | 416 | } else { |
417 | mResourceView = 0; | 417 | mResourceView = 0; |
418 | } | 418 | } |
419 | #endif | 419 | #endif |
420 | QWidget *rightBox = new QWidget( mPanner ); | 420 | QWidget *rightBox = new QWidget( mPanner ); |
421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 421 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
422 | 422 | ||
423 | mRightFrame = new QWidgetStack( rightBox ); | 423 | mRightFrame = new QWidgetStack( rightBox ); |
424 | rightLayout->addWidget( mRightFrame, 1 ); | 424 | rightLayout->addWidget( mRightFrame, 1 ); |
425 | 425 | ||
426 | mLeftFrame = mLeftSplitter; | 426 | mLeftFrame = mLeftSplitter; |
427 | #else | 427 | #else |
428 | //QWidget *mainBox = new QWidget( this ); | 428 | //QWidget *mainBox = new QWidget( this ); |
429 | //QWidget *leftFrame = new QWidget( mainBox ); | 429 | //QWidget *leftFrame = new QWidget( mainBox ); |
430 | //QBoxLayout * mainBoxLayout; | 430 | //QBoxLayout * mainBoxLayout; |
431 | if ( KOPrefs::instance()->mVerticalScreen ) { | 431 | if ( KOPrefs::instance()->mVerticalScreen ) { |
432 | //mainBoxLayout = new QVBoxLayout(mainBox); | 432 | //mainBoxLayout = new QVBoxLayout(mainBox); |
433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); | 433 | //leftFrameLayout = new QHBoxLayout(leftFrame ); |
434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); | 434 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); |
435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 435 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; | 436 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; |
437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 437 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
438 | } else { | 438 | } else { |
439 | //mainBoxLayout = new QHBoxLayout(mainBox); | 439 | //mainBoxLayout = new QHBoxLayout(mainBox); |
440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); | 440 | //leftFrameLayout = new QVBoxLayout(leftFrame ); |
441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); | 441 | mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); |
442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); | 442 | mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); |
443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); | 443 | mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); |
444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 444 | mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
445 | } | 445 | } |
446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); | 446 | mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); |
447 | //QBoxLayout * leftFrameLayout; | 447 | //QBoxLayout * leftFrameLayout; |
448 | topLayout->addWidget( mMainFrame ); | 448 | topLayout->addWidget( mMainFrame ); |
449 | //mainBoxLayout->addWidget (mLeftFrame); | 449 | //mainBoxLayout->addWidget (mLeftFrame); |
450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, | 450 | mDateNavigator = new DateNavigatorContainer( mLeftFrame, |
451 | "CalendarView::DateNavigator" ); | 451 | "CalendarView::DateNavigator" ); |
452 | #if 0 | 452 | #if 0 |
453 | // FIXME | 453 | // FIXME |
454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, | 454 | mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, |
455 | "CalendarView::DateNavigator", QDate::currentDate()); | 455 | "CalendarView::DateNavigator", QDate::currentDate()); |
456 | #endif | 456 | #endif |
457 | // mDateNavigator->blockSignals( true ); | 457 | // mDateNavigator->blockSignals( true ); |
458 | //leftFrameLayout->addWidget( mDateNavigator ); | 458 | //leftFrameLayout->addWidget( mDateNavigator ); |
459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); | 459 | mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); |
460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); | 460 | mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); |
461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); | 461 | mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); |
462 | mTodoList->setNavigator( mNavigator ); | 462 | mTodoList->setNavigator( mNavigator ); |
463 | #if 0 | 463 | #if 0 |
464 | if ( QApplication::desktop()->width() < 480 ) { | 464 | if ( QApplication::desktop()->width() < 480 ) { |
465 | leftFrameLayout->addWidget(mFilterView); | 465 | leftFrameLayout->addWidget(mFilterView); |
466 | leftFrameLayout->addWidget(mTodoList, 2 ); | 466 | leftFrameLayout->addWidget(mTodoList, 2 ); |
467 | 467 | ||
468 | } else { | 468 | } else { |
469 | leftFrameLayout->addWidget(mTodoList,2 ); | 469 | leftFrameLayout->addWidget(mTodoList,2 ); |
470 | leftFrameLayout->addWidget(mFilterView ); | 470 | leftFrameLayout->addWidget(mFilterView ); |
471 | } | 471 | } |
472 | #endif | 472 | #endif |
473 | mFilterView->hide(); | 473 | mFilterView->hide(); |
474 | mCalEditView->hide(); | 474 | mCalEditView->hide(); |
475 | QWidget *rightBox = new QWidget( mMainFrame ); | 475 | QWidget *rightBox = new QWidget( mMainFrame ); |
476 | //mainBoxLayout->addWidget ( rightBox, 10 ); | 476 | //mainBoxLayout->addWidget ( rightBox, 10 ); |
477 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); | 477 | QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); |
478 | mRightFrame = new QWidgetStack( rightBox ); | 478 | mRightFrame = new QWidgetStack( rightBox ); |
479 | rightLayout->addWidget( mRightFrame, 10 ); | 479 | rightLayout->addWidget( mRightFrame, 10 ); |
480 | 480 | ||
481 | //mLeftFrame = (QWidget *)leftFrame; | 481 | //mLeftFrame = (QWidget *)leftFrame; |
482 | if ( KOPrefs::instance()->mVerticalScreen ) { | 482 | if ( KOPrefs::instance()->mVerticalScreen ) { |
483 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); | 483 | //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); |
484 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); | 484 | //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); |
485 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); | 485 | //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); |
486 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); | 486 | //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); |
487 | } else { | 487 | } else { |
488 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); | 488 | //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); |
489 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); | 489 | //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); |
490 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); | 490 | //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); |
491 | } | 491 | } |
492 | if ( !KOPrefs::instance()->mShowDateNavigator) | 492 | if ( !KOPrefs::instance()->mShowDateNavigator) |
493 | mDateNavigator->hide(); | 493 | mDateNavigator->hide(); |
494 | //qDebug("Calendarview Size %d %d ", width(), height()); | 494 | //qDebug("Calendarview Size %d %d ", width(), height()); |
495 | #endif | 495 | #endif |
496 | 496 | ||
497 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 497 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
498 | SLOT( showDates( const KCal::DateList & ) ) ); | 498 | SLOT( showDates( const KCal::DateList & ) ) ); |
499 | 499 | ||
500 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 500 | connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
501 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 501 | mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
502 | 502 | ||
503 | 503 | ||
504 | 504 | ||
505 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), | 505 | connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), |
506 | mViewManager, SLOT( showMonth( const QDate & ) ) ); | 506 | mViewManager, SLOT( showMonth( const QDate & ) ) ); |
507 | 507 | ||
508 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), | 508 | connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), |
509 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); | 509 | mNavigator, SLOT( selectWeek( const QDate & ) ) ); |
510 | 510 | ||
511 | connect( mDateNavigator, SIGNAL( goPrevYear() ), | 511 | connect( mDateNavigator, SIGNAL( goPrevYear() ), |
512 | mNavigator, SLOT( selectPreviousYear() ) ); | 512 | mNavigator, SLOT( selectPreviousYear() ) ); |
513 | connect( mDateNavigator, SIGNAL( goNextYear() ), | 513 | connect( mDateNavigator, SIGNAL( goNextYear() ), |
514 | mNavigator, SLOT( selectNextYear() ) ); | 514 | mNavigator, SLOT( selectNextYear() ) ); |
515 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), | 515 | connect( mDateNavigator, SIGNAL( goPrevMonth() ), |
516 | mNavigator, SLOT( selectPreviousMonth() ) ); | 516 | mNavigator, SLOT( selectPreviousMonth() ) ); |
517 | connect( mDateNavigator, SIGNAL( goNextMonth() ), | 517 | connect( mDateNavigator, SIGNAL( goNextMonth() ), |
518 | mNavigator, SLOT( selectNextMonth() ) ); | 518 | mNavigator, SLOT( selectNextMonth() ) ); |
519 | 519 | ||
520 | connect( mDateNavigator, SIGNAL( goPrevious() ), | 520 | connect( mDateNavigator, SIGNAL( goPrevious() ), |
521 | mNavigator, SLOT( selectPrevious() ) ); | 521 | mNavigator, SLOT( selectPrevious() ) ); |
522 | connect( mDateNavigator, SIGNAL( goNext() ), | 522 | connect( mDateNavigator, SIGNAL( goNext() ), |
523 | mNavigator, SLOT( selectNext() ) ); | 523 | mNavigator, SLOT( selectNext() ) ); |
524 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), | 524 | connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), |
525 | mNavigator, SLOT( slotMonthSelect( int ) ) ); | 525 | mNavigator, SLOT( slotMonthSelect( int ) ) ); |
526 | 526 | ||
527 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), | 527 | connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), |
528 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); | 528 | mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); |
529 | #if 0 | 529 | #if 0 |
530 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), | 530 | connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), |
531 | SLOT( incidenceAdded( Incidence *) ) ); | 531 | SLOT( incidenceAdded( Incidence *) ) ); |
532 | #endif | 532 | #endif |
533 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); | 533 | // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); |
534 | 534 | ||
535 | connect( this, SIGNAL( configChanged() ), | 535 | connect( this, SIGNAL( configChanged() ), |
536 | mDateNavigator, SLOT( updateConfig() ) ); | 536 | mDateNavigator, SLOT( updateConfig() ) ); |
537 | 537 | ||
538 | connect( mTodoList, SIGNAL( newTodoSignal() ), | 538 | connect( mTodoList, SIGNAL( newTodoSignal() ), |
539 | SLOT( newTodo() ) ); | 539 | SLOT( newTodo() ) ); |
540 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), | 540 | connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), |
541 | SLOT( newSubTodo( Todo * ) ) ); | 541 | SLOT( newSubTodo( Todo * ) ) ); |
542 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), | 542 | connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), |
543 | SLOT( editTodo( Todo * ) ) ); | 543 | SLOT( editTodo( Todo * ) ) ); |
544 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), | 544 | connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), |
545 | SLOT( showTodo( Todo *) ) ); | 545 | SLOT( showTodo( Todo *) ) ); |
546 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), | 546 | connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), |
547 | SLOT( deleteTodo( Todo *) ) ); | 547 | SLOT( deleteTodo( Todo *) ) ); |
548 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); | 548 | connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); |
549 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), | 549 | connect( mTodoList, SIGNAL( purgeCompletedSignal() ), |
550 | SLOT( purgeCompleted() ) ); | 550 | SLOT( purgeCompleted() ) ); |
551 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 551 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
552 | SIGNAL( todoModified( Todo *, int ) ) ); | 552 | SIGNAL( todoModified( Todo *, int ) ) ); |
553 | 553 | ||
554 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 554 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
555 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 555 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
556 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 556 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
557 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 557 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
558 | 558 | ||
559 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 559 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
560 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 560 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
561 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 561 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
562 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 562 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
563 | 563 | ||
564 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 564 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
565 | this, SLOT ( todo_unsub( Todo * ) ) ); | 565 | this, SLOT ( todo_unsub( Todo * ) ) ); |
566 | 566 | ||
567 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 567 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
568 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 568 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
569 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 569 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
570 | SLOT( updateTodo( Todo *, int ) ) ); | 570 | SLOT( updateTodo( Todo *, int ) ) ); |
571 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 571 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
572 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 572 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
573 | 573 | ||
574 | 574 | ||
575 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 575 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
576 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 576 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
577 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 577 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
578 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 578 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
579 | 579 | ||
580 | 580 | ||
581 | 581 | ||
582 | 582 | ||
583 | 583 | ||
584 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 584 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
585 | SLOT(checkClipboard())); | 585 | SLOT(checkClipboard())); |
586 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 586 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
587 | SLOT( processTodoListSelection( Incidence * ) ) ); | 587 | SLOT( processTodoListSelection( Incidence * ) ) ); |
588 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 588 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
589 | 589 | ||
590 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 590 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
591 | 591 | ||
592 | mDateFrame = new QVBox(0,0,WType_Popup); | 592 | mDateFrame = new QVBox(0,0,WType_Popup); |
593 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 593 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
594 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 594 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
595 | mDateFrame->setLineWidth(3); | 595 | mDateFrame->setLineWidth(3); |
596 | mDateFrame->hide(); | 596 | mDateFrame->hide(); |
597 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 597 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
598 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 598 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
599 | 599 | ||
600 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 600 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
601 | 601 | ||
602 | mEventEditor = mDialogManager->getEventEditor(); | 602 | mEventEditor = mDialogManager->getEventEditor(); |
603 | mTodoEditor = mDialogManager->getTodoEditor(); | 603 | mTodoEditor = mDialogManager->getTodoEditor(); |
604 | 604 | ||
605 | mFlagEditDescription = false; | 605 | mFlagEditDescription = false; |
606 | 606 | ||
607 | mSuspendTimer = new QTimer( this ); | 607 | mSuspendTimer = new QTimer( this ); |
608 | mAlarmTimer = new QTimer( this ); | 608 | mAlarmTimer = new QTimer( this ); |
609 | mRecheckAlarmTimer = new QTimer( this ); | 609 | mRecheckAlarmTimer = new QTimer( this ); |
610 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 610 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
611 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 611 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
612 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 612 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
613 | mAlarmDialog = new AlarmDialog( this ); | 613 | mAlarmDialog = new AlarmDialog( this ); |
614 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 614 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
615 | mAlarmDialog->setServerNotification( false ); | 615 | mAlarmDialog->setServerNotification( false ); |
616 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 616 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
617 | 617 | ||
618 | 618 | ||
619 | #ifndef DESKTOP_VERSION | 619 | #ifndef DESKTOP_VERSION |
620 | //US listen for arriving address resultsets | 620 | //US listen for arriving address resultsets |
621 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 621 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
622 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 622 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
623 | #endif | 623 | #endif |
624 | mDateNavigator->setCalendar( mCalendar ); | 624 | mDateNavigator->setCalendar( mCalendar ); |
625 | } | 625 | } |
626 | 626 | ||
627 | 627 | ||
628 | CalendarView::~CalendarView() | 628 | CalendarView::~CalendarView() |
629 | { | 629 | { |
630 | // kdDebug() << "~CalendarView()" << endl; | 630 | // kdDebug() << "~CalendarView()" << endl; |
631 | //qDebug("CalendarView::~CalendarView() "); | 631 | //qDebug("CalendarView::~CalendarView() "); |
632 | delete mDialogManager; | 632 | delete mDialogManager; |
633 | delete mViewManager; | 633 | delete mViewManager; |
634 | delete mStorage; | 634 | delete mStorage; |
635 | delete mDateFrame ; | 635 | delete mDateFrame ; |
636 | delete beamDialog; | 636 | delete beamDialog; |
637 | delete mEventViewerDialog; | 637 | delete mEventViewerDialog; |
638 | //kdDebug() << "~CalendarView() done" << endl; | 638 | //kdDebug() << "~CalendarView() done" << endl; |
639 | } | 639 | } |
640 | void CalendarView::checkAlarms() | 640 | void CalendarView::checkAlarms() |
641 | { | 641 | { |
642 | KConfig *config = KOGlobals::config(); | 642 | KConfig *config = KOGlobals::config(); |
643 | config->setGroup( "AppRun" ); | 643 | config->setGroup( "AppRun" ); |
644 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); | 644 | QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); |
645 | int secto = dt.secsTo( QDateTime::currentDateTime() ); | 645 | int secto = dt.secsTo( QDateTime::currentDateTime() ); |
646 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; | 646 | int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; |
647 | //secs -= ( 3600 * 24*3 ); // debug only | 647 | //secs -= ( 3600 * 24*3 ); // debug only |
648 | QDateTime latest = dt.addSecs ( secs ); | 648 | QDateTime latest = dt.addSecs ( secs ); |
649 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); | 649 | qDebug("KO: Last termination on %s ", latest.toString().latin1()); |
650 | QPtrList<Incidence> el = mCalendar->rawIncidences(); | 650 | QPtrList<Incidence> el = mCalendar->rawIncidences(); |
651 | QPtrList<Incidence> al; | 651 | QPtrList<Incidence> al; |
652 | Incidence* inL = el.first(); | 652 | Incidence* inL = el.first(); |
653 | QDateTime cur = QDateTime::currentDateTime().addSecs(-59); | ||
654 | qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); | ||
653 | while ( inL ) { | 655 | while ( inL ) { |
654 | bool ok = false; | 656 | bool ok = false; |
655 | int offset = 0; | 657 | int offset = 0; |
656 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; | 658 | QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; |
657 | if ( ok ) { | 659 | if ( ok ) { |
658 | //qDebug("OK %s",next.toString().latin1()); | 660 | //qDebug("OK %s",next.toString().latin1()); |
659 | if ( next < QDateTime::currentDateTime() ) { | 661 | if ( next < cur ) { |
660 | al.append( inL ); | 662 | al.append( inL ); |
661 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); | 663 | //qDebug("found missed alarm: %s ", inL->summary().latin1() ); |
662 | } | 664 | } |
663 | } | 665 | } |
664 | inL = el.next(); | 666 | inL = el.next(); |
665 | } | 667 | } |
666 | if ( al.count() ) { | 668 | if ( al.count() ) { |
667 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); | 669 | QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); |
668 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); | 670 | dia->setCaption( i18n("KO/Pi: Missing alarms!") ); |
669 | QVBoxLayout* lay = new QVBoxLayout( dia ); | 671 | QVBoxLayout* lay = new QVBoxLayout( dia ); |
670 | lay->setSpacing( 0 ); | 672 | lay->setSpacing( 0 ); |
671 | lay->setMargin( 0 ); | 673 | lay->setMargin( 0 ); |
672 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); | 674 | MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); |
673 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 675 | connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
674 | lay->addWidget( matb ); | 676 | lay->addWidget( matb ); |
675 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { | 677 | if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { |
676 | int wid = 210; | 678 | int wid = 210; |
677 | int x = QApplication::desktop()->width() - wid - 7; | 679 | int x = QApplication::desktop()->width() - wid - 7; |
678 | int y = QApplication::desktop()->height() - wid - 70; | 680 | int y = QApplication::desktop()->height() - wid - 70; |
679 | dia->setGeometry ( x,y,wid,wid); | 681 | dia->setGeometry ( x,y,wid,wid); |
680 | } else { | 682 | } else { |
681 | int si = 220; | 683 | int si = 220; |
682 | if ( QApplication::desktop()->width() > 470 ) | 684 | if ( QApplication::desktop()->width() > 470 ) |
683 | si = 400; | 685 | si = 400; |
684 | dia->resize(si,si/2); | 686 | dia->resize(si,si/2); |
685 | } | 687 | } |
686 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); | 688 | dia->setBackgroundColor( QColor( 255, 255, 255 ) ); |
687 | dia->show(); | 689 | dia->show(); |
688 | 690 | ||
689 | } | 691 | } |
690 | } | 692 | } |
691 | void CalendarView::showDay( QDate d ) | 693 | void CalendarView::showDay( QDate d ) |
692 | { | 694 | { |
693 | dateNavigator()->blockSignals( true ); | 695 | dateNavigator()->blockSignals( true ); |
694 | dateNavigator()->selectDate( d ); | 696 | dateNavigator()->selectDate( d ); |
695 | dateNavigator()->blockSignals( false ); | 697 | dateNavigator()->blockSignals( false ); |
696 | mViewManager->showDayView(); | 698 | mViewManager->showDayView(); |
697 | //dateNavigator()->selectDate( d ); | 699 | //dateNavigator()->selectDate( d ); |
698 | } | 700 | } |
699 | void CalendarView::timerAlarm() | 701 | void CalendarView::timerAlarm() |
700 | { | 702 | { |
701 | //qDebug("CalendarView::timerAlarm() "); | 703 | //qDebug("CalendarView::timerAlarm() "); |
702 | computeAlarm(mAlarmNotification ); | 704 | computeAlarm(mAlarmNotification ); |
703 | } | 705 | } |
704 | 706 | ||
705 | void CalendarView::suspendAlarm() | 707 | void CalendarView::suspendAlarm() |
706 | { | 708 | { |
707 | //qDebug(" CalendarView::suspendAlarm() "); | 709 | //qDebug(" CalendarView::suspendAlarm() "); |
708 | computeAlarm(mSuspendAlarmNotification ); | 710 | computeAlarm(mSuspendAlarmNotification ); |
709 | 711 | ||
710 | } | 712 | } |
711 | 713 | ||
712 | void CalendarView::startAlarm( QString mess , QString filename) | 714 | void CalendarView::startAlarm( QString mess , QString filename) |
713 | { | 715 | { |
714 | 716 | ||
715 | topLevelWidget()->showNormal(); | 717 | topLevelWidget()->showNormal(); |
716 | topLevelWidget()->setActiveWindow(); | 718 | topLevelWidget()->setActiveWindow(); |
717 | topLevelWidget()->raise(); | 719 | topLevelWidget()->raise(); |
718 | 720 | ||
719 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); | 721 | mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); |
720 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); | 722 | QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); |
721 | 723 | ||
722 | } | 724 | } |
723 | 725 | ||
724 | void CalendarView::checkNextTimerAlarm() | 726 | void CalendarView::checkNextTimerAlarm() |
725 | { | 727 | { |
726 | mCalendar->checkAlarmForIncidence( 0, true ); | 728 | mCalendar->checkAlarmForIncidence( 0, true ); |
727 | } | 729 | } |
728 | 730 | ||
729 | void CalendarView::computeAlarm( QString msg ) | 731 | void CalendarView::computeAlarm( QString msg ) |
730 | { | 732 | { |
731 | 733 | ||
732 | QString mess = msg; | 734 | QString mess = msg; |
733 | QString mAlarmMessage = mess.mid( 9 ); | 735 | QString mAlarmMessage = mess.mid( 9 ); |
734 | QString filename = MainWindow::resourcePath(); | 736 | QString filename = MainWindow::resourcePath(); |
735 | filename += "koalarm.wav"; | 737 | filename += "koalarm.wav"; |
736 | QString tempfilename; | 738 | QString tempfilename; |
737 | if ( mess.left( 13 ) == "suspend_alarm") { | 739 | if ( mess.left( 13 ) == "suspend_alarm") { |
738 | bool error = false; | 740 | bool error = false; |
739 | int len = mess.mid( 13 ).find("+++"); | 741 | int len = mess.mid( 13 ).find("+++"); |
740 | if ( len < 2 ) | 742 | if ( len < 2 ) |
741 | error = true; | 743 | error = true; |
742 | else { | 744 | else { |
743 | tempfilename = mess.mid( 13, len ); | 745 | tempfilename = mess.mid( 13, len ); |
744 | if ( !QFile::exists( tempfilename ) ) | 746 | if ( !QFile::exists( tempfilename ) ) |
745 | error = true; | 747 | error = true; |
746 | } | 748 | } |
747 | if ( ! error ) { | 749 | if ( ! error ) { |
748 | filename = tempfilename; | 750 | filename = tempfilename; |
749 | } | 751 | } |
750 | mAlarmMessage = mess.mid( 13+len+3 ); | 752 | mAlarmMessage = mess.mid( 13+len+3 ); |
751 | //qDebug("suspend file %s ",tempfilename.latin1() ); | 753 | //qDebug("suspend file %s ",tempfilename.latin1() ); |
752 | startAlarm( mAlarmMessage, filename); | 754 | startAlarm( mAlarmMessage, filename); |
753 | return; | 755 | return; |
754 | } | 756 | } |
755 | if ( mess.left( 11 ) == "timer_alarm") { | 757 | if ( mess.left( 11 ) == "timer_alarm") { |
756 | //mTimerTime = 0; | 758 | //mTimerTime = 0; |
757 | startAlarm( mess.mid( 11 ), filename ); | 759 | startAlarm( mess.mid( 11 ), filename ); |
758 | return; | 760 | return; |
759 | } | 761 | } |
760 | if ( mess.left( 10 ) == "proc_alarm") { | 762 | if ( mess.left( 10 ) == "proc_alarm") { |
761 | bool error = false; | 763 | bool error = false; |
762 | int len = mess.mid( 10 ).find("+++"); | 764 | int len = mess.mid( 10 ).find("+++"); |
763 | if ( len < 2 ) | 765 | if ( len < 2 ) |
764 | error = true; | 766 | error = true; |
765 | else { | 767 | else { |
766 | tempfilename = mess.mid( 10, len ); | 768 | tempfilename = mess.mid( 10, len ); |
767 | if ( !QFile::exists( tempfilename ) ) | 769 | if ( !QFile::exists( tempfilename ) ) |
768 | error = true; | 770 | error = true; |
769 | } | 771 | } |
770 | if ( error ) { | 772 | if ( error ) { |
771 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; | 773 | mAlarmMessage = "Procedure Alarm\nError - File not found\n"; |
772 | mAlarmMessage += mess.mid( 10+len+3+9 ); | 774 | mAlarmMessage += mess.mid( 10+len+3+9 ); |
773 | } else { | 775 | } else { |
774 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); | 776 | //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); |
775 | //qDebug("-----system command %s ",tempfilename.latin1() ); | 777 | //qDebug("-----system command %s ",tempfilename.latin1() ); |
776 | #ifndef _WIN32_ | 778 | #ifndef _WIN32_ |
777 | if ( vfork () == 0 ) { | 779 | if ( vfork () == 0 ) { |
778 | execl ( tempfilename.latin1(), 0 ); | 780 | execl ( tempfilename.latin1(), 0 ); |
779 | return; | 781 | return; |
780 | } | 782 | } |
781 | #else | 783 | #else |
782 | QProcess* p = new QProcess(); | 784 | QProcess* p = new QProcess(); |
783 | p->addArgument( tempfilename.latin1() ); | 785 | p->addArgument( tempfilename.latin1() ); |
784 | p->start(); | 786 | p->start(); |
785 | return; | 787 | return; |
786 | #endif | 788 | #endif |
787 | 789 | ||
788 | return; | 790 | return; |
789 | } | 791 | } |
790 | 792 | ||
791 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); | 793 | //qDebug("+++++++system command %s ",tempfilename.latin1() ); |
792 | } | 794 | } |
793 | if ( mess.left( 11 ) == "audio_alarm") { | 795 | if ( mess.left( 11 ) == "audio_alarm") { |
794 | bool error = false; | 796 | bool error = false; |
795 | int len = mess.mid( 11 ).find("+++"); | 797 | int len = mess.mid( 11 ).find("+++"); |
796 | if ( len < 2 ) | 798 | if ( len < 2 ) |
797 | error = true; | 799 | error = true; |
798 | else { | 800 | else { |
799 | tempfilename = mess.mid( 11, len ); | 801 | tempfilename = mess.mid( 11, len ); |
800 | if ( !QFile::exists( tempfilename ) ) | 802 | if ( !QFile::exists( tempfilename ) ) |
801 | error = true; | 803 | error = true; |
802 | } | 804 | } |
803 | if ( ! error ) { | 805 | if ( ! error ) { |
804 | filename = tempfilename; | 806 | filename = tempfilename; |
805 | } | 807 | } |
806 | mAlarmMessage = mess.mid( 11+len+3+9 ); | 808 | mAlarmMessage = mess.mid( 11+len+3+9 ); |
807 | //qDebug("audio file command %s ",tempfilename.latin1() ); | 809 | //qDebug("audio file command %s ",tempfilename.latin1() ); |
808 | } | 810 | } |
809 | if ( mess.left( 9 ) == "cal_alarm") { | 811 | if ( mess.left( 9 ) == "cal_alarm") { |
810 | mAlarmMessage = mess.mid( 9 ) ; | 812 | mAlarmMessage = mess.mid( 9 ) ; |
811 | } | 813 | } |
812 | 814 | ||
813 | startAlarm( mAlarmMessage, filename ); | 815 | startAlarm( mAlarmMessage, filename ); |
814 | 816 | ||
815 | 817 | ||
816 | } | 818 | } |
817 | 819 | ||
818 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) | 820 | void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString ¬i ) |
819 | { | 821 | { |
820 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 822 | //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
821 | 823 | ||
822 | mSuspendAlarmNotification = noti; | 824 | mSuspendAlarmNotification = noti; |
823 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; | 825 | int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; |
824 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); | 826 | //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); |
825 | mSuspendTimer->start( ms , true ); | 827 | mSuspendTimer->start( ms , true ); |
826 | 828 | ||
827 | } | 829 | } |
828 | 830 | ||
829 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) | 831 | void CalendarView::addAlarm(const QDateTime &qdt, const QString ¬i ) |
830 | { | 832 | { |
831 | mNextAlarmDateTime = qdt; | 833 | mNextAlarmDateTime = qdt; |
832 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 834 | //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
833 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 835 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
834 | #ifndef DESKTOP_VERSION | 836 | #ifndef DESKTOP_VERSION |
835 | AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); | 837 | AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); |
836 | #endif | 838 | #endif |
837 | return; | 839 | return; |
838 | } | 840 | } |
839 | int maxSec; | 841 | int maxSec; |
840 | //maxSec = 5; //testing only | 842 | //maxSec = 5; //testing only |
841 | maxSec = 86400+3600; // one day+1hour | 843 | maxSec = 86400+3600; // one day+1hour |
842 | mAlarmNotification = noti; | 844 | mAlarmNotification = noti; |
843 | int sec = QDateTime::currentDateTime().secsTo( qdt ); | 845 | int sec = QDateTime::currentDateTime().secsTo( qdt ); |
844 | if ( sec > maxSec ) { | 846 | if ( sec > maxSec ) { |
845 | mRecheckAlarmTimer->start( maxSec * 1000 ); | 847 | mRecheckAlarmTimer->start( maxSec * 1000 ); |
846 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); | 848 | // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); |
847 | return; | 849 | return; |
848 | } else { | 850 | } else { |
849 | mRecheckAlarmTimer->stop(); | 851 | mRecheckAlarmTimer->stop(); |
850 | } | 852 | } |
851 | //qDebug("Alarm timer started with secs: %d ", sec); | 853 | //qDebug("Alarm timer started with secs: %d ", sec); |
852 | mAlarmTimer->start( sec *1000 , true ); | 854 | mAlarmTimer->start( sec *1000 , true ); |
853 | 855 | ||
854 | } | 856 | } |
855 | // called by mRecheckAlarmTimer to get next alarm | 857 | // called by mRecheckAlarmTimer to get next alarm |
856 | // we need this, because a QTimer has only a max range of 25 days | 858 | // we need this, because a QTimer has only a max range of 25 days |
857 | void CalendarView::recheckTimerAlarm() | 859 | void CalendarView::recheckTimerAlarm() |
858 | { | 860 | { |
859 | mAlarmTimer->stop(); | 861 | mAlarmTimer->stop(); |
860 | mRecheckAlarmTimer->stop(); | 862 | mRecheckAlarmTimer->stop(); |
861 | mCalendar->checkAlarmForIncidence( 0, true ); | 863 | mCalendar->checkAlarmForIncidence( 0, true ); |
862 | } | 864 | } |
863 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) | 865 | void CalendarView::removeAlarm(const QDateTime &qdt, const QString ¬i ) |
864 | { | 866 | { |
865 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); | 867 | //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); |
866 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { | 868 | if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { |
867 | #ifndef DESKTOP_VERSION | 869 | #ifndef DESKTOP_VERSION |
868 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); | 870 | AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); |
869 | #endif | 871 | #endif |
870 | return; | 872 | return; |
871 | } | 873 | } |
872 | mAlarmTimer->stop(); | 874 | mAlarmTimer->stop(); |
873 | } | 875 | } |
874 | void CalendarView::selectWeekNum ( int num ) | 876 | void CalendarView::selectWeekNum ( int num ) |
875 | { | 877 | { |
876 | dateNavigator()->blockSignals( true ); | 878 | dateNavigator()->blockSignals( true ); |
877 | dateNavigator()->selectWeek( num ); | 879 | dateNavigator()->selectWeek( num ); |
878 | dateNavigator()->blockSignals( false ); | 880 | dateNavigator()->blockSignals( false ); |
879 | mViewManager->showWeekView(); | 881 | mViewManager->showWeekView(); |
880 | } | 882 | } |
881 | KOViewManager *CalendarView::viewManager() | 883 | KOViewManager *CalendarView::viewManager() |
882 | { | 884 | { |
883 | return mViewManager; | 885 | return mViewManager; |
884 | } | 886 | } |
885 | 887 | ||
886 | KODialogManager *CalendarView::dialogManager() | 888 | KODialogManager *CalendarView::dialogManager() |
887 | { | 889 | { |
888 | return mDialogManager; | 890 | return mDialogManager; |
889 | } | 891 | } |
890 | 892 | ||
891 | QDate CalendarView::startDate() | 893 | QDate CalendarView::startDate() |
892 | { | 894 | { |
893 | DateList dates = mNavigator->selectedDates(); | 895 | DateList dates = mNavigator->selectedDates(); |
894 | 896 | ||
895 | return dates.first(); | 897 | return dates.first(); |
896 | } | 898 | } |
897 | 899 | ||
898 | QDate CalendarView::endDate() | 900 | QDate CalendarView::endDate() |
899 | { | 901 | { |
900 | DateList dates = mNavigator->selectedDates(); | 902 | DateList dates = mNavigator->selectedDates(); |
901 | 903 | ||
902 | return dates.last(); | 904 | return dates.last(); |
903 | } | 905 | } |
904 | 906 | ||
905 | 907 | ||
906 | void CalendarView::createPrinter() | 908 | void CalendarView::createPrinter() |
907 | { | 909 | { |
908 | #ifndef KORG_NOPRINTER | 910 | #ifndef KORG_NOPRINTER |
909 | if (!mCalPrinter) { | 911 | if (!mCalPrinter) { |
910 | mCalPrinter = new CalPrinter(this, mCalendar); | 912 | mCalPrinter = new CalPrinter(this, mCalendar); |
911 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); | 913 | connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); |
912 | } | 914 | } |
913 | #endif | 915 | #endif |
914 | } | 916 | } |
915 | 917 | ||
916 | 918 | ||
917 | //KOPrefs::instance()->mWriteBackFile | 919 | //KOPrefs::instance()->mWriteBackFile |
918 | //KOPrefs::instance()->mWriteBackExistingOnly | 920 | //KOPrefs::instance()->mWriteBackExistingOnly |
919 | 921 | ||
920 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); | 922 | // 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); |
921 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); | 923 | // 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); |
922 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); | 924 | // 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); |
923 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); | 925 | // 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); |
924 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); | 926 | // 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); |
925 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); | 927 | // 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); |
926 | 928 | ||
927 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) | 929 | int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) |
928 | { | 930 | { |
929 | 931 | ||
930 | // 0 equal | 932 | // 0 equal |
931 | // 1 take local | 933 | // 1 take local |
932 | // 2 take remote | 934 | // 2 take remote |
933 | // 3 cancel | 935 | // 3 cancel |
934 | QDateTime lastSync = mLastCalendarSync; | 936 | QDateTime lastSync = mLastCalendarSync; |
935 | QDateTime localMod = local->lastModified(); | 937 | QDateTime localMod = local->lastModified(); |
936 | QDateTime remoteMod = remote->lastModified(); | 938 | QDateTime remoteMod = remote->lastModified(); |
937 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 939 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
938 | bool remCh, locCh; | 940 | bool remCh, locCh; |
939 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); | 941 | remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); |
940 | //if ( remCh ) | 942 | //if ( remCh ) |
941 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); | 943 | //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); |
942 | locCh = ( localMod > mLastCalendarSync ); | 944 | locCh = ( localMod > mLastCalendarSync ); |
943 | if ( !remCh && ! locCh ) { | 945 | if ( !remCh && ! locCh ) { |
944 | //qDebug("both not changed "); | 946 | //qDebug("both not changed "); |
945 | lastSync = localMod.addDays(1); | 947 | lastSync = localMod.addDays(1); |
946 | if ( mode <= SYNC_PREF_ASK ) | 948 | if ( mode <= SYNC_PREF_ASK ) |
947 | return 0; | 949 | return 0; |
948 | } else { | 950 | } else { |
949 | if ( locCh ) { | 951 | if ( locCh ) { |
950 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); | 952 | //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); |
951 | lastSync = localMod.addDays( -1 ); | 953 | lastSync = localMod.addDays( -1 ); |
952 | if ( !remCh ) | 954 | if ( !remCh ) |
953 | remoteMod = ( lastSync.addDays( -1 ) ); | 955 | remoteMod = ( lastSync.addDays( -1 ) ); |
954 | } else { | 956 | } else { |
955 | //qDebug(" not loc changed "); | 957 | //qDebug(" not loc changed "); |
956 | lastSync = localMod.addDays( 1 ); | 958 | lastSync = localMod.addDays( 1 ); |
957 | if ( remCh ) | 959 | if ( remCh ) |
958 | remoteMod =( lastSync.addDays( 1 ) ); | 960 | remoteMod =( lastSync.addDays( 1 ) ); |
959 | 961 | ||
960 | } | 962 | } |
961 | } | 963 | } |
962 | full = true; | 964 | full = true; |
963 | if ( mode < SYNC_PREF_ASK ) | 965 | if ( mode < SYNC_PREF_ASK ) |
964 | mode = SYNC_PREF_ASK; | 966 | mode = SYNC_PREF_ASK; |
965 | } else { | 967 | } else { |
966 | if ( localMod == remoteMod ) | 968 | if ( localMod == remoteMod ) |
967 | // if ( local->revision() == remote->revision() ) | 969 | // if ( local->revision() == remote->revision() ) |
968 | return 0; | 970 | return 0; |
969 | 971 | ||
970 | } | 972 | } |
971 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); | 973 | // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); |
972 | 974 | ||
973 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); | 975 | //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); |
974 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); | 976 | //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); |
975 | //full = true; //debug only | 977 | //full = true; //debug only |
976 | if ( full ) { | 978 | if ( full ) { |
977 | bool equ = false; | 979 | bool equ = false; |
978 | if ( local->typeID() == eventID ) { | 980 | if ( local->typeID() == eventID ) { |
979 | equ = (*((Event*) local) == *((Event*) remote)); | 981 | equ = (*((Event*) local) == *((Event*) remote)); |
980 | } | 982 | } |
981 | else if ( local->typeID() == todoID ) | 983 | else if ( local->typeID() == todoID ) |
982 | equ = (*((Todo*) local) == (*(Todo*) remote)); | 984 | equ = (*((Todo*) local) == (*(Todo*) remote)); |
983 | else if ( local->typeID() == journalID ) | 985 | else if ( local->typeID() == journalID ) |
984 | equ = (*((Journal*) local) == *((Journal*) remote)); | 986 | equ = (*((Journal*) local) == *((Journal*) remote)); |
985 | if ( equ ) { | 987 | if ( equ ) { |
986 | //qDebug("equal "); | 988 | //qDebug("equal "); |
987 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 989 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
988 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); | 990 | local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); |
989 | } | 991 | } |
990 | if ( mode < SYNC_PREF_FORCE_LOCAL ) | 992 | if ( mode < SYNC_PREF_FORCE_LOCAL ) |
991 | return 0; | 993 | return 0; |
992 | 994 | ||
993 | }//else //debug only | 995 | }//else //debug only |
994 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); | 996 | //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); |
995 | } | 997 | } |
996 | int result; | 998 | int result; |
997 | bool localIsNew; | 999 | bool localIsNew; |
998 | //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() ); | 1000 | //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() ); |
999 | 1001 | ||
1000 | 1002 | ||
1001 | // ************************************************ | 1003 | // ************************************************ |
1002 | // ************************************************ | 1004 | // ************************************************ |
1003 | // ************************************************ | 1005 | // ************************************************ |
1004 | // We may have that lastSync > remoteMod AND lastSync > localMod | 1006 | // We may have that lastSync > remoteMod AND lastSync > localMod |
1005 | // BUT remoteMod != localMod | 1007 | // BUT remoteMod != localMod |
1006 | 1008 | ||
1007 | 1009 | ||
1008 | if ( full && mode < SYNC_PREF_NEWEST ) | 1010 | if ( full && mode < SYNC_PREF_NEWEST ) |
1009 | mode = SYNC_PREF_ASK; | 1011 | mode = SYNC_PREF_ASK; |
1010 | 1012 | ||
1011 | switch( mode ) { | 1013 | switch( mode ) { |
1012 | case SYNC_PREF_LOCAL: | 1014 | case SYNC_PREF_LOCAL: |
1013 | if ( lastSync > remoteMod ) | 1015 | if ( lastSync > remoteMod ) |
1014 | return 1; | 1016 | return 1; |
1015 | if ( lastSync > localMod ) | 1017 | if ( lastSync > localMod ) |
1016 | return 2; | 1018 | return 2; |
1017 | return 1; | 1019 | return 1; |
1018 | break; | 1020 | break; |
1019 | case SYNC_PREF_REMOTE: | 1021 | case SYNC_PREF_REMOTE: |
1020 | if ( lastSync > localMod ) | 1022 | if ( lastSync > localMod ) |
1021 | return 2; | 1023 | return 2; |
1022 | if ( lastSync > remoteMod ) | 1024 | if ( lastSync > remoteMod ) |
1023 | return 1; | 1025 | return 1; |
1024 | return 2; | 1026 | return 2; |
1025 | break; | 1027 | break; |
1026 | case SYNC_PREF_NEWEST: | 1028 | case SYNC_PREF_NEWEST: |
1027 | if ( localMod >= remoteMod ) | 1029 | if ( localMod >= remoteMod ) |
1028 | return 1; | 1030 | return 1; |
1029 | else | 1031 | else |
1030 | return 2; | 1032 | return 2; |
1031 | break; | 1033 | break; |
1032 | case SYNC_PREF_ASK: | 1034 | case SYNC_PREF_ASK: |
1033 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1035 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1034 | if ( lastSync > remoteMod && lastSync > localMod) | 1036 | if ( lastSync > remoteMod && lastSync > localMod) |
1035 | return 0; | 1037 | return 0; |
1036 | if ( lastSync > remoteMod ) | 1038 | if ( lastSync > remoteMod ) |
1037 | return 1; | 1039 | return 1; |
1038 | if ( lastSync > localMod ) | 1040 | if ( lastSync > localMod ) |
1039 | return 2; | 1041 | return 2; |
1040 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); | 1042 | //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); |
1041 | localIsNew = localMod >= remoteMod; | 1043 | localIsNew = localMod >= remoteMod; |
1042 | if ( localIsNew ) | 1044 | if ( localIsNew ) |
1043 | getEventViewerDialog()->setColorMode( 1 ); | 1045 | getEventViewerDialog()->setColorMode( 1 ); |
1044 | else | 1046 | else |
1045 | getEventViewerDialog()->setColorMode( 2 ); | 1047 | getEventViewerDialog()->setColorMode( 2 ); |
1046 | getEventViewerDialog()->setIncidence(local); | 1048 | getEventViewerDialog()->setIncidence(local); |
1047 | if ( localIsNew ) | 1049 | if ( localIsNew ) |
1048 | getEventViewerDialog()->setColorMode( 2 ); | 1050 | getEventViewerDialog()->setColorMode( 2 ); |
1049 | else | 1051 | else |
1050 | getEventViewerDialog()->setColorMode( 1 ); | 1052 | getEventViewerDialog()->setColorMode( 1 ); |
1051 | getEventViewerDialog()->addIncidence(remote); | 1053 | getEventViewerDialog()->addIncidence(remote); |
1052 | getEventViewerDialog()->setColorMode( 0 ); | 1054 | getEventViewerDialog()->setColorMode( 0 ); |
1053 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); | 1055 | //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); |
1054 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); | 1056 | getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); |
1055 | getEventViewerDialog()->showMe(); | 1057 | getEventViewerDialog()->showMe(); |
1056 | result = getEventViewerDialog()->executeS( localIsNew ); | 1058 | result = getEventViewerDialog()->executeS( localIsNew ); |
1057 | return result; | 1059 | return result; |
1058 | 1060 | ||
1059 | break; | 1061 | break; |
1060 | case SYNC_PREF_FORCE_LOCAL: | 1062 | case SYNC_PREF_FORCE_LOCAL: |
1061 | return 1; | 1063 | return 1; |
1062 | break; | 1064 | break; |
1063 | case SYNC_PREF_FORCE_REMOTE: | 1065 | case SYNC_PREF_FORCE_REMOTE: |
1064 | return 2; | 1066 | return 2; |
1065 | break; | 1067 | break; |
1066 | 1068 | ||
1067 | default: | 1069 | default: |
1068 | // SYNC_PREF_TAKE_BOTH not implemented | 1070 | // SYNC_PREF_TAKE_BOTH not implemented |
1069 | break; | 1071 | break; |
1070 | } | 1072 | } |
1071 | return 0; | 1073 | return 0; |
1072 | } | 1074 | } |
1073 | Event* CalendarView::getLastSyncEvent() | 1075 | Event* CalendarView::getLastSyncEvent() |
1074 | { | 1076 | { |
1075 | Event* lse; | 1077 | Event* lse; |
1076 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); | 1078 | //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); |
1077 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); | 1079 | lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); |
1078 | if (!lse) { | 1080 | if (!lse) { |
1079 | lse = new Event(); | 1081 | lse = new Event(); |
1080 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); | 1082 | lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); |
1081 | QString sum = ""; | 1083 | QString sum = ""; |
1082 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) | 1084 | if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) |
1083 | sum = "E: "; | 1085 | sum = "E: "; |
1084 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); | 1086 | lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); |
1085 | lse->setDtStart( mLastCalendarSync ); | 1087 | lse->setDtStart( mLastCalendarSync ); |
1086 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1088 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1087 | lse->setCategories( i18n("SyncEvent") ); | 1089 | lse->setCategories( i18n("SyncEvent") ); |
1088 | lse->setReadOnly( true ); | 1090 | lse->setReadOnly( true ); |
1089 | mCalendar->addEvent( lse ); | 1091 | mCalendar->addEvent( lse ); |
1090 | } | 1092 | } |
1091 | 1093 | ||
1092 | return lse; | 1094 | return lse; |
1093 | 1095 | ||
1094 | } | 1096 | } |
1095 | 1097 | ||
1096 | // we check, if the to delete event has a id for a profile | 1098 | // we check, if the to delete event has a id for a profile |
1097 | // if yes, we set this id in the profile to delete | 1099 | // if yes, we set this id in the profile to delete |
1098 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) | 1100 | void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) |
1099 | { | 1101 | { |
1100 | if ( lastSync.count() == 0 ) { | 1102 | if ( lastSync.count() == 0 ) { |
1101 | //qDebug(" lastSync.count() == 0"); | 1103 | //qDebug(" lastSync.count() == 0"); |
1102 | return; | 1104 | return; |
1103 | } | 1105 | } |
1104 | if ( toDelete->typeID() == journalID ) | 1106 | if ( toDelete->typeID() == journalID ) |
1105 | return; | 1107 | return; |
1106 | 1108 | ||
1107 | Event* eve = lastSync.first(); | 1109 | Event* eve = lastSync.first(); |
1108 | 1110 | ||
1109 | while ( eve ) { | 1111 | while ( eve ) { |
1110 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name | 1112 | QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name |
1111 | if ( !id.isEmpty() ) { | 1113 | if ( !id.isEmpty() ) { |
1112 | QString des = eve->description(); | 1114 | QString des = eve->description(); |
1113 | QString pref = "e"; | 1115 | QString pref = "e"; |
1114 | if ( toDelete->typeID() == todoID ) | 1116 | if ( toDelete->typeID() == todoID ) |
1115 | pref = "t"; | 1117 | pref = "t"; |
1116 | des += pref+ id + ","; | 1118 | des += pref+ id + ","; |
1117 | eve->setReadOnly( false ); | 1119 | eve->setReadOnly( false ); |
1118 | eve->setDescription( des ); | 1120 | eve->setDescription( des ); |
1119 | //qDebug("setdes %s ", des.latin1()); | 1121 | //qDebug("setdes %s ", des.latin1()); |
1120 | eve->setReadOnly( true ); | 1122 | eve->setReadOnly( true ); |
1121 | } | 1123 | } |
1122 | eve = lastSync.next(); | 1124 | eve = lastSync.next(); |
1123 | } | 1125 | } |
1124 | 1126 | ||
1125 | } | 1127 | } |
1126 | void CalendarView::checkExternalId( Incidence * inc ) | 1128 | void CalendarView::checkExternalId( Incidence * inc ) |
1127 | { | 1129 | { |
1128 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; | 1130 | QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; |
1129 | checkExternSyncEvent( lastSync, inc ); | 1131 | checkExternSyncEvent( lastSync, inc ); |
1130 | 1132 | ||
1131 | } | 1133 | } |
1132 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) | 1134 | bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) |
1133 | { | 1135 | { |
1134 | bool syncOK = true; | 1136 | bool syncOK = true; |
1135 | int addedEvent = 0; | 1137 | int addedEvent = 0; |
1136 | int addedEventR = 0; | 1138 | int addedEventR = 0; |
1137 | int deletedEventR = 0; | 1139 | int deletedEventR = 0; |
1138 | int deletedEventL = 0; | 1140 | int deletedEventL = 0; |
1139 | int changedLocal = 0; | 1141 | int changedLocal = 0; |
1140 | int changedRemote = 0; | 1142 | int changedRemote = 0; |
1141 | int filteredIN = 0; | 1143 | int filteredIN = 0; |
1142 | int filteredOUT = 0; | 1144 | int filteredOUT = 0; |
1143 | //QPtrList<Event> el = local->rawEvents(); | 1145 | //QPtrList<Event> el = local->rawEvents(); |
1144 | Event* eventR; | 1146 | Event* eventR; |
1145 | QString uid; | 1147 | QString uid; |
1146 | int take; | 1148 | int take; |
1147 | Event* eventL; | 1149 | Event* eventL; |
1148 | Event* eventRSync; | 1150 | Event* eventRSync; |
1149 | Event* eventLSync; | 1151 | Event* eventLSync; |
1150 | clearAllViews(); | 1152 | clearAllViews(); |
1151 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); | 1153 | QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); |
1152 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); | 1154 | QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); |
1153 | bool fullDateRange = false; | 1155 | bool fullDateRange = false; |
1154 | local->resetTempSyncStat(); | 1156 | local->resetTempSyncStat(); |
1155 | mLastCalendarSync = QDateTime::currentDateTime(); | 1157 | mLastCalendarSync = QDateTime::currentDateTime(); |
1156 | if ( mSyncManager->syncWithDesktop() ) { | 1158 | if ( mSyncManager->syncWithDesktop() ) { |
1157 | remote->resetPilotStat(1); | 1159 | remote->resetPilotStat(1); |
1158 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { | 1160 | if ( KSyncManager::mRequestedSyncEvent.isValid() ) { |
1159 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; | 1161 | mLastCalendarSync = KSyncManager::mRequestedSyncEvent; |
1160 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); | 1162 | qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); |
1161 | } else { | 1163 | } else { |
1162 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); | 1164 | qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); |
1163 | } | 1165 | } |
1164 | } | 1166 | } |
1165 | QDateTime modifiedCalendar = mLastCalendarSync; | 1167 | QDateTime modifiedCalendar = mLastCalendarSync; |
1166 | eventLSync = getLastSyncEvent(); | 1168 | eventLSync = getLastSyncEvent(); |
1167 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); | 1169 | eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); |
1168 | if ( eventR ) { | 1170 | if ( eventR ) { |
1169 | eventRSync = (Event*) eventR->clone(); | 1171 | eventRSync = (Event*) eventR->clone(); |
1170 | remote->deleteEvent(eventR ); | 1172 | remote->deleteEvent(eventR ); |
1171 | 1173 | ||
1172 | } else { | 1174 | } else { |
1173 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { | 1175 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { |
1174 | eventRSync = (Event*)eventLSync->clone(); | 1176 | eventRSync = (Event*)eventLSync->clone(); |
1175 | } else { | 1177 | } else { |
1176 | fullDateRange = true; | 1178 | fullDateRange = true; |
1177 | eventRSync = new Event(); | 1179 | eventRSync = new Event(); |
1178 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); | 1180 | eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); |
1179 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); | 1181 | eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); |
1180 | eventRSync->setDtStart( mLastCalendarSync ); | 1182 | eventRSync->setDtStart( mLastCalendarSync ); |
1181 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1183 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1182 | eventRSync->setCategories( i18n("SyncEvent") ); | 1184 | eventRSync->setCategories( i18n("SyncEvent") ); |
1183 | } | 1185 | } |
1184 | } | 1186 | } |
1185 | if ( eventLSync->dtStart() == mLastCalendarSync ) | 1187 | if ( eventLSync->dtStart() == mLastCalendarSync ) |
1186 | fullDateRange = true; | 1188 | fullDateRange = true; |
1187 | 1189 | ||
1188 | if ( ! fullDateRange ) { | 1190 | if ( ! fullDateRange ) { |
1189 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { | 1191 | if ( eventLSync->dtStart() != eventRSync->dtStart() ) { |
1190 | 1192 | ||
1191 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); | 1193 | // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); |
1192 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); | 1194 | //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); |
1193 | fullDateRange = true; | 1195 | fullDateRange = true; |
1194 | } | 1196 | } |
1195 | } | 1197 | } |
1196 | if ( mSyncManager->syncWithDesktop() ) { | 1198 | if ( mSyncManager->syncWithDesktop() ) { |
1197 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); | 1199 | fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); |
1198 | } | 1200 | } |
1199 | if ( fullDateRange ) | 1201 | if ( fullDateRange ) |
1200 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); | 1202 | mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); |
1201 | else | 1203 | else |
1202 | mLastCalendarSync = eventLSync->dtStart(); | 1204 | mLastCalendarSync = eventLSync->dtStart(); |
1203 | // for resyncing if own file has changed | 1205 | // for resyncing if own file has changed |
1204 | if ( mCurrentSyncDevice == "deleteaftersync" ) { | 1206 | if ( mCurrentSyncDevice == "deleteaftersync" ) { |
1205 | mLastCalendarSync = loadedFileVersion; | 1207 | mLastCalendarSync = loadedFileVersion; |
1206 | //qDebug("setting mLastCalendarSync "); | 1208 | //qDebug("setting mLastCalendarSync "); |
1207 | } | 1209 | } |
1208 | //qDebug("*************************** "); | 1210 | //qDebug("*************************** "); |
1209 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); | 1211 | qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); |
1210 | QPtrList<Incidence> er = remote->rawIncidences(); | 1212 | QPtrList<Incidence> er = remote->rawIncidences(); |
1211 | Incidence* inR = er.first(); | 1213 | Incidence* inR = er.first(); |
1212 | Incidence* inL; | 1214 | Incidence* inL; |
1213 | QProgressBar bar( er.count(),0 ); | 1215 | QProgressBar bar( er.count(),0 ); |
1214 | bar.setCaption (i18n("Syncing - close to abort!") ); | 1216 | bar.setCaption (i18n("Syncing - close to abort!") ); |
1215 | 1217 | ||
1216 | // ************** setting up filter ************* | 1218 | // ************** setting up filter ************* |
1217 | CalFilter *filterIN = 0; | 1219 | CalFilter *filterIN = 0; |
1218 | CalFilter *filterOUT = 0; | 1220 | CalFilter *filterOUT = 0; |
1219 | CalFilter *filter = mFilters.first(); | 1221 | CalFilter *filter = mFilters.first(); |
1220 | while(filter) { | 1222 | while(filter) { |
1221 | if ( filter->name() == mSyncManager->mFilterInCal ) | 1223 | if ( filter->name() == mSyncManager->mFilterInCal ) |
1222 | filterIN = filter; | 1224 | filterIN = filter; |
1223 | if ( filter->name() == mSyncManager->mFilterOutCal ) | 1225 | if ( filter->name() == mSyncManager->mFilterOutCal ) |
1224 | filterOUT = filter; | 1226 | filterOUT = filter; |
1225 | filter = mFilters.next(); | 1227 | filter = mFilters.next(); |
1226 | } | 1228 | } |
1227 | int w = 300; | 1229 | int w = 300; |
1228 | if ( QApplication::desktop()->width() < 320 ) | 1230 | if ( QApplication::desktop()->width() < 320 ) |
1229 | w = 220; | 1231 | w = 220; |
1230 | int h = bar.sizeHint().height() ; | 1232 | int h = bar.sizeHint().height() ; |
1231 | int dw = QApplication::desktop()->width(); | 1233 | int dw = QApplication::desktop()->width(); |
1232 | int dh = QApplication::desktop()->height(); | 1234 | int dh = QApplication::desktop()->height(); |
1233 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 1235 | bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
1234 | bar.show(); | 1236 | bar.show(); |
1235 | int modulo = (er.count()/10)+1; | 1237 | int modulo = (er.count()/10)+1; |
1236 | int incCounter = 0; | 1238 | int incCounter = 0; |
1237 | while ( inR ) { | 1239 | while ( inR ) { |
1238 | if ( ! bar.isVisible() ) | 1240 | if ( ! bar.isVisible() ) |
1239 | return false; | 1241 | return false; |
1240 | if ( incCounter % modulo == 0 ) | 1242 | if ( incCounter % modulo == 0 ) |
1241 | bar.setProgress( incCounter ); | 1243 | bar.setProgress( incCounter ); |
1242 | ++incCounter; | 1244 | ++incCounter; |
1243 | uid = inR->uid(); | 1245 | uid = inR->uid(); |
1244 | bool skipIncidence = false; | 1246 | bool skipIncidence = false; |
1245 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1247 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1246 | skipIncidence = true; | 1248 | skipIncidence = true; |
1247 | QString idS; | 1249 | QString idS; |
1248 | qApp->processEvents(); | 1250 | qApp->processEvents(); |
1249 | if ( !skipIncidence ) { | 1251 | if ( !skipIncidence ) { |
1250 | inL = local->incidence( uid ); | 1252 | inL = local->incidence( uid ); |
1251 | if ( inL ) { // maybe conflict - same uid in both calendars | 1253 | if ( inL ) { // maybe conflict - same uid in both calendars |
1252 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { | 1254 | if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { |
1253 | //qDebug("take %d %s ", take, inL->summary().latin1()); | 1255 | //qDebug("take %d %s ", take, inL->summary().latin1()); |
1254 | if ( take == 3 ) | 1256 | if ( take == 3 ) |
1255 | return false; | 1257 | return false; |
1256 | if ( take == 1 ) {// take local ********************** | 1258 | if ( take == 1 ) {// take local ********************** |
1257 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) | 1259 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) |
1258 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1260 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1259 | else | 1261 | else |
1260 | idS = inR->IDStr(); | 1262 | idS = inR->IDStr(); |
1261 | remote->deleteIncidence( inR ); | 1263 | remote->deleteIncidence( inR ); |
1262 | inR = inL->clone(); | 1264 | inR = inL->clone(); |
1263 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1265 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1264 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) | 1266 | if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) |
1265 | inR->setIDStr( idS ); | 1267 | inR->setIDStr( idS ); |
1266 | remote->addIncidence( inR ); | 1268 | remote->addIncidence( inR ); |
1267 | if ( mSyncManager->syncWithDesktop() ) | 1269 | if ( mSyncManager->syncWithDesktop() ) |
1268 | inR->setPilotId( 2 ); | 1270 | inR->setPilotId( 2 ); |
1269 | ++changedRemote; | 1271 | ++changedRemote; |
1270 | } else {// take remote ********************** | 1272 | } else {// take remote ********************** |
1271 | idS = inL->IDStr(); | 1273 | idS = inL->IDStr(); |
1272 | int pid = inL->pilotId(); | 1274 | int pid = inL->pilotId(); |
1273 | local->deleteIncidence( inL ); | 1275 | local->deleteIncidence( inL ); |
1274 | inL = inR->clone(); | 1276 | inL = inR->clone(); |
1275 | if ( mSyncManager->syncWithDesktop() ) | 1277 | if ( mSyncManager->syncWithDesktop() ) |
1276 | inL->setPilotId( pid ); | 1278 | inL->setPilotId( pid ); |
1277 | inL->setIDStr( idS ); | 1279 | inL->setIDStr( idS ); |
1278 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1280 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1279 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1281 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1280 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1282 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1281 | } | 1283 | } |
1282 | local->addIncidence( inL ); | 1284 | local->addIncidence( inL ); |
1283 | ++changedLocal; | 1285 | ++changedLocal; |
1284 | } | 1286 | } |
1285 | } | 1287 | } |
1286 | } else { // no conflict ********** add or delete remote | 1288 | } else { // no conflict ********** add or delete remote |
1287 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ | 1289 | if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ |
1288 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1290 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1289 | QString des = eventLSync->description(); | 1291 | QString des = eventLSync->description(); |
1290 | QString pref = "e"; | 1292 | QString pref = "e"; |
1291 | if ( inR->typeID() == todoID ) | 1293 | if ( inR->typeID() == todoID ) |
1292 | pref = "t"; | 1294 | pref = "t"; |
1293 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it | 1295 | if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it |
1294 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); | 1296 | inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); |
1295 | //remote->deleteIncidence( inR ); | 1297 | //remote->deleteIncidence( inR ); |
1296 | ++deletedEventR; | 1298 | ++deletedEventR; |
1297 | } else { | 1299 | } else { |
1298 | inR->setLastModified( modifiedCalendar ); | 1300 | inR->setLastModified( modifiedCalendar ); |
1299 | inL = inR->clone(); | 1301 | inL = inR->clone(); |
1300 | inL->setIDStr( ":" ); | 1302 | inL->setIDStr( ":" ); |
1301 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); | 1303 | inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); |
1302 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); | 1304 | inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); |
1303 | local->addIncidence( inL ); | 1305 | local->addIncidence( inL ); |
1304 | ++addedEvent; | 1306 | ++addedEvent; |
1305 | 1307 | ||
1306 | } | 1308 | } |
1307 | } else { | 1309 | } else { |
1308 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { | 1310 | if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { |
1309 | inR->setLastModified( modifiedCalendar ); | 1311 | inR->setLastModified( modifiedCalendar ); |
1310 | inL = inR->clone(); | 1312 | inL = inR->clone(); |
1311 | inL->setIDStr( ":" ); | 1313 | inL->setIDStr( ":" ); |
1312 | local->addIncidence( inL ); | 1314 | local->addIncidence( inL ); |
1313 | ++addedEvent; | 1315 | ++addedEvent; |
1314 | 1316 | ||
1315 | } else { | 1317 | } else { |
1316 | checkExternSyncEvent(eventRSyncSharp, inR); | 1318 | checkExternSyncEvent(eventRSyncSharp, inR); |
1317 | remote->deleteIncidence( inR ); | 1319 | remote->deleteIncidence( inR ); |
1318 | ++deletedEventR; | 1320 | ++deletedEventR; |
1319 | } | 1321 | } |
1320 | } | 1322 | } |
1321 | } else { | 1323 | } else { |
1322 | ++filteredIN; | 1324 | ++filteredIN; |
1323 | } | 1325 | } |
1324 | } | 1326 | } |
1325 | } | 1327 | } |
1326 | inR = er.next(); | 1328 | inR = er.next(); |
1327 | } | 1329 | } |
1328 | QPtrList<Incidence> el = local->rawIncidences(); | 1330 | QPtrList<Incidence> el = local->rawIncidences(); |
1329 | inL = el.first(); | 1331 | inL = el.first(); |
1330 | modulo = (el.count()/10)+1; | 1332 | modulo = (el.count()/10)+1; |
1331 | bar.setCaption (i18n("Add / remove events") ); | 1333 | bar.setCaption (i18n("Add / remove events") ); |
1332 | bar.setTotalSteps ( el.count() ) ; | 1334 | bar.setTotalSteps ( el.count() ) ; |
1333 | bar.show(); | 1335 | bar.show(); |
1334 | incCounter = 0; | 1336 | incCounter = 0; |
1335 | 1337 | ||
1336 | while ( inL ) { | 1338 | while ( inL ) { |
1337 | 1339 | ||
1338 | qApp->processEvents(); | 1340 | qApp->processEvents(); |
1339 | if ( ! bar.isVisible() ) | 1341 | if ( ! bar.isVisible() ) |
1340 | return false; | 1342 | return false; |
1341 | if ( incCounter % modulo == 0 ) | 1343 | if ( incCounter % modulo == 0 ) |
1342 | bar.setProgress( incCounter ); | 1344 | bar.setProgress( incCounter ); |
1343 | ++incCounter; | 1345 | ++incCounter; |
1344 | uid = inL->uid(); | 1346 | uid = inL->uid(); |
1345 | bool skipIncidence = false; | 1347 | bool skipIncidence = false; |
1346 | if ( uid.left(15) == QString("last-syncEvent-") ) | 1348 | if ( uid.left(15) == QString("last-syncEvent-") ) |
1347 | skipIncidence = true; | 1349 | skipIncidence = true; |
1348 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) | 1350 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) |
1349 | skipIncidence = true; | 1351 | skipIncidence = true; |
1350 | if ( !skipIncidence ) { | 1352 | if ( !skipIncidence ) { |
1351 | inR = remote->incidence( uid ); | 1353 | inR = remote->incidence( uid ); |
1352 | if ( ! inR ) { | 1354 | if ( ! inR ) { |
1353 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ | 1355 | if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ |
1354 | // no conflict ********** add or delete local | 1356 | // no conflict ********** add or delete local |
1355 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { | 1357 | if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { |
1356 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { | 1358 | if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { |
1357 | checkExternSyncEvent(eventLSyncSharp, inL); | 1359 | checkExternSyncEvent(eventLSyncSharp, inL); |
1358 | local->deleteIncidence( inL ); | 1360 | local->deleteIncidence( inL ); |
1359 | ++deletedEventL; | 1361 | ++deletedEventL; |
1360 | } else { | 1362 | } else { |
1361 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1363 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1362 | inL->removeID(mCurrentSyncDevice ); | 1364 | inL->removeID(mCurrentSyncDevice ); |
1363 | ++addedEventR; | 1365 | ++addedEventR; |
1364 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); | 1366 | //qDebug("remote added Incidence %s ", inL->summary().latin1()); |
1365 | inL->setLastModified( modifiedCalendar ); | 1367 | inL->setLastModified( modifiedCalendar ); |
1366 | inR = inL->clone(); | 1368 | inR = inL->clone(); |
1367 | inR->setIDStr( ":" ); | 1369 | inR->setIDStr( ":" ); |
1368 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); | 1370 | inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); |
1369 | remote->addIncidence( inR ); | 1371 | remote->addIncidence( inR ); |
1370 | } | 1372 | } |
1371 | } | 1373 | } |
1372 | } else { | 1374 | } else { |
1373 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { | 1375 | if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { |
1374 | checkExternSyncEvent(eventLSyncSharp, inL); | 1376 | checkExternSyncEvent(eventLSyncSharp, inL); |
1375 | local->deleteIncidence( inL ); | 1377 | local->deleteIncidence( inL ); |
1376 | ++deletedEventL; | 1378 | ++deletedEventL; |
1377 | } else { | 1379 | } else { |
1378 | if ( ! mSyncManager->mWriteBackExistingOnly ) { | 1380 | if ( ! mSyncManager->mWriteBackExistingOnly ) { |
1379 | ++addedEventR; | 1381 | ++addedEventR; |
1380 | inL->setLastModified( modifiedCalendar ); | 1382 | inL->setLastModified( modifiedCalendar ); |
1381 | inR = inL->clone(); | 1383 | inR = inL->clone(); |
1382 | inR->setIDStr( ":" ); | 1384 | inR->setIDStr( ":" ); |
1383 | remote->addIncidence( inR ); | 1385 | remote->addIncidence( inR ); |
1384 | } | 1386 | } |
1385 | } | 1387 | } |
1386 | } | 1388 | } |
1387 | } else { | 1389 | } else { |
1388 | ++filteredOUT; | 1390 | ++filteredOUT; |
1389 | } | 1391 | } |
1390 | } | 1392 | } |
1391 | } | 1393 | } |
1392 | inL = el.next(); | 1394 | inL = el.next(); |
1393 | } | 1395 | } |
1394 | int delFut = 0; | 1396 | int delFut = 0; |
1395 | int remRem = 0; | 1397 | int remRem = 0; |
1396 | if ( mSyncManager->mWriteBackInFuture ) { | 1398 | if ( mSyncManager->mWriteBackInFuture ) { |
1397 | er = remote->rawIncidences(); | 1399 | er = remote->rawIncidences(); |
1398 | remRem = er.count(); | 1400 | remRem = er.count(); |
1399 | inR = er.first(); | 1401 | inR = er.first(); |
1400 | QDateTime dt; | 1402 | QDateTime dt; |
1401 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); | 1403 | QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); |
1402 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); | 1404 | QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); |
1403 | while ( inR ) { | 1405 | while ( inR ) { |
1404 | if ( inR->typeID() == todoID ) { | 1406 | if ( inR->typeID() == todoID ) { |
1405 | Todo * t = (Todo*)inR; | 1407 | Todo * t = (Todo*)inR; |
1406 | if ( t->hasDueDate() ) | 1408 | if ( t->hasDueDate() ) |
1407 | dt = t->dtDue(); | 1409 | dt = t->dtDue(); |
1408 | else | 1410 | else |
1409 | dt = cur.addSecs( 62 ); | 1411 | dt = cur.addSecs( 62 ); |
1410 | } | 1412 | } |
1411 | else if (inR->typeID() == eventID ) { | 1413 | else if (inR->typeID() == eventID ) { |
1412 | bool ok; | 1414 | bool ok; |
1413 | dt = inR->getNextOccurence( cur, &ok ); | 1415 | dt = inR->getNextOccurence( cur, &ok ); |
1414 | if ( !ok ) | 1416 | if ( !ok ) |
1415 | dt = cur.addSecs( -62 ); | 1417 | dt = cur.addSecs( -62 ); |
1416 | } | 1418 | } |
1417 | else | 1419 | else |
1418 | dt = inR->dtStart(); | 1420 | dt = inR->dtStart(); |
1419 | if ( dt < cur || dt > end ) { | 1421 | if ( dt < cur || dt > end ) { |
1420 | remote->deleteIncidence( inR ); | 1422 | remote->deleteIncidence( inR ); |
1421 | ++delFut; | 1423 | ++delFut; |
1422 | } | 1424 | } |
1423 | inR = er.next(); | 1425 | inR = er.next(); |
1424 | } | 1426 | } |
1425 | } | 1427 | } |
1426 | bar.hide(); | 1428 | bar.hide(); |
1427 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1429 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1428 | eventLSync->setReadOnly( false ); | 1430 | eventLSync->setReadOnly( false ); |
1429 | eventLSync->setDtStart( mLastCalendarSync ); | 1431 | eventLSync->setDtStart( mLastCalendarSync ); |
1430 | eventRSync->setDtStart( mLastCalendarSync ); | 1432 | eventRSync->setDtStart( mLastCalendarSync ); |
1431 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1433 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1432 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1434 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1433 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1435 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; |
1434 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1436 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); |
1435 | eventLSync->setReadOnly( true ); | 1437 | eventLSync->setReadOnly( true ); |
1436 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1438 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1437 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1439 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... |
1438 | remote->addEvent( eventRSync ); | 1440 | remote->addEvent( eventRSync ); |
1439 | else | 1441 | else |
1440 | delete eventRSync; | 1442 | delete eventRSync; |
1441 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); | 1443 | qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); |
1442 | QString mes; | 1444 | QString mes; |
1443 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); | 1445 | 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); |
1444 | QString delmess; | 1446 | QString delmess; |
1445 | if ( delFut ) { | 1447 | if ( delFut ) { |
1446 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); | 1448 | delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); |
1447 | mes += delmess; | 1449 | mes += delmess; |
1448 | } | 1450 | } |
1449 | mes = i18n("Local calendar changed!\n") +mes; | 1451 | mes = i18n("Local calendar changed!\n") +mes; |
1450 | mCalendar->checkAlarmForIncidence( 0, true ); | 1452 | mCalendar->checkAlarmForIncidence( 0, true ); |
1451 | qDebug( mes ); | 1453 | qDebug( mes ); |
1452 | if ( mSyncManager->mShowSyncSummary ) { | 1454 | if ( mSyncManager->mShowSyncSummary ) { |
1453 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, | 1455 | if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, |
1454 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { | 1456 | i18n("KO/Pi Synchronization"),i18n("Write back"))) { |
1455 | qDebug("KO: WB cancelled "); | 1457 | qDebug("KO: WB cancelled "); |
1456 | mSyncManager->mWriteBackFile = false; | 1458 | mSyncManager->mWriteBackFile = false; |
1457 | return syncOK; | 1459 | return syncOK; |
1458 | } | 1460 | } |
1459 | } | 1461 | } |
1460 | return syncOK; | 1462 | return syncOK; |
1461 | } | 1463 | } |
1462 | 1464 | ||
1463 | void CalendarView::setSyncDevice( QString s ) | 1465 | void CalendarView::setSyncDevice( QString s ) |
1464 | { | 1466 | { |
1465 | mCurrentSyncDevice= s; | 1467 | mCurrentSyncDevice= s; |
1466 | } | 1468 | } |
1467 | void CalendarView::setSyncName( QString s ) | 1469 | void CalendarView::setSyncName( QString s ) |
1468 | { | 1470 | { |
1469 | mCurrentSyncName= s; | 1471 | mCurrentSyncName= s; |
1470 | } | 1472 | } |
1471 | bool CalendarView::syncCalendar(QString filename, int mode) | 1473 | bool CalendarView::syncCalendar(QString filename, int mode) |
1472 | { | 1474 | { |
1473 | //qDebug("syncCalendar %s ", filename.latin1()); | 1475 | //qDebug("syncCalendar %s ", filename.latin1()); |
1474 | mGlobalSyncMode = SYNC_MODE_NORMAL; | 1476 | mGlobalSyncMode = SYNC_MODE_NORMAL; |
1475 | CalendarLocal* calendar = new CalendarLocal(); | 1477 | CalendarLocal* calendar = new CalendarLocal(); |
1476 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1478 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1477 | FileStorage* storage = new FileStorage( calendar ); | 1479 | FileStorage* storage = new FileStorage( calendar ); |
1478 | bool syncOK = false; | 1480 | bool syncOK = false; |
1479 | storage->setFileName( filename ); | 1481 | storage->setFileName( filename ); |
1480 | // qDebug("loading ... "); | 1482 | // qDebug("loading ... "); |
1481 | if ( storage->load() ) { | 1483 | if ( storage->load() ) { |
1482 | getEventViewerDialog()->setSyncMode( true ); | 1484 | getEventViewerDialog()->setSyncMode( true ); |
1483 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); | 1485 | syncOK = synchronizeCalendar( mCalendar, calendar, mode ); |
1484 | getEventViewerDialog()->setSyncMode( false ); | 1486 | getEventViewerDialog()->setSyncMode( false ); |
1485 | if ( syncOK ) { | 1487 | if ( syncOK ) { |
1486 | if ( mSyncManager->mWriteBackFile ) | 1488 | if ( mSyncManager->mWriteBackFile ) |
1487 | { | 1489 | { |
1488 | storage->setSaveFormat( new ICalFormat() ); | 1490 | storage->setSaveFormat( new ICalFormat() ); |
1489 | storage->save(); | 1491 | storage->save(); |
1490 | } | 1492 | } |
1491 | } | 1493 | } |
1492 | setModified( true ); | 1494 | setModified( true ); |
1493 | } | 1495 | } |
1494 | delete storage; | 1496 | delete storage; |
1495 | delete calendar; | 1497 | delete calendar; |
1496 | if ( syncOK ) | 1498 | if ( syncOK ) |
1497 | updateView(); | 1499 | updateView(); |
1498 | return syncOK; | 1500 | return syncOK; |
1499 | } | 1501 | } |
1500 | 1502 | ||
1501 | void CalendarView::syncExternal( int mode ) | 1503 | void CalendarView::syncExternal( int mode ) |
1502 | { | 1504 | { |
1503 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; | 1505 | mGlobalSyncMode = SYNC_MODE_EXTERNAL; |
1504 | 1506 | ||
1505 | qApp->processEvents(); | 1507 | qApp->processEvents(); |
1506 | CalendarLocal* calendar = new CalendarLocal(); | 1508 | CalendarLocal* calendar = new CalendarLocal(); |
1507 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 1509 | calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
1508 | bool syncOK = false; | 1510 | bool syncOK = false; |
1509 | bool loadSuccess = false; | 1511 | bool loadSuccess = false; |
1510 | PhoneFormat* phoneFormat = 0; | 1512 | PhoneFormat* phoneFormat = 0; |
1511 | emit tempDisableBR(true); | 1513 | emit tempDisableBR(true); |
1512 | #ifndef DESKTOP_VERSION | 1514 | #ifndef DESKTOP_VERSION |
1513 | SharpFormat* sharpFormat = 0; | 1515 | SharpFormat* sharpFormat = 0; |
1514 | if ( mode == 0 ) { // sharp | 1516 | if ( mode == 0 ) { // sharp |
1515 | sharpFormat = new SharpFormat () ; | 1517 | sharpFormat = new SharpFormat () ; |
1516 | loadSuccess = sharpFormat->load( calendar, mCalendar ); | 1518 | loadSuccess = sharpFormat->load( calendar, mCalendar ); |
1517 | 1519 | ||
1518 | } else | 1520 | } else |
1519 | #endif | 1521 | #endif |
1520 | if ( mode == 1 ) { // phone | 1522 | if ( mode == 1 ) { // phone |
1521 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, | 1523 | phoneFormat = new PhoneFormat (mCurrentSyncDevice, |
1522 | mSyncManager->mPhoneDevice, | 1524 | mSyncManager->mPhoneDevice, |
1523 | mSyncManager->mPhoneConnection, | 1525 | mSyncManager->mPhoneConnection, |
1524 | mSyncManager->mPhoneModel); | 1526 | mSyncManager->mPhoneModel); |
1525 | loadSuccess = phoneFormat->load( calendar,mCalendar); | 1527 | loadSuccess = phoneFormat->load( calendar,mCalendar); |
1526 | 1528 | ||
1527 | } else { | 1529 | } else { |
1528 | emit tempDisableBR(false); | 1530 | emit tempDisableBR(false); |
1529 | return; | 1531 | return; |
1530 | } | 1532 | } |
1531 | if ( loadSuccess ) { | 1533 | if ( loadSuccess ) { |
1532 | getEventViewerDialog()->setSyncMode( true ); | 1534 | getEventViewerDialog()->setSyncMode( true ); |
1533 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); | 1535 | syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); |
1534 | getEventViewerDialog()->setSyncMode( false ); | 1536 | getEventViewerDialog()->setSyncMode( false ); |
1535 | qApp->processEvents(); | 1537 | qApp->processEvents(); |
1536 | if ( syncOK ) { | 1538 | if ( syncOK ) { |
1537 | if ( mSyncManager->mWriteBackFile ) | 1539 | if ( mSyncManager->mWriteBackFile ) |
1538 | { | 1540 | { |
1539 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); | 1541 | QPtrList<Incidence> iL = mCalendar->rawIncidences(); |
1540 | Incidence* inc = iL.first(); | 1542 | Incidence* inc = iL.first(); |
1541 | if ( phoneFormat ) { | 1543 | if ( phoneFormat ) { |
1542 | while ( inc ) { | 1544 | while ( inc ) { |
1543 | inc->removeID(mCurrentSyncDevice); | 1545 | inc->removeID(mCurrentSyncDevice); |
1544 | inc = iL.next(); | 1546 | inc = iL.next(); |
1545 | } | 1547 | } |
1546 | } | 1548 | } |
1547 | #ifndef DESKTOP_VERSION | 1549 | #ifndef DESKTOP_VERSION |
1548 | if ( sharpFormat ) | 1550 | if ( sharpFormat ) |
1549 | sharpFormat->save(calendar); | 1551 | sharpFormat->save(calendar); |
1550 | #endif | 1552 | #endif |
1551 | if ( phoneFormat ) | 1553 | if ( phoneFormat ) |
1552 | phoneFormat->save(calendar); | 1554 | phoneFormat->save(calendar); |
1553 | iL = calendar->rawIncidences(); | 1555 | iL = calendar->rawIncidences(); |
1554 | inc = iL.first(); | 1556 | inc = iL.first(); |
1555 | Incidence* loc; | 1557 | Incidence* loc; |
1556 | while ( inc ) { | 1558 | while ( inc ) { |
1557 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { | 1559 | if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { |
1558 | loc = mCalendar->incidence(inc->uid() ); | 1560 | loc = mCalendar->incidence(inc->uid() ); |
1559 | if ( loc ) { | 1561 | if ( loc ) { |
1560 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); | 1562 | loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); |
1561 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); | 1563 | loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); |
1562 | } | 1564 | } |
1563 | } | 1565 | } |
1564 | inc = iL.next(); | 1566 | inc = iL.next(); |
1565 | } | 1567 | } |
1566 | Incidence* lse = getLastSyncEvent(); | 1568 | Incidence* lse = getLastSyncEvent(); |
1567 | if ( lse ) { | 1569 | if ( lse ) { |
1568 | lse->setReadOnly( false ); | 1570 | lse->setReadOnly( false ); |
1569 | lse->setDescription( "" ); | 1571 | lse->setDescription( "" ); |
1570 | lse->setReadOnly( true ); | 1572 | lse->setReadOnly( true ); |
1571 | } | 1573 | } |
1572 | } | 1574 | } |
1573 | } else { | 1575 | } else { |
1574 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); | 1576 | topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); |
1575 | } | 1577 | } |
1576 | setModified( true ); | 1578 | setModified( true ); |
1577 | } else { | 1579 | } else { |
1578 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; | 1580 | QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; |
1579 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), | 1581 | QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), |
1580 | question, i18n("Ok")) ; | 1582 | question, i18n("Ok")) ; |
1581 | 1583 | ||
1582 | } | 1584 | } |
1583 | delete calendar; | 1585 | delete calendar; |
1584 | updateView(); | 1586 | updateView(); |
1585 | emit tempDisableBR(false); | 1587 | emit tempDisableBR(false); |
1586 | return ;//syncOK; | 1588 | return ;//syncOK; |
1587 | 1589 | ||
1588 | } | 1590 | } |
1589 | 1591 | ||
1590 | bool CalendarView::importBday() | 1592 | bool CalendarView::importBday() |
1591 | { | 1593 | { |
1592 | #ifndef KORG_NOKABC | 1594 | #ifndef KORG_NOKABC |
1593 | 1595 | ||
1594 | #ifdef DESKTOP_VERSION | 1596 | #ifdef DESKTOP_VERSION |
1595 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); | 1597 | KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); |
1596 | KABC::AddressBook::Iterator it; | 1598 | KABC::AddressBook::Iterator it; |
1597 | int count = 0; | 1599 | int count = 0; |
1598 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { | 1600 | for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { |
1599 | ++count; | 1601 | ++count; |
1600 | } | 1602 | } |
1601 | QProgressBar bar(count,0 ); | 1603 | QProgressBar bar(count,0 ); |
1602 | int w = 300; | 1604 | int w = 300; |
1603 | if ( QApplication::desktop()->width() < 320 ) | 1605 | if ( QApplication::desktop()->width() < 320 ) |