summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-31 13:53:56 (UTC)
committer zautrix <zautrix>2005-07-31 13:53:56 (UTC)
commitbfa3d79c4172c4a8efebb1f2801e152a3a706dca (patch) (unidiff)
tree32065e18eb2597449387cf9d72527c301016344d
parent4fa00d59fd2895036e9f3bce7902bf6360679a0b (diff)
downloadkdepimpi-bfa3d79c4172c4a8efebb1f2801e152a3a706dca.zip
kdepimpi-bfa3d79c4172c4a8efebb1f2801e152a3a706dca.tar.gz
kdepimpi-bfa3d79c4172c4a8efebb1f2801e152a3a706dca.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8269910..7566b22 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,2607 +1,2608 @@
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 "koagenda.h" 107#include "koagenda.h"
108#include "kodialogmanager.h" 108#include "kodialogmanager.h"
109#include "outgoingdialog.h" 109#include "outgoingdialog.h"
110#include "incomingdialog.h" 110#include "incomingdialog.h"
111#include "datenavigatorcontainer.h" 111#include "datenavigatorcontainer.h"
112#include "statusdialog.h" 112#include "statusdialog.h"
113#include "kdatenavigator.h" 113#include "kdatenavigator.h"
114#include "kotodoview.h" 114#include "kotodoview.h"
115#include "datenavigator.h" 115#include "datenavigator.h"
116#include "resourceview.h" 116#include "resourceview.h"
117#include "navigatorbar.h" 117#include "navigatorbar.h"
118#include "searchdialog.h" 118#include "searchdialog.h"
119#include "mainwindow.h" 119#include "mainwindow.h"
120#include "categoryeditdialog.h" 120#include "categoryeditdialog.h"
121 121
122#include "calendarview.h" 122#include "calendarview.h"
123#ifndef DESKTOP_VERSION 123#ifndef DESKTOP_VERSION
124#include <qtopia/alarmserver.h> 124#include <qtopia/alarmserver.h>
125#endif 125#endif
126#ifndef _WIN32_ 126#ifndef _WIN32_
127#include <stdlib.h> 127#include <stdlib.h>
128#include <stdio.h> 128#include <stdio.h>
129#include <unistd.h> 129#include <unistd.h>
130#else 130#else
131#include <qprocess.h> 131#include <qprocess.h>
132#endif 132#endif
133 133
134#ifdef DESKTOP_VERSION 134#ifdef DESKTOP_VERSION
135#include <kabc/stdaddressbook.h> 135#include <kabc/stdaddressbook.h>
136#endif 136#endif
137using namespace KOrg; 137using namespace KOrg;
138using namespace KCal; 138using namespace KCal;
139extern int globalFlagBlockAgenda; 139extern int globalFlagBlockAgenda;
140extern int globalFlagBlockStartup; 140extern int globalFlagBlockStartup;
141 141
142 142
143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
144 144
145{ 145{
146 mAlarms = alarms; 146 mAlarms = alarms;
147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
148 QString mText = "<table width=\"100%\">\n"; 148 QString mText = "<table width=\"100%\">\n";
149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
150#ifdef DESKTOP_VERSION 150#ifdef DESKTOP_VERSION
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
152#else 152#else
153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
154#endif 154#endif
155 // mText += "<img src=\""; 155 // mText += "<img src=\"";
156 // mText += ipath; 156 // mText += ipath;
157 // mText += "\">"; 157 // mText += "\">";
158 //mEventDate = QDate::currentDate(); 158 //mEventDate = QDate::currentDate();
159#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
161#else 161#else
162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
163#endif 163#endif
164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
165 165
166 Incidence * inc = getNextInc( start ); 166 Incidence * inc = getNextInc( start );
167 int time = 0; 167 int time = 0;
168 //mText += "<table>"; 168 //mText += "<table>";
169 while ( inc ) { 169 while ( inc ) {
170 QDateTime dt ; 170 QDateTime dt ;
171 QString tempText = "<a "; 171 QString tempText = "<a ";
172 bool ok; 172 bool ok;
173 dt = inc->getNextOccurence( start, &ok ); 173 dt = inc->getNextOccurence( start, &ok );
174 if ( !ok ) continue; 174 if ( !ok ) continue;
175 if ( inc->typeID() == eventID ) { 175 if ( inc->typeID() == eventID ) {
176 tempText += "href=\"event:"; 176 tempText += "href=\"event:";
177 } else if ( inc->typeID() == todoID ) { 177 } else if ( inc->typeID() == todoID ) {
178 tempText += "href=\"todo:"; 178 tempText += "href=\"todo:";
179 } 179 }
180 tempText += inc->uid() + "\">"; 180 tempText += inc->uid() + "\">";
181 if ( inc->typeID() == todoID ) 181 if ( inc->typeID() == todoID )
182 tempText += i18n("Todo: "); 182 tempText += i18n("Todo: ");
183 if ( inc->summary().length() > 0 ) 183 if ( inc->summary().length() > 0 )
184 tempText += inc->summary(); 184 tempText += inc->summary();
185 else 185 else
186 tempText += i18n("-no summary-"); 186 tempText += i18n("-no summary-");
187 QString timestr; 187 QString timestr;
188 if (!inc->doesFloat()) 188 if (!inc->doesFloat())
189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
190 else 190 else
191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
192 if ( dt.date() < QDate::currentDate() && time == 0 ) { 192 if ( dt.date() < QDate::currentDate() && time == 0 ) {
193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
194 mText += "<table>"; 194 mText += "<table>";
195 time = 1; 195 time = 1;
196 } 196 }
197 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 197 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
198 if ( time > 0 ) 198 if ( time > 0 )
199 mText +="</table>"; 199 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
201 mText += "<table>"; 201 mText += "<table>";
202 time = 2; 202 time = 2;
203 203
204 } 204 }
205 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 205 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
206 if ( time > 0 ) 206 if ( time > 0 )
207 mText +="</table>"; 207 mText +="</table>";
208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
209 mText += "<table>"; 209 mText += "<table>";
210 time = 3; 210 time = 3;
211 } 211 }
212 mText +="<tr><td><b>"; 212 mText +="<tr><td><b>";
213 mText += timestr; 213 mText += timestr;
214 mText += "</b></td><td>"; 214 mText += "</b></td><td>";
215 mText += tempText; 215 mText += tempText;
216 mText += "</td></tr>\n"; 216 mText += "</td></tr>\n";
217 inc = getNextInc( start ); 217 inc = getNextInc( start );
218 } 218 }
219 mText +="</table>"; 219 mText +="</table>";
220 setText( mText ); 220 setText( mText );
221} 221}
222 222
223MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 223MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
224{ 224{
225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
226} 226}
227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
228{ 228{
229 QDateTime dt ; 229 QDateTime dt ;
230 Incidence * retInc; 230 Incidence * retInc;
231 Incidence * inc = mAlarms.first(); 231 Incidence * inc = mAlarms.first();
232 if ( inc == 0 ) 232 if ( inc == 0 )
233 return 0; 233 return 0;
234 bool ok; 234 bool ok;
235 dt = inc->getNextOccurence( start, &ok ); 235 dt = inc->getNextOccurence( start, &ok );
236 if ( ! ok ) return 0; 236 if ( ! ok ) return 0;
237 QDateTime dtn ; 237 QDateTime dtn ;
238 retInc = inc; 238 retInc = inc;
239 inc = mAlarms.next(); 239 inc = mAlarms.next();
240 while ( inc ) { 240 while ( inc ) {
241 dtn = inc->getNextOccurence( start, &ok ); 241 dtn = inc->getNextOccurence( start, &ok );
242 if ( ! ok ) return 0; 242 if ( ! ok ) return 0;
243 if ( dtn < dt ) { 243 if ( dtn < dt ) {
244 dt = dtn; 244 dt = dtn;
245 retInc = inc; 245 retInc = inc;
246 } 246 }
247 inc = mAlarms.next(); 247 inc = mAlarms.next();
248 } 248 }
249 mAlarms.remove( retInc ); 249 mAlarms.remove( retInc );
250 return retInc; 250 return retInc;
251 251
252} 252}
253void MissedAlarmTextBrowser::setSource(const QString & n) 253void MissedAlarmTextBrowser::setSource(const QString & n)
254{ 254{
255 if (n.startsWith("event:")) { 255 if (n.startsWith("event:")) {
256#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
257 emit showIncidence(n.mid(8)); 257 emit showIncidence(n.mid(8));
258#else 258#else
259 emit showIncidence(n.mid(6)); 259 emit showIncidence(n.mid(6));
260#endif 260#endif
261 return; 261 return;
262 } else if (n.startsWith("todo:")) { 262 } else if (n.startsWith("todo:")) {
263#ifdef DESKTOP_VERSION 263#ifdef DESKTOP_VERSION
264 emit showIncidence(n.mid(7)); 264 emit showIncidence(n.mid(7));
265#else 265#else
266 emit showIncidence(n.mid(5)); 266 emit showIncidence(n.mid(5));
267#endif 267#endif
268 return; 268 return;
269 } 269 }
270} 270}
271 271
272 272
273class KOBeamPrefs : public QDialog 273class KOBeamPrefs : public QDialog
274{ 274{
275 public: 275 public:
276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
277 QDialog( parent, name, true ) 277 QDialog( parent, name, true )
278 { 278 {
279 setCaption( i18n("Beam Options") ); 279 setCaption( i18n("Beam Options") );
280 QVBoxLayout* lay = new QVBoxLayout( this ); 280 QVBoxLayout* lay = new QVBoxLayout( this );
281 lay->setSpacing( 3 ); 281 lay->setSpacing( 3 );
282 lay->setMargin( 3 ); 282 lay->setMargin( 3 );
283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
284 lay->addWidget( format ); 284 lay->addWidget( format );
285 format->setExclusive ( true ) ; 285 format->setExclusive ( true ) ;
286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
287 lay->addWidget( time ); time->setExclusive ( true ) ; 287 lay->addWidget( time ); time->setExclusive ( true ) ;
288 vcal = new QRadioButton(" vCalendar ", format ); 288 vcal = new QRadioButton(" vCalendar ", format );
289 ical = new QRadioButton(" iCalendar ", format ); 289 ical = new QRadioButton(" iCalendar ", format );
290 vcal->setChecked( true ); 290 vcal->setChecked( true );
291 tz = new QRadioButton(i18n(" With timezone "), time ); 291 tz = new QRadioButton(i18n(" With timezone "), time );
292 local = new QRadioButton(i18n(" Local time "), time ); 292 local = new QRadioButton(i18n(" Local time "), time );
293 tz->setChecked( true ); 293 tz->setChecked( true );
294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
295 lay->addWidget( ok ); 295 lay->addWidget( ok );
296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
297 lay->addWidget( cancel ); 297 lay->addWidget( cancel );
298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
300 resize( 200, 200 ); 300 resize( 200, 200 );
301 } 301 }
302 302
303 bool beamVcal() { return vcal->isChecked(); } 303 bool beamVcal() { return vcal->isChecked(); }
304 bool beamLocal() { return local->isChecked(); } 304 bool beamLocal() { return local->isChecked(); }
305private: 305private:
306 QRadioButton* vcal, *ical, *local, *tz; 306 QRadioButton* vcal, *ical, *local, *tz;
307}; 307};
308class KOCatPrefs : public QDialog 308class KOCatPrefs : public QDialog
309{ 309{
310 public: 310 public:
311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
312 QDialog( parent, name, true ) 312 QDialog( parent, name, true )
313 { 313 {
314 setCaption( i18n("Manage new Categories") ); 314 setCaption( i18n("Manage new Categories") );
315 QVBoxLayout* lay = new QVBoxLayout( this ); 315 QVBoxLayout* lay = new QVBoxLayout( this );
316 lay->setSpacing( 3 ); 316 lay->setSpacing( 3 );
317 lay->setMargin( 3 ); 317 lay->setMargin( 3 );
318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
319 lay->addWidget( lab ); 319 lay->addWidget( lab );
320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
321 lay->addWidget( format ); 321 lay->addWidget( format );
322 format->setExclusive ( true ) ; 322 format->setExclusive ( true ) ;
323 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 323 addCatBut = new QRadioButton(i18n("Add to category list"), format );
324 new QRadioButton(i18n("Remove from Events/Todos"), format ); 324 new QRadioButton(i18n("Remove from Events/Todos"), format );
325 addCatBut->setChecked( true ); 325 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 327 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 329 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 332 resize( 200, 200 );
333 } 333 }
334 334
335 bool addCat() { return addCatBut->isChecked(); } 335 bool addCat() { return addCatBut->isChecked(); }
336private: 336private:
337 QRadioButton* addCatBut; 337 QRadioButton* addCatBut;
338}; 338};
339 339
340 340
341 341
342CalendarView::CalendarView( CalendarResources *calendar, 342CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 345 mCalendar( calendar ),
346 mResourceManager( calendar->resourceManager() ) 346 mResourceManager( calendar->resourceManager() )
347{ 347{
348 348
349 mEventEditor = 0; 349 mEventEditor = 0;
350 mTodoEditor = 0; 350 mTodoEditor = 0;
351 351
352 init(); 352 init();
353} 353}
354 354
355CalendarView::CalendarView( Calendar *calendar, 355CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 357 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 358 mCalendar( calendar ),
359 mResourceManager( 0 ) 359 mResourceManager( 0 )
360{ 360{
361 361
362 mEventEditor = 0; 362 mEventEditor = 0;
363 mTodoEditor = 0; 363 mTodoEditor = 0;
364 init(); 364 init();
365} 365}
366 366
367void CalendarView::init() 367void CalendarView::init()
368{ 368{
369 mNextAlarmDateTime = QDateTime::currentDateTime(); 369 mNextAlarmDateTime = QDateTime::currentDateTime();
370 setFocusPolicy (NoFocus ); 370 setFocusPolicy (NoFocus );
371 mViewerCallerIsSearchDialog = false; 371 mViewerCallerIsSearchDialog = false;
372 mBlockShowDates = false; 372 mBlockShowDates = false;
373 mConflictingEvent = 0; 373 mConflictingEvent = 0;
374 mDatePickerMode = 0; 374 mDatePickerMode = 0;
375 mCurrentSyncDevice = ""; 375 mCurrentSyncDevice = "";
376 mViewManager = new KOViewManager( this ); 376 mViewManager = new KOViewManager( this );
377 mDialogManager = new KODialogManager( this ); 377 mDialogManager = new KODialogManager( this );
378 mEventViewerDialog = 0; 378 mEventViewerDialog = 0;
379 mModified = false; 379 mModified = false;
380 mReadOnly = false; 380 mReadOnly = false;
381 mSelectedIncidence = 0; 381 mSelectedIncidence = 0;
382 mCalPrinter = 0; 382 mCalPrinter = 0;
383 mFilters.setAutoDelete(true); 383 mFilters.setAutoDelete(true);
384 384
385 mCalendar->registerObserver( this ); 385 mCalendar->registerObserver( this );
386 // TODO: Make sure that view is updated, when calendar is changed. 386 // TODO: Make sure that view is updated, when calendar is changed.
387 387
388 mStorage = new FileStorage( mCalendar ); 388 mStorage = new FileStorage( mCalendar );
389 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 389 mNavigator = new DateNavigator( this, "datevav", mViewManager );
390 390
391 QBoxLayout *topLayout = (QBoxLayout*)layout(); 391 QBoxLayout *topLayout = (QBoxLayout*)layout();
392#ifndef KORG_NOSPLITTER 392#ifndef KORG_NOSPLITTER
393 // create the main layout frames. 393 // create the main layout frames.
394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
395 topLayout->addWidget(mPanner); 395 topLayout->addWidget(mPanner);
396 396
397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
398 "CalendarView::LeftFrame"); 398 "CalendarView::LeftFrame");
399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
400 400
401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
402 "CalendarView::DateNavigator" ); 402 "CalendarView::DateNavigator" );
403 403
404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
406 mTodoList->setNavigator( mNavigator ); 406 mTodoList->setNavigator( mNavigator );
407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
408 408
409#ifdef KORG_NORESOURCEVIEW 409#ifdef KORG_NORESOURCEVIEW
410 mResourceView = 0; 410 mResourceView = 0;
411#else 411#else
412 if ( mResourceManager ) { 412 if ( mResourceManager ) {
413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
414 mResourceView->updateView(); 414 mResourceView->updateView();
415 connect( mResourceView, SIGNAL( resourcesChanged() ), 415 connect( mResourceView, SIGNAL( resourcesChanged() ),
416 SLOT( updateView() ) ); 416 SLOT( updateView() ) );
417 } else { 417 } else {
418 mResourceView = 0; 418 mResourceView = 0;
419 } 419 }
420#endif 420#endif
421 QWidget *rightBox = new QWidget( mPanner ); 421 QWidget *rightBox = new QWidget( mPanner );
422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
423 423
424 mRightFrame = new QWidgetStack( rightBox ); 424 mRightFrame = new QWidgetStack( rightBox );
425 rightLayout->addWidget( mRightFrame, 1 ); 425 rightLayout->addWidget( mRightFrame, 1 );
426 426
427 mLeftFrame = mLeftSplitter; 427 mLeftFrame = mLeftSplitter;
428#else 428#else
429 //QWidget *mainBox = new QWidget( this ); 429 //QWidget *mainBox = new QWidget( this );
430 //QWidget *leftFrame = new QWidget( mainBox ); 430 //QWidget *leftFrame = new QWidget( mainBox );
431 //QBoxLayout * mainBoxLayout; 431 //QBoxLayout * mainBoxLayout;
432 if ( KOPrefs::instance()->mVerticalScreen ) { 432 if ( KOPrefs::instance()->mVerticalScreen ) {
433 //mainBoxLayout = new QVBoxLayout(mainBox); 433 //mainBoxLayout = new QVBoxLayout(mainBox);
434 //leftFrameLayout = new QHBoxLayout(leftFrame ); 434 //leftFrameLayout = new QHBoxLayout(leftFrame );
435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
439 } else { 439 } else {
440 //mainBoxLayout = new QHBoxLayout(mainBox); 440 //mainBoxLayout = new QHBoxLayout(mainBox);
441 //leftFrameLayout = new QVBoxLayout(leftFrame ); 441 //leftFrameLayout = new QVBoxLayout(leftFrame );
442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
446 } 446 }
447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
448 //QBoxLayout * leftFrameLayout; 448 //QBoxLayout * leftFrameLayout;
449 topLayout->addWidget( mMainFrame ); 449 topLayout->addWidget( mMainFrame );
450#ifdef DESKTOP_VERSION 450#ifdef DESKTOP_VERSION
451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this );
452 topLayout->addWidget( mDateScrollBar ); 452 topLayout->addWidget( mDateScrollBar );
453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
454 if ( QApplication::desktop()->width() < 800 ) 454 if ( QApplication::desktop()->width() < 800 )
455 mDateScrollBar->hide(); 455 mDateScrollBar->hide();
456#endif 456#endif
457 //mainBoxLayout->addWidget (mLeftFrame); 457 //mainBoxLayout->addWidget (mLeftFrame);
458 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 458 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
459 "CalendarView::DateNavigator" ); 459 "CalendarView::DateNavigator" );
460#if 0 460#if 0
461 // FIXME 461 // FIXME
462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
463 "CalendarView::DateNavigator", QDate::currentDate()); 463 "CalendarView::DateNavigator", QDate::currentDate());
464#endif 464#endif
465 // mDateNavigator->blockSignals( true ); 465 // mDateNavigator->blockSignals( true );
466 //leftFrameLayout->addWidget( mDateNavigator ); 466 //leftFrameLayout->addWidget( mDateNavigator );
467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
480 480
481 mTodoList->setNavigator( mNavigator ); 481 mTodoList->setNavigator( mNavigator );
482#if 0 482#if 0
483 if ( QApplication::desktop()->width() < 480 ) { 483 if ( QApplication::desktop()->width() < 480 ) {
484 leftFrameLayout->addWidget(mFilterView); 484 leftFrameLayout->addWidget(mFilterView);
485 leftFrameLayout->addWidget(mTodoList, 2 ); 485 leftFrameLayout->addWidget(mTodoList, 2 );
486 486
487 } else { 487 } else {
488 leftFrameLayout->addWidget(mTodoList,2 ); 488 leftFrameLayout->addWidget(mTodoList,2 );
489 leftFrameLayout->addWidget(mFilterView ); 489 leftFrameLayout->addWidget(mFilterView );
490 } 490 }
491#endif 491#endif
492 mFilterView->hide(); 492 mFilterView->hide();
493 mCalEditView->hide(); 493 mCalEditView->hide();
494 QWidget *rightBox = new QWidget( mMainFrame ); 494 QWidget *rightBox = new QWidget( mMainFrame );
495 //mainBoxLayout->addWidget ( rightBox, 10 ); 495 //mainBoxLayout->addWidget ( rightBox, 10 );
496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
497 mRightFrame = new QWidgetStack( rightBox ); 497 mRightFrame = new QWidgetStack( rightBox );
498 rightLayout->addWidget( mRightFrame, 10 ); 498 rightLayout->addWidget( mRightFrame, 10 );
499 499
500 //mLeftFrame = (QWidget *)leftFrame; 500 //mLeftFrame = (QWidget *)leftFrame;
501 if ( KOPrefs::instance()->mVerticalScreen ) { 501 if ( KOPrefs::instance()->mVerticalScreen ) {
502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
506 } else { 506 } else {
507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
510 } 510 }
511 if ( !KOPrefs::instance()->mShowDateNavigator) 511 if ( !KOPrefs::instance()->mShowDateNavigator)
512 mDateNavigator->hide(); 512 mDateNavigator->hide();
513 //qDebug("Calendarview Size %d %d ", width(), height()); 513 //qDebug("Calendarview Size %d %d ", width(), height());
514#endif 514#endif
515 515
516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
517 SLOT( showDates( const KCal::DateList & ) ) ); 517 SLOT( showDates( const KCal::DateList & ) ) );
518 518
519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
521 521
522 522
523 523
524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
525 mViewManager, SLOT( showMonth( const QDate & ) ) ); 525 mViewManager, SLOT( showMonth( const QDate & ) ) );
526 526
527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
528 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 528 mNavigator, SLOT( selectWeek( const QDate & ) ) );
529 529
530 connect( mDateNavigator, SIGNAL( goPrevYear() ), 530 connect( mDateNavigator, SIGNAL( goPrevYear() ),
531 mNavigator, SLOT( selectPreviousYear() ) ); 531 mNavigator, SLOT( selectPreviousYear() ) );
532 connect( mDateNavigator, SIGNAL( goNextYear() ), 532 connect( mDateNavigator, SIGNAL( goNextYear() ),
533 mNavigator, SLOT( selectNextYear() ) ); 533 mNavigator, SLOT( selectNextYear() ) );
534 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 534 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
535 mNavigator, SLOT( selectPreviousMonth() ) ); 535 mNavigator, SLOT( selectPreviousMonth() ) );
536 connect( mDateNavigator, SIGNAL( goNextMonth() ), 536 connect( mDateNavigator, SIGNAL( goNextMonth() ),
537 mNavigator, SLOT( selectNextMonth() ) ); 537 mNavigator, SLOT( selectNextMonth() ) );
538 538
539 connect( mDateNavigator, SIGNAL( goPrevious() ), 539 connect( mDateNavigator, SIGNAL( goPrevious() ),
540 mNavigator, SLOT( selectPrevious() ) ); 540 mNavigator, SLOT( selectPrevious() ) );
541 connect( mDateNavigator, SIGNAL( goNext() ), 541 connect( mDateNavigator, SIGNAL( goNext() ),
542 mNavigator, SLOT( selectNext() ) ); 542 mNavigator, SLOT( selectNext() ) );
543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
544 mNavigator, SLOT( slotMonthSelect( int ) ) ); 544 mNavigator, SLOT( slotMonthSelect( int ) ) );
545 545
546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
548#if 0 548#if 0
549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
550 SLOT( incidenceAdded( Incidence *) ) ); 550 SLOT( incidenceAdded( Incidence *) ) );
551#endif 551#endif
552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
553 553
554 connect( this, SIGNAL( configChanged() ), 554 connect( this, SIGNAL( configChanged() ),
555 mDateNavigator, SLOT( updateConfig() ) ); 555 mDateNavigator, SLOT( updateConfig() ) );
556 556
557 connect( mTodoList, SIGNAL( newTodoSignal() ), 557 connect( mTodoList, SIGNAL( newTodoSignal() ),
558 SLOT( newTodo() ) ); 558 SLOT( newTodo() ) );
559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
560 SLOT( newSubTodo( Todo * ) ) ); 560 SLOT( newSubTodo( Todo * ) ) );
561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
562 SLOT( editTodo( Todo * ) ) ); 562 SLOT( editTodo( Todo * ) ) );
563 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 563 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
564 SLOT( showTodo( Todo *) ) ); 564 SLOT( showTodo( Todo *) ) );
565 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 565 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
566 SLOT( deleteTodo( Todo *) ) ); 566 SLOT( deleteTodo( Todo *) ) );
567 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 567 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
568 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 568 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
569 SLOT( purgeCompleted() ) ); 569 SLOT( purgeCompleted() ) );
570 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 570 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
571 SIGNAL( todoModified( Todo *, int ) ) ); 571 SIGNAL( todoModified( Todo *, int ) ) );
572 572
573 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 573 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
574 this, SLOT ( cloneIncidence( Incidence * ) ) ); 574 this, SLOT ( cloneIncidence( Incidence * ) ) );
575 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 575 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
576 this, SLOT (cancelIncidence( Incidence * ) ) ); 576 this, SLOT (cancelIncidence( Incidence * ) ) );
577 577
578 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 578 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
579 this, SLOT ( moveIncidence( Incidence * ) ) ); 579 this, SLOT ( moveIncidence( Incidence * ) ) );
580 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 580 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
581 this, SLOT ( beamIncidence( Incidence * ) ) ); 581 this, SLOT ( beamIncidence( Incidence * ) ) );
582 582
583 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 583 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
584 this, SLOT ( todo_unsub( Todo * ) ) ); 584 this, SLOT ( todo_unsub( Todo * ) ) );
585 585
586 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 586 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
587 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 587 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
588 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 588 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
589 SLOT( updateTodo( Todo *, int ) ) ); 589 SLOT( updateTodo( Todo *, int ) ) );
590 connect( this, SIGNAL( todoModified( Todo *, int )), this, 590 connect( this, SIGNAL( todoModified( Todo *, int )), this,
591 SLOT( changeTodoDisplay( Todo *, int ) ) ); 591 SLOT( changeTodoDisplay( Todo *, int ) ) );
592 592
593 593
594 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 594 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
595 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 595 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
596 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 596 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
597 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 597 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
598 598
599 599
600 600
601 601
602 602
603 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 603 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
604 SLOT(checkClipboard())); 604 SLOT(checkClipboard()));
605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
606 SLOT( processTodoListSelection( Incidence * ) ) ); 606 SLOT( processTodoListSelection( Incidence * ) ) );
607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
608 608
609 // kdDebug() << "CalendarView::CalendarView() done" << endl; 609 // kdDebug() << "CalendarView::CalendarView() done" << endl;
610 610
611 mDateFrame = new QVBox(0,0,WType_Popup); 611 mDateFrame = new QVBox(0,0,WType_Popup);
612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
614 mDateFrame->setLineWidth(3); 614 mDateFrame->setLineWidth(3);
615 mDateFrame->hide(); 615 mDateFrame->hide();
616 mDateFrame->setCaption( i18n( "Pick a date to display")); 616 mDateFrame->setCaption( i18n( "Pick a date to display"));
617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
618 618
619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
620 620
621 mEventEditor = mDialogManager->getEventEditor(); 621 mEventEditor = mDialogManager->getEventEditor();
622 mTodoEditor = mDialogManager->getTodoEditor(); 622 mTodoEditor = mDialogManager->getTodoEditor();
623 623
624 mFlagEditDescription = false; 624 mFlagEditDescription = false;
625 625
626 mSuspendTimer = new QTimer( this ); 626 mSuspendTimer = new QTimer( this );
627 mAlarmTimer = new QTimer( this ); 627 mAlarmTimer = new QTimer( this );
628 mRecheckAlarmTimer = new QTimer( this ); 628 mRecheckAlarmTimer = new QTimer( this );
629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
632 mAlarmDialog = new AlarmDialog( this ); 632 mAlarmDialog = new AlarmDialog( this );
633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
634 mAlarmDialog->setServerNotification( false ); 634 mAlarmDialog->setServerNotification( false );
635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
636 636
637 637
638#ifndef DESKTOP_VERSION 638#ifndef DESKTOP_VERSION
639//US listen for arriving address resultsets 639//US listen for arriving address resultsets
640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
642#endif 642#endif
643 mDateNavigator->setCalendar( mCalendar ); 643 mDateNavigator->setCalendar( mCalendar );
644} 644}
645 645
646 646
647CalendarView::~CalendarView() 647CalendarView::~CalendarView()
648{ 648{
649 // kdDebug() << "~CalendarView()" << endl; 649 // kdDebug() << "~CalendarView()" << endl;
650 //qDebug("CalendarView::~CalendarView() "); 650 //qDebug("CalendarView::~CalendarView() ");
651 delete mDialogManager; 651 delete mDialogManager;
652 delete mViewManager; 652 delete mViewManager;
653 delete mStorage; 653 delete mStorage;
654 delete mDateFrame ; 654 delete mDateFrame ;
655 delete mEventViewerDialog; 655 delete mEventViewerDialog;
656 //kdDebug() << "~CalendarView() done" << endl; 656 //kdDebug() << "~CalendarView() done" << endl;
657} 657}
658 658
659 659
660void CalendarView::nextConflict( bool all, bool allday ) 660void CalendarView::nextConflict( bool all, bool allday )
661{ 661{
662 static bool block = false; 662 static bool block = false;
663 if ( block ) return; 663 if ( block ) return;
664 block = true; 664 block = true;
665 QPtrList<Event> testlist = mCalendar->events(); 665 QPtrList<Event> testlist = mCalendar->events();
666 Event * test = testlist.first(); 666 Event * test = testlist.first();
667 while ( test ) { 667 while ( test ) {
668 test->setTagged( false ); 668 test->setTagged( false );
669 test = testlist.next(); 669 test = testlist.next();
670 } 670 }
671 QTime st ( 0,0,0); 671 QTime st ( 0,0,0);
672 if ( mViewManager->currentView() == mViewManager->agendaView() ) 672 if ( mViewManager->currentView() == mViewManager->agendaView() )
673 st = mViewManager->agendaView()->agenda()->getEndTime(); 673 st = mViewManager->agendaView()->agenda()->getEndTime();
674 //qDebug("time %s ", st.toString().latin1()); 674 //qDebug("time %s ", st.toString().latin1());
675 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 675 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
676 QDateTime conflict; 676 QDateTime conflict;
677 QDateTime retVal; 677 QDateTime retVal;
678 bool found = false; 678 bool found = false;
679 Event * cE = 0; 679 Event * cE = 0;
680 Event * cE2 = 0; 680 Event * cE2 = 0;
681 QPtrList<Event> testlist2 = testlist; 681 QPtrList<Event> testlist2 = testlist;
682 test = testlist.first(); 682 test = testlist.first();
683 bool skip = false; 683 bool skip = false;
684 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 684 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
685 //QTime tm; 685 //QTime tm;
686 //tm.start(); 686 //tm.start();
687 while ( test ) { 687 while ( test ) {
688 qApp->processEvents(); 688 qApp->processEvents();
689 skip = false; 689 skip = false;
690 if ( !all ) skip = ( allday != test->doesFloat() ); 690 if ( !all ) skip = ( allday != test->doesFloat() );
691 if ( !skip ) { 691 if ( !skip ) {
692 if ( found ) 692 if ( found )
693 skip = !test->matchTime( &startDT, &conflict ); 693 skip = !test->matchTime( &startDT, &conflict );
694 else 694 else
695 skip = !test->matchTime( &startDT, 0 ); 695 skip = !test->matchTime( &startDT, 0 );
696 } 696 }
697 if ( !skip ) { 697 if ( !skip ) {
698 Event * test2 = testlist2.first(); 698 Event * test2 = testlist2.first();
699 while ( test2 ) { 699 while ( test2 ) {
700 skip = test2->isTagged(); 700 skip = test2->isTagged();
701 if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); 701 if ( !skip && !all ) skip = ( allday != test2->doesFloat() );
702 if ( !skip ) { 702 if ( !skip ) {
703 if ( found ) 703 if ( found )
704 skip = !test2->matchTime( &startDT, &conflict ); 704 skip = !test2->matchTime( &startDT, &conflict );
705 else 705 else
706 skip = !test2->matchTime( &startDT, 0 ); 706 skip = !test2->matchTime( &startDT, 0 );
707 } 707 }
708 if ( !skip ) { 708 if ( !skip ) {
709 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 709 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
710 //qDebug("overlap "); 710 //qDebug("overlap ");
711 if ( ! found ) { 711 if ( ! found ) {
712 if ( retVal >= startDT ) { 712 if ( retVal >= startDT ) {
713 conflict = retVal; 713 conflict = retVal;
714 cE = test; 714 cE = test;
715 cE2 = test2; 715 cE2 = test2;
716 found = true; 716 found = true;
717 } 717 }
718 } else { 718 } else {
719 if ( retVal >= startDT && retVal < conflict ) { 719 if ( retVal >= startDT && retVal < conflict ) {
720 conflict = retVal; 720 conflict = retVal;
721 cE = test; 721 cE = test;
722 cE2 = test2; 722 cE2 = test2;
723 } 723 }
724 } 724 }
725 } 725 }
726 } 726 }
727 test2 = testlist2.next(); 727 test2 = testlist2.next();
728 } 728 }
729 } 729 }
730 test->setTagged( true ); 730 test->setTagged( true );
731 test = testlist.next(); 731 test = testlist.next();
732 } 732 }
733 //qDebug("Search time : %d", tm.elapsed()); 733 //qDebug("Search time : %d", tm.elapsed());
734 if ( found ) { 734 if ( found ) {
735 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 735 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
736 mViewManager->showDayView(); 736 mViewManager->showDayView();
737 mNavigator->slotDaySelect( conflict.date() ); 737 mNavigator->slotDaySelect( conflict.date() );
738 int hour = conflict.time().hour(); 738 int hour = conflict.time().hour();
739 mViewManager->agendaView()->setStartHour( hour ); 739 mViewManager->agendaView()->setStartHour( hour );
740 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); 740 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
741 block = false; 741 block = false;
742 return; 742 return;
743 } 743 }
744 744
745 topLevelWidget()->setCaption( i18n("No conflict found") ); 745 topLevelWidget()->setCaption( i18n("No conflict found") );
746 //qDebug("No conflict found "); 746 //qDebug("No conflict found ");
747 block = false; 747 block = false;
748 return; 748 return;
749} 749}
750 750
751void CalendarView::conflictAll() 751void CalendarView::conflictAll()
752{ 752{
753 nextConflict ( true, true ); 753 nextConflict ( true, true );
754} 754}
755void CalendarView::conflictAllday() 755void CalendarView::conflictAllday()
756{ 756{
757 nextConflict ( false, true ); 757 nextConflict ( false, true );
758} 758}
759void CalendarView::conflictNotAll() 759void CalendarView::conflictNotAll()
760{ 760{
761 nextConflict ( false, false ); 761 nextConflict ( false, false );
762} 762}
763 763
764void CalendarView::setCalReadOnly( int id, bool readO ) 764void CalendarView::setCalReadOnly( int id, bool readO )
765{ 765{
766 if ( readO ) { 766 if ( readO ) {
767 emit save(); 767 emit save();
768 } 768 }
769 mCalendar->setReadOnly( id, readO ); 769 mCalendar->setReadOnly( id, readO );
770} 770}
771void CalendarView::setScrollBarStep(int val ) 771void CalendarView::setScrollBarStep(int val )
772{ 772{
773#ifdef DESKTOP_VERSION 773#ifdef DESKTOP_VERSION
774 mDateScrollBar->setLineStep ( val ); 774 mDateScrollBar->setLineStep ( val );
775#endif 775#endif
776} 776}
777void CalendarView::scrollBarValue(int val ) 777void CalendarView::scrollBarValue(int val )
778{ 778{
779#ifdef DESKTOP_VERSION 779#ifdef DESKTOP_VERSION
780 if ( QApplication::desktop()->width() < 800 ) return; 780 if ( QApplication::desktop()->width() < 800 ) return;
781 static bool block = false; 781 static bool block = false;
782 if ( block ) return; 782 if ( block ) return;
783 block = true; 783 block = true;
784 int count = mNavigator->selectedDates().count(); 784 int count = mNavigator->selectedDates().count();
785 int day = mNavigator->selectedDates().first().dayOfYear(); 785 int day = mNavigator->selectedDates().first().dayOfYear();
786 int stepdays = val; 786 int stepdays = val;
787 if ( mDateScrollBar->lineStep () <= count ) { 787 if ( mDateScrollBar->lineStep () <= count ) {
788 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 788 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
789 //qDebug("VAL %d ",val ); 789 //qDebug("VAL %d ",val );
790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 790 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
791 stepdays = day+stepdays; 791 stepdays = day+stepdays;
792 if ( stepdays < 0 ) stepdays = 0; 792 if ( stepdays < 0 ) stepdays = 0;
793 } 793 }
794 if ( stepdays == day ) { 794 if ( stepdays == day ) {
795 block = false; 795 block = false;
796 return; 796 return;
797 } 797 }
798 int year = mNavigator->selectedDates().first().year(); 798 int year = mNavigator->selectedDates().first().year();
799 QDate d ( year,1,1 ); 799 QDate d ( year,1,1 );
800 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 800 mNavigator->selectDates( d.addDays( stepdays-1) , count );
801 block = false; 801 block = false;
802#endif 802#endif
803 803
804} 804}
805void CalendarView::updateView(const QDate &start, const QDate &end) 805void CalendarView::updateView(const QDate &start, const QDate &end)
806{ 806{
807#ifdef DESKTOP_VERSION 807#ifdef DESKTOP_VERSION
808 if ( ! mDateScrollBar->draggingSlider () ) { 808 if ( ! mDateScrollBar->draggingSlider () ) {
809 int dof = start.dayOfYear(); 809 int dof = start.dayOfYear();
810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 810 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
811 if ( dof != mDateScrollBar->value() ) { 811 if ( dof != mDateScrollBar->value() ) {
812 mDateScrollBar->blockSignals( true ); 812 mDateScrollBar->blockSignals( true );
813 mDateScrollBar->setValue( start.dayOfYear()); 813 mDateScrollBar->setValue( start.dayOfYear());
814 mDateScrollBar->blockSignals( false ); 814 mDateScrollBar->blockSignals( false );
815 } 815 }
816 } 816 }
817#endif 817#endif
818 mTodoList->updateView(); 818 mTodoList->updateView();
819 mViewManager->updateView(start, end); 819 mViewManager->updateView(start, end);
820 //mDateNavigator->updateView(); 820 //mDateNavigator->updateView();
821} 821}
822 822
823 823
824 824
825void CalendarView::checkFiles() 825void CalendarView::checkFiles()
826{ 826{
827 QString message; 827 QString message;
828 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 828 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
829 KopiCalendarFile * cal = calendars.first(); 829 KopiCalendarFile * cal = calendars.first();
830 while ( cal ) { 830 while ( cal ) {
831 if ( cal->mErrorOnLoad ) { 831 if ( cal->mErrorOnLoad ) {
832 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 832 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
833 } 833 }
834 cal = calendars.next(); 834 cal = calendars.next();
835 } 835 }
836 if ( !message.isEmpty() ) { 836 if ( !message.isEmpty() ) {
837 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); 837 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0);
838 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); 838 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed"));
839 } 839 }
840 static bool firstTime = true; 840 static bool firstTime = true;
841 if ( firstTime ) { 841 if ( firstTime ) {
842 firstTime = false; 842 firstTime = false;
843 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 843 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
844 } 844 }
845} 845}
846void CalendarView::checkAlarms() 846void CalendarView::checkAlarms()
847{ 847{
848 KConfig *config = KOGlobals::config(); 848 KConfig *config = KOGlobals::config();
849 config->setGroup( "AppRun" ); 849 config->setGroup( "AppRun" );
850 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 850 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
851 int daysto = dt.daysTo( QDate::currentDate() ); 851 int daysto = dt.daysTo( QDate::currentDate() );
852 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 852 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
853 dt = dt.addDays( days ); 853 dt = dt.addDays( days );
854 int secto = dt.secsTo( QDateTime::currentDateTime() ); 854 int secto = dt.secsTo( QDateTime::currentDateTime() );
855 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 855 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
856 //qDebug("KO: Reading program stop %d ", secs); 856 //qDebug("KO: Reading program stop %d ", secs);
857 //secs -= ( 3600 * 24*3 ); // debug only 857 //secs -= ( 3600 * 24*3 ); // debug only
858 QDateTime latest = dt.addSecs ( secs ); 858 QDateTime latest = dt.addSecs ( secs );
859 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 859 qDebug("KO: Last termination on %s ", latest.toString().latin1());
860 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 860 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
861 QPtrList<Incidence> el = mCalendar->rawIncidences(); 861 QPtrList<Incidence> el = mCalendar->rawIncidences();
862 QPtrList<Incidence> al; 862 QPtrList<Incidence> al;
863 Incidence* inL = el.first(); 863 Incidence* inL = el.first();
864 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 864 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
865 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 865 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
866 while ( inL ) { 866 while ( inL ) {
867 bool ok = false; 867 bool ok = false;
868 int offset = 0; 868 int offset = 0;
869 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 869 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
870 if ( ok ) { 870 if ( ok ) {
871 //qDebug("OK %s",next.toString().latin1()); 871 //qDebug("OK %s",next.toString().latin1());
872 if ( next < cur ) { 872 if ( next < cur ) {
873 al.append( inL ); 873 al.append( inL );
874 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 874 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
875 } 875 }
876 } 876 }
877 inL = el.next(); 877 inL = el.next();
878 } 878 }
879 if ( al.count() ) { 879 if ( al.count() ) {
880 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 880 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
881 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 881 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
882 QVBoxLayout* lay = new QVBoxLayout( dia ); 882 QVBoxLayout* lay = new QVBoxLayout( dia );
883 lay->setSpacing( 0 ); 883 lay->setSpacing( 0 );
884 lay->setMargin( 0 ); 884 lay->setMargin( 0 );
885 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 885 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
886 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 886 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
887 lay->addWidget( matb ); 887 lay->addWidget( matb );
888 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 888 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
889 int wid = 210; 889 int wid = 210;
890 int x = QApplication::desktop()->width() - wid - 7; 890 int x = QApplication::desktop()->width() - wid - 7;
891 int y = QApplication::desktop()->height() - wid - 70; 891 int y = QApplication::desktop()->height() - wid - 70;
892 dia->setGeometry ( x,y,wid,wid); 892 dia->setGeometry ( x,y,wid,wid);
893 } else { 893 } else {
894 int si = 220; 894 int si = 220;
895 if ( QApplication::desktop()->width() > 470 ) 895 if ( QApplication::desktop()->width() > 470 )
896 si = 400; 896 si = 400;
897 dia->resize(si,si/2); 897 dia->resize(si,si/2);
898 } 898 }
899 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 899 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
900 dia->show(); 900 dia->show();
901 901
902 } 902 }
903#if 0 903#if 0
904 // for creating timetracker test data 904 // for creating timetracker test data
905 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); 905 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc ");
906 Todo * nt; 906 Todo * nt;
907 mCalendar->close(); 907 mCalendar->close();
908 { 908 {
909 Todo * root1 = new Todo; 909 Todo * root1 = new Todo;
910 mCalendar->addTodo( root1 ); 910 mCalendar->addTodo( root1 );
911 root1->setSummary( "Project_1"); 911 root1->setSummary( "Project_1");
912 root1->setPriority( 1 ); 912 root1->setPriority( 1 );
913 root1->setDescription( "This is a test description of a root Project" ); 913 root1->setDescription( "This is a test description of a root Project" );
914 root1->setPercentComplete( 20 ); 914 root1->setPercentComplete( 20 );
915 updateView(); 915 updateView();
916 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 916 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
917 QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) ); 917 QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) );
918 918
919 nt = new Todo; 919 nt = new Todo;
920 mCalendar->addTodo( nt ); 920 mCalendar->addTodo( nt );
921 nt->setSummary( "Planning_Project_1"); 921 nt->setSummary( "Planning_Project_1");
922 nt->setPriority( 1 ); 922 nt->setPriority( 1 );
923 nt->setDescription( "This is a test description of Planning_Project_1" ); 923 nt->setDescription( "This is a test description of Planning_Project_1" );
924 nt->setPercentComplete( 20 ); 924 nt->setPercentComplete( 20 );
925 925
926 926
927 Todo * sub1 = nt; 927 Todo * sub1 = nt;
928 sub1->setRelatedTo( root1 ); 928 sub1->setRelatedTo( root1 );
929 929
930 nt = new Todo; 930 nt = new Todo;
931 mCalendar->addTodo( nt ); 931 mCalendar->addTodo( nt );
932 nt->setSummary( "Planning_Project_1: Lutz"); 932 nt->setSummary( "Planning_Project_1: Lutz");
933 nt->setPriority( 1 ); 933 nt->setPriority( 1 );
934 nt->setDescription( "This todo counts the actual work of a person on a project" ); 934 nt->setDescription( "This todo counts the actual work of a person on a project" );
935 nt->setPercentComplete( 20 ); 935 nt->setPercentComplete( 20 );
936 Todo * workLutz11 = nt; 936 Todo * workLutz11 = nt;
937 workLutz11->setRelatedTo( sub1 ); 937 workLutz11->setRelatedTo( sub1 );
938 938
939 nt = new Todo; 939 nt = new Todo;
940 mCalendar->addTodo( nt ); 940 mCalendar->addTodo( nt );
941 nt->setSummary( "Planning_Project_1: Norbert"); 941 nt->setSummary( "Planning_Project_1: Norbert");
942 nt->setPriority( 1 ); 942 nt->setPriority( 1 );
943 nt->setDescription( "This todo counts the actual work of a person on a project" ); 943 nt->setDescription( "This todo counts the actual work of a person on a project" );
944 nt->setPercentComplete( 20 ); 944 nt->setPercentComplete( 20 );
945 Todo * workNorbert11 = nt; 945 Todo * workNorbert11 = nt;
946 workNorbert11->setRelatedTo( sub1 ); 946 workNorbert11->setRelatedTo( sub1 );
947 947
948 nt = new Todo; 948 nt = new Todo;
949 mCalendar->addTodo( nt ); 949 mCalendar->addTodo( nt );
950 nt->setSummary( "Work on 1"); 950 nt->setSummary( "Work on 1");
951 nt->setPriority( 1 ); 951 nt->setPriority( 1 );
952 nt->setDescription( "This is a test description of Work Project_1" ); 952 nt->setDescription( "This is a test description of Work Project_1" );
953 nt->setPercentComplete( 20 ); 953 nt->setPercentComplete( 20 );
954 954
955 Todo * sub2 = nt; 955 Todo * sub2 = nt;
956 sub2->setRelatedTo( root1 ); 956 sub2->setRelatedTo( root1 );
957 957
958 958
959 nt = new Todo; 959 nt = new Todo;
960 mCalendar->addTodo( nt ); 960 mCalendar->addTodo( nt );
961 nt->setSummary( "Work on 1: Lutz"); 961 nt->setSummary( "Work on 1: Lutz");
962 nt->setPriority( 1 ); 962 nt->setPriority( 1 );
963 nt->setDescription( "This todo counts the actual work of a person on a project" ); 963 nt->setDescription( "This todo counts the actual work of a person on a project" );
964 nt->setPercentComplete( 20 ); 964 nt->setPercentComplete( 20 );
965 Todo * workLutz12 = nt; 965 Todo * workLutz12 = nt;
966 workLutz12->setRelatedTo( sub2 ); 966 workLutz12->setRelatedTo( sub2 );
967 967
968 nt = new Todo; 968 nt = new Todo;
969 mCalendar->addTodo( nt ); 969 mCalendar->addTodo( nt );
970 nt->setSummary( "Work on 1: Norbert"); 970 nt->setSummary( "Work on 1: Norbert");
971 nt->setPriority( 1 ); 971 nt->setPriority( 1 );
972 nt->setDescription( "This todo counts the actual work of a person on a project" ); 972 nt->setDescription( "This todo counts the actual work of a person on a project" );
973 nt->setPercentComplete( 20 ); 973 nt->setPercentComplete( 20 );
974 Todo * workNorbert12 = nt; 974 Todo * workNorbert12 = nt;
975 workNorbert12->setRelatedTo( sub2 ); 975 workNorbert12->setRelatedTo( sub2 );
976 976
977 int secLenRunning = 7200; 977 int secLenRunning = 7200;
978 int secLenPausing = 3600 * 3; 978 int secLenPausing = 3600 * 3;
979 int dayInterval = 1; 979 int dayInterval = 1;
980 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); 980 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval );
981 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); 981 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 );
982 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); 982 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1);
983 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); 983 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3);
984 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); 984 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0);
985 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); 985 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1);
986 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); 986 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3);
987 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); 987 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0);
988 988
989 } 989 }
990 990
991 { 991 {
992 Todo * root1 = new Todo; 992 Todo * root1 = new Todo;
993 mCalendar->addTodo( root1 ); 993 mCalendar->addTodo( root1 );
994 root1->setSummary( "Project_2"); 994 root1->setSummary( "Project_2");
995 root1->setPriority( 1 ); 995 root1->setPriority( 1 );
996 root1->setDescription( "This is a test description of a root Project 2" ); 996 root1->setDescription( "This is a test description of a root Project 2" );
997 root1->setPercentComplete( 20 ); 997 root1->setPercentComplete( 20 );
998 updateView(); 998 updateView();
999 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 999 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
1000 QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) ); 1000 QDateTime end = QDateTime ( QDate( 2005,8,1), QTime ( 0,0,0) );
1001 int secLenRunning = 7200; 1001 int secLenRunning = 7200;
1002 int secLenPausing = 3600 * 3; 1002 int secLenPausing = 3600 * 3;
1003 int dayInterval = 1; 1003 int dayInterval = 1;
1004 1004
1005 nt = new Todo; 1005 nt = new Todo;
1006 mCalendar->addTodo( nt ); 1006 mCalendar->addTodo( nt );
1007 nt->setSummary( "Planning_Project_2"); 1007 nt->setSummary( "Planning_Project_2");
1008 nt->setPriority( 1 ); 1008 nt->setPriority( 1 );
1009 nt->setDescription( "This is a test description of Planning_Project_2" ); 1009 nt->setDescription( "This is a test description of Planning_Project_2" );
1010 nt->setPercentComplete( 20 ); 1010 nt->setPercentComplete( 20 );
1011 1011
1012 1012
1013 Todo * sub1 = nt; 1013 Todo * sub1 = nt;
1014 sub1->setRelatedTo( root1 ); 1014 sub1->setRelatedTo( root1 );
1015 1015
1016 nt = new Todo; 1016 nt = new Todo;
1017 mCalendar->addTodo( nt ); 1017 mCalendar->addTodo( nt );
1018 nt->setSummary( "Planning_Project_2: Lutz"); 1018 nt->setSummary( "Planning_Project_2: Lutz");
1019 nt->setPriority( 1 ); 1019 nt->setPriority( 1 );
1020 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1020 nt->setDescription( "This todo counts the actual work of a person on a project" );
1021 nt->setPercentComplete( 20 ); 1021 nt->setPercentComplete( 20 );
1022 Todo * workLutz11 = nt; 1022 Todo * workLutz11 = nt;
1023 workLutz11->setRelatedTo( sub1 ); 1023 workLutz11->setRelatedTo( sub1 );
1024 1024
1025 nt = new Todo; 1025 nt = new Todo;
1026 mCalendar->addTodo( nt ); 1026 mCalendar->addTodo( nt );
1027 nt->setSummary( "Planning_Project_2: Norbert"); 1027 nt->setSummary( "Planning_Project_2: Norbert");
1028 nt->setPriority( 1 ); 1028 nt->setPriority( 1 );
1029 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1029 nt->setDescription( "This todo counts the actual work of a person on a project" );
1030 nt->setPercentComplete( 20 ); 1030 nt->setPercentComplete( 20 );
1031 Todo * workNorbert11 = nt; 1031 Todo * workNorbert11 = nt;
1032 workNorbert11->setRelatedTo( sub1 ); 1032 workNorbert11->setRelatedTo( sub1 );
1033 1033
1034 nt = new Todo; 1034 nt = new Todo;
1035 mCalendar->addTodo( nt ); 1035 mCalendar->addTodo( nt );
1036 nt->setSummary( "Work on 2"); 1036 nt->setSummary( "Work on 2");
1037 nt->setPriority( 1 ); 1037 nt->setPriority( 1 );
1038 nt->setDescription( "This is a test description of Work Project_2" ); 1038 nt->setDescription( "This is a test description of Work Project_2" );
1039 nt->setPercentComplete( 20 ); 1039 nt->setPercentComplete( 20 );
1040 1040
1041 Todo * sub2 = nt; 1041 Todo * sub2 = nt;
1042 sub2->setRelatedTo( root1 ); 1042 sub2->setRelatedTo( root1 );
1043 1043
1044 1044
1045 nt = new Todo; 1045 nt = new Todo;
1046 mCalendar->addTodo( nt ); 1046 mCalendar->addTodo( nt );
1047 nt->setSummary( "Work on 2: Lutz"); 1047 nt->setSummary( "Work on 2: Lutz");
1048 nt->setPriority( 1 ); 1048 nt->setPriority( 1 );
1049 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1049 nt->setDescription( "This todo counts the actual work of a person on a project" );
1050 nt->setPercentComplete( 20 ); 1050 nt->setPercentComplete( 20 );
1051 Todo * workLutz12 = nt; 1051 Todo * workLutz12 = nt;
1052 workLutz12->setRelatedTo( sub2 ); 1052 workLutz12->setRelatedTo( sub2 );
1053 1053
1054 nt = new Todo; 1054 nt = new Todo;
1055 mCalendar->addTodo( nt ); 1055 mCalendar->addTodo( nt );
1056 nt->setSummary( "Work on 2: Norbert"); 1056 nt->setSummary( "Work on 2: Norbert");
1057 nt->setPriority( 1 ); 1057 nt->setPriority( 1 );
1058 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1058 nt->setDescription( "This todo counts the actual work of a person on a project" );
1059 nt->setPercentComplete( 20 ); 1059 nt->setPercentComplete( 20 );
1060 Todo * workNorbert12 = nt; 1060 Todo * workNorbert12 = nt;
1061 workNorbert12->setRelatedTo( sub2 ); 1061 workNorbert12->setRelatedTo( sub2 );
1062 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); 1062 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 );
1063 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); 1063 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2);
1064 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); 1064 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7);
1065 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); 1065 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0);
1066 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); 1066 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1);
1067 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); 1067 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0);
1068 createRunningDate4Todo( workNorbert11, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); 1068 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0);
1069 } 1069 }
1070 updateView(); 1070 updateView();
1071#endif 1071#endif
1072
1072} 1073}
1073void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) 1074void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval )
1074{ 1075{
1075 static int ccc = 0; 1076 static int ccc = 0;
1076 ++ccc; 1077 ++ccc;
1077 QDateTime t_start = start; 1078 QDateTime t_start = start;
1078 runT->setPriority( 5 ); 1079 runT->setPriority( 5 );
1079 runT->setPercentComplete( 0 ); 1080 runT->setPercentComplete( 0 );
1080 int count = 0; 1081 int count = 0;
1081 int prio = 5; 1082 int prio = 5;
1082 int complete = 0; 1083 int complete = 0;
1083 while ( t_start < end ) { 1084 while ( t_start < end ) {
1084 ++count; 1085 ++count;
1085 if ( count > ccc ) { 1086 if ( count > ccc ) {
1086 count = 0; 1087 count = 0;
1087 --prio; 1088 --prio;
1088 if ( prio == 0 ) prio = 5; 1089 if ( prio == 0 ) prio = 5;
1089 complete += 20; 1090 complete += 20;
1090 if ( complete > 100 ) complete = 0; 1091 if ( complete > 100 ) complete = 0;
1091 runT->setPriority( prio ); 1092 runT->setPriority( prio );
1092 runT->setPercentComplete( complete ); 1093 runT->setPercentComplete( complete );
1093 } 1094 }
1094 runT->setRunning( true ); 1095 runT->setRunning( true );
1095 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); 1096 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) );
1096 if ( dayInterval ) 1097 if ( dayInterval )
1097 t_start = t_start.addDays( dayInterval ); 1098 t_start = t_start.addDays( dayInterval );
1098 else { 1099 else {
1099 t_start = t_start.addSecs( secLenRunning + secLenPausing ); 1100 t_start = t_start.addSecs( secLenRunning + secLenPausing );
1100 } 1101 }
1101 } 1102 }
1102} 1103}
1103 1104
1104void CalendarView::showDay( QDate d ) 1105void CalendarView::showDay( QDate d )
1105{ 1106{
1106 dateNavigator()->blockSignals( true ); 1107 dateNavigator()->blockSignals( true );
1107 dateNavigator()->selectDate( d ); 1108 dateNavigator()->selectDate( d );
1108 dateNavigator()->blockSignals( false ); 1109 dateNavigator()->blockSignals( false );
1109 mViewManager->showDayView(); 1110 mViewManager->showDayView();
1110 //dateNavigator()->selectDate( d ); 1111 //dateNavigator()->selectDate( d );
1111} 1112}
1112void CalendarView::timerAlarm() 1113void CalendarView::timerAlarm()
1113{ 1114{
1114 //qDebug("CalendarView::timerAlarm() "); 1115 //qDebug("CalendarView::timerAlarm() ");
1115 computeAlarm(mAlarmNotification ); 1116 computeAlarm(mAlarmNotification );
1116} 1117}
1117 1118
1118void CalendarView::suspendAlarm() 1119void CalendarView::suspendAlarm()
1119{ 1120{
1120 //qDebug(" CalendarView::suspendAlarm() "); 1121 //qDebug(" CalendarView::suspendAlarm() ");
1121 computeAlarm(mSuspendAlarmNotification ); 1122 computeAlarm(mSuspendAlarmNotification );
1122 1123
1123} 1124}
1124 1125
1125void CalendarView::startAlarm( QString mess , QString filename) 1126void CalendarView::startAlarm( QString mess , QString filename)
1126{ 1127{
1127 1128
1128 topLevelWidget()->showNormal(); 1129 topLevelWidget()->showNormal();
1129 topLevelWidget()->setActiveWindow(); 1130 topLevelWidget()->setActiveWindow();
1130 topLevelWidget()->raise(); 1131 topLevelWidget()->raise();
1131 1132
1132 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 1133 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
1133 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 1134 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
1134 1135
1135} 1136}
1136 1137
1137void CalendarView::checkNextTimerAlarm() 1138void CalendarView::checkNextTimerAlarm()
1138{ 1139{
1139 mCalendar->checkAlarmForIncidence( 0, true ); 1140 mCalendar->checkAlarmForIncidence( 0, true );
1140} 1141}
1141 1142
1142void CalendarView::computeAlarm( QString msg ) 1143void CalendarView::computeAlarm( QString msg )
1143{ 1144{
1144 1145
1145 QString mess = msg; 1146 QString mess = msg;
1146 QString mAlarmMessage = mess.mid( 9 ); 1147 QString mAlarmMessage = mess.mid( 9 );
1147 QString filename = MainWindow::resourcePath(); 1148 QString filename = MainWindow::resourcePath();
1148 filename += "koalarm.wav"; 1149 filename += "koalarm.wav";
1149 QString tempfilename; 1150 QString tempfilename;
1150 if ( mess.left( 13 ) == "suspend_alarm") { 1151 if ( mess.left( 13 ) == "suspend_alarm") {
1151 bool error = false; 1152 bool error = false;
1152 int len = mess.mid( 13 ).find("+++"); 1153 int len = mess.mid( 13 ).find("+++");
1153 if ( len < 2 ) 1154 if ( len < 2 )
1154 error = true; 1155 error = true;
1155 else { 1156 else {
1156 tempfilename = mess.mid( 13, len ); 1157 tempfilename = mess.mid( 13, len );
1157 if ( !QFile::exists( tempfilename ) ) 1158 if ( !QFile::exists( tempfilename ) )
1158 error = true; 1159 error = true;
1159 } 1160 }
1160 if ( ! error ) { 1161 if ( ! error ) {
1161 filename = tempfilename; 1162 filename = tempfilename;
1162 } 1163 }
1163 mAlarmMessage = mess.mid( 13+len+3 ); 1164 mAlarmMessage = mess.mid( 13+len+3 );
1164 //qDebug("suspend file %s ",tempfilename.latin1() ); 1165 //qDebug("suspend file %s ",tempfilename.latin1() );
1165 startAlarm( mAlarmMessage, filename); 1166 startAlarm( mAlarmMessage, filename);
1166 return; 1167 return;
1167 } 1168 }
1168 if ( mess.left( 11 ) == "timer_alarm") { 1169 if ( mess.left( 11 ) == "timer_alarm") {
1169 //mTimerTime = 0; 1170 //mTimerTime = 0;
1170 startAlarm( mess.mid( 11 ), filename ); 1171 startAlarm( mess.mid( 11 ), filename );
1171 return; 1172 return;
1172 } 1173 }
1173 if ( mess.left( 10 ) == "proc_alarm") { 1174 if ( mess.left( 10 ) == "proc_alarm") {
1174 bool error = false; 1175 bool error = false;
1175 int len = mess.mid( 10 ).find("+++"); 1176 int len = mess.mid( 10 ).find("+++");
1176 if ( len < 2 ) 1177 if ( len < 2 )
1177 error = true; 1178 error = true;
1178 else { 1179 else {
1179 tempfilename = mess.mid( 10, len ); 1180 tempfilename = mess.mid( 10, len );
1180 if ( !QFile::exists( tempfilename ) ) 1181 if ( !QFile::exists( tempfilename ) )
1181 error = true; 1182 error = true;
1182 } 1183 }
1183 if ( error ) { 1184 if ( error ) {
1184 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 1185 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
1185 mAlarmMessage += mess.mid( 10+len+3+9 ); 1186 mAlarmMessage += mess.mid( 10+len+3+9 );
1186 } else { 1187 } else {
1187 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 1188 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
1188 //qDebug("-----system command %s ",tempfilename.latin1() ); 1189 //qDebug("-----system command %s ",tempfilename.latin1() );
1189#ifndef _WIN32_ 1190#ifndef _WIN32_
1190 if ( vfork () == 0 ) { 1191 if ( vfork () == 0 ) {
1191 execl ( tempfilename.latin1(), 0 ); 1192 execl ( tempfilename.latin1(), 0 );
1192 return; 1193 return;
1193 } 1194 }
1194#else 1195#else
1195 QProcess* p = new QProcess(); 1196 QProcess* p = new QProcess();
1196 p->addArgument( tempfilename.latin1() ); 1197 p->addArgument( tempfilename.latin1() );
1197 p->start(); 1198 p->start();
1198 return; 1199 return;
1199#endif 1200#endif
1200 1201
1201 return; 1202 return;
1202 } 1203 }
1203 1204
1204 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 1205 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1205 } 1206 }
1206 if ( mess.left( 11 ) == "audio_alarm") { 1207 if ( mess.left( 11 ) == "audio_alarm") {
1207 bool error = false; 1208 bool error = false;
1208 int len = mess.mid( 11 ).find("+++"); 1209 int len = mess.mid( 11 ).find("+++");
1209 if ( len < 2 ) 1210 if ( len < 2 )
1210 error = true; 1211 error = true;
1211 else { 1212 else {
1212 tempfilename = mess.mid( 11, len ); 1213 tempfilename = mess.mid( 11, len );
1213 if ( !QFile::exists( tempfilename ) ) 1214 if ( !QFile::exists( tempfilename ) )
1214 error = true; 1215 error = true;
1215 } 1216 }
1216 if ( ! error ) { 1217 if ( ! error ) {
1217 filename = tempfilename; 1218 filename = tempfilename;
1218 } 1219 }
1219 mAlarmMessage = mess.mid( 11+len+3+9 ); 1220 mAlarmMessage = mess.mid( 11+len+3+9 );
1220 //qDebug("audio file command %s ",tempfilename.latin1() ); 1221 //qDebug("audio file command %s ",tempfilename.latin1() );
1221 } 1222 }
1222 if ( mess.left( 9 ) == "cal_alarm") { 1223 if ( mess.left( 9 ) == "cal_alarm") {
1223 mAlarmMessage = mess.mid( 9 ) ; 1224 mAlarmMessage = mess.mid( 9 ) ;
1224 } 1225 }
1225 1226
1226 startAlarm( mAlarmMessage, filename ); 1227 startAlarm( mAlarmMessage, filename );
1227 1228
1228 1229
1229} 1230}
1230 1231
1231void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1232void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1232{ 1233{
1233 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1234 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1234 1235
1235 mSuspendAlarmNotification = noti; 1236 mSuspendAlarmNotification = noti;
1236 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1237 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1237 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1238 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1238 mSuspendTimer->start( ms , true ); 1239 mSuspendTimer->start( ms , true );
1239 1240
1240} 1241}
1241 1242
1242void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1243void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1243{ 1244{
1244 mNextAlarmDateTime = qdt; 1245 mNextAlarmDateTime = qdt;
1245 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1246 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1246 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1247 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1247#ifndef DESKTOP_VERSION 1248#ifndef DESKTOP_VERSION
1248 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1249 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1249#endif 1250#endif
1250 return; 1251 return;
1251 } 1252 }
1252 int maxSec; 1253 int maxSec;
1253 //maxSec = 5; //testing only 1254 //maxSec = 5; //testing only
1254 maxSec = 86400+3600; // one day+1hour 1255 maxSec = 86400+3600; // one day+1hour
1255 mAlarmNotification = noti; 1256 mAlarmNotification = noti;
1256 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1257 int sec = QDateTime::currentDateTime().secsTo( qdt );
1257 if ( sec > maxSec ) { 1258 if ( sec > maxSec ) {
1258 mRecheckAlarmTimer->start( maxSec * 1000 ); 1259 mRecheckAlarmTimer->start( maxSec * 1000 );
1259 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1260 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1260 return; 1261 return;
1261 } else { 1262 } else {
1262 mRecheckAlarmTimer->stop(); 1263 mRecheckAlarmTimer->stop();
1263 } 1264 }
1264 //qDebug("Alarm timer started with secs: %d ", sec); 1265 //qDebug("Alarm timer started with secs: %d ", sec);
1265 mAlarmTimer->start( sec *1000 , true ); 1266 mAlarmTimer->start( sec *1000 , true );
1266 1267
1267} 1268}
1268// called by mRecheckAlarmTimer to get next alarm 1269// called by mRecheckAlarmTimer to get next alarm
1269// we need this, because a QTimer has only a max range of 25 days 1270// we need this, because a QTimer has only a max range of 25 days
1270void CalendarView::recheckTimerAlarm() 1271void CalendarView::recheckTimerAlarm()
1271{ 1272{
1272 mAlarmTimer->stop(); 1273 mAlarmTimer->stop();
1273 mRecheckAlarmTimer->stop(); 1274 mRecheckAlarmTimer->stop();
1274 mCalendar->checkAlarmForIncidence( 0, true ); 1275 mCalendar->checkAlarmForIncidence( 0, true );
1275} 1276}
1276#ifndef DESKTOP_VERSION 1277#ifndef DESKTOP_VERSION
1277void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1278void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1278#else 1279#else
1279void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1280void CalendarView::removeAlarm(const QDateTime &, const QString & )
1280#endif 1281#endif
1281{ 1282{
1282 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1283 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1283 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1284 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1284#ifndef DESKTOP_VERSION 1285#ifndef DESKTOP_VERSION
1285 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1286 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1286#endif 1287#endif
1287 return; 1288 return;
1288 } 1289 }
1289 mAlarmTimer->stop(); 1290 mAlarmTimer->stop();
1290} 1291}
1291void CalendarView::selectWeekNum ( int num ) 1292void CalendarView::selectWeekNum ( int num )
1292{ 1293{
1293 dateNavigator()->blockSignals( true ); 1294 dateNavigator()->blockSignals( true );
1294 dateNavigator()->selectWeek( num ); 1295 dateNavigator()->selectWeek( num );
1295 dateNavigator()->blockSignals( false ); 1296 dateNavigator()->blockSignals( false );
1296 mViewManager->showWeekView(); 1297 mViewManager->showWeekView();
1297} 1298}
1298KOViewManager *CalendarView::viewManager() 1299KOViewManager *CalendarView::viewManager()
1299{ 1300{
1300 return mViewManager; 1301 return mViewManager;
1301} 1302}
1302 1303
1303KODialogManager *CalendarView::dialogManager() 1304KODialogManager *CalendarView::dialogManager()
1304{ 1305{
1305 return mDialogManager; 1306 return mDialogManager;
1306} 1307}
1307 1308
1308QDate CalendarView::startDate() 1309QDate CalendarView::startDate()
1309{ 1310{
1310 DateList dates = mNavigator->selectedDates(); 1311 DateList dates = mNavigator->selectedDates();
1311 1312
1312 return dates.first(); 1313 return dates.first();
1313} 1314}
1314 1315
1315QDate CalendarView::endDate() 1316QDate CalendarView::endDate()
1316{ 1317{
1317 DateList dates = mNavigator->selectedDates(); 1318 DateList dates = mNavigator->selectedDates();
1318 1319
1319 return dates.last(); 1320 return dates.last();
1320} 1321}
1321 1322
1322 1323
1323void CalendarView::createPrinter() 1324void CalendarView::createPrinter()
1324{ 1325{
1325#ifndef KORG_NOPRINTER 1326#ifndef KORG_NOPRINTER
1326 if (!mCalPrinter) { 1327 if (!mCalPrinter) {
1327 mCalPrinter = new CalPrinter(this, mCalendar); 1328 mCalPrinter = new CalPrinter(this, mCalendar);
1328 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1329 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1329 } 1330 }
1330#endif 1331#endif
1331} 1332}
1332 1333
1333 1334
1334//KOPrefs::instance()->mWriteBackFile 1335//KOPrefs::instance()->mWriteBackFile
1335//KOPrefs::instance()->mWriteBackExistingOnly 1336//KOPrefs::instance()->mWriteBackExistingOnly
1336 1337
1337// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 1338// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
1338// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 1339// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
1339// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 1340// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
1340// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 1341// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
1341// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 1342// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
1342// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 1343// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
1343 1344
1344int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 1345int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
1345{ 1346{
1346 1347
1347 // 0 equal 1348 // 0 equal
1348 // 1 take local 1349 // 1 take local
1349 // 2 take remote 1350 // 2 take remote
1350 // 3 cancel 1351 // 3 cancel
1351 QDateTime lastSync = mLastCalendarSync; 1352 QDateTime lastSync = mLastCalendarSync;
1352 QDateTime localMod = local->lastModified(); 1353 QDateTime localMod = local->lastModified();
1353 QDateTime remoteMod = remote->lastModified(); 1354 QDateTime remoteMod = remote->lastModified();
1354 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1355 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1355 bool remCh, locCh; 1356 bool remCh, locCh;
1356 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1357 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
1357 //if ( remCh ) 1358 //if ( remCh )
1358 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1359 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
1359 locCh = ( localMod > mLastCalendarSync ); 1360 locCh = ( localMod > mLastCalendarSync );
1360 if ( !remCh && ! locCh ) { 1361 if ( !remCh && ! locCh ) {
1361 //qDebug("both not changed "); 1362 //qDebug("both not changed ");
1362 lastSync = localMod.addDays(1); 1363 lastSync = localMod.addDays(1);
1363 if ( mode <= SYNC_PREF_ASK ) 1364 if ( mode <= SYNC_PREF_ASK )
1364 return 0; 1365 return 0;
1365 } else { 1366 } else {
1366 if ( locCh ) { 1367 if ( locCh ) {
1367 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1368 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1368 lastSync = localMod.addDays( -1 ); 1369 lastSync = localMod.addDays( -1 );
1369 if ( !remCh ) 1370 if ( !remCh )
1370 remoteMod = ( lastSync.addDays( -1 ) ); 1371 remoteMod = ( lastSync.addDays( -1 ) );
1371 } else { 1372 } else {
1372 //qDebug(" not loc changed "); 1373 //qDebug(" not loc changed ");
1373 lastSync = localMod.addDays( 1 ); 1374 lastSync = localMod.addDays( 1 );
1374 if ( remCh ) 1375 if ( remCh )
1375 remoteMod =( lastSync.addDays( 1 ) ); 1376 remoteMod =( lastSync.addDays( 1 ) );
1376 1377
1377 } 1378 }
1378 } 1379 }
1379 full = true; 1380 full = true;
1380 if ( mode < SYNC_PREF_ASK ) 1381 if ( mode < SYNC_PREF_ASK )
1381 mode = SYNC_PREF_ASK; 1382 mode = SYNC_PREF_ASK;
1382 } else { 1383 } else {
1383 if ( localMod == remoteMod ) 1384 if ( localMod == remoteMod )
1384 // if ( local->revision() == remote->revision() ) 1385 // if ( local->revision() == remote->revision() )
1385 return 0; 1386 return 0;
1386 1387
1387 } 1388 }
1388 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1389 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1389 1390
1390 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1391 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1391 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1392 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1392 //full = true; //debug only 1393 //full = true; //debug only
1393 if ( full ) { 1394 if ( full ) {
1394 bool equ = false; 1395 bool equ = false;
1395 if ( local->typeID() == eventID ) { 1396 if ( local->typeID() == eventID ) {
1396 equ = (*((Event*) local) == *((Event*) remote)); 1397 equ = (*((Event*) local) == *((Event*) remote));
1397 } 1398 }
1398 else if ( local->typeID() == todoID ) 1399 else if ( local->typeID() == todoID )
1399 equ = (*((Todo*) local) == (*(Todo*) remote)); 1400 equ = (*((Todo*) local) == (*(Todo*) remote));
1400 else if ( local->typeID() == journalID ) 1401 else if ( local->typeID() == journalID )
1401 equ = (*((Journal*) local) == *((Journal*) remote)); 1402 equ = (*((Journal*) local) == *((Journal*) remote));
1402 if ( equ ) { 1403 if ( equ ) {
1403 //qDebug("equal "); 1404 //qDebug("equal ");
1404 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1405 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1405 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1406 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1406 } 1407 }
1407 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1408 if ( mode < SYNC_PREF_FORCE_LOCAL )
1408 return 0; 1409 return 0;
1409 1410
1410 }//else //debug only 1411 }//else //debug only
1411 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1412 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1412 } 1413 }
1413 int result; 1414 int result;
1414 bool localIsNew; 1415 bool localIsNew;
1415 //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() ); 1416 //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() );
1416 1417
1417 1418
1418 // ************************************************ 1419 // ************************************************
1419 // ************************************************ 1420 // ************************************************
1420 // ************************************************ 1421 // ************************************************
1421 // We may have that lastSync > remoteMod AND lastSync > localMod 1422 // We may have that lastSync > remoteMod AND lastSync > localMod
1422 // BUT remoteMod != localMod 1423 // BUT remoteMod != localMod
1423 1424
1424 1425
1425 if ( full && mode < SYNC_PREF_NEWEST ) 1426 if ( full && mode < SYNC_PREF_NEWEST )
1426 mode = SYNC_PREF_ASK; 1427 mode = SYNC_PREF_ASK;
1427 1428
1428 switch( mode ) { 1429 switch( mode ) {
1429 case SYNC_PREF_LOCAL: 1430 case SYNC_PREF_LOCAL:
1430 if ( lastSync > remoteMod ) 1431 if ( lastSync > remoteMod )
1431 return 1; 1432 return 1;
1432 if ( lastSync > localMod ) 1433 if ( lastSync > localMod )
1433 return 2; 1434 return 2;
1434 return 1; 1435 return 1;
1435 break; 1436 break;
1436 case SYNC_PREF_REMOTE: 1437 case SYNC_PREF_REMOTE:
1437 if ( lastSync > localMod ) 1438 if ( lastSync > localMod )
1438 return 2; 1439 return 2;
1439 if ( lastSync > remoteMod ) 1440 if ( lastSync > remoteMod )
1440 return 1; 1441 return 1;
1441 return 2; 1442 return 2;
1442 break; 1443 break;
1443 case SYNC_PREF_NEWEST: 1444 case SYNC_PREF_NEWEST:
1444 if ( localMod >= remoteMod ) 1445 if ( localMod >= remoteMod )
1445 return 1; 1446 return 1;
1446 else 1447 else
1447 return 2; 1448 return 2;
1448 break; 1449 break;
1449 case SYNC_PREF_ASK: 1450 case SYNC_PREF_ASK:
1450 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1451 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1451 if ( lastSync > remoteMod && lastSync > localMod) 1452 if ( lastSync > remoteMod && lastSync > localMod)
1452 return 0; 1453 return 0;
1453 if ( lastSync > remoteMod ) 1454 if ( lastSync > remoteMod )
1454 return 1; 1455 return 1;
1455 if ( lastSync > localMod ) 1456 if ( lastSync > localMod )
1456 return 2; 1457 return 2;
1457 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1458 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1458 localIsNew = localMod >= remoteMod; 1459 localIsNew = localMod >= remoteMod;
1459 if ( localIsNew ) 1460 if ( localIsNew )
1460 getEventViewerDialog()->setColorMode( 1 ); 1461 getEventViewerDialog()->setColorMode( 1 );
1461 else 1462 else
1462 getEventViewerDialog()->setColorMode( 2 ); 1463 getEventViewerDialog()->setColorMode( 2 );
1463 getEventViewerDialog()->setIncidence(local); 1464 getEventViewerDialog()->setIncidence(local);
1464 if ( localIsNew ) 1465 if ( localIsNew )
1465 getEventViewerDialog()->setColorMode( 2 ); 1466 getEventViewerDialog()->setColorMode( 2 );
1466 else 1467 else
1467 getEventViewerDialog()->setColorMode( 1 ); 1468 getEventViewerDialog()->setColorMode( 1 );
1468 getEventViewerDialog()->addIncidence(remote); 1469 getEventViewerDialog()->addIncidence(remote);
1469 getEventViewerDialog()->setColorMode( 0 ); 1470 getEventViewerDialog()->setColorMode( 0 );
1470 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1471 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1471 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1472 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1472 getEventViewerDialog()->showMe(); 1473 getEventViewerDialog()->showMe();
1473 result = getEventViewerDialog()->executeS( localIsNew ); 1474 result = getEventViewerDialog()->executeS( localIsNew );
1474 return result; 1475 return result;
1475 1476
1476 break; 1477 break;
1477 case SYNC_PREF_FORCE_LOCAL: 1478 case SYNC_PREF_FORCE_LOCAL:
1478 return 1; 1479 return 1;
1479 break; 1480 break;
1480 case SYNC_PREF_FORCE_REMOTE: 1481 case SYNC_PREF_FORCE_REMOTE:
1481 return 2; 1482 return 2;
1482 break; 1483 break;
1483 1484
1484 default: 1485 default:
1485 // SYNC_PREF_TAKE_BOTH not implemented 1486 // SYNC_PREF_TAKE_BOTH not implemented
1486 break; 1487 break;
1487 } 1488 }
1488 return 0; 1489 return 0;
1489} 1490}
1490Event* CalendarView::getLastSyncEvent() 1491Event* CalendarView::getLastSyncEvent()
1491{ 1492{
1492 Event* lse; 1493 Event* lse;
1493 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1494 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1494 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1495 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1495 if (!lse) { 1496 if (!lse) {
1496 lse = new Event(); 1497 lse = new Event();
1497 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1498 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1498 QString sum = ""; 1499 QString sum = "";
1499 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1500 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1500 sum = "E: "; 1501 sum = "E: ";
1501 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1502 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1502 lse->setDtStart( mLastCalendarSync ); 1503 lse->setDtStart( mLastCalendarSync );
1503 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1504 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1504 lse->setCategories( i18n("SyncEvent") ); 1505 lse->setCategories( i18n("SyncEvent") );
1505 lse->setReadOnly( true ); 1506 lse->setReadOnly( true );
1506 mCalendar->addEvent( lse ); 1507 mCalendar->addEvent( lse );
1507 } 1508 }
1508 1509
1509 return lse; 1510 return lse;
1510 1511
1511} 1512}
1512 1513
1513// we check, if the to delete event has a id for a profile 1514// we check, if the to delete event has a id for a profile
1514// if yes, we set this id in the profile to delete 1515// if yes, we set this id in the profile to delete
1515void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1516void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1516{ 1517{
1517 if ( lastSync.count() == 0 ) { 1518 if ( lastSync.count() == 0 ) {
1518 //qDebug(" lastSync.count() == 0"); 1519 //qDebug(" lastSync.count() == 0");
1519 return; 1520 return;
1520 } 1521 }
1521 if ( toDelete->typeID() == journalID ) 1522 if ( toDelete->typeID() == journalID )
1522 return; 1523 return;
1523 1524
1524 Event* eve = lastSync.first(); 1525 Event* eve = lastSync.first();
1525 1526
1526 while ( eve ) { 1527 while ( eve ) {
1527 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1528 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1528 if ( !id.isEmpty() ) { 1529 if ( !id.isEmpty() ) {
1529 QString des = eve->description(); 1530 QString des = eve->description();
1530 QString pref = "e"; 1531 QString pref = "e";
1531 if ( toDelete->typeID() == todoID ) 1532 if ( toDelete->typeID() == todoID )
1532 pref = "t"; 1533 pref = "t";
1533 des += pref+ id + ","; 1534 des += pref+ id + ",";
1534 eve->setReadOnly( false ); 1535 eve->setReadOnly( false );
1535 eve->setDescription( des ); 1536 eve->setDescription( des );
1536 //qDebug("setdes %s ", des.latin1()); 1537 //qDebug("setdes %s ", des.latin1());
1537 eve->setReadOnly( true ); 1538 eve->setReadOnly( true );
1538 } 1539 }
1539 eve = lastSync.next(); 1540 eve = lastSync.next();
1540 } 1541 }
1541 1542
1542} 1543}
1543void CalendarView::checkExternalId( Incidence * inc ) 1544void CalendarView::checkExternalId( Incidence * inc )
1544{ 1545{
1545 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1546 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1546 checkExternSyncEvent( lastSync, inc ); 1547 checkExternSyncEvent( lastSync, inc );
1547 1548
1548} 1549}
1549bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1550bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1550{ 1551{
1551 bool syncOK = true; 1552 bool syncOK = true;
1552 int addedEvent = 0; 1553 int addedEvent = 0;
1553 int addedEventR = 0; 1554 int addedEventR = 0;
1554 int deletedEventR = 0; 1555 int deletedEventR = 0;
1555 int deletedEventL = 0; 1556 int deletedEventL = 0;
1556 int changedLocal = 0; 1557 int changedLocal = 0;
1557 int changedRemote = 0; 1558 int changedRemote = 0;
1558 int filteredIN = 0; 1559 int filteredIN = 0;
1559 int filteredOUT = 0; 1560 int filteredOUT = 0;
1560 //QPtrList<Event> el = local->rawEvents(); 1561 //QPtrList<Event> el = local->rawEvents();
1561 Event* eventR; 1562 Event* eventR;
1562 QString uid; 1563 QString uid;
1563 int take; 1564 int take;
1564 Event* eventRSync; 1565 Event* eventRSync;
1565 Event* eventLSync; 1566 Event* eventLSync;
1566 clearAllViews(); 1567 clearAllViews();
1567 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1568 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1568 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1569 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1569 bool fullDateRange = false; 1570 bool fullDateRange = false;
1570 local->resetTempSyncStat(); 1571 local->resetTempSyncStat();
1571 mLastCalendarSync = QDateTime::currentDateTime(); 1572 mLastCalendarSync = QDateTime::currentDateTime();
1572 if ( mSyncManager->syncWithDesktop() ) { 1573 if ( mSyncManager->syncWithDesktop() ) {
1573 remote->resetPilotStat(1); 1574 remote->resetPilotStat(1);
1574 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1575 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1575 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1576 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1576 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1577 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1577 } else { 1578 } else {
1578 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1579 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1579 } 1580 }
1580 } 1581 }
1581 QDateTime modifiedCalendar = mLastCalendarSync; 1582 QDateTime modifiedCalendar = mLastCalendarSync;
1582 eventLSync = getLastSyncEvent(); 1583 eventLSync = getLastSyncEvent();
1583 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1584 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1584 if ( eventR ) { 1585 if ( eventR ) {
1585 qDebug("last-syncEvent on remote found "); 1586 qDebug("last-syncEvent on remote found ");
1586 eventRSync = (Event*) eventR->clone(); 1587 eventRSync = (Event*) eventR->clone();
1587 remote->deleteEvent(eventR ); 1588 remote->deleteEvent(eventR );
1588 1589
1589 } else { 1590 } else {
1590 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1591 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1591 eventRSync = (Event*)eventLSync->clone(); 1592 eventRSync = (Event*)eventLSync->clone();
1592 } else { 1593 } else {
1593 fullDateRange = true; 1594 fullDateRange = true;
1594 eventRSync = new Event(); 1595 eventRSync = new Event();
1595 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1596 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1596 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1597 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1597 eventRSync->setDtStart( mLastCalendarSync ); 1598 eventRSync->setDtStart( mLastCalendarSync );
1598 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1599 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1599 eventRSync->setCategories( i18n("SyncEvent") ); 1600 eventRSync->setCategories( i18n("SyncEvent") );
1600 } 1601 }
1601 } 1602 }
1602 if ( eventLSync->dtStart() == mLastCalendarSync ) 1603 if ( eventLSync->dtStart() == mLastCalendarSync )
1603 fullDateRange = true; 1604 fullDateRange = true;
1604 1605
1605 if ( ! fullDateRange ) { 1606 if ( ! fullDateRange ) {
1606 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1607 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1607 1608
1608 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1609 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1609 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1610 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1610 fullDateRange = true; 1611 fullDateRange = true;
1611 } 1612 }
1612 } 1613 }
1613 if ( mSyncManager->syncWithDesktop() ) { 1614 if ( mSyncManager->syncWithDesktop() ) {
1614 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1615 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1615 } 1616 }
1616 if ( fullDateRange ) 1617 if ( fullDateRange )
1617 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1618 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1618 else 1619 else
1619 mLastCalendarSync = eventLSync->dtStart(); 1620 mLastCalendarSync = eventLSync->dtStart();
1620 // for resyncing if own file has changed 1621 // for resyncing if own file has changed
1621 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1622 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1622 mLastCalendarSync = loadedFileVersion; 1623 mLastCalendarSync = loadedFileVersion;
1623 //qDebug("setting mLastCalendarSync "); 1624 //qDebug("setting mLastCalendarSync ");
1624 } 1625 }
1625 //qDebug("*************************** "); 1626 //qDebug("*************************** ");
1626 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1627 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1627 QPtrList<Incidence> er = remote->rawIncidences(); 1628 QPtrList<Incidence> er = remote->rawIncidences();
1628 Incidence* inR = er.first(); 1629 Incidence* inR = er.first();
1629 Incidence* inL; 1630 Incidence* inL;
1630 QProgressBar bar( er.count(),0 ); 1631 QProgressBar bar( er.count(),0 );
1631 bar.setCaption (i18n("Syncing - close to abort!") ); 1632 bar.setCaption (i18n("Syncing - close to abort!") );
1632 1633
1633 // ************** setting up filter ************* 1634 // ************** setting up filter *************
1634 CalFilter *filterIN = 0; 1635 CalFilter *filterIN = 0;
1635 CalFilter *filterOUT = 0; 1636 CalFilter *filterOUT = 0;
1636 CalFilter *filter = mFilters.first(); 1637 CalFilter *filter = mFilters.first();
1637 while(filter) { 1638 while(filter) {
1638 if ( filter->name() == mSyncManager->mFilterInCal ) 1639 if ( filter->name() == mSyncManager->mFilterInCal )
1639 filterIN = filter; 1640 filterIN = filter;
1640 if ( filter->name() == mSyncManager->mFilterOutCal ) 1641 if ( filter->name() == mSyncManager->mFilterOutCal )
1641 filterOUT = filter; 1642 filterOUT = filter;
1642 filter = mFilters.next(); 1643 filter = mFilters.next();
1643 } 1644 }
1644 int w = 300; 1645 int w = 300;
1645 if ( QApplication::desktop()->width() < 320 ) 1646 if ( QApplication::desktop()->width() < 320 )
1646 w = 220; 1647 w = 220;
1647 int h = bar.sizeHint().height() ; 1648 int h = bar.sizeHint().height() ;
1648 int dw = QApplication::desktop()->width(); 1649 int dw = QApplication::desktop()->width();
1649 int dh = QApplication::desktop()->height(); 1650 int dh = QApplication::desktop()->height();
1650 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1651 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1651 bar.show(); 1652 bar.show();
1652 int modulo = (er.count()/10)+1; 1653 int modulo = (er.count()/10)+1;
1653 int incCounter = 0; 1654 int incCounter = 0;
1654 while ( inR ) { 1655 while ( inR ) {
1655 if ( ! bar.isVisible() ) 1656 if ( ! bar.isVisible() )
1656 return false; 1657 return false;
1657 if ( incCounter % modulo == 0 ) 1658 if ( incCounter % modulo == 0 )
1658 bar.setProgress( incCounter ); 1659 bar.setProgress( incCounter );
1659 ++incCounter; 1660 ++incCounter;
1660 uid = inR->uid(); 1661 uid = inR->uid();
1661 bool skipIncidence = false; 1662 bool skipIncidence = false;
1662 if ( uid.left(15) == QString("last-syncEvent-") ) 1663 if ( uid.left(15) == QString("last-syncEvent-") )
1663 skipIncidence = true; 1664 skipIncidence = true;
1664 QString idS; 1665 QString idS;
1665 qApp->processEvents(); 1666 qApp->processEvents();
1666 if ( !skipIncidence ) { 1667 if ( !skipIncidence ) {
1667 inL = local->incidenceForUid( uid , false ); 1668 inL = local->incidenceForUid( uid , false );
1668 if ( inL ) { // maybe conflict - same uid in both calendars 1669 if ( inL ) { // maybe conflict - same uid in both calendars
1669 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1670 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1670 //qDebug("take %d %s ", take, inL->summary().latin1()); 1671 //qDebug("take %d %s ", take, inL->summary().latin1());
1671 if ( take == 3 ) 1672 if ( take == 3 )
1672 return false; 1673 return false;
1673 if ( take == 1 ) {// take local ********************** 1674 if ( take == 1 ) {// take local **********************
1674 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1675 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1675 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1676 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1676 else 1677 else
1677 idS = inR->IDStr(); 1678 idS = inR->IDStr();
1678 int calID = inR->calID(); 1679 int calID = inR->calID();
1679 remote->deleteIncidence( inR ); 1680 remote->deleteIncidence( inR );
1680 inR = inL->clone(); 1681 inR = inL->clone();
1681 inR->setCalID( calID ); 1682 inR->setCalID( calID );
1682 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1683 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1683 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1684 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1684 inR->setIDStr( idS ); 1685 inR->setIDStr( idS );
1685 remote->addIncidence( inR ); 1686 remote->addIncidence( inR );
1686 if ( mSyncManager->syncWithDesktop() ) 1687 if ( mSyncManager->syncWithDesktop() )
1687 inR->setPilotId( 2 ); 1688 inR->setPilotId( 2 );
1688 ++changedRemote; 1689 ++changedRemote;
1689 } else {// take remote ********************** 1690 } else {// take remote **********************
1690 if ( !inL->isReadOnly() ) { 1691 if ( !inL->isReadOnly() ) {
1691 idS = inL->IDStr(); 1692 idS = inL->IDStr();
1692 int pid = inL->pilotId(); 1693 int pid = inL->pilotId();
1693 int calID = inL->calID(); 1694 int calID = inL->calID();
1694 local->deleteIncidence( inL ); 1695 local->deleteIncidence( inL );
1695 inL = inR->clone(); 1696 inL = inR->clone();
1696 inL->setCalID( calID ); 1697 inL->setCalID( calID );
1697 if ( mSyncManager->syncWithDesktop() ) 1698 if ( mSyncManager->syncWithDesktop() )
1698 inL->setPilotId( pid ); 1699 inL->setPilotId( pid );
1699 inL->setIDStr( idS ); 1700 inL->setIDStr( idS );
1700 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1701 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1701 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1702 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1702 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1703 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1703 } 1704 }
1704 local->addIncidence( inL ); 1705 local->addIncidence( inL );
1705 ++changedLocal; 1706 ++changedLocal;
1706 } 1707 }
1707 } 1708 }
1708 } 1709 }
1709 } else { // no conflict ********** add or delete remote 1710 } else { // no conflict ********** add or delete remote
1710 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1711 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1711 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1712 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1712 QString des = eventLSync->description(); 1713 QString des = eventLSync->description();
1713 QString pref = "e"; 1714 QString pref = "e";
1714 if ( inR->typeID() == todoID ) 1715 if ( inR->typeID() == todoID )
1715 pref = "t"; 1716 pref = "t";
1716 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1717 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1717 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1718 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1718 //remote->deleteIncidence( inR ); 1719 //remote->deleteIncidence( inR );
1719 ++deletedEventR; 1720 ++deletedEventR;
1720 } else { 1721 } else {
1721 inR->setLastModified( modifiedCalendar ); 1722 inR->setLastModified( modifiedCalendar );
1722 inL = inR->clone(); 1723 inL = inR->clone();
1723 inL->setIDStr( ":" ); 1724 inL->setIDStr( ":" );
1724 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1725 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1725 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1726 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1726 1727
1727 inL->setCalID( 0 );// add to default cal 1728 inL->setCalID( 0 );// add to default cal
1728 local->addIncidence( inL ); 1729 local->addIncidence( inL );
1729 ++addedEvent; 1730 ++addedEvent;
1730 1731
1731 } 1732 }
1732 } else { 1733 } else {
1733 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1734 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1734 inR->setLastModified( modifiedCalendar ); 1735 inR->setLastModified( modifiedCalendar );
1735 inL = inR->clone(); 1736 inL = inR->clone();
1736 inL->setIDStr( ":" ); 1737 inL->setIDStr( ":" );
1737 inL->setCalID( 0 );// add to default cal 1738 inL->setCalID( 0 );// add to default cal
1738 local->addIncidence( inL ); 1739 local->addIncidence( inL );
1739 ++addedEvent; 1740 ++addedEvent;
1740 1741
1741 } else { 1742 } else {
1742 checkExternSyncEvent(eventRSyncSharp, inR); 1743 checkExternSyncEvent(eventRSyncSharp, inR);
1743 remote->deleteIncidence( inR ); 1744 remote->deleteIncidence( inR );
1744 ++deletedEventR; 1745 ++deletedEventR;
1745 } 1746 }
1746 } 1747 }
1747 } else { 1748 } else {
1748 ++filteredIN; 1749 ++filteredIN;
1749 } 1750 }
1750 } 1751 }
1751 } 1752 }
1752 inR = er.next(); 1753 inR = er.next();
1753 } 1754 }
1754 QPtrList<Incidence> el = local->rawIncidences(); 1755 QPtrList<Incidence> el = local->rawIncidences();
1755 inL = el.first(); 1756 inL = el.first();
1756 modulo = (el.count()/10)+1; 1757 modulo = (el.count()/10)+1;
1757 bar.setCaption (i18n("Add / remove events") ); 1758 bar.setCaption (i18n("Add / remove events") );
1758 bar.setTotalSteps ( el.count() ) ; 1759 bar.setTotalSteps ( el.count() ) ;
1759 bar.show(); 1760 bar.show();
1760 incCounter = 0; 1761 incCounter = 0;
1761 1762
1762 while ( inL ) { 1763 while ( inL ) {
1763 1764
1764 qApp->processEvents(); 1765 qApp->processEvents();
1765 if ( ! bar.isVisible() ) 1766 if ( ! bar.isVisible() )
1766 return false; 1767 return false;
1767 if ( incCounter % modulo == 0 ) 1768 if ( incCounter % modulo == 0 )
1768 bar.setProgress( incCounter ); 1769 bar.setProgress( incCounter );
1769 ++incCounter; 1770 ++incCounter;
1770 uid = inL->uid(); 1771 uid = inL->uid();
1771 bool skipIncidence = false; 1772 bool skipIncidence = false;
1772 if ( uid.left(15) == QString("last-syncEvent-") ) 1773 if ( uid.left(15) == QString("last-syncEvent-") )
1773 skipIncidence = true; 1774 skipIncidence = true;
1774 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1775 skipIncidence = true; 1776 skipIncidence = true;
1776 if ( !skipIncidence ) { 1777 if ( !skipIncidence ) {
1777 inR = remote->incidenceForUid( uid , true ); 1778 inR = remote->incidenceForUid( uid , true );
1778 if ( ! inR ) { 1779 if ( ! inR ) {
1779 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1780 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1780 // no conflict ********** add or delete local 1781 // no conflict ********** add or delete local
1781 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1782 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1782 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1783 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1783 checkExternSyncEvent(eventLSyncSharp, inL); 1784 checkExternSyncEvent(eventLSyncSharp, inL);
1784 local->deleteIncidence( inL ); 1785 local->deleteIncidence( inL );
1785 ++deletedEventL; 1786 ++deletedEventL;
1786 } else { 1787 } else {
1787 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1788 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1788 inL->removeID(mCurrentSyncDevice ); 1789 inL->removeID(mCurrentSyncDevice );
1789 ++addedEventR; 1790 ++addedEventR;
1790 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1791 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1791 inL->setLastModified( modifiedCalendar ); 1792 inL->setLastModified( modifiedCalendar );
1792 inR = inL->clone(); 1793 inR = inL->clone();
1793 inR->setIDStr( ":" ); 1794 inR->setIDStr( ":" );
1794 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1795 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1795 inR->setCalID( 0 );// add to default cal 1796 inR->setCalID( 0 );// add to default cal
1796 remote->addIncidence( inR ); 1797 remote->addIncidence( inR );
1797 } 1798 }
1798 } 1799 }
1799 } else { 1800 } else {
1800 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1801 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1801 checkExternSyncEvent(eventLSyncSharp, inL); 1802 checkExternSyncEvent(eventLSyncSharp, inL);
1802 local->deleteIncidence( inL ); 1803 local->deleteIncidence( inL );
1803 ++deletedEventL; 1804 ++deletedEventL;
1804 } else { 1805 } else {
1805 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1806 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1806 ++addedEventR; 1807 ++addedEventR;
1807 inL->setLastModified( modifiedCalendar ); 1808 inL->setLastModified( modifiedCalendar );
1808 inR = inL->clone(); 1809 inR = inL->clone();
1809 inR->setIDStr( ":" ); 1810 inR->setIDStr( ":" );
1810 inR->setCalID( 0 );// add to default cal 1811 inR->setCalID( 0 );// add to default cal
1811 remote->addIncidence( inR ); 1812 remote->addIncidence( inR );
1812 } 1813 }
1813 } 1814 }
1814 } 1815 }
1815 } else { 1816 } else {
1816 ++filteredOUT; 1817 ++filteredOUT;
1817 } 1818 }
1818 } 1819 }
1819 } 1820 }
1820 inL = el.next(); 1821 inL = el.next();
1821 } 1822 }
1822 int delFut = 0; 1823 int delFut = 0;
1823 int remRem = 0; 1824 int remRem = 0;
1824 if ( mSyncManager->mWriteBackInFuture ) { 1825 if ( mSyncManager->mWriteBackInFuture ) {
1825 er = remote->rawIncidences(); 1826 er = remote->rawIncidences();
1826 remRem = er.count(); 1827 remRem = er.count();
1827 inR = er.first(); 1828 inR = er.first();
1828 QDateTime dt; 1829 QDateTime dt;
1829 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1830 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1830 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1831 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1831 while ( inR ) { 1832 while ( inR ) {
1832 if ( inR->typeID() == todoID ) { 1833 if ( inR->typeID() == todoID ) {
1833 Todo * t = (Todo*)inR; 1834 Todo * t = (Todo*)inR;
1834 if ( t->hasDueDate() ) 1835 if ( t->hasDueDate() )
1835 dt = t->dtDue(); 1836 dt = t->dtDue();
1836 else 1837 else
1837 dt = cur.addSecs( 62 ); 1838 dt = cur.addSecs( 62 );
1838 } 1839 }
1839 else if (inR->typeID() == eventID ) { 1840 else if (inR->typeID() == eventID ) {
1840 bool ok; 1841 bool ok;
1841 dt = inR->getNextOccurence( cur, &ok ); 1842 dt = inR->getNextOccurence( cur, &ok );
1842 if ( !ok ) 1843 if ( !ok )
1843 dt = cur.addSecs( -62 ); 1844 dt = cur.addSecs( -62 );
1844 } 1845 }
1845 else 1846 else
1846 dt = inR->dtStart(); 1847 dt = inR->dtStart();
1847 if ( dt < cur || dt > end ) { 1848 if ( dt < cur || dt > end ) {
1848 remote->deleteIncidence( inR ); 1849 remote->deleteIncidence( inR );
1849 ++delFut; 1850 ++delFut;
1850 } 1851 }
1851 inR = er.next(); 1852 inR = er.next();
1852 } 1853 }
1853 } 1854 }
1854 bar.hide(); 1855 bar.hide();
1855 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1856 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1856 eventLSync->setReadOnly( false ); 1857 eventLSync->setReadOnly( false );
1857 eventLSync->setDtStart( mLastCalendarSync ); 1858 eventLSync->setDtStart( mLastCalendarSync );
1858 eventRSync->setDtStart( mLastCalendarSync ); 1859 eventRSync->setDtStart( mLastCalendarSync );
1859 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1860 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1860 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1861 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1861 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1862 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1862 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1863 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1863 eventLSync->setReadOnly( true ); 1864 eventLSync->setReadOnly( true );
1864 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1865 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1865 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1866 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1866 remote->addEvent( eventRSync ); 1867 remote->addEvent( eventRSync );
1867 else 1868 else
1868 delete eventRSync; 1869 delete eventRSync;
1869 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1870 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1870 QString mes; 1871 QString mes;
1871 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1872 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1872 QString delmess; 1873 QString delmess;
1873 if ( delFut ) { 1874 if ( delFut ) {
1874 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1875 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1875 mes += delmess; 1876 mes += delmess;
1876 } 1877 }
1877 mes = i18n("Local calendar changed!\n") +mes; 1878 mes = i18n("Local calendar changed!\n") +mes;
1878 mCalendar->checkAlarmForIncidence( 0, true ); 1879 mCalendar->checkAlarmForIncidence( 0, true );
1879 qDebug( mes ); 1880 qDebug( mes );
1880 if ( mSyncManager->mShowSyncSummary ) { 1881 if ( mSyncManager->mShowSyncSummary ) {
1881 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1882 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1882 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1883 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1883 qDebug("KO: WB cancelled "); 1884 qDebug("KO: WB cancelled ");
1884 mSyncManager->mWriteBackFile = false; 1885 mSyncManager->mWriteBackFile = false;
1885 return syncOK; 1886 return syncOK;
1886 } 1887 }
1887 } 1888 }
1888 return syncOK; 1889 return syncOK;
1889} 1890}
1890 1891
1891void CalendarView::setSyncDevice( QString s ) 1892void CalendarView::setSyncDevice( QString s )
1892{ 1893{
1893 mCurrentSyncDevice= s; 1894 mCurrentSyncDevice= s;
1894} 1895}
1895void CalendarView::setSyncName( QString s ) 1896void CalendarView::setSyncName( QString s )
1896{ 1897{
1897 mCurrentSyncName= s; 1898 mCurrentSyncName= s;
1898} 1899}
1899bool CalendarView::syncCalendar(QString filename, int mode) 1900bool CalendarView::syncCalendar(QString filename, int mode)
1900{ 1901{
1901 //qDebug("syncCalendar %s ", filename.latin1()); 1902 //qDebug("syncCalendar %s ", filename.latin1());
1902 mGlobalSyncMode = SYNC_MODE_NORMAL; 1903 mGlobalSyncMode = SYNC_MODE_NORMAL;
1903 CalendarLocal* calendar = new CalendarLocal(); 1904 CalendarLocal* calendar = new CalendarLocal();
1904 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1905 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1905 FileStorage* storage = new FileStorage( calendar ); 1906 FileStorage* storage = new FileStorage( calendar );
1906 bool syncOK = false; 1907 bool syncOK = false;
1907 storage->setFileName( filename ); 1908 storage->setFileName( filename );
1908 // qDebug("loading ... "); 1909 // qDebug("loading ... ");
1909 if ( storage->load() ) { 1910 if ( storage->load() ) {
1910 getEventViewerDialog()->setSyncMode( true ); 1911 getEventViewerDialog()->setSyncMode( true );
1911 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1912 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1912 getEventViewerDialog()->setSyncMode( false ); 1913 getEventViewerDialog()->setSyncMode( false );
1913 if ( syncOK ) { 1914 if ( syncOK ) {
1914 if ( mSyncManager->mWriteBackFile ) 1915 if ( mSyncManager->mWriteBackFile )
1915 { 1916 {
1916 storage->setSaveFormat( new ICalFormat() ); 1917 storage->setSaveFormat( new ICalFormat() );
1917 storage->save(); 1918 storage->save();
1918 } 1919 }
1919 } 1920 }
1920 setModified( true ); 1921 setModified( true );
1921 } 1922 }
1922 delete storage; 1923 delete storage;
1923 delete calendar; 1924 delete calendar;
1924 if ( syncOK ) 1925 if ( syncOK )
1925 updateView(); 1926 updateView();
1926 return syncOK; 1927 return syncOK;
1927} 1928}
1928 1929
1929void CalendarView::syncExternal( int mode ) 1930void CalendarView::syncExternal( int mode )
1930{ 1931{
1931 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1932 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1932 1933
1933 qApp->processEvents(); 1934 qApp->processEvents();
1934 CalendarLocal* calendar = new CalendarLocal(); 1935 CalendarLocal* calendar = new CalendarLocal();
1935 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1936 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1936 bool syncOK = false; 1937 bool syncOK = false;
1937 bool loadSuccess = false; 1938 bool loadSuccess = false;
1938 PhoneFormat* phoneFormat = 0; 1939 PhoneFormat* phoneFormat = 0;
1939 emit tempDisableBR(true); 1940 emit tempDisableBR(true);
1940#ifndef DESKTOP_VERSION 1941#ifndef DESKTOP_VERSION
1941 SharpFormat* sharpFormat = 0; 1942 SharpFormat* sharpFormat = 0;
1942 if ( mode == 0 ) { // sharp 1943 if ( mode == 0 ) { // sharp
1943 sharpFormat = new SharpFormat () ; 1944 sharpFormat = new SharpFormat () ;
1944 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1945 loadSuccess = sharpFormat->load( calendar, mCalendar );
1945 1946
1946 } else 1947 } else
1947#endif 1948#endif
1948 if ( mode == 1 ) { // phone 1949 if ( mode == 1 ) { // phone
1949 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1950 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1950 mSyncManager->mPhoneDevice, 1951 mSyncManager->mPhoneDevice,
1951 mSyncManager->mPhoneConnection, 1952 mSyncManager->mPhoneConnection,
1952 mSyncManager->mPhoneModel); 1953 mSyncManager->mPhoneModel);
1953 loadSuccess = phoneFormat->load( calendar,mCalendar); 1954 loadSuccess = phoneFormat->load( calendar,mCalendar);
1954 1955
1955 } else { 1956 } else {
1956 emit tempDisableBR(false); 1957 emit tempDisableBR(false);
1957 return; 1958 return;
1958 } 1959 }
1959 if ( loadSuccess ) { 1960 if ( loadSuccess ) {
1960 getEventViewerDialog()->setSyncMode( true ); 1961 getEventViewerDialog()->setSyncMode( true );
1961 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1962 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1962 getEventViewerDialog()->setSyncMode( false ); 1963 getEventViewerDialog()->setSyncMode( false );
1963 qApp->processEvents(); 1964 qApp->processEvents();
1964 if ( syncOK ) { 1965 if ( syncOK ) {
1965 if ( mSyncManager->mWriteBackFile ) 1966 if ( mSyncManager->mWriteBackFile )
1966 { 1967 {
1967 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1968 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1968 Incidence* inc = iL.first(); 1969 Incidence* inc = iL.first();
1969 if ( phoneFormat ) { 1970 if ( phoneFormat ) {
1970 while ( inc ) { 1971 while ( inc ) {
1971 inc->removeID(mCurrentSyncDevice); 1972 inc->removeID(mCurrentSyncDevice);
1972 inc = iL.next(); 1973 inc = iL.next();
1973 } 1974 }
1974 } 1975 }
1975#ifndef DESKTOP_VERSION 1976#ifndef DESKTOP_VERSION
1976 if ( sharpFormat ) 1977 if ( sharpFormat )
1977 sharpFormat->save(calendar); 1978 sharpFormat->save(calendar);
1978#endif 1979#endif
1979 if ( phoneFormat ) 1980 if ( phoneFormat )
1980 phoneFormat->save(calendar); 1981 phoneFormat->save(calendar);
1981 iL = calendar->rawIncidences(); 1982 iL = calendar->rawIncidences();
1982 inc = iL.first(); 1983 inc = iL.first();
1983 Incidence* loc; 1984 Incidence* loc;
1984 while ( inc ) { 1985 while ( inc ) {
1985 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1986 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1986 loc = mCalendar->incidence(inc->uid() ); 1987 loc = mCalendar->incidence(inc->uid() );
1987 if ( loc ) { 1988 if ( loc ) {
1988 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1989 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1989 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1990 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1990 } 1991 }
1991 } 1992 }
1992 inc = iL.next(); 1993 inc = iL.next();
1993 } 1994 }
1994 Incidence* lse = getLastSyncEvent(); 1995 Incidence* lse = getLastSyncEvent();
1995 if ( lse ) { 1996 if ( lse ) {
1996 lse->setReadOnly( false ); 1997 lse->setReadOnly( false );
1997 lse->setDescription( "" ); 1998 lse->setDescription( "" );
1998 lse->setReadOnly( true ); 1999 lse->setReadOnly( true );
1999 } 2000 }
2000 } 2001 }
2001 } else { 2002 } else {
2002 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 2003 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
2003 } 2004 }
2004 setModified( true ); 2005 setModified( true );
2005 } else { 2006 } else {
2006 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 2007 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
2007 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 2008 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
2008 question, i18n("Ok")) ; 2009 question, i18n("Ok")) ;
2009 2010
2010 } 2011 }
2011 delete calendar; 2012 delete calendar;
2012 updateView(); 2013 updateView();
2013 emit tempDisableBR(false); 2014 emit tempDisableBR(false);
2014 return ;//syncOK; 2015 return ;//syncOK;
2015 2016
2016} 2017}
2017 2018
2018bool CalendarView::importBday() 2019bool CalendarView::importBday()
2019{ 2020{
2020#ifndef KORG_NOKABC 2021#ifndef KORG_NOKABC
2021 2022
2022#ifdef DESKTOP_VERSION 2023#ifdef DESKTOP_VERSION
2023 int curCal = mCalendar->defaultCalendar(); 2024 int curCal = mCalendar->defaultCalendar();
2024 int bd = mCalEditView->getBirtdayID(); 2025 int bd = mCalEditView->getBirtdayID();
2025 if ( bd == 0 ) 2026 if ( bd == 0 )
2026 return false; 2027 return false;
2027 mCalendar->setDefaultCalendar( bd ); 2028 mCalendar->setDefaultCalendar( bd );
2028 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 2029 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
2029 KABC::AddressBook::Iterator it; 2030 KABC::AddressBook::Iterator it;
2030 int count = 0; 2031 int count = 0;
2031 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2032 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2032 ++count; 2033 ++count;
2033 } 2034 }
2034 QProgressBar bar(count,0 ); 2035 QProgressBar bar(count,0 );
2035 int w = 300; 2036 int w = 300;
2036 if ( QApplication::desktop()->width() < 320 ) 2037 if ( QApplication::desktop()->width() < 320 )
2037 w = 220; 2038 w = 220;
2038 int h = bar.sizeHint().height() ; 2039 int h = bar.sizeHint().height() ;
2039 int dw = QApplication::desktop()->width(); 2040 int dw = QApplication::desktop()->width();
2040 int dh = QApplication::desktop()->height(); 2041 int dh = QApplication::desktop()->height();
2041 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2042 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2042 bar.show(); 2043 bar.show();
2043 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 2044 bar.setCaption (i18n("Reading addressbook - close to abort!") );
2044 qApp->processEvents(); 2045 qApp->processEvents();
2045 count = 0; 2046 count = 0;
2046 int addCount = 0; 2047 int addCount = 0;
2047 KCal::Attendee* a = 0; 2048 KCal::Attendee* a = 0;
2048 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2049 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2049 if ( ! bar.isVisible() ) 2050 if ( ! bar.isVisible() )
2050 return false; 2051 return false;
2051 bar.setProgress( count++ ); 2052 bar.setProgress( count++ );
2052 qApp->processEvents(); 2053 qApp->processEvents();
2053 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 2054 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
2054 if ( (*it).birthday().date().isValid() ){ 2055 if ( (*it).birthday().date().isValid() ){
2055 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2056 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2056 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 2057 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
2057 ++addCount; 2058 ++addCount;
2058 } 2059 }
2059 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 2060 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
2060 if ( anni.isValid() ){ 2061 if ( anni.isValid() ){
2061 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2062 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2062 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 2063 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
2063 ++addCount; 2064 ++addCount;
2064 } 2065 }
2065 } 2066 }
2066 mCalendar->setDefaultCalendar( curCal ); 2067 mCalendar->setDefaultCalendar( curCal );
2067 updateView(); 2068 updateView();
2068 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2069 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2069#else //DESKTOP_VERSION 2070#else //DESKTOP_VERSION
2070 2071
2071 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 2072 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
2072 // the result should now arrive through method insertBirthdays 2073 // the result should now arrive through method insertBirthdays
2073 2074
2074#endif //DESKTOP_VERSION 2075#endif //DESKTOP_VERSION
2075 2076
2076#endif //KORG_NOKABC 2077#endif //KORG_NOKABC
2077 2078
2078 2079
2079 return true; 2080 return true;
2080} 2081}
2081 2082
2082// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 2083// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
2083void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 2084void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
2084 const QStringList& anniversaryList, const QStringList& realNameList, 2085 const QStringList& anniversaryList, const QStringList& realNameList,
2085 const QStringList& emailList, const QStringList& assembledNameList, 2086 const QStringList& emailList, const QStringList& assembledNameList,
2086 const QStringList& uidList) 2087 const QStringList& uidList)
2087{ 2088{
2088 2089
2089 //qDebug("KO::CalendarView::insertBirthdays"); 2090 //qDebug("KO::CalendarView::insertBirthdays");
2090 if (uid == this->name()) 2091 if (uid == this->name())
2091 { 2092 {
2092 int curCal = mCalendar->defaultCalendar(); 2093 int curCal = mCalendar->defaultCalendar();
2093 int bd = mCalEditView->getBirtdayID(); 2094 int bd = mCalEditView->getBirtdayID();
2094 if ( bd == 0 ) 2095 if ( bd == 0 )
2095 return; 2096 return;
2096 mCalendar->setDefaultCalendar( bd ); 2097 mCalendar->setDefaultCalendar( bd );
2097 2098
2098 2099
2099 int count = birthdayList.count(); 2100 int count = birthdayList.count();
2100 int addCount = 0; 2101 int addCount = 0;
2101 KCal::Attendee* a = 0; 2102 KCal::Attendee* a = 0;
2102 2103
2103 //qDebug("CalView 1 %i", count); 2104 //qDebug("CalView 1 %i", count);
2104 2105
2105 QProgressBar bar(count,0 ); 2106 QProgressBar bar(count,0 );
2106 int w = 300; 2107 int w = 300;
2107 if ( QApplication::desktop()->width() < 320 ) 2108 if ( QApplication::desktop()->width() < 320 )
2108 w = 220; 2109 w = 220;
2109 int h = bar.sizeHint().height() ; 2110 int h = bar.sizeHint().height() ;
2110 int dw = QApplication::desktop()->width(); 2111 int dw = QApplication::desktop()->width();
2111 int dh = QApplication::desktop()->height(); 2112 int dh = QApplication::desktop()->height();
2112 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2113 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2113 bar.show(); 2114 bar.show();
2114 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 2115 bar.setCaption (i18n("inserting birthdays - close to abort!") );
2115 qApp->processEvents(); 2116 qApp->processEvents();
2116 2117
2117 QDate birthday; 2118 QDate birthday;
2118 QDate anniversary; 2119 QDate anniversary;
2119 QString realName; 2120 QString realName;
2120 QString email; 2121 QString email;
2121 QString assembledName; 2122 QString assembledName;
2122 QString uid; 2123 QString uid;
2123 bool ok = true; 2124 bool ok = true;
2124 for ( int i = 0; i < count; i++) 2125 for ( int i = 0; i < count; i++)
2125 { 2126 {
2126 if ( ! bar.isVisible() ) 2127 if ( ! bar.isVisible() )
2127 return; 2128 return;
2128 bar.setProgress( i ); 2129 bar.setProgress( i );
2129 qApp->processEvents(); 2130 qApp->processEvents();
2130 2131
2131 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 2132 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
2132 if (!ok) { 2133 if (!ok) {
2133 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 2134 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
2134 } 2135 }
2135 2136
2136 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 2137 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
2137 if (!ok) { 2138 if (!ok) {
2138 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 2139 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
2139 } 2140 }
2140 realName = realNameList[i]; 2141 realName = realNameList[i];
2141 email = emailList[i]; 2142 email = emailList[i];
2142 assembledName = assembledNameList[i]; 2143 assembledName = assembledNameList[i];
2143 uid = uidList[i]; 2144 uid = uidList[i];
2144 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 2145 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
2145 2146
2146 if ( birthday.isValid() ){ 2147 if ( birthday.isValid() ){
2147 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2148 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2148 KCal::Attendee::ReqParticipant,uid) ; 2149 KCal::Attendee::ReqParticipant,uid) ;
2149 if ( addAnniversary( birthday, assembledName, a, true ) ) 2150 if ( addAnniversary( birthday, assembledName, a, true ) )
2150 ++addCount; 2151 ++addCount;
2151 } 2152 }
2152 2153
2153 if ( anniversary.isValid() ){ 2154 if ( anniversary.isValid() ){
2154 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2155 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2155 KCal::Attendee::ReqParticipant,uid) ; 2156 KCal::Attendee::ReqParticipant,uid) ;
2156 if ( addAnniversary( anniversary, assembledName, a, false ) ) 2157 if ( addAnniversary( anniversary, assembledName, a, false ) )
2157 ++addCount; 2158 ++addCount;
2158 } 2159 }
2159 } 2160 }
2160 2161
2161 mCalendar->setDefaultCalendar( curCal ); 2162 mCalendar->setDefaultCalendar( curCal );
2162 updateView(); 2163 updateView();
2163 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2164 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2164 2165
2165 } 2166 }
2166 2167
2167} 2168}
2168 2169
2169 2170
2170 2171
2171bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 2172bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
2172{ 2173{
2173 //qDebug("addAnni "); 2174 //qDebug("addAnni ");
2174 Event * ev = new Event(); 2175 Event * ev = new Event();
2175 ev->setOrganizer(KOPrefs::instance()->email()); 2176 ev->setOrganizer(KOPrefs::instance()->email());
2176 if ( a ) { 2177 if ( a ) {
2177 ev->addAttendee( a ); 2178 ev->addAttendee( a );
2178 } 2179 }
2179 QString kind; 2180 QString kind;
2180 if ( birthday ) { 2181 if ( birthday ) {
2181 kind = i18n( "Birthday" ); 2182 kind = i18n( "Birthday" );
2182 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 2183 ev->setSummary( name + " (" + QString::number(date.year()) +")");
2183 } 2184 }
2184 else { 2185 else {
2185 kind = i18n( "Anniversary" ); 2186 kind = i18n( "Anniversary" );
2186 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 2187 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
2187 } 2188 }
2188 ev->setCategories( kind ); 2189 ev->setCategories( kind );
2189 ev->setDtStart( QDateTime(date) ); 2190 ev->setDtStart( QDateTime(date) );
2190 ev->setDtEnd( QDateTime(date) ); 2191 ev->setDtEnd( QDateTime(date) );
2191 ev->setFloats( true ); 2192 ev->setFloats( true );
2192 Recurrence * rec = ev->recurrence(); 2193 Recurrence * rec = ev->recurrence();
2193 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 2194 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
2194 rec->addYearlyNum( date.month() ); 2195 rec->addYearlyNum( date.month() );
2195 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 2196 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
2196 delete ev; 2197 delete ev;
2197 return false; 2198 return false;
2198 } 2199 }
2199 return true; 2200 return true;
2200 2201
2201} 2202}
2202bool CalendarView::importQtopia( const QString &categories, 2203bool CalendarView::importQtopia( const QString &categories,
2203 const QString &datebook, 2204 const QString &datebook,
2204 const QString &todolist ) 2205 const QString &todolist )
2205{ 2206{
2206 2207
2207 QtopiaFormat qtopiaFormat; 2208 QtopiaFormat qtopiaFormat;
2208 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2209 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2209 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 2210 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
2210 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 2211 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
2211 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 2212 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
2212 2213
2213 updateView(); 2214 updateView();
2214 return true; 2215 return true;
2215 2216
2216#if 0 2217#if 0
2217 mGlobalSyncMode = SYNC_MODE_QTOPIA; 2218 mGlobalSyncMode = SYNC_MODE_QTOPIA;
2218 mCurrentSyncDevice = "qtopia-XML"; 2219 mCurrentSyncDevice = "qtopia-XML";
2219 if ( mSyncManager->mAskForPreferences ) 2220 if ( mSyncManager->mAskForPreferences )
2220 edit_sync_options(); 2221 edit_sync_options();
2221 qApp->processEvents(); 2222 qApp->processEvents();
2222 CalendarLocal* calendar = new CalendarLocal(); 2223 CalendarLocal* calendar = new CalendarLocal();
2223 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2224 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2224 bool syncOK = false; 2225 bool syncOK = false;
2225 QtopiaFormat qtopiaFormat; 2226 QtopiaFormat qtopiaFormat;
2226 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2227 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2227 bool loadOk = true; 2228 bool loadOk = true;
2228 if ( !categories.isEmpty() ) 2229 if ( !categories.isEmpty() )
2229 loadOk = qtopiaFormat.load( calendar, categories ); 2230 loadOk = qtopiaFormat.load( calendar, categories );
2230 if ( loadOk && !datebook.isEmpty() ) 2231 if ( loadOk && !datebook.isEmpty() )
2231 loadOk = qtopiaFormat.load( calendar, datebook ); 2232 loadOk = qtopiaFormat.load( calendar, datebook );
2232 if ( loadOk && !todolist.isEmpty() ) 2233 if ( loadOk && !todolist.isEmpty() )
2233 loadOk = qtopiaFormat.load( calendar, todolist ); 2234 loadOk = qtopiaFormat.load( calendar, todolist );
2234 2235
2235 if ( loadOk ) { 2236 if ( loadOk ) {
2236 getEventViewerDialog()->setSyncMode( true ); 2237 getEventViewerDialog()->setSyncMode( true );
2237 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2238 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2238 getEventViewerDialog()->setSyncMode( false ); 2239 getEventViewerDialog()->setSyncMode( false );
2239 qApp->processEvents(); 2240 qApp->processEvents();
2240 if ( syncOK ) { 2241 if ( syncOK ) {
2241 if ( mSyncManager->mWriteBackFile ) 2242 if ( mSyncManager->mWriteBackFile )
2242 { 2243 {
2243 // write back XML file 2244 // write back XML file
2244 2245
2245 } 2246 }
2246 setModified( true ); 2247 setModified( true );
2247 } 2248 }
2248 } else { 2249 } else {
2249 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2250 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2250 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2251 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2251 question, i18n("Ok")) ; 2252 question, i18n("Ok")) ;
2252 } 2253 }
2253 delete calendar; 2254 delete calendar;
2254 updateView(); 2255 updateView();
2255 return syncOK; 2256 return syncOK;
2256 2257
2257 2258
2258#endif 2259#endif
2259 2260
2260} 2261}
2261 2262
2262void CalendarView::setSyncEventsReadOnly() 2263void CalendarView::setSyncEventsReadOnly()
2263{ 2264{
2264 mCalendar->setSyncEventsReadOnly(); 2265 mCalendar->setSyncEventsReadOnly();
2265} 2266}
2266 2267
2267bool CalendarView::loadCalendars() 2268bool CalendarView::loadCalendars()
2268{ 2269{
2269 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2270 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2270 KopiCalendarFile * cal = calendars.first(); 2271 KopiCalendarFile * cal = calendars.first();
2271 mCalendar->setDefaultCalendar( 1 ); 2272 mCalendar->setDefaultCalendar( 1 );
2272 openCalendar( MainWindow::defaultFileName(), false ); 2273 openCalendar( MainWindow::defaultFileName(), false );
2273 cal = calendars.next(); 2274 cal = calendars.next();
2274 while ( cal ) { 2275 while ( cal ) {
2275 addCalendar( cal ); 2276 addCalendar( cal );
2276 cal = calendars.next(); 2277 cal = calendars.next();
2277 } 2278 }
2278 restoreCalendarSettings(); 2279 restoreCalendarSettings();
2279 return true; 2280 return true;
2280} 2281}
2281bool CalendarView::restoreCalendarSettings() 2282bool CalendarView::restoreCalendarSettings()
2282{ 2283{
2283 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2284 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2284 KopiCalendarFile * cal = calendars.first(); 2285 KopiCalendarFile * cal = calendars.first();
2285 while ( cal ) { 2286 while ( cal ) {
2286 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2287 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2287 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2288 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2288 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2289 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2289 if ( cal->isStandard ) 2290 if ( cal->isStandard )
2290 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2291 mCalendar->setDefaultCalendar( cal->mCalNumber );
2291 cal = calendars.next(); 2292 cal = calendars.next();
2292 } 2293 }
2293 setSyncEventsReadOnly(); 2294 setSyncEventsReadOnly();
2294 mCalendar->reInitAlarmSettings(); 2295 mCalendar->reInitAlarmSettings();
2295 updateUnmanagedViews(); 2296 updateUnmanagedViews();
2296 updateView(); 2297 updateView();
2297 return true; 2298 return true;
2298} 2299}
2299void CalendarView::addCalendarId( int id ) 2300void CalendarView::addCalendarId( int id )
2300{ 2301{
2301 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2302 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2302 if ( cal ) 2303 if ( cal )
2303 addCalendar( cal ); 2304 addCalendar( cal );
2304} 2305}
2305bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2306bool CalendarView::addCalendar( KopiCalendarFile * cal )
2306{ 2307{
2307 cal->mErrorOnLoad = false; 2308 cal->mErrorOnLoad = false;
2308 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2309 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2309 cal->mLoadDt = QDateTime::currentDateTime(); 2310 cal->mLoadDt = QDateTime::currentDateTime();
2310 return true; 2311 return true;
2311 } 2312 }
2312 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2313 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2313 cal->mErrorOnLoad = true; 2314 cal->mErrorOnLoad = true;
2314 return false; 2315 return false;
2315} 2316}
2316bool CalendarView::openCalendar(QString filename, bool merge) 2317bool CalendarView::openCalendar(QString filename, bool merge)
2317{ 2318{
2318 2319
2319 if (filename.isEmpty()) { 2320 if (filename.isEmpty()) {
2320 return false; 2321 return false;
2321 } 2322 }
2322 2323
2323 if (!QFile::exists(filename)) { 2324 if (!QFile::exists(filename)) {
2324 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2325 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2325 return false; 2326 return false;
2326 } 2327 }
2327 2328
2328 globalFlagBlockAgenda = 1; 2329 globalFlagBlockAgenda = 1;
2329 clearAllViews(); 2330 clearAllViews();
2330 if (!merge) { 2331 if (!merge) {
2331 mViewManager->setDocumentId( filename ); 2332 mViewManager->setDocumentId( filename );
2332 mCalendar->close(); 2333 mCalendar->close();
2333 } 2334 }
2334 mStorage->setFileName( filename ); 2335 mStorage->setFileName( filename );
2335 2336
2336 if ( mStorage->load() ) { 2337 if ( mStorage->load() ) {
2337 if ( merge ) ;//setModified( true ); 2338 if ( merge ) ;//setModified( true );
2338 else { 2339 else {
2339 //setModified( true ); 2340 //setModified( true );
2340 mViewManager->setDocumentId( filename ); 2341 mViewManager->setDocumentId( filename );
2341 mDialogManager->setDocumentId( filename ); 2342 mDialogManager->setDocumentId( filename );
2342 mTodoList->setDocumentId( filename ); 2343 mTodoList->setDocumentId( filename );
2343 } 2344 }
2344 globalFlagBlockAgenda = 2; 2345 globalFlagBlockAgenda = 2;
2345 // if ( getLastSyncEvent() ) 2346 // if ( getLastSyncEvent() )
2346 // getLastSyncEvent()->setReadOnly( true ); 2347 // getLastSyncEvent()->setReadOnly( true );
2347 mCalendar->reInitAlarmSettings(); 2348 mCalendar->reInitAlarmSettings();
2348 setSyncEventsReadOnly(); 2349 setSyncEventsReadOnly();
2349 updateUnmanagedViews(); 2350 updateUnmanagedViews();
2350 updateView(); 2351 updateView();
2351 if ( filename != MainWindow::defaultFileName() ) { 2352 if ( filename != MainWindow::defaultFileName() ) {
2352 saveCalendar( MainWindow::defaultFileName() ); 2353 saveCalendar( MainWindow::defaultFileName() );
2353 } else { 2354 } else {
2354 QFileInfo finf ( MainWindow::defaultFileName()); 2355 QFileInfo finf ( MainWindow::defaultFileName());
2355 if ( finf.exists() ) { 2356 if ( finf.exists() ) {
2356 setLoadedFileVersion( finf.lastModified () ); 2357 setLoadedFileVersion( finf.lastModified () );
2357 } 2358 }
2358 } 2359 }
2359 return true; 2360 return true;
2360 } else { 2361 } else {
2361 // while failing to load, the calendar object could 2362 // while failing to load, the calendar object could
2362 // have become partially populated. Clear it out. 2363 // have become partially populated. Clear it out.
2363 if ( !merge ) { 2364 if ( !merge ) {
2364 mCalendar->close(); 2365 mCalendar->close();
2365 mViewManager->setDocumentId( filename ); 2366 mViewManager->setDocumentId( filename );
2366 mDialogManager->setDocumentId( filename ); 2367 mDialogManager->setDocumentId( filename );
2367 mTodoList->setDocumentId( filename ); 2368 mTodoList->setDocumentId( filename );
2368 } 2369 }
2369 2370
2370 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2371 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2371 2372
2372 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2373 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2373 globalFlagBlockAgenda = 2; 2374 globalFlagBlockAgenda = 2;
2374 mCalendar->reInitAlarmSettings(); 2375 mCalendar->reInitAlarmSettings();
2375 setSyncEventsReadOnly(); 2376 setSyncEventsReadOnly();
2376 updateUnmanagedViews(); 2377 updateUnmanagedViews();
2377 updateView(); 2378 updateView();
2378 } 2379 }
2379 return false; 2380 return false;
2380} 2381}
2381void CalendarView::mergeFile( QString fn ) 2382void CalendarView::mergeFile( QString fn )
2382{ 2383{
2383 clearAllViews(); 2384 clearAllViews();
2384 mCalendar->mergeCalendarFile( fn ); 2385 mCalendar->mergeCalendarFile( fn );
2385 mCalendar->reInitAlarmSettings(); 2386 mCalendar->reInitAlarmSettings();
2386 setSyncEventsReadOnly(); 2387 setSyncEventsReadOnly();
2387 updateUnmanagedViews(); 2388 updateUnmanagedViews();
2388 updateView(); 2389 updateView();
2389} 2390}
2390void CalendarView::showOpenError() 2391void CalendarView::showOpenError()
2391{ 2392{
2392 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2393 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2393} 2394}
2394void CalendarView::setLoadedFileVersion(QDateTime dt) 2395void CalendarView::setLoadedFileVersion(QDateTime dt)
2395{ 2396{
2396 loadedFileVersion = dt; 2397 loadedFileVersion = dt;
2397} 2398}
2398bool CalendarView::checkFileChanged(QString fn) 2399bool CalendarView::checkFileChanged(QString fn)
2399{ 2400{
2400 QFileInfo finf ( fn ); 2401 QFileInfo finf ( fn );
2401 if ( !finf.exists() ) 2402 if ( !finf.exists() )
2402 return true; 2403 return true;
2403 QDateTime dt = finf.lastModified (); 2404 QDateTime dt = finf.lastModified ();
2404 if ( dt <= loadedFileVersion ) 2405 if ( dt <= loadedFileVersion )
2405 return false; 2406 return false;
2406 return true; 2407 return true;
2407 2408
2408} 2409}
2409void CalendarView::watchSavedFile() 2410void CalendarView::watchSavedFile()
2410{ 2411{
2411 QFileInfo finf ( MainWindow::defaultFileName()); 2412 QFileInfo finf ( MainWindow::defaultFileName());
2412 if ( !finf.exists() ) 2413 if ( !finf.exists() )
2413 return; 2414 return;
2414 QDateTime dt = finf.lastModified (); 2415 QDateTime dt = finf.lastModified ();
2415 if ( dt < loadedFileVersion ) { 2416 if ( dt < loadedFileVersion ) {
2416 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2417 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2417 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2418 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2418 return; 2419 return;
2419 } 2420 }
2420 loadedFileVersion = dt; 2421 loadedFileVersion = dt;
2421} 2422}
2422bool CalendarView::checkAllFileVersions() 2423bool CalendarView::checkAllFileVersions()
2423{ 2424{
2424 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2425 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2425 KopiCalendarFile * cal = calendars.first(); 2426 KopiCalendarFile * cal = calendars.first();
2426 mCalendar->setDefaultCalendar( 1 ); 2427 mCalendar->setDefaultCalendar( 1 );
2427 mCalendar->setDefaultCalendarEnabledOnly(); 2428 mCalendar->setDefaultCalendarEnabledOnly();
2428 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2429 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2429 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2430 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2430 restoreCalendarSettings(); 2431 restoreCalendarSettings();
2431 return false; 2432 return false;
2432 } 2433 }
2433 } 2434 }
2434 cal = calendars.next(); 2435 cal = calendars.next();
2435 QDateTime storeTemp = loadedFileVersion; 2436 QDateTime storeTemp = loadedFileVersion;
2436 while ( cal ) { 2437 while ( cal ) {
2437 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2438 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2438 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2439 mCalendar->setDefaultCalendar( cal->mCalNumber );
2439 mCalendar->setDefaultCalendarEnabledOnly(); 2440 mCalendar->setDefaultCalendarEnabledOnly();
2440 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2441 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2441 if ( !checkFileVersion(cal->mFileName )) { 2442 if ( !checkFileVersion(cal->mFileName )) {
2442 loadedFileVersion = storeTemp; 2443 loadedFileVersion = storeTemp;
2443 restoreCalendarSettings(); 2444 restoreCalendarSettings();
2444 return false; 2445 return false;
2445 } 2446 }
2446 } 2447 }
2447 cal = calendars.next(); 2448 cal = calendars.next();
2448 } 2449 }
2449 loadedFileVersion = storeTemp; 2450 loadedFileVersion = storeTemp;
2450 return true; 2451 return true;
2451} 2452}
2452bool CalendarView::checkFileVersion(QString fn) 2453bool CalendarView::checkFileVersion(QString fn)
2453{ 2454{
2454 QFileInfo finf ( fn ); 2455 QFileInfo finf ( fn );
2455 if ( !finf.exists() ) 2456 if ( !finf.exists() )
2456 return true; 2457 return true;
2457 QDateTime dt = finf.lastModified (); 2458 QDateTime dt = finf.lastModified ();
2458 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2459 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2459 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2460 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2460 if ( dt <= loadedFileVersion ) 2461 if ( dt <= loadedFileVersion )
2461 return true; 2462 return true;
2462 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2463 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2463 i18n("KO/Pi Warning"),i18n("Overwrite"), 2464 i18n("KO/Pi Warning"),i18n("Overwrite"),
2464 i18n("Sync+save")); 2465 i18n("Sync+save"));
2465 2466
2466 if ( km == KMessageBox::Cancel ) 2467 if ( km == KMessageBox::Cancel )
2467 return false; 2468 return false;
2468 if ( km == KMessageBox::Yes ) 2469 if ( km == KMessageBox::Yes )
2469 return true; 2470 return true;
2470 2471
2471 setSyncDevice("deleteaftersync" ); 2472 setSyncDevice("deleteaftersync" );
2472 mSyncManager->mAskForPreferences = true; 2473 mSyncManager->mAskForPreferences = true;
2473 mSyncManager->mSyncAlgoPrefs = 3; 2474 mSyncManager->mSyncAlgoPrefs = 3;
2474 mSyncManager->mWriteBackFile = false; 2475 mSyncManager->mWriteBackFile = false;
2475 mSyncManager->mWriteBackExistingOnly = false; 2476 mSyncManager->mWriteBackExistingOnly = false;
2476 mSyncManager->mShowSyncSummary = false; 2477 mSyncManager->mShowSyncSummary = false;
2477 syncCalendar( fn, 3 ); 2478 syncCalendar( fn, 3 );
2478 Event * e = getLastSyncEvent(); 2479 Event * e = getLastSyncEvent();
2479 if ( e ) 2480 if ( e )
2480 mCalendar->deleteEvent( e ); 2481 mCalendar->deleteEvent( e );
2481 return true; 2482 return true;
2482} 2483}
2483bool CalendarView::saveCalendars() 2484bool CalendarView::saveCalendars()
2484{ 2485{
2485 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2486 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2486 KopiCalendarFile * cal = calendars.first(); 2487 KopiCalendarFile * cal = calendars.first();
2487 mCalendar->setDefaultCalendar( 1 ); 2488 mCalendar->setDefaultCalendar( 1 );
2488 mCalendar->setDefaultCalendarEnabledOnly(); 2489 mCalendar->setDefaultCalendarEnabledOnly();
2489 saveCalendar( MainWindow::defaultFileName() ); 2490 saveCalendar( MainWindow::defaultFileName() );
2490 cal = calendars.next(); 2491 cal = calendars.next();
2491 while ( cal ) { 2492 while ( cal ) {
2492 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2493 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2493 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2494 mCalendar->setDefaultCalendar( cal->mCalNumber );
2494 mCalendar->setDefaultCalendarEnabledOnly(); 2495 mCalendar->setDefaultCalendarEnabledOnly();
2495 if ( saveCalendar( cal->mFileName ) ) 2496 if ( saveCalendar( cal->mFileName ) )
2496 cal->mLoadDt = QDateTime::currentDateTime(); 2497 cal->mLoadDt = QDateTime::currentDateTime();
2497 } 2498 }
2498 cal = calendars.next(); 2499 cal = calendars.next();
2499 } 2500 }
2500 restoreCalendarSettings(); 2501 restoreCalendarSettings();
2501 return true; 2502 return true;
2502} 2503}
2503bool CalendarView::saveCalendar( QString filename ) 2504bool CalendarView::saveCalendar( QString filename )
2504{ 2505{
2505 2506
2506 // Store back all unsaved data into calendar object 2507 // Store back all unsaved data into calendar object
2507 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2508 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2508 if ( mViewManager->currentView() ) 2509 if ( mViewManager->currentView() )
2509 mViewManager->currentView()->flushView(); 2510 mViewManager->currentView()->flushView();
2510 2511
2511 2512
2512 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2513 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2513 mStorage->setSaveFormat( new ICalFormat() ); 2514 mStorage->setSaveFormat( new ICalFormat() );
2514 mStorage->setFileName( filename ); 2515 mStorage->setFileName( filename );
2515 bool success; 2516 bool success;
2516 success = mStorage->save(); 2517 success = mStorage->save();
2517 if ( !success ) { 2518 if ( !success ) {
2518 return false; 2519 return false;
2519 } 2520 }
2520 if ( filename == MainWindow::defaultFileName() ) { 2521 if ( filename == MainWindow::defaultFileName() ) {
2521 setLoadedFileVersion( lfv ); 2522 setLoadedFileVersion( lfv );
2522 watchSavedFile(); 2523 watchSavedFile();
2523 } 2524 }
2524 return true; 2525 return true;
2525} 2526}
2526 2527
2527void CalendarView::closeCalendar() 2528void CalendarView::closeCalendar()
2528{ 2529{
2529 2530
2530 // child windows no longer valid 2531 // child windows no longer valid
2531 clearAllViews(); 2532 clearAllViews();
2532 emit closingDown(); 2533 emit closingDown();
2533 2534
2534 mCalendar->close(); 2535 mCalendar->close();
2535 setModified(false); 2536 setModified(false);
2536 updateView(); 2537 updateView();
2537} 2538}
2538 2539
2539void CalendarView::archiveCalendar() 2540void CalendarView::archiveCalendar()
2540{ 2541{
2541 mDialogManager->showArchiveDialog(); 2542 mDialogManager->showArchiveDialog();
2542} 2543}
2543 2544
2544 2545
2545void CalendarView::readSettings() 2546void CalendarView::readSettings()
2546{ 2547{
2547 2548
2548 2549
2549 // mViewManager->showAgendaView(); 2550 // mViewManager->showAgendaView();
2550 QString str; 2551 QString str;
2551 //qDebug("CalendarView::readSettings() "); 2552 //qDebug("CalendarView::readSettings() ");
2552 // read settings from the KConfig, supplying reasonable 2553 // read settings from the KConfig, supplying reasonable
2553 // defaults where none are to be found 2554 // defaults where none are to be found
2554 KConfig *config = KOGlobals::config(); 2555 KConfig *config = KOGlobals::config();
2555#ifndef KORG_NOSPLITTER 2556#ifndef KORG_NOSPLITTER
2556 config->setGroup("KOrganizer Geometry"); 2557 config->setGroup("KOrganizer Geometry");
2557 2558
2558 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2559 QValueList<int> sizes = config->readIntListEntry("Separator1");
2559 if (sizes.count() != 2) { 2560 if (sizes.count() != 2) {
2560 sizes << mDateNavigator->minimumSizeHint().width(); 2561 sizes << mDateNavigator->minimumSizeHint().width();
2561 sizes << 300; 2562 sizes << 300;
2562 } 2563 }
2563 mPanner->setSizes(sizes); 2564 mPanner->setSizes(sizes);
2564 2565
2565 sizes = config->readIntListEntry("Separator2"); 2566 sizes = config->readIntListEntry("Separator2");
2566 if ( ( mResourceView && sizes.count() == 4 ) || 2567 if ( ( mResourceView && sizes.count() == 4 ) ||
2567 ( !mResourceView && sizes.count() == 3 ) ) { 2568 ( !mResourceView && sizes.count() == 3 ) ) {
2568 mLeftSplitter->setSizes(sizes); 2569 mLeftSplitter->setSizes(sizes);
2569 } 2570 }
2570#endif 2571#endif
2571 globalFlagBlockAgenda = 1; 2572 globalFlagBlockAgenda = 1;
2572 mViewManager->showAgendaView(); 2573 mViewManager->showAgendaView();
2573 //mViewManager->readSettings( config ); 2574 //mViewManager->readSettings( config );
2574 mTodoList->restoreLayout(config,QString("Todo Layout")); 2575 mTodoList->restoreLayout(config,QString("Todo Layout"));
2575 readFilterSettings(config); 2576 readFilterSettings(config);
2576 2577
2577#ifdef DESKTOP_VERSION 2578#ifdef DESKTOP_VERSION
2578 config->setGroup("WidgetLayout"); 2579 config->setGroup("WidgetLayout");
2579 QStringList list; 2580 QStringList list;
2580 list = config->readListEntry("MainLayout"); 2581 list = config->readListEntry("MainLayout");
2581 int x,y,w,h; 2582 int x,y,w,h;
2582 if ( ! list.isEmpty() ) { 2583 if ( ! list.isEmpty() ) {
2583 x = list[0].toInt(); 2584 x = list[0].toInt();
2584 y = list[1].toInt(); 2585 y = list[1].toInt();
2585 w = list[2].toInt(); 2586 w = list[2].toInt();
2586 h = list[3].toInt(); 2587 h = list[3].toInt();
2587 KApplication::testCoords( &x,&y,&w,&h ); 2588 KApplication::testCoords( &x,&y,&w,&h );
2588 topLevelWidget()->setGeometry(x,y,w,h); 2589 topLevelWidget()->setGeometry(x,y,w,h);
2589 2590
2590 } else { 2591 } else {
2591 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2592 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2592 } 2593 }
2593 list = config->readListEntry("EditEventLayout"); 2594 list = config->readListEntry("EditEventLayout");
2594 if ( ! list.isEmpty() ) { 2595 if ( ! list.isEmpty() ) {
2595 x = list[0].toInt(); 2596 x = list[0].toInt();
2596 y = list[1].toInt(); 2597 y = list[1].toInt();
2597 w = list[2].toInt(); 2598 w = list[2].toInt();
2598 h = list[3].toInt(); 2599 h = list[3].toInt();
2599 KApplication::testCoords( &x,&y,&w,&h ); 2600 KApplication::testCoords( &x,&y,&w,&h );
2600 mEventEditor->setGeometry(x,y,w,h); 2601 mEventEditor->setGeometry(x,y,w,h);
2601 2602
2602 } 2603 }
2603 list = config->readListEntry("EditTodoLayout"); 2604 list = config->readListEntry("EditTodoLayout");
2604 if ( ! list.isEmpty() ) { 2605 if ( ! list.isEmpty() ) {
2605 x = list[0].toInt(); 2606 x = list[0].toInt();
2606 y = list[1].toInt(); 2607 y = list[1].toInt();
2607 w = list[2].toInt(); 2608 w = list[2].toInt();