summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-03 23:47:47 (UTC)
committer zautrix <zautrix>2005-06-03 23:47:47 (UTC)
commit0e0ac7a92ac2fe052b3e72d49e505a078b05e7f3 (patch) (unidiff)
tree01c96ae843e7a988d6957a5353616b42e0b322da
parentaa0f7df485c3ff0c298d4924ac1e8a5e9e6da627 (diff)
downloadkdepimpi-0e0ac7a92ac2fe052b3e72d49e505a078b05e7f3.zip
kdepimpi-0e0ac7a92ac2fe052b3e72d49e505a078b05e7f3.tar.gz
kdepimpi-0e0ac7a92ac2fe052b3e72d49e505a078b05e7f3.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index c01be9b..5132f98 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,1430 +1,1434 @@
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
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
142 142
143{ 143{
144 mAlarms = alarms; 144 mAlarms = alarms;
145 setBackgroundColor( QColor( 86, 153, 205 ) ); 145 setBackgroundColor( QColor( 86, 153, 205 ) );
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\"><h1>";
150#else
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
150#else
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></h1>";
159#else
160 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
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->type() == "Event" ) { 173 if ( inc->type() == "Event" ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->type() == "Todo" ) { 175 } else if ( inc->type() == "Todo" ) {
176 tempText += "href=\"todo:"; 176 tempText += "href=\"todo:";
177 } 177 }
178 tempText += inc->uid() + "\">"; 178 tempText += inc->uid() + "\">";
179 if ( inc->type() == "Todo" ) 179 if ( inc->type() == "Todo" )
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 time = 1; 191 time = 1;
192 mText +="</table>"; 192 mText +="</table>";
193 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
194 mText += "<table>"; 194 mText += "<table>";
195 195
196 } 196 }
197 if ( dt.date() > QDate::currentDate() && time != 2 ) { 197 if ( dt.date() > QDate::currentDate() && time != 2 ) {
198 time = 2; 198 time = 2;
199 mText +="</table>"; 199 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
201 mText += "<table>"; 201 mText += "<table>";
202 } 202 }
203 mText +="<tr><td><b>"; 203 mText +="<tr><td><b>";
204 mText += timestr; 204 mText += timestr;
205 mText += "</b></td><td>"; 205 mText += "</b></td><td>";
206 mText += tempText; 206 mText += tempText;
207 mText += "</td></tr>\n"; 207 mText += "</td></tr>\n";
208 inc = getNextInc( start ); 208 inc = getNextInc( start );
209 } 209 }
210 mText +="</table>"; 210 mText +="</table>";
211 setText( mText ); 211 setText( mText );
212} 212}
213 213
214Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 214Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
215{ 215{
216 QDateTime dt ; 216 QDateTime dt ;
217 Incidence * retInc; 217 Incidence * retInc;
218 Incidence * inc = mAlarms.first(); 218 Incidence * inc = mAlarms.first();
219 if ( inc == 0 ) 219 if ( inc == 0 )
220 return 0; 220 return 0;
221 bool ok; 221 bool ok;
222 dt = inc->getNextOccurence( start, &ok ); 222 dt = inc->getNextOccurence( start, &ok );
223 if ( ! ok ) return 0; 223 if ( ! ok ) return 0;
224 QDateTime dtn ; 224 QDateTime dtn ;
225 retInc = inc; 225 retInc = inc;
226 inc = mAlarms.next(); 226 inc = mAlarms.next();
227 while ( inc ) { 227 while ( inc ) {
228 dtn = inc->getNextOccurence( start, &ok ); 228 dtn = inc->getNextOccurence( start, &ok );
229 if ( ! ok ) return 0; 229 if ( ! ok ) return 0;
230 if ( dtn < dt ) { 230 if ( dtn < dt ) {
231 dt = dtn; 231 dt = dtn;
232 retInc = inc; 232 retInc = inc;
233 } 233 }
234 inc = mAlarms.next(); 234 inc = mAlarms.next();
235 } 235 }
236 mAlarms.remove( retInc ); 236 mAlarms.remove( retInc );
237 return retInc; 237 return retInc;
238 238
239} 239}
240void MissedAlarmTextBrowser::setSource(const QString & n) 240void MissedAlarmTextBrowser::setSource(const QString & n)
241{ 241{
242 if (n.startsWith("event:")) { 242 if (n.startsWith("event:")) {
243#ifdef DESKTOP_VERSION 243#ifdef DESKTOP_VERSION
244 emit showIncidence(n.mid(8)); 244 emit showIncidence(n.mid(8));
245#else 245#else
246 emit showIncidence(n.mid(6)); 246 emit showIncidence(n.mid(6));
247#endif 247#endif
248 return; 248 return;
249 } else if (n.startsWith("todo:")) { 249 } else if (n.startsWith("todo:")) {
250#ifdef DESKTOP_VERSION 250#ifdef DESKTOP_VERSION
251 emit showIncidence(n.mid(7)); 251 emit showIncidence(n.mid(7));
252#else 252#else
253 emit showIncidence(n.mid(5)); 253 emit showIncidence(n.mid(5));
254#endif 254#endif
255 return; 255 return;
256 } 256 }
257} 257}
258 258
259 259
260class KOBeamPrefs : public QDialog 260class KOBeamPrefs : public QDialog
261{ 261{
262 public: 262 public:
263 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 263 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
264 QDialog( parent, name, true ) 264 QDialog( parent, name, true )
265 { 265 {
266 setCaption( i18n("Beam Options") ); 266 setCaption( i18n("Beam Options") );
267 QVBoxLayout* lay = new QVBoxLayout( this ); 267 QVBoxLayout* lay = new QVBoxLayout( this );
268 lay->setSpacing( 3 ); 268 lay->setSpacing( 3 );
269 lay->setMargin( 3 ); 269 lay->setMargin( 3 );
270 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 270 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
271 lay->addWidget( format ); 271 lay->addWidget( format );
272 format->setExclusive ( true ) ; 272 format->setExclusive ( true ) ;
273 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 273 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
274 lay->addWidget( time ); time->setExclusive ( true ) ; 274 lay->addWidget( time ); time->setExclusive ( true ) ;
275 vcal = new QRadioButton(" vCalendar ", format ); 275 vcal = new QRadioButton(" vCalendar ", format );
276 ical = new QRadioButton(" iCalendar ", format ); 276 ical = new QRadioButton(" iCalendar ", format );
277 vcal->setChecked( true ); 277 vcal->setChecked( true );
278 tz = new QRadioButton(i18n(" With timezone "), time ); 278 tz = new QRadioButton(i18n(" With timezone "), time );
279 local = new QRadioButton(i18n(" Local time "), time ); 279 local = new QRadioButton(i18n(" Local time "), time );
280 tz->setChecked( true ); 280 tz->setChecked( true );
281 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 281 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
282 lay->addWidget( ok ); 282 lay->addWidget( ok );
283 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 283 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
284 lay->addWidget( cancel ); 284 lay->addWidget( cancel );
285 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 285 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
286 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 286 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
287 resize( 200, 200 ); 287 resize( 200, 200 );
288 } 288 }
289 289
290 bool beamVcal() { return vcal->isChecked(); } 290 bool beamVcal() { return vcal->isChecked(); }
291 bool beamLocal() { return local->isChecked(); } 291 bool beamLocal() { return local->isChecked(); }
292private: 292private:
293 QRadioButton* vcal, *ical, *local, *tz; 293 QRadioButton* vcal, *ical, *local, *tz;
294}; 294};
295class KOCatPrefs : public QDialog 295class KOCatPrefs : public QDialog
296{ 296{
297 public: 297 public:
298 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 298 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
299 QDialog( parent, name, true ) 299 QDialog( parent, name, true )
300 { 300 {
301 setCaption( i18n("Manage new Categories") ); 301 setCaption( i18n("Manage new Categories") );
302 QVBoxLayout* lay = new QVBoxLayout( this ); 302 QVBoxLayout* lay = new QVBoxLayout( this );
303 lay->setSpacing( 3 ); 303 lay->setSpacing( 3 );
304 lay->setMargin( 3 ); 304 lay->setMargin( 3 );
305 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 ); 305 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 );
306 lay->addWidget( lab ); 306 lay->addWidget( lab );
307 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 307 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
308 lay->addWidget( format ); 308 lay->addWidget( format );
309 format->setExclusive ( true ) ; 309 format->setExclusive ( true ) ;
310 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 310 addCatBut = new QRadioButton(i18n("Add to category list"), format );
311 new QRadioButton(i18n("Remove from Events/Todos"), format ); 311 new QRadioButton(i18n("Remove from Events/Todos"), format );
312 addCatBut->setChecked( true ); 312 addCatBut->setChecked( true );
313 QPushButton * ok = new QPushButton( i18n("OK"), this ); 313 QPushButton * ok = new QPushButton( i18n("OK"), this );
314 lay->addWidget( ok ); 314 lay->addWidget( ok );
315 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 315 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
316 lay->addWidget( cancel ); 316 lay->addWidget( cancel );
317 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 317 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
318 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 318 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
319 resize( 200, 200 ); 319 resize( 200, 200 );
320 } 320 }
321 321
322 bool addCat() { return addCatBut->isChecked(); } 322 bool addCat() { return addCatBut->isChecked(); }
323private: 323private:
324 QRadioButton* addCatBut; 324 QRadioButton* addCatBut;
325}; 325};
326 326
327 327
328 328
329CalendarView::CalendarView( CalendarResources *calendar, 329CalendarView::CalendarView( CalendarResources *calendar,
330 QWidget *parent, const char *name ) 330 QWidget *parent, const char *name )
331 : CalendarViewBase( parent, name ), 331 : CalendarViewBase( parent, name ),
332 mCalendar( calendar ), 332 mCalendar( calendar ),
333 mResourceManager( calendar->resourceManager() ) 333 mResourceManager( calendar->resourceManager() )
334{ 334{
335 335
336 mEventEditor = 0; 336 mEventEditor = 0;
337 mTodoEditor = 0; 337 mTodoEditor = 0;
338 338
339 init(); 339 init();
340} 340}
341 341
342CalendarView::CalendarView( Calendar *calendar, 342CalendarView::CalendarView( Calendar *calendar,
343 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 345 mCalendar( calendar ),
346 mResourceManager( 0 ) 346 mResourceManager( 0 )
347{ 347{
348 348
349 mEventEditor = 0; 349 mEventEditor = 0;
350 mTodoEditor = 0; 350 mTodoEditor = 0;
351 init(); 351 init();
352} 352}
353 353
354void CalendarView::init() 354void CalendarView::init()
355{ 355{
356 mNextAlarmDateTime = QDateTime::currentDateTime(); 356 mNextAlarmDateTime = QDateTime::currentDateTime();
357 setFocusPolicy ( NoFocus ); 357 setFocusPolicy ( NoFocus );
358 mViewerCallerIsSearchDialog = false; 358 mViewerCallerIsSearchDialog = false;
359 mBlockShowDates = false; 359 mBlockShowDates = false;
360 beamDialog = new KOBeamPrefs(); 360 beamDialog = new KOBeamPrefs();
361 mDatePickerMode = 0; 361 mDatePickerMode = 0;
362 mCurrentSyncDevice = ""; 362 mCurrentSyncDevice = "";
363 writeLocale(); 363 writeLocale();
364 mViewManager = new KOViewManager( this ); 364 mViewManager = new KOViewManager( this );
365 mDialogManager = new KODialogManager( this ); 365 mDialogManager = new KODialogManager( this );
366 mEventViewerDialog = 0; 366 mEventViewerDialog = 0;
367 mModified = false; 367 mModified = false;
368 mReadOnly = false; 368 mReadOnly = false;
369 mSelectedIncidence = 0; 369 mSelectedIncidence = 0;
370 mCalPrinter = 0; 370 mCalPrinter = 0;
371 mFilters.setAutoDelete(true); 371 mFilters.setAutoDelete(true);
372 372
373 mCalendar->registerObserver( this ); 373 mCalendar->registerObserver( this );
374 // TODO: Make sure that view is updated, when calendar is changed. 374 // TODO: Make sure that view is updated, when calendar is changed.
375 375
376 mStorage = new FileStorage( mCalendar ); 376 mStorage = new FileStorage( mCalendar );
377 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 377 mNavigator = new DateNavigator( this, "datevav", mViewManager );
378 378
379 QBoxLayout *topLayout = (QBoxLayout*)layout(); 379 QBoxLayout *topLayout = (QBoxLayout*)layout();
380#ifndef KORG_NOSPLITTER 380#ifndef KORG_NOSPLITTER
381 // create the main layout frames. 381 // create the main layout frames.
382 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 382 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
383 topLayout->addWidget(mPanner); 383 topLayout->addWidget(mPanner);
384 384
385 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 385 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
386 "CalendarView::LeftFrame"); 386 "CalendarView::LeftFrame");
387 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 387 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
388 388
389 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 389 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
390 "CalendarView::DateNavigator" ); 390 "CalendarView::DateNavigator" );
391 391
392 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 392 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
393 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 393 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
394 mTodoList->setNavigator( mNavigator ); 394 mTodoList->setNavigator( mNavigator );
395 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 395 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
396 396
397#ifdef KORG_NORESOURCEVIEW 397#ifdef KORG_NORESOURCEVIEW
398 mResourceView = 0; 398 mResourceView = 0;
399#else 399#else
400 if ( mResourceManager ) { 400 if ( mResourceManager ) {
401 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 401 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
402 mResourceView->updateView(); 402 mResourceView->updateView();
403 connect( mResourceView, SIGNAL( resourcesChanged() ), 403 connect( mResourceView, SIGNAL( resourcesChanged() ),
404 SLOT( updateView() ) ); 404 SLOT( updateView() ) );
405 } else { 405 } else {
406 mResourceView = 0; 406 mResourceView = 0;
407 } 407 }
408#endif 408#endif
409 QWidget *rightBox = new QWidget( mPanner ); 409 QWidget *rightBox = new QWidget( mPanner );
410 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 410 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
411 411
412 mRightFrame = new QWidgetStack( rightBox ); 412 mRightFrame = new QWidgetStack( rightBox );
413 rightLayout->addWidget( mRightFrame, 1 ); 413 rightLayout->addWidget( mRightFrame, 1 );
414 414
415 mLeftFrame = mLeftSplitter; 415 mLeftFrame = mLeftSplitter;
416#else 416#else
417 //QWidget *mainBox = new QWidget( this ); 417 //QWidget *mainBox = new QWidget( this );
418 //QWidget *leftFrame = new QWidget( mainBox ); 418 //QWidget *leftFrame = new QWidget( mainBox );
419 //QBoxLayout * mainBoxLayout; 419 //QBoxLayout * mainBoxLayout;
420 if ( KOPrefs::instance()->mVerticalScreen ) { 420 if ( KOPrefs::instance()->mVerticalScreen ) {
421 //mainBoxLayout = new QVBoxLayout(mainBox); 421 //mainBoxLayout = new QVBoxLayout(mainBox);
422 //leftFrameLayout = new QHBoxLayout(leftFrame ); 422 //leftFrameLayout = new QHBoxLayout(leftFrame );
423 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 423 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
424 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 424 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
425 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 425 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
426 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 426 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
427 } else { 427 } else {
428 //mainBoxLayout = new QHBoxLayout(mainBox); 428 //mainBoxLayout = new QHBoxLayout(mainBox);
429 //leftFrameLayout = new QVBoxLayout(leftFrame ); 429 //leftFrameLayout = new QVBoxLayout(leftFrame );
430 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 430 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
431 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 431 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
432 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 432 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
433 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 433 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
434 } 434 }
435 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 435 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
436 //QBoxLayout * leftFrameLayout; 436 //QBoxLayout * leftFrameLayout;
437 topLayout->addWidget( mMainFrame ); 437 topLayout->addWidget( mMainFrame );
438 //mainBoxLayout->addWidget (mLeftFrame); 438 //mainBoxLayout->addWidget (mLeftFrame);
439 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 439 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
440 "CalendarView::DateNavigator" ); 440 "CalendarView::DateNavigator" );
441#if 0 441#if 0
442 // FIXME 442 // FIXME
443 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 443 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
444 "CalendarView::DateNavigator", QDate::currentDate()); 444 "CalendarView::DateNavigator", QDate::currentDate());
445#endif 445#endif
446 // mDateNavigator->blockSignals( true ); 446 // mDateNavigator->blockSignals( true );
447 //leftFrameLayout->addWidget( mDateNavigator ); 447 //leftFrameLayout->addWidget( mDateNavigator );
448 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 448 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
449 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 449 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
450 mTodoList->setNavigator( mNavigator ); 450 mTodoList->setNavigator( mNavigator );
451#if 0 451#if 0
452 if ( QApplication::desktop()->width() < 480 ) { 452 if ( QApplication::desktop()->width() < 480 ) {
453 leftFrameLayout->addWidget(mFilterView); 453 leftFrameLayout->addWidget(mFilterView);
454 leftFrameLayout->addWidget(mTodoList, 2 ); 454 leftFrameLayout->addWidget(mTodoList, 2 );
455 455
456 } else { 456 } else {
457 leftFrameLayout->addWidget(mTodoList,2 ); 457 leftFrameLayout->addWidget(mTodoList,2 );
458 leftFrameLayout->addWidget(mFilterView ); 458 leftFrameLayout->addWidget(mFilterView );
459 } 459 }
460#endif 460#endif
461 mFilterView->hide(); 461 mFilterView->hide();
462 QWidget *rightBox = new QWidget( mMainFrame ); 462 QWidget *rightBox = new QWidget( mMainFrame );
463 //mainBoxLayout->addWidget ( rightBox, 10 ); 463 //mainBoxLayout->addWidget ( rightBox, 10 );
464 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 464 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
465 mRightFrame = new QWidgetStack( rightBox ); 465 mRightFrame = new QWidgetStack( rightBox );
466 rightLayout->addWidget( mRightFrame, 10 ); 466 rightLayout->addWidget( mRightFrame, 10 );
467 467
468 //mLeftFrame = (QWidget *)leftFrame; 468 //mLeftFrame = (QWidget *)leftFrame;
469 if ( KOPrefs::instance()->mVerticalScreen ) { 469 if ( KOPrefs::instance()->mVerticalScreen ) {
470 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 470 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
471 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 471 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
472 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 472 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
473 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 473 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
474 } else { 474 } else {
475 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 475 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
476 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 476 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
477 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 477 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
478 } 478 }
479 if ( !KOPrefs::instance()->mShowDateNavigator) 479 if ( !KOPrefs::instance()->mShowDateNavigator)
480 mDateNavigator->hide(); 480 mDateNavigator->hide();
481 //qDebug("Calendarview Size %d %d ", width(), height()); 481 //qDebug("Calendarview Size %d %d ", width(), height());
482#endif 482#endif
483 483
484 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 484 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
485 SLOT( showDates( const KCal::DateList & ) ) ); 485 SLOT( showDates( const KCal::DateList & ) ) );
486 486
487 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 487 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
488 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 488 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
489 489
490 490
491 491
492 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 492 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
493 mViewManager, SLOT( showMonth( const QDate & ) ) ); 493 mViewManager, SLOT( showMonth( const QDate & ) ) );
494 494
495 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 495 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
496 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 496 mNavigator, SLOT( selectWeek( const QDate & ) ) );
497 497
498 connect( mDateNavigator, SIGNAL( goPrevYear() ), 498 connect( mDateNavigator, SIGNAL( goPrevYear() ),
499 mNavigator, SLOT( selectPreviousYear() ) ); 499 mNavigator, SLOT( selectPreviousYear() ) );
500 connect( mDateNavigator, SIGNAL( goNextYear() ), 500 connect( mDateNavigator, SIGNAL( goNextYear() ),
501 mNavigator, SLOT( selectNextYear() ) ); 501 mNavigator, SLOT( selectNextYear() ) );
502 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 502 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
503 mNavigator, SLOT( selectPreviousMonth() ) ); 503 mNavigator, SLOT( selectPreviousMonth() ) );
504 connect( mDateNavigator, SIGNAL( goNextMonth() ), 504 connect( mDateNavigator, SIGNAL( goNextMonth() ),
505 mNavigator, SLOT( selectNextMonth() ) ); 505 mNavigator, SLOT( selectNextMonth() ) );
506 506
507 connect( mDateNavigator, SIGNAL( goPrevious() ), 507 connect( mDateNavigator, SIGNAL( goPrevious() ),
508 mNavigator, SLOT( selectPrevious() ) ); 508 mNavigator, SLOT( selectPrevious() ) );
509 connect( mDateNavigator, SIGNAL( goNext() ), 509 connect( mDateNavigator, SIGNAL( goNext() ),
510 mNavigator, SLOT( selectNext() ) ); 510 mNavigator, SLOT( selectNext() ) );
511 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 511 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
512 mNavigator, SLOT( slotMonthSelect( int ) ) ); 512 mNavigator, SLOT( slotMonthSelect( int ) ) );
513 513
514 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 514 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
515 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 515 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
516#if 0 516#if 0
517 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 517 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
518 SLOT( incidenceAdded( Incidence *) ) ); 518 SLOT( incidenceAdded( Incidence *) ) );
519#endif 519#endif
520 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 520 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
521 521
522 connect( this, SIGNAL( configChanged() ), 522 connect( this, SIGNAL( configChanged() ),
523 mDateNavigator, SLOT( updateConfig() ) ); 523 mDateNavigator, SLOT( updateConfig() ) );
524 524
525 connect( mTodoList, SIGNAL( newTodoSignal() ), 525 connect( mTodoList, SIGNAL( newTodoSignal() ),
526 SLOT( newTodo() ) ); 526 SLOT( newTodo() ) );
527 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 527 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
528 SLOT( newSubTodo( Todo * ) ) ); 528 SLOT( newSubTodo( Todo * ) ) );
529 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 529 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
530 SLOT( editTodo( Todo * ) ) ); 530 SLOT( editTodo( Todo * ) ) );
531 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 531 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
532 SLOT( showTodo( Todo *) ) ); 532 SLOT( showTodo( Todo *) ) );
533 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 533 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
534 SLOT( deleteTodo( Todo *) ) ); 534 SLOT( deleteTodo( Todo *) ) );
535 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 535 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
536 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 536 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
537 SLOT( purgeCompleted() ) ); 537 SLOT( purgeCompleted() ) );
538 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 538 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
539 SIGNAL( todoModified( Todo *, int ) ) ); 539 SIGNAL( todoModified( Todo *, int ) ) );
540 540
541 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 541 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
542 this, SLOT ( cloneIncidence( Incidence * ) ) ); 542 this, SLOT ( cloneIncidence( Incidence * ) ) );
543 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 543 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
544 this, SLOT (cancelIncidence( Incidence * ) ) ); 544 this, SLOT (cancelIncidence( Incidence * ) ) );
545 545
546 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 546 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
547 this, SLOT ( moveIncidence( Incidence * ) ) ); 547 this, SLOT ( moveIncidence( Incidence * ) ) );
548 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 548 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
549 this, SLOT ( beamIncidence( Incidence * ) ) ); 549 this, SLOT ( beamIncidence( Incidence * ) ) );
550 550
551 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 551 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
552 this, SLOT ( todo_unsub( Todo * ) ) ); 552 this, SLOT ( todo_unsub( Todo * ) ) );
553 553
554 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 554 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
555 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 555 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
556 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 556 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
557 SLOT( updateTodo( Todo *, int ) ) ); 557 SLOT( updateTodo( Todo *, int ) ) );
558 connect( this, SIGNAL( todoModified( Todo *, int )), this, 558 connect( this, SIGNAL( todoModified( Todo *, int )), this,
559 SLOT( changeTodoDisplay( Todo *, int ) ) ); 559 SLOT( changeTodoDisplay( Todo *, int ) ) );
560 560
561 561
562 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 562 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
563 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 563 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
564 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 564 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
565 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 565 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
566 566
567 567
568 568
569 569
570 570
571 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 571 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
572 SLOT(checkClipboard())); 572 SLOT(checkClipboard()));
573 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 573 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
574 SLOT( processTodoListSelection( Incidence * ) ) ); 574 SLOT( processTodoListSelection( Incidence * ) ) );
575 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 575 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
576 576
577 // kdDebug() << "CalendarView::CalendarView() done" << endl; 577 // kdDebug() << "CalendarView::CalendarView() done" << endl;
578 578
579 mDateFrame = new QVBox(0,0,WType_Popup); 579 mDateFrame = new QVBox(0,0,WType_Popup);
580 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 580 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
581 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 581 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
582 mDateFrame->setLineWidth(3); 582 mDateFrame->setLineWidth(3);
583 mDateFrame->hide(); 583 mDateFrame->hide();
584 mDateFrame->setCaption( i18n( "Pick a date to display")); 584 mDateFrame->setCaption( i18n( "Pick a date to display"));
585 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 585 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
586 586
587 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 587 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
588 588
589 mEventEditor = mDialogManager->getEventEditor(); 589 mEventEditor = mDialogManager->getEventEditor();
590 mTodoEditor = mDialogManager->getTodoEditor(); 590 mTodoEditor = mDialogManager->getTodoEditor();
591 591
592 mFlagEditDescription = false; 592 mFlagEditDescription = false;
593 593
594 mSuspendTimer = new QTimer( this ); 594 mSuspendTimer = new QTimer( this );
595 mAlarmTimer = new QTimer( this ); 595 mAlarmTimer = new QTimer( this );
596 mRecheckAlarmTimer = new QTimer( this ); 596 mRecheckAlarmTimer = new QTimer( this );
597 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 597 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
598 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 598 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
599 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 599 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
600 mAlarmDialog = new AlarmDialog( this ); 600 mAlarmDialog = new AlarmDialog( this );
601 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 601 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
602 mAlarmDialog->setServerNotification( false ); 602 mAlarmDialog->setServerNotification( false );
603 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 603 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
604 604
605 605
606#ifndef DESKTOP_VERSION 606#ifndef DESKTOP_VERSION
607//US listen for arriving address resultsets 607//US listen for arriving address resultsets
608 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 608 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
609 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 609 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
610#endif 610#endif
611 mDateNavigator->setCalendar( mCalendar ); 611 mDateNavigator->setCalendar( mCalendar );
612} 612}
613 613
614 614
615CalendarView::~CalendarView() 615CalendarView::~CalendarView()
616{ 616{
617 // kdDebug() << "~CalendarView()" << endl; 617 // kdDebug() << "~CalendarView()" << endl;
618 //qDebug("CalendarView::~CalendarView() "); 618 //qDebug("CalendarView::~CalendarView() ");
619 delete mDialogManager; 619 delete mDialogManager;
620 delete mViewManager; 620 delete mViewManager;
621 delete mStorage; 621 delete mStorage;
622 delete mDateFrame ; 622 delete mDateFrame ;
623 delete beamDialog; 623 delete beamDialog;
624 delete mEventViewerDialog; 624 delete mEventViewerDialog;
625 //kdDebug() << "~CalendarView() done" << endl; 625 //kdDebug() << "~CalendarView() done" << endl;
626} 626}
627void CalendarView::checkAlarms() 627void CalendarView::checkAlarms()
628{ 628{
629 KConfig *config = KOGlobals::config(); 629 KConfig *config = KOGlobals::config();
630 config->setGroup( "AppRun" ); 630 config->setGroup( "AppRun" );
631 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 631 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
632 int secs = config->readNumEntry( "LatestProgramStop" ) - 30; 632 int secs = config->readNumEntry( "LatestProgramStop" ) - 30;
633 secs -= ( 3600 * 24*3 ); // debug only 633 secs -= ( 3600 * 24*3 ); // debug only
634 QDateTime latest = dt.addSecs ( secs ); 634 QDateTime latest = dt.addSecs ( secs );
635 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 635 qDebug("KO: Last termination on %s ", latest.toString().latin1());
636 QPtrList<Incidence> el = mCalendar->rawIncidences(); 636 QPtrList<Incidence> el = mCalendar->rawIncidences();
637 QPtrList<Incidence> al; 637 QPtrList<Incidence> al;
638 Incidence* inL = el.first(); 638 Incidence* inL = el.first();
639 while ( inL ) { 639 while ( inL ) {
640 bool ok = false; 640 bool ok = false;
641 int offset = 0; 641 int offset = 0;
642 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 642 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
643 if ( ok ) { 643 if ( ok ) {
644 //qDebug("OK %s",next.toString().latin1()); 644 //qDebug("OK %s",next.toString().latin1());
645 if ( next < QDateTime::currentDateTime() ) { 645 if ( next < QDateTime::currentDateTime() ) {
646 al.append( inL ); 646 al.append( inL );
647 qDebug("found missed alarm: %s ", inL->summary().latin1() ); 647 qDebug("found missed alarm: %s ", inL->summary().latin1() );
648 } 648 }
649 } 649 }
650 inL = el.next(); 650 inL = el.next();
651 } 651 }
652 if ( al.count() ) { 652 if ( al.count() ) {
653 QDialog dia ( this, "huhu", true ); 653 QDialog* dia = new QDialog( this, "huhu", false );
654 dia.setCaption( i18n("KO/Pi: Missing alarm notification!") ); 654 dia->setCaption( i18n("KO/Pi: Missing alarm notification!") );
655 QVBoxLayout* lay = new QVBoxLayout( &dia ); 655 QVBoxLayout* lay = new QVBoxLayout( dia );
656 lay->setSpacing( 3 ); 656 lay->setSpacing( 0 );
657 lay->setMargin( 3 ); 657 lay->setMargin( 0 );
658 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( &dia, al, latest ); 658 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
659 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 659 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
660 lay->addWidget( matb ); 660 lay->addWidget( matb );
661 dia.resize(240,240); 661 int si = 220;
662 dia.exec(); 662 if ( QApplication::desktop()->width() > 470 )
663 si = 400;
664 dia->resize(si,si/2);
665 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
666 dia->show();
663 667
664 } 668 }
665} 669}
666void CalendarView::showDay( QDate d ) 670void CalendarView::showDay( QDate d )
667{ 671{
668 dateNavigator()->blockSignals( true ); 672 dateNavigator()->blockSignals( true );
669 dateNavigator()->selectDate( d ); 673 dateNavigator()->selectDate( d );
670 dateNavigator()->blockSignals( false ); 674 dateNavigator()->blockSignals( false );
671 mViewManager->showDayView(); 675 mViewManager->showDayView();
672 //dateNavigator()->selectDate( d ); 676 //dateNavigator()->selectDate( d );
673} 677}
674void CalendarView::timerAlarm() 678void CalendarView::timerAlarm()
675{ 679{
676 //qDebug("CalendarView::timerAlarm() "); 680 //qDebug("CalendarView::timerAlarm() ");
677 computeAlarm(mAlarmNotification ); 681 computeAlarm(mAlarmNotification );
678} 682}
679 683
680void CalendarView::suspendAlarm() 684void CalendarView::suspendAlarm()
681{ 685{
682 //qDebug(" CalendarView::suspendAlarm() "); 686 //qDebug(" CalendarView::suspendAlarm() ");
683 computeAlarm(mSuspendAlarmNotification ); 687 computeAlarm(mSuspendAlarmNotification );
684 688
685} 689}
686 690
687void CalendarView::startAlarm( QString mess , QString filename) 691void CalendarView::startAlarm( QString mess , QString filename)
688{ 692{
689 693
690 topLevelWidget()->showNormal(); 694 topLevelWidget()->showNormal();
691 topLevelWidget()->setActiveWindow(); 695 topLevelWidget()->setActiveWindow();
692 topLevelWidget()->raise(); 696 topLevelWidget()->raise();
693 697
694 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 698 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
695 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 699 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
696 700
697} 701}
698 702
699void CalendarView::checkNextTimerAlarm() 703void CalendarView::checkNextTimerAlarm()
700{ 704{
701 mCalendar->checkAlarmForIncidence( 0, true ); 705 mCalendar->checkAlarmForIncidence( 0, true );
702} 706}
703 707
704void CalendarView::computeAlarm( QString msg ) 708void CalendarView::computeAlarm( QString msg )
705{ 709{
706 710
707 QString mess = msg; 711 QString mess = msg;
708 QString mAlarmMessage = mess.mid( 9 ); 712 QString mAlarmMessage = mess.mid( 9 );
709 QString filename = MainWindow::resourcePath(); 713 QString filename = MainWindow::resourcePath();
710 filename += "koalarm.wav"; 714 filename += "koalarm.wav";
711 QString tempfilename; 715 QString tempfilename;
712 if ( mess.left( 13 ) == "suspend_alarm") { 716 if ( mess.left( 13 ) == "suspend_alarm") {
713 bool error = false; 717 bool error = false;
714 int len = mess.mid( 13 ).find("+++"); 718 int len = mess.mid( 13 ).find("+++");
715 if ( len < 2 ) 719 if ( len < 2 )
716 error = true; 720 error = true;
717 else { 721 else {
718 tempfilename = mess.mid( 13, len ); 722 tempfilename = mess.mid( 13, len );
719 if ( !QFile::exists( tempfilename ) ) 723 if ( !QFile::exists( tempfilename ) )
720 error = true; 724 error = true;
721 } 725 }
722 if ( ! error ) { 726 if ( ! error ) {
723 filename = tempfilename; 727 filename = tempfilename;
724 } 728 }
725 mAlarmMessage = mess.mid( 13+len+3 ); 729 mAlarmMessage = mess.mid( 13+len+3 );
726 //qDebug("suspend file %s ",tempfilename.latin1() ); 730 //qDebug("suspend file %s ",tempfilename.latin1() );
727 startAlarm( mAlarmMessage, filename); 731 startAlarm( mAlarmMessage, filename);
728 return; 732 return;
729 } 733 }
730 if ( mess.left( 11 ) == "timer_alarm") { 734 if ( mess.left( 11 ) == "timer_alarm") {
731 //mTimerTime = 0; 735 //mTimerTime = 0;
732 startAlarm( mess.mid( 11 ), filename ); 736 startAlarm( mess.mid( 11 ), filename );
733 return; 737 return;
734 } 738 }
735 if ( mess.left( 10 ) == "proc_alarm") { 739 if ( mess.left( 10 ) == "proc_alarm") {
736 bool error = false; 740 bool error = false;
737 int len = mess.mid( 10 ).find("+++"); 741 int len = mess.mid( 10 ).find("+++");
738 if ( len < 2 ) 742 if ( len < 2 )
739 error = true; 743 error = true;
740 else { 744 else {
741 tempfilename = mess.mid( 10, len ); 745 tempfilename = mess.mid( 10, len );
742 if ( !QFile::exists( tempfilename ) ) 746 if ( !QFile::exists( tempfilename ) )
743 error = true; 747 error = true;
744 } 748 }
745 if ( error ) { 749 if ( error ) {
746 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 750 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
747 mAlarmMessage += mess.mid( 10+len+3+9 ); 751 mAlarmMessage += mess.mid( 10+len+3+9 );
748 } else { 752 } else {
749 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 753 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
750 //qDebug("-----system command %s ",tempfilename.latin1() ); 754 //qDebug("-----system command %s ",tempfilename.latin1() );
751#ifndef _WIN32_ 755#ifndef _WIN32_
752 if ( vfork () == 0 ) { 756 if ( vfork () == 0 ) {
753 execl ( tempfilename.latin1(), 0 ); 757 execl ( tempfilename.latin1(), 0 );
754 return; 758 return;
755 } 759 }
756#else 760#else
757 QProcess* p = new QProcess(); 761 QProcess* p = new QProcess();
758 p->addArgument( tempfilename.latin1() ); 762 p->addArgument( tempfilename.latin1() );
759 p->start(); 763 p->start();
760 return; 764 return;
761#endif 765#endif
762 766
763 return; 767 return;
764 } 768 }
765 769
766 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 770 //qDebug("+++++++system command %s ",tempfilename.latin1() );
767 } 771 }
768 if ( mess.left( 11 ) == "audio_alarm") { 772 if ( mess.left( 11 ) == "audio_alarm") {
769 bool error = false; 773 bool error = false;
770 int len = mess.mid( 11 ).find("+++"); 774 int len = mess.mid( 11 ).find("+++");
771 if ( len < 2 ) 775 if ( len < 2 )
772 error = true; 776 error = true;
773 else { 777 else {
774 tempfilename = mess.mid( 11, len ); 778 tempfilename = mess.mid( 11, len );
775 if ( !QFile::exists( tempfilename ) ) 779 if ( !QFile::exists( tempfilename ) )
776 error = true; 780 error = true;
777 } 781 }
778 if ( ! error ) { 782 if ( ! error ) {
779 filename = tempfilename; 783 filename = tempfilename;
780 } 784 }
781 mAlarmMessage = mess.mid( 11+len+3+9 ); 785 mAlarmMessage = mess.mid( 11+len+3+9 );
782 //qDebug("audio file command %s ",tempfilename.latin1() ); 786 //qDebug("audio file command %s ",tempfilename.latin1() );
783 } 787 }
784 if ( mess.left( 9 ) == "cal_alarm") { 788 if ( mess.left( 9 ) == "cal_alarm") {
785 mAlarmMessage = mess.mid( 9 ) ; 789 mAlarmMessage = mess.mid( 9 ) ;
786 } 790 }
787 791
788 startAlarm( mAlarmMessage, filename ); 792 startAlarm( mAlarmMessage, filename );
789 793
790 794
791} 795}
792 796
793void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 797void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
794{ 798{
795 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 799 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
796 800
797 mSuspendAlarmNotification = noti; 801 mSuspendAlarmNotification = noti;
798 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 802 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
799 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 803 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
800 mSuspendTimer->start( ms , true ); 804 mSuspendTimer->start( ms , true );
801 805
802} 806}
803 807
804void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 808void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
805{ 809{
806 mNextAlarmDateTime = qdt; 810 mNextAlarmDateTime = qdt;
807 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 811 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
808 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 812 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
809#ifndef DESKTOP_VERSION 813#ifndef DESKTOP_VERSION
810 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 814 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
811#endif 815#endif
812 return; 816 return;
813 } 817 }
814 int maxSec; 818 int maxSec;
815 //maxSec = 5; //testing only 819 //maxSec = 5; //testing only
816 maxSec = 86400+3600; // one day+1hour 820 maxSec = 86400+3600; // one day+1hour
817 mAlarmNotification = noti; 821 mAlarmNotification = noti;
818 int sec = QDateTime::currentDateTime().secsTo( qdt ); 822 int sec = QDateTime::currentDateTime().secsTo( qdt );
819 if ( sec > maxSec ) { 823 if ( sec > maxSec ) {
820 mRecheckAlarmTimer->start( maxSec * 1000 ); 824 mRecheckAlarmTimer->start( maxSec * 1000 );
821 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 825 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
822 return; 826 return;
823 } else { 827 } else {
824 mRecheckAlarmTimer->stop(); 828 mRecheckAlarmTimer->stop();
825 } 829 }
826 //qDebug("Alarm timer started with secs: %d ", sec); 830 //qDebug("Alarm timer started with secs: %d ", sec);
827 mAlarmTimer->start( sec *1000 , true ); 831 mAlarmTimer->start( sec *1000 , true );
828 832
829} 833}
830// called by mRecheckAlarmTimer to get next alarm 834// called by mRecheckAlarmTimer to get next alarm
831// we need this, because a QTimer has only a max range of 25 days 835// we need this, because a QTimer has only a max range of 25 days
832void CalendarView::recheckTimerAlarm() 836void CalendarView::recheckTimerAlarm()
833{ 837{
834 mAlarmTimer->stop(); 838 mAlarmTimer->stop();
835 mRecheckAlarmTimer->stop(); 839 mRecheckAlarmTimer->stop();
836 mCalendar->checkAlarmForIncidence( 0, true ); 840 mCalendar->checkAlarmForIncidence( 0, true );
837} 841}
838void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 842void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
839{ 843{
840 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 844 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
841 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 845 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
842#ifndef DESKTOP_VERSION 846#ifndef DESKTOP_VERSION
843 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 847 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
844#endif 848#endif
845 return; 849 return;
846 } 850 }
847 mAlarmTimer->stop(); 851 mAlarmTimer->stop();
848} 852}
849void CalendarView::selectWeekNum ( int num ) 853void CalendarView::selectWeekNum ( int num )
850{ 854{
851 dateNavigator()->blockSignals( true ); 855 dateNavigator()->blockSignals( true );
852 dateNavigator()->selectWeek( num ); 856 dateNavigator()->selectWeek( num );
853 dateNavigator()->blockSignals( false ); 857 dateNavigator()->blockSignals( false );
854 mViewManager->showWeekView(); 858 mViewManager->showWeekView();
855} 859}
856KOViewManager *CalendarView::viewManager() 860KOViewManager *CalendarView::viewManager()
857{ 861{
858 return mViewManager; 862 return mViewManager;
859} 863}
860 864
861KODialogManager *CalendarView::dialogManager() 865KODialogManager *CalendarView::dialogManager()
862{ 866{
863 return mDialogManager; 867 return mDialogManager;
864} 868}
865 869
866QDate CalendarView::startDate() 870QDate CalendarView::startDate()
867{ 871{
868 DateList dates = mNavigator->selectedDates(); 872 DateList dates = mNavigator->selectedDates();
869 873
870 return dates.first(); 874 return dates.first();
871} 875}
872 876
873QDate CalendarView::endDate() 877QDate CalendarView::endDate()
874{ 878{
875 DateList dates = mNavigator->selectedDates(); 879 DateList dates = mNavigator->selectedDates();
876 880
877 return dates.last(); 881 return dates.last();
878} 882}
879 883
880 884
881void CalendarView::createPrinter() 885void CalendarView::createPrinter()
882{ 886{
883#ifndef KORG_NOPRINTER 887#ifndef KORG_NOPRINTER
884 if (!mCalPrinter) { 888 if (!mCalPrinter) {
885 mCalPrinter = new CalPrinter(this, mCalendar); 889 mCalPrinter = new CalPrinter(this, mCalendar);
886 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 890 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
887 } 891 }
888#endif 892#endif
889} 893}
890 894
891 895
892//KOPrefs::instance()->mWriteBackFile 896//KOPrefs::instance()->mWriteBackFile
893//KOPrefs::instance()->mWriteBackExistingOnly 897//KOPrefs::instance()->mWriteBackExistingOnly
894 898
895// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 899// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
896// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 900// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
897// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 901// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
898// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 902// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
899// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 903// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
900// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 904// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
901 905
902int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 906int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
903{ 907{
904 908
905 // 0 equal 909 // 0 equal
906 // 1 take local 910 // 1 take local
907 // 2 take remote 911 // 2 take remote
908 // 3 cancel 912 // 3 cancel
909 QDateTime lastSync = mLastCalendarSync; 913 QDateTime lastSync = mLastCalendarSync;
910 QDateTime localMod = local->lastModified(); 914 QDateTime localMod = local->lastModified();
911 QDateTime remoteMod = remote->lastModified(); 915 QDateTime remoteMod = remote->lastModified();
912 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 916 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
913 bool remCh, locCh; 917 bool remCh, locCh;
914 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 918 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
915 //if ( remCh ) 919 //if ( remCh )
916 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 920 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
917 locCh = ( localMod > mLastCalendarSync ); 921 locCh = ( localMod > mLastCalendarSync );
918 if ( !remCh && ! locCh ) { 922 if ( !remCh && ! locCh ) {
919 //qDebug("both not changed "); 923 //qDebug("both not changed ");
920 lastSync = localMod.addDays(1); 924 lastSync = localMod.addDays(1);
921 if ( mode <= SYNC_PREF_ASK ) 925 if ( mode <= SYNC_PREF_ASK )
922 return 0; 926 return 0;
923 } else { 927 } else {
924 if ( locCh ) { 928 if ( locCh ) {
925 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 929 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
926 lastSync = localMod.addDays( -1 ); 930 lastSync = localMod.addDays( -1 );
927 if ( !remCh ) 931 if ( !remCh )
928 remoteMod = ( lastSync.addDays( -1 ) ); 932 remoteMod = ( lastSync.addDays( -1 ) );
929 } else { 933 } else {
930 //qDebug(" not loc changed "); 934 //qDebug(" not loc changed ");
931 lastSync = localMod.addDays( 1 ); 935 lastSync = localMod.addDays( 1 );
932 if ( remCh ) 936 if ( remCh )
933 remoteMod =( lastSync.addDays( 1 ) ); 937 remoteMod =( lastSync.addDays( 1 ) );
934 938
935 } 939 }
936 } 940 }
937 full = true; 941 full = true;
938 if ( mode < SYNC_PREF_ASK ) 942 if ( mode < SYNC_PREF_ASK )
939 mode = SYNC_PREF_ASK; 943 mode = SYNC_PREF_ASK;
940 } else { 944 } else {
941 if ( localMod == remoteMod ) 945 if ( localMod == remoteMod )
942 // if ( local->revision() == remote->revision() ) 946 // if ( local->revision() == remote->revision() )
943 return 0; 947 return 0;
944 948
945 } 949 }
946 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 950 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
947 951
948 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 952 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
949 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 953 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
950 //full = true; //debug only 954 //full = true; //debug only
951 if ( full ) { 955 if ( full ) {
952 bool equ = false; 956 bool equ = false;
953 if ( local->type() == "Event" ) { 957 if ( local->type() == "Event" ) {
954 equ = (*((Event*) local) == *((Event*) remote)); 958 equ = (*((Event*) local) == *((Event*) remote));
955 } 959 }
956 else if ( local->type() =="Todo" ) 960 else if ( local->type() =="Todo" )
957 equ = (*((Todo*) local) == (*(Todo*) remote)); 961 equ = (*((Todo*) local) == (*(Todo*) remote));
958 else if ( local->type() =="Journal" ) 962 else if ( local->type() =="Journal" )
959 equ = (*((Journal*) local) == *((Journal*) remote)); 963 equ = (*((Journal*) local) == *((Journal*) remote));
960 if ( equ ) { 964 if ( equ ) {
961 //qDebug("equal "); 965 //qDebug("equal ");
962 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 966 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
963 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 967 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
964 } 968 }
965 if ( mode < SYNC_PREF_FORCE_LOCAL ) 969 if ( mode < SYNC_PREF_FORCE_LOCAL )
966 return 0; 970 return 0;
967 971
968 }//else //debug only 972 }//else //debug only
969 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 973 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
970 } 974 }
971 int result; 975 int result;
972 bool localIsNew; 976 bool localIsNew;
973 //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() ); 977 //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() );
974 978
975 979
976 // ************************************************ 980 // ************************************************
977 // ************************************************ 981 // ************************************************
978 // ************************************************ 982 // ************************************************
979 // We may have that lastSync > remoteMod AND lastSync > localMod 983 // We may have that lastSync > remoteMod AND lastSync > localMod
980 // BUT remoteMod != localMod 984 // BUT remoteMod != localMod
981 985
982 986
983 if ( full && mode < SYNC_PREF_NEWEST ) 987 if ( full && mode < SYNC_PREF_NEWEST )
984 mode = SYNC_PREF_ASK; 988 mode = SYNC_PREF_ASK;
985 989
986 switch( mode ) { 990 switch( mode ) {
987 case SYNC_PREF_LOCAL: 991 case SYNC_PREF_LOCAL:
988 if ( lastSync > remoteMod ) 992 if ( lastSync > remoteMod )
989 return 1; 993 return 1;
990 if ( lastSync > localMod ) 994 if ( lastSync > localMod )
991 return 2; 995 return 2;
992 return 1; 996 return 1;
993 break; 997 break;
994 case SYNC_PREF_REMOTE: 998 case SYNC_PREF_REMOTE:
995 if ( lastSync > localMod ) 999 if ( lastSync > localMod )
996 return 2; 1000 return 2;
997 if ( lastSync > remoteMod ) 1001 if ( lastSync > remoteMod )
998 return 1; 1002 return 1;
999 return 2; 1003 return 2;
1000 break; 1004 break;
1001 case SYNC_PREF_NEWEST: 1005 case SYNC_PREF_NEWEST:
1002 if ( localMod >= remoteMod ) 1006 if ( localMod >= remoteMod )
1003 return 1; 1007 return 1;
1004 else 1008 else
1005 return 2; 1009 return 2;
1006 break; 1010 break;
1007 case SYNC_PREF_ASK: 1011 case SYNC_PREF_ASK:
1008 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1012 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1009 if ( lastSync > remoteMod && lastSync > localMod) 1013 if ( lastSync > remoteMod && lastSync > localMod)
1010 return 0; 1014 return 0;
1011 if ( lastSync > remoteMod ) 1015 if ( lastSync > remoteMod )
1012 return 1; 1016 return 1;
1013 if ( lastSync > localMod ) 1017 if ( lastSync > localMod )
1014 return 2; 1018 return 2;
1015 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1019 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1016 localIsNew = localMod >= remoteMod; 1020 localIsNew = localMod >= remoteMod;
1017 if ( localIsNew ) 1021 if ( localIsNew )
1018 getEventViewerDialog()->setColorMode( 1 ); 1022 getEventViewerDialog()->setColorMode( 1 );
1019 else 1023 else
1020 getEventViewerDialog()->setColorMode( 2 ); 1024 getEventViewerDialog()->setColorMode( 2 );
1021 getEventViewerDialog()->setIncidence(local); 1025 getEventViewerDialog()->setIncidence(local);
1022 if ( localIsNew ) 1026 if ( localIsNew )
1023 getEventViewerDialog()->setColorMode( 2 ); 1027 getEventViewerDialog()->setColorMode( 2 );
1024 else 1028 else
1025 getEventViewerDialog()->setColorMode( 1 ); 1029 getEventViewerDialog()->setColorMode( 1 );
1026 getEventViewerDialog()->addIncidence(remote); 1030 getEventViewerDialog()->addIncidence(remote);
1027 getEventViewerDialog()->setColorMode( 0 ); 1031 getEventViewerDialog()->setColorMode( 0 );
1028 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1032 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1029 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1033 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1030 getEventViewerDialog()->showMe(); 1034 getEventViewerDialog()->showMe();
1031 result = getEventViewerDialog()->executeS( localIsNew ); 1035 result = getEventViewerDialog()->executeS( localIsNew );
1032 return result; 1036 return result;
1033 1037
1034 break; 1038 break;
1035 case SYNC_PREF_FORCE_LOCAL: 1039 case SYNC_PREF_FORCE_LOCAL:
1036 return 1; 1040 return 1;
1037 break; 1041 break;
1038 case SYNC_PREF_FORCE_REMOTE: 1042 case SYNC_PREF_FORCE_REMOTE:
1039 return 2; 1043 return 2;
1040 break; 1044 break;
1041 1045
1042 default: 1046 default:
1043 // SYNC_PREF_TAKE_BOTH not implemented 1047 // SYNC_PREF_TAKE_BOTH not implemented
1044 break; 1048 break;
1045 } 1049 }
1046 return 0; 1050 return 0;
1047} 1051}
1048Event* CalendarView::getLastSyncEvent() 1052Event* CalendarView::getLastSyncEvent()
1049{ 1053{
1050 Event* lse; 1054 Event* lse;
1051 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1055 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1052 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1056 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1053 if (!lse) { 1057 if (!lse) {
1054 lse = new Event(); 1058 lse = new Event();
1055 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1059 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1056 QString sum = ""; 1060 QString sum = "";
1057 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1061 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1058 sum = "E: "; 1062 sum = "E: ";
1059 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1063 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1060 lse->setDtStart( mLastCalendarSync ); 1064 lse->setDtStart( mLastCalendarSync );
1061 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1065 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1062 lse->setCategories( i18n("SyncEvent") ); 1066 lse->setCategories( i18n("SyncEvent") );
1063 lse->setReadOnly( true ); 1067 lse->setReadOnly( true );
1064 mCalendar->addEvent( lse ); 1068 mCalendar->addEvent( lse );
1065 } 1069 }
1066 1070
1067 return lse; 1071 return lse;
1068 1072
1069} 1073}
1070 1074
1071// we check, if the to delete event has a id for a profile 1075// we check, if the to delete event has a id for a profile
1072// if yes, we set this id in the profile to delete 1076// if yes, we set this id in the profile to delete
1073void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1077void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1074{ 1078{
1075 if ( lastSync.count() == 0 ) { 1079 if ( lastSync.count() == 0 ) {
1076 //qDebug(" lastSync.count() == 0"); 1080 //qDebug(" lastSync.count() == 0");
1077 return; 1081 return;
1078 } 1082 }
1079 if ( toDelete->type() == "Journal" ) 1083 if ( toDelete->type() == "Journal" )
1080 return; 1084 return;
1081 1085
1082 Event* eve = lastSync.first(); 1086 Event* eve = lastSync.first();
1083 1087
1084 while ( eve ) { 1088 while ( eve ) {
1085 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1089 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1086 if ( !id.isEmpty() ) { 1090 if ( !id.isEmpty() ) {
1087 QString des = eve->description(); 1091 QString des = eve->description();
1088 QString pref = "e"; 1092 QString pref = "e";
1089 if ( toDelete->type() == "Todo" ) 1093 if ( toDelete->type() == "Todo" )
1090 pref = "t"; 1094 pref = "t";
1091 des += pref+ id + ","; 1095 des += pref+ id + ",";
1092 eve->setReadOnly( false ); 1096 eve->setReadOnly( false );
1093 eve->setDescription( des ); 1097 eve->setDescription( des );
1094 //qDebug("setdes %s ", des.latin1()); 1098 //qDebug("setdes %s ", des.latin1());
1095 eve->setReadOnly( true ); 1099 eve->setReadOnly( true );
1096 } 1100 }
1097 eve = lastSync.next(); 1101 eve = lastSync.next();
1098 } 1102 }
1099 1103
1100} 1104}
1101void CalendarView::checkExternalId( Incidence * inc ) 1105void CalendarView::checkExternalId( Incidence * inc )
1102{ 1106{
1103 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1107 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1104 checkExternSyncEvent( lastSync, inc ); 1108 checkExternSyncEvent( lastSync, inc );
1105 1109
1106} 1110}
1107bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1111bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1108{ 1112{
1109 bool syncOK = true; 1113 bool syncOK = true;
1110 int addedEvent = 0; 1114 int addedEvent = 0;
1111 int addedEventR = 0; 1115 int addedEventR = 0;
1112 int deletedEventR = 0; 1116 int deletedEventR = 0;
1113 int deletedEventL = 0; 1117 int deletedEventL = 0;
1114 int changedLocal = 0; 1118 int changedLocal = 0;
1115 int changedRemote = 0; 1119 int changedRemote = 0;
1116 int filteredIN = 0; 1120 int filteredIN = 0;
1117 int filteredOUT = 0; 1121 int filteredOUT = 0;
1118 //QPtrList<Event> el = local->rawEvents(); 1122 //QPtrList<Event> el = local->rawEvents();
1119 Event* eventR; 1123 Event* eventR;
1120 QString uid; 1124 QString uid;
1121 int take; 1125 int take;
1122 Event* eventL; 1126 Event* eventL;
1123 Event* eventRSync; 1127 Event* eventRSync;
1124 Event* eventLSync; 1128 Event* eventLSync;
1125 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1129 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1126 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1130 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1127 bool fullDateRange = false; 1131 bool fullDateRange = false;
1128 local->resetTempSyncStat(); 1132 local->resetTempSyncStat();
1129 mLastCalendarSync = QDateTime::currentDateTime(); 1133 mLastCalendarSync = QDateTime::currentDateTime();
1130 if ( mSyncManager->syncWithDesktop() ) { 1134 if ( mSyncManager->syncWithDesktop() ) {
1131 remote->resetPilotStat(1); 1135 remote->resetPilotStat(1);
1132 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1136 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1133 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1137 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1134 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1138 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1135 } else { 1139 } else {
1136 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1140 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1137 } 1141 }
1138 } 1142 }
1139 QDateTime modifiedCalendar = mLastCalendarSync; 1143 QDateTime modifiedCalendar = mLastCalendarSync;
1140 eventLSync = getLastSyncEvent(); 1144 eventLSync = getLastSyncEvent();
1141 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1145 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1142 if ( eventR ) { 1146 if ( eventR ) {
1143 eventRSync = (Event*) eventR->clone(); 1147 eventRSync = (Event*) eventR->clone();
1144 remote->deleteEvent(eventR ); 1148 remote->deleteEvent(eventR );
1145 1149
1146 } else { 1150 } else {
1147 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1151 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1148 eventRSync = (Event*)eventLSync->clone(); 1152 eventRSync = (Event*)eventLSync->clone();
1149 } else { 1153 } else {
1150 fullDateRange = true; 1154 fullDateRange = true;
1151 eventRSync = new Event(); 1155 eventRSync = new Event();
1152 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1156 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1153 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1157 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1154 eventRSync->setDtStart( mLastCalendarSync ); 1158 eventRSync->setDtStart( mLastCalendarSync );
1155 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1159 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1156 eventRSync->setCategories( i18n("SyncEvent") ); 1160 eventRSync->setCategories( i18n("SyncEvent") );
1157 } 1161 }
1158 } 1162 }
1159 if ( eventLSync->dtStart() == mLastCalendarSync ) 1163 if ( eventLSync->dtStart() == mLastCalendarSync )
1160 fullDateRange = true; 1164 fullDateRange = true;
1161 1165
1162 if ( ! fullDateRange ) { 1166 if ( ! fullDateRange ) {
1163 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1167 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1164 1168
1165 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1169 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1166 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1170 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1167 fullDateRange = true; 1171 fullDateRange = true;
1168 } 1172 }
1169 } 1173 }
1170 if ( mSyncManager->syncWithDesktop() ) { 1174 if ( mSyncManager->syncWithDesktop() ) {
1171 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1175 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1172 } 1176 }
1173 if ( fullDateRange ) 1177 if ( fullDateRange )
1174 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1178 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1175 else 1179 else
1176 mLastCalendarSync = eventLSync->dtStart(); 1180 mLastCalendarSync = eventLSync->dtStart();
1177 // for resyncing if own file has changed 1181 // for resyncing if own file has changed
1178 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1182 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1179 mLastCalendarSync = loadedFileVersion; 1183 mLastCalendarSync = loadedFileVersion;
1180 //qDebug("setting mLastCalendarSync "); 1184 //qDebug("setting mLastCalendarSync ");
1181 } 1185 }
1182 //qDebug("*************************** "); 1186 //qDebug("*************************** ");
1183 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1187 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1184 QPtrList<Incidence> er = remote->rawIncidences(); 1188 QPtrList<Incidence> er = remote->rawIncidences();
1185 Incidence* inR = er.first(); 1189 Incidence* inR = er.first();
1186 Incidence* inL; 1190 Incidence* inL;
1187 QProgressBar bar( er.count(),0 ); 1191 QProgressBar bar( er.count(),0 );
1188 bar.setCaption (i18n("Syncing - close to abort!") ); 1192 bar.setCaption (i18n("Syncing - close to abort!") );
1189 1193
1190 // ************** setting up filter ************* 1194 // ************** setting up filter *************
1191 CalFilter *filterIN = 0; 1195 CalFilter *filterIN = 0;
1192 CalFilter *filterOUT = 0; 1196 CalFilter *filterOUT = 0;
1193 CalFilter *filter = mFilters.first(); 1197 CalFilter *filter = mFilters.first();
1194 while(filter) { 1198 while(filter) {
1195 if ( filter->name() == mSyncManager->mFilterInCal ) 1199 if ( filter->name() == mSyncManager->mFilterInCal )
1196 filterIN = filter; 1200 filterIN = filter;
1197 if ( filter->name() == mSyncManager->mFilterOutCal ) 1201 if ( filter->name() == mSyncManager->mFilterOutCal )
1198 filterOUT = filter; 1202 filterOUT = filter;
1199 filter = mFilters.next(); 1203 filter = mFilters.next();
1200 } 1204 }
1201 int w = 300; 1205 int w = 300;
1202 if ( QApplication::desktop()->width() < 320 ) 1206 if ( QApplication::desktop()->width() < 320 )
1203 w = 220; 1207 w = 220;
1204 int h = bar.sizeHint().height() ; 1208 int h = bar.sizeHint().height() ;
1205 int dw = QApplication::desktop()->width(); 1209 int dw = QApplication::desktop()->width();
1206 int dh = QApplication::desktop()->height(); 1210 int dh = QApplication::desktop()->height();
1207 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1211 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1208 bar.show(); 1212 bar.show();
1209 int modulo = (er.count()/10)+1; 1213 int modulo = (er.count()/10)+1;
1210 int incCounter = 0; 1214 int incCounter = 0;
1211 while ( inR ) { 1215 while ( inR ) {
1212 if ( ! bar.isVisible() ) 1216 if ( ! bar.isVisible() )
1213 return false; 1217 return false;
1214 if ( incCounter % modulo == 0 ) 1218 if ( incCounter % modulo == 0 )
1215 bar.setProgress( incCounter ); 1219 bar.setProgress( incCounter );
1216 ++incCounter; 1220 ++incCounter;
1217 uid = inR->uid(); 1221 uid = inR->uid();
1218 bool skipIncidence = false; 1222 bool skipIncidence = false;
1219 if ( uid.left(15) == QString("last-syncEvent-") ) 1223 if ( uid.left(15) == QString("last-syncEvent-") )
1220 skipIncidence = true; 1224 skipIncidence = true;
1221 QString idS; 1225 QString idS;
1222 qApp->processEvents(); 1226 qApp->processEvents();
1223 if ( !skipIncidence ) { 1227 if ( !skipIncidence ) {
1224 inL = local->incidence( uid ); 1228 inL = local->incidence( uid );
1225 if ( inL ) { // maybe conflict - same uid in both calendars 1229 if ( inL ) { // maybe conflict - same uid in both calendars
1226 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1230 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1227 //qDebug("take %d %s ", take, inL->summary().latin1()); 1231 //qDebug("take %d %s ", take, inL->summary().latin1());
1228 if ( take == 3 ) 1232 if ( take == 3 )
1229 return false; 1233 return false;
1230 if ( take == 1 ) {// take local ********************** 1234 if ( take == 1 ) {// take local **********************
1231 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1235 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1232 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1236 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1233 else 1237 else
1234 idS = inR->IDStr(); 1238 idS = inR->IDStr();
1235 remote->deleteIncidence( inR ); 1239 remote->deleteIncidence( inR );
1236 inR = inL->clone(); 1240 inR = inL->clone();
1237 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1241 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1238 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1242 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1239 inR->setIDStr( idS ); 1243 inR->setIDStr( idS );
1240 remote->addIncidence( inR ); 1244 remote->addIncidence( inR );
1241 if ( mSyncManager->syncWithDesktop() ) 1245 if ( mSyncManager->syncWithDesktop() )
1242 inR->setPilotId( 2 ); 1246 inR->setPilotId( 2 );
1243 ++changedRemote; 1247 ++changedRemote;
1244 } else {// take remote ********************** 1248 } else {// take remote **********************
1245 idS = inL->IDStr(); 1249 idS = inL->IDStr();
1246 int pid = inL->pilotId(); 1250 int pid = inL->pilotId();
1247 local->deleteIncidence( inL ); 1251 local->deleteIncidence( inL );
1248 inL = inR->clone(); 1252 inL = inR->clone();
1249 if ( mSyncManager->syncWithDesktop() ) 1253 if ( mSyncManager->syncWithDesktop() )
1250 inL->setPilotId( pid ); 1254 inL->setPilotId( pid );
1251 inL->setIDStr( idS ); 1255 inL->setIDStr( idS );
1252 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1256 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1253 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1257 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1254 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1258 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1255 } 1259 }
1256 local->addIncidence( inL ); 1260 local->addIncidence( inL );
1257 ++changedLocal; 1261 ++changedLocal;
1258 } 1262 }
1259 } 1263 }
1260 } else { // no conflict ********** add or delete remote 1264 } else { // no conflict ********** add or delete remote
1261 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1265 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1262 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1266 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1263 QString des = eventLSync->description(); 1267 QString des = eventLSync->description();
1264 QString pref = "e"; 1268 QString pref = "e";
1265 if ( inR->type() == "Todo" ) 1269 if ( inR->type() == "Todo" )
1266 pref = "t"; 1270 pref = "t";
1267 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1271 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1268 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1272 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1269 //remote->deleteIncidence( inR ); 1273 //remote->deleteIncidence( inR );
1270 ++deletedEventR; 1274 ++deletedEventR;
1271 } else { 1275 } else {
1272 inR->setLastModified( modifiedCalendar ); 1276 inR->setLastModified( modifiedCalendar );
1273 inL = inR->clone(); 1277 inL = inR->clone();
1274 inL->setIDStr( ":" ); 1278 inL->setIDStr( ":" );
1275 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1279 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1276 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1280 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1277 local->addIncidence( inL ); 1281 local->addIncidence( inL );
1278 ++addedEvent; 1282 ++addedEvent;
1279 1283
1280 } 1284 }
1281 } else { 1285 } else {
1282 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1286 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1283 inR->setLastModified( modifiedCalendar ); 1287 inR->setLastModified( modifiedCalendar );
1284 inL = inR->clone(); 1288 inL = inR->clone();
1285 inL->setIDStr( ":" ); 1289 inL->setIDStr( ":" );
1286 local->addIncidence( inL ); 1290 local->addIncidence( inL );
1287 ++addedEvent; 1291 ++addedEvent;
1288 1292
1289 } else { 1293 } else {
1290 checkExternSyncEvent(eventRSyncSharp, inR); 1294 checkExternSyncEvent(eventRSyncSharp, inR);
1291 remote->deleteIncidence( inR ); 1295 remote->deleteIncidence( inR );
1292 ++deletedEventR; 1296 ++deletedEventR;
1293 } 1297 }
1294 } 1298 }
1295 } else { 1299 } else {
1296 ++filteredIN; 1300 ++filteredIN;
1297 } 1301 }
1298 } 1302 }
1299 } 1303 }
1300 inR = er.next(); 1304 inR = er.next();
1301 } 1305 }
1302 QPtrList<Incidence> el = local->rawIncidences(); 1306 QPtrList<Incidence> el = local->rawIncidences();
1303 inL = el.first(); 1307 inL = el.first();
1304 modulo = (el.count()/10)+1; 1308 modulo = (el.count()/10)+1;
1305 bar.setCaption (i18n("Add / remove events") ); 1309 bar.setCaption (i18n("Add / remove events") );
1306 bar.setTotalSteps ( el.count() ) ; 1310 bar.setTotalSteps ( el.count() ) ;
1307 bar.show(); 1311 bar.show();
1308 incCounter = 0; 1312 incCounter = 0;
1309 1313
1310 while ( inL ) { 1314 while ( inL ) {
1311 1315
1312 qApp->processEvents(); 1316 qApp->processEvents();
1313 if ( ! bar.isVisible() ) 1317 if ( ! bar.isVisible() )
1314 return false; 1318 return false;
1315 if ( incCounter % modulo == 0 ) 1319 if ( incCounter % modulo == 0 )
1316 bar.setProgress( incCounter ); 1320 bar.setProgress( incCounter );
1317 ++incCounter; 1321 ++incCounter;
1318 uid = inL->uid(); 1322 uid = inL->uid();
1319 bool skipIncidence = false; 1323 bool skipIncidence = false;
1320 if ( uid.left(15) == QString("last-syncEvent-") ) 1324 if ( uid.left(15) == QString("last-syncEvent-") )
1321 skipIncidence = true; 1325 skipIncidence = true;
1322 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1326 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1323 skipIncidence = true; 1327 skipIncidence = true;
1324 if ( !skipIncidence ) { 1328 if ( !skipIncidence ) {
1325 inR = remote->incidence( uid ); 1329 inR = remote->incidence( uid );
1326 if ( ! inR ) { 1330 if ( ! inR ) {
1327 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1331 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1328 // no conflict ********** add or delete local 1332 // no conflict ********** add or delete local
1329 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1333 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1330 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1334 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1331 checkExternSyncEvent(eventLSyncSharp, inL); 1335 checkExternSyncEvent(eventLSyncSharp, inL);
1332 local->deleteIncidence( inL ); 1336 local->deleteIncidence( inL );
1333 ++deletedEventL; 1337 ++deletedEventL;
1334 } else { 1338 } else {
1335 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1339 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1336 inL->removeID(mCurrentSyncDevice ); 1340 inL->removeID(mCurrentSyncDevice );
1337 ++addedEventR; 1341 ++addedEventR;
1338 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1342 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1339 inL->setLastModified( modifiedCalendar ); 1343 inL->setLastModified( modifiedCalendar );
1340 inR = inL->clone(); 1344 inR = inL->clone();
1341 inR->setIDStr( ":" ); 1345 inR->setIDStr( ":" );
1342 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1346 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1343 remote->addIncidence( inR ); 1347 remote->addIncidence( inR );
1344 } 1348 }
1345 } 1349 }
1346 } else { 1350 } else {
1347 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1351 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1348 checkExternSyncEvent(eventLSyncSharp, inL); 1352 checkExternSyncEvent(eventLSyncSharp, inL);
1349 local->deleteIncidence( inL ); 1353 local->deleteIncidence( inL );
1350 ++deletedEventL; 1354 ++deletedEventL;
1351 } else { 1355 } else {
1352 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1356 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1353 ++addedEventR; 1357 ++addedEventR;
1354 inL->setLastModified( modifiedCalendar ); 1358 inL->setLastModified( modifiedCalendar );
1355 inR = inL->clone(); 1359 inR = inL->clone();
1356 inR->setIDStr( ":" ); 1360 inR->setIDStr( ":" );
1357 remote->addIncidence( inR ); 1361 remote->addIncidence( inR );
1358 } 1362 }
1359 } 1363 }
1360 } 1364 }
1361 } else { 1365 } else {
1362 ++filteredOUT; 1366 ++filteredOUT;
1363 } 1367 }
1364 } 1368 }
1365 } 1369 }
1366 inL = el.next(); 1370 inL = el.next();
1367 } 1371 }
1368 int delFut = 0; 1372 int delFut = 0;
1369 int remRem = 0; 1373 int remRem = 0;
1370 if ( mSyncManager->mWriteBackInFuture ) { 1374 if ( mSyncManager->mWriteBackInFuture ) {
1371 er = remote->rawIncidences(); 1375 er = remote->rawIncidences();
1372 remRem = er.count(); 1376 remRem = er.count();
1373 inR = er.first(); 1377 inR = er.first();
1374 QDateTime dt; 1378 QDateTime dt;
1375 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1379 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1376 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1380 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1377 while ( inR ) { 1381 while ( inR ) {
1378 if ( inR->type() == "Todo" ) { 1382 if ( inR->type() == "Todo" ) {
1379 Todo * t = (Todo*)inR; 1383 Todo * t = (Todo*)inR;
1380 if ( t->hasDueDate() ) 1384 if ( t->hasDueDate() )
1381 dt = t->dtDue(); 1385 dt = t->dtDue();
1382 else 1386 else
1383 dt = cur.addSecs( 62 ); 1387 dt = cur.addSecs( 62 );
1384 } 1388 }
1385 else if (inR->type() == "Event" ) { 1389 else if (inR->type() == "Event" ) {
1386 bool ok; 1390 bool ok;
1387 dt = inR->getNextOccurence( cur, &ok ); 1391 dt = inR->getNextOccurence( cur, &ok );
1388 if ( !ok ) 1392 if ( !ok )
1389 dt = cur.addSecs( -62 ); 1393 dt = cur.addSecs( -62 );
1390 } 1394 }
1391 else 1395 else
1392 dt = inR->dtStart(); 1396 dt = inR->dtStart();
1393 if ( dt < cur || dt > end ) { 1397 if ( dt < cur || dt > end ) {
1394 remote->deleteIncidence( inR ); 1398 remote->deleteIncidence( inR );
1395 ++delFut; 1399 ++delFut;
1396 } 1400 }
1397 inR = er.next(); 1401 inR = er.next();
1398 } 1402 }
1399 } 1403 }
1400 bar.hide(); 1404 bar.hide();
1401 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1405 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1402 eventLSync->setReadOnly( false ); 1406 eventLSync->setReadOnly( false );
1403 eventLSync->setDtStart( mLastCalendarSync ); 1407 eventLSync->setDtStart( mLastCalendarSync );
1404 eventRSync->setDtStart( mLastCalendarSync ); 1408 eventRSync->setDtStart( mLastCalendarSync );
1405 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1409 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1406 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1410 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1407 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1411 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1408 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1412 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1409 eventLSync->setReadOnly( true ); 1413 eventLSync->setReadOnly( true );
1410 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1414 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1411 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1415 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1412 remote->addEvent( eventRSync ); 1416 remote->addEvent( eventRSync );
1413 else 1417 else
1414 delete eventRSync; 1418 delete eventRSync;
1415 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1419 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1416 QString mes; 1420 QString mes;
1417 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 ); 1421 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 );
1418 QString delmess; 1422 QString delmess;
1419 if ( delFut ) { 1423 if ( delFut ) {
1420 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); 1424 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);
1421 mes += delmess; 1425 mes += delmess;
1422 } 1426 }
1423 mes = i18n("Local calendar changed!\n") +mes; 1427 mes = i18n("Local calendar changed!\n") +mes;
1424 mCalendar->checkAlarmForIncidence( 0, true ); 1428 mCalendar->checkAlarmForIncidence( 0, true );
1425 qDebug( mes ); 1429 qDebug( mes );
1426 if ( mSyncManager->mShowSyncSummary ) { 1430 if ( mSyncManager->mShowSyncSummary ) {
1427 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1431 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1428 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1432 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1429 qDebug("KO: WB cancelled "); 1433 qDebug("KO: WB cancelled ");
1430 mSyncManager->mWriteBackFile = false; 1434 mSyncManager->mWriteBackFile = false;