summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-14 15:00:29 (UTC)
committer zautrix <zautrix>2005-06-14 15:00:29 (UTC)
commit9b2265ffbe8c21fff0b00b376dd3925e4b44168b (patch) (unidiff)
tree27147c040dc5bbd44f2210955e4df2fb1930fb93
parentd38f601cfdb510fc39dd798af44a50c7958d7be8 (diff)
downloadkdepimpi-9b2265ffbe8c21fff0b00b376dd3925e4b44168b.zip
kdepimpi-9b2265ffbe8c21fff0b00b376dd3925e4b44168b.tar.gz
kdepimpi-9b2265ffbe8c21fff0b00b376dd3925e4b44168b.tar.bz2
compile fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b0be340..dd4ea41 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4517 +1,4520 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preton.brown@yale.edu) 8 Preston Brown (preton.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
142 142
143{ 143{
144 mAlarms = alarms; 144 mAlarms = alarms;
145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
146 QString mText = "<table width=\"100%\">\n"; 146 QString mText = "<table width=\"100%\">\n";
147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
148#ifdef DESKTOP_VERSION 148#ifdef DESKTOP_VERSION
149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
150#else 150#else
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
152#endif 152#endif
153 // mText += "<img src=\""; 153 // mText += "<img src=\"";
154 // mText += ipath; 154 // mText += ipath;
155 // mText += "\">"; 155 // mText += "\">";
156 //mEventDate = QDate::currentDate(); 156 //mEventDate = QDate::currentDate();
157#ifdef DESKTOP_VERSION 157#ifdef DESKTOP_VERSION
158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
159#else 159#else
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
161#endif 161#endif
162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
163 163
164 Incidence * inc = getNextInc( start ); 164 Incidence * inc = getNextInc( start );
165 int time = 0; 165 int time = 0;
166 //mText += "<table>"; 166 //mText += "<table>";
167 while ( inc ) { 167 while ( inc ) {
168 QDateTime dt ; 168 QDateTime dt ;
169 QString tempText = "<a "; 169 QString tempText = "<a ";
170 bool ok; 170 bool ok;
171 dt = inc->getNextOccurence( start, &ok ); 171 dt = inc->getNextOccurence( start, &ok );
172 if ( !ok ) continue; 172 if ( !ok ) continue;
173 if ( inc->typeID() == eventID ) { 173 if ( inc->typeID() == eventID ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->typeID() == todoID ) { 175 } else if ( inc->typeID() == todoID ) {
176 tempText += "href=\"todo:"; 176 tempText += "href=\"todo:";
177 } 177 }
178 tempText += inc->uid() + "\">"; 178 tempText += inc->uid() + "\">";
179 if ( inc->typeID() == todoID ) 179 if ( inc->typeID() == todoID )
180 tempText += i18n("Todo: "); 180 tempText += i18n("Todo: ");
181 if ( inc->summary().length() > 0 ) 181 if ( inc->summary().length() > 0 )
182 tempText += inc->summary(); 182 tempText += inc->summary();
183 else 183 else
184 tempText += i18n("-no summary-"); 184 tempText += i18n("-no summary-");
185 QString timestr; 185 QString timestr;
186 if (!inc->doesFloat()) 186 if (!inc->doesFloat())
187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
188 else 188 else
189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
190 if ( dt.date() < QDate::currentDate() && time == 0 ) { 190 if ( dt.date() < QDate::currentDate() && time == 0 ) {
191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
192 mText += "<table>"; 192 mText += "<table>";
193 time = 1; 193 time = 1;
194 } 194 }
195 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 195 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
196 if ( time > 0 ) 196 if ( time > 0 )
197 mText +="</table>"; 197 mText +="</table>";
198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
199 mText += "<table>"; 199 mText += "<table>";
200 time = 2; 200 time = 2;
201 201
202 } 202 }
203 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 203 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
204 if ( time > 0 ) 204 if ( time > 0 )
205 mText +="</table>"; 205 mText +="</table>";
206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
207 mText += "<table>"; 207 mText += "<table>";
208 time = 3; 208 time = 3;
209 } 209 }
210 mText +="<tr><td><b>"; 210 mText +="<tr><td><b>";
211 mText += timestr; 211 mText += timestr;
212 mText += "</b></td><td>"; 212 mText += "</b></td><td>";
213 mText += tempText; 213 mText += tempText;
214 mText += "</td></tr>\n"; 214 mText += "</td></tr>\n";
215 inc = getNextInc( start ); 215 inc = getNextInc( start );
216 } 216 }
217 mText +="</table>"; 217 mText +="</table>";
218 setText( mText ); 218 setText( mText );
219} 219}
220 220
221MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 221MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
222{ 222{
223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
224} 224}
225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
226{ 226{
227 QDateTime dt ; 227 QDateTime dt ;
228 Incidence * retInc; 228 Incidence * retInc;
229 Incidence * inc = mAlarms.first(); 229 Incidence * inc = mAlarms.first();
230 if ( inc == 0 ) 230 if ( inc == 0 )
231 return 0; 231 return 0;
232 bool ok; 232 bool ok;
233 dt = inc->getNextOccurence( start, &ok ); 233 dt = inc->getNextOccurence( start, &ok );
234 if ( ! ok ) return 0; 234 if ( ! ok ) return 0;
235 QDateTime dtn ; 235 QDateTime dtn ;
236 retInc = inc; 236 retInc = inc;
237 inc = mAlarms.next(); 237 inc = mAlarms.next();
238 while ( inc ) { 238 while ( inc ) {
239 dtn = inc->getNextOccurence( start, &ok ); 239 dtn = inc->getNextOccurence( start, &ok );
240 if ( ! ok ) return 0; 240 if ( ! ok ) return 0;
241 if ( dtn < dt ) { 241 if ( dtn < dt ) {
242 dt = dtn; 242 dt = dtn;
243 retInc = inc; 243 retInc = inc;
244 } 244 }
245 inc = mAlarms.next(); 245 inc = mAlarms.next();
246 } 246 }
247 mAlarms.remove( retInc ); 247 mAlarms.remove( retInc );
248 return retInc; 248 return retInc;
249 249
250} 250}
251void MissedAlarmTextBrowser::setSource(const QString & n) 251void MissedAlarmTextBrowser::setSource(const QString & n)
252{ 252{
253 if (n.startsWith("event:")) { 253 if (n.startsWith("event:")) {
254#ifdef DESKTOP_VERSION 254#ifdef DESKTOP_VERSION
255 emit showIncidence(n.mid(8)); 255 emit showIncidence(n.mid(8));
256#else 256#else
257 emit showIncidence(n.mid(6)); 257 emit showIncidence(n.mid(6));
258#endif 258#endif
259 return; 259 return;
260 } else if (n.startsWith("todo:")) { 260 } else if (n.startsWith("todo:")) {
261#ifdef DESKTOP_VERSION 261#ifdef DESKTOP_VERSION
262 emit showIncidence(n.mid(7)); 262 emit showIncidence(n.mid(7));
263#else 263#else
264 emit showIncidence(n.mid(5)); 264 emit showIncidence(n.mid(5));
265#endif 265#endif
266 return; 266 return;
267 } 267 }
268} 268}
269 269
270 270
271class KOBeamPrefs : public QDialog 271class KOBeamPrefs : public QDialog
272{ 272{
273 public: 273 public:
274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
275 QDialog( parent, name, true ) 275 QDialog( parent, name, true )
276 { 276 {
277 setCaption( i18n("Beam Options") ); 277 setCaption( i18n("Beam Options") );
278 QVBoxLayout* lay = new QVBoxLayout( this ); 278 QVBoxLayout* lay = new QVBoxLayout( this );
279 lay->setSpacing( 3 ); 279 lay->setSpacing( 3 );
280 lay->setMargin( 3 ); 280 lay->setMargin( 3 );
281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
282 lay->addWidget( format ); 282 lay->addWidget( format );
283 format->setExclusive ( true ) ; 283 format->setExclusive ( true ) ;
284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
285 lay->addWidget( time ); time->setExclusive ( true ) ; 285 lay->addWidget( time ); time->setExclusive ( true ) ;
286 vcal = new QRadioButton(" vCalendar ", format ); 286 vcal = new QRadioButton(" vCalendar ", format );
287 ical = new QRadioButton(" iCalendar ", format ); 287 ical = new QRadioButton(" iCalendar ", format );
288 vcal->setChecked( true ); 288 vcal->setChecked( true );
289 tz = new QRadioButton(i18n(" With timezone "), time ); 289 tz = new QRadioButton(i18n(" With timezone "), time );
290 local = new QRadioButton(i18n(" Local time "), time ); 290 local = new QRadioButton(i18n(" Local time "), time );
291 tz->setChecked( true ); 291 tz->setChecked( true );
292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
293 lay->addWidget( ok ); 293 lay->addWidget( ok );
294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
295 lay->addWidget( cancel ); 295 lay->addWidget( cancel );
296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
298 resize( 200, 200 ); 298 resize( 200, 200 );
299 } 299 }
300 300
301 bool beamVcal() { return vcal->isChecked(); } 301 bool beamVcal() { return vcal->isChecked(); }
302 bool beamLocal() { return local->isChecked(); } 302 bool beamLocal() { return local->isChecked(); }
303private: 303private:
304 QRadioButton* vcal, *ical, *local, *tz; 304 QRadioButton* vcal, *ical, *local, *tz;
305}; 305};
306class KOCatPrefs : public QDialog 306class KOCatPrefs : public QDialog
307{ 307{
308 public: 308 public:
309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
310 QDialog( parent, name, true ) 310 QDialog( parent, name, true )
311 { 311 {
312 setCaption( i18n("Manage new Categories") ); 312 setCaption( i18n("Manage new Categories") );
313 QVBoxLayout* lay = new QVBoxLayout( this ); 313 QVBoxLayout* lay = new QVBoxLayout( this );
314 lay->setSpacing( 3 ); 314 lay->setSpacing( 3 );
315 lay->setMargin( 3 ); 315 lay->setMargin( 3 );
316 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 316 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
317 lay->addWidget( lab ); 317 lay->addWidget( lab );
318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
319 lay->addWidget( format ); 319 lay->addWidget( format );
320 format->setExclusive ( true ) ; 320 format->setExclusive ( true ) ;
321 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 321 addCatBut = new QRadioButton(i18n("Add to category list"), format );
322 new QRadioButton(i18n("Remove from Events/Todos"), format ); 322 new QRadioButton(i18n("Remove from Events/Todos"), format );
323 addCatBut->setChecked( true ); 323 addCatBut->setChecked( true );
324 QPushButton * ok = new QPushButton( i18n("OK"), this ); 324 QPushButton * ok = new QPushButton( i18n("OK"), this );
325 lay->addWidget( ok ); 325 lay->addWidget( ok );
326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
327 lay->addWidget( cancel ); 327 lay->addWidget( cancel );
328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
330 resize( 200, 200 ); 330 resize( 200, 200 );
331 } 331 }
332 332
333 bool addCat() { return addCatBut->isChecked(); } 333 bool addCat() { return addCatBut->isChecked(); }
334private: 334private:
335 QRadioButton* addCatBut; 335 QRadioButton* addCatBut;
336}; 336};
337 337
338 338
339 339
340CalendarView::CalendarView( CalendarResources *calendar, 340CalendarView::CalendarView( CalendarResources *calendar,
341 QWidget *parent, const char *name ) 341 QWidget *parent, const char *name )
342 : CalendarViewBase( parent, name ), 342 : CalendarViewBase( parent, name ),
343 mCalendar( calendar ), 343 mCalendar( calendar ),
344 mResourceManager( calendar->resourceManager() ) 344 mResourceManager( calendar->resourceManager() )
345{ 345{
346 346
347 mEventEditor = 0; 347 mEventEditor = 0;
348 mTodoEditor = 0; 348 mTodoEditor = 0;
349 349
350 init(); 350 init();
351} 351}
352 352
353CalendarView::CalendarView( Calendar *calendar, 353CalendarView::CalendarView( Calendar *calendar,
354 QWidget *parent, const char *name ) 354 QWidget *parent, const char *name )
355 : CalendarViewBase( parent, name ), 355 : CalendarViewBase( parent, name ),
356 mCalendar( calendar ), 356 mCalendar( calendar ),
357 mResourceManager( 0 ) 357 mResourceManager( 0 )
358{ 358{
359 359
360 mEventEditor = 0; 360 mEventEditor = 0;
361 mTodoEditor = 0; 361 mTodoEditor = 0;
362 init(); 362 init();
363} 363}
364 364
365void CalendarView::init() 365void CalendarView::init()
366{ 366{
367 mNextAlarmDateTime = QDateTime::currentDateTime(); 367 mNextAlarmDateTime = QDateTime::currentDateTime();
368 setFocusPolicy ( NoFocus ); 368 setFocusPolicy ( NoFocus );
369 mViewerCallerIsSearchDialog = false; 369 mViewerCallerIsSearchDialog = false;
370 mBlockShowDates = false; 370 mBlockShowDates = false;
371 beamDialog = new KOBeamPrefs(); 371 beamDialog = new KOBeamPrefs();
372 mDatePickerMode = 0; 372 mDatePickerMode = 0;
373 mCurrentSyncDevice = ""; 373 mCurrentSyncDevice = "";
374 writeLocale(); 374 writeLocale();
375 mViewManager = new KOViewManager( this ); 375 mViewManager = new KOViewManager( this );
376 mDialogManager = new KODialogManager( this ); 376 mDialogManager = new KODialogManager( this );
377 mEventViewerDialog = 0; 377 mEventViewerDialog = 0;
378 mModified = false; 378 mModified = false;
379 mReadOnly = false; 379 mReadOnly = false;
380 mSelectedIncidence = 0; 380 mSelectedIncidence = 0;
381 mCalPrinter = 0; 381 mCalPrinter = 0;
382 mFilters.setAutoDelete(true); 382 mFilters.setAutoDelete(true);
383 383
384 mCalendar->registerObserver( this ); 384 mCalendar->registerObserver( this );
385 // TODO: Make sure that view is updated, when calendar is changed. 385 // TODO: Make sure that view is updated, when calendar is changed.
386 386
387 mStorage = new FileStorage( mCalendar ); 387 mStorage = new FileStorage( mCalendar );
388 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 388 mNavigator = new DateNavigator( this, "datevav", mViewManager );
389 389
390 QBoxLayout *topLayout = (QBoxLayout*)layout(); 390 QBoxLayout *topLayout = (QBoxLayout*)layout();
391#ifndef KORG_NOSPLITTER 391#ifndef KORG_NOSPLITTER
392 // create the main layout frames. 392 // create the main layout frames.
393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
394 topLayout->addWidget(mPanner); 394 topLayout->addWidget(mPanner);
395 395
396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
397 "CalendarView::LeftFrame"); 397 "CalendarView::LeftFrame");
398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
399 399
400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
401 "CalendarView::DateNavigator" ); 401 "CalendarView::DateNavigator" );
402 402
403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
405 mTodoList->setNavigator( mNavigator ); 405 mTodoList->setNavigator( mNavigator );
406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
407 407
408#ifdef KORG_NORESOURCEVIEW 408#ifdef KORG_NORESOURCEVIEW
409 mResourceView = 0; 409 mResourceView = 0;
410#else 410#else
411 if ( mResourceManager ) { 411 if ( mResourceManager ) {
412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
413 mResourceView->updateView(); 413 mResourceView->updateView();
414 connect( mResourceView, SIGNAL( resourcesChanged() ), 414 connect( mResourceView, SIGNAL( resourcesChanged() ),
415 SLOT( updateView() ) ); 415 SLOT( updateView() ) );
416 } else { 416 } else {
417 mResourceView = 0; 417 mResourceView = 0;
418 } 418 }
419#endif 419#endif
420 QWidget *rightBox = new QWidget( mPanner ); 420 QWidget *rightBox = new QWidget( mPanner );
421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
422 422
423 mRightFrame = new QWidgetStack( rightBox ); 423 mRightFrame = new QWidgetStack( rightBox );
424 rightLayout->addWidget( mRightFrame, 1 ); 424 rightLayout->addWidget( mRightFrame, 1 );
425 425
426 mLeftFrame = mLeftSplitter; 426 mLeftFrame = mLeftSplitter;
427#else 427#else
428 //QWidget *mainBox = new QWidget( this ); 428 //QWidget *mainBox = new QWidget( this );
429 //QWidget *leftFrame = new QWidget( mainBox ); 429 //QWidget *leftFrame = new QWidget( mainBox );
430 //QBoxLayout * mainBoxLayout; 430 //QBoxLayout * mainBoxLayout;
431 if ( KOPrefs::instance()->mVerticalScreen ) { 431 if ( KOPrefs::instance()->mVerticalScreen ) {
432 //mainBoxLayout = new QVBoxLayout(mainBox); 432 //mainBoxLayout = new QVBoxLayout(mainBox);
433 //leftFrameLayout = new QHBoxLayout(leftFrame ); 433 //leftFrameLayout = new QHBoxLayout(leftFrame );
434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
438 } else { 438 } else {
439 //mainBoxLayout = new QHBoxLayout(mainBox); 439 //mainBoxLayout = new QHBoxLayout(mainBox);
440 //leftFrameLayout = new QVBoxLayout(leftFrame ); 440 //leftFrameLayout = new QVBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
445 } 445 }
446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
447 //QBoxLayout * leftFrameLayout; 447 //QBoxLayout * leftFrameLayout;
448 topLayout->addWidget( mMainFrame ); 448 topLayout->addWidget( mMainFrame );
449 //mainBoxLayout->addWidget (mLeftFrame); 449 //mainBoxLayout->addWidget (mLeftFrame);
450 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 450 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
451 "CalendarView::DateNavigator" ); 451 "CalendarView::DateNavigator" );
452#if 0 452#if 0
453 // FIXME 453 // FIXME
454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
455 "CalendarView::DateNavigator", QDate::currentDate()); 455 "CalendarView::DateNavigator", QDate::currentDate());
456#endif 456#endif
457 // mDateNavigator->blockSignals( true ); 457 // mDateNavigator->blockSignals( true );
458 //leftFrameLayout->addWidget( mDateNavigator ); 458 //leftFrameLayout->addWidget( mDateNavigator );
459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
462 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 462 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
463 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 463 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
464 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); 464 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
465 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 465 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
466 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 466 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
467 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 467 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
468 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 468 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
469 mTodoList->setNavigator( mNavigator ); 469 mTodoList->setNavigator( mNavigator );
470#if 0 470#if 0
471 if ( QApplication::desktop()->width() < 480 ) { 471 if ( QApplication::desktop()->width() < 480 ) {
472 leftFrameLayout->addWidget(mFilterView); 472 leftFrameLayout->addWidget(mFilterView);
473 leftFrameLayout->addWidget(mTodoList, 2 ); 473 leftFrameLayout->addWidget(mTodoList, 2 );
474 474
475 } else { 475 } else {
476 leftFrameLayout->addWidget(mTodoList,2 ); 476 leftFrameLayout->addWidget(mTodoList,2 );
477 leftFrameLayout->addWidget(mFilterView ); 477 leftFrameLayout->addWidget(mFilterView );
478 } 478 }
479#endif 479#endif
480 mFilterView->hide(); 480 mFilterView->hide();
481 mCalEditView->hide(); 481 mCalEditView->hide();
482 QWidget *rightBox = new QWidget( mMainFrame ); 482 QWidget *rightBox = new QWidget( mMainFrame );
483 //mainBoxLayout->addWidget ( rightBox, 10 ); 483 //mainBoxLayout->addWidget ( rightBox, 10 );
484 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 484 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
485 mRightFrame = new QWidgetStack( rightBox ); 485 mRightFrame = new QWidgetStack( rightBox );
486 rightLayout->addWidget( mRightFrame, 10 ); 486 rightLayout->addWidget( mRightFrame, 10 );
487 487
488 //mLeftFrame = (QWidget *)leftFrame; 488 //mLeftFrame = (QWidget *)leftFrame;
489 if ( KOPrefs::instance()->mVerticalScreen ) { 489 if ( KOPrefs::instance()->mVerticalScreen ) {
490 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 490 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
491 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 491 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
492 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 492 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
493 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 493 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
494 } else { 494 } else {
495 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 495 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
496 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 496 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
497 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 497 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
498 } 498 }
499 if ( !KOPrefs::instance()->mShowDateNavigator) 499 if ( !KOPrefs::instance()->mShowDateNavigator)
500 mDateNavigator->hide(); 500 mDateNavigator->hide();
501 //qDebug("Calendarview Size %d %d ", width(), height()); 501 //qDebug("Calendarview Size %d %d ", width(), height());
502#endif 502#endif
503 503
504 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 504 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
505 SLOT( showDates( const KCal::DateList & ) ) ); 505 SLOT( showDates( const KCal::DateList & ) ) );
506 506
507 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 507 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
508 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 508 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
509 509
510 510
511 511
512 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 512 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
513 mViewManager, SLOT( showMonth( const QDate & ) ) ); 513 mViewManager, SLOT( showMonth( const QDate & ) ) );
514 514
515 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 515 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
516 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 516 mNavigator, SLOT( selectWeek( const QDate & ) ) );
517 517
518 connect( mDateNavigator, SIGNAL( goPrevYear() ), 518 connect( mDateNavigator, SIGNAL( goPrevYear() ),
519 mNavigator, SLOT( selectPreviousYear() ) ); 519 mNavigator, SLOT( selectPreviousYear() ) );
520 connect( mDateNavigator, SIGNAL( goNextYear() ), 520 connect( mDateNavigator, SIGNAL( goNextYear() ),
521 mNavigator, SLOT( selectNextYear() ) ); 521 mNavigator, SLOT( selectNextYear() ) );
522 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 522 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
523 mNavigator, SLOT( selectPreviousMonth() ) ); 523 mNavigator, SLOT( selectPreviousMonth() ) );
524 connect( mDateNavigator, SIGNAL( goNextMonth() ), 524 connect( mDateNavigator, SIGNAL( goNextMonth() ),
525 mNavigator, SLOT( selectNextMonth() ) ); 525 mNavigator, SLOT( selectNextMonth() ) );
526 526
527 connect( mDateNavigator, SIGNAL( goPrevious() ), 527 connect( mDateNavigator, SIGNAL( goPrevious() ),
528 mNavigator, SLOT( selectPrevious() ) ); 528 mNavigator, SLOT( selectPrevious() ) );
529 connect( mDateNavigator, SIGNAL( goNext() ), 529 connect( mDateNavigator, SIGNAL( goNext() ),
530 mNavigator, SLOT( selectNext() ) ); 530 mNavigator, SLOT( selectNext() ) );
531 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 531 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
532 mNavigator, SLOT( slotMonthSelect( int ) ) ); 532 mNavigator, SLOT( slotMonthSelect( int ) ) );
533 533
534 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 534 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
535 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 535 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
536#if 0 536#if 0
537 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 537 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
538 SLOT( incidenceAdded( Incidence *) ) ); 538 SLOT( incidenceAdded( Incidence *) ) );
539#endif 539#endif
540 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 540 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
541 541
542 connect( this, SIGNAL( configChanged() ), 542 connect( this, SIGNAL( configChanged() ),
543 mDateNavigator, SLOT( updateConfig() ) ); 543 mDateNavigator, SLOT( updateConfig() ) );
544 544
545 connect( mTodoList, SIGNAL( newTodoSignal() ), 545 connect( mTodoList, SIGNAL( newTodoSignal() ),
546 SLOT( newTodo() ) ); 546 SLOT( newTodo() ) );
547 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 547 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
548 SLOT( newSubTodo( Todo * ) ) ); 548 SLOT( newSubTodo( Todo * ) ) );
549 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 549 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
550 SLOT( editTodo( Todo * ) ) ); 550 SLOT( editTodo( Todo * ) ) );
551 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 551 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
552 SLOT( showTodo( Todo *) ) ); 552 SLOT( showTodo( Todo *) ) );
553 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 553 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
554 SLOT( deleteTodo( Todo *) ) ); 554 SLOT( deleteTodo( Todo *) ) );
555 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 555 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
556 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 556 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
557 SLOT( purgeCompleted() ) ); 557 SLOT( purgeCompleted() ) );
558 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 558 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
559 SIGNAL( todoModified( Todo *, int ) ) ); 559 SIGNAL( todoModified( Todo *, int ) ) );
560 560
561 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 561 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
562 this, SLOT ( cloneIncidence( Incidence * ) ) ); 562 this, SLOT ( cloneIncidence( Incidence * ) ) );
563 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 563 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
564 this, SLOT (cancelIncidence( Incidence * ) ) ); 564 this, SLOT (cancelIncidence( Incidence * ) ) );
565 565
566 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 566 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
567 this, SLOT ( moveIncidence( Incidence * ) ) ); 567 this, SLOT ( moveIncidence( Incidence * ) ) );
568 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 568 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
569 this, SLOT ( beamIncidence( Incidence * ) ) ); 569 this, SLOT ( beamIncidence( Incidence * ) ) );
570 570
571 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 571 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
572 this, SLOT ( todo_unsub( Todo * ) ) ); 572 this, SLOT ( todo_unsub( Todo * ) ) );
573 573
574 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 574 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
575 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 575 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
576 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 576 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
577 SLOT( updateTodo( Todo *, int ) ) ); 577 SLOT( updateTodo( Todo *, int ) ) );
578 connect( this, SIGNAL( todoModified( Todo *, int )), this, 578 connect( this, SIGNAL( todoModified( Todo *, int )), this,
579 SLOT( changeTodoDisplay( Todo *, int ) ) ); 579 SLOT( changeTodoDisplay( Todo *, int ) ) );
580 580
581 581
582 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 582 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
583 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 583 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
584 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 584 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
585 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 585 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
586 586
587 587
588 588
589 589
590 590
591 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 591 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
592 SLOT(checkClipboard())); 592 SLOT(checkClipboard()));
593 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 593 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
594 SLOT( processTodoListSelection( Incidence * ) ) ); 594 SLOT( processTodoListSelection( Incidence * ) ) );
595 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 595 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
596 596
597 // kdDebug() << "CalendarView::CalendarView() done" << endl; 597 // kdDebug() << "CalendarView::CalendarView() done" << endl;
598 598
599 mDateFrame = new QVBox(0,0,WType_Popup); 599 mDateFrame = new QVBox(0,0,WType_Popup);
600 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 600 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
601 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 601 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
602 mDateFrame->setLineWidth(3); 602 mDateFrame->setLineWidth(3);
603 mDateFrame->hide(); 603 mDateFrame->hide();
604 mDateFrame->setCaption( i18n( "Pick a date to display")); 604 mDateFrame->setCaption( i18n( "Pick a date to display"));
605 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 605 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
606 606
607 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 607 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
608 608
609 mEventEditor = mDialogManager->getEventEditor(); 609 mEventEditor = mDialogManager->getEventEditor();
610 mTodoEditor = mDialogManager->getTodoEditor(); 610 mTodoEditor = mDialogManager->getTodoEditor();
611 611
612 mFlagEditDescription = false; 612 mFlagEditDescription = false;
613 613
614 mSuspendTimer = new QTimer( this ); 614 mSuspendTimer = new QTimer( this );
615 mAlarmTimer = new QTimer( this ); 615 mAlarmTimer = new QTimer( this );
616 mRecheckAlarmTimer = new QTimer( this ); 616 mRecheckAlarmTimer = new QTimer( this );
617 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 617 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
618 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 618 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
619 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 619 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
620 mAlarmDialog = new AlarmDialog( this ); 620 mAlarmDialog = new AlarmDialog( this );
621 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 621 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
622 mAlarmDialog->setServerNotification( false ); 622 mAlarmDialog->setServerNotification( false );
623 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 623 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
624 624
625 625
626#ifndef DESKTOP_VERSION 626#ifndef DESKTOP_VERSION
627//US listen for arriving address resultsets 627//US listen for arriving address resultsets
628 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 628 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
629 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 629 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
630#endif 630#endif
631 mDateNavigator->setCalendar( mCalendar ); 631 mDateNavigator->setCalendar( mCalendar );
632} 632}
633 633
634 634
635CalendarView::~CalendarView() 635CalendarView::~CalendarView()
636{ 636{
637 // kdDebug() << "~CalendarView()" << endl; 637 // kdDebug() << "~CalendarView()" << endl;
638 //qDebug("CalendarView::~CalendarView() "); 638 //qDebug("CalendarView::~CalendarView() ");
639 delete mDialogManager; 639 delete mDialogManager;
640 delete mViewManager; 640 delete mViewManager;
641 delete mStorage; 641 delete mStorage;
642 delete mDateFrame ; 642 delete mDateFrame ;
643 delete beamDialog; 643 delete beamDialog;
644 delete mEventViewerDialog; 644 delete mEventViewerDialog;
645 //kdDebug() << "~CalendarView() done" << endl; 645 //kdDebug() << "~CalendarView() done" << endl;
646} 646}
647void CalendarView::checkAlarms() 647void CalendarView::checkAlarms()
648{ 648{
649 KConfig *config = KOGlobals::config(); 649 KConfig *config = KOGlobals::config();
650 config->setGroup( "AppRun" ); 650 config->setGroup( "AppRun" );
651 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 651 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
652 int daysto = dt.daysTo( QDate::currentDate() ); 652 int daysto = dt.daysTo( QDate::currentDate() );
653 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 653 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
654 dt = dt.addDays( days ); 654 dt = dt.addDays( days );
655 int secto = dt.secsTo( QDateTime::currentDateTime() ); 655 int secto = dt.secsTo( QDateTime::currentDateTime() );
656 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 656 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
657 //qDebug("KO: Reading program stop %d ", secs); 657 //qDebug("KO: Reading program stop %d ", secs);
658 //secs -= ( 3600 * 24*3 ); // debug only 658 //secs -= ( 3600 * 24*3 ); // debug only
659 QDateTime latest = dt.addSecs ( secs ); 659 QDateTime latest = dt.addSecs ( secs );
660 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 660 qDebug("KO: Last termination on %s ", latest.toString().latin1());
661 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 661 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
662 QPtrList<Incidence> el = mCalendar->rawIncidences(); 662 QPtrList<Incidence> el = mCalendar->rawIncidences();
663 QPtrList<Incidence> al; 663 QPtrList<Incidence> al;
664 Incidence* inL = el.first(); 664 Incidence* inL = el.first();
665 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 665 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
666 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 666 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
667 while ( inL ) { 667 while ( inL ) {
668 bool ok = false; 668 bool ok = false;
669 int offset = 0; 669 int offset = 0;
670 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 670 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
671 if ( ok ) { 671 if ( ok ) {
672 //qDebug("OK %s",next.toString().latin1()); 672 //qDebug("OK %s",next.toString().latin1());
673 if ( next < cur ) { 673 if ( next < cur ) {
674 al.append( inL ); 674 al.append( inL );
675 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 675 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
676 } 676 }
677 } 677 }
678 inL = el.next(); 678 inL = el.next();
679 } 679 }
680 if ( al.count() ) { 680 if ( al.count() ) {
681 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 681 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
682 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 682 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
683 QVBoxLayout* lay = new QVBoxLayout( dia ); 683 QVBoxLayout* lay = new QVBoxLayout( dia );
684 lay->setSpacing( 0 ); 684 lay->setSpacing( 0 );
685 lay->setMargin( 0 ); 685 lay->setMargin( 0 );
686 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 686 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
687 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 687 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
688 lay->addWidget( matb ); 688 lay->addWidget( matb );
689 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 689 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
690 int wid = 210; 690 int wid = 210;
691 int x = QApplication::desktop()->width() - wid - 7; 691 int x = QApplication::desktop()->width() - wid - 7;
692 int y = QApplication::desktop()->height() - wid - 70; 692 int y = QApplication::desktop()->height() - wid - 70;
693 dia->setGeometry ( x,y,wid,wid); 693 dia->setGeometry ( x,y,wid,wid);
694 } else { 694 } else {
695 int si = 220; 695 int si = 220;
696 if ( QApplication::desktop()->width() > 470 ) 696 if ( QApplication::desktop()->width() > 470 )
697 si = 400; 697 si = 400;
698 dia->resize(si,si/2); 698 dia->resize(si,si/2);
699 } 699 }
700 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 700 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
701 dia->show(); 701 dia->show();
702 702
703 } 703 }
704} 704}
705void CalendarView::showDay( QDate d ) 705void CalendarView::showDay( QDate d )
706{ 706{
707 dateNavigator()->blockSignals( true ); 707 dateNavigator()->blockSignals( true );
708 dateNavigator()->selectDate( d ); 708 dateNavigator()->selectDate( d );
709 dateNavigator()->blockSignals( false ); 709 dateNavigator()->blockSignals( false );
710 mViewManager->showDayView(); 710 mViewManager->showDayView();
711 //dateNavigator()->selectDate( d ); 711 //dateNavigator()->selectDate( d );
712} 712}
713void CalendarView::timerAlarm() 713void CalendarView::timerAlarm()
714{ 714{
715 //qDebug("CalendarView::timerAlarm() "); 715 //qDebug("CalendarView::timerAlarm() ");
716 computeAlarm(mAlarmNotification ); 716 computeAlarm(mAlarmNotification );
717} 717}
718 718
719void CalendarView::suspendAlarm() 719void CalendarView::suspendAlarm()
720{ 720{
721 //qDebug(" CalendarView::suspendAlarm() "); 721 //qDebug(" CalendarView::suspendAlarm() ");
722 computeAlarm(mSuspendAlarmNotification ); 722 computeAlarm(mSuspendAlarmNotification );
723 723
724} 724}
725 725
726void CalendarView::startAlarm( QString mess , QString filename) 726void CalendarView::startAlarm( QString mess , QString filename)
727{ 727{
728 728
729 topLevelWidget()->showNormal(); 729 topLevelWidget()->showNormal();
730 topLevelWidget()->setActiveWindow(); 730 topLevelWidget()->setActiveWindow();
731 topLevelWidget()->raise(); 731 topLevelWidget()->raise();
732 732
733 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 733 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
734 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 734 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
735 735
736} 736}
737 737
738void CalendarView::checkNextTimerAlarm() 738void CalendarView::checkNextTimerAlarm()
739{ 739{
740 mCalendar->checkAlarmForIncidence( 0, true ); 740 mCalendar->checkAlarmForIncidence( 0, true );
741} 741}
742 742
743void CalendarView::computeAlarm( QString msg ) 743void CalendarView::computeAlarm( QString msg )
744{ 744{
745 745
746 QString mess = msg; 746 QString mess = msg;
747 QString mAlarmMessage = mess.mid( 9 ); 747 QString mAlarmMessage = mess.mid( 9 );
748 QString filename = MainWindow::resourcePath(); 748 QString filename = MainWindow::resourcePath();
749 filename += "koalarm.wav"; 749 filename += "koalarm.wav";
750 QString tempfilename; 750 QString tempfilename;
751 if ( mess.left( 13 ) == "suspend_alarm") { 751 if ( mess.left( 13 ) == "suspend_alarm") {
752 bool error = false; 752 bool error = false;
753 int len = mess.mid( 13 ).find("+++"); 753 int len = mess.mid( 13 ).find("+++");
754 if ( len < 2 ) 754 if ( len < 2 )
755 error = true; 755 error = true;
756 else { 756 else {
757 tempfilename = mess.mid( 13, len ); 757 tempfilename = mess.mid( 13, len );
758 if ( !QFile::exists( tempfilename ) ) 758 if ( !QFile::exists( tempfilename ) )
759 error = true; 759 error = true;
760 } 760 }
761 if ( ! error ) { 761 if ( ! error ) {
762 filename = tempfilename; 762 filename = tempfilename;
763 } 763 }
764 mAlarmMessage = mess.mid( 13+len+3 ); 764 mAlarmMessage = mess.mid( 13+len+3 );
765 //qDebug("suspend file %s ",tempfilename.latin1() ); 765 //qDebug("suspend file %s ",tempfilename.latin1() );
766 startAlarm( mAlarmMessage, filename); 766 startAlarm( mAlarmMessage, filename);
767 return; 767 return;
768 } 768 }
769 if ( mess.left( 11 ) == "timer_alarm") { 769 if ( mess.left( 11 ) == "timer_alarm") {
770 //mTimerTime = 0; 770 //mTimerTime = 0;
771 startAlarm( mess.mid( 11 ), filename ); 771 startAlarm( mess.mid( 11 ), filename );
772 return; 772 return;
773 } 773 }
774 if ( mess.left( 10 ) == "proc_alarm") { 774 if ( mess.left( 10 ) == "proc_alarm") {
775 bool error = false; 775 bool error = false;
776 int len = mess.mid( 10 ).find("+++"); 776 int len = mess.mid( 10 ).find("+++");
777 if ( len < 2 ) 777 if ( len < 2 )
778 error = true; 778 error = true;
779 else { 779 else {
780 tempfilename = mess.mid( 10, len ); 780 tempfilename = mess.mid( 10, len );
781 if ( !QFile::exists( tempfilename ) ) 781 if ( !QFile::exists( tempfilename ) )
782 error = true; 782 error = true;
783 } 783 }
784 if ( error ) { 784 if ( error ) {
785 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 785 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
786 mAlarmMessage += mess.mid( 10+len+3+9 ); 786 mAlarmMessage += mess.mid( 10+len+3+9 );
787 } else { 787 } else {
788 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 788 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
789 //qDebug("-----system command %s ",tempfilename.latin1() ); 789 //qDebug("-----system command %s ",tempfilename.latin1() );
790#ifndef _WIN32_ 790#ifndef _WIN32_
791 if ( vfork () == 0 ) { 791 if ( vfork () == 0 ) {
792 execl ( tempfilename.latin1(), 0 ); 792 execl ( tempfilename.latin1(), 0 );
793 return; 793 return;
794 } 794 }
795#else 795#else
796 QProcess* p = new QProcess(); 796 QProcess* p = new QProcess();
797 p->addArgument( tempfilename.latin1() ); 797 p->addArgument( tempfilename.latin1() );
798 p->start(); 798 p->start();
799 return; 799 return;
800#endif 800#endif
801 801
802 return; 802 return;
803 } 803 }
804 804
805 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 805 //qDebug("+++++++system command %s ",tempfilename.latin1() );
806 } 806 }
807 if ( mess.left( 11 ) == "audio_alarm") { 807 if ( mess.left( 11 ) == "audio_alarm") {
808 bool error = false; 808 bool error = false;
809 int len = mess.mid( 11 ).find("+++"); 809 int len = mess.mid( 11 ).find("+++");
810 if ( len < 2 ) 810 if ( len < 2 )
811 error = true; 811 error = true;
812 else { 812 else {
813 tempfilename = mess.mid( 11, len ); 813 tempfilename = mess.mid( 11, len );
814 if ( !QFile::exists( tempfilename ) ) 814 if ( !QFile::exists( tempfilename ) )
815 error = true; 815 error = true;
816 } 816 }
817 if ( ! error ) { 817 if ( ! error ) {
818 filename = tempfilename; 818 filename = tempfilename;
819 } 819 }
820 mAlarmMessage = mess.mid( 11+len+3+9 ); 820 mAlarmMessage = mess.mid( 11+len+3+9 );
821 //qDebug("audio file command %s ",tempfilename.latin1() ); 821 //qDebug("audio file command %s ",tempfilename.latin1() );
822 } 822 }
823 if ( mess.left( 9 ) == "cal_alarm") { 823 if ( mess.left( 9 ) == "cal_alarm") {
824 mAlarmMessage = mess.mid( 9 ) ; 824 mAlarmMessage = mess.mid( 9 ) ;
825 } 825 }
826 826
827 startAlarm( mAlarmMessage, filename ); 827 startAlarm( mAlarmMessage, filename );
828 828
829 829
830} 830}
831 831
832void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 832void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
833{ 833{
834 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 834 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
835 835
836 mSuspendAlarmNotification = noti; 836 mSuspendAlarmNotification = noti;
837 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 837 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
838 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 838 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
839 mSuspendTimer->start( ms , true ); 839 mSuspendTimer->start( ms , true );
840 840
841} 841}
842 842
843void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 843void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
844{ 844{
845 mNextAlarmDateTime = qdt; 845 mNextAlarmDateTime = qdt;
846 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 846 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
847 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 847 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
848#ifndef DESKTOP_VERSION 848#ifndef DESKTOP_VERSION
849 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 849 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
850#endif 850#endif
851 return; 851 return;
852 } 852 }
853 int maxSec; 853 int maxSec;
854 //maxSec = 5; //testing only 854 //maxSec = 5; //testing only
855 maxSec = 86400+3600; // one day+1hour 855 maxSec = 86400+3600; // one day+1hour
856 mAlarmNotification = noti; 856 mAlarmNotification = noti;
857 int sec = QDateTime::currentDateTime().secsTo( qdt ); 857 int sec = QDateTime::currentDateTime().secsTo( qdt );
858 if ( sec > maxSec ) { 858 if ( sec > maxSec ) {
859 mRecheckAlarmTimer->start( maxSec * 1000 ); 859 mRecheckAlarmTimer->start( maxSec * 1000 );
860 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 860 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
861 return; 861 return;
862 } else { 862 } else {
863 mRecheckAlarmTimer->stop(); 863 mRecheckAlarmTimer->stop();
864 } 864 }
865 //qDebug("Alarm timer started with secs: %d ", sec); 865 //qDebug("Alarm timer started with secs: %d ", sec);
866 mAlarmTimer->start( sec *1000 , true ); 866 mAlarmTimer->start( sec *1000 , true );
867 867
868} 868}
869// called by mRecheckAlarmTimer to get next alarm 869// called by mRecheckAlarmTimer to get next alarm
870// we need this, because a QTimer has only a max range of 25 days 870// we need this, because a QTimer has only a max range of 25 days
871void CalendarView::recheckTimerAlarm() 871void CalendarView::recheckTimerAlarm()
872{ 872{
873 mAlarmTimer->stop(); 873 mAlarmTimer->stop();
874 mRecheckAlarmTimer->stop(); 874 mRecheckAlarmTimer->stop();
875 mCalendar->checkAlarmForIncidence( 0, true ); 875 mCalendar->checkAlarmForIncidence( 0, true );
876} 876}
877void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 877void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
878{ 878{
879 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 879 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
880 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 880 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
881#ifndef DESKTOP_VERSION 881#ifndef DESKTOP_VERSION
882 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 882 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
883#endif 883#endif
884 return; 884 return;
885 } 885 }
886 mAlarmTimer->stop(); 886 mAlarmTimer->stop();
887} 887}
888void CalendarView::selectWeekNum ( int num ) 888void CalendarView::selectWeekNum ( int num )
889{ 889{
890 dateNavigator()->blockSignals( true ); 890 dateNavigator()->blockSignals( true );
891 dateNavigator()->selectWeek( num ); 891 dateNavigator()->selectWeek( num );
892 dateNavigator()->blockSignals( false ); 892 dateNavigator()->blockSignals( false );
893 mViewManager->showWeekView(); 893 mViewManager->showWeekView();
894} 894}
895KOViewManager *CalendarView::viewManager() 895KOViewManager *CalendarView::viewManager()
896{ 896{
897 return mViewManager; 897 return mViewManager;
898} 898}
899 899
900KODialogManager *CalendarView::dialogManager() 900KODialogManager *CalendarView::dialogManager()
901{ 901{
902 return mDialogManager; 902 return mDialogManager;
903} 903}
904 904
905QDate CalendarView::startDate() 905QDate CalendarView::startDate()
906{ 906{
907 DateList dates = mNavigator->selectedDates(); 907 DateList dates = mNavigator->selectedDates();
908 908
909 return dates.first(); 909 return dates.first();
910} 910}
911 911
912QDate CalendarView::endDate() 912QDate CalendarView::endDate()
913{ 913{
914 DateList dates = mNavigator->selectedDates(); 914 DateList dates = mNavigator->selectedDates();
915 915
916 return dates.last(); 916 return dates.last();
917} 917}
918 918
919 919
920void CalendarView::createPrinter() 920void CalendarView::createPrinter()
921{ 921{
922#ifndef KORG_NOPRINTER 922#ifndef KORG_NOPRINTER
923 if (!mCalPrinter) { 923 if (!mCalPrinter) {
924 mCalPrinter = new CalPrinter(this, mCalendar); 924 mCalPrinter = new CalPrinter(this, mCalendar);
925 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 925 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
926 } 926 }
927#endif 927#endif
928} 928}
929 929
930 930
931//KOPrefs::instance()->mWriteBackFile 931//KOPrefs::instance()->mWriteBackFile
932//KOPrefs::instance()->mWriteBackExistingOnly 932//KOPrefs::instance()->mWriteBackExistingOnly
933 933
934// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 934// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
935// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 935// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
936// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 936// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
937// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 937// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
938// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 938// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
939// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 939// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
940 940
941int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 941int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
942{ 942{
943 943
944 // 0 equal 944 // 0 equal
945 // 1 take local 945 // 1 take local
946 // 2 take remote 946 // 2 take remote
947 // 3 cancel 947 // 3 cancel
948 QDateTime lastSync = mLastCalendarSync; 948 QDateTime lastSync = mLastCalendarSync;
949 QDateTime localMod = local->lastModified(); 949 QDateTime localMod = local->lastModified();
950 QDateTime remoteMod = remote->lastModified(); 950 QDateTime remoteMod = remote->lastModified();
951 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 951 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
952 bool remCh, locCh; 952 bool remCh, locCh;
953 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 953 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
954 //if ( remCh ) 954 //if ( remCh )
955 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 955 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
956 locCh = ( localMod > mLastCalendarSync ); 956 locCh = ( localMod > mLastCalendarSync );
957 if ( !remCh && ! locCh ) { 957 if ( !remCh && ! locCh ) {
958 //qDebug("both not changed "); 958 //qDebug("both not changed ");
959 lastSync = localMod.addDays(1); 959 lastSync = localMod.addDays(1);
960 if ( mode <= SYNC_PREF_ASK ) 960 if ( mode <= SYNC_PREF_ASK )
961 return 0; 961 return 0;
962 } else { 962 } else {
963 if ( locCh ) { 963 if ( locCh ) {
964 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 964 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
965 lastSync = localMod.addDays( -1 ); 965 lastSync = localMod.addDays( -1 );
966 if ( !remCh ) 966 if ( !remCh )
967 remoteMod = ( lastSync.addDays( -1 ) ); 967 remoteMod = ( lastSync.addDays( -1 ) );
968 } else { 968 } else {
969 //qDebug(" not loc changed "); 969 //qDebug(" not loc changed ");
970 lastSync = localMod.addDays( 1 ); 970 lastSync = localMod.addDays( 1 );
971 if ( remCh ) 971 if ( remCh )
972 remoteMod =( lastSync.addDays( 1 ) ); 972 remoteMod =( lastSync.addDays( 1 ) );
973 973
974 } 974 }
975 } 975 }
976 full = true; 976 full = true;
977 if ( mode < SYNC_PREF_ASK ) 977 if ( mode < SYNC_PREF_ASK )
978 mode = SYNC_PREF_ASK; 978 mode = SYNC_PREF_ASK;
979 } else { 979 } else {
980 if ( localMod == remoteMod ) 980 if ( localMod == remoteMod )
981 // if ( local->revision() == remote->revision() ) 981 // if ( local->revision() == remote->revision() )
982 return 0; 982 return 0;
983 983
984 } 984 }
985 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 985 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
986 986
987 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 987 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
988 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 988 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
989 //full = true; //debug only 989 //full = true; //debug only
990 if ( full ) { 990 if ( full ) {
991 bool equ = false; 991 bool equ = false;
992 if ( local->typeID() == eventID ) { 992 if ( local->typeID() == eventID ) {
993 equ = (*((Event*) local) == *((Event*) remote)); 993 equ = (*((Event*) local) == *((Event*) remote));
994 } 994 }
995 else if ( local->typeID() == todoID ) 995 else if ( local->typeID() == todoID )
996 equ = (*((Todo*) local) == (*(Todo*) remote)); 996 equ = (*((Todo*) local) == (*(Todo*) remote));
997 else if ( local->typeID() == journalID ) 997 else if ( local->typeID() == journalID )
998 equ = (*((Journal*) local) == *((Journal*) remote)); 998 equ = (*((Journal*) local) == *((Journal*) remote));
999 if ( equ ) { 999 if ( equ ) {
1000 //qDebug("equal "); 1000 //qDebug("equal ");
1001 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1001 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1002 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1002 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1003 } 1003 }
1004 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1004 if ( mode < SYNC_PREF_FORCE_LOCAL )
1005 return 0; 1005 return 0;
1006 1006
1007 }//else //debug only 1007 }//else //debug only
1008 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1008 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1009 } 1009 }
1010 int result; 1010 int result;
1011 bool localIsNew; 1011 bool localIsNew;
1012 //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() ); 1012 //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() );
1013 1013
1014 1014
1015 // ************************************************ 1015 // ************************************************
1016 // ************************************************ 1016 // ************************************************
1017 // ************************************************ 1017 // ************************************************
1018 // We may have that lastSync > remoteMod AND lastSync > localMod 1018 // We may have that lastSync > remoteMod AND lastSync > localMod
1019 // BUT remoteMod != localMod 1019 // BUT remoteMod != localMod
1020 1020
1021 1021
1022 if ( full && mode < SYNC_PREF_NEWEST ) 1022 if ( full && mode < SYNC_PREF_NEWEST )
1023 mode = SYNC_PREF_ASK; 1023 mode = SYNC_PREF_ASK;
1024 1024
1025 switch( mode ) { 1025 switch( mode ) {
1026 case SYNC_PREF_LOCAL: 1026 case SYNC_PREF_LOCAL:
1027 if ( lastSync > remoteMod ) 1027 if ( lastSync > remoteMod )
1028 return 1; 1028 return 1;
1029 if ( lastSync > localMod ) 1029 if ( lastSync > localMod )
1030 return 2; 1030 return 2;
1031 return 1; 1031 return 1;
1032 break; 1032 break;
1033 case SYNC_PREF_REMOTE: 1033 case SYNC_PREF_REMOTE:
1034 if ( lastSync > localMod ) 1034 if ( lastSync > localMod )
1035 return 2; 1035 return 2;
1036 if ( lastSync > remoteMod ) 1036 if ( lastSync > remoteMod )
1037 return 1; 1037 return 1;
1038 return 2; 1038 return 2;
1039 break; 1039 break;
1040 case SYNC_PREF_NEWEST: 1040 case SYNC_PREF_NEWEST:
1041 if ( localMod >= remoteMod ) 1041 if ( localMod >= remoteMod )
1042 return 1; 1042 return 1;
1043 else 1043 else
1044 return 2; 1044 return 2;
1045 break; 1045 break;
1046 case SYNC_PREF_ASK: 1046 case SYNC_PREF_ASK:
1047 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1047 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1048 if ( lastSync > remoteMod && lastSync > localMod) 1048 if ( lastSync > remoteMod && lastSync > localMod)
1049 return 0; 1049 return 0;
1050 if ( lastSync > remoteMod ) 1050 if ( lastSync > remoteMod )
1051 return 1; 1051 return 1;
1052 if ( lastSync > localMod ) 1052 if ( lastSync > localMod )
1053 return 2; 1053 return 2;
1054 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1054 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1055 localIsNew = localMod >= remoteMod; 1055 localIsNew = localMod >= remoteMod;
1056 if ( localIsNew ) 1056 if ( localIsNew )
1057 getEventViewerDialog()->setColorMode( 1 ); 1057 getEventViewerDialog()->setColorMode( 1 );
1058 else 1058 else
1059 getEventViewerDialog()->setColorMode( 2 ); 1059 getEventViewerDialog()->setColorMode( 2 );
1060 getEventViewerDialog()->setIncidence(local); 1060 getEventViewerDialog()->setIncidence(local);
1061 if ( localIsNew ) 1061 if ( localIsNew )
1062 getEventViewerDialog()->setColorMode( 2 ); 1062 getEventViewerDialog()->setColorMode( 2 );
1063 else 1063 else
1064 getEventViewerDialog()->setColorMode( 1 ); 1064 getEventViewerDialog()->setColorMode( 1 );
1065 getEventViewerDialog()->addIncidence(remote); 1065 getEventViewerDialog()->addIncidence(remote);
1066 getEventViewerDialog()->setColorMode( 0 ); 1066 getEventViewerDialog()->setColorMode( 0 );
1067 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1067 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1068 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1068 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1069 getEventViewerDialog()->showMe(); 1069 getEventViewerDialog()->showMe();
1070 result = getEventViewerDialog()->executeS( localIsNew ); 1070 result = getEventViewerDialog()->executeS( localIsNew );
1071 return result; 1071 return result;
1072 1072
1073 break; 1073 break;
1074 case SYNC_PREF_FORCE_LOCAL: 1074 case SYNC_PREF_FORCE_LOCAL:
1075 return 1; 1075 return 1;
1076 break; 1076 break;
1077 case SYNC_PREF_FORCE_REMOTE: 1077 case SYNC_PREF_FORCE_REMOTE:
1078 return 2; 1078 return 2;
1079 break; 1079 break;
1080 1080
1081 default: 1081 default:
1082 // SYNC_PREF_TAKE_BOTH not implemented 1082 // SYNC_PREF_TAKE_BOTH not implemented
1083 break; 1083 break;
1084 } 1084 }
1085 return 0; 1085 return 0;
1086} 1086}
1087Event* CalendarView::getLastSyncEvent() 1087Event* CalendarView::getLastSyncEvent()
1088{ 1088{
1089 Event* lse; 1089 Event* lse;
1090 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1090 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1091 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1091 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1092 if (!lse) { 1092 if (!lse) {
1093 lse = new Event(); 1093 lse = new Event();
1094 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1094 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1095 QString sum = ""; 1095 QString sum = "";
1096 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1096 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1097 sum = "E: "; 1097 sum = "E: ";
1098 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1098 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1099 lse->setDtStart( mLastCalendarSync ); 1099 lse->setDtStart( mLastCalendarSync );
1100 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1100 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1101 lse->setCategories( i18n("SyncEvent") ); 1101 lse->setCategories( i18n("SyncEvent") );
1102 lse->setReadOnly( true ); 1102 lse->setReadOnly( true );
1103 mCalendar->addEvent( lse ); 1103 mCalendar->addEvent( lse );
1104 } 1104 }
1105 1105
1106 return lse; 1106 return lse;
1107 1107
1108} 1108}
1109 1109
1110// we check, if the to delete event has a id for a profile 1110// we check, if the to delete event has a id for a profile
1111// if yes, we set this id in the profile to delete 1111// if yes, we set this id in the profile to delete
1112void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1112void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1113{ 1113{
1114 if ( lastSync.count() == 0 ) { 1114 if ( lastSync.count() == 0 ) {
1115 //qDebug(" lastSync.count() == 0"); 1115 //qDebug(" lastSync.count() == 0");
1116 return; 1116 return;
1117 } 1117 }
1118 if ( toDelete->typeID() == journalID ) 1118 if ( toDelete->typeID() == journalID )
1119 return; 1119 return;
1120 1120
1121 Event* eve = lastSync.first(); 1121 Event* eve = lastSync.first();
1122 1122
1123 while ( eve ) { 1123 while ( eve ) {
1124 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1124 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1125 if ( !id.isEmpty() ) { 1125 if ( !id.isEmpty() ) {
1126 QString des = eve->description(); 1126 QString des = eve->description();
1127 QString pref = "e"; 1127 QString pref = "e";
1128 if ( toDelete->typeID() == todoID ) 1128 if ( toDelete->typeID() == todoID )
1129 pref = "t"; 1129 pref = "t";
1130 des += pref+ id + ","; 1130 des += pref+ id + ",";
1131 eve->setReadOnly( false ); 1131 eve->setReadOnly( false );
1132 eve->setDescription( des ); 1132 eve->setDescription( des );
1133 //qDebug("setdes %s ", des.latin1()); 1133 //qDebug("setdes %s ", des.latin1());
1134 eve->setReadOnly( true ); 1134 eve->setReadOnly( true );
1135 } 1135 }
1136 eve = lastSync.next(); 1136 eve = lastSync.next();
1137 } 1137 }
1138 1138
1139} 1139}
1140void CalendarView::checkExternalId( Incidence * inc ) 1140void CalendarView::checkExternalId( Incidence * inc )
1141{ 1141{
1142 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1142 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1143 checkExternSyncEvent( lastSync, inc ); 1143 checkExternSyncEvent( lastSync, inc );
1144 1144
1145} 1145}
1146bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1146bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1147{ 1147{
1148 bool syncOK = true; 1148 bool syncOK = true;
1149 int addedEvent = 0; 1149 int addedEvent = 0;
1150 int addedEventR = 0; 1150 int addedEventR = 0;
1151 int deletedEventR = 0; 1151 int deletedEventR = 0;
1152 int deletedEventL = 0; 1152 int deletedEventL = 0;
1153 int changedLocal = 0; 1153 int changedLocal = 0;
1154 int changedRemote = 0; 1154 int changedRemote = 0;
1155 int filteredIN = 0; 1155 int filteredIN = 0;
1156 int filteredOUT = 0; 1156 int filteredOUT = 0;
1157 //QPtrList<Event> el = local->rawEvents(); 1157 //QPtrList<Event> el = local->rawEvents();
1158 Event* eventR; 1158 Event* eventR;
1159 QString uid; 1159 QString uid;
1160 int take; 1160 int take;
1161 Event* eventL; 1161 Event* eventL;
1162 Event* eventRSync; 1162 Event* eventRSync;
1163 Event* eventLSync; 1163 Event* eventLSync;
1164 clearAllViews(); 1164 clearAllViews();
1165 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1165 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1166 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1166 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1167 bool fullDateRange = false; 1167 bool fullDateRange = false;
1168 local->resetTempSyncStat(); 1168 local->resetTempSyncStat();
1169 mLastCalendarSync = QDateTime::currentDateTime(); 1169 mLastCalendarSync = QDateTime::currentDateTime();
1170 if ( mSyncManager->syncWithDesktop() ) { 1170 if ( mSyncManager->syncWithDesktop() ) {
1171 remote->resetPilotStat(1); 1171 remote->resetPilotStat(1);
1172 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1172 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1173 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1173 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1174 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1174 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1175 } else { 1175 } else {
1176 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1176 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1177 } 1177 }
1178 } 1178 }
1179 QDateTime modifiedCalendar = mLastCalendarSync; 1179 QDateTime modifiedCalendar = mLastCalendarSync;
1180 eventLSync = getLastSyncEvent(); 1180 eventLSync = getLastSyncEvent();
1181 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1181 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1182 if ( eventR ) { 1182 if ( eventR ) {
1183 eventRSync = (Event*) eventR->clone(); 1183 eventRSync = (Event*) eventR->clone();
1184 remote->deleteEvent(eventR ); 1184 remote->deleteEvent(eventR );
1185 1185
1186 } else { 1186 } else {
1187 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1187 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1188 eventRSync = (Event*)eventLSync->clone(); 1188 eventRSync = (Event*)eventLSync->clone();
1189 } else { 1189 } else {
1190 fullDateRange = true; 1190 fullDateRange = true;
1191 eventRSync = new Event(); 1191 eventRSync = new Event();
1192 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1192 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1193 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1193 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1194 eventRSync->setDtStart( mLastCalendarSync ); 1194 eventRSync->setDtStart( mLastCalendarSync );
1195 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1195 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1196 eventRSync->setCategories( i18n("SyncEvent") ); 1196 eventRSync->setCategories( i18n("SyncEvent") );
1197 } 1197 }
1198 } 1198 }
1199 if ( eventLSync->dtStart() == mLastCalendarSync ) 1199 if ( eventLSync->dtStart() == mLastCalendarSync )
1200 fullDateRange = true; 1200 fullDateRange = true;
1201 1201
1202 if ( ! fullDateRange ) { 1202 if ( ! fullDateRange ) {
1203 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1203 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1204 1204
1205 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1205 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1206 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1206 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1207 fullDateRange = true; 1207 fullDateRange = true;
1208 } 1208 }
1209 } 1209 }
1210 if ( mSyncManager->syncWithDesktop() ) { 1210 if ( mSyncManager->syncWithDesktop() ) {
1211 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1211 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1212 } 1212 }
1213 if ( fullDateRange ) 1213 if ( fullDateRange )
1214 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1214 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1215 else 1215 else
1216 mLastCalendarSync = eventLSync->dtStart(); 1216 mLastCalendarSync = eventLSync->dtStart();
1217 // for resyncing if own file has changed 1217 // for resyncing if own file has changed
1218 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1218 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1219 mLastCalendarSync = loadedFileVersion; 1219 mLastCalendarSync = loadedFileVersion;
1220 //qDebug("setting mLastCalendarSync "); 1220 //qDebug("setting mLastCalendarSync ");
1221 } 1221 }
1222 //qDebug("*************************** "); 1222 //qDebug("*************************** ");
1223 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1223 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1224 QPtrList<Incidence> er = remote->rawIncidences(); 1224 QPtrList<Incidence> er = remote->rawIncidences();
1225 Incidence* inR = er.first(); 1225 Incidence* inR = er.first();
1226 Incidence* inL; 1226 Incidence* inL;
1227 QProgressBar bar( er.count(),0 ); 1227 QProgressBar bar( er.count(),0 );
1228 bar.setCaption (i18n("Syncing - close to abort!") ); 1228 bar.setCaption (i18n("Syncing - close to abort!") );
1229 1229
1230 // ************** setting up filter ************* 1230 // ************** setting up filter *************
1231 CalFilter *filterIN = 0; 1231 CalFilter *filterIN = 0;
1232 CalFilter *filterOUT = 0; 1232 CalFilter *filterOUT = 0;
1233 CalFilter *filter = mFilters.first(); 1233 CalFilter *filter = mFilters.first();
1234 while(filter) { 1234 while(filter) {
1235 if ( filter->name() == mSyncManager->mFilterInCal ) 1235 if ( filter->name() == mSyncManager->mFilterInCal )
1236 filterIN = filter; 1236 filterIN = filter;
1237 if ( filter->name() == mSyncManager->mFilterOutCal ) 1237 if ( filter->name() == mSyncManager->mFilterOutCal )
1238 filterOUT = filter; 1238 filterOUT = filter;
1239 filter = mFilters.next(); 1239 filter = mFilters.next();
1240 } 1240 }
1241 int w = 300; 1241 int w = 300;
1242 if ( QApplication::desktop()->width() < 320 ) 1242 if ( QApplication::desktop()->width() < 320 )
1243 w = 220; 1243 w = 220;
1244 int h = bar.sizeHint().height() ; 1244 int h = bar.sizeHint().height() ;
1245 int dw = QApplication::desktop()->width(); 1245 int dw = QApplication::desktop()->width();
1246 int dh = QApplication::desktop()->height(); 1246 int dh = QApplication::desktop()->height();
1247 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1247 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1248 bar.show(); 1248 bar.show();
1249 int modulo = (er.count()/10)+1; 1249 int modulo = (er.count()/10)+1;
1250 int incCounter = 0; 1250 int incCounter = 0;
1251 while ( inR ) { 1251 while ( inR ) {
1252 if ( ! bar.isVisible() ) 1252 if ( ! bar.isVisible() )
1253 return false; 1253 return false;
1254 if ( incCounter % modulo == 0 ) 1254 if ( incCounter % modulo == 0 )
1255 bar.setProgress( incCounter ); 1255 bar.setProgress( incCounter );
1256 ++incCounter; 1256 ++incCounter;
1257 uid = inR->uid(); 1257 uid = inR->uid();
1258 bool skipIncidence = false; 1258 bool skipIncidence = false;
1259 if ( uid.left(15) == QString("last-syncEvent-") ) 1259 if ( uid.left(15) == QString("last-syncEvent-") )
1260 skipIncidence = true; 1260 skipIncidence = true;
1261 QString idS; 1261 QString idS;
1262 qApp->processEvents(); 1262 qApp->processEvents();
1263 if ( !skipIncidence ) { 1263 if ( !skipIncidence ) {
1264 inL = local->incidence( uid ); 1264 inL = local->incidence( uid );
1265 if ( inL ) { // maybe conflict - same uid in both calendars 1265 if ( inL ) { // maybe conflict - same uid in both calendars
1266 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1266 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1267 //qDebug("take %d %s ", take, inL->summary().latin1()); 1267 //qDebug("take %d %s ", take, inL->summary().latin1());
1268 if ( take == 3 ) 1268 if ( take == 3 )
1269 return false; 1269 return false;
1270 if ( take == 1 ) {// take local ********************** 1270 if ( take == 1 ) {// take local **********************
1271 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1271 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1272 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1272 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1273 else 1273 else
1274 idS = inR->IDStr(); 1274 idS = inR->IDStr();
1275 remote->deleteIncidence( inR ); 1275 remote->deleteIncidence( inR );
1276 inR = inL->clone(); 1276 inR = inL->clone();
1277 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1277 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1278 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1278 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1279 inR->setIDStr( idS ); 1279 inR->setIDStr( idS );
1280 remote->addIncidence( inR ); 1280 remote->addIncidence( inR );
1281 if ( mSyncManager->syncWithDesktop() ) 1281 if ( mSyncManager->syncWithDesktop() )
1282 inR->setPilotId( 2 ); 1282 inR->setPilotId( 2 );
1283 ++changedRemote; 1283 ++changedRemote;
1284 } else {// take remote ********************** 1284 } else {// take remote **********************
1285 idS = inL->IDStr(); 1285 idS = inL->IDStr();
1286 int pid = inL->pilotId(); 1286 int pid = inL->pilotId();
1287 local->deleteIncidence( inL ); 1287 local->deleteIncidence( inL );
1288 inL = inR->clone(); 1288 inL = inR->clone();
1289 if ( mSyncManager->syncWithDesktop() ) 1289 if ( mSyncManager->syncWithDesktop() )
1290 inL->setPilotId( pid ); 1290 inL->setPilotId( pid );
1291 inL->setIDStr( idS ); 1291 inL->setIDStr( idS );
1292 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1292 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1293 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1293 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1294 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1294 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1295 } 1295 }
1296 local->addIncidence( inL ); 1296 local->addIncidence( inL );
1297 ++changedLocal; 1297 ++changedLocal;
1298 } 1298 }
1299 } 1299 }
1300 } else { // no conflict ********** add or delete remote 1300 } else { // no conflict ********** add or delete remote
1301 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1301 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1302 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1302 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1303 QString des = eventLSync->description(); 1303 QString des = eventLSync->description();
1304 QString pref = "e"; 1304 QString pref = "e";
1305 if ( inR->typeID() == todoID ) 1305 if ( inR->typeID() == todoID )
1306 pref = "t"; 1306 pref = "t";
1307 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1307 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1308 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1308 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1309 //remote->deleteIncidence( inR ); 1309 //remote->deleteIncidence( inR );
1310 ++deletedEventR; 1310 ++deletedEventR;
1311 } else { 1311 } else {
1312 inR->setLastModified( modifiedCalendar ); 1312 inR->setLastModified( modifiedCalendar );
1313 inL = inR->clone(); 1313 inL = inR->clone();
1314 inL->setIDStr( ":" ); 1314 inL->setIDStr( ":" );
1315 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1315 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1316 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1316 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1317 local->addIncidence( inL ); 1317 local->addIncidence( inL );
1318 ++addedEvent; 1318 ++addedEvent;
1319 1319
1320 } 1320 }
1321 } else { 1321 } else {
1322 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1322 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1323 inR->setLastModified( modifiedCalendar ); 1323 inR->setLastModified( modifiedCalendar );
1324 inL = inR->clone(); 1324 inL = inR->clone();
1325 inL->setIDStr( ":" ); 1325 inL->setIDStr( ":" );
1326 local->addIncidence( inL ); 1326 local->addIncidence( inL );
1327 ++addedEvent; 1327 ++addedEvent;
1328 1328
1329 } else { 1329 } else {
1330 checkExternSyncEvent(eventRSyncSharp, inR); 1330 checkExternSyncEvent(eventRSyncSharp, inR);
1331 remote->deleteIncidence( inR ); 1331 remote->deleteIncidence( inR );
1332 ++deletedEventR; 1332 ++deletedEventR;
1333 } 1333 }
1334 } 1334 }
1335 } else { 1335 } else {
1336 ++filteredIN; 1336 ++filteredIN;
1337 } 1337 }
1338 } 1338 }
1339 } 1339 }
1340 inR = er.next(); 1340 inR = er.next();
1341 } 1341 }
1342 QPtrList<Incidence> el = local->rawIncidences(); 1342 QPtrList<Incidence> el = local->rawIncidences();
1343 inL = el.first(); 1343 inL = el.first();
1344 modulo = (el.count()/10)+1; 1344 modulo = (el.count()/10)+1;
1345 bar.setCaption (i18n("Add / remove events") ); 1345 bar.setCaption (i18n("Add / remove events") );
1346 bar.setTotalSteps ( el.count() ) ; 1346 bar.setTotalSteps ( el.count() ) ;
1347 bar.show(); 1347 bar.show();
1348 incCounter = 0; 1348 incCounter = 0;
1349 1349
1350 while ( inL ) { 1350 while ( inL ) {
1351 1351
1352 qApp->processEvents(); 1352 qApp->processEvents();
1353 if ( ! bar.isVisible() ) 1353 if ( ! bar.isVisible() )
1354 return false; 1354 return false;
1355 if ( incCounter % modulo == 0 ) 1355 if ( incCounter % modulo == 0 )
1356 bar.setProgress( incCounter ); 1356 bar.setProgress( incCounter );
1357 ++incCounter; 1357 ++incCounter;
1358 uid = inL->uid(); 1358 uid = inL->uid();
1359 bool skipIncidence = false; 1359 bool skipIncidence = false;
1360 if ( uid.left(15) == QString("last-syncEvent-") ) 1360 if ( uid.left(15) == QString("last-syncEvent-") )
1361 skipIncidence = true; 1361 skipIncidence = true;
1362 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1362 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1363 skipIncidence = true; 1363 skipIncidence = true;
1364 if ( !skipIncidence ) { 1364 if ( !skipIncidence ) {
1365 inR = remote->incidence( uid ); 1365 inR = remote->incidence( uid );
1366 if ( ! inR ) { 1366 if ( ! inR ) {
1367 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1367 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1368 // no conflict ********** add or delete local 1368 // no conflict ********** add or delete local
1369 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1369 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1370 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1370 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1371 checkExternSyncEvent(eventLSyncSharp, inL); 1371 checkExternSyncEvent(eventLSyncSharp, inL);
1372 local->deleteIncidence( inL ); 1372 local->deleteIncidence( inL );
1373 ++deletedEventL; 1373 ++deletedEventL;
1374 } else { 1374 } else {
1375 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1375 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1376 inL->removeID(mCurrentSyncDevice ); 1376 inL->removeID(mCurrentSyncDevice );
1377 ++addedEventR; 1377 ++addedEventR;
1378 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1378 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1379 inL->setLastModified( modifiedCalendar ); 1379 inL->setLastModified( modifiedCalendar );
1380 inR = inL->clone(); 1380 inR = inL->clone();
1381 inR->setIDStr( ":" ); 1381 inR->setIDStr( ":" );
1382 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1382 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1383 remote->addIncidence( inR ); 1383 remote->addIncidence( inR );
1384 } 1384 }
1385 } 1385 }
1386 } else { 1386 } else {
1387 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1387 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1388 checkExternSyncEvent(eventLSyncSharp, inL); 1388 checkExternSyncEvent(eventLSyncSharp, inL);
1389 local->deleteIncidence( inL ); 1389 local->deleteIncidence( inL );
1390 ++deletedEventL; 1390 ++deletedEventL;
1391 } else { 1391 } else {
1392 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1392 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1393 ++addedEventR; 1393 ++addedEventR;
1394 inL->setLastModified( modifiedCalendar ); 1394 inL->setLastModified( modifiedCalendar );
1395 inR = inL->clone(); 1395 inR = inL->clone();
1396 inR->setIDStr( ":" ); 1396 inR->setIDStr( ":" );
1397 remote->addIncidence( inR ); 1397 remote->addIncidence( inR );
1398 } 1398 }
1399 } 1399 }
1400 } 1400 }
1401 } else { 1401 } else {
1402 ++filteredOUT; 1402 ++filteredOUT;
1403 } 1403 }
1404 } 1404 }
1405 } 1405 }
1406 inL = el.next(); 1406 inL = el.next();
1407 } 1407 }
1408 int delFut = 0; 1408 int delFut = 0;
1409 int remRem = 0; 1409 int remRem = 0;
1410 if ( mSyncManager->mWriteBackInFuture ) { 1410 if ( mSyncManager->mWriteBackInFuture ) {
1411 er = remote->rawIncidences(); 1411 er = remote->rawIncidences();
1412 remRem = er.count(); 1412 remRem = er.count();
1413 inR = er.first(); 1413 inR = er.first();
1414 QDateTime dt; 1414 QDateTime dt;
1415 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1415 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1416 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1416 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1417 while ( inR ) { 1417 while ( inR ) {
1418 if ( inR->typeID() == todoID ) { 1418 if ( inR->typeID() == todoID ) {
1419 Todo * t = (Todo*)inR; 1419 Todo * t = (Todo*)inR;
1420 if ( t->hasDueDate() ) 1420 if ( t->hasDueDate() )
1421 dt = t->dtDue(); 1421 dt = t->dtDue();
1422 else 1422 else
1423 dt = cur.addSecs( 62 ); 1423 dt = cur.addSecs( 62 );
1424 } 1424 }
1425 else if (inR->typeID() == eventID ) { 1425 else if (inR->typeID() == eventID ) {
1426 bool ok; 1426 bool ok;
1427 dt = inR->getNextOccurence( cur, &ok ); 1427 dt = inR->getNextOccurence( cur, &ok );
1428 if ( !ok ) 1428 if ( !ok )
1429 dt = cur.addSecs( -62 ); 1429 dt = cur.addSecs( -62 );
1430 } 1430 }
1431 else 1431 else
1432 dt = inR->dtStart(); 1432 dt = inR->dtStart();
1433 if ( dt < cur || dt > end ) { 1433 if ( dt < cur || dt > end ) {
1434 remote->deleteIncidence( inR ); 1434 remote->deleteIncidence( inR );
1435 ++delFut; 1435 ++delFut;
1436 } 1436 }
1437 inR = er.next(); 1437 inR = er.next();
1438 } 1438 }
1439 } 1439 }
1440 bar.hide(); 1440 bar.hide();
1441 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1441 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1442 eventLSync->setReadOnly( false ); 1442 eventLSync->setReadOnly( false );
1443 eventLSync->setDtStart( mLastCalendarSync ); 1443 eventLSync->setDtStart( mLastCalendarSync );
1444 eventRSync->setDtStart( mLastCalendarSync ); 1444 eventRSync->setDtStart( mLastCalendarSync );
1445 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1445 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1446 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1446 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1447 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1447 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1448 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1448 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1449 eventLSync->setReadOnly( true ); 1449 eventLSync->setReadOnly( true );
1450 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1450 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1451 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1451 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1452 remote->addEvent( eventRSync ); 1452 remote->addEvent( eventRSync );
1453 else 1453 else
1454 delete eventRSync; 1454 delete eventRSync;
1455 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1455 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1456 QString mes; 1456 QString mes;
1457 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 ); 1457 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 );
1458 QString delmess; 1458 QString delmess;
1459 if ( delFut ) { 1459 if ( delFut ) {
1460 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); 1460 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);
1461 mes += delmess; 1461 mes += delmess;
1462 } 1462 }
1463 mes = i18n("Local calendar changed!\n") +mes; 1463 mes = i18n("Local calendar changed!\n") +mes;
1464 mCalendar->checkAlarmForIncidence( 0, true ); 1464 mCalendar->checkAlarmForIncidence( 0, true );
1465 qDebug( mes ); 1465 qDebug( mes );
1466 if ( mSyncManager->mShowSyncSummary ) { 1466 if ( mSyncManager->mShowSyncSummary ) {
1467 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1467 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1468 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1468 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1469 qDebug("KO: WB cancelled "); 1469 qDebug("KO: WB cancelled ");
1470 mSyncManager->mWriteBackFile = false; 1470 mSyncManager->mWriteBackFile = false;
1471 return syncOK; 1471 return syncOK;
1472 } 1472 }
1473 } 1473 }
1474 return syncOK; 1474 return syncOK;
1475} 1475}
1476 1476
1477void CalendarView::setSyncDevice( QString s ) 1477void CalendarView::setSyncDevice( QString s )
1478{ 1478{
1479 mCurrentSyncDevice= s; 1479 mCurrentSyncDevice= s;
1480} 1480}
1481void CalendarView::setSyncName( QString s ) 1481void CalendarView::setSyncName( QString s )
1482{ 1482{
1483 mCurrentSyncName= s; 1483 mCurrentSyncName= s;
1484} 1484}
1485bool CalendarView::syncCalendar(QString filename, int mode) 1485bool CalendarView::syncCalendar(QString filename, int mode)
1486{ 1486{
1487 //qDebug("syncCalendar %s ", filename.latin1()); 1487 //qDebug("syncCalendar %s ", filename.latin1());
1488 mGlobalSyncMode = SYNC_MODE_NORMAL; 1488 mGlobalSyncMode = SYNC_MODE_NORMAL;
1489 CalendarLocal* calendar = new CalendarLocal(); 1489 CalendarLocal* calendar = new CalendarLocal();
1490 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1490 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1491 FileStorage* storage = new FileStorage( calendar ); 1491 FileStorage* storage = new FileStorage( calendar );
1492 bool syncOK = false; 1492 bool syncOK = false;
1493 storage->setFileName( filename ); 1493 storage->setFileName( filename );
1494 // qDebug("loading ... "); 1494 // qDebug("loading ... ");
1495 if ( storage->load() ) { 1495 if ( storage->load() ) {
1496 getEventViewerDialog()->setSyncMode( true ); 1496 getEventViewerDialog()->setSyncMode( true );
1497 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1497 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1498 getEventViewerDialog()->setSyncMode( false ); 1498 getEventViewerDialog()->setSyncMode( false );
1499 if ( syncOK ) { 1499 if ( syncOK ) {
1500 if ( mSyncManager->mWriteBackFile ) 1500 if ( mSyncManager->mWriteBackFile )
1501 { 1501 {
1502 storage->setSaveFormat( new ICalFormat() ); 1502 storage->setSaveFormat( new ICalFormat() );
1503 storage->save(); 1503 storage->save();
1504 } 1504 }
1505 } 1505 }
1506 setModified( true ); 1506 setModified( true );
1507 } 1507 }
1508 delete storage; 1508 delete storage;
1509 delete calendar; 1509 delete calendar;
1510 if ( syncOK ) 1510 if ( syncOK )
1511 updateView(); 1511 updateView();
1512 return syncOK; 1512 return syncOK;
1513} 1513}
1514 1514
1515void CalendarView::syncExternal( int mode ) 1515void CalendarView::syncExternal( int mode )
1516{ 1516{
1517 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1517 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1518 1518
1519 qApp->processEvents(); 1519 qApp->processEvents();
1520 CalendarLocal* calendar = new CalendarLocal(); 1520 CalendarLocal* calendar = new CalendarLocal();
1521 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1521 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1522 bool syncOK = false; 1522 bool syncOK = false;
1523 bool loadSuccess = false; 1523 bool loadSuccess = false;
1524 PhoneFormat* phoneFormat = 0; 1524 PhoneFormat* phoneFormat = 0;
1525 emit tempDisableBR(true); 1525 emit tempDisableBR(true);
1526#ifndef DESKTOP_VERSION 1526#ifndef DESKTOP_VERSION
1527 SharpFormat* sharpFormat = 0; 1527 SharpFormat* sharpFormat = 0;
1528 if ( mode == 0 ) { // sharp 1528 if ( mode == 0 ) { // sharp
1529 sharpFormat = new SharpFormat () ; 1529 sharpFormat = new SharpFormat () ;
1530 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1530 loadSuccess = sharpFormat->load( calendar, mCalendar );
1531 1531
1532 } else 1532 } else
1533#endif 1533#endif
1534 if ( mode == 1 ) { // phone 1534 if ( mode == 1 ) { // phone
1535 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1535 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1536 mSyncManager->mPhoneDevice, 1536 mSyncManager->mPhoneDevice,
1537 mSyncManager->mPhoneConnection, 1537 mSyncManager->mPhoneConnection,
1538 mSyncManager->mPhoneModel); 1538 mSyncManager->mPhoneModel);
1539 loadSuccess = phoneFormat->load( calendar,mCalendar); 1539 loadSuccess = phoneFormat->load( calendar,mCalendar);
1540 1540
1541 } else { 1541 } else {
1542 emit tempDisableBR(false); 1542 emit tempDisableBR(false);
1543 return; 1543 return;
1544 } 1544 }
1545 if ( loadSuccess ) { 1545 if ( loadSuccess ) {
1546 getEventViewerDialog()->setSyncMode( true ); 1546 getEventViewerDialog()->setSyncMode( true );
1547 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1547 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1548 getEventViewerDialog()->setSyncMode( false ); 1548 getEventViewerDialog()->setSyncMode( false );
1549 qApp->processEvents(); 1549 qApp->processEvents();
1550 if ( syncOK ) { 1550 if ( syncOK ) {
1551 if ( mSyncManager->mWriteBackFile ) 1551 if ( mSyncManager->mWriteBackFile )
1552 { 1552 {
1553 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1553 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1554 Incidence* inc = iL.first(); 1554 Incidence* inc = iL.first();
1555 if ( phoneFormat ) { 1555 if ( phoneFormat ) {
1556 while ( inc ) { 1556 while ( inc ) {
1557 inc->removeID(mCurrentSyncDevice); 1557 inc->removeID(mCurrentSyncDevice);
1558 inc = iL.next(); 1558 inc = iL.next();
1559 } 1559 }
1560 } 1560 }
1561#ifndef DESKTOP_VERSION 1561#ifndef DESKTOP_VERSION
1562 if ( sharpFormat ) 1562 if ( sharpFormat )
1563 sharpFormat->save(calendar); 1563 sharpFormat->save(calendar);
1564#endif 1564#endif
1565 if ( phoneFormat ) 1565 if ( phoneFormat )
1566 phoneFormat->save(calendar); 1566 phoneFormat->save(calendar);
1567 iL = calendar->rawIncidences(); 1567 iL = calendar->rawIncidences();
1568 inc = iL.first(); 1568 inc = iL.first();
1569 Incidence* loc; 1569 Incidence* loc;
1570 while ( inc ) { 1570 while ( inc ) {
1571 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1571 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1572 loc = mCalendar->incidence(inc->uid() ); 1572 loc = mCalendar->incidence(inc->uid() );
1573 if ( loc ) { 1573 if ( loc ) {
1574 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1574 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1575 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1575 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1576 } 1576 }
1577 } 1577 }
1578 inc = iL.next(); 1578 inc = iL.next();
1579 } 1579 }
1580 Incidence* lse = getLastSyncEvent(); 1580 Incidence* lse = getLastSyncEvent();
1581 if ( lse ) { 1581 if ( lse ) {
1582 lse->setReadOnly( false ); 1582 lse->setReadOnly( false );
1583 lse->setDescription( "" ); 1583 lse->setDescription( "" );
1584 lse->setReadOnly( true ); 1584 lse->setReadOnly( true );
1585 } 1585 }
1586 } 1586 }
1587 } else { 1587 } else {
1588 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1588 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1589 } 1589 }
1590 setModified( true ); 1590 setModified( true );
1591 } else { 1591 } else {
1592 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1592 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1593 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1593 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1594 question, i18n("Ok")) ; 1594 question, i18n("Ok")) ;
1595 1595
1596 } 1596 }
1597 delete calendar; 1597 delete calendar;
1598 updateView(); 1598 updateView();
1599 emit tempDisableBR(false); 1599 emit tempDisableBR(false);
1600 return ;//syncOK; 1600 return ;//syncOK;
1601 1601
1602} 1602}
1603 1603
1604bool CalendarView::importBday() 1604bool CalendarView::importBday()
1605{ 1605{
1606#ifndef KORG_NOKABC 1606#ifndef KORG_NOKABC
1607 1607
1608#ifdef DESKTOP_VERSION 1608#ifdef DESKTOP_VERSION
1609 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1609 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1610 KABC::AddressBook::Iterator it; 1610 KABC::AddressBook::Iterator it;
1611 int count = 0; 1611 int count = 0;
1612 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1612 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1613 ++count; 1613 ++count;
1614 } 1614 }
1615 QProgressBar bar(count,0 ); 1615 QProgressBar bar(count,0 );
1616 int w = 300; 1616 int w = 300;
1617 if ( QApplication::desktop()->width() < 320 ) 1617 if ( QApplication::desktop()->width() < 320 )
1618 w = 220; 1618 w = 220;
1619 int h = bar.sizeHint().height() ; 1619 int h = bar.sizeHint().height() ;
1620 int dw = QApplication::desktop()->width(); 1620 int dw = QApplication::desktop()->width();
1621 int dh = QApplication::desktop()->height(); 1621 int dh = QApplication::desktop()->height();
1622 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1622 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1623 bar.show(); 1623 bar.show();
1624 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1624 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1625 qApp->processEvents(); 1625 qApp->processEvents();
1626 count = 0; 1626 count = 0;
1627 int addCount = 0; 1627 int addCount = 0;
1628 KCal::Attendee* a = 0; 1628 KCal::Attendee* a = 0;
1629 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1629 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1630 if ( ! bar.isVisible() ) 1630 if ( ! bar.isVisible() )
1631 return false; 1631 return false;
1632 bar.setProgress( count++ ); 1632 bar.setProgress( count++ );
1633 qApp->processEvents(); 1633 qApp->processEvents();
1634 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1634 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1635 if ( (*it).birthday().date().isValid() ){ 1635 if ( (*it).birthday().date().isValid() ){
1636 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1636 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1637 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1637 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1638 ++addCount; 1638 ++addCount;
1639 } 1639 }
1640 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1640 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1641 if ( anni.isValid() ){ 1641 if ( anni.isValid() ){
1642 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1642 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1643 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1643 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1644 ++addCount; 1644 ++addCount;
1645 } 1645 }
1646 } 1646 }
1647 updateView(); 1647 updateView();
1648 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1648 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1649#else //DESKTOP_VERSION 1649#else //DESKTOP_VERSION
1650 1650
1651 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1651 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1652 // the result should now arrive through method insertBirthdays 1652 // the result should now arrive through method insertBirthdays
1653 1653
1654#endif //DESKTOP_VERSION 1654#endif //DESKTOP_VERSION
1655 1655
1656#endif //KORG_NOKABC 1656#endif //KORG_NOKABC
1657 1657
1658 1658
1659 return true; 1659 return true;
1660} 1660}
1661 1661
1662// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1662// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1663void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1663void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1664 const QStringList& anniversaryList, const QStringList& realNameList, 1664 const QStringList& anniversaryList, const QStringList& realNameList,
1665 const QStringList& emailList, const QStringList& assembledNameList, 1665 const QStringList& emailList, const QStringList& assembledNameList,
1666 const QStringList& uidList) 1666 const QStringList& uidList)
1667{ 1667{
1668 //qDebug("KO::CalendarView::insertBirthdays"); 1668 //qDebug("KO::CalendarView::insertBirthdays");
1669 if (uid == this->name()) 1669 if (uid == this->name())
1670 { 1670 {
1671 int count = birthdayList.count(); 1671 int count = birthdayList.count();
1672 int addCount = 0; 1672 int addCount = 0;
1673 KCal::Attendee* a = 0; 1673 KCal::Attendee* a = 0;
1674 1674
1675 //qDebug("CalView 1 %i", count); 1675 //qDebug("CalView 1 %i", count);
1676 1676
1677 QProgressBar bar(count,0 ); 1677 QProgressBar bar(count,0 );
1678 int w = 300; 1678 int w = 300;
1679 if ( QApplication::desktop()->width() < 320 ) 1679 if ( QApplication::desktop()->width() < 320 )
1680 w = 220; 1680 w = 220;
1681 int h = bar.sizeHint().height() ; 1681 int h = bar.sizeHint().height() ;
1682 int dw = QApplication::desktop()->width(); 1682 int dw = QApplication::desktop()->width();
1683 int dh = QApplication::desktop()->height(); 1683 int dh = QApplication::desktop()->height();
1684 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1684 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1685 bar.show(); 1685 bar.show();
1686 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1686 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1687 qApp->processEvents(); 1687 qApp->processEvents();
1688 1688
1689 QDate birthday; 1689 QDate birthday;
1690 QDate anniversary; 1690 QDate anniversary;
1691 QString realName; 1691 QString realName;
1692 QString email; 1692 QString email;
1693 QString assembledName; 1693 QString assembledName;
1694 QString uid; 1694 QString uid;
1695 bool ok = true; 1695 bool ok = true;
1696 for ( int i = 0; i < count; i++) 1696 for ( int i = 0; i < count; i++)
1697 { 1697 {
1698 if ( ! bar.isVisible() ) 1698 if ( ! bar.isVisible() )
1699 return; 1699 return;
1700 bar.setProgress( i ); 1700 bar.setProgress( i );
1701 qApp->processEvents(); 1701 qApp->processEvents();
1702 1702
1703 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1703 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1704 if (!ok) { 1704 if (!ok) {
1705 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1705 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1706 } 1706 }
1707 1707
1708 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1708 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1709 if (!ok) { 1709 if (!ok) {
1710 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1710 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1711 } 1711 }
1712 realName = realNameList[i]; 1712 realName = realNameList[i];
1713 email = emailList[i]; 1713 email = emailList[i];
1714 assembledName = assembledNameList[i]; 1714 assembledName = assembledNameList[i];
1715 uid = uidList[i]; 1715 uid = uidList[i];
1716 //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() ); 1716 //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() );
1717 1717
1718 if ( birthday.isValid() ){ 1718 if ( birthday.isValid() ){
1719 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1719 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1720 KCal::Attendee::ReqParticipant,uid) ; 1720 KCal::Attendee::ReqParticipant,uid) ;
1721 if ( addAnniversary( birthday, assembledName, a, true ) ) 1721 if ( addAnniversary( birthday, assembledName, a, true ) )
1722 ++addCount; 1722 ++addCount;
1723 } 1723 }
1724 1724
1725 if ( anniversary.isValid() ){ 1725 if ( anniversary.isValid() ){
1726 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1726 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1727 KCal::Attendee::ReqParticipant,uid) ; 1727 KCal::Attendee::ReqParticipant,uid) ;
1728 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1728 if ( addAnniversary( anniversary, assembledName, a, false ) )
1729 ++addCount; 1729 ++addCount;
1730 } 1730 }
1731 } 1731 }
1732 1732
1733 updateView(); 1733 updateView();
1734 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1734 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1735 1735
1736 } 1736 }
1737 1737
1738} 1738}
1739 1739
1740 1740
1741 1741
1742bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1742bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1743{ 1743{
1744 //qDebug("addAnni "); 1744 //qDebug("addAnni ");
1745 Event * ev = new Event(); 1745 Event * ev = new Event();
1746 ev->setOrganizer(KOPrefs::instance()->email()); 1746 ev->setOrganizer(KOPrefs::instance()->email());
1747 if ( a ) { 1747 if ( a ) {
1748 ev->addAttendee( a ); 1748 ev->addAttendee( a );
1749 } 1749 }
1750 QString kind; 1750 QString kind;
1751 if ( birthday ) { 1751 if ( birthday ) {
1752 kind = i18n( "Birthday" ); 1752 kind = i18n( "Birthday" );
1753 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1753 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1754 } 1754 }
1755 else { 1755 else {
1756 kind = i18n( "Anniversary" ); 1756 kind = i18n( "Anniversary" );
1757 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1757 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1758 } 1758 }
1759 ev->setCategories( kind ); 1759 ev->setCategories( kind );
1760 ev->setDtStart( QDateTime(date) ); 1760 ev->setDtStart( QDateTime(date) );
1761 ev->setDtEnd( QDateTime(date) ); 1761 ev->setDtEnd( QDateTime(date) );
1762 ev->setFloats( true ); 1762 ev->setFloats( true );
1763 Recurrence * rec = ev->recurrence(); 1763 Recurrence * rec = ev->recurrence();
1764 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1764 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1765 rec->addYearlyNum( date.month() ); 1765 rec->addYearlyNum( date.month() );
1766 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1766 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1767 delete ev; 1767 delete ev;
1768 return false; 1768 return false;
1769 } 1769 }
1770 return true; 1770 return true;
1771 1771
1772} 1772}
1773bool CalendarView::importQtopia( const QString &categories, 1773bool CalendarView::importQtopia( const QString &categories,
1774 const QString &datebook, 1774 const QString &datebook,
1775 const QString &todolist ) 1775 const QString &todolist )
1776{ 1776{
1777 1777
1778 QtopiaFormat qtopiaFormat; 1778 QtopiaFormat qtopiaFormat;
1779 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1779 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1780 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1780 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1781 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1781 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1782 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1782 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1783 1783
1784 updateView(); 1784 updateView();
1785 return true; 1785 return true;
1786 1786
1787#if 0 1787#if 0
1788 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1788 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1789 mCurrentSyncDevice = "qtopia-XML"; 1789 mCurrentSyncDevice = "qtopia-XML";
1790 if ( mSyncManager->mAskForPreferences ) 1790 if ( mSyncManager->mAskForPreferences )
1791 edit_sync_options(); 1791 edit_sync_options();
1792 qApp->processEvents(); 1792 qApp->processEvents();
1793 CalendarLocal* calendar = new CalendarLocal(); 1793 CalendarLocal* calendar = new CalendarLocal();
1794 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1794 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1795 bool syncOK = false; 1795 bool syncOK = false;
1796 QtopiaFormat qtopiaFormat; 1796 QtopiaFormat qtopiaFormat;
1797 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1797 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1798 bool loadOk = true; 1798 bool loadOk = true;
1799 if ( !categories.isEmpty() ) 1799 if ( !categories.isEmpty() )
1800 loadOk = qtopiaFormat.load( calendar, categories ); 1800 loadOk = qtopiaFormat.load( calendar, categories );
1801 if ( loadOk && !datebook.isEmpty() ) 1801 if ( loadOk && !datebook.isEmpty() )
1802 loadOk = qtopiaFormat.load( calendar, datebook ); 1802 loadOk = qtopiaFormat.load( calendar, datebook );
1803 if ( loadOk && !todolist.isEmpty() ) 1803 if ( loadOk && !todolist.isEmpty() )
1804 loadOk = qtopiaFormat.load( calendar, todolist ); 1804 loadOk = qtopiaFormat.load( calendar, todolist );
1805 1805
1806 if ( loadOk ) { 1806 if ( loadOk ) {
1807 getEventViewerDialog()->setSyncMode( true ); 1807 getEventViewerDialog()->setSyncMode( true );
1808 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1808 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1809 getEventViewerDialog()->setSyncMode( false ); 1809 getEventViewerDialog()->setSyncMode( false );
1810 qApp->processEvents(); 1810 qApp->processEvents();
1811 if ( syncOK ) { 1811 if ( syncOK ) {
1812 if ( mSyncManager->mWriteBackFile ) 1812 if ( mSyncManager->mWriteBackFile )
1813 { 1813 {
1814 // write back XML file 1814 // write back XML file
1815 1815
1816 } 1816 }
1817 setModified( true ); 1817 setModified( true );
1818 } 1818 }
1819 } else { 1819 } else {
1820 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1820 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1821 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1821 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1822 question, i18n("Ok")) ; 1822 question, i18n("Ok")) ;
1823 } 1823 }
1824 delete calendar; 1824 delete calendar;
1825 updateView(); 1825 updateView();
1826 return syncOK; 1826 return syncOK;
1827 1827
1828 1828
1829#endif 1829#endif
1830 1830
1831} 1831}
1832 1832
1833void CalendarView::setSyncEventsReadOnly() 1833void CalendarView::setSyncEventsReadOnly()
1834{ 1834{
1835 Event * ev; 1835 Event * ev;
1836 QPtrList<Event> eL = mCalendar->rawEvents(); 1836 QPtrList<Event> eL = mCalendar->rawEvents();
1837 ev = eL.first(); 1837 ev = eL.first();
1838 while ( ev ) { 1838 while ( ev ) {
1839 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1839 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1840 ev->setReadOnly( true ); 1840 ev->setReadOnly( true );
1841 ev = eL.next(); 1841 ev = eL.next();
1842 } 1842 }
1843} 1843}
1844 1844
1845bool CalendarView::loadCalendars() 1845bool CalendarView::loadCalendars()
1846{ 1846{
1847 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1847 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1848 KopiCalendarFile * cal = calendars.first(); 1848 KopiCalendarFile * cal = calendars.first();
1849 mCalendar->setDefaultCalendar( 1 ); 1849 mCalendar->setDefaultCalendar( 1 );
1850 openCalendar( MainWindow::defaultFileName(), false ); 1850 openCalendar( MainWindow::defaultFileName(), false );
1851 cal = calendars.next(); 1851 cal = calendars.next();
1852 while ( cal ) { 1852 while ( cal ) {
1853 addCalendar( cal ); 1853 addCalendar( cal );
1854 cal = calendars.next(); 1854 cal = calendars.next();
1855 } 1855 }
1856 restoreCalendarSettings(); 1856 restoreCalendarSettings();
1857 mCalendar->reInitAlarmSettings(); 1857 mCalendar->reInitAlarmSettings();
1858 setSyncEventsReadOnly(); 1858 setSyncEventsReadOnly();
1859 updateUnmanagedViews(); 1859 updateUnmanagedViews();
1860 updateView(); 1860 updateView();
1861 return true;
1861} 1862}
1862bool CalendarView::restoreCalendarSettings() 1863bool CalendarView::restoreCalendarSettings()
1863{ 1864{
1864 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1865 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1865 KopiCalendarFile * cal = calendars.first(); 1866 KopiCalendarFile * cal = calendars.first();
1866 while ( cal ) { 1867 while ( cal ) {
1867 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1868 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1868 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1869 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1869 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1870 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1870 if ( cal->isStandard ) 1871 if ( cal->isStandard )
1871 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1872 mCalendar->setDefaultCalendar( cal->mCalNumber );
1872 cal = calendars.next(); 1873 cal = calendars.next();
1873 } 1874 }
1875 return true;
1874} 1876}
1875void CalendarView::addCalendarId( int id ) 1877void CalendarView::addCalendarId( int id )
1876{ 1878{
1877 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1879 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1878 addCalendar( cal ); 1880 addCalendar( cal );
1879} 1881}
1880bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1882bool CalendarView::addCalendar( KopiCalendarFile * cal )
1881{ 1883{
1882 cal->mErrorOnLoad = false; 1884 cal->mErrorOnLoad = false;
1883 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1885 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1884 cal->mLoadDt = QDateTime::currentDateTime(); 1886 cal->mLoadDt = QDateTime::currentDateTime();
1885 return true; 1887 return true;
1886 } 1888 }
1887 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1889 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1888 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); 1890 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1889 cal->mErrorOnLoad = true; 1891 cal->mErrorOnLoad = true;
1890 return false; 1892 return false;
1891} 1893}
1892bool CalendarView::openCalendar(QString filename, bool merge) 1894bool CalendarView::openCalendar(QString filename, bool merge)
1893{ 1895{
1894 1896
1895 if (filename.isEmpty()) { 1897 if (filename.isEmpty()) {
1896 return false; 1898 return false;
1897 } 1899 }
1898 1900
1899 if (!QFile::exists(filename)) { 1901 if (!QFile::exists(filename)) {
1900 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1902 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1901 return false; 1903 return false;
1902 } 1904 }
1903 1905
1904 globalFlagBlockAgenda = 1; 1906 globalFlagBlockAgenda = 1;
1905 clearAllViews(); 1907 clearAllViews();
1906 if (!merge) { 1908 if (!merge) {
1907 mViewManager->setDocumentId( filename ); 1909 mViewManager->setDocumentId( filename );
1908 mCalendar->close(); 1910 mCalendar->close();
1909 } 1911 }
1910 mStorage->setFileName( filename ); 1912 mStorage->setFileName( filename );
1911 1913
1912 if ( mStorage->load() ) { 1914 if ( mStorage->load() ) {
1913 if ( merge ) ;//setModified( true ); 1915 if ( merge ) ;//setModified( true );
1914 else { 1916 else {
1915 //setModified( true ); 1917 //setModified( true );
1916 mViewManager->setDocumentId( filename ); 1918 mViewManager->setDocumentId( filename );
1917 mDialogManager->setDocumentId( filename ); 1919 mDialogManager->setDocumentId( filename );
1918 mTodoList->setDocumentId( filename ); 1920 mTodoList->setDocumentId( filename );
1919 } 1921 }
1920 globalFlagBlockAgenda = 2; 1922 globalFlagBlockAgenda = 2;
1921 // if ( getLastSyncEvent() ) 1923 // if ( getLastSyncEvent() )
1922 // getLastSyncEvent()->setReadOnly( true ); 1924 // getLastSyncEvent()->setReadOnly( true );
1923 mCalendar->reInitAlarmSettings(); 1925 mCalendar->reInitAlarmSettings();
1924 setSyncEventsReadOnly(); 1926 setSyncEventsReadOnly();
1925 updateUnmanagedViews(); 1927 updateUnmanagedViews();
1926 updateView(); 1928 updateView();
1927 if ( filename != MainWindow::defaultFileName() ) { 1929 if ( filename != MainWindow::defaultFileName() ) {
1928 saveCalendar( MainWindow::defaultFileName() ); 1930 saveCalendar( MainWindow::defaultFileName() );
1929 } else { 1931 } else {
1930 QFileInfo finf ( MainWindow::defaultFileName()); 1932 QFileInfo finf ( MainWindow::defaultFileName());
1931 if ( finf.exists() ) { 1933 if ( finf.exists() ) {
1932 setLoadedFileVersion( finf.lastModified () ); 1934 setLoadedFileVersion( finf.lastModified () );
1933 } 1935 }
1934 } 1936 }
1935 return true; 1937 return true;
1936 } else { 1938 } else {
1937 // while failing to load, the calendar object could 1939 // while failing to load, the calendar object could
1938 // have become partially populated. Clear it out. 1940 // have become partially populated. Clear it out.
1939 if ( !merge ) { 1941 if ( !merge ) {
1940 mCalendar->close(); 1942 mCalendar->close();
1941 mViewManager->setDocumentId( filename ); 1943 mViewManager->setDocumentId( filename );
1942 mDialogManager->setDocumentId( filename ); 1944 mDialogManager->setDocumentId( filename );
1943 mTodoList->setDocumentId( filename ); 1945 mTodoList->setDocumentId( filename );
1944 } 1946 }
1945 1947
1946 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1948 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1947 1949
1948 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1950 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1949 globalFlagBlockAgenda = 2; 1951 globalFlagBlockAgenda = 2;
1950 mCalendar->reInitAlarmSettings(); 1952 mCalendar->reInitAlarmSettings();
1951 setSyncEventsReadOnly(); 1953 setSyncEventsReadOnly();
1952 updateUnmanagedViews(); 1954 updateUnmanagedViews();
1953 updateView(); 1955 updateView();
1954 } 1956 }
1955 return false; 1957 return false;
1956} 1958}
1957void CalendarView::showOpenError() 1959void CalendarView::showOpenError()
1958{ 1960{
1959 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1961 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1960} 1962}
1961void CalendarView::setLoadedFileVersion(QDateTime dt) 1963void CalendarView::setLoadedFileVersion(QDateTime dt)
1962{ 1964{
1963 loadedFileVersion = dt; 1965 loadedFileVersion = dt;
1964} 1966}
1965bool CalendarView::checkFileChanged(QString fn) 1967bool CalendarView::checkFileChanged(QString fn)
1966{ 1968{
1967 QFileInfo finf ( fn ); 1969 QFileInfo finf ( fn );
1968 if ( !finf.exists() ) 1970 if ( !finf.exists() )
1969 return true; 1971 return true;
1970 QDateTime dt = finf.lastModified (); 1972 QDateTime dt = finf.lastModified ();
1971 if ( dt <= loadedFileVersion ) 1973 if ( dt <= loadedFileVersion )
1972 return false; 1974 return false;
1973 return true; 1975 return true;
1974 1976
1975} 1977}
1976void CalendarView::watchSavedFile() 1978void CalendarView::watchSavedFile()
1977{ 1979{
1978 QFileInfo finf ( MainWindow::defaultFileName()); 1980 QFileInfo finf ( MainWindow::defaultFileName());
1979 if ( !finf.exists() ) 1981 if ( !finf.exists() )
1980 return; 1982 return;
1981 QDateTime dt = finf.lastModified (); 1983 QDateTime dt = finf.lastModified ();
1982 if ( dt < loadedFileVersion ) { 1984 if ( dt < loadedFileVersion ) {
1983 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1985 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1984 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1986 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1985 return; 1987 return;
1986 } 1988 }
1987 loadedFileVersion = dt; 1989 loadedFileVersion = dt;
1988} 1990}
1989bool CalendarView::checkAllFileVersions() 1991bool CalendarView::checkAllFileVersions()
1990{ 1992{
1991 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1993 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1992 KopiCalendarFile * cal = calendars.first(); 1994 KopiCalendarFile * cal = calendars.first();
1993 mCalendar->setDefaultCalendar( 1 ); 1995 mCalendar->setDefaultCalendar( 1 );
1994 mCalendar->setDefaultCalendarEnabledOnly(); 1996 mCalendar->setDefaultCalendarEnabledOnly();
1995 if ( !checkFileVersion(MainWindow::defaultFileName())) 1997 if ( !checkFileVersion(MainWindow::defaultFileName()))
1996 return false; 1998 return false;
1997 cal = calendars.next(); 1999 cal = calendars.next();
1998 QDateTime storeTemp = loadedFileVersion; 2000 QDateTime storeTemp = loadedFileVersion;
1999 while ( cal ) { 2001 while ( cal ) {
2000 if ( !cal->mErrorOnLoad ) { 2002 if ( !cal->mErrorOnLoad ) {
2001 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2003 mCalendar->setDefaultCalendar( cal->mCalNumber );
2002 mCalendar->setDefaultCalendarEnabledOnly(); 2004 mCalendar->setDefaultCalendarEnabledOnly();
2003 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2005 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2004 if ( !checkFileVersion(cal->mFileName )) { 2006 if ( !checkFileVersion(cal->mFileName )) {
2005 loadedFileVersion = storeTemp; 2007 loadedFileVersion = storeTemp;
2006 updateView(); 2008 updateView();
2007 return false; 2009 return false;
2008 } 2010 }
2009 } 2011 }
2010 cal = calendars.next(); 2012 cal = calendars.next();
2011 } 2013 }
2012 loadedFileVersion = storeTemp; 2014 loadedFileVersion = storeTemp;
2013 updateView(); 2015 updateView();
2014 return true; 2016 return true;
2015} 2017}
2016bool CalendarView::checkFileVersion(QString fn) 2018bool CalendarView::checkFileVersion(QString fn)
2017{ 2019{
2018 QFileInfo finf ( fn ); 2020 QFileInfo finf ( fn );
2019 if ( !finf.exists() ) 2021 if ( !finf.exists() )
2020 return true; 2022 return true;
2021 QDateTime dt = finf.lastModified (); 2023 QDateTime dt = finf.lastModified ();
2022 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 2024 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
2023 //qDebug("file on disk version %s",dt.toString().latin1()); 2025 //qDebug("file on disk version %s",dt.toString().latin1());
2024 if ( dt <= loadedFileVersion ) 2026 if ( dt <= loadedFileVersion )
2025 return true; 2027 return true;
2026 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on 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(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2028 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on 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(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2027 i18n("KO/Pi Warning"),i18n("Overwrite"), 2029 i18n("KO/Pi Warning"),i18n("Overwrite"),
2028 i18n("Sync+save")); 2030 i18n("Sync+save"));
2029 2031
2030 if ( km == KMessageBox::Cancel ) 2032 if ( km == KMessageBox::Cancel )
2031 return false; 2033 return false;
2032 if ( km == KMessageBox::Yes ) 2034 if ( km == KMessageBox::Yes )
2033 return true; 2035 return true;
2034 2036
2035 setSyncDevice("deleteaftersync" ); 2037 setSyncDevice("deleteaftersync" );
2036 mSyncManager->mAskForPreferences = true; 2038 mSyncManager->mAskForPreferences = true;
2037 mSyncManager->mSyncAlgoPrefs = 3; 2039 mSyncManager->mSyncAlgoPrefs = 3;
2038 mSyncManager->mWriteBackFile = false; 2040 mSyncManager->mWriteBackFile = false;
2039 mSyncManager->mWriteBackExistingOnly = false; 2041 mSyncManager->mWriteBackExistingOnly = false;
2040 mSyncManager->mShowSyncSummary = false; 2042 mSyncManager->mShowSyncSummary = false;
2041 syncCalendar( fn, 3 ); 2043 syncCalendar( fn, 3 );
2042 Event * e = getLastSyncEvent(); 2044 Event * e = getLastSyncEvent();
2043 if ( e ) 2045 if ( e )
2044 mCalendar->deleteEvent( e ); 2046 mCalendar->deleteEvent( e );
2045 return true; 2047 return true;
2046} 2048}
2047bool CalendarView::saveCalendars() 2049bool CalendarView::saveCalendars()
2048{ 2050{
2049 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2051 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2050 KopiCalendarFile * cal = calendars.first(); 2052 KopiCalendarFile * cal = calendars.first();
2051 mCalendar->setDefaultCalendar( 1 ); 2053 mCalendar->setDefaultCalendar( 1 );
2052 mCalendar->setDefaultCalendarEnabledOnly(); 2054 mCalendar->setDefaultCalendarEnabledOnly();
2053 saveCalendar( MainWindow::defaultFileName() ); 2055 saveCalendar( MainWindow::defaultFileName() );
2054 cal = calendars.next(); 2056 cal = calendars.next();
2055 while ( cal ) { 2057 while ( cal ) {
2056 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2058 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2057 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2059 mCalendar->setDefaultCalendar( cal->mCalNumber );
2058 mCalendar->setDefaultCalendarEnabledOnly(); 2060 mCalendar->setDefaultCalendarEnabledOnly();
2059 if ( saveCalendar( cal->mFileName ) ) 2061 if ( saveCalendar( cal->mFileName ) )
2060 cal->mLoadDt = QDateTime::currentDateTime(); 2062 cal->mLoadDt = QDateTime::currentDateTime();
2061 } 2063 }
2062 cal = calendars.next(); 2064 cal = calendars.next();
2063 } 2065 }
2064 restoreCalendarSettings(); 2066 restoreCalendarSettings();
2067 return true;
2065} 2068}
2066bool CalendarView::saveCalendar( QString filename ) 2069bool CalendarView::saveCalendar( QString filename )
2067{ 2070{
2068 2071
2069 // Store back all unsaved data into calendar object 2072 // Store back all unsaved data into calendar object
2070 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2073 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2071 if ( mViewManager->currentView() ) 2074 if ( mViewManager->currentView() )
2072 mViewManager->currentView()->flushView(); 2075 mViewManager->currentView()->flushView();
2073 2076
2074 2077
2075 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2078 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2076 mStorage->setSaveFormat( new ICalFormat() ); 2079 mStorage->setSaveFormat( new ICalFormat() );
2077 mStorage->setFileName( filename ); 2080 mStorage->setFileName( filename );
2078 bool success; 2081 bool success;
2079 success = mStorage->save(); 2082 success = mStorage->save();
2080 if ( !success ) { 2083 if ( !success ) {
2081 return false; 2084 return false;
2082 } 2085 }
2083 if ( filename == MainWindow::defaultFileName() ) { 2086 if ( filename == MainWindow::defaultFileName() ) {
2084 setLoadedFileVersion( lfv ); 2087 setLoadedFileVersion( lfv );
2085 watchSavedFile(); 2088 watchSavedFile();
2086 } 2089 }
2087 return true; 2090 return true;
2088} 2091}
2089 2092
2090void CalendarView::closeCalendar() 2093void CalendarView::closeCalendar()
2091{ 2094{
2092 2095
2093 // child windows no longer valid 2096 // child windows no longer valid
2094 clearAllViews(); 2097 clearAllViews();
2095 emit closingDown(); 2098 emit closingDown();
2096 2099
2097 mCalendar->close(); 2100 mCalendar->close();
2098 setModified(false); 2101 setModified(false);
2099 updateView(); 2102 updateView();
2100} 2103}
2101 2104
2102void CalendarView::archiveCalendar() 2105void CalendarView::archiveCalendar()
2103{ 2106{
2104 mDialogManager->showArchiveDialog(); 2107 mDialogManager->showArchiveDialog();
2105} 2108}
2106 2109
2107 2110
2108void CalendarView::readSettings() 2111void CalendarView::readSettings()
2109{ 2112{
2110 2113
2111 2114
2112 // mViewManager->showAgendaView(); 2115 // mViewManager->showAgendaView();
2113 QString str; 2116 QString str;
2114 //qDebug("CalendarView::readSettings() "); 2117 //qDebug("CalendarView::readSettings() ");
2115 // read settings from the KConfig, supplying reasonable 2118 // read settings from the KConfig, supplying reasonable
2116 // defaults where none are to be found 2119 // defaults where none are to be found
2117 KConfig *config = KOGlobals::config(); 2120 KConfig *config = KOGlobals::config();
2118#ifndef KORG_NOSPLITTER 2121#ifndef KORG_NOSPLITTER
2119 config->setGroup("KOrganizer Geometry"); 2122 config->setGroup("KOrganizer Geometry");
2120 2123
2121 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2124 QValueList<int> sizes = config->readIntListEntry("Separator1");
2122 if (sizes.count() != 2) { 2125 if (sizes.count() != 2) {
2123 sizes << mDateNavigator->minimumSizeHint().width(); 2126 sizes << mDateNavigator->minimumSizeHint().width();
2124 sizes << 300; 2127 sizes << 300;
2125 } 2128 }
2126 mPanner->setSizes(sizes); 2129 mPanner->setSizes(sizes);
2127 2130
2128 sizes = config->readIntListEntry("Separator2"); 2131 sizes = config->readIntListEntry("Separator2");
2129 if ( ( mResourceView && sizes.count() == 4 ) || 2132 if ( ( mResourceView && sizes.count() == 4 ) ||
2130 ( !mResourceView && sizes.count() == 3 ) ) { 2133 ( !mResourceView && sizes.count() == 3 ) ) {
2131 mLeftSplitter->setSizes(sizes); 2134 mLeftSplitter->setSizes(sizes);
2132 } 2135 }
2133#endif 2136#endif
2134 globalFlagBlockAgenda = 1; 2137 globalFlagBlockAgenda = 1;
2135 mViewManager->showAgendaView(); 2138 mViewManager->showAgendaView();
2136 //mViewManager->readSettings( config ); 2139 //mViewManager->readSettings( config );
2137 mTodoList->restoreLayout(config,QString("Todo Layout")); 2140 mTodoList->restoreLayout(config,QString("Todo Layout"));
2138 readFilterSettings(config); 2141 readFilterSettings(config);
2139 2142
2140#ifdef DESKTOP_VERSION 2143#ifdef DESKTOP_VERSION
2141 config->setGroup("WidgetLayout"); 2144 config->setGroup("WidgetLayout");
2142 QStringList list; 2145 QStringList list;
2143 list = config->readListEntry("MainLayout"); 2146 list = config->readListEntry("MainLayout");
2144 int x,y,w,h; 2147 int x,y,w,h;
2145 if ( ! list.isEmpty() ) { 2148 if ( ! list.isEmpty() ) {
2146 x = list[0].toInt(); 2149 x = list[0].toInt();
2147 y = list[1].toInt(); 2150 y = list[1].toInt();
2148 w = list[2].toInt(); 2151 w = list[2].toInt();
2149 h = list[3].toInt(); 2152 h = list[3].toInt();
2150 KApplication::testCoords( &x,&y,&w,&h ); 2153 KApplication::testCoords( &x,&y,&w,&h );
2151 topLevelWidget()->setGeometry(x,y,w,h); 2154 topLevelWidget()->setGeometry(x,y,w,h);
2152 2155
2153 } else { 2156 } else {
2154 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2157 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2155 } 2158 }
2156 list = config->readListEntry("EditEventLayout"); 2159 list = config->readListEntry("EditEventLayout");
2157 if ( ! list.isEmpty() ) { 2160 if ( ! list.isEmpty() ) {
2158 x = list[0].toInt(); 2161 x = list[0].toInt();
2159 y = list[1].toInt(); 2162 y = list[1].toInt();
2160 w = list[2].toInt(); 2163 w = list[2].toInt();
2161 h = list[3].toInt(); 2164 h = list[3].toInt();
2162 KApplication::testCoords( &x,&y,&w,&h ); 2165 KApplication::testCoords( &x,&y,&w,&h );
2163 mEventEditor->setGeometry(x,y,w,h); 2166 mEventEditor->setGeometry(x,y,w,h);
2164 2167
2165 } 2168 }
2166 list = config->readListEntry("EditTodoLayout"); 2169 list = config->readListEntry("EditTodoLayout");
2167 if ( ! list.isEmpty() ) { 2170 if ( ! list.isEmpty() ) {
2168 x = list[0].toInt(); 2171 x = list[0].toInt();
2169 y = list[1].toInt(); 2172 y = list[1].toInt();
2170 w = list[2].toInt(); 2173 w = list[2].toInt();
2171 h = list[3].toInt(); 2174 h = list[3].toInt();
2172 KApplication::testCoords( &x,&y,&w,&h ); 2175 KApplication::testCoords( &x,&y,&w,&h );
2173 mTodoEditor->setGeometry(x,y,w,h); 2176 mTodoEditor->setGeometry(x,y,w,h);
2174 2177
2175 } 2178 }
2176 list = config->readListEntry("ViewerLayout"); 2179 list = config->readListEntry("ViewerLayout");
2177 if ( ! list.isEmpty() ) { 2180 if ( ! list.isEmpty() ) {
2178 x = list[0].toInt(); 2181 x = list[0].toInt();
2179 y = list[1].toInt(); 2182 y = list[1].toInt();
2180 w = list[2].toInt(); 2183 w = list[2].toInt();
2181 h = list[3].toInt(); 2184 h = list[3].toInt();
2182 KApplication::testCoords( &x,&y,&w,&h ); 2185 KApplication::testCoords( &x,&y,&w,&h );
2183 getEventViewerDialog()->setGeometry(x,y,w,h); 2186 getEventViewerDialog()->setGeometry(x,y,w,h);
2184 } 2187 }
2185#endif 2188#endif
2186 config->setGroup( "Views" ); 2189 config->setGroup( "Views" );
2187 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2190 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2188 2191
2189 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2192 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2190 2193
2191 int resetval = 0; 2194 int resetval = 0;
2192 int maxVal = 0; 2195 int maxVal = 0;
2193 if (sizes.count() != 3) { 2196 if (sizes.count() != 3) {
2194 if ( KOPrefs::instance()->mVerticalScreen ) { 2197 if ( KOPrefs::instance()->mVerticalScreen ) {
2195 resetval = mDateNavigator->sizeHint().width()+2; 2198 resetval = mDateNavigator->sizeHint().width()+2;
2196 } else { 2199 } else {
2197 resetval = mDateNavigator->sizeHint().height()+2; 2200 resetval = mDateNavigator->sizeHint().height()+2;
2198 } 2201 }
2199 } 2202 }
2200 if ( resetval ) { 2203 if ( resetval ) {
2201 sizes.clear(); 2204 sizes.clear();
2202 if ( KOPrefs::instance()->mVerticalScreen ) { 2205 if ( KOPrefs::instance()->mVerticalScreen ) {
2203 maxVal = QApplication::desktop()->width() -10; 2206 maxVal = QApplication::desktop()->width() -10;
2204 } else { 2207 } else {
2205 maxVal = QApplication::desktop()->height()-10; 2208 maxVal = QApplication::desktop()->height()-10;
2206 } 2209 }
2207 sizes << resetval; 2210 sizes << resetval;
2208 if ( maxVal < resetval + resetval) 2211 if ( maxVal < resetval + resetval)
2209 resetval = maxVal - resetval; 2212 resetval = maxVal - resetval;
2210 sizes << resetval; 2213 sizes << resetval;
2211 sizes << 100; 2214 sizes << 100;
2212 } 2215 }
2213 mLeftFrame->setSizes(sizes); 2216 mLeftFrame->setSizes(sizes);
2214 sizes = config->readIntListEntry("Main Splitter Frame"); 2217 sizes = config->readIntListEntry("Main Splitter Frame");
2215 resetval = 0; 2218 resetval = 0;
2216 maxVal = 0; 2219 maxVal = 0;
2217 if (sizes.count() != 2) { 2220 if (sizes.count() != 2) {
2218 if ( !KOPrefs::instance()->mVerticalScreen ) { 2221 if ( !KOPrefs::instance()->mVerticalScreen ) {
2219 resetval = mDateNavigator->sizeHint().width()+2; 2222 resetval = mDateNavigator->sizeHint().width()+2;
2220 } else { 2223 } else {
2221 resetval = mDateNavigator->sizeHint().height()+2; 2224 resetval = mDateNavigator->sizeHint().height()+2;
2222 } 2225 }
2223 } 2226 }
2224 if ( resetval ) { 2227 if ( resetval ) {
2225 sizes.clear(); 2228 sizes.clear();
2226 if ( !KOPrefs::instance()->mVerticalScreen ) { 2229 if ( !KOPrefs::instance()->mVerticalScreen ) {
2227 maxVal = QApplication::desktop()->width() -10; 2230 maxVal = QApplication::desktop()->width() -10;
2228 } else { 2231 } else {
2229 maxVal = QApplication::desktop()->height()-10; 2232 maxVal = QApplication::desktop()->height()-10;
2230 } 2233 }
2231 sizes << resetval; 2234 sizes << resetval;
2232 if ( maxVal < resetval + resetval) 2235 if ( maxVal < resetval + resetval)
2233 resetval = maxVal - resetval; 2236 resetval = maxVal - resetval;
2234 sizes << resetval; 2237 sizes << resetval;
2235 } 2238 }
2236 mMainFrame->setSizes(sizes); 2239 mMainFrame->setSizes(sizes);
2237 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2240 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2238 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2241 else if ( dateCount == 7 ) mNavigator->selectWeek();
2239 else mNavigator->selectDates( dateCount ); 2242 else mNavigator->selectDates( dateCount );
2240 // mViewManager->readSettings( config ); 2243 // mViewManager->readSettings( config );
2241 updateConfig(); 2244 updateConfig();
2242 globalFlagBlockAgenda = 2; 2245 globalFlagBlockAgenda = 2;
2243 mViewManager->readSettings( config ); 2246 mViewManager->readSettings( config );
2244 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2247 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2245} 2248}
2246 2249
2247 2250
2248void CalendarView::writeSettings() 2251void CalendarView::writeSettings()
2249{ 2252{
2250 // kdDebug() << "CalendarView::writeSettings" << endl; 2253 // kdDebug() << "CalendarView::writeSettings" << endl;
2251 2254
2252 KConfig *config = KOGlobals::config(); 2255 KConfig *config = KOGlobals::config();
2253 2256
2254 mViewManager->writeSettings( config ); 2257 mViewManager->writeSettings( config );
2255 mTodoList->saveLayout(config,QString("Todo Layout")); 2258 mTodoList->saveLayout(config,QString("Todo Layout"));
2256 mDialogManager->writeSettings( config ); 2259 mDialogManager->writeSettings( config );
2257 //KOPrefs::instance()->usrWriteConfig(); 2260 //KOPrefs::instance()->usrWriteConfig();
2258 KOPrefs::instance()->writeConfig(); 2261 KOPrefs::instance()->writeConfig();
2259 2262
2260 writeFilterSettings(config); 2263 writeFilterSettings(config);
2261 config->setGroup( "AppRun" ); 2264 config->setGroup( "AppRun" );
2262 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2265 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2263 int days = dt.daysTo( QDate::currentDate() ); 2266 int days = dt.daysTo( QDate::currentDate() );
2264 dt = dt.addDays( days ); 2267 dt = dt.addDays( days );
2265 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2268 int secs = dt.secsTo( QDateTime::currentDateTime() );
2266 config->writeEntry( "LatestProgramStopDays", days ); 2269 config->writeEntry( "LatestProgramStopDays", days );
2267 config->writeEntry( "LatestProgramStopSecs", secs ); 2270 config->writeEntry( "LatestProgramStopSecs", secs );
2268 //qDebug("KO: Writing stop time: %d ", secs); 2271 //qDebug("KO: Writing stop time: %d ", secs);
2269 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2272 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2270 //QDateTime latest = dt.addSecs ( secs ); 2273 //QDateTime latest = dt.addSecs ( secs );
2271 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2274 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2272 config->setGroup( "Views" ); 2275 config->setGroup( "Views" );
2273 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2276 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2274 2277
2275#if 0 2278#if 0
2276 qDebug("********************* "); 2279 qDebug("********************* ");
2277 qDebug("Testcode secsto "); 2280 qDebug("Testcode secsto ");
2278 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2281 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2279 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2282 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2280 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2283 int secsto = dt_nodaylight.secsTo( dt_daylight );
2281 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2284 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2282 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2285 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2283 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2286 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2284 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2287 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2285 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2288 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2286 qDebug("********************* testcode end"); 2289 qDebug("********************* testcode end");
2287 2290
2288#endif 2291#endif
2289 2292
2290 QValueList<int> listINT = mLeftFrame->sizes(); 2293 QValueList<int> listINT = mLeftFrame->sizes();
2291 config->writeEntry("Left Splitter Frame",listINT); 2294 config->writeEntry("Left Splitter Frame",listINT);
2292 QValueList<int> listINT2 = mMainFrame->sizes(); 2295 QValueList<int> listINT2 = mMainFrame->sizes();
2293 config->writeEntry("Main Splitter Frame",listINT2); 2296 config->writeEntry("Main Splitter Frame",listINT2);
2294#ifdef DESKTOP_VERSION 2297#ifdef DESKTOP_VERSION
2295 config->setGroup("WidgetLayout"); 2298 config->setGroup("WidgetLayout");
2296 QStringList list ;//= config->readListEntry("MainLayout"); 2299 QStringList list ;//= config->readListEntry("MainLayout");
2297 int x,y,w,h; 2300 int x,y,w,h;
2298 QWidget* wid; 2301 QWidget* wid;
2299 wid = topLevelWidget(); 2302 wid = topLevelWidget();
2300 x = wid->geometry().x(); 2303 x = wid->geometry().x();
2301 y = wid->geometry().y(); 2304 y = wid->geometry().y();
2302 w = wid->width(); 2305 w = wid->width();
2303 h = wid->height(); 2306 h = wid->height();
2304 list.clear(); 2307 list.clear();
2305 list << QString::number( x ); 2308 list << QString::number( x );
2306 list << QString::number( y ); 2309 list << QString::number( y );
2307 list << QString::number( w ); 2310 list << QString::number( w );
2308 list << QString::number( h ); 2311 list << QString::number( h );
2309 config->writeEntry("MainLayout",list ); 2312 config->writeEntry("MainLayout",list );
2310 2313
2311 wid = mEventEditor; 2314 wid = mEventEditor;
2312 x = wid->geometry().x(); 2315 x = wid->geometry().x();
2313 y = wid->geometry().y(); 2316 y = wid->geometry().y();
2314 w = wid->width(); 2317 w = wid->width();
2315 h = wid->height(); 2318 h = wid->height();
2316 list.clear(); 2319 list.clear();
2317 list << QString::number( x ); 2320 list << QString::number( x );
2318 list << QString::number( y ); 2321 list << QString::number( y );
2319 list << QString::number( w ); 2322 list << QString::number( w );
2320 list << QString::number( h ); 2323 list << QString::number( h );
2321 config->writeEntry("EditEventLayout",list ); 2324 config->writeEntry("EditEventLayout",list );
2322 2325
2323 wid = mTodoEditor; 2326 wid = mTodoEditor;
2324 x = wid->geometry().x(); 2327 x = wid->geometry().x();
2325 y = wid->geometry().y(); 2328 y = wid->geometry().y();
2326 w = wid->width(); 2329 w = wid->width();
2327 h = wid->height(); 2330 h = wid->height();
2328 list.clear(); 2331 list.clear();
2329 list << QString::number( x ); 2332 list << QString::number( x );
2330 list << QString::number( y ); 2333 list << QString::number( y );
2331 list << QString::number( w ); 2334 list << QString::number( w );
2332 list << QString::number( h ); 2335 list << QString::number( h );
2333 config->writeEntry("EditTodoLayout",list ); 2336 config->writeEntry("EditTodoLayout",list );
2334 wid = getEventViewerDialog(); 2337 wid = getEventViewerDialog();
2335 x = wid->geometry().x(); 2338 x = wid->geometry().x();
2336 y = wid->geometry().y(); 2339 y = wid->geometry().y();
2337 w = wid->width(); 2340 w = wid->width();
2338 h = wid->height(); 2341 h = wid->height();
2339 list.clear(); 2342 list.clear();
2340 list << QString::number( x ); 2343 list << QString::number( x );
2341 list << QString::number( y ); 2344 list << QString::number( y );
2342 list << QString::number( w ); 2345 list << QString::number( w );
2343 list << QString::number( h ); 2346 list << QString::number( h );
2344 config->writeEntry("ViewerLayout",list ); 2347 config->writeEntry("ViewerLayout",list );
2345 wid = mDialogManager->getSearchDialog(); 2348 wid = mDialogManager->getSearchDialog();
2346 if ( wid ) { 2349 if ( wid ) {
2347 x = wid->geometry().x(); 2350 x = wid->geometry().x();
2348 y = wid->geometry().y(); 2351 y = wid->geometry().y();
2349 w = wid->width(); 2352 w = wid->width();
2350 h = wid->height(); 2353 h = wid->height();
2351 list.clear(); 2354 list.clear();
2352 list << QString::number( x ); 2355 list << QString::number( x );
2353 list << QString::number( y ); 2356 list << QString::number( y );
2354 list << QString::number( w ); 2357 list << QString::number( w );
2355 list << QString::number( h ); 2358 list << QString::number( h );
2356 config->writeEntry("SearchLayout",list ); 2359 config->writeEntry("SearchLayout",list );
2357 } 2360 }
2358#endif 2361#endif
2359 2362
2360 2363
2361 config->sync(); 2364 config->sync();
2362} 2365}
2363 2366
2364void CalendarView::readFilterSettings(KConfig *config) 2367void CalendarView::readFilterSettings(KConfig *config)
2365{ 2368{
2366 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2369 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2367 2370
2368 mFilters.clear(); 2371 mFilters.clear();
2369 2372
2370 config->setGroup("General"); 2373 config->setGroup("General");
2371 QStringList filterList = config->readListEntry("CalendarFilters"); 2374 QStringList filterList = config->readListEntry("CalendarFilters");
2372 2375
2373 QStringList::ConstIterator it = filterList.begin(); 2376 QStringList::ConstIterator it = filterList.begin();
2374 QStringList::ConstIterator end = filterList.end(); 2377 QStringList::ConstIterator end = filterList.end();
2375 while(it != end) { 2378 while(it != end) {
2376 // kdDebug() << " filter: " << (*it) << endl; 2379 // kdDebug() << " filter: " << (*it) << endl;
2377 2380
2378 CalFilter *filter; 2381 CalFilter *filter;
2379 filter = new CalFilter(*it); 2382 filter = new CalFilter(*it);
2380 config->setGroup("Filter_" + (*it).utf8()); 2383 config->setGroup("Filter_" + (*it).utf8());
2381 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2384 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2382 filter->setCriteria(config->readNumEntry("Criteria",0)); 2385 filter->setCriteria(config->readNumEntry("Criteria",0));
2383 filter->setCategoryList(config->readListEntry("CategoryList")); 2386 filter->setCategoryList(config->readListEntry("CategoryList"));
2384 mFilters.append(filter); 2387 mFilters.append(filter);
2385 2388
2386 ++it; 2389 ++it;
2387 } 2390 }
2388 2391
2389 if (mFilters.count() == 0) { 2392 if (mFilters.count() == 0) {
2390 CalFilter *filter = new CalFilter(i18n("Default")); 2393 CalFilter *filter = new CalFilter(i18n("Default"));
2391 mFilters.append(filter); 2394 mFilters.append(filter);
2392 } 2395 }
2393 mFilterView->updateFilters(); 2396 mFilterView->updateFilters();
2394 config->setGroup("FilterView"); 2397 config->setGroup("FilterView");
2395 2398
2396 mFilterView->blockSignals(true); 2399 mFilterView->blockSignals(true);
2397 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2400 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2398 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2401 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2399 mFilterView->blockSignals(false); 2402 mFilterView->blockSignals(false);
2400 // We do it manually to avoid it being done twice by the above calls 2403 // We do it manually to avoid it being done twice by the above calls
2401 updateFilter(); 2404 updateFilter();
2402} 2405}
2403 2406
2404void CalendarView::writeFilterSettings(KConfig *config) 2407void CalendarView::writeFilterSettings(KConfig *config)
2405{ 2408{
2406 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2409 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2407 2410
2408 QStringList filterList; 2411 QStringList filterList;
2409 2412
2410 CalFilter *filter = mFilters.first(); 2413 CalFilter *filter = mFilters.first();
2411 while(filter) { 2414 while(filter) {
2412 // kdDebug() << " fn: " << filter->name() << endl; 2415 // kdDebug() << " fn: " << filter->name() << endl;
2413 filterList << filter->name(); 2416 filterList << filter->name();
2414 config->setGroup("Filter_" + filter->name().utf8()); 2417 config->setGroup("Filter_" + filter->name().utf8());
2415 config->writeEntry("Criteria",filter->criteria()); 2418 config->writeEntry("Criteria",filter->criteria());
2416 config->writeEntry("CategoryList",filter->categoryList()); 2419 config->writeEntry("CategoryList",filter->categoryList());
2417 filter = mFilters.next(); 2420 filter = mFilters.next();
2418 } 2421 }
2419 config->setGroup("General"); 2422 config->setGroup("General");
2420 config->writeEntry("CalendarFilters",filterList); 2423 config->writeEntry("CalendarFilters",filterList);
2421 2424
2422 config->setGroup("FilterView"); 2425 config->setGroup("FilterView");
2423 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2426 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2424 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2427 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2425} 2428}
2426 2429
2427 2430
2428void CalendarView::goToday() 2431void CalendarView::goToday()
2429{ 2432{
2430 if ( mViewManager->currentView()->isMonthView() ) 2433 if ( mViewManager->currentView()->isMonthView() )
2431 mNavigator->selectTodayMonth(); 2434 mNavigator->selectTodayMonth();
2432 else 2435 else
2433 mNavigator->selectToday(); 2436 mNavigator->selectToday();
2434} 2437}
2435 2438
2436void CalendarView::goNext() 2439void CalendarView::goNext()
2437{ 2440{
2438 mNavigator->selectNext(); 2441 mNavigator->selectNext();
2439} 2442}
2440 2443
2441void CalendarView::goPrevious() 2444void CalendarView::goPrevious()
2442{ 2445{
2443 mNavigator->selectPrevious(); 2446 mNavigator->selectPrevious();
2444} 2447}
2445void CalendarView::goNextMonth() 2448void CalendarView::goNextMonth()
2446{ 2449{
2447 mNavigator->selectNextMonth(); 2450 mNavigator->selectNextMonth();
2448} 2451}
2449 2452
2450void CalendarView::goPreviousMonth() 2453void CalendarView::goPreviousMonth()
2451{ 2454{
2452 mNavigator->selectPreviousMonth(); 2455 mNavigator->selectPreviousMonth();
2453} 2456}
2454void CalendarView::writeLocale() 2457void CalendarView::writeLocale()
2455{ 2458{
2456 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2459 //KPimGlobalPrefs::instance()->setGlobalConfig();
2457#if 0 2460#if 0
2458 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2461 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2459 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2462 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2460 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2463 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2461 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2464 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2462 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2465 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2463 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2466 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2464 dummy = KOPrefs::instance()->mUserDateFormatShort; 2467 dummy = KOPrefs::instance()->mUserDateFormatShort;
2465 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2468 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2466 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2469 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2467 KOPrefs::instance()->mDaylightsavingStart, 2470 KOPrefs::instance()->mDaylightsavingStart,
2468 KOPrefs::instance()->mDaylightsavingEnd ); 2471 KOPrefs::instance()->mDaylightsavingEnd );
2469 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2472 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2470#endif 2473#endif
2471} 2474}
2472void CalendarView::updateConfig() 2475void CalendarView::updateConfig()
2473{ 2476{
2474 writeLocale(); 2477 writeLocale();
2475 if ( KOPrefs::instance()->mUseAppColors ) 2478 if ( KOPrefs::instance()->mUseAppColors )
2476 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2479 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2477 emit configChanged(); 2480 emit configChanged();
2478 mTodoList->updateConfig(); 2481 mTodoList->updateConfig();
2479 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2482 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2480 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2483 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2481 // To make the "fill window" configurations work 2484 // To make the "fill window" configurations work
2482 //mViewManager->raiseCurrentView(); 2485 //mViewManager->raiseCurrentView();
2483} 2486}
2484 2487
2485 2488
2486void CalendarView::eventChanged(Event *event) 2489void CalendarView::eventChanged(Event *event)
2487{ 2490{
2488 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2491 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2489 //updateUnmanagedViews(); 2492 //updateUnmanagedViews();
2490} 2493}
2491 2494
2492void CalendarView::eventAdded(Event *event) 2495void CalendarView::eventAdded(Event *event)
2493{ 2496{
2494 changeEventDisplay(event,KOGlobals::EVENTADDED); 2497 changeEventDisplay(event,KOGlobals::EVENTADDED);
2495} 2498}
2496 2499
2497void CalendarView::eventToBeDeleted(Event *) 2500void CalendarView::eventToBeDeleted(Event *)
2498{ 2501{
2499 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2502 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2500} 2503}
2501 2504
2502void CalendarView::eventDeleted() 2505void CalendarView::eventDeleted()
2503{ 2506{
2504 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2507 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2505} 2508}
2506void CalendarView::changeTodoDisplay(Todo *which, int action) 2509void CalendarView::changeTodoDisplay(Todo *which, int action)
2507{ 2510{
2508 changeIncidenceDisplay((Incidence *)which, action); 2511 changeIncidenceDisplay((Incidence *)which, action);
2509 mDateNavigator->updateView(); //LR 2512 mDateNavigator->updateView(); //LR
2510 //mDialogManager->updateSearchDialog(); 2513 //mDialogManager->updateSearchDialog();
2511 2514
2512 if (which) { 2515 if (which) {
2513 mViewManager->updateWNview(); 2516 mViewManager->updateWNview();
2514 //mTodoList->updateView(); 2517 //mTodoList->updateView();
2515 } 2518 }
2516 2519
2517} 2520}
2518 2521
2519void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2522void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2520{ 2523{
2521 updateUnmanagedViews(); 2524 updateUnmanagedViews();
2522 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2525 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2523 if ( action == KOGlobals::EVENTDELETED ) { //delete 2526 if ( action == KOGlobals::EVENTDELETED ) { //delete
2524 mCalendar->checkAlarmForIncidence( 0, true ); 2527 mCalendar->checkAlarmForIncidence( 0, true );
2525 if ( mEventViewerDialog ) 2528 if ( mEventViewerDialog )
2526 mEventViewerDialog->hide(); 2529 mEventViewerDialog->hide();
2527 } 2530 }
2528 else 2531 else
2529 mCalendar->checkAlarmForIncidence( which , false ); 2532 mCalendar->checkAlarmForIncidence( which , false );
2530} 2533}
2531 2534
2532// most of the changeEventDisplays() right now just call the view's 2535// most of the changeEventDisplays() right now just call the view's
2533// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2536// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2534void CalendarView::changeEventDisplay(Event *which, int action) 2537void CalendarView::changeEventDisplay(Event *which, int action)
2535{ 2538{
2536 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2539 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2537 changeIncidenceDisplay((Incidence *)which, action); 2540 changeIncidenceDisplay((Incidence *)which, action);
2538 mDateNavigator->updateView(); 2541 mDateNavigator->updateView();
2539 //mDialogManager->updateSearchDialog(); 2542 //mDialogManager->updateSearchDialog();
2540 2543
2541 if (which) { 2544 if (which) {
2542 // If there is an event view visible update the display 2545 // If there is an event view visible update the display
2543 mViewManager->currentView()->changeEventDisplay(which,action); 2546 mViewManager->currentView()->changeEventDisplay(which,action);
2544 // TODO: check, if update needed 2547 // TODO: check, if update needed
2545 // if (which->getTodoStatus()) { 2548 // if (which->getTodoStatus()) {
2546 mTodoList->updateView(); 2549 mTodoList->updateView();
2547 // } 2550 // }
2548 } else { 2551 } else {
2549 mViewManager->currentView()->updateView(); 2552 mViewManager->currentView()->updateView();
2550 } 2553 }
2551} 2554}
2552 2555
2553 2556
2554void CalendarView::updateTodoViews() 2557void CalendarView::updateTodoViews()
2555{ 2558{
2556 mTodoList->updateView(); 2559 mTodoList->updateView();
2557 mViewManager->currentView()->updateView(); 2560 mViewManager->currentView()->updateView();
2558 2561
2559} 2562}
2560 2563
2561 2564
2562void CalendarView::updateView(const QDate &start, const QDate &end) 2565void CalendarView::updateView(const QDate &start, const QDate &end)
2563{ 2566{
2564 mTodoList->updateView(); 2567 mTodoList->updateView();
2565 mViewManager->updateView(start, end); 2568 mViewManager->updateView(start, end);
2566 //mDateNavigator->updateView(); 2569 //mDateNavigator->updateView();
2567} 2570}
2568 2571
2569void CalendarView::clearAllViews() 2572void CalendarView::clearAllViews()
2570{ 2573{
2571 mTodoList->clearList(); 2574 mTodoList->clearList();
2572 mViewManager->clearAllViews(); 2575 mViewManager->clearAllViews();
2573 SearchDialog * sd = mDialogManager->getSearchDialog(); 2576 SearchDialog * sd = mDialogManager->getSearchDialog();
2574 if ( sd ) { 2577 if ( sd ) {
2575 KOListView* kol = sd->listview(); 2578 KOListView* kol = sd->listview();
2576 if ( kol ) 2579 if ( kol )
2577 kol->clearList(); 2580 kol->clearList();
2578 } 2581 }
2579} 2582}
2580void CalendarView::updateView() 2583void CalendarView::updateView()
2581{ 2584{
2582 DateList tmpList = mNavigator->selectedDates(); 2585 DateList tmpList = mNavigator->selectedDates();
2583 2586
2584 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2587 if ( KOPrefs::instance()->mHideNonStartedTodos )
2585 mTodoList->updateView(); 2588 mTodoList->updateView();
2586 // We assume that the navigator only selects consecutive days. 2589 // We assume that the navigator only selects consecutive days.
2587 updateView( tmpList.first(), tmpList.last() ); 2590 updateView( tmpList.first(), tmpList.last() );
2588} 2591}
2589 2592
2590void CalendarView::updateUnmanagedViews() 2593void CalendarView::updateUnmanagedViews()
2591{ 2594{
2592 mDateNavigator->updateDayMatrix(); 2595 mDateNavigator->updateDayMatrix();
2593} 2596}
2594 2597
2595int CalendarView::msgItemDelete(const QString name) 2598int CalendarView::msgItemDelete(const QString name)
2596{ 2599{
2597 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2600 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2598 i18n("This item will be\npermanently deleted."), 2601 i18n("This item will be\npermanently deleted."),
2599 i18n("KO/Pi Confirmation"),i18n("Delete")); 2602 i18n("KO/Pi Confirmation"),i18n("Delete"));
2600} 2603}
2601 2604
2602 2605
2603void CalendarView::edit_cut() 2606void CalendarView::edit_cut()
2604{ 2607{
2605 Event *anEvent=0; 2608 Event *anEvent=0;
2606 2609
2607 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2610 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2608 2611
2609 if (mViewManager->currentView()->isEventView()) { 2612 if (mViewManager->currentView()->isEventView()) {
2610 if ( incidence && incidence->typeID() == eventID ) { 2613 if ( incidence && incidence->typeID() == eventID ) {
2611 anEvent = static_cast<Event *>(incidence); 2614 anEvent = static_cast<Event *>(incidence);
2612 } 2615 }
2613 } 2616 }
2614 2617
2615 if (!anEvent) { 2618 if (!anEvent) {
2616 KNotifyClient::beep(); 2619 KNotifyClient::beep();
2617 return; 2620 return;
2618 } 2621 }
2619 DndFactory factory( mCalendar ); 2622 DndFactory factory( mCalendar );
2620 factory.cutIncidence(anEvent); 2623 factory.cutIncidence(anEvent);
2621 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2624 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2622} 2625}
2623 2626
2624void CalendarView::edit_copy() 2627void CalendarView::edit_copy()
2625{ 2628{
2626 Event *anEvent=0; 2629 Event *anEvent=0;
2627 2630
2628 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2631 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2629 2632
2630 if (mViewManager->currentView()->isEventView()) { 2633 if (mViewManager->currentView()->isEventView()) {
2631 if ( incidence && incidence->typeID() == eventID ) { 2634 if ( incidence && incidence->typeID() == eventID ) {
2632 anEvent = static_cast<Event *>(incidence); 2635 anEvent = static_cast<Event *>(incidence);
2633 } 2636 }
2634 } 2637 }
2635 2638
2636 if (!anEvent) { 2639 if (!anEvent) {
2637 KNotifyClient::beep(); 2640 KNotifyClient::beep();
2638 return; 2641 return;
2639 } 2642 }
2640 DndFactory factory( mCalendar ); 2643 DndFactory factory( mCalendar );
2641 factory.copyIncidence(anEvent); 2644 factory.copyIncidence(anEvent);
2642} 2645}
2643 2646
2644void CalendarView::edit_paste() 2647void CalendarView::edit_paste()
2645{ 2648{
2646 QDate date = mNavigator->selectedDates().first(); 2649 QDate date = mNavigator->selectedDates().first();
2647 2650
2648 DndFactory factory( mCalendar ); 2651 DndFactory factory( mCalendar );
2649 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2652 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2650 2653
2651 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2654 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2652} 2655}
2653void CalendarView::edit_global_options() 2656void CalendarView::edit_global_options()
2654{ 2657{
2655 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2658 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2656 emit save(); 2659 emit save();
2657 emit saveStopTimer(); 2660 emit saveStopTimer();
2658 mDialogManager->showGlobalOptionsDialog(); 2661 mDialogManager->showGlobalOptionsDialog();
2659 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2662 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2660 emit saveStopTimer(); 2663 emit saveStopTimer();
2661 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2664 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2662 i18n("Timezone settings"),i18n("Reload"))) { 2665 i18n("Timezone settings"),i18n("Reload"))) {
2663 qDebug("KO: TZ reload cancelled "); 2666 qDebug("KO: TZ reload cancelled ");
2664 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2667 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2665 return; 2668 return;
2666 } 2669 }
2667 qDebug("KO: Timezone change "); 2670 qDebug("KO: Timezone change ");
2668 openCalendar( MainWindow::defaultFileName() ); 2671 openCalendar( MainWindow::defaultFileName() );
2669 setModified(true); 2672 setModified(true);
2670 } 2673 }
2671 else 2674 else
2672 qDebug("KO: No tz change "); 2675 qDebug("KO: No tz change ");
2673} 2676}
2674void CalendarView::edit_options() 2677void CalendarView::edit_options()
2675{ 2678{
2676 mDialogManager->showOptionsDialog(); 2679 mDialogManager->showOptionsDialog();
2677} 2680}
2678 2681
2679 2682
2680void CalendarView::slotSelectPickerDate( QDate d) 2683void CalendarView::slotSelectPickerDate( QDate d)
2681{ 2684{
2682 mDateFrame->hide(); 2685 mDateFrame->hide();
2683 if ( mDatePickerMode == 1 ) { 2686 if ( mDatePickerMode == 1 ) {
2684 mNavigator->slotDaySelect( d ); 2687 mNavigator->slotDaySelect( d );
2685 } else if ( mDatePickerMode == 2 ) { 2688 } else if ( mDatePickerMode == 2 ) {
2686 if ( mMoveIncidence->typeID() == todoID ) { 2689 if ( mMoveIncidence->typeID() == todoID ) {
2687 Todo * to = (Todo *) mMoveIncidence; 2690 Todo * to = (Todo *) mMoveIncidence;
2688 QTime tim; 2691 QTime tim;
2689 int len = 0; 2692 int len = 0;
2690 if ( to->hasStartDate() && to->hasDueDate() ) 2693 if ( to->hasStartDate() && to->hasDueDate() )
2691 len = to->dtStart().secsTo( to->dtDue()); 2694 len = to->dtStart().secsTo( to->dtDue());
2692 if ( to->hasDueDate() ) 2695 if ( to->hasDueDate() )
2693 tim = to->dtDue().time(); 2696 tim = to->dtDue().time();
2694 else { 2697 else {
2695 tim = QTime ( 0,0,0 ); 2698 tim = QTime ( 0,0,0 );
2696 to->setFloats( true ); 2699 to->setFloats( true );
2697 to->setHasDueDate( true ); 2700 to->setHasDueDate( true );
2698 } 2701 }
2699 QDateTime dt ( d,tim ); 2702 QDateTime dt ( d,tim );
2700 to->setDtDue( dt ); 2703 to->setDtDue( dt );
2701 2704
2702 if ( to->hasStartDate() ) { 2705 if ( to->hasStartDate() ) {
2703 if ( len>0 ) 2706 if ( len>0 )
2704 to->setDtStart(to->dtDue().addSecs( -len )); 2707 to->setDtStart(to->dtDue().addSecs( -len ));
2705 else 2708 else
2706 if (to->dtStart() > to->dtDue() ) 2709 if (to->dtStart() > to->dtDue() )
2707 to->setDtStart(to->dtDue().addDays( -3 )); 2710 to->setDtStart(to->dtDue().addDays( -3 ));
2708 } 2711 }
2709 2712
2710 todoChanged( to ); 2713 todoChanged( to );
2711 } else { 2714 } else {
2712 if ( mMoveIncidence->doesRecur() ) { 2715 if ( mMoveIncidence->doesRecur() ) {
2713#if 0 2716#if 0
2714 // PENDING implement this 2717 // PENDING implement this
2715 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2718 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2716 mCalendar()->addIncidence( newInc ); 2719 mCalendar()->addIncidence( newInc );
2717 if ( mMoveIncidence->typeID() == todoID ) 2720 if ( mMoveIncidence->typeID() == todoID )
2718 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2721 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2719 else 2722 else
2720 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2723 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2721 mMoveIncidence = newInc; 2724 mMoveIncidence = newInc;
2722 2725
2723#endif 2726#endif
2724 } 2727 }
2725 QTime tim = mMoveIncidence->dtStart().time(); 2728 QTime tim = mMoveIncidence->dtStart().time();
2726 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2729 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2727 QDateTime dt ( d,tim ); 2730 QDateTime dt ( d,tim );
2728 mMoveIncidence->setDtStart( dt ); 2731 mMoveIncidence->setDtStart( dt );
2729 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2732 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2730 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2733 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2731 } 2734 }
2732 2735
2733 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2736 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2734 } 2737 }
2735} 2738}
2736 2739
2737void CalendarView::removeCategories() 2740void CalendarView::removeCategories()
2738{ 2741{
2739 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2742 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2740 QStringList catList = KOPrefs::instance()->mCustomCategories; 2743 QStringList catList = KOPrefs::instance()->mCustomCategories;
2741 QStringList catIncList; 2744 QStringList catIncList;
2742 QStringList newCatList; 2745 QStringList newCatList;
2743 Incidence* inc = incList.first(); 2746 Incidence* inc = incList.first();
2744 int i; 2747 int i;
2745 int count = 0; 2748 int count = 0;
2746 while ( inc ) { 2749 while ( inc ) {
2747 newCatList.clear(); 2750 newCatList.clear();
2748 catIncList = inc->categories() ; 2751 catIncList = inc->categories() ;
2749 for( i = 0; i< catIncList.count(); ++i ) { 2752 for( i = 0; i< catIncList.count(); ++i ) {
2750 if ( catList.contains (catIncList[i])) 2753 if ( catList.contains (catIncList[i]))
2751 newCatList.append( catIncList[i] ); 2754 newCatList.append( catIncList[i] );
2752 } 2755 }
2753 newCatList.sort(); 2756 newCatList.sort();
2754 inc->setCategories( newCatList.join(",") ); 2757 inc->setCategories( newCatList.join(",") );
2755 inc = incList.next(); 2758 inc = incList.next();
2756 } 2759 }
2757} 2760}
2758 2761
2759int CalendarView::addCategories() 2762int CalendarView::addCategories()
2760{ 2763{
2761 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2764 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2762 QStringList catList = KOPrefs::instance()->mCustomCategories; 2765 QStringList catList = KOPrefs::instance()->mCustomCategories;
2763 QStringList catIncList; 2766 QStringList catIncList;
2764 Incidence* inc = incList.first(); 2767 Incidence* inc = incList.first();
2765 int i; 2768 int i;
2766 int count = 0; 2769 int count = 0;
2767 while ( inc ) { 2770 while ( inc ) {
2768 catIncList = inc->categories() ; 2771 catIncList = inc->categories() ;
2769 for( i = 0; i< catIncList.count(); ++i ) { 2772 for( i = 0; i< catIncList.count(); ++i ) {
2770 if ( !catList.contains (catIncList[i])) { 2773 if ( !catList.contains (catIncList[i])) {
2771 catList.append( catIncList[i] ); 2774 catList.append( catIncList[i] );
2772 //qDebug("add cat %s ", catIncList[i].latin1()); 2775 //qDebug("add cat %s ", catIncList[i].latin1());
2773 ++count; 2776 ++count;
2774 } 2777 }
2775 } 2778 }
2776 inc = incList.next(); 2779 inc = incList.next();
2777 } 2780 }
2778 catList.sort(); 2781 catList.sort();
2779 KOPrefs::instance()->mCustomCategories = catList; 2782 KOPrefs::instance()->mCustomCategories = catList;
2780 return count; 2783 return count;
2781} 2784}
2782 2785
2783void CalendarView::manageCategories() 2786void CalendarView::manageCategories()
2784{ 2787{
2785 KOCatPrefs* cp = new KOCatPrefs(); 2788 KOCatPrefs* cp = new KOCatPrefs();
2786 cp->show(); 2789 cp->show();
2787 int w =cp->sizeHint().width() ; 2790 int w =cp->sizeHint().width() ;
2788 int h = cp->sizeHint().height() ; 2791 int h = cp->sizeHint().height() ;
2789 int dw = QApplication::desktop()->width(); 2792 int dw = QApplication::desktop()->width();
2790 int dh = QApplication::desktop()->height(); 2793 int dh = QApplication::desktop()->height();
2791 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2794 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2792 if ( !cp->exec() ) { 2795 if ( !cp->exec() ) {
2793 delete cp; 2796 delete cp;
2794 return; 2797 return;
2795 } 2798 }
2796 int count = 0; 2799 int count = 0;
2797 if ( cp->addCat() ) { 2800 if ( cp->addCat() ) {
2798 count = addCategories(); 2801 count = addCategories();
2799 if ( count ) { 2802 if ( count ) {
2800 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2803 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2801 writeSettings(); 2804 writeSettings();
2802 } else 2805 } else
2803 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2806 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2804 } else { 2807 } else {
2805 removeCategories(); 2808 removeCategories();
2806 updateView(); 2809 updateView();
2807 } 2810 }
2808 delete cp; 2811 delete cp;
2809} 2812}
2810 2813
2811void CalendarView::beamIncidence(Incidence * Inc) 2814void CalendarView::beamIncidence(Incidence * Inc)
2812{ 2815{
2813 QPtrList<Incidence> delSel ; 2816 QPtrList<Incidence> delSel ;
2814 delSel.append(Inc); 2817 delSel.append(Inc);
2815 beamIncidenceList( delSel ); 2818 beamIncidenceList( delSel );
2816} 2819}
2817void CalendarView::beamCalendar() 2820void CalendarView::beamCalendar()
2818{ 2821{
2819 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2822 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2820 //qDebug("beamCalendar() "); 2823 //qDebug("beamCalendar() ");
2821 beamIncidenceList( delSel ); 2824 beamIncidenceList( delSel );
2822} 2825}
2823void CalendarView::beamFilteredCalendar() 2826void CalendarView::beamFilteredCalendar()
2824{ 2827{
2825 QPtrList<Incidence> delSel = mCalendar->incidences(); 2828 QPtrList<Incidence> delSel = mCalendar->incidences();
2826 //qDebug("beamFilteredCalendar() "); 2829 //qDebug("beamFilteredCalendar() ");
2827 beamIncidenceList( delSel ); 2830 beamIncidenceList( delSel );
2828} 2831}
2829void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2832void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2830{ 2833{
2831 if ( beamDialog->exec () == QDialog::Rejected ) 2834 if ( beamDialog->exec () == QDialog::Rejected )
2832 return; 2835 return;
2833#ifdef DESKTOP_VERSION 2836#ifdef DESKTOP_VERSION
2834 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2837 QString fn = locateLocal( "tmp", "kopibeamfile" );
2835#else 2838#else
2836 QString fn = "/tmp/kopibeamfile"; 2839 QString fn = "/tmp/kopibeamfile";
2837#endif 2840#endif
2838 QString mes; 2841 QString mes;
2839 bool createbup = true; 2842 bool createbup = true;
2840 if ( createbup ) { 2843 if ( createbup ) {
2841 QString description = "\n"; 2844 QString description = "\n";
2842 CalendarLocal* cal = new CalendarLocal(); 2845 CalendarLocal* cal = new CalendarLocal();
2843 if ( beamDialog->beamLocal() ) 2846 if ( beamDialog->beamLocal() )
2844 cal->setLocalTime(); 2847 cal->setLocalTime();
2845 else 2848 else
2846 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2849 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2847 Incidence *incidence = delSel.first(); 2850 Incidence *incidence = delSel.first();
2848 bool addText = false; 2851 bool addText = false;
2849 if ( delSel.count() < 10 ) 2852 if ( delSel.count() < 10 )
2850 addText = true; 2853 addText = true;
2851 else { 2854 else {
2852 description.sprintf(i18n(" %d items?"),delSel.count() ); 2855 description.sprintf(i18n(" %d items?"),delSel.count() );
2853 } 2856 }
2854 while ( incidence ) { 2857 while ( incidence ) {
2855 Incidence *in = incidence->clone(); 2858 Incidence *in = incidence->clone();
2856 if ( ! in->summary().isEmpty() ) { 2859 if ( ! in->summary().isEmpty() ) {
2857 in->setDescription(""); 2860 in->setDescription("");
2858 } else { 2861 } else {
2859 in->setSummary( in->description().left(20)); 2862 in->setSummary( in->description().left(20));
2860 in->setDescription(""); 2863 in->setDescription("");
2861 } 2864 }
2862 if ( addText ) 2865 if ( addText )
2863 description += in->summary() + "\n"; 2866 description += in->summary() + "\n";
2864 cal->addIncidence( in ); 2867 cal->addIncidence( in );
2865 incidence = delSel.next(); 2868 incidence = delSel.next();
2866 } 2869 }
2867 if ( beamDialog->beamVcal() ) { 2870 if ( beamDialog->beamVcal() ) {
2868 fn += ".vcs"; 2871 fn += ".vcs";
2869 FileStorage storage( cal, fn, new VCalFormat ); 2872 FileStorage storage( cal, fn, new VCalFormat );
2870 storage.save(); 2873 storage.save();
2871 } else { 2874 } else {
2872 fn += ".ics"; 2875 fn += ".ics";
2873 FileStorage storage( cal, fn, new ICalFormat( ) ); 2876 FileStorage storage( cal, fn, new ICalFormat( ) );
2874 storage.save(); 2877 storage.save();
2875 } 2878 }
2876 delete cal; 2879 delete cal;
2877 mes = i18n("KO/Pi: Ready for beaming"); 2880 mes = i18n("KO/Pi: Ready for beaming");
2878 topLevelWidget()->setCaption(mes); 2881 topLevelWidget()->setCaption(mes);
2879 KApplication::convert2latin1( fn ); 2882 KApplication::convert2latin1( fn );
2880#ifndef DESKTOP_VERSION 2883#ifndef DESKTOP_VERSION
2881 Ir *ir = new Ir( this ); 2884 Ir *ir = new Ir( this );
2882 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2885 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2883 ir->send( fn, description, "text/x-vCalendar" ); 2886 ir->send( fn, description, "text/x-vCalendar" );
2884#endif 2887#endif
2885 } 2888 }
2886} 2889}
2887void CalendarView::beamDone( Ir *ir ) 2890void CalendarView::beamDone( Ir *ir )
2888{ 2891{
2889#ifndef DESKTOP_VERSION 2892#ifndef DESKTOP_VERSION
2890 delete ir; 2893 delete ir;
2891#endif 2894#endif
2892 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2895 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2893 topLevelWidget()->raise(); 2896 topLevelWidget()->raise();
2894} 2897}
2895 2898
2896void CalendarView::moveIncidence(Incidence * inc ) 2899void CalendarView::moveIncidence(Incidence * inc )
2897{ 2900{
2898 if ( !inc ) return; 2901 if ( !inc ) return;
2899 showDatePickerPopup(); 2902 showDatePickerPopup();
2900 mDatePickerMode = 2; 2903 mDatePickerMode = 2;
2901 mMoveIncidence = inc ; 2904 mMoveIncidence = inc ;
2902 QDate da; 2905 QDate da;
2903 if ( mMoveIncidence->typeID() == todoID ) { 2906 if ( mMoveIncidence->typeID() == todoID ) {
2904 Todo * to = (Todo *) mMoveIncidence; 2907 Todo * to = (Todo *) mMoveIncidence;
2905 if ( to->hasDueDate() ) 2908 if ( to->hasDueDate() )
2906 da = to->dtDue().date(); 2909 da = to->dtDue().date();
2907 else 2910 else
2908 da = QDate::currentDate(); 2911 da = QDate::currentDate();
2909 } else { 2912 } else {
2910 da = mMoveIncidence->dtStart().date(); 2913 da = mMoveIncidence->dtStart().date();
2911 } 2914 }
2912 //PENDING set date for recurring incidence to date of recurrence 2915 //PENDING set date for recurring incidence to date of recurrence
2913 //mMoveIncidenceOldDate; 2916 //mMoveIncidenceOldDate;
2914 mDatePicker->setDate( da ); 2917 mDatePicker->setDate( da );
2915} 2918}
2916void CalendarView::showDatePickerPopup() 2919void CalendarView::showDatePickerPopup()
2917{ 2920{
2918 if ( mDateFrame->isVisible() ) 2921 if ( mDateFrame->isVisible() )
2919 mDateFrame->hide(); 2922 mDateFrame->hide();
2920 else { 2923 else {
2921 int offX = 0, offY = 0; 2924 int offX = 0, offY = 0;
2922#ifdef DESKTOP_VERSION 2925#ifdef DESKTOP_VERSION
2923 int w =mDatePicker->sizeHint().width() ; 2926 int w =mDatePicker->sizeHint().width() ;
2924 int h = mDatePicker->sizeHint().height() ; 2927 int h = mDatePicker->sizeHint().height() ;
2925 int dw = topLevelWidget()->width(); 2928 int dw = topLevelWidget()->width();
2926 int dh = topLevelWidget()->height(); 2929 int dh = topLevelWidget()->height();
2927 offX = topLevelWidget()->x(); 2930 offX = topLevelWidget()->x();
2928 offY = topLevelWidget()->y(); 2931 offY = topLevelWidget()->y();
2929#else 2932#else
2930 int w =mDatePicker->sizeHint().width() ; 2933 int w =mDatePicker->sizeHint().width() ;
2931 int h = mDatePicker->sizeHint().height() ; 2934 int h = mDatePicker->sizeHint().height() ;
2932 int dw = QApplication::desktop()->width(); 2935 int dw = QApplication::desktop()->width();
2933 int dh = QApplication::desktop()->height(); 2936 int dh = QApplication::desktop()->height();
2934#endif 2937#endif
2935 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2938 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2936 mDateFrame->show(); 2939 mDateFrame->show();
2937 } 2940 }
2938} 2941}
2939void CalendarView::showDatePicker( ) 2942void CalendarView::showDatePicker( )
2940{ 2943{
2941 showDatePickerPopup(); 2944 showDatePickerPopup();
2942 mDatePickerMode = 1; 2945 mDatePickerMode = 1;
2943 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2946 mDatePicker->setDate( mNavigator->selectedDates().first() );
2944} 2947}
2945 2948
2946void CalendarView::showEventEditor() 2949void CalendarView::showEventEditor()
2947{ 2950{
2948#ifdef DESKTOP_VERSION 2951#ifdef DESKTOP_VERSION
2949 int x,y,w,h; 2952 int x,y,w,h;
2950 x = mEventEditor->geometry().x(); 2953 x = mEventEditor->geometry().x();
2951 y = mEventEditor->geometry().y(); 2954 y = mEventEditor->geometry().y();
2952 w = mEventEditor->width(); 2955 w = mEventEditor->width();
2953 h = mEventEditor->height(); 2956 h = mEventEditor->height();
2954 mEventEditor->show(); 2957 mEventEditor->show();
2955 mEventEditor->setGeometry(x,y,w,h); 2958 mEventEditor->setGeometry(x,y,w,h);
2956#else 2959#else
2957 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2960 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2958 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2961 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2959 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2962 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2960 qApp->processEvents(); 2963 qApp->processEvents();
2961 delete mEventEditor; 2964 delete mEventEditor;
2962 mEventEditor = mDialogManager->getEventEditor(); 2965 mEventEditor = mDialogManager->getEventEditor();
2963 topLevelWidget()->setCaption( i18n("") ); 2966 topLevelWidget()->setCaption( i18n("") );
2964 } 2967 }
2965 mEventEditor->showMaximized(); 2968 mEventEditor->showMaximized();
2966#endif 2969#endif
2967} 2970}
2968void CalendarView::showTodoEditor() 2971void CalendarView::showTodoEditor()
2969{ 2972{
2970#ifdef DESKTOP_VERSION 2973#ifdef DESKTOP_VERSION
2971 int x,y,w,h; 2974 int x,y,w,h;
2972 x = mTodoEditor->geometry().x(); 2975 x = mTodoEditor->geometry().x();
2973 y = mTodoEditor->geometry().y(); 2976 y = mTodoEditor->geometry().y();
2974 w = mTodoEditor->width(); 2977 w = mTodoEditor->width();
2975 h = mTodoEditor->height(); 2978 h = mTodoEditor->height();
2976 mTodoEditor->show(); 2979 mTodoEditor->show();
2977 mTodoEditor->setGeometry(x,y,w,h); 2980 mTodoEditor->setGeometry(x,y,w,h);
2978#else 2981#else
2979 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2982 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2980 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2983 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2981 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2984 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2982 qApp->processEvents(); 2985 qApp->processEvents();
2983 delete mTodoEditor; 2986 delete mTodoEditor;
2984 mTodoEditor = mDialogManager->getTodoEditor(); 2987 mTodoEditor = mDialogManager->getTodoEditor();
2985 topLevelWidget()->setCaption( i18n("") ); 2988 topLevelWidget()->setCaption( i18n("") );
2986 } 2989 }
2987 mTodoEditor->showMaximized(); 2990 mTodoEditor->showMaximized();
2988#endif 2991#endif
2989} 2992}
2990 2993
2991void CalendarView::cloneIncidence() 2994void CalendarView::cloneIncidence()
2992{ 2995{
2993 Incidence *incidence = currentSelection(); 2996 Incidence *incidence = currentSelection();
2994 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2997 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2995 if ( incidence ) { 2998 if ( incidence ) {
2996 cloneIncidence(incidence); 2999 cloneIncidence(incidence);
2997 } 3000 }
2998} 3001}
2999void CalendarView::moveIncidence() 3002void CalendarView::moveIncidence()
3000{ 3003{
3001 Incidence *incidence = currentSelection(); 3004 Incidence *incidence = currentSelection();
3002 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3005 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3003 if ( incidence ) { 3006 if ( incidence ) {
3004 moveIncidence(incidence); 3007 moveIncidence(incidence);
3005 } 3008 }
3006} 3009}
3007void CalendarView::beamIncidence() 3010void CalendarView::beamIncidence()
3008{ 3011{
3009 Incidence *incidence = currentSelection(); 3012 Incidence *incidence = currentSelection();
3010 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3013 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3011 if ( incidence ) { 3014 if ( incidence ) {
3012 beamIncidence(incidence); 3015 beamIncidence(incidence);
3013 } 3016 }
3014} 3017}
3015void CalendarView::toggleCancelIncidence() 3018void CalendarView::toggleCancelIncidence()
3016{ 3019{
3017 Incidence *incidence = currentSelection(); 3020 Incidence *incidence = currentSelection();
3018 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3021 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3019 if ( incidence ) { 3022 if ( incidence ) {
3020 cancelIncidence(incidence); 3023 cancelIncidence(incidence);
3021 } 3024 }
3022} 3025}
3023 3026
3024 3027
3025void CalendarView::cancelIncidence(Incidence * inc ) 3028void CalendarView::cancelIncidence(Incidence * inc )
3026{ 3029{
3027 inc->setCancelled( ! inc->cancelled() ); 3030 inc->setCancelled( ! inc->cancelled() );
3028 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3031 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3029 updateView(); 3032 updateView();
3030} 3033}
3031void CalendarView::cloneIncidence(Incidence * orgInc ) 3034void CalendarView::cloneIncidence(Incidence * orgInc )
3032{ 3035{
3033 Incidence * newInc = orgInc->clone(); 3036 Incidence * newInc = orgInc->clone();
3034 newInc->recreate(); 3037 newInc->recreate();
3035 3038
3036 if ( newInc->typeID() == todoID ) { 3039 if ( newInc->typeID() == todoID ) {
3037 Todo* t = (Todo*) newInc; 3040 Todo* t = (Todo*) newInc;
3038 bool cloneSub = false; 3041 bool cloneSub = false;
3039 if ( orgInc->relations().count() ) { 3042 if ( orgInc->relations().count() ) {
3040 int result = KMessageBox::warningYesNoCancel(this, 3043 int result = KMessageBox::warningYesNoCancel(this,
3041 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), 3044 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
3042 i18n("Todo has subtodos"), 3045 i18n("Todo has subtodos"),
3043 i18n("Yes"), 3046 i18n("Yes"),
3044 i18n("No")); 3047 i18n("No"));
3045 3048
3046 if ( result == KMessageBox::Cancel ) { 3049 if ( result == KMessageBox::Cancel ) {
3047 delete t; 3050 delete t;
3048 return; 3051 return;
3049 } 3052 }
3050 if (result == KMessageBox::Yes) cloneSub = true; 3053 if (result == KMessageBox::Yes) cloneSub = true;
3051 } 3054 }
3052 showTodoEditor(); 3055 showTodoEditor();
3053 mTodoEditor->editTodo( t ); 3056 mTodoEditor->editTodo( t );
3054 if ( mTodoEditor->exec() ) { 3057 if ( mTodoEditor->exec() ) {
3055 if ( cloneSub ) { 3058 if ( cloneSub ) {
3056 orgInc->cloneRelations( t ); 3059 orgInc->cloneRelations( t );
3057 mCalendar->addIncidenceBranch( t ); 3060 mCalendar->addIncidenceBranch( t );
3058 updateView(); 3061 updateView();
3059 3062
3060 } else { 3063 } else {
3061 mCalendar->addTodo( t ); 3064 mCalendar->addTodo( t );
3062 updateView(); 3065 updateView();
3063 } 3066 }
3064 } else { 3067 } else {
3065 delete t; 3068 delete t;
3066 } 3069 }
3067 } 3070 }
3068 else { 3071 else {
3069 Event* e = (Event*) newInc; 3072 Event* e = (Event*) newInc;
3070 showEventEditor(); 3073 showEventEditor();
3071 mEventEditor->editEvent( e ); 3074 mEventEditor->editEvent( e );
3072 if ( mEventEditor->exec() ) { 3075 if ( mEventEditor->exec() ) {
3073 mCalendar->addEvent( e ); 3076 mCalendar->addEvent( e );
3074 updateView(); 3077 updateView();
3075 } else { 3078 } else {
3076 delete e; 3079 delete e;
3077 } 3080 }
3078 } 3081 }
3079 setActiveWindow(); 3082 setActiveWindow();
3080} 3083}
3081 3084
3082void CalendarView::newEvent() 3085void CalendarView::newEvent()
3083{ 3086{
3084 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3087 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3085 KOAgendaView *aView = mViewManager->agendaView(); 3088 KOAgendaView *aView = mViewManager->agendaView();
3086 if (aView) { 3089 if (aView) {
3087 if (aView->selectionStart().isValid()) { 3090 if (aView->selectionStart().isValid()) {
3088 if (aView->selectedIsAllDay()) { 3091 if (aView->selectedIsAllDay()) {
3089 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3092 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3090 } else { 3093 } else {
3091 newEvent(aView->selectionStart(),aView->selectionEnd()); 3094 newEvent(aView->selectionStart(),aView->selectionEnd());
3092 } 3095 }
3093 return; 3096 return;
3094 } 3097 }
3095 } 3098 }
3096 3099
3097 QDate date = mNavigator->selectedDates().first(); 3100 QDate date = mNavigator->selectedDates().first();
3098 QDateTime current = QDateTime::currentDateTime(); 3101 QDateTime current = QDateTime::currentDateTime();
3099 if ( date <= current.date() ) { 3102 if ( date <= current.date() ) {
3100 int hour = current.time().hour() +1; 3103 int hour = current.time().hour() +1;
3101 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3104 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3102 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3105 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3103 } else 3106 } else
3104 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3107 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3105 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3108 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3106 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3109 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3107} 3110}
3108 3111
3109void CalendarView::newEvent(QDateTime fh) 3112void CalendarView::newEvent(QDateTime fh)
3110{ 3113{
3111 newEvent(fh, 3114 newEvent(fh,
3112 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3115 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3113} 3116}
3114 3117
3115void CalendarView::newEvent(QDate dt) 3118void CalendarView::newEvent(QDate dt)
3116{ 3119{
3117 newEvent(QDateTime(dt, QTime(0,0,0)), 3120 newEvent(QDateTime(dt, QTime(0,0,0)),
3118 QDateTime(dt, QTime(0,0,0)), true); 3121 QDateTime(dt, QTime(0,0,0)), true);
3119} 3122}
3120void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3123void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3121{ 3124{
3122 newEvent(fromHint, toHint, false); 3125 newEvent(fromHint, toHint, false);
3123} 3126}
3124void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3127void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3125{ 3128{
3126 3129
3127 showEventEditor(); 3130 showEventEditor();
3128 mEventEditor->newEvent(fromHint,toHint,allDay); 3131 mEventEditor->newEvent(fromHint,toHint,allDay);
3129 if ( mFilterView->filtersEnabled() ) { 3132 if ( mFilterView->filtersEnabled() ) {
3130 CalFilter *filter = mFilterView->selectedFilter(); 3133 CalFilter *filter = mFilterView->selectedFilter();
3131 if (filter && filter->showCategories()) { 3134 if (filter && filter->showCategories()) {
3132 mEventEditor->setCategories(filter->categoryList().join(",") ); 3135 mEventEditor->setCategories(filter->categoryList().join(",") );
3133 } 3136 }
3134 if ( filter ) 3137 if ( filter )
3135 mEventEditor->setSecrecy( filter->getSecrecy() ); 3138 mEventEditor->setSecrecy( filter->getSecrecy() );
3136 } 3139 }
3137 mEventEditor->exec(); 3140 mEventEditor->exec();
3138 setActiveWindow(); 3141 setActiveWindow();
3139} 3142}
3140void CalendarView::todoAdded(Todo * t) 3143void CalendarView::todoAdded(Todo * t)
3141{ 3144{
3142 3145
3143 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3146 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3144 updateTodoViews(); 3147 updateTodoViews();
3145} 3148}
3146void CalendarView::todoChanged(Todo * t) 3149void CalendarView::todoChanged(Todo * t)
3147{ 3150{
3148 emit todoModified( t, 4 ); 3151 emit todoModified( t, 4 );
3149 // updateTodoViews(); 3152 // updateTodoViews();
3150} 3153}
3151void CalendarView::todoToBeDeleted(Todo *) 3154void CalendarView::todoToBeDeleted(Todo *)
3152{ 3155{
3153 //qDebug("todoToBeDeleted(Todo *) "); 3156 //qDebug("todoToBeDeleted(Todo *) ");
3154 updateTodoViews(); 3157 updateTodoViews();
3155} 3158}
3156void CalendarView::todoDeleted() 3159void CalendarView::todoDeleted()
3157{ 3160{
3158 //qDebug(" todoDeleted()"); 3161 //qDebug(" todoDeleted()");
3159 updateTodoViews(); 3162 updateTodoViews();
3160} 3163}
3161 3164
3162 3165
3163void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3166void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3164{ 3167{
3165 showTodoEditor(); 3168 showTodoEditor();
3166 mTodoEditor->newTodo(dt,0,allday); 3169 mTodoEditor->newTodo(dt,0,allday);
3167 if ( mFilterView->filtersEnabled() ) { 3170 if ( mFilterView->filtersEnabled() ) {
3168 CalFilter *filter = mFilterView->selectedFilter(); 3171 CalFilter *filter = mFilterView->selectedFilter();
3169 if (filter && filter->showCategories()) { 3172 if (filter && filter->showCategories()) {
3170 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3173 mTodoEditor->setCategories(filter->categoryList().join(",") );
3171 } 3174 }
3172 if ( filter ) 3175 if ( filter )
3173 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3176 mTodoEditor->setSecrecy( filter->getSecrecy() );
3174 } 3177 }
3175 mTodoEditor->exec(); 3178 mTodoEditor->exec();
3176 setActiveWindow(); 3179 setActiveWindow();
3177} 3180}
3178 3181
3179void CalendarView::newTodo() 3182void CalendarView::newTodo()
3180{ 3183{
3181 newTodoDateTime( QDateTime(),true ); 3184 newTodoDateTime( QDateTime(),true );
3182} 3185}
3183 3186
3184void CalendarView::newSubTodo() 3187void CalendarView::newSubTodo()
3185{ 3188{
3186 Todo *todo = selectedTodo(); 3189 Todo *todo = selectedTodo();
3187 if ( todo ) newSubTodo( todo ); 3190 if ( todo ) newSubTodo( todo );
3188} 3191}
3189 3192
3190void CalendarView::newSubTodo(Todo *parentEvent) 3193void CalendarView::newSubTodo(Todo *parentEvent)
3191{ 3194{
3192 3195
3193 showTodoEditor(); 3196 showTodoEditor();
3194 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3197 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3195 mTodoEditor->exec(); 3198 mTodoEditor->exec();
3196 setActiveWindow(); 3199 setActiveWindow();
3197} 3200}
3198 3201
3199void CalendarView::newFloatingEvent() 3202void CalendarView::newFloatingEvent()
3200{ 3203{
3201 DateList tmpList = mNavigator->selectedDates(); 3204 DateList tmpList = mNavigator->selectedDates();
3202 QDate date = tmpList.first(); 3205 QDate date = tmpList.first();
3203 3206
3204 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3207 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3205 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3208 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3206} 3209}
3207 3210
3208 3211
3209void CalendarView::editEvent( Event *event ) 3212void CalendarView::editEvent( Event *event )
3210{ 3213{
3211 3214
3212 if ( !event ) return; 3215 if ( !event ) return;
3213 if ( event->isReadOnly() ) { 3216 if ( event->isReadOnly() ) {
3214 showEvent( event ); 3217 showEvent( event );
3215 return; 3218 return;
3216 } 3219 }
3217 showEventEditor(); 3220 showEventEditor();
3218 mEventEditor->editEvent( event , mFlagEditDescription); 3221 mEventEditor->editEvent( event , mFlagEditDescription);
3219 mEventEditor->exec(); 3222 mEventEditor->exec();
3220 setActiveWindow(); 3223 setActiveWindow();
3221 3224
3222} 3225}
3223void CalendarView::editJournal( Journal *jour ) 3226void CalendarView::editJournal( Journal *jour )
3224{ 3227{
3225 if ( !jour ) return; 3228 if ( !jour ) return;
3226 mDialogManager->hideSearchDialog(); 3229 mDialogManager->hideSearchDialog();
3227 mViewManager->showJournalView(); 3230 mViewManager->showJournalView();
3228 mNavigator->slotDaySelect( jour->dtStart().date() ); 3231 mNavigator->slotDaySelect( jour->dtStart().date() );
3229} 3232}
3230void CalendarView::editTodo( Todo *todo ) 3233void CalendarView::editTodo( Todo *todo )
3231{ 3234{
3232 if ( !todo ) return; 3235 if ( !todo ) return;
3233 3236
3234 if ( todo->isReadOnly() ) { 3237 if ( todo->isReadOnly() ) {
3235 showTodo( todo ); 3238 showTodo( todo );
3236 return; 3239 return;
3237 } 3240 }
3238 showTodoEditor(); 3241 showTodoEditor();
3239 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3242 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3240 mTodoEditor->exec(); 3243 mTodoEditor->exec();
3241 setActiveWindow(); 3244 setActiveWindow();
3242 3245
3243} 3246}
3244 3247
3245KOEventViewerDialog* CalendarView::getEventViewerDialog() 3248KOEventViewerDialog* CalendarView::getEventViewerDialog()
3246{ 3249{
3247 if ( !mEventViewerDialog ) { 3250 if ( !mEventViewerDialog ) {
3248 mEventViewerDialog = new KOEventViewerDialog(0); 3251 mEventViewerDialog = new KOEventViewerDialog(0);
3249 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3252 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3250 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3253 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3251 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3254 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3252 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3255 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3253 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3256 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3254 viewManager(), SLOT( showAgendaView( bool ) ) ); 3257 viewManager(), SLOT( showAgendaView( bool ) ) );
3255 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3258 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3256 this, SLOT( slotViewerClosed() ) ); 3259 this, SLOT( slotViewerClosed() ) );
3257 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3260 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3258 this, SLOT( todoChanged(Todo *) ) ); 3261 this, SLOT( todoChanged(Todo *) ) );
3259 mEventViewerDialog->resize( 640, 480 ); 3262 mEventViewerDialog->resize( 640, 480 );
3260 3263
3261 } 3264 }
3262 return mEventViewerDialog; 3265 return mEventViewerDialog;
3263} 3266}
3264void CalendarView::showEvent(Event *event) 3267void CalendarView::showEvent(Event *event)
3265{ 3268{
3266 getEventViewerDialog()->setEvent(event); 3269 getEventViewerDialog()->setEvent(event);
3267 getEventViewerDialog()->showMe(); 3270 getEventViewerDialog()->showMe();
3268} 3271}
3269 3272
3270void CalendarView::showTodo(Todo *event) 3273void CalendarView::showTodo(Todo *event)
3271{ 3274{
3272 getEventViewerDialog()->setTodo(event); 3275 getEventViewerDialog()->setTodo(event);
3273 getEventViewerDialog()->showMe(); 3276 getEventViewerDialog()->showMe();
3274} 3277}
3275void CalendarView::showJournal( Journal *jour ) 3278void CalendarView::showJournal( Journal *jour )
3276{ 3279{
3277 getEventViewerDialog()->setJournal(jour); 3280 getEventViewerDialog()->setJournal(jour);
3278 getEventViewerDialog()->showMe(); 3281 getEventViewerDialog()->showMe();
3279 3282
3280} 3283}
3281// void CalendarView::todoModified (Todo *event, int changed) 3284// void CalendarView::todoModified (Todo *event, int changed)
3282// { 3285// {
3283// // if (mDialogList.find (event) != mDialogList.end ()) { 3286// // if (mDialogList.find (event) != mDialogList.end ()) {
3284// // kdDebug() << "Todo modified and open" << endl; 3287// // kdDebug() << "Todo modified and open" << endl;
3285// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3288// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3286// // temp->modified (changed); 3289// // temp->modified (changed);
3287 3290
3288// // } 3291// // }
3289 3292
3290// mViewManager->updateView(); 3293// mViewManager->updateView();
3291// } 3294// }
3292 3295
3293void CalendarView::appointment_show() 3296void CalendarView::appointment_show()
3294{ 3297{
3295 Event *anEvent = 0; 3298 Event *anEvent = 0;
3296 3299
3297 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3300 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3298 3301
3299 if (mViewManager->currentView()->isEventView()) { 3302 if (mViewManager->currentView()->isEventView()) {
3300 if ( incidence && incidence->typeID() == eventID ) { 3303 if ( incidence && incidence->typeID() == eventID ) {
3301 anEvent = static_cast<Event *>(incidence); 3304 anEvent = static_cast<Event *>(incidence);
3302 } 3305 }
3303 } 3306 }
3304 3307
3305 if (!anEvent) { 3308 if (!anEvent) {
3306 KNotifyClient::beep(); 3309 KNotifyClient::beep();
3307 return; 3310 return;
3308 } 3311 }
3309 3312
3310 showEvent(anEvent); 3313 showEvent(anEvent);
3311} 3314}
3312 3315
3313void CalendarView::appointment_edit() 3316void CalendarView::appointment_edit()
3314{ 3317{
3315 Event *anEvent = 0; 3318 Event *anEvent = 0;
3316 3319
3317 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3320 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3318 3321
3319 if (mViewManager->currentView()->isEventView()) { 3322 if (mViewManager->currentView()->isEventView()) {
3320 if ( incidence && incidence->typeID() == eventID ) { 3323 if ( incidence && incidence->typeID() == eventID ) {
3321 anEvent = static_cast<Event *>(incidence); 3324 anEvent = static_cast<Event *>(incidence);
3322 } 3325 }
3323 } 3326 }
3324 3327
3325 if (!anEvent) { 3328 if (!anEvent) {
3326 KNotifyClient::beep(); 3329 KNotifyClient::beep();
3327 return; 3330 return;
3328 } 3331 }
3329 3332
3330 editEvent(anEvent); 3333 editEvent(anEvent);
3331} 3334}
3332 3335
3333void CalendarView::appointment_delete() 3336void CalendarView::appointment_delete()
3334{ 3337{
3335 Event *anEvent = 0; 3338 Event *anEvent = 0;
3336 3339
3337 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3340 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3338 3341
3339 if (mViewManager->currentView()->isEventView()) { 3342 if (mViewManager->currentView()->isEventView()) {
3340 if ( incidence && incidence->typeID() == eventID ) { 3343 if ( incidence && incidence->typeID() == eventID ) {
3341 anEvent = static_cast<Event *>(incidence); 3344 anEvent = static_cast<Event *>(incidence);
3342 } 3345 }
3343 } 3346 }
3344 3347
3345 if (!anEvent) { 3348 if (!anEvent) {
3346 KNotifyClient::beep(); 3349 KNotifyClient::beep();
3347 return; 3350 return;
3348 } 3351 }
3349 3352
3350 deleteEvent(anEvent); 3353 deleteEvent(anEvent);
3351} 3354}
3352 3355
3353void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3356void CalendarView::todo_resub( Todo * parent, Todo * sub )
3354{ 3357{
3355 if (!sub) return; 3358 if (!sub) return;
3356 if ( sub->relatedTo() == parent ) 3359 if ( sub->relatedTo() == parent )
3357 return; 3360 return;
3358 sub->setRelatedTo(parent); 3361 sub->setRelatedTo(parent);
3359 sub->updated(); 3362 sub->updated();
3360 setModified(true); 3363 setModified(true);
3361 updateView(); 3364 updateView();
3362} 3365}
3363void CalendarView::todo_unsub(Todo *anTodo ) 3366void CalendarView::todo_unsub(Todo *anTodo )
3364{ 3367{
3365 todo_resub( 0, anTodo ); 3368 todo_resub( 0, anTodo );
3366} 3369}
3367 3370
3368void CalendarView::deleteTodo(Todo *todo) 3371void CalendarView::deleteTodo(Todo *todo)
3369{ 3372{
3370 if (!todo) { 3373 if (!todo) {
3371 KNotifyClient::beep(); 3374 KNotifyClient::beep();
3372 return; 3375 return;
3373 } 3376 }
3374 if (KOPrefs::instance()->mConfirm) { 3377 if (KOPrefs::instance()->mConfirm) {
3375 QString text = todo->summary().left(20); 3378 QString text = todo->summary().left(20);
3376 if (!todo->relations().isEmpty()) { 3379 if (!todo->relations().isEmpty()) {
3377 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3380 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3378 3381
3379 } 3382 }
3380 switch (msgItemDelete(text)) { 3383 switch (msgItemDelete(text)) {
3381 case KMessageBox::Continue: // OK 3384 case KMessageBox::Continue: // OK
3382 bool deleteT = false; 3385 bool deleteT = false;
3383 if (!todo->relations().isEmpty()) { 3386 if (!todo->relations().isEmpty()) {
3384 deleteT = removeCompletedSubTodos( todo ); 3387 deleteT = removeCompletedSubTodos( todo );
3385 } 3388 }
3386 // deleteT == true: todo already deleted in removeCompletedSubTodos 3389 // deleteT == true: todo already deleted in removeCompletedSubTodos
3387 if ( !deleteT ) { 3390 if ( !deleteT ) {
3388 checkExternalId( todo ); 3391 checkExternalId( todo );
3389 calendar()->deleteTodo(todo); 3392 calendar()->deleteTodo(todo);
3390 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3393 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3391 updateView(); 3394 updateView();
3392 } 3395 }
3393 break; 3396 break;
3394 } // switch 3397 } // switch
3395 } else { 3398 } else {
3396 checkExternalId( todo ); 3399 checkExternalId( todo );
3397 mCalendar->deleteTodo(todo); 3400 mCalendar->deleteTodo(todo);
3398 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3401 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3399 updateView(); 3402 updateView();
3400 } 3403 }
3401 3404
3402 emit updateSearchDialog(); 3405 emit updateSearchDialog();
3403} 3406}
3404void CalendarView::deleteJournal(Journal *jour) 3407void CalendarView::deleteJournal(Journal *jour)
3405{ 3408{
3406 if (!jour) { 3409 if (!jour) {
3407 KNotifyClient::beep(); 3410 KNotifyClient::beep();
3408 return; 3411 return;
3409 } 3412 }
3410 if (KOPrefs::instance()->mConfirm) { 3413 if (KOPrefs::instance()->mConfirm) {
3411 switch (msgItemDelete( jour->description().left(20))) { 3414 switch (msgItemDelete( jour->description().left(20))) {
3412 case KMessageBox::Continue: // OK 3415 case KMessageBox::Continue: // OK
3413 calendar()->deleteJournal(jour); 3416 calendar()->deleteJournal(jour);
3414 updateView(); 3417 updateView();
3415 break; 3418 break;
3416 } // switch 3419 } // switch
3417 } else { 3420 } else {
3418 calendar()->deleteJournal(jour);; 3421 calendar()->deleteJournal(jour);;
3419 updateView(); 3422 updateView();
3420 } 3423 }
3421 emit updateSearchDialog(); 3424 emit updateSearchDialog();
3422} 3425}
3423 3426
3424void CalendarView::deleteEvent(Event *anEvent) 3427void CalendarView::deleteEvent(Event *anEvent)
3425{ 3428{
3426 if (!anEvent) { 3429 if (!anEvent) {
3427 KNotifyClient::beep(); 3430 KNotifyClient::beep();
3428 return; 3431 return;
3429 } 3432 }
3430 3433
3431 if (anEvent->recurrence()->doesRecur()) { 3434 if (anEvent->recurrence()->doesRecur()) {
3432 QDate itemDate = mViewManager->currentSelectionDate(); 3435 QDate itemDate = mViewManager->currentSelectionDate();
3433 int km; 3436 int km;
3434 if (!itemDate.isValid()) { 3437 if (!itemDate.isValid()) {
3435 //kdDebug() << "Date Not Valid" << endl; 3438 //kdDebug() << "Date Not Valid" << endl;
3436 if (KOPrefs::instance()->mConfirm) { 3439 if (KOPrefs::instance()->mConfirm) {
3437 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3440 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3438 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3441 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3439 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3442 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3440 if ( km == KMessageBox::Continue ) 3443 if ( km == KMessageBox::Continue )
3441 km = KMessageBox::No; // No = all below 3444 km = KMessageBox::No; // No = all below
3442 } else 3445 } else
3443 km = KMessageBox::No; 3446 km = KMessageBox::No;
3444 } else { 3447 } else {
3445 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3448 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3446 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3449 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3447 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3450 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3448 i18n("KO/Pi Confirmation"),i18n("Current"), 3451 i18n("KO/Pi Confirmation"),i18n("Current"),
3449 i18n("All")); 3452 i18n("All"));
3450 } 3453 }
3451 switch(km) { 3454 switch(km) {
3452 3455
3453 case KMessageBox::No: // Continue // all 3456 case KMessageBox::No: // Continue // all
3454 //qDebug("KMessageBox::No "); 3457 //qDebug("KMessageBox::No ");
3455 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3458 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3456 schedule(Scheduler::Cancel,anEvent); 3459 schedule(Scheduler::Cancel,anEvent);
3457 3460
3458 checkExternalId( anEvent); 3461 checkExternalId( anEvent);
3459 mCalendar->deleteEvent(anEvent); 3462 mCalendar->deleteEvent(anEvent);
3460 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3463 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3461 break; 3464 break;
3462 3465
3463 // Disabled because it does not work 3466 // Disabled because it does not work
3464 //#if 0 3467 //#if 0
3465 case KMessageBox::Yes: // just this one 3468 case KMessageBox::Yes: // just this one
3466 //QDate qd = mNavigator->selectedDates().first(); 3469 //QDate qd = mNavigator->selectedDates().first();
3467 //if (!qd.isValid()) { 3470 //if (!qd.isValid()) {
3468 // kdDebug() << "no date selected, or invalid date" << endl; 3471 // kdDebug() << "no date selected, or invalid date" << endl;
3469 // KNotifyClient::beep(); 3472 // KNotifyClient::beep();
3470 // return; 3473 // return;
3471 //} 3474 //}
3472 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3475 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3473 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3476 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3474 anEvent->addExDate(itemDate); 3477 anEvent->addExDate(itemDate);
3475 int duration = anEvent->recurrence()->duration(); 3478 int duration = anEvent->recurrence()->duration();
3476 if ( duration > 0 ) { 3479 if ( duration > 0 ) {
3477 anEvent->recurrence()->setDuration( duration - 1 ); 3480 anEvent->recurrence()->setDuration( duration - 1 );
3478 } 3481 }
3479 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3482 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3480 } 3483 }
3481 break; 3484 break;
3482 //#endif 3485 //#endif
3483 } // switch 3486 } // switch
3484 } else { 3487 } else {
3485 if (KOPrefs::instance()->mConfirm) { 3488 if (KOPrefs::instance()->mConfirm) {
3486 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3489 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3487 i18n("\nAre you sure you want\nto delete this event?"), 3490 i18n("\nAre you sure you want\nto delete this event?"),
3488 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3491 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3489 case KMessageBox::Continue: // OK 3492 case KMessageBox::Continue: // OK
3490 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3493 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3491 schedule(Scheduler::Cancel,anEvent); 3494 schedule(Scheduler::Cancel,anEvent);
3492 checkExternalId( anEvent); 3495 checkExternalId( anEvent);
3493 mCalendar->deleteEvent(anEvent); 3496 mCalendar->deleteEvent(anEvent);
3494 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3497 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3495 break; 3498 break;
3496 } // switch 3499 } // switch
3497 } else { 3500 } else {
3498 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3501 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3499 schedule(Scheduler::Cancel,anEvent); 3502 schedule(Scheduler::Cancel,anEvent);
3500 checkExternalId( anEvent); 3503 checkExternalId( anEvent);
3501 mCalendar->deleteEvent(anEvent); 3504 mCalendar->deleteEvent(anEvent);
3502 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3505 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3503 } 3506 }
3504 } // if-else 3507 } // if-else
3505 emit updateSearchDialog(); 3508 emit updateSearchDialog();
3506} 3509}
3507 3510
3508bool CalendarView::deleteEvent(const QString &uid) 3511bool CalendarView::deleteEvent(const QString &uid)
3509{ 3512{
3510 Event *ev = mCalendar->event(uid); 3513 Event *ev = mCalendar->event(uid);
3511 if (ev) { 3514 if (ev) {
3512 deleteEvent(ev); 3515 deleteEvent(ev);
3513 return true; 3516 return true;
3514 } else { 3517 } else {
3515 return false; 3518 return false;
3516 } 3519 }
3517} 3520}
3518 3521
3519/*****************************************************************************/ 3522/*****************************************************************************/
3520 3523
3521void CalendarView::action_mail() 3524void CalendarView::action_mail()
3522{ 3525{
3523#ifndef KORG_NOMAIL 3526#ifndef KORG_NOMAIL
3524 KOMailClient mailClient; 3527 KOMailClient mailClient;
3525 3528
3526 Incidence *incidence = currentSelection(); 3529 Incidence *incidence = currentSelection();
3527 3530
3528 if (!incidence) { 3531 if (!incidence) {
3529 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3532 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3530 return; 3533 return;
3531 } 3534 }
3532 if(incidence->attendeeCount() == 0 ) { 3535 if(incidence->attendeeCount() == 0 ) {
3533 KMessageBox::sorry(this, 3536 KMessageBox::sorry(this,
3534 i18n("Can't generate mail:\nNo attendees defined.\n")); 3537 i18n("Can't generate mail:\nNo attendees defined.\n"));
3535 return; 3538 return;
3536 } 3539 }
3537 3540
3538 CalendarLocal cal_tmp; 3541 CalendarLocal cal_tmp;
3539 Event *event = 0; 3542 Event *event = 0;
3540 Event *ev = 0; 3543 Event *ev = 0;
3541 if ( incidence && incidence->typeID() == eventID ) { 3544 if ( incidence && incidence->typeID() == eventID ) {
3542 event = static_cast<Event *>(incidence); 3545 event = static_cast<Event *>(incidence);
3543 ev = new Event(*event); 3546 ev = new Event(*event);
3544 cal_tmp.addEvent(ev); 3547 cal_tmp.addEvent(ev);
3545 } 3548 }
3546 ICalFormat mForm(); 3549 ICalFormat mForm();
3547 QString attachment = mForm.toString( &cal_tmp ); 3550 QString attachment = mForm.toString( &cal_tmp );
3548 if (ev) delete(ev); 3551 if (ev) delete(ev);
3549 3552
3550 mailClient.mailAttendees(currentSelection(), attachment); 3553 mailClient.mailAttendees(currentSelection(), attachment);
3551 3554
3552#endif 3555#endif
3553 3556
3554#if 0 3557#if 0
3555 Event *anEvent = 0; 3558 Event *anEvent = 0;
3556 if (mViewManager->currentView()->isEventView()) { 3559 if (mViewManager->currentView()->isEventView()) {
3557 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3560 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3558 } 3561 }
3559 3562
3560 if (!anEvent) { 3563 if (!anEvent) {
3561 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3564 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3562 return; 3565 return;
3563 } 3566 }
3564 if(anEvent->attendeeCount() == 0 ) { 3567 if(anEvent->attendeeCount() == 0 ) {
3565 KMessageBox::sorry(this, 3568 KMessageBox::sorry(this,
3566 i18n("Can't generate mail:\nNo attendees defined.\n")); 3569 i18n("Can't generate mail:\nNo attendees defined.\n"));
3567 return; 3570 return;
3568 } 3571 }
3569 3572
3570 mailobject.emailEvent(anEvent); 3573 mailobject.emailEvent(anEvent);
3571#endif 3574#endif
3572} 3575}
3573 3576
3574 3577
3575void CalendarView::schedule_publish(Incidence *incidence) 3578void CalendarView::schedule_publish(Incidence *incidence)
3576{ 3579{
3577 Event *event = 0; 3580 Event *event = 0;
3578 Todo *todo = 0; 3581 Todo *todo = 0;
3579 3582
3580 if (incidence == 0) { 3583 if (incidence == 0) {
3581 incidence = mViewManager->currentView()->selectedIncidences().first(); 3584 incidence = mViewManager->currentView()->selectedIncidences().first();
3582 if (incidence == 0) { 3585 if (incidence == 0) {
3583 incidence = mTodoList->selectedIncidences().first(); 3586 incidence = mTodoList->selectedIncidences().first();
3584 } 3587 }
3585 } 3588 }
3586 if ( incidence && incidence->typeID() == eventID ) { 3589 if ( incidence && incidence->typeID() == eventID ) {
3587 event = static_cast<Event *>(incidence); 3590 event = static_cast<Event *>(incidence);
3588 } else { 3591 } else {
3589 if ( incidence && incidence->typeID() == todoID ) { 3592 if ( incidence && incidence->typeID() == todoID ) {
3590 todo = static_cast<Todo *>(incidence); 3593 todo = static_cast<Todo *>(incidence);
3591 } 3594 }
3592 } 3595 }
3593 3596
3594 if (!event && !todo) { 3597 if (!event && !todo) {
3595 KMessageBox::sorry(this,i18n("No event selected.")); 3598 KMessageBox::sorry(this,i18n("No event selected."));
3596 return; 3599 return;
3597 } 3600 }
3598 3601
3599 PublishDialog *publishdlg = new PublishDialog(); 3602 PublishDialog *publishdlg = new PublishDialog();
3600 if (incidence->attendeeCount()>0) { 3603 if (incidence->attendeeCount()>0) {
3601 QPtrList<Attendee> attendees = incidence->attendees(); 3604 QPtrList<Attendee> attendees = incidence->attendees();
3602 attendees.first(); 3605 attendees.first();
3603 while ( attendees.current()!=0 ) { 3606 while ( attendees.current()!=0 ) {
3604 publishdlg->addAttendee(attendees.current()); 3607 publishdlg->addAttendee(attendees.current());
3605 attendees.next(); 3608 attendees.next();
3606 } 3609 }
3607 } 3610 }
3608 bool send = true; 3611 bool send = true;
3609 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3612 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3610 if ( publishdlg->exec() != QDialog::Accepted ) 3613 if ( publishdlg->exec() != QDialog::Accepted )
3611 send = false; 3614 send = false;
3612 } 3615 }
3613 if ( send ) { 3616 if ( send ) {
3614 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3617 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3615 if ( event ) { 3618 if ( event ) {
3616 Event *ev = new Event(*event); 3619 Event *ev = new Event(*event);
3617 ev->registerObserver(0); 3620 ev->registerObserver(0);
3618 ev->clearAttendees(); 3621 ev->clearAttendees();
3619 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3622 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3620 delete(ev); 3623 delete(ev);
3621 } 3624 }
3622 } else { 3625 } else {
3623 if ( todo ) { 3626 if ( todo ) {
3624 Todo *ev = new Todo(*todo); 3627 Todo *ev = new Todo(*todo);
3625 ev->registerObserver(0); 3628 ev->registerObserver(0);
3626 ev->clearAttendees(); 3629 ev->clearAttendees();
3627 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3630 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3628 delete(ev); 3631 delete(ev);
3629 } 3632 }
3630 } 3633 }
3631 } 3634 }
3632 } 3635 }
3633 delete publishdlg; 3636 delete publishdlg;
3634} 3637}
3635 3638
3636void CalendarView::schedule_request(Incidence *incidence) 3639void CalendarView::schedule_request(Incidence *incidence)
3637{ 3640{
3638 schedule(Scheduler::Request,incidence); 3641 schedule(Scheduler::Request,incidence);
3639} 3642}
3640 3643
3641void CalendarView::schedule_refresh(Incidence *incidence) 3644void CalendarView::schedule_refresh(Incidence *incidence)
3642{ 3645{
3643 schedule(Scheduler::Refresh,incidence); 3646 schedule(Scheduler::Refresh,incidence);
3644} 3647}
3645 3648
3646void CalendarView::schedule_cancel(Incidence *incidence) 3649void CalendarView::schedule_cancel(Incidence *incidence)
3647{ 3650{
3648 schedule(Scheduler::Cancel,incidence); 3651 schedule(Scheduler::Cancel,incidence);
3649} 3652}
3650 3653
3651void CalendarView::schedule_add(Incidence *incidence) 3654void CalendarView::schedule_add(Incidence *incidence)
3652{ 3655{
3653 schedule(Scheduler::Add,incidence); 3656 schedule(Scheduler::Add,incidence);
3654} 3657}
3655 3658
3656void CalendarView::schedule_reply(Incidence *incidence) 3659void CalendarView::schedule_reply(Incidence *incidence)
3657{ 3660{
3658 schedule(Scheduler::Reply,incidence); 3661 schedule(Scheduler::Reply,incidence);
3659} 3662}
3660 3663
3661void CalendarView::schedule_counter(Incidence *incidence) 3664void CalendarView::schedule_counter(Incidence *incidence)
3662{ 3665{
3663 schedule(Scheduler::Counter,incidence); 3666 schedule(Scheduler::Counter,incidence);
3664} 3667}
3665 3668
3666void CalendarView::schedule_declinecounter(Incidence *incidence) 3669void CalendarView::schedule_declinecounter(Incidence *incidence)
3667{ 3670{
3668 schedule(Scheduler::Declinecounter,incidence); 3671 schedule(Scheduler::Declinecounter,incidence);
3669} 3672}
3670 3673
3671void CalendarView::schedule_publish_freebusy(int daysToPublish) 3674void CalendarView::schedule_publish_freebusy(int daysToPublish)
3672{ 3675{
3673 QDateTime start = QDateTime::currentDateTime(); 3676 QDateTime start = QDateTime::currentDateTime();
3674 QDateTime end = start.addDays(daysToPublish); 3677 QDateTime end = start.addDays(daysToPublish);
3675 3678
3676 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3679 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3677 freebusy->setOrganizer(KOPrefs::instance()->email()); 3680 freebusy->setOrganizer(KOPrefs::instance()->email());
3678 3681
3679 3682
3680 PublishDialog *publishdlg = new PublishDialog(); 3683 PublishDialog *publishdlg = new PublishDialog();
3681 if ( publishdlg->exec() == QDialog::Accepted ) { 3684 if ( publishdlg->exec() == QDialog::Accepted ) {
3682 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3685 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3683 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3686 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3684 delete(freebusy); 3687 delete(freebusy);
3685 } 3688 }
3686 } 3689 }
3687 delete publishdlg; 3690 delete publishdlg;
3688} 3691}
3689 3692
3690void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3693void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3691{ 3694{
3692 Event *event = 0; 3695 Event *event = 0;
3693 Todo *todo = 0; 3696 Todo *todo = 0;
3694 3697
3695 if (incidence == 0) { 3698 if (incidence == 0) {
3696 incidence = mViewManager->currentView()->selectedIncidences().first(); 3699 incidence = mViewManager->currentView()->selectedIncidences().first();
3697 if (incidence == 0) { 3700 if (incidence == 0) {
3698 incidence = mTodoList->selectedIncidences().first(); 3701 incidence = mTodoList->selectedIncidences().first();
3699 } 3702 }
3700 } 3703 }
3701 if ( incidence && incidence->typeID() == eventID ) { 3704 if ( incidence && incidence->typeID() == eventID ) {
3702 event = static_cast<Event *>(incidence); 3705 event = static_cast<Event *>(incidence);
3703 } 3706 }
3704 if ( incidence && incidence->typeID() == todoID ) { 3707 if ( incidence && incidence->typeID() == todoID ) {
3705 todo = static_cast<Todo *>(incidence); 3708 todo = static_cast<Todo *>(incidence);
3706 } 3709 }
3707 3710
3708 if (!event && !todo) { 3711 if (!event && !todo) {
3709 KMessageBox::sorry(this,i18n("No event selected.")); 3712 KMessageBox::sorry(this,i18n("No event selected."));
3710 return; 3713 return;
3711 } 3714 }
3712 3715
3713 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3716 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3714 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3717 KMessageBox::sorry(this,i18n("The event has no attendees."));
3715 return; 3718 return;
3716 } 3719 }
3717 3720
3718 Event *ev = 0; 3721 Event *ev = 0;
3719 if (event) ev = new Event(*event); 3722 if (event) ev = new Event(*event);
3720 Todo *to = 0; 3723 Todo *to = 0;
3721 if (todo) to = new Todo(*todo); 3724 if (todo) to = new Todo(*todo);
3722 3725
3723 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3726 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3724 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3727 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3725 if (!me) { 3728 if (!me) {
3726 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3729 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3727 return; 3730 return;
3728 } 3731 }
3729 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3732 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3730 StatusDialog *statdlg = new StatusDialog(this); 3733 StatusDialog *statdlg = new StatusDialog(this);
3731 if (!statdlg->exec()==QDialog::Accepted) return; 3734 if (!statdlg->exec()==QDialog::Accepted) return;
3732 me->setStatus( statdlg->status() ); 3735 me->setStatus( statdlg->status() );
3733 delete(statdlg); 3736 delete(statdlg);
3734 } 3737 }
3735 Attendee *menew = new Attendee(*me); 3738 Attendee *menew = new Attendee(*me);
3736 if (ev) { 3739 if (ev) {
3737 ev->clearAttendees(); 3740 ev->clearAttendees();
3738 ev->addAttendee(menew,false); 3741 ev->addAttendee(menew,false);
3739 } else { 3742 } else {
3740 if (to) { 3743 if (to) {
3741 todo->clearAttendees(); 3744 todo->clearAttendees();
3742 todo->addAttendee(menew,false); 3745 todo->addAttendee(menew,false);
3743 } 3746 }
3744 } 3747 }
3745 } 3748 }
3746 3749
3747 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3750 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3748 if (ev) { 3751 if (ev) {
3749 if ( !dlg->addMessage(ev,method) ) delete(ev); 3752 if ( !dlg->addMessage(ev,method) ) delete(ev);
3750 } else { 3753 } else {
3751 if (to) { 3754 if (to) {
3752 if ( !dlg->addMessage(to,method) ) delete(to); 3755 if ( !dlg->addMessage(to,method) ) delete(to);
3753 } 3756 }
3754 } 3757 }
3755} 3758}
3756 3759
3757void CalendarView::openAddressbook() 3760void CalendarView::openAddressbook()
3758{ 3761{
3759 KRun::runCommand("kaddressbook"); 3762 KRun::runCommand("kaddressbook");
3760} 3763}
3761 3764
3762void CalendarView::setModified(bool modified) 3765void CalendarView::setModified(bool modified)
3763{ 3766{
3764 if ( modified ) 3767 if ( modified )
3765 emit signalmodified(); 3768 emit signalmodified();
3766 if (mModified != modified) { 3769 if (mModified != modified) {
3767 mModified = modified; 3770 mModified = modified;
3768 emit modifiedChanged(mModified); 3771 emit modifiedChanged(mModified);
3769 } 3772 }
3770} 3773}
3771 3774
3772bool CalendarView::isReadOnly() 3775bool CalendarView::isReadOnly()
3773{ 3776{
3774 return mReadOnly; 3777 return mReadOnly;
3775} 3778}
3776 3779
3777void CalendarView::setReadOnly(bool readOnly) 3780void CalendarView::setReadOnly(bool readOnly)
3778{ 3781{
3779 if (mReadOnly != readOnly) { 3782 if (mReadOnly != readOnly) {
3780 mReadOnly = readOnly; 3783 mReadOnly = readOnly;
3781 emit readOnlyChanged(mReadOnly); 3784 emit readOnlyChanged(mReadOnly);
3782 } 3785 }
3783} 3786}
3784 3787
3785bool CalendarView::isModified() 3788bool CalendarView::isModified()
3786{ 3789{
3787 return mModified; 3790 return mModified;
3788} 3791}
3789void CalendarView::slotprintSelInc() 3792void CalendarView::slotprintSelInc()
3790{ 3793{
3791 if ( currentSelection() == 0 ) { 3794 if ( currentSelection() == 0 ) {
3792 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3795 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3793 return; 3796 return;
3794 } 3797 }
3795 showIncidence(); 3798 showIncidence();
3796 getEventViewerDialog()->print(); 3799 getEventViewerDialog()->print();
3797 3800
3798} 3801}
3799void CalendarView::printSetup() 3802void CalendarView::printSetup()
3800{ 3803{
3801#ifndef KORG_NOPRINTER 3804#ifndef KORG_NOPRINTER
3802 createPrinter(); 3805 createPrinter();
3803 3806
3804 mCalPrinter->setupPrinter(); 3807 mCalPrinter->setupPrinter();
3805#endif 3808#endif
3806} 3809}
3807 3810
3808void CalendarView::print() 3811void CalendarView::print()
3809{ 3812{
3810#ifndef KORG_NOPRINTER 3813#ifndef KORG_NOPRINTER
3811 createPrinter(); 3814 createPrinter();
3812 3815
3813 DateList tmpDateList = mNavigator->selectedDates(); 3816 DateList tmpDateList = mNavigator->selectedDates();
3814 mCalPrinter->print(CalPrinter::Month, 3817 mCalPrinter->print(CalPrinter::Month,
3815 tmpDateList.first(), tmpDateList.last()); 3818 tmpDateList.first(), tmpDateList.last());
3816#endif 3819#endif
3817} 3820}
3818 3821
3819void CalendarView::printPreview() 3822void CalendarView::printPreview()
3820{ 3823{
3821#ifndef KORG_NOPRINTER 3824#ifndef KORG_NOPRINTER
3822 kdDebug() << "CalendarView::printPreview()" << endl; 3825 kdDebug() << "CalendarView::printPreview()" << endl;
3823 3826
3824 createPrinter(); 3827 createPrinter();
3825 3828
3826 DateList tmpDateList = mNavigator->selectedDates(); 3829 DateList tmpDateList = mNavigator->selectedDates();
3827 3830
3828 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3831 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3829 tmpDateList.last()); 3832 tmpDateList.last());
3830#endif 3833#endif
3831} 3834}
3832 3835
3833void CalendarView::exportICalendar() 3836void CalendarView::exportICalendar()
3834{ 3837{
3835 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3838 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3836 3839
3837 // Force correct extension 3840 // Force correct extension
3838 if (filename.right(4) != ".ics") filename += ".ics"; 3841 if (filename.right(4) != ".ics") filename += ".ics";
3839 3842
3840 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3843 FileStorage storage( mCalendar, filename, new ICalFormat() );
3841 storage.save(); 3844 storage.save();
3842} 3845}
3843 3846
3844bool CalendarView::exportVCalendar( QString filename ) 3847bool CalendarView::exportVCalendar( QString filename )
3845{ 3848{
3846 if (mCalendar->journals().count() > 0) { 3849 if (mCalendar->journals().count() > 0) {
3847 int result = KMessageBox::warningContinueCancel(this, 3850 int result = KMessageBox::warningContinueCancel(this,
3848 i18n("The journal entries can not be\nexported to a vCalendar file."), 3851 i18n("The journal entries can not be\nexported to a vCalendar file."),
3849 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3852 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3850 true); 3853 true);
3851 if (result != KMessageBox::Continue) return false; 3854 if (result != KMessageBox::Continue) return false;
3852 } 3855 }
3853 3856
3854 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3857 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3855 3858
3856 // Force correct extension 3859 // Force correct extension
3857 if (filename.right(4) != ".vcs") filename += ".vcs"; 3860 if (filename.right(4) != ".vcs") filename += ".vcs";
3858 3861
3859 FileStorage storage( mCalendar, filename, new VCalFormat ); 3862 FileStorage storage( mCalendar, filename, new VCalFormat );
3860 return storage.save(); 3863 return storage.save();
3861 3864
3862} 3865}
3863 3866
3864void CalendarView::eventUpdated(Incidence *) 3867void CalendarView::eventUpdated(Incidence *)
3865{ 3868{
3866 setModified(); 3869 setModified();
3867 // Don't call updateView here. The code, which has caused the update of the 3870 // Don't call updateView here. The code, which has caused the update of the
3868 // event is responsible for updating the view. 3871 // event is responsible for updating the view.
3869 // updateView(); 3872 // updateView();
3870} 3873}
3871 3874
3872void CalendarView::adaptNavigationUnits() 3875void CalendarView::adaptNavigationUnits()
3873{ 3876{
3874 if (mViewManager->currentView()->isEventView()) { 3877 if (mViewManager->currentView()->isEventView()) {
3875 int days = mViewManager->currentView()->currentDateCount(); 3878 int days = mViewManager->currentView()->currentDateCount();
3876 if (days == 1) { 3879 if (days == 1) {
3877 emit changeNavStringPrev(i18n("&Previous Day")); 3880 emit changeNavStringPrev(i18n("&Previous Day"));
3878 emit changeNavStringNext(i18n("&Next Day")); 3881 emit changeNavStringNext(i18n("&Next Day"));
3879 } else { 3882 } else {
3880 emit changeNavStringPrev(i18n("&Previous Week")); 3883 emit changeNavStringPrev(i18n("&Previous Week"));
3881 emit changeNavStringNext(i18n("&Next Week")); 3884 emit changeNavStringNext(i18n("&Next Week"));
3882 } 3885 }
3883 } 3886 }
3884} 3887}
3885 3888
3886void CalendarView::processMainViewSelection( Incidence *incidence ) 3889void CalendarView::processMainViewSelection( Incidence *incidence )
3887{ 3890{
3888 if ( incidence ) mTodoList->clearSelection(); 3891 if ( incidence ) mTodoList->clearSelection();
3889 processIncidenceSelection( incidence ); 3892 processIncidenceSelection( incidence );
3890} 3893}
3891 3894
3892void CalendarView::processTodoListSelection( Incidence *incidence ) 3895void CalendarView::processTodoListSelection( Incidence *incidence )
3893{ 3896{
3894 if ( incidence && mViewManager->currentView() ) { 3897 if ( incidence && mViewManager->currentView() ) {
3895 mViewManager->currentView()->clearSelection(); 3898 mViewManager->currentView()->clearSelection();
3896 } 3899 }
3897 processIncidenceSelection( incidence ); 3900 processIncidenceSelection( incidence );
3898} 3901}
3899 3902
3900void CalendarView::processIncidenceSelection( Incidence *incidence ) 3903void CalendarView::processIncidenceSelection( Incidence *incidence )
3901{ 3904{
3902 if ( incidence == mSelectedIncidence ) return; 3905 if ( incidence == mSelectedIncidence ) return;
3903 3906
3904 mSelectedIncidence = incidence; 3907 mSelectedIncidence = incidence;
3905 3908
3906 emit incidenceSelected( mSelectedIncidence ); 3909 emit incidenceSelected( mSelectedIncidence );
3907 3910
3908 if ( incidence && incidence->typeID() == eventID ) { 3911 if ( incidence && incidence->typeID() == eventID ) {
3909 Event *event = static_cast<Event *>( incidence ); 3912 Event *event = static_cast<Event *>( incidence );
3910 if ( event->organizer() == KOPrefs::instance()->email() ) { 3913 if ( event->organizer() == KOPrefs::instance()->email() ) {
3911 emit organizerEventsSelected( true ); 3914 emit organizerEventsSelected( true );
3912 } else { 3915 } else {
3913 emit organizerEventsSelected(false); 3916 emit organizerEventsSelected(false);
3914 } 3917 }
3915 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3918 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3916 KOPrefs::instance()->email() ) ) { 3919 KOPrefs::instance()->email() ) ) {
3917 emit groupEventsSelected( true ); 3920 emit groupEventsSelected( true );
3918 } else { 3921 } else {
3919 emit groupEventsSelected(false); 3922 emit groupEventsSelected(false);
3920 } 3923 }
3921 return; 3924 return;
3922 } else { 3925 } else {
3923 if ( incidence && incidence->typeID() == todoID ) { 3926 if ( incidence && incidence->typeID() == todoID ) {
3924 emit todoSelected( true ); 3927 emit todoSelected( true );
3925 Todo *event = static_cast<Todo *>( incidence ); 3928 Todo *event = static_cast<Todo *>( incidence );
3926 if ( event->organizer() == KOPrefs::instance()->email() ) { 3929 if ( event->organizer() == KOPrefs::instance()->email() ) {
3927 emit organizerEventsSelected( true ); 3930 emit organizerEventsSelected( true );
3928 } else { 3931 } else {
3929 emit organizerEventsSelected(false); 3932 emit organizerEventsSelected(false);
3930 } 3933 }
3931 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3934 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3932 KOPrefs::instance()->email() ) ) { 3935 KOPrefs::instance()->email() ) ) {
3933 emit groupEventsSelected( true ); 3936 emit groupEventsSelected( true );
3934 } else { 3937 } else {
3935 emit groupEventsSelected(false); 3938 emit groupEventsSelected(false);
3936 } 3939 }
3937 return; 3940 return;
3938 } else { 3941 } else {
3939 emit todoSelected( false ); 3942 emit todoSelected( false );
3940 emit organizerEventsSelected(false); 3943 emit organizerEventsSelected(false);
3941 emit groupEventsSelected(false); 3944 emit groupEventsSelected(false);
3942 } 3945 }
3943 return; 3946 return;
3944 } 3947 }
3945 3948
3946 /* if ( incidence && incidence->typeID() == todoID ) { 3949 /* if ( incidence && incidence->typeID() == todoID ) {
3947 emit todoSelected( true ); 3950 emit todoSelected( true );
3948 } else { 3951 } else {
3949 emit todoSelected( false ); 3952 emit todoSelected( false );
3950 }*/ 3953 }*/
3951} 3954}
3952 3955
3953 3956
3954void CalendarView::checkClipboard() 3957void CalendarView::checkClipboard()
3955{ 3958{
3956#ifndef KORG_NODND 3959#ifndef KORG_NODND
3957 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3960 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3958 emit pasteEnabled(true); 3961 emit pasteEnabled(true);
3959 } else { 3962 } else {
3960 emit pasteEnabled(false); 3963 emit pasteEnabled(false);
3961 } 3964 }
3962#endif 3965#endif
3963} 3966}
3964 3967
3965void CalendarView::showDates(const DateList &selectedDates) 3968void CalendarView::showDates(const DateList &selectedDates)
3966{ 3969{
3967 // kdDebug() << "CalendarView::selectDates()" << endl; 3970 // kdDebug() << "CalendarView::selectDates()" << endl;
3968 3971
3969 3972
3970 if ( !mBlockShowDates ) { 3973 if ( !mBlockShowDates ) {
3971 if ( mViewManager->currentView() ) { 3974 if ( mViewManager->currentView() ) {
3972 updateView( selectedDates.first(), selectedDates.last() ); 3975 updateView( selectedDates.first(), selectedDates.last() );
3973 } else { 3976 } else {
3974 mViewManager->showAgendaView(); 3977 mViewManager->showAgendaView();
3975 } 3978 }
3976 } 3979 }
3977 3980
3978 QDate date = selectedDates.first(); 3981 QDate date = selectedDates.first();
3979 if ( ! date.isValid() ) { 3982 if ( ! date.isValid() ) {
3980 topLevelWidget()->setCaption(""); 3983 topLevelWidget()->setCaption("");
3981 return; 3984 return;
3982 } 3985 }
3983 3986
3984 QString selDates; 3987 QString selDates;
3985 selDates = KGlobal::locale()->formatDate( date, true); 3988 selDates = KGlobal::locale()->formatDate( date, true);
3986 if (selectedDates.first() < selectedDates.last() ) 3989 if (selectedDates.first() < selectedDates.last() )
3987 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3990 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3988 else { 3991 else {
3989 QString addString; 3992 QString addString;
3990 if ( date == QDateTime::currentDateTime().date() ) 3993 if ( date == QDateTime::currentDateTime().date() )
3991 addString = i18n("Today"); 3994 addString = i18n("Today");
3992 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3995 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3993 addString = i18n("Tomorrow"); 3996 addString = i18n("Tomorrow");
3994 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3997 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3995 addString = i18n("Yesterday"); 3998 addString = i18n("Yesterday");
3996 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3999 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3997 addString = i18n("Day before yesterday"); 4000 addString = i18n("Day before yesterday");
3998 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 4001 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3999 addString = i18n("Day after tomorrow"); 4002 addString = i18n("Day after tomorrow");
4000 if ( !addString.isEmpty() ) { 4003 if ( !addString.isEmpty() ) {
4001 topLevelWidget()->setCaption( addString+", " + selDates ); 4004 topLevelWidget()->setCaption( addString+", " + selDates );
4002 return; 4005 return;
4003 } 4006 }
4004 } 4007 }
4005 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 4008 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
4006 4009
4007} 4010}
4008 4011
4009QPtrList<CalFilter> CalendarView::filters() 4012QPtrList<CalFilter> CalendarView::filters()
4010{ 4013{
4011 return mFilters; 4014 return mFilters;
4012 4015
4013} 4016}
4014void CalendarView::editFilters() 4017void CalendarView::editFilters()
4015{ 4018{
4016 // kdDebug() << "CalendarView::editFilters()" << endl; 4019 // kdDebug() << "CalendarView::editFilters()" << endl;
4017 4020
4018 CalFilter *filter = mFilters.first(); 4021 CalFilter *filter = mFilters.first();
4019 while(filter) { 4022 while(filter) {
4020 kdDebug() << " Filter: " << filter->name() << endl; 4023 kdDebug() << " Filter: " << filter->name() << endl;
4021 filter = mFilters.next(); 4024 filter = mFilters.next();
4022 } 4025 }
4023 4026
4024 mDialogManager->showFilterEditDialog(&mFilters); 4027 mDialogManager->showFilterEditDialog(&mFilters);
4025} 4028}
4026void CalendarView::toggleFilter() 4029void CalendarView::toggleFilter()
4027{ 4030{
4028 showFilter(! mCalEditView->isVisible()); 4031 showFilter(! mCalEditView->isVisible());
4029} 4032}
4030 4033
4031KOFilterView *CalendarView::filterView() 4034KOFilterView *CalendarView::filterView()
4032{ 4035{
4033 return mFilterView; 4036 return mFilterView;
4034} 4037}
4035void CalendarView::selectFilter( int fil ) 4038void CalendarView::selectFilter( int fil )
4036{ 4039{
4037 mFilterView->setSelectedFilter( fil ); 4040 mFilterView->setSelectedFilter( fil );
4038} 4041}
4039void CalendarView::showFilter(bool visible) 4042void CalendarView::showFilter(bool visible)
4040{ 4043{
4041#if 1 4044#if 1
4042 if (visible) { 4045 if (visible) {
4043 mCalEditView->readConfig(); 4046 mCalEditView->readConfig();
4044 mCalEditView->show(); 4047 mCalEditView->show();
4045 QValueList<int> sizes; 4048 QValueList<int> sizes;
4046 sizes = mLeftFrame->sizes(); 4049 sizes = mLeftFrame->sizes();
4047 if ( sizes.count() == 4 && sizes[3] < 20 ) { 4050 if ( sizes.count() == 4 && sizes[3] < 20 ) {
4048 sizes.clear(); 4051 sizes.clear();
4049 sizes << 100; 4052 sizes << 100;
4050 sizes << 0; 4053 sizes << 0;
4051 sizes << 0; 4054 sizes << 0;
4052 sizes << 100; 4055 sizes << 100;
4053 mLeftFrame->setSizes(sizes); 4056 mLeftFrame->setSizes(sizes);
4054 } 4057 }
4055#if 0 4058#if 0
4056 sizes = mLeftFrame->sizes(); 4059 sizes = mLeftFrame->sizes();
4057 int ccc = 0; 4060 int ccc = 0;
4058 while ( ccc < sizes.count()) { 4061 while ( ccc < sizes.count()) {
4059 qDebug("size %d %d ", ccc, sizes[ccc]); 4062 qDebug("size %d %d ", ccc, sizes[ccc]);
4060 ++ccc; 4063 ++ccc;
4061 } 4064 }
4062#endif 4065#endif
4063 4066
4064 } 4067 }
4065 else { 4068 else {
4066 mCalEditView->hide(); 4069 mCalEditView->hide();
4067 } 4070 }
4068#else 4071#else
4069 if (visible) mFilterView->show(); 4072 if (visible) mFilterView->show();
4070 else mFilterView->hide(); 4073 else mFilterView->hide();
4071#endif 4074#endif
4072} 4075}
4073void CalendarView::toggleFilerEnabled( ) 4076void CalendarView::toggleFilerEnabled( )
4074{ 4077{
4075 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 4078 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
4076 if ( !mFilterView->filtersEnabled() ) 4079 if ( !mFilterView->filtersEnabled() )
4077 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 4080 topLevelWidget()->setCaption( i18n("Filter disabled ") );
4078 4081
4079} 4082}
4080void CalendarView::updateFilter() 4083void CalendarView::updateFilter()
4081{ 4084{
4082 CalFilter *filter = mFilterView->selectedFilter(); 4085 CalFilter *filter = mFilterView->selectedFilter();
4083 if (filter) { 4086 if (filter) {
4084 QString mess; 4087 QString mess;
4085 if (mFilterView->filtersEnabled()) { 4088 if (mFilterView->filtersEnabled()) {
4086 mess = i18n("Filter selected: ")+filter->name(); 4089 mess = i18n("Filter selected: ")+filter->name();
4087 filter->setEnabled(true); 4090 filter->setEnabled(true);
4088 } 4091 }
4089 else filter->setEnabled(false); 4092 else filter->setEnabled(false);
4090 mCalendar->setFilter(filter); 4093 mCalendar->setFilter(filter);
4091 updateView(); 4094 updateView();
4092 if ( !mess.isEmpty() ) 4095 if ( !mess.isEmpty() )
4093 topLevelWidget()->setCaption( mess ); 4096 topLevelWidget()->setCaption( mess );
4094 4097
4095 } 4098 }
4096} 4099}
4097 4100
4098void CalendarView::filterEdited() 4101void CalendarView::filterEdited()
4099{ 4102{
4100 mFilterView->updateFilters(); 4103 mFilterView->updateFilters();
4101 updateFilter(); 4104 updateFilter();
4102 writeSettings(); 4105 writeSettings();
4103} 4106}
4104 4107
4105 4108
4106void CalendarView::takeOverEvent() 4109void CalendarView::takeOverEvent()
4107{ 4110{
4108 Incidence *incidence = currentSelection(); 4111 Incidence *incidence = currentSelection();
4109 4112
4110 if (!incidence) return; 4113 if (!incidence) return;
4111 4114
4112 incidence->setOrganizer(KOPrefs::instance()->email()); 4115 incidence->setOrganizer(KOPrefs::instance()->email());
4113 incidence->recreate(); 4116 incidence->recreate();
4114 incidence->setReadOnly(false); 4117 incidence->setReadOnly(false);
4115 4118
4116 updateView(); 4119 updateView();
4117} 4120}
4118 4121
4119void CalendarView::takeOverCalendar() 4122void CalendarView::takeOverCalendar()
4120{ 4123{
4121 // TODO: Create Calendar::allIncidences() function and use it here 4124 // TODO: Create Calendar::allIncidences() function and use it here
4122 4125
4123 clearAllViews(); 4126 clearAllViews();
4124 QPtrList<Event> events = mCalendar->events(); 4127 QPtrList<Event> events = mCalendar->events();
4125 for(uint i=0; i<events.count(); ++i) { 4128 for(uint i=0; i<events.count(); ++i) {
4126 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4129 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4127 events.at(i)->recreate(); 4130 events.at(i)->recreate();
4128 events.at(i)->setReadOnly(false); 4131 events.at(i)->setReadOnly(false);
4129 } 4132 }
4130 4133
4131 QPtrList<Todo> todos = mCalendar->todos(); 4134 QPtrList<Todo> todos = mCalendar->todos();
4132 for(uint i=0; i<todos.count(); ++i) { 4135 for(uint i=0; i<todos.count(); ++i) {
4133 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4136 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4134 todos.at(i)->recreate(); 4137 todos.at(i)->recreate();
4135 todos.at(i)->setReadOnly(false); 4138 todos.at(i)->setReadOnly(false);
4136 } 4139 }
4137 4140
4138 QPtrList<Journal> journals = mCalendar->journals(); 4141 QPtrList<Journal> journals = mCalendar->journals();
4139 for(uint i=0; i<journals.count(); ++i) { 4142 for(uint i=0; i<journals.count(); ++i) {
4140 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4143 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4141 journals.at(i)->recreate(); 4144 journals.at(i)->recreate();
4142 journals.at(i)->setReadOnly(false); 4145 journals.at(i)->setReadOnly(false);
4143 } 4146 }
4144 4147
4145 updateView(); 4148 updateView();
4146} 4149}
4147 4150
4148void CalendarView::showIntro() 4151void CalendarView::showIntro()
4149{ 4152{
4150 kdDebug() << "To be implemented." << endl; 4153 kdDebug() << "To be implemented." << endl;
4151} 4154}
4152 4155
4153QWidgetStack *CalendarView::viewStack() 4156QWidgetStack *CalendarView::viewStack()
4154{ 4157{
4155 return mRightFrame; 4158 return mRightFrame;
4156} 4159}
4157 4160
4158QWidget *CalendarView::leftFrame() 4161QWidget *CalendarView::leftFrame()
4159{ 4162{
4160 return ( QWidget *)mLeftFrame; 4163 return ( QWidget *)mLeftFrame;
4161} 4164}
4162 4165
4163DateNavigator *CalendarView::dateNavigator() 4166DateNavigator *CalendarView::dateNavigator()
4164{ 4167{
4165 return mNavigator; 4168 return mNavigator;
4166} 4169}
4167 4170
4168KDateNavigator* CalendarView::dateNavigatorWidget() 4171KDateNavigator* CalendarView::dateNavigatorWidget()
4169{ 4172{
4170 return mDateNavigator->navigatorView(); 4173 return mDateNavigator->navigatorView();
4171} 4174}
4172void CalendarView::toggleDateNavigatorWidget() 4175void CalendarView::toggleDateNavigatorWidget()
4173{ 4176{
4174 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4177 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4175 4178
4176 if (!KOPrefs::instance()->mShowDateNavigator ) 4179 if (!KOPrefs::instance()->mShowDateNavigator )
4177 mDateNavigator->hide(); 4180 mDateNavigator->hide();
4178 else 4181 else
4179 mDateNavigator->show(); 4182 mDateNavigator->show();
4180} 4183}
4181void CalendarView::addView(KOrg::BaseView *view) 4184void CalendarView::addView(KOrg::BaseView *view)
4182{ 4185{
4183 mViewManager->addView(view); 4186 mViewManager->addView(view);
4184} 4187}
4185 4188
4186void CalendarView::showView(KOrg::BaseView *view) 4189void CalendarView::showView(KOrg::BaseView *view)
4187{ 4190{
4188 mViewManager->showView(view, mLeftFrame->isVisible()); 4191 mViewManager->showView(view, mLeftFrame->isVisible());
4189} 4192}
4190 4193
4191Incidence *CalendarView::currentSelection() 4194Incidence *CalendarView::currentSelection()
4192{ 4195{
4193 return mViewManager->currentSelection(); 4196 return mViewManager->currentSelection();
4194} 4197}
4195void CalendarView::toggleAllDaySize() 4198void CalendarView::toggleAllDaySize()
4196{ 4199{
4197 /* 4200 /*
4198 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4201 if ( KOPrefs::instance()->mAllDaySize > 47 )
4199 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4202 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4200 else 4203 else
4201 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4204 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4202 */ 4205 */
4203 viewManager()->agendaView()->toggleAllDay(); 4206 viewManager()->agendaView()->toggleAllDay();
4204} 4207}
4205void CalendarView::toggleExpand() 4208void CalendarView::toggleExpand()
4206{ 4209{
4207 // if ( mLeftFrame->isHidden() ) { 4210 // if ( mLeftFrame->isHidden() ) {
4208 // mLeftFrame->show(); 4211 // mLeftFrame->show();
4209 // emit calendarViewExpanded( false ); 4212 // emit calendarViewExpanded( false );
4210 // } else { 4213 // } else {
4211 // mLeftFrame->hide(); 4214 // mLeftFrame->hide();
4212 // emit calendarViewExpanded( true ); 4215 // emit calendarViewExpanded( true );
4213 // } 4216 // }
4214 //qDebug(" CalendarView::toggleExpand()"); 4217 //qDebug(" CalendarView::toggleExpand()");
4215 globalFlagBlockAgenda = 1; 4218 globalFlagBlockAgenda = 1;
4216 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4219 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4217 globalFlagBlockAgenda = 5; 4220 globalFlagBlockAgenda = 5;
4218 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4221 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4219 //mViewManager->showView( 0, true ); 4222 //mViewManager->showView( 0, true );
4220} 4223}
4221 4224
4222void CalendarView::calendarModified( bool modified, Calendar * ) 4225void CalendarView::calendarModified( bool modified, Calendar * )
4223{ 4226{
4224 setModified( modified ); 4227 setModified( modified );
4225} 4228}
4226 4229
4227Todo *CalendarView::selectedTodo() 4230Todo *CalendarView::selectedTodo()
4228{ 4231{
4229 Incidence *incidence = currentSelection(); 4232 Incidence *incidence = currentSelection();
4230 if ( incidence && incidence->typeID() == todoID ) { 4233 if ( incidence && incidence->typeID() == todoID ) {
4231 return static_cast<Todo *>( incidence ); 4234 return static_cast<Todo *>( incidence );
4232 } 4235 }
4233 4236
4234 incidence = mTodoList->selectedIncidences().first(); 4237 incidence = mTodoList->selectedIncidences().first();
4235 if ( incidence && incidence->typeID() == todoID ) { 4238 if ( incidence && incidence->typeID() == todoID ) {
4236 return static_cast<Todo *>( incidence ); 4239 return static_cast<Todo *>( incidence );
4237 } 4240 }
4238 4241
4239 return 0; 4242 return 0;
4240} 4243}
4241 4244
4242void CalendarView::dialogClosing(Incidence *in) 4245void CalendarView::dialogClosing(Incidence *in)
4243{ 4246{
4244 // mDialogList.remove(in); 4247 // mDialogList.remove(in);
4245} 4248}
4246 4249
4247void CalendarView::showIncidence() 4250void CalendarView::showIncidence()
4248{ 4251{
4249 mViewerCallerIsSearchDialog = false; 4252 mViewerCallerIsSearchDialog = false;
4250 Incidence *incidence = currentSelection(); 4253 Incidence *incidence = currentSelection();
4251 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4254 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4252 if ( incidence ) { 4255 if ( incidence ) {
4253 ShowIncidenceVisitor v; 4256 ShowIncidenceVisitor v;
4254 v.act( incidence, this ); 4257 v.act( incidence, this );
4255 } 4258 }
4256} 4259}
4257void CalendarView::editIncidenceDescription() 4260void CalendarView::editIncidenceDescription()
4258{ 4261{
4259 mFlagEditDescription = true; 4262 mFlagEditDescription = true;
4260 editIncidence(); 4263 editIncidence();
4261 mFlagEditDescription = false; 4264 mFlagEditDescription = false;
4262} 4265}
4263void CalendarView::editIncidence() 4266void CalendarView::editIncidence()
4264{ 4267{
4265 // qDebug("editIncidence() "); 4268 // qDebug("editIncidence() ");
4266 Incidence *incidence = currentSelection(); 4269 Incidence *incidence = currentSelection();
4267 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4270 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4268 if ( incidence ) { 4271 if ( incidence ) {
4269 EditIncidenceVisitor v; 4272 EditIncidenceVisitor v;
4270 v.act( incidence, this ); 4273 v.act( incidence, this );
4271 } 4274 }
4272} 4275}
4273 4276
4274void CalendarView::deleteIncidence() 4277void CalendarView::deleteIncidence()
4275{ 4278{
4276 Incidence *incidence = currentSelection(); 4279 Incidence *incidence = currentSelection();
4277 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4280 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4278 if ( incidence ) { 4281 if ( incidence ) {
4279 deleteIncidence(incidence); 4282 deleteIncidence(incidence);
4280 } 4283 }
4281} 4284}
4282void CalendarView::showIncidence(QString uid) 4285void CalendarView::showIncidence(QString uid)
4283{ 4286{
4284 Incidence *inc = mCalendar->incidence( uid ); 4287 Incidence *inc = mCalendar->incidence( uid );
4285 if ( inc ) 4288 if ( inc )
4286 showIncidence( inc ); 4289 showIncidence( inc );
4287} 4290}
4288void CalendarView::showIncidence(Incidence *incidence) 4291void CalendarView::showIncidence(Incidence *incidence)
4289{ 4292{
4290 mViewerCallerIsSearchDialog = false; 4293 mViewerCallerIsSearchDialog = false;
4291 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4294 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4292 if ( sender() && mDialogManager->getSearchDialog() ) { 4295 if ( sender() && mDialogManager->getSearchDialog() ) {
4293 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4296 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4294 mViewerCallerIsSearchDialog = true; 4297 mViewerCallerIsSearchDialog = true;
4295 } 4298 }
4296 } 4299 }
4297 if ( incidence ) { 4300 if ( incidence ) {
4298 ShowIncidenceVisitor v; 4301 ShowIncidenceVisitor v;
4299 v.act( incidence, this ); 4302 v.act( incidence, this );
4300 } 4303 }
4301} 4304}
4302 4305
4303void CalendarView::editIncidence(Incidence *incidence) 4306void CalendarView::editIncidence(Incidence *incidence)
4304{ 4307{
4305 if ( incidence ) { 4308 if ( incidence ) {
4306 4309
4307 EditIncidenceVisitor v; 4310 EditIncidenceVisitor v;
4308 v.act( incidence, this ); 4311 v.act( incidence, this );
4309 4312
4310 } 4313 }
4311} 4314}
4312 4315
4313void CalendarView::deleteIncidence(Incidence *incidence) 4316void CalendarView::deleteIncidence(Incidence *incidence)
4314{ 4317{
4315 //qDebug(" CalendarView::deleteIncidence "); 4318 //qDebug(" CalendarView::deleteIncidence ");
4316 if ( incidence ) { 4319 if ( incidence ) {
4317 DeleteIncidenceVisitor v; 4320 DeleteIncidenceVisitor v;
4318 v.act( incidence, this ); 4321 v.act( incidence, this );
4319 } 4322 }
4320} 4323}
4321 4324
4322 4325
4323void CalendarView::lookForOutgoingMessages() 4326void CalendarView::lookForOutgoingMessages()
4324{ 4327{
4325 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4328 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4326 ogd->loadMessages(); 4329 ogd->loadMessages();
4327} 4330}
4328 4331
4329void CalendarView::lookForIncomingMessages() 4332void CalendarView::lookForIncomingMessages()
4330{ 4333{
4331 IncomingDialog *icd = mDialogManager->incomingDialog(); 4334 IncomingDialog *icd = mDialogManager->incomingDialog();
4332 icd->retrieve(); 4335 icd->retrieve();
4333} 4336}
4334 4337
4335bool CalendarView::removeCompletedSubTodos( Todo* t ) 4338bool CalendarView::removeCompletedSubTodos( Todo* t )
4336{ 4339{
4337 bool deleteTodo = true; 4340 bool deleteTodo = true;
4338 QPtrList<Incidence> subTodos; 4341 QPtrList<Incidence> subTodos;
4339 Incidence *aTodo; 4342 Incidence *aTodo;
4340 subTodos = t->relations(); 4343 subTodos = t->relations();
4341 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4344 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4342 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4345 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4343 deleteTodo = false; 4346 deleteTodo = false;
4344 } 4347 }
4345 if ( deleteTodo ) { 4348 if ( deleteTodo ) {
4346 if ( t->isCompleted() && !t->doesRecur()) { 4349 if ( t->isCompleted() && !t->doesRecur()) {
4347 checkExternalId( t ); 4350 checkExternalId( t );
4348 mCalendar->deleteTodo( t ); 4351 mCalendar->deleteTodo( t );
4349 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4352 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4350 } 4353 }
4351 else 4354 else
4352 deleteTodo = false; 4355 deleteTodo = false;
4353 } 4356 }
4354 return deleteTodo; 4357 return deleteTodo;
4355 4358
4356} 4359}
4357void CalendarView::purgeCompleted() 4360void CalendarView::purgeCompleted()
4358{ 4361{
4359 int result = KMessageBox::warningContinueCancel(this, 4362 int result = KMessageBox::warningContinueCancel(this,
4360 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 4363 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
4361 4364
4362 if (result == KMessageBox::Continue) { 4365 if (result == KMessageBox::Continue) {
4363 4366
4364 QPtrList<Todo> todoCal; 4367 QPtrList<Todo> todoCal;
4365 QPtrList<Todo> rootTodos; 4368 QPtrList<Todo> rootTodos;
4366 //QPtrList<Incidence> rel; 4369 //QPtrList<Incidence> rel;
4367 Todo *aTodo;//, *rTodo; 4370 Todo *aTodo;//, *rTodo;
4368 Incidence *rIncidence; 4371 Incidence *rIncidence;
4369 bool childDelete = false; 4372 bool childDelete = false;
4370 bool deletedOne = true; 4373 bool deletedOne = true;
4371 todoCal = calendar()->todos(); 4374 todoCal = calendar()->todos();
4372 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 4375 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
4373 if ( !aTodo->relatedTo() ) 4376 if ( !aTodo->relatedTo() )
4374 rootTodos.append( aTodo ); 4377 rootTodos.append( aTodo );
4375 } 4378 }
4376 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4379 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4377 removeCompletedSubTodos( aTodo ); 4380 removeCompletedSubTodos( aTodo );
4378 } 4381 }
4379 4382
4380 updateView(); 4383 updateView();
4381 } 4384 }
4382} 4385}
4383 4386
4384void CalendarView::slotCalendarChanged() 4387void CalendarView::slotCalendarChanged()
4385{ 4388{
4386 ; 4389 ;
4387} 4390}
4388 4391
4389void CalendarView::keyPressEvent ( QKeyEvent *e) 4392void CalendarView::keyPressEvent ( QKeyEvent *e)
4390{ 4393{
4391 //qDebug(" alendarView::keyPressEvent "); 4394 //qDebug(" alendarView::keyPressEvent ");
4392 e->ignore(); 4395 e->ignore();
4393} 4396}
4394 4397
4395 4398
4396bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4399bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4397{ 4400{
4398 // mSyncManager = manager; 4401 // mSyncManager = manager;
4399 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4402 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4400 qDebug("KO: SyncKDE request detected!"); 4403 qDebug("KO: SyncKDE request detected!");
4401 } 4404 }
4402 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4405 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4403 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4406 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4404 return syncCalendar( filename, mode ); 4407 return syncCalendar( filename, mode );
4405} 4408}
4406bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4409bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4407{ 4410{
4408 //mSyncManager = manager; 4411 //mSyncManager = manager;
4409 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4412 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4410 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4413 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4411 if ( resource == "sharp" ) 4414 if ( resource == "sharp" )
4412 syncExternal( 0 ); 4415 syncExternal( 0 );
4413 if ( resource == "phone" ) 4416 if ( resource == "phone" )
4414 syncExternal( 1 ); 4417 syncExternal( 1 );
4415 // pending setmodified 4418 // pending setmodified
4416 return true; 4419 return true;
4417} 4420}
4418void CalendarView::setSyncManager(KSyncManager* manager) 4421void CalendarView::setSyncManager(KSyncManager* manager)
4419{ 4422{
4420 mSyncManager = manager; 4423 mSyncManager = manager;
4421} 4424}
4422 4425
4423void CalendarView::removeSyncInfo( QString syncProfile) 4426void CalendarView::removeSyncInfo( QString syncProfile)
4424{ 4427{
4425 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4428 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4426 mCalendar->removeSyncInfo( syncProfile ); 4429 mCalendar->removeSyncInfo( syncProfile );
4427 4430
4428} 4431}
4429 4432
4430void CalendarView::undo_delete() 4433void CalendarView::undo_delete()
4431{ 4434{
4432 //qDebug("undo_delete() "); 4435 //qDebug("undo_delete() ");
4433 Incidence* undo = mCalendar->undoIncidence(); 4436 Incidence* undo = mCalendar->undoIncidence();
4434 if ( !undo ) { 4437 if ( !undo ) {
4435 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4438 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4436 i18n("KO/Pi")); 4439 i18n("KO/Pi"));
4437 return; 4440 return;
4438 } 4441 }
4439 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4442 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4440 i18n("\nAre you sure you want\nto restore this?"), 4443 i18n("\nAre you sure you want\nto restore this?"),
4441 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4444 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4442 mCalendar->undoDeleteIncidence(); 4445 mCalendar->undoDeleteIncidence();
4443 updateView(); 4446 updateView();
4444 } 4447 }
4445} 4448}
4446 4449
4447void CalendarView::slotViewerClosed() 4450void CalendarView::slotViewerClosed()
4448{ 4451{
4449 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4452 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4450} 4453}
4451 4454
4452void CalendarView::resetFocus() 4455void CalendarView::resetFocus()
4453{ 4456{
4454 if ( mViewerCallerIsSearchDialog ) { 4457 if ( mViewerCallerIsSearchDialog ) {
4455 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4458 if ( mDialogManager->getSearchDialog()->isVisible() ){
4456 mDialogManager->getSearchDialog()->raise(); 4459 mDialogManager->getSearchDialog()->raise();
4457 mDialogManager->getSearchDialog()->setActiveWindow(); 4460 mDialogManager->getSearchDialog()->setActiveWindow();
4458 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4461 mDialogManager->getSearchDialog()->listview()->resetFocus();
4459 } else 4462 } else
4460 mViewerCallerIsSearchDialog = false; 4463 mViewerCallerIsSearchDialog = false;
4461 } 4464 }
4462 if ( !mViewerCallerIsSearchDialog ) { 4465 if ( !mViewerCallerIsSearchDialog ) {
4463 //mViewManager->currentView()->setFocus(); 4466 //mViewManager->currentView()->setFocus();
4464 //qDebug("sssssssssssssssset focus "); 4467 //qDebug("sssssssssssssssset focus ");
4465 topLevelWidget()->raise(); 4468 topLevelWidget()->raise();
4466 setActiveWindow(); 4469 setActiveWindow();
4467 //setFocus(); 4470 //setFocus();
4468 } 4471 }
4469 mViewerCallerIsSearchDialog = false; 4472 mViewerCallerIsSearchDialog = false;
4470} 4473}
4471 4474
4472void CalendarView::showNextAlarms() 4475void CalendarView::showNextAlarms()
4473{ 4476{
4474 QString message; 4477 QString message;
4475 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4478 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4476 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4479 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4477 QString sum = mCalendar->nextSummary(); 4480 QString sum = mCalendar->nextSummary();
4478 QDateTime nextA = mNextAlarmDateTime; 4481 QDateTime nextA = mNextAlarmDateTime;
4479 QDateTime cur = QDateTime::currentDateTime(); 4482 QDateTime cur = QDateTime::currentDateTime();
4480 int secs = cur.secsTo( nextA ); 4483 int secs = cur.secsTo( nextA );
4481 int min = secs /60; 4484 int min = secs /60;
4482 int hours = min /60; 4485 int hours = min /60;
4483 min = min % 60; 4486 min = min % 60;
4484 int days = hours /24; 4487 int days = hours /24;
4485 hours = hours % 24; 4488 hours = hours % 24;
4486 4489
4487 //message = i18n("The next alarm is in:\n"); 4490 //message = i18n("The next alarm is in:\n");
4488 if ( days > 1 ) 4491 if ( days > 1 )
4489 message += i18n("%1 days\n").arg( days ); 4492 message += i18n("%1 days\n").arg( days );
4490 else if ( days == 1 ) 4493 else if ( days == 1 )
4491 message += i18n("1 day\n"); 4494 message += i18n("1 day\n");
4492 if ( hours > 1 ) 4495 if ( hours > 1 )
4493 message += i18n("%1 hours\n").arg( hours ); 4496 message += i18n("%1 hours\n").arg( hours );
4494 else if ( hours == 1 ) 4497 else if ( hours == 1 )
4495 message += i18n("1 hour\n"); 4498 message += i18n("1 hour\n");
4496 if ( min > 1 ) 4499 if ( min > 1 )
4497 message += i18n("%1 minutes\n").arg( min ); 4500 message += i18n("%1 minutes\n").arg( min );
4498 else if ( min == 1 ) 4501 else if ( min == 1 )
4499 message += i18n("1 minute\n"); 4502 message += i18n("1 minute\n");
4500 if ( message.isEmpty() ) 4503 if ( message.isEmpty() )
4501 message = i18n("The next alarm is in\nless than one minute!"); 4504 message = i18n("The next alarm is in\nless than one minute!");
4502 else 4505 else
4503 message = i18n("The next alarm is in:\n") + message; 4506 message = i18n("The next alarm is in:\n") + message;
4504 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4507 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4505 } else { 4508 } else {
4506 message = i18n("There is no next alarm."); 4509 message = i18n("There is no next alarm.");
4507 4510
4508 } 4511 }
4509#ifdef DESKTOP_VERSION 4512#ifdef DESKTOP_VERSION
4510 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 4513 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4511 message += i18n("\nThe internal alarm notification is disabled!\n"); 4514 message += i18n("\nThe internal alarm notification is disabled!\n");
4512 message += i18n("Enable it in the settings menu, TAB alarm."); 4515 message += i18n("Enable it in the settings menu, TAB alarm.");
4513 } 4516 }
4514 4517
4515#endif 4518#endif
4516 KMessageBox::information( this, message); 4519 KMessageBox::information( this, message);
4517} 4520}