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