summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Unidiff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp148
1 files changed, 77 insertions, 71 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8385bcc..c1a2f76 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,191 +1,197 @@
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) savecale1997, 1998, 1999 7 Copyright (c) savecale1997, 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 <q3buttongroup.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 <q3progressbar.h>
41#include <qmultilineedit.h> 41#include <q3multilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <q3widgetstack.h>
44#include <qptrlist.h> 44#include <q3ptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <q3groupbox.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//Added by qt3to4:
52#include <Q3VBoxLayout>
53#include <QKeyEvent>
54#include <Q3Frame>
55#include <QLabel>
56#include <Q3ValueList>
51#endif 57#endif
52 58
53#include <kglobal.h> 59#include <kglobal.h>
54#include <kdebug.h> 60#include <kdebug.h>
55#include <kstandarddirs.h> 61#include <kstandarddirs.h>
56#include <kfiledialog.h> 62#include <kfiledialog.h>
57#include <kmessagebox.h> 63#include <kmessagebox.h>
58#include <knotifyclient.h> 64#include <knotifyclient.h>
59#include <kconfig.h> 65#include <kconfig.h>
60 66
61#include <libkdepim/ksyncprefsdialog.h> 67#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 68#include <krun.h>
63#include <kdirwatch.h> 69#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 70#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 71#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 72#include <libkdepim/kpimglobalprefs.h>
67 73
68#include <libkcal/vcaldrag.h> 74#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 75#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 76#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 77#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 78#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 79#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 80#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 81#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 82#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 83#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 84#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 85#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 86#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 87#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 88#include "../kalarmd/alarmdialog.h"
83 89
84#ifndef DESKTOP_VERSION 90#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 91#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 92#include <externalapphandler.h>
87#endif 93#endif
88#include <libkcal/phoneformat.h> 94#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 95#ifndef KORG_NOMAIL
90#include "komailclient.h" 96#include "komailclient.h"
91#endif 97#endif
92#ifndef KORG_NOPRINTER 98#ifndef KORG_NOPRINTER
93#include "calprinter.h" 99#include "calprinter.h"
94#endif 100#endif
95#ifndef KORG_NOPLUGINS 101#ifndef KORG_NOPLUGINS
96#include "kocore.h" 102#include "kocore.h"
97#endif 103#endif
98#include "koeventeditor.h" 104#include "koeventeditor.h"
99#include "kotodoeditor.h" 105#include "kotodoeditor.h"
100#include "koprefs.h" 106#include "koprefs.h"
101#include "koeventviewerdialog.h" 107#include "koeventviewerdialog.h"
102#include "publishdialog.h" 108#include "publishdialog.h"
103#include "kofilterview.h" 109#include "kofilterview.h"
104#include "koglobals.h" 110#include "koglobals.h"
105#include "koviewmanager.h" 111#include "koviewmanager.h"
106#include "koagendaview.h" 112#include "koagendaview.h"
107#include "koagenda.h" 113#include "koagenda.h"
108#include "kodialogmanager.h" 114#include "kodialogmanager.h"
109#include "outgoingdialog.h" 115#include "outgoingdialog.h"
110#include "incomingdialog.h" 116#include "incomingdialog.h"
111#include "datenavigatorcontainer.h" 117#include "datenavigatorcontainer.h"
112#include "statusdialog.h" 118#include "statusdialog.h"
113#include "kdatenavigator.h" 119#include "kdatenavigator.h"
114#include "kotodoview.h" 120#include "kotodoview.h"
115#include "datenavigator.h" 121#include "datenavigator.h"
116#include "resourceview.h" 122#include "resourceview.h"
117#include "navigatorbar.h" 123#include "navigatorbar.h"
118#include "searchdialog.h" 124#include "searchdialog.h"
119#include "mainwindow.h" 125#include "mainwindow.h"
120#include "categoryeditdialog.h" 126#include "categoryeditdialog.h"
121 127
122#include "calendarview.h" 128#include "calendarview.h"
123#ifndef DESKTOP_VERSION 129#ifndef DESKTOP_VERSION
124#include <qtopia/alarmserver.h> 130#include <qtopia/alarmserver.h>
125#endif 131#endif
126#ifndef _WIN32_ 132#ifndef _WIN32_
127#include <stdlib.h> 133#include <stdlib.h>
128#include <stdio.h> 134#include <stdio.h>
129#include <unistd.h> 135#include <unistd.h>
130#else 136#else
131#include <qprocess.h> 137#include <q3process.h>
132#endif 138#endif
133 139
134#ifdef DESKTOP_VERSION 140#ifdef DESKTOP_VERSION
135#include <kabc/stdaddressbook.h> 141#include <kabc/stdaddressbook.h>
136#endif 142#endif
137using namespace KOrg; 143using namespace KOrg;
138using namespace KCal; 144using namespace KCal;
139extern int globalFlagBlockAgenda; 145extern int globalFlagBlockAgenda;
140extern int globalFlagBlockStartup; 146extern int globalFlagBlockStartup;
141 147
142 148
143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 149MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, Q3PtrList<Incidence> alarms,QDateTime start ) : Q3TextBrowser(parent)
144 150
145{ 151{
146 mAlarms = alarms; 152 mAlarms = alarms;
147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 153 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
148 QString mText = "<table width=\"100%\">\n"; 154 QString mText = "<table width=\"100%\">\n";
149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 155 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
150#ifdef DESKTOP_VERSION 156#ifdef DESKTOP_VERSION
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 157 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
152#else 158#else
153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 159 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
154#endif 160#endif
155 // mText += "<img src=\""; 161 // mText += "<img src=\"";
156 // mText += ipath; 162 // mText += ipath;
157 // mText += "\">"; 163 // mText += "\">";
158 //mEventDate = QDate::currentDate(); 164 //mEventDate = QDate::currentDate();
159#ifdef DESKTOP_VERSION 165#ifdef DESKTOP_VERSION
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 166 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
161#else 167#else
162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 168 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
163#endif 169#endif
164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 170 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
165 171
166 Incidence * inc = getNextInc( start ); 172 Incidence * inc = getNextInc( start );
167 int time = 0; 173 int time = 0;
168 //mText += "<table>"; 174 //mText += "<table>";
169 while ( inc ) { 175 while ( inc ) {
170 QDateTime dt ; 176 QDateTime dt ;
171 QString tempText = "<a "; 177 QString tempText = "<a ";
172 bool ok; 178 bool ok;
173 dt = inc->getNextOccurence( start, &ok ); 179 dt = inc->getNextOccurence( start, &ok );
174 if ( !ok ) continue; 180 if ( !ok ) continue;
175 if ( inc->typeID() == eventID ) { 181 if ( inc->typeID() == eventID ) {
176 tempText += "href=\"event:"; 182 tempText += "href=\"event:";
177 } else if ( inc->typeID() == todoID ) { 183 } else if ( inc->typeID() == todoID ) {
178 tempText += "href=\"todo:"; 184 tempText += "href=\"todo:";
179 } 185 }
180 tempText += inc->uid() + "\">"; 186 tempText += inc->uid() + "\">";
181 if ( inc->typeID() == todoID ) 187 if ( inc->typeID() == todoID )
182 tempText += i18n("Todo: "); 188 tempText += i18n("Todo: ");
183 if ( inc->summary().length() > 0 ) 189 if ( inc->summary().length() > 0 )
184 tempText += inc->summary(); 190 tempText += inc->summary();
185 else 191 else
186 tempText += i18n("-no summary-"); 192 tempText += i18n("-no summary-");
187 QString timestr; 193 QString timestr;
188 if (!inc->doesFloat()) 194 if (!inc->doesFloat())
189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 195 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
190 else 196 else
191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 197 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
@@ -232,322 +238,322 @@ Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
232 if ( inc == 0 ) 238 if ( inc == 0 )
233 return 0; 239 return 0;
234 bool ok; 240 bool ok;
235 dt = inc->getNextOccurence( start, &ok ); 241 dt = inc->getNextOccurence( start, &ok );
236 if ( ! ok ) return 0; 242 if ( ! ok ) return 0;
237 QDateTime dtn ; 243 QDateTime dtn ;
238 retInc = inc; 244 retInc = inc;
239 inc = mAlarms.next(); 245 inc = mAlarms.next();
240 while ( inc ) { 246 while ( inc ) {
241 dtn = inc->getNextOccurence( start, &ok ); 247 dtn = inc->getNextOccurence( start, &ok );
242 if ( ! ok ) return 0; 248 if ( ! ok ) return 0;
243 if ( dtn < dt ) { 249 if ( dtn < dt ) {
244 dt = dtn; 250 dt = dtn;
245 retInc = inc; 251 retInc = inc;
246 } 252 }
247 inc = mAlarms.next(); 253 inc = mAlarms.next();
248 } 254 }
249 mAlarms.remove( retInc ); 255 mAlarms.remove( retInc );
250 return retInc; 256 return retInc;
251 257
252} 258}
253void MissedAlarmTextBrowser::setSource(const QString & n) 259void MissedAlarmTextBrowser::setSource(const QString & n)
254{ 260{
255 if (n.startsWith("event:")) { 261 if (n.startsWith("event:")) {
256#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
257 emit showIncidence(n.mid(8)); 263 emit showIncidence(n.mid(8));
258#else 264#else
259 emit showIncidence(n.mid(6)); 265 emit showIncidence(n.mid(6));
260#endif 266#endif
261 return; 267 return;
262 } else if (n.startsWith("todo:")) { 268 } else if (n.startsWith("todo:")) {
263#ifdef DESKTOP_VERSION 269#ifdef DESKTOP_VERSION
264 emit showIncidence(n.mid(7)); 270 emit showIncidence(n.mid(7));
265#else 271#else
266 emit showIncidence(n.mid(5)); 272 emit showIncidence(n.mid(5));
267#endif 273#endif
268 return; 274 return;
269 } 275 }
270} 276}
271 277
272 278
273class KOBeamPrefs : public QDialog 279class KOBeamPrefs : public QDialog
274{ 280{
275 public: 281 public:
276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 282 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
277 QDialog( parent, name, true ) 283 QDialog( parent, name, true )
278 { 284 {
279 setCaption( i18n("Beam Options") ); 285 setCaption( i18n("Beam Options") );
280 QVBoxLayout* lay = new QVBoxLayout( this ); 286 Q3VBoxLayout* lay = new Q3VBoxLayout( this );
281 lay->setSpacing( 3 ); 287 lay->setSpacing( 3 );
282 lay->setMargin( 3 ); 288 lay->setMargin( 3 );
283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 289 Q3ButtonGroup* format = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("File format"), this );
284 lay->addWidget( format ); 290 lay->addWidget( format );
285 format->setExclusive ( true ) ; 291 format->setExclusive ( true ) ;
286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 292 Q3ButtonGroup* time = new Q3ButtonGroup(1, Qt::Horizontal, i18n("Time format"), this );
287 lay->addWidget( time ); time->setExclusive ( true ) ; 293 lay->addWidget( time ); time->setExclusive ( true ) ;
288 vcal = new QRadioButton(" vCalendar ", format ); 294 vcal = new QRadioButton(" vCalendar ", format );
289 ical = new QRadioButton(" iCalendar ", format ); 295 ical = new QRadioButton(" iCalendar ", format );
290 vcal->setChecked( true ); 296 vcal->setChecked( true );
291 tz = new QRadioButton(i18n(" With timezone "), time ); 297 tz = new QRadioButton(i18n(" With timezone "), time );
292 local = new QRadioButton(i18n(" Local time "), time ); 298 local = new QRadioButton(i18n(" Local time "), time );
293 tz->setChecked( true ); 299 tz->setChecked( true );
294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 300 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
295 lay->addWidget( ok ); 301 lay->addWidget( ok );
296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 302 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
297 lay->addWidget( cancel ); 303 lay->addWidget( cancel );
298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 304 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 305 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
300 resize( 200, 200 ); 306 resize( 200, 200 );
301 } 307 }
302 308
303 bool beamVcal() { return vcal->isChecked(); } 309 bool beamVcal() { return vcal->isChecked(); }
304 bool beamLocal() { return local->isChecked(); } 310 bool beamLocal() { return local->isChecked(); }
305private: 311private:
306 QRadioButton* vcal, *ical, *local, *tz; 312 QRadioButton* vcal, *ical, *local, *tz;
307}; 313};
308class KOCatPrefs : public QDialog 314class KOCatPrefs : public QDialog
309{ 315{
310 public: 316 public:
311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 317 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
312 QDialog( parent, name, true ) 318 QDialog( parent, name, true )
313 { 319 {
314 setCaption( i18n("Manage new Categories") ); 320 setCaption( i18n("Manage new Categories") );
315 QVBoxLayout* lay = new QVBoxLayout( this ); 321 Q3VBoxLayout* lay = new Q3VBoxLayout( this );
316 lay->setSpacing( 3 ); 322 lay->setSpacing( 3 );
317 lay->setMargin( 3 ); 323 lay->setMargin( 3 );
318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 324 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
319 lay->addWidget( lab ); 325 lay->addWidget( lab );
320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 326 Q3ButtonGroup* format = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("New categories not in list:"), this );
321 lay->addWidget( format ); 327 lay->addWidget( format );
322 format->setExclusive ( true ) ; 328 format->setExclusive ( true ) ;
323 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 329 addCatBut = new QRadioButton(i18n("Add to category list"), format );
324 new QRadioButton(i18n("Remove from Events/Todos"), format ); 330 new QRadioButton(i18n("Remove from Events/Todos"), format );
325 addCatBut->setChecked( true ); 331 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 332 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 333 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 334 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 335 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 336 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 337 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 338 resize( 200, 200 );
333 } 339 }
334 340
335 bool addCat() { return addCatBut->isChecked(); } 341 bool addCat() { return addCatBut->isChecked(); }
336private: 342private:
337 QRadioButton* addCatBut; 343 QRadioButton* addCatBut;
338}; 344};
339 345
340 346
341 347
342CalendarView::CalendarView( CalendarResources *calendar, 348CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 349 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 350 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 351 mCalendar( calendar ),
346 mResourceManager( calendar->resourceManager() ) 352 mResourceManager( calendar->resourceManager() )
347{ 353{
348 354
349 mEventEditor = 0; 355 mEventEditor = 0;
350 mTodoEditor = 0; 356 mTodoEditor = 0;
351 357
352 init(); 358 init();
353} 359}
354 360
355CalendarView::CalendarView( Calendar *calendar, 361CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 362 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 363 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 364 mCalendar( calendar ),
359 mResourceManager( 0 ) 365 mResourceManager( 0 )
360{ 366{
361 367
362 mEventEditor = 0; 368 mEventEditor = 0;
363 mTodoEditor = 0; 369 mTodoEditor = 0;
364 init(); 370 init();
365} 371}
366 372
367void CalendarView::init() 373void CalendarView::init()
368{ 374{
369 mMultiResourceSync = false; 375 mMultiResourceSync = false;
370 flag_blockConflict = false; 376 flag_blockConflict = false;
371 flag_blockScrollBar = false; 377 flag_blockScrollBar = false;
372 flag_checkFileFirsttime = true; 378 flag_checkFileFirsttime = true;
373 flag_clearallviewsEventDisplay = false; 379 flag_clearallviewsEventDisplay = false;
374 flag_clearallviewsupdateView = false; 380 flag_clearallviewsupdateView = false;
375 mNextAlarmDateTime = QDateTime::currentDateTime(); 381 mNextAlarmDateTime = QDateTime::currentDateTime();
376 setFocusPolicy (NoFocus ); 382 setFocusPolicy (Qt::NoFocus );
377 mViewerCallerIsSearchDialog = false; 383 mViewerCallerIsSearchDialog = false;
378 mBlockShowDates = false; 384 mBlockShowDates = false;
379 mConflictingEvent = 0; 385 mConflictingEvent = 0;
380 mDatePickerMode = 0; 386 mDatePickerMode = 0;
381 mCurrentSyncDevice = ""; 387 mCurrentSyncDevice = "";
382 mViewManager = new KOViewManager( this ); 388 mViewManager = new KOViewManager( this );
383 mDialogManager = new KODialogManager( this ); 389 mDialogManager = new KODialogManager( this );
384 mEventViewerDialog = 0; 390 mEventViewerDialog = 0;
385 mModified = false; 391 mModified = false;
386 mReadOnly = false; 392 mReadOnly = false;
387 mSelectedIncidence = 0; 393 mSelectedIncidence = 0;
388 mCalPrinter = 0; 394 mCalPrinter = 0;
389 mFilters.setAutoDelete(true); 395 mFilters.setAutoDelete(true);
390 396
391 mCalendar->registerObserver( this ); 397 mCalendar->registerObserver( this );
392 // TODO: Make sure that view is updated, when calendar is changed. 398 // TODO: Make sure that view is updated, when calendar is changed.
393 399
394 mStorage = new FileStorage( mCalendar ); 400 mStorage = new FileStorage( mCalendar );
395 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 401 mNavigator = new DateNavigator( this, "datevav", mViewManager );
396 402
397 QBoxLayout *topLayout = (QBoxLayout*)layout(); 403 Q3BoxLayout *topLayout = (Q3BoxLayout*)layout();
398#ifndef KORG_NOSPLITTER 404#ifndef KORG_NOSPLITTER
399 // create the main layout frames. 405 // create the main layout frames.
400 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 406 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
401 topLayout->addWidget(mPanner); 407 topLayout->addWidget(mPanner);
402 408
403 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 409 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
404 "CalendarView::LeftFrame"); 410 "CalendarView::LeftFrame");
405 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 411 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
406 412
407 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 413 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
408 "CalendarView::DateNavigator" ); 414 "CalendarView::DateNavigator" );
409 415
410 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 416 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
411 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 417 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
412 mTodoList->setNavigator( mNavigator ); 418 mTodoList->setNavigator( mNavigator );
413 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 419 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
414 420
415#ifdef KORG_NORESOURCEVIEW 421#ifdef KORG_NORESOURCEVIEW
416 mResourceView = 0; 422 mResourceView = 0;
417#else 423#else
418 if ( mResourceManager ) { 424 if ( mResourceManager ) {
419 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 425 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
420 mResourceView->updateView(); 426 mResourceView->updateView();
421 connect( mResourceView, SIGNAL( resourcesChanged() ), 427 connect( mResourceView, SIGNAL( resourcesChanged() ),
422 SLOT( updateView() ) ); 428 SLOT( updateView() ) );
423 } else { 429 } else {
424 mResourceView = 0; 430 mResourceView = 0;
425 } 431 }
426#endif 432#endif
427 QWidget *rightBox = new QWidget( mPanner ); 433 QWidget *rightBox = new QWidget( mPanner );
428 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 434 Q3BoxLayout *rightLayout = new Q3VBoxLayout( rightBox );
429 435
430 mRightFrame = new QWidgetStack( rightBox ); 436 mRightFrame = new Q3WidgetStack( rightBox );
431 rightLayout->addWidget( mRightFrame, 1 ); 437 rightLayout->addWidget( mRightFrame, 1 );
432 438
433 mLeftFrame = mLeftSplitter; 439 mLeftFrame = mLeftSplitter;
434#else 440#else
435 //QWidget *mainBox = new QWidget( this ); 441 //QWidget *mainBox = new QWidget( this );
436 //QWidget *leftFrame = new QWidget( mainBox ); 442 //QWidget *leftFrame = new QWidget( mainBox );
437 //QBoxLayout * mainBoxLayout; 443 //QBoxLayout * mainBoxLayout;
438 if ( KOPrefs::instance()->mVerticalScreen ) { 444 if ( KOPrefs::instance()->mVerticalScreen ) {
439 //mainBoxLayout = new QVBoxLayout(mainBox); 445 //mainBoxLayout = new QVBoxLayout(mainBox);
440 //leftFrameLayout = new QHBoxLayout(leftFrame ); 446 //leftFrameLayout = new QHBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 447 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 448 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 449 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 450 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
445 } else { 451 } else {
446 //mainBoxLayout = new QHBoxLayout(mainBox); 452 //mainBoxLayout = new QHBoxLayout(mainBox);
447 //leftFrameLayout = new QVBoxLayout(leftFrame ); 453 //leftFrameLayout = new QVBoxLayout(leftFrame );
448 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 454 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
449 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 455 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
450 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 456 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
451 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 457 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
452 } 458 }
453 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 459 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
454 //QBoxLayout * leftFrameLayout; 460 //QBoxLayout * leftFrameLayout;
455 topLayout->addWidget( mMainFrame ); 461 topLayout->addWidget( mMainFrame );
456#ifdef DESKTOP_VERSION 462#ifdef DESKTOP_VERSION
457 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 463 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,Qt::Horizontal, this );
458 topLayout->addWidget( mDateScrollBar ); 464 topLayout->addWidget( mDateScrollBar );
459 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 465 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
460 if ( QApplication::desktop()->width() < 800 ) 466 if ( QApplication::desktop()->width() < 800 )
461 mDateScrollBar->hide(); 467 mDateScrollBar->hide();
462#endif 468#endif
463 //mainBoxLayout->addWidget (mLeftFrame); 469 //mainBoxLayout->addWidget (mLeftFrame);
464 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 470 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
465 "CalendarView::DateNavigator" ); 471 "CalendarView::DateNavigator" );
466#if 0 472#if 0
467 // FIXME 473 // FIXME
468 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 474 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
469 "CalendarView::DateNavigator", QDate::currentDate()); 475 "CalendarView::DateNavigator", QDate::currentDate());
470#endif 476#endif
471 // mDateNavigator->blockSignals( true ); 477 // mDateNavigator->blockSignals( true );
472 //leftFrameLayout->addWidget( mDateNavigator ); 478 //leftFrameLayout->addWidget( mDateNavigator );
473 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 479 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
474 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 480 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
475 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 481 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
476 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 482 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
477 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 483 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
478 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 484 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
479 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 485 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
480 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 486 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
481 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 487 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
482 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 488 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
483 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 489 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
484 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 490 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
485 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 491 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
486 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); 492 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) );
487 493
488 494
489 mTodoList->setNavigator( mNavigator ); 495 mTodoList->setNavigator( mNavigator );
490#if 0 496#if 0
491 if ( QApplication::desktop()->width() < 480 ) { 497 if ( QApplication::desktop()->width() < 480 ) {
492 leftFrameLayout->addWidget(mFilterView); 498 leftFrameLayout->addWidget(mFilterView);
493 leftFrameLayout->addWidget(mTodoList, 2 ); 499 leftFrameLayout->addWidget(mTodoList, 2 );
494 500
495 } else { 501 } else {
496 leftFrameLayout->addWidget(mTodoList,2 ); 502 leftFrameLayout->addWidget(mTodoList,2 );
497 leftFrameLayout->addWidget(mFilterView ); 503 leftFrameLayout->addWidget(mFilterView );
498 } 504 }
499#endif 505#endif
500 mFilterView->hide(); 506 mFilterView->hide();
501 mCalEditView->hide(); 507 mCalEditView->hide();
502 QWidget *rightBox = new QWidget( mMainFrame ); 508 QWidget *rightBox = new QWidget( mMainFrame );
503 //mainBoxLayout->addWidget ( rightBox, 10 ); 509 //mainBoxLayout->addWidget ( rightBox, 10 );
504 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 510 Q3BoxLayout *rightLayout = new Q3VBoxLayout( rightBox );
505 mRightFrame = new QWidgetStack( rightBox ); 511 mRightFrame = new Q3WidgetStack( rightBox );
506 rightLayout->addWidget( mRightFrame, 10 ); 512 rightLayout->addWidget( mRightFrame, 10 );
507 513
508 //mLeftFrame = (QWidget *)leftFrame; 514 //mLeftFrame = (QWidget *)leftFrame;
509 if ( KOPrefs::instance()->mVerticalScreen ) { 515 if ( KOPrefs::instance()->mVerticalScreen ) {
510 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 516 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
511 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 517 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
512 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 518 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
513 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 519 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
514 } else { 520 } else {
515 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 521 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
516 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 522 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
517 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 523 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
518 } 524 }
519 if ( !KOPrefs::instance()->mShowDateNavigator) 525 if ( !KOPrefs::instance()->mShowDateNavigator)
520 mDateNavigator->hide(); 526 mDateNavigator->hide();
521 //qDebug("Calendarview Size %d %d ", width(), height()); 527 //qDebug("Calendarview Size %d %d ", width(), height());
522#endif 528#endif
523 529
524 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 530 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
525 SLOT( showDates( const KCal::DateList & ) ) ); 531 SLOT( showDates( const KCal::DateList & ) ) );
526 532
527 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 533 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
528 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 534 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
529 535
530 536
531 537
532 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 538 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
533 mViewManager, SLOT( showMonth( const QDate & ) ) ); 539 mViewManager, SLOT( showMonth( const QDate & ) ) );
534 540
535 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 541 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
536 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 542 mNavigator, SLOT( selectWeek( const QDate & ) ) );
537 543
538 connect( mDateNavigator, SIGNAL( goPrevYear() ), 544 connect( mDateNavigator, SIGNAL( goPrevYear() ),
539 mNavigator, SLOT( selectPreviousYear() ) ); 545 mNavigator, SLOT( selectPreviousYear() ) );
540 connect( mDateNavigator, SIGNAL( goNextYear() ), 546 connect( mDateNavigator, SIGNAL( goNextYear() ),
541 mNavigator, SLOT( selectNextYear() ) ); 547 mNavigator, SLOT( selectNextYear() ) );
542 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 548 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
543 mNavigator, SLOT( selectPreviousMonth() ) ); 549 mNavigator, SLOT( selectPreviousMonth() ) );
544 connect( mDateNavigator, SIGNAL( goNextMonth() ), 550 connect( mDateNavigator, SIGNAL( goNextMonth() ),
545 mNavigator, SLOT( selectNextMonth() ) ); 551 mNavigator, SLOT( selectNextMonth() ) );
546 552
547 connect( mDateNavigator, SIGNAL( goPrevious() ), 553 connect( mDateNavigator, SIGNAL( goPrevious() ),
548 mNavigator, SLOT( selectPrevious() ) ); 554 mNavigator, SLOT( selectPrevious() ) );
549 connect( mDateNavigator, SIGNAL( goNext() ), 555 connect( mDateNavigator, SIGNAL( goNext() ),
550 mNavigator, SLOT( selectNext() ) ); 556 mNavigator, SLOT( selectNext() ) );
551 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 557 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
552 mNavigator, SLOT( slotMonthSelect( int ) ) ); 558 mNavigator, SLOT( slotMonthSelect( int ) ) );
553 559
@@ -571,166 +577,166 @@ void CalendarView::init()
571 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 577 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
572 SLOT( showTodo( Todo *) ) ); 578 SLOT( showTodo( Todo *) ) );
573 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 579 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
574 SLOT( deleteTodo( Todo *) ) ); 580 SLOT( deleteTodo( Todo *) ) );
575 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 581 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
576 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 582 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
577 SLOT( purgeCompleted() ) ); 583 SLOT( purgeCompleted() ) );
578 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 584 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
579 SIGNAL( todoModified( Todo *, int ) ) ); 585 SIGNAL( todoModified( Todo *, int ) ) );
580 586
581 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 587 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
582 this, SLOT ( cloneIncidence( Incidence * ) ) ); 588 this, SLOT ( cloneIncidence( Incidence * ) ) );
583 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 589 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
584 this, SLOT (cancelIncidence( Incidence * ) ) ); 590 this, SLOT (cancelIncidence( Incidence * ) ) );
585 591
586 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 592 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
587 this, SLOT ( moveIncidence( Incidence * ) ) ); 593 this, SLOT ( moveIncidence( Incidence * ) ) );
588 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 594 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
589 this, SLOT ( beamIncidence( Incidence * ) ) ); 595 this, SLOT ( beamIncidence( Incidence * ) ) );
590 596
591 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 597 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
592 this, SLOT ( todo_unsub( Todo * ) ) ); 598 this, SLOT ( todo_unsub( Todo * ) ) );
593 599
594 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 600 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
595 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 601 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
596 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 602 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
597 SLOT( updateTodo( Todo *, int ) ) ); 603 SLOT( updateTodo( Todo *, int ) ) );
598 connect( this, SIGNAL( todoModified( Todo *, int )), this, 604 connect( this, SIGNAL( todoModified( Todo *, int )), this,
599 SLOT( changeTodoDisplay( Todo *, int ) ) ); 605 SLOT( changeTodoDisplay( Todo *, int ) ) );
600 606
601 607
602 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 608 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
603 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 609 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
604 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 610 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
605 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 611 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
606 612
607 613
608 614
609 615
610 616
611 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 617 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
612 SLOT(checkClipboard())); 618 SLOT(checkClipboard()));
613 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 619 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
614 SLOT( processTodoListSelection( Incidence * ) ) ); 620 SLOT( processTodoListSelection( Incidence * ) ) );
615 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 621 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
616 622
617 // kdDebug() << "CalendarView::CalendarView() done" << endl; 623 // kdDebug() << "CalendarView::CalendarView() done" << endl;
618 624
619 mDateFrame = new QVBox(0,0,WType_Popup); 625 mDateFrame = new Q3VBox(0,0,Qt::WType_Popup);
620 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 626 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
621 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 627 mDateFrame->setFrameStyle( Q3Frame::WinPanel |Q3Frame::Raised );
622 mDateFrame->setLineWidth(3); 628 mDateFrame->setLineWidth(3);
623 mDateFrame->hide(); 629 mDateFrame->hide();
624 mDateFrame->setCaption( i18n( "Pick a date to display")); 630 mDateFrame->setCaption( i18n( "Pick a date to display"));
625 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 631 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
626 632
627 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 633 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
628 634
629 mEventEditor = mDialogManager->getEventEditor(); 635 mEventEditor = mDialogManager->getEventEditor();
630 mTodoEditor = mDialogManager->getTodoEditor(); 636 mTodoEditor = mDialogManager->getTodoEditor();
631 637
632 mFlagEditDescription = false; 638 mFlagEditDescription = false;
633 639
634 mSuspendTimer = new QTimer( this ); 640 mSuspendTimer = new QTimer( this );
635 mAlarmTimer = new QTimer( this ); 641 mAlarmTimer = new QTimer( this );
636 mRecheckAlarmTimer = new QTimer( this ); 642 mRecheckAlarmTimer = new QTimer( this );
637 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 643 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
638 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 644 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
639 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 645 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
640 mAlarmDialog = new AlarmDialog( this ); 646 mAlarmDialog = new AlarmDialog( this );
641 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 647 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
642 mAlarmDialog->setServerNotification( false ); 648 mAlarmDialog->setServerNotification( false );
643 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 649 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
644 650
645 651
646#ifndef DESKTOP_VERSION 652#ifndef DESKTOP_VERSION
647//US listen for arriving address resultsets 653//US listen for arriving address resultsets
648 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 654 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
649 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 655 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
650#endif 656#endif
651 mDateNavigator->setCalendar( mCalendar ); 657 mDateNavigator->setCalendar( mCalendar );
652} 658}
653 659
654 660
655CalendarView::~CalendarView() 661CalendarView::~CalendarView()
656{ 662{
657 // kdDebug() << "~CalendarView()" << endl; 663 // kdDebug() << "~CalendarView()" << endl;
658 //qDebug("CalendarView::~CalendarView() "); 664 //qDebug("CalendarView::~CalendarView() ");
659 delete mDialogManager; 665 delete mDialogManager;
660 delete mViewManager; 666 delete mViewManager;
661 delete mStorage; 667 delete mStorage;
662 delete mDateFrame ; 668 delete mDateFrame ;
663 delete mEventViewerDialog; 669 delete mEventViewerDialog;
664 //kdDebug() << "~CalendarView() done" << endl; 670 //kdDebug() << "~CalendarView() done" << endl;
665} 671}
666 672
667 673
668void CalendarView::nextConflict( bool all, bool allday ) 674void CalendarView::nextConflict( bool all, bool allday )
669{ 675{
670 if ( flag_blockConflict ) return; 676 if ( flag_blockConflict ) return;
671 flag_blockConflict = true; 677 flag_blockConflict = true;
672 QPtrList<Event> testlist = mCalendar->events(); 678 Q3PtrList<Event> testlist = mCalendar->events();
673 Event * test = testlist.first(); 679 Event * test = testlist.first();
674 while ( test ) { 680 while ( test ) {
675 test->setTagged( false ); 681 test->setTagged( false );
676 test = testlist.next(); 682 test = testlist.next();
677 } 683 }
678 QTime st ( 0,0,0); 684 QTime st ( 0,0,0);
679 if ( mViewManager->currentView() == mViewManager->agendaView() ) 685 if ( mViewManager->currentView() == mViewManager->agendaView() )
680 st = mViewManager->agendaView()->agenda()->getEndTime(); 686 st = mViewManager->agendaView()->agenda()->getEndTime();
681 //qDebug("time %s ", st.toString().latin1()); 687 //qDebug("time %s ", st.toString().latin1());
682 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 688 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
683 QDateTime conflict; 689 QDateTime conflict;
684 QDateTime retVal; 690 QDateTime retVal;
685 bool found = false; 691 bool found = false;
686 Event * cE = 0; 692 Event * cE = 0;
687 Event * cE2 = 0; 693 Event * cE2 = 0;
688 QPtrList<Event> testlist2 = testlist; 694 Q3PtrList<Event> testlist2 = testlist;
689 test = testlist.first(); 695 test = testlist.first();
690 bool skip = false; 696 bool skip = false;
691 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 697 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
692 //QTime tm; 698 //QTime tm;
693 //tm.start(); 699 //tm.start();
694 while ( test ) { 700 while ( test ) {
695 qApp->processEvents(); 701 qApp->processEvents();
696 skip = false; 702 skip = false;
697 if ( !all ) skip = ( allday != test->doesFloat() ); 703 if ( !all ) skip = ( allday != test->doesFloat() );
698 if ( !skip ) { 704 if ( !skip ) {
699 if ( found ) 705 if ( found )
700 skip = !test->matchTime( &startDT, &conflict ); 706 skip = !test->matchTime( &startDT, &conflict );
701 else 707 else
702 skip = !test->matchTime( &startDT, 0 ); 708 skip = !test->matchTime( &startDT, 0 );
703 } 709 }
704 if ( !skip ) { 710 if ( !skip ) {
705 Event * test2 = testlist2.first(); 711 Event * test2 = testlist2.first();
706 while ( test2 ) { 712 while ( test2 ) {
707 skip = test2->isTagged(); 713 skip = test2->isTagged();
708 if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); 714 if ( !skip && !all ) skip = ( allday != test2->doesFloat() );
709 if ( !skip ) { 715 if ( !skip ) {
710 if ( found ) 716 if ( found )
711 skip = !test2->matchTime( &startDT, &conflict ); 717 skip = !test2->matchTime( &startDT, &conflict );
712 else 718 else
713 skip = !test2->matchTime( &startDT, 0 ); 719 skip = !test2->matchTime( &startDT, 0 );
714 } 720 }
715 if ( !skip ) { 721 if ( !skip ) {
716 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 722 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
717 //qDebug("overlap "); 723 //qDebug("overlap ");
718 if ( ! found ) { 724 if ( ! found ) {
719 if ( retVal >= startDT ) { 725 if ( retVal >= startDT ) {
720 conflict = retVal; 726 conflict = retVal;
721 cE = test; 727 cE = test;
722 cE2 = test2; 728 cE2 = test2;
723 found = true; 729 found = true;
724 } 730 }
725 } else { 731 } else {
726 if ( retVal >= startDT && retVal < conflict ) { 732 if ( retVal >= startDT && retVal < conflict ) {
727 conflict = retVal; 733 conflict = retVal;
728 cE = test; 734 cE = test;
729 cE2 = test2; 735 cE2 = test2;
730 } 736 }
731 } 737 }
732 } 738 }
733 } 739 }
734 test2 = testlist2.next(); 740 test2 = testlist2.next();
735 } 741 }
736 } 742 }
@@ -790,150 +796,150 @@ void CalendarView::scrollBarValue(int val )
790 if ( flag_blockScrollBar ) return; 796 if ( flag_blockScrollBar ) return;
791 flag_blockScrollBar = true; 797 flag_blockScrollBar = true;
792 int count = mNavigator->selectedDates().count(); 798 int count = mNavigator->selectedDates().count();
793 int day = mNavigator->selectedDates().first().dayOfYear(); 799 int day = mNavigator->selectedDates().first().dayOfYear();
794 int stepdays = val; 800 int stepdays = val;
795 if ( mDateScrollBar->lineStep () <= count ) { 801 if ( mDateScrollBar->lineStep () <= count ) {
796 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 802 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
797 //qDebug("VAL %d ",val ); 803 //qDebug("VAL %d ",val );
798 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 804 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
799 stepdays = day+stepdays; 805 stepdays = day+stepdays;
800 if ( stepdays < 0 ) stepdays = 0; 806 if ( stepdays < 0 ) stepdays = 0;
801 } 807 }
802 if ( stepdays == day ) { 808 if ( stepdays == day ) {
803 flag_blockScrollBar = false; 809 flag_blockScrollBar = false;
804 return; 810 return;
805 } 811 }
806 int year = mNavigator->selectedDates().first().year(); 812 int year = mNavigator->selectedDates().first().year();
807 QDate d ( year,1,1 ); 813 QDate d ( year,1,1 );
808 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 814 mNavigator->selectDates( d.addDays( stepdays-1) , count );
809 flag_blockScrollBar = false; 815 flag_blockScrollBar = false;
810#else 816#else
811 Q_UNUSED( val ); 817 Q_UNUSED( val );
812#endif 818#endif
813 819
814} 820}
815void CalendarView::updateView(const QDate &start, const QDate &end) 821void CalendarView::updateView(const QDate &start, const QDate &end)
816{ 822{
817#ifdef DESKTOP_VERSION 823#ifdef DESKTOP_VERSION
818 if ( ! mDateScrollBar->draggingSlider () ) { 824 if ( ! mDateScrollBar->draggingSlider () ) {
819 int dof = start.dayOfYear(); 825 int dof = start.dayOfYear();
820 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 826 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
821 if ( dof != mDateScrollBar->value() ) { 827 if ( dof != mDateScrollBar->value() ) {
822 mDateScrollBar->blockSignals( true ); 828 mDateScrollBar->blockSignals( true );
823 mDateScrollBar->setValue( start.dayOfYear()); 829 mDateScrollBar->setValue( start.dayOfYear());
824 mDateScrollBar->blockSignals( false ); 830 mDateScrollBar->blockSignals( false );
825 } 831 }
826 } 832 }
827#endif 833#endif
828 mTodoList->updateView(); 834 mTodoList->updateView();
829 mViewManager->updateView(start, end); 835 mViewManager->updateView(start, end);
830 //mDateNavigator->updateView(); 836 //mDateNavigator->updateView();
831} 837}
832 838
833 839
834 840
835void CalendarView::checkFiles() 841void CalendarView::checkFiles()
836{ 842{
837 QString message; 843 QString message;
838 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 844 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
839 KopiCalendarFile * cal = calendars.first(); 845 KopiCalendarFile * cal = calendars.first();
840 while ( cal ) { 846 while ( cal ) {
841 if ( cal->mErrorOnLoad ) { 847 if ( cal->mErrorOnLoad ) {
842 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 848 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
843 } 849 }
844 cal = calendars.next(); 850 cal = calendars.next();
845 } 851 }
846 if ( !message.isEmpty() ) { 852 if ( !message.isEmpty() ) {
847 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); 853 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0);
848 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); 854 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed"));
849 } 855 }
850 if ( flag_checkFileFirsttime ) { 856 if ( flag_checkFileFirsttime ) {
851 flag_checkFileFirsttime = false; 857 flag_checkFileFirsttime = false;
852 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 858 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
853 } 859 }
854} 860}
855void CalendarView::checkAlarms() 861void CalendarView::checkAlarms()
856{ 862{
857 KConfig *config = KOGlobals::config(); 863 KConfig *config = KOGlobals::config();
858 config->setGroup( "AppRun" ); 864 config->setGroup( "AppRun" );
859 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 865 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
860 int daysto = dt.daysTo( QDate::currentDate() ); 866 int daysto = dt.daysTo( (QDateTime)QDate::currentDate() );
861 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 867 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
862 dt = dt.addDays( days ); 868 dt = dt.addDays( days );
863 int secto = dt.secsTo( QDateTime::currentDateTime() ); 869 int secto = dt.secsTo( QDateTime::currentDateTime() );
864 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 870 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
865 //qDebug("KO: Reading program stop %d ", secs); 871 //qDebug("KO: Reading program stop %d ", secs);
866 //secs -= ( 3600 * 24*3 ); // debug only 872 //secs -= ( 3600 * 24*3 ); // debug only
867 QDateTime latest = dt.addSecs ( secs ); 873 QDateTime latest = dt.addSecs ( secs );
868 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 874 qDebug("KO: Last termination on %s ", latest.toString().latin1());
869 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 875 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
870 QPtrList<Incidence> el = mCalendar->rawIncidences(); 876 Q3PtrList<Incidence> el = mCalendar->rawIncidences();
871 QPtrList<Incidence> al; 877 Q3PtrList<Incidence> al;
872 Incidence* inL = el.first(); 878 Incidence* inL = el.first();
873 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 879 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
874 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 880 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
875 while ( inL ) { 881 while ( inL ) {
876 bool ok = false; 882 bool ok = false;
877 int offset = 0; 883 int offset = 0;
878 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 884 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
879 if ( ok ) { 885 if ( ok ) {
880 //qDebug("OK %s",next.toString().latin1()); 886 //qDebug("OK %s",next.toString().latin1());
881 if ( next < cur ) { 887 if ( next < cur ) {
882 al.append( inL ); 888 al.append( inL );
883 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 889 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
884 } 890 }
885 } 891 }
886 inL = el.next(); 892 inL = el.next();
887 } 893 }
888 if ( al.count() ) { 894 if ( al.count() ) {
889 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 895 QDialog* dia = new QDialog( this, "huhu", false, Qt::WDestructiveClose | Qt::WStyle_StaysOnTop );
890 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 896 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
891 QVBoxLayout* lay = new QVBoxLayout( dia ); 897 Q3VBoxLayout* lay = new Q3VBoxLayout( dia );
892 lay->setSpacing( 0 ); 898 lay->setSpacing( 0 );
893 lay->setMargin( 0 ); 899 lay->setMargin( 0 );
894 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 900 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
895 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 901 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
896 lay->addWidget( matb ); 902 lay->addWidget( matb );
897 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 903 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
898 int wid = 210; 904 int wid = 210;
899 int x = QApplication::desktop()->width() - wid - 7; 905 int x = QApplication::desktop()->width() - wid - 7;
900 int y = QApplication::desktop()->height() - wid - 70; 906 int y = QApplication::desktop()->height() - wid - 70;
901 dia->setGeometry ( x,y,wid,wid); 907 dia->setGeometry ( x,y,wid,wid);
902 } else { 908 } else {
903 int si = 220; 909 int si = 220;
904 if ( QApplication::desktop()->width() > 470 ) 910 if ( QApplication::desktop()->width() > 470 )
905 si = 400; 911 si = 400;
906 dia->resize(si,si/2); 912 dia->resize(si,si/2);
907 } 913 }
908 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 914 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
909 dia->show(); 915 dia->show();
910 916
911 } 917 }
912#if 0 918#if 0
913 // for creating timetracker test data 919 // for creating timetracker test data
914 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); 920 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc ");
915 Todo * nt; 921 Todo * nt;
916 mCalendar->close(); 922 mCalendar->close();
917 { 923 {
918 Todo * root1 = new Todo; 924 Todo * root1 = new Todo;
919 mCalendar->addTodo( root1 ); 925 mCalendar->addTodo( root1 );
920 root1->setSummary( "Project1"); 926 root1->setSummary( "Project1");
921 root1->setPriority( 1 ); 927 root1->setPriority( 1 );
922 root1->setCategories( QString( "Cat_Pro1") ); 928 root1->setCategories( QString( "Cat_Pro1") );
923 root1->setDescription( "This is a test description of a root Project" ); 929 root1->setDescription( "This is a test description of a root Project" );
924 root1->setPercentComplete( 20 ); 930 root1->setPercentComplete( 20 );
925 updateView(); 931 updateView();
926 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 932 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
927 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 933 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
928 934
929 nt = new Todo; 935 nt = new Todo;
930 mCalendar->addTodo( nt ); 936 mCalendar->addTodo( nt );
931 nt->setSummary( "Planning Project1"); 937 nt->setSummary( "Planning Project1");
932 nt->setPriority( 1 ); 938 nt->setPriority( 1 );
933 nt->setDescription( "This is a test description of Planning Project1" ); 939 nt->setDescription( "This is a test description of Planning Project1" );
934 nt->setPercentComplete( 20 ); 940 nt->setPercentComplete( 20 );
935 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); 941 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") );
936 942
937 943
938 Todo * sub1 = nt; 944 Todo * sub1 = nt;
939 sub1->setRelatedTo( root1 ); 945 sub1->setRelatedTo( root1 );
@@ -1171,178 +1177,178 @@ void CalendarView::computeAlarm( QString msg )
1171 QString filename = MainWindow::resourcePath(); 1177 QString filename = MainWindow::resourcePath();
1172 filename += "koalarm.wav"; 1178 filename += "koalarm.wav";
1173 QString tempfilename; 1179 QString tempfilename;
1174 if ( mess.left( 13 ) == "suspend_alarm") { 1180 if ( mess.left( 13 ) == "suspend_alarm") {
1175 bool error = false; 1181 bool error = false;
1176 int len = mess.mid( 13 ).find("+++"); 1182 int len = mess.mid( 13 ).find("+++");
1177 if ( len < 2 ) 1183 if ( len < 2 )
1178 error = true; 1184 error = true;
1179 else { 1185 else {
1180 tempfilename = mess.mid( 13, len ); 1186 tempfilename = mess.mid( 13, len );
1181 if ( !QFile::exists( tempfilename ) ) 1187 if ( !QFile::exists( tempfilename ) )
1182 error = true; 1188 error = true;
1183 } 1189 }
1184 if ( ! error ) { 1190 if ( ! error ) {
1185 filename = tempfilename; 1191 filename = tempfilename;
1186 } 1192 }
1187 mAlarmMessage = mess.mid( 13+len+3 ); 1193 mAlarmMessage = mess.mid( 13+len+3 );
1188 //qDebug("suspend file %s ",tempfilename.latin1() ); 1194 //qDebug("suspend file %s ",tempfilename.latin1() );
1189 startAlarm( mAlarmMessage, filename); 1195 startAlarm( mAlarmMessage, filename);
1190 return; 1196 return;
1191 } 1197 }
1192 if ( mess.left( 11 ) == "timer_alarm") { 1198 if ( mess.left( 11 ) == "timer_alarm") {
1193 //mTimerTime = 0; 1199 //mTimerTime = 0;
1194 startAlarm( mess.mid( 11 ), filename ); 1200 startAlarm( mess.mid( 11 ), filename );
1195 return; 1201 return;
1196 } 1202 }
1197 if ( mess.left( 10 ) == "proc_alarm") { 1203 if ( mess.left( 10 ) == "proc_alarm") {
1198 bool error = false; 1204 bool error = false;
1199 int len = mess.mid( 10 ).find("+++"); 1205 int len = mess.mid( 10 ).find("+++");
1200 if ( len < 2 ) 1206 if ( len < 2 )
1201 error = true; 1207 error = true;
1202 else { 1208 else {
1203 tempfilename = mess.mid( 10, len ); 1209 tempfilename = mess.mid( 10, len );
1204 if ( !QFile::exists( tempfilename ) ) 1210 if ( !QFile::exists( tempfilename ) )
1205 error = true; 1211 error = true;
1206 } 1212 }
1207 if ( error ) { 1213 if ( error ) {
1208 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 1214 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
1209 mAlarmMessage += mess.mid( 10+len+3+9 ); 1215 mAlarmMessage += mess.mid( 10+len+3+9 );
1210 } else { 1216 } else {
1211 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 1217 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
1212 //qDebug("-----system command %s ",tempfilename.latin1() ); 1218 //qDebug("-----system command %s ",tempfilename.latin1() );
1213#ifndef _WIN32_ 1219#ifndef _WIN32_
1214 if ( vfork () == 0 ) { 1220 if ( vfork () == 0 ) {
1215 execl ( tempfilename.latin1(), 0 ); 1221 execl ( tempfilename.latin1(), 0 );
1216 return; 1222 return;
1217 } 1223 }
1218#else 1224#else
1219 QProcess* p = new QProcess(); 1225 Q3Process* p = new Q3Process();
1220 p->addArgument( tempfilename.latin1() ); 1226 p->addArgument( tempfilename.latin1() );
1221 p->start(); 1227 p->start();
1222 return; 1228 return;
1223#endif 1229#endif
1224 1230
1225 return; 1231 return;
1226 } 1232 }
1227 1233
1228 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 1234 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1229 } 1235 }
1230 if ( mess.left( 11 ) == "audio_alarm") { 1236 if ( mess.left( 11 ) == "audio_alarm") {
1231 bool error = false; 1237 bool error = false;
1232 int len = mess.mid( 11 ).find("+++"); 1238 int len = mess.mid( 11 ).find("+++");
1233 if ( len < 2 ) 1239 if ( len < 2 )
1234 error = true; 1240 error = true;
1235 else { 1241 else {
1236 tempfilename = mess.mid( 11, len ); 1242 tempfilename = mess.mid( 11, len );
1237 if ( !QFile::exists( tempfilename ) ) 1243 if ( !QFile::exists( tempfilename ) )
1238 error = true; 1244 error = true;
1239 } 1245 }
1240 if ( ! error ) { 1246 if ( ! error ) {
1241 filename = tempfilename; 1247 filename = tempfilename;
1242 } 1248 }
1243 mAlarmMessage = mess.mid( 11+len+3+9 ); 1249 mAlarmMessage = mess.mid( 11+len+3+9 );
1244 //qDebug("audio file command %s ",tempfilename.latin1() ); 1250 //qDebug("audio file command %s ",tempfilename.latin1() );
1245 } 1251 }
1246 if ( mess.left( 9 ) == "cal_alarm") { 1252 if ( mess.left( 9 ) == "cal_alarm") {
1247 mAlarmMessage = mess.mid( 9 ) ; 1253 mAlarmMessage = mess.mid( 9 ) ;
1248 } 1254 }
1249 1255
1250 startAlarm( mAlarmMessage, filename ); 1256 startAlarm( mAlarmMessage, filename );
1251 1257
1252 1258
1253} 1259}
1254 1260
1255void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1261void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1256{ 1262{
1257 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1263 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1258 1264
1259 mSuspendAlarmNotification = noti; 1265 mSuspendAlarmNotification = noti;
1260 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1266 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1261 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1267 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1262 mSuspendTimer->start( ms , true ); 1268 mSuspendTimer->start( ms , true );
1263#ifdef DESKTOP_VERSION 1269#ifdef DESKTOP_VERSION
1264 if ( QApplication::desktop()->width() < 1024 ) { 1270 if ( QApplication::desktop()->width() < 1024 ) {
1265 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1271 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1266 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); 1272 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() );
1267 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; 1273 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm";
1268 QFile file( fn ); 1274 QFile file( fn );
1269 if (!file.open( IO_WriteOnly ) ) { 1275 if (!file.open( QIODevice::WriteOnly ) ) {
1270 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1276 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1271 } else { 1277 } else {
1272 QTextStream ts( &file ); 1278 Q3TextStream ts( &file );
1273 ts << mess; 1279 ts << mess;
1274 file.close(); 1280 file.close();
1275 } 1281 }
1276 } 1282 }
1277#endif 1283#endif
1278 1284
1279} 1285}
1280 1286
1281void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1287void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1282{ 1288{
1283 mNextAlarmDateTime = qdt; 1289 mNextAlarmDateTime = qdt;
1284 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1290 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1285 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1291 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1286#ifndef DESKTOP_VERSION 1292#ifndef DESKTOP_VERSION
1287 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1293 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1288#endif 1294#endif
1289 return; 1295 return;
1290 } 1296 }
1291#ifdef DESKTOP_VERSION 1297#ifdef DESKTOP_VERSION
1292 if ( QApplication::desktop()->width() < 1024 ) { 1298 if ( QApplication::desktop()->width() < 1024 ) {
1293 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1299 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1294 //qDebug("nextalarm = \n%s ",mess.latin1() ); 1300 //qDebug("nextalarm = \n%s ",mess.latin1() );
1295 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; 1301 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm";
1296 QFile file( fn ); 1302 QFile file( fn );
1297 if (!file.open( IO_WriteOnly ) ) { 1303 if (!file.open( QIODevice::WriteOnly ) ) {
1298 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1304 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1299 } else { 1305 } else {
1300 QTextStream ts( &file ); 1306 Q3TextStream ts( &file );
1301 ts << mess; 1307 ts << mess;
1302 file.close(); 1308 file.close();
1303 } 1309 }
1304 } 1310 }
1305#endif 1311#endif
1306 int maxSec; 1312 int maxSec;
1307 //maxSec = 5; //testing only 1313 //maxSec = 5; //testing only
1308 maxSec = 86400+3600; // one day+1hour 1314 maxSec = 86400+3600; // one day+1hour
1309 mAlarmNotification = noti; 1315 mAlarmNotification = noti;
1310 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1316 int sec = QDateTime::currentDateTime().secsTo( qdt );
1311 if ( sec > maxSec ) { 1317 if ( sec > maxSec ) {
1312 mRecheckAlarmTimer->start( maxSec * 1000 ); 1318 mRecheckAlarmTimer->start( maxSec * 1000 );
1313 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1319 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1314 return; 1320 return;
1315 } else { 1321 } else {
1316 mRecheckAlarmTimer->stop(); 1322 mRecheckAlarmTimer->stop();
1317 } 1323 }
1318 //qDebug("Alarm timer started with secs: %d ", sec); 1324 //qDebug("Alarm timer started with secs: %d ", sec);
1319 mAlarmTimer->start( sec * 1000 , true ); 1325 mAlarmTimer->start( sec * 1000 , true );
1320 1326
1321} 1327}
1322// called by mRecheckAlarmTimer to get next alarm 1328// called by mRecheckAlarmTimer to get next alarm
1323// we need this, because a QTimer has only a max range of 25 days 1329// we need this, because a QTimer has only a max range of 25 days
1324void CalendarView::recheckTimerAlarm() 1330void CalendarView::recheckTimerAlarm()
1325{ 1331{
1326 mAlarmTimer->stop(); 1332 mAlarmTimer->stop();
1327 mRecheckAlarmTimer->stop(); 1333 mRecheckAlarmTimer->stop();
1328 mCalendar->checkAlarmForIncidence( 0, true ); 1334 mCalendar->checkAlarmForIncidence( 0, true );
1329} 1335}
1330#ifndef DESKTOP_VERSION 1336#ifndef DESKTOP_VERSION
1331void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1337void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1332#else 1338#else
1333void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1339void CalendarView::removeAlarm(const QDateTime &, const QString & )
1334#endif 1340#endif
1335{ 1341{
1336 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1342 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1337 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1343 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1338#ifndef DESKTOP_VERSION 1344#ifndef DESKTOP_VERSION
1339 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1345 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1340#endif 1346#endif
1341 return; 1347 return;
1342 } 1348 }
1343 mAlarmTimer->stop(); 1349 mAlarmTimer->stop();
1344} 1350}
1345void CalendarView::selectWeekNum ( int num ) 1351void CalendarView::selectWeekNum ( int num )
1346{ 1352{
1347 dateNavigator()->blockSignals( true ); 1353 dateNavigator()->blockSignals( true );
1348 dateNavigator()->selectWeek( num ); 1354 dateNavigator()->selectWeek( num );
@@ -1525,214 +1531,214 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b
1525 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1531 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1526 getEventViewerDialog()->showMe(); 1532 getEventViewerDialog()->showMe();
1527 result = getEventViewerDialog()->executeS( localIsNew ); 1533 result = getEventViewerDialog()->executeS( localIsNew );
1528 return result; 1534 return result;
1529 1535
1530 break; 1536 break;
1531 case SYNC_PREF_FORCE_LOCAL: 1537 case SYNC_PREF_FORCE_LOCAL:
1532 return 1; 1538 return 1;
1533 break; 1539 break;
1534 case SYNC_PREF_FORCE_REMOTE: 1540 case SYNC_PREF_FORCE_REMOTE:
1535 return 2; 1541 return 2;
1536 break; 1542 break;
1537 1543
1538 default: 1544 default:
1539 // SYNC_PREF_TAKE_BOTH not implemented 1545 // SYNC_PREF_TAKE_BOTH not implemented
1540 break; 1546 break;
1541 } 1547 }
1542 return 0; 1548 return 0;
1543} 1549}
1544Event* CalendarView::getLastSyncEvent() 1550Event* CalendarView::getLastSyncEvent()
1545{ 1551{
1546 Event* lse; 1552 Event* lse;
1547 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1553 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1548 mCalendar->setSyncEventsEnabled(); 1554 mCalendar->setSyncEventsEnabled();
1549 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1555 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1550 if (!lse) { 1556 if (!lse) {
1551 qDebug("KO: New last Syncevent created for local: %s",mCurrentSyncDevice.latin1() ); 1557 qDebug("KO: New last Syncevent created for local: %s",mCurrentSyncDevice.latin1() );
1552 lse = new Event(); 1558 lse = new Event();
1553 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1559 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1554 QString sum = ""; 1560 QString sum = "";
1555 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1561 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1556 sum = "E: "; 1562 sum = "E: ";
1557 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1563 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1558 lse->setDtStart( mLastCalendarSync ); 1564 lse->setDtStart( mLastCalendarSync );
1559 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1565 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1560 lse->setCategories( i18n("SyncEvent") ); 1566 lse->setCategories( i18n("SyncEvent") );
1561 lse->setReadOnly( true ); 1567 lse->setReadOnly( true );
1562 lse->setCalID( 1 ); 1568 lse->setCalID( 1 );
1563 mCalendar->addEvent( lse ); 1569 mCalendar->addEvent( lse );
1564 } else 1570 } else
1565 qDebug("KO: Last Syncevent on local found"); 1571 qDebug("KO: Last Syncevent on local found");
1566 1572
1567 return lse; 1573 return lse;
1568 1574
1569} 1575}
1570 1576
1571// we check, if the to delete event has a id for a profile 1577// we check, if the to delete event has a id for a profile
1572// if yes, we set this id in the profile to delete 1578// if yes, we set this id in the profile to delete
1573void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1579void CalendarView::checkExternSyncEvent( Q3PtrList<Event> lastSync , Incidence* toDelete )
1574{ 1580{
1575 if ( lastSync.count() == 0 ) { 1581 if ( lastSync.count() == 0 ) {
1576 //qDebug(" lastSync.count() == 0"); 1582 //qDebug(" lastSync.count() == 0");
1577 return; 1583 return;
1578 } 1584 }
1579 if ( toDelete->typeID() == journalID ) 1585 if ( toDelete->typeID() == journalID )
1580 return; 1586 return;
1581 1587
1582 Event* eve = lastSync.first(); 1588 Event* eve = lastSync.first();
1583 1589
1584 while ( eve ) { 1590 while ( eve ) {
1585 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1591 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1586 if ( !id.isEmpty() ) { 1592 if ( !id.isEmpty() ) {
1587 QString des = eve->description(); 1593 QString des = eve->description();
1588 QString pref = "e"; 1594 QString pref = "e";
1589 if ( toDelete->typeID() == todoID ) 1595 if ( toDelete->typeID() == todoID )
1590 pref = "t"; 1596 pref = "t";
1591 des += pref+ id + ","; 1597 des += pref+ id + ",";
1592 eve->setReadOnly( false ); 1598 eve->setReadOnly( false );
1593 eve->setDescription( des ); 1599 eve->setDescription( des );
1594 //qDebug("setdes %s ", des.latin1()); 1600 //qDebug("setdes %s ", des.latin1());
1595 eve->setReadOnly( true ); 1601 eve->setReadOnly( true );
1596 } 1602 }
1597 eve = lastSync.next(); 1603 eve = lastSync.next();
1598 } 1604 }
1599 1605
1600} 1606}
1601void CalendarView::checkExternalId( Incidence * inc ) 1607void CalendarView::checkExternalId( Incidence * inc )
1602{ 1608{
1603 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1609 Q3PtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1604 checkExternSyncEvent( lastSync, inc ); 1610 checkExternSyncEvent( lastSync, inc );
1605 1611
1606} 1612}
1607// SSSSSSSSSSSSSSSSSSSSSS 1613// SSSSSSSSSSSSSSSSSSSSSS
1608bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1614bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1609{ 1615{
1610 1616
1611 bool syncOK = true; 1617 bool syncOK = true;
1612 int addedEvent = 0; 1618 int addedEvent = 0;
1613 int addedEventR = 0; 1619 int addedEventR = 0;
1614 int deletedEventR = 0; 1620 int deletedEventR = 0;
1615 int deletedEventL = 0; 1621 int deletedEventL = 0;
1616 int changedLocal = 0; 1622 int changedLocal = 0;
1617 int changedRemote = 0; 1623 int changedRemote = 0;
1618 int filteredIN = 0; 1624 int filteredIN = 0;
1619 int filteredOUT = 0; 1625 int filteredOUT = 0;
1620 //QPtrList<Event> el = local->rawEvents(); 1626 //QPtrList<Event> el = local->rawEvents();
1621 Event* eventR; 1627 Event* eventR;
1622 QString uid; 1628 QString uid;
1623 int take; 1629 int take;
1624 Event* eventRSync; 1630 Event* eventRSync;
1625 Event* eventLSync; 1631 Event* eventLSync;
1626 clearAllViews(); 1632 clearAllViews();
1627 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1633 Q3PtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1628 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1634 Q3PtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1629 bool fullDateRange = false; 1635 bool fullDateRange = false;
1630 local->resetTempSyncStat(); 1636 local->resetTempSyncStat();
1631 mLastCalendarSync = QDateTime::currentDateTime(); 1637 mLastCalendarSync = QDateTime::currentDateTime();
1632 if ( mSyncManager->syncWithDesktop() ) { 1638 if ( mSyncManager->syncWithDesktop() ) {
1633 remote->resetPilotStat(1); 1639 remote->resetPilotStat(1);
1634 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1640 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1635 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1641 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1636 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1642 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1637 } else { 1643 } else {
1638 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1644 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1639 } 1645 }
1640 } 1646 }
1641 QDateTime modifiedCalendar = mLastCalendarSync; 1647 QDateTime modifiedCalendar = mLastCalendarSync;
1642 eventLSync = getLastSyncEvent(); 1648 eventLSync = getLastSyncEvent();
1643 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1649 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1644 if ( eventR ) { 1650 if ( eventR ) {
1645 qDebug("KO: Last-syncEvent on remote found "); 1651 qDebug("KO: Last-syncEvent on remote found ");
1646 eventRSync = (Event*) eventR->clone(); 1652 eventRSync = (Event*) eventR->clone();
1647 remote->deleteEvent(eventR ); 1653 remote->deleteEvent(eventR );
1648 1654
1649 } else { 1655 } else {
1650 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1656 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1651 eventRSync = (Event*)eventLSync->clone(); 1657 eventRSync = (Event*)eventLSync->clone();
1652 } else { 1658 } else {
1653 fullDateRange = true; 1659 fullDateRange = true;
1654 eventRSync = new Event(); 1660 eventRSync = new Event();
1655 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1661 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1656 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1662 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1657 eventRSync->setDtStart( mLastCalendarSync ); 1663 eventRSync->setDtStart( mLastCalendarSync );
1658 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1664 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1659 eventRSync->setCategories( i18n("SyncEvent") ); 1665 eventRSync->setCategories( i18n("SyncEvent") );
1660 } 1666 }
1661 } 1667 }
1662 if ( eventLSync->dtStart() == mLastCalendarSync ) 1668 if ( eventLSync->dtStart() == mLastCalendarSync )
1663 fullDateRange = true; 1669 fullDateRange = true;
1664 1670
1665 if ( ! fullDateRange ) { 1671 if ( ! fullDateRange ) {
1666 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1672 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1667 1673
1668 qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1674 qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1669 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1675 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1670 fullDateRange = true; 1676 fullDateRange = true;
1671 } 1677 }
1672 } 1678 }
1673 if ( mSyncManager->syncWithDesktop() ) { 1679 if ( mSyncManager->syncWithDesktop() ) {
1674 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1680 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1675 } 1681 }
1676 if ( fullDateRange ) 1682 if ( fullDateRange )
1677 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1683 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1678 else 1684 else
1679 mLastCalendarSync = eventLSync->dtStart(); 1685 mLastCalendarSync = eventLSync->dtStart();
1680 // for resyncing if own file has changed 1686 // for resyncing if own file has changed
1681 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1687 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1682 mLastCalendarSync = loadedFileVersion; 1688 mLastCalendarSync = loadedFileVersion;
1683 //qDebug("setting mLastCalendarSync "); 1689 //qDebug("setting mLastCalendarSync ");
1684 } 1690 }
1685 //qDebug("*************************** "); 1691 //qDebug("*************************** ");
1686 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1692 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1687 QPtrList<Incidence> er = remote->rawIncidences(); 1693 Q3PtrList<Incidence> er = remote->rawIncidences();
1688 Incidence* inR = er.first(); 1694 Incidence* inR = er.first();
1689 Incidence* inL; 1695 Incidence* inL;
1690 QProgressBar bar( er.count(),0 ); 1696 Q3ProgressBar bar( er.count(),0 );
1691 bar.setCaption (i18n("Syncing - close to abort!") ); 1697 bar.setCaption (i18n("Syncing - close to abort!") );
1692 1698
1693 // ************** setting up filter ************* 1699 // ************** setting up filter *************
1694 CalFilter *filterIN = 0; 1700 CalFilter *filterIN = 0;
1695 CalFilter *filterOUT = 0; 1701 CalFilter *filterOUT = 0;
1696 CalFilter *filter = mFilters.first(); 1702 CalFilter *filter = mFilters.first();
1697 while(filter) { 1703 while(filter) {
1698 if ( filter->name() == mSyncManager->mFilterInCal ) 1704 if ( filter->name() == mSyncManager->mFilterInCal )
1699 filterIN = filter; 1705 filterIN = filter;
1700 if ( filter->name() == mSyncManager->mFilterOutCal ) 1706 if ( filter->name() == mSyncManager->mFilterOutCal )
1701 filterOUT = filter; 1707 filterOUT = filter;
1702 filter = mFilters.next(); 1708 filter = mFilters.next();
1703 } 1709 }
1704 int w = 300; 1710 int w = 300;
1705 if ( QApplication::desktop()->width() < 320 ) 1711 if ( QApplication::desktop()->width() < 320 )
1706 w = 220; 1712 w = 220;
1707 int h = bar.sizeHint().height() ; 1713 int h = bar.sizeHint().height() ;
1708 int dw = QApplication::desktop()->width(); 1714 int dw = QApplication::desktop()->width();
1709 int dh = QApplication::desktop()->height(); 1715 int dh = QApplication::desktop()->height();
1710 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1716 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1711 bar.show(); 1717 bar.show();
1712 int modulo = (er.count()/10)+1; 1718 int modulo = (er.count()/10)+1;
1713 int incCounter = 0; 1719 int incCounter = 0;
1714 while ( inR ) { 1720 while ( inR ) {
1715 if ( ! bar.isVisible() ) 1721 if ( ! bar.isVisible() )
1716 return false; 1722 return false;
1717 if ( incCounter % modulo == 0 ) 1723 if ( incCounter % modulo == 0 )
1718 bar.setProgress( incCounter ); 1724 bar.setProgress( incCounter );
1719 ++incCounter; 1725 ++incCounter;
1720 uid = inR->uid(); 1726 uid = inR->uid();
1721 bool skipIncidence = false; 1727 bool skipIncidence = false;
1722 if ( uid.left(15) == QString("last-syncEvent-") ) 1728 if ( uid.left(15) == QString("last-syncEvent-") )
1723 skipIncidence = true; 1729 skipIncidence = true;
1724 QString idS; 1730 QString idS;
1725 qApp->processEvents(); 1731 qApp->processEvents();
1726 if ( !skipIncidence ) { 1732 if ( !skipIncidence ) {
1727 int hasCalId = 0; 1733 int hasCalId = 0;
1728 inL = local->incidenceForUid( uid , false , true, &hasCalId ); 1734 inL = local->incidenceForUid( uid , false , true, &hasCalId );
1729 if ( hasCalId && !inL ) 1735 if ( hasCalId && !inL )
1730 inL = local->incidenceForUid( uid , false , true, &hasCalId ); 1736 inL = local->incidenceForUid( uid , false , true, &hasCalId );
1731 else 1737 else
1732 hasCalId = 0; 1738 hasCalId = 0;
1733 if ( inL ) { // maybe conflict - same uid in both calendars 1739 if ( inL ) { // maybe conflict - same uid in both calendars
1734 1740
1735 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1741 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1736 //qDebug("take %d %s ", take, inL->summary().latin1()); 1742 //qDebug("take %d %s ", take, inL->summary().latin1());
1737 if ( take == 3 ) 1743 if ( take == 3 )
1738 return false; 1744 return false;
@@ -1786,97 +1792,97 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1786 } 1792 }
1787 1793
1788 1794
1789 } else { // no conflict ********** add or delete remote 1795 } else { // no conflict ********** add or delete remote
1790 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1796 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1791 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1797 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1792 QString des = eventLSync->description(); 1798 QString des = eventLSync->description();
1793 QString pref = "e"; 1799 QString pref = "e";
1794 if ( inR->typeID() == todoID ) 1800 if ( inR->typeID() == todoID )
1795 pref = "t"; 1801 pref = "t";
1796 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1802 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1797 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1803 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1798 //remote->deleteIncidence( inR ); 1804 //remote->deleteIncidence( inR );
1799 ++deletedEventR; 1805 ++deletedEventR;
1800 } else { 1806 } else {
1801 inR->setLastModified( modifiedCalendar ); 1807 inR->setLastModified( modifiedCalendar );
1802 inL = inR->clone(); 1808 inL = inR->clone();
1803 inL->setIDStr( ":" ); 1809 inL->setIDStr( ":" );
1804 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1810 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1805 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1811 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1806 1812
1807 inL->setCalID_block( 0 );// add to default cal 1813 inL->setCalID_block( 0 );// add to default cal
1808 local->addIncidence( inL ); 1814 local->addIncidence( inL );
1809 ++addedEvent; 1815 ++addedEvent;
1810 1816
1811 } 1817 }
1812 } else { 1818 } else {
1813 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1819 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1814 inR->setLastModified( modifiedCalendar ); 1820 inR->setLastModified( modifiedCalendar );
1815 inL = inR->clone(); 1821 inL = inR->clone();
1816 inL->setIDStr( ":" ); 1822 inL->setIDStr( ":" );
1817 inL->setCalID_block( 0 );// add to default cal 1823 inL->setCalID_block( 0 );// add to default cal
1818 local->addIncidence( inL ); 1824 local->addIncidence( inL );
1819 ++addedEvent; 1825 ++addedEvent;
1820 1826
1821 } else { 1827 } else {
1822 checkExternSyncEvent(eventRSyncSharp, inR); 1828 checkExternSyncEvent(eventRSyncSharp, inR);
1823 remote->deleteIncidence( inR ); 1829 remote->deleteIncidence( inR );
1824 ++deletedEventR; 1830 ++deletedEventR;
1825 } 1831 }
1826 } 1832 }
1827 } else { 1833 } else {
1828 ++filteredIN; 1834 ++filteredIN;
1829 } 1835 }
1830 } 1836 }
1831 } 1837 }
1832 inR = er.next(); 1838 inR = er.next();
1833 } 1839 }
1834 QPtrList<Incidence> el = local->rawIncidences(); 1840 Q3PtrList<Incidence> el = local->rawIncidences();
1835 inL = el.first(); 1841 inL = el.first();
1836 modulo = (el.count()/10)+1; 1842 modulo = (el.count()/10)+1;
1837 bar.setCaption (i18n("Add / remove events") ); 1843 bar.setCaption (i18n("Add / remove events") );
1838 bar.setTotalSteps ( el.count() ) ; 1844 bar.setTotalSteps ( el.count() ) ;
1839 bar.show(); 1845 bar.show();
1840 incCounter = 0; 1846 incCounter = 0;
1841 1847
1842 while ( inL ) { 1848 while ( inL ) {
1843 1849
1844 qApp->processEvents(); 1850 qApp->processEvents();
1845 if ( ! bar.isVisible() ) 1851 if ( ! bar.isVisible() )
1846 return false; 1852 return false;
1847 if ( incCounter % modulo == 0 ) 1853 if ( incCounter % modulo == 0 )
1848 bar.setProgress( incCounter ); 1854 bar.setProgress( incCounter );
1849 ++incCounter; 1855 ++incCounter;
1850 uid = inL->uid(); 1856 uid = inL->uid();
1851 bool skipIncidence = false; 1857 bool skipIncidence = false;
1852 if ( uid.left(15) == QString("last-syncEvent-") ) 1858 if ( uid.left(15) == QString("last-syncEvent-") )
1853 skipIncidence = true; 1859 skipIncidence = true;
1854 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1860 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1855 skipIncidence = true; 1861 skipIncidence = true;
1856 if ( !skipIncidence ) { 1862 if ( !skipIncidence ) {
1857 inR = remote->incidenceForUid( uid , true, true ); 1863 inR = remote->incidenceForUid( uid , true, true );
1858 if ( ! inR ) { 1864 if ( ! inR ) {
1859 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1865 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1860 // no conflict ********** add or delete local 1866 // no conflict ********** add or delete local
1861 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1867 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1862 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1868 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1863 checkExternSyncEvent(eventLSyncSharp, inL); 1869 checkExternSyncEvent(eventLSyncSharp, inL);
1864 local->deleteIncidence( inL ); 1870 local->deleteIncidence( inL );
1865 ++deletedEventL; 1871 ++deletedEventL;
1866 } else { 1872 } else {
1867 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1873 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1868 inL->removeID(mCurrentSyncDevice ); 1874 inL->removeID(mCurrentSyncDevice );
1869 ++addedEventR; 1875 ++addedEventR;
1870 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1876 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1871 inL->setLastModified( modifiedCalendar ); 1877 inL->setLastModified( modifiedCalendar );
1872 inR = inL->clone(); 1878 inR = inL->clone();
1873 inR->setIDStr( ":" ); 1879 inR->setIDStr( ":" );
1874 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1880 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1875 inR->setCalID_block( 0 );// add to default cal 1881 inR->setCalID_block( 0 );// add to default cal
1876 remote->addIncidence( inR ); 1882 remote->addIncidence( inR );
1877 } 1883 }
1878 } 1884 }
1879 } else { 1885 } else {
1880 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1886 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1881 checkExternSyncEvent(eventLSyncSharp, inL); 1887 checkExternSyncEvent(eventLSyncSharp, inL);
1882 local->deleteIncidence( inL ); 1888 local->deleteIncidence( inL );
@@ -2003,235 +2009,235 @@ bool CalendarView::syncCalendar(QString filename, int mode)
2003 } 2009 }
2004 } 2010 }
2005 setModified( true ); 2011 setModified( true );
2006 } 2012 }
2007 delete storage; 2013 delete storage;
2008 delete calendar; 2014 delete calendar;
2009 if ( syncOK ) 2015 if ( syncOK )
2010 updateView(); 2016 updateView();
2011 return syncOK; 2017 return syncOK;
2012} 2018}
2013 2019
2014void CalendarView::syncExternal( int mode ) 2020void CalendarView::syncExternal( int mode )
2015{ 2021{
2016 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 2022 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
2017 qApp->processEvents(); 2023 qApp->processEvents();
2018 CalendarLocal* calendar = new CalendarLocal(); 2024 CalendarLocal* calendar = new CalendarLocal();
2019 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2025 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2020 bool syncOK = false; 2026 bool syncOK = false;
2021 bool loadSuccess = false; 2027 bool loadSuccess = false;
2022 PhoneFormat* phoneFormat = 0; 2028 PhoneFormat* phoneFormat = 0;
2023 emit tempDisableBR(true); 2029 emit tempDisableBR(true);
2024#ifndef DESKTOP_VERSION 2030#ifndef DESKTOP_VERSION
2025 SharpFormat* sharpFormat = 0; 2031 SharpFormat* sharpFormat = 0;
2026 if ( mode == 0 ) { // sharp 2032 if ( mode == 0 ) { // sharp
2027 sharpFormat = new SharpFormat () ; 2033 sharpFormat = new SharpFormat () ;
2028 loadSuccess = sharpFormat->load( calendar, mCalendar ); 2034 loadSuccess = sharpFormat->load( calendar, mCalendar );
2029 2035
2030 } else 2036 } else
2031#endif 2037#endif
2032 if ( mode == 1 ) { // phone 2038 if ( mode == 1 ) { // phone
2033 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 2039 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
2034 mSyncManager->mPhoneDevice, 2040 mSyncManager->mPhoneDevice,
2035 mSyncManager->mPhoneConnection, 2041 mSyncManager->mPhoneConnection,
2036 mSyncManager->mPhoneModel); 2042 mSyncManager->mPhoneModel);
2037 loadSuccess = phoneFormat->load( calendar,mCalendar); 2043 loadSuccess = phoneFormat->load( calendar,mCalendar);
2038 2044
2039 } else { 2045 } else {
2040 emit tempDisableBR(false); 2046 emit tempDisableBR(false);
2041 return; 2047 return;
2042 } 2048 }
2043 if ( loadSuccess ) { 2049 if ( loadSuccess ) {
2044 getEventViewerDialog()->setSyncMode( true ); 2050 getEventViewerDialog()->setSyncMode( true );
2045 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2051 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2046 getEventViewerDialog()->setSyncMode( false ); 2052 getEventViewerDialog()->setSyncMode( false );
2047 qApp->processEvents(); 2053 qApp->processEvents();
2048 if ( syncOK ) { 2054 if ( syncOK ) {
2049 if ( mSyncManager->mWriteBackFile ) 2055 if ( mSyncManager->mWriteBackFile )
2050 { 2056 {
2051 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 2057 Q3PtrList<Incidence> iL = mCalendar->rawIncidences();
2052 Incidence* inc = iL.first(); 2058 Incidence* inc = iL.first();
2053 if ( phoneFormat ) { 2059 if ( phoneFormat ) {
2054 while ( inc ) { 2060 while ( inc ) {
2055 inc->removeID(mCurrentSyncDevice); 2061 inc->removeID(mCurrentSyncDevice);
2056 inc = iL.next(); 2062 inc = iL.next();
2057 } 2063 }
2058 } 2064 }
2059#ifndef DESKTOP_VERSION 2065#ifndef DESKTOP_VERSION
2060 if ( sharpFormat ) 2066 if ( sharpFormat )
2061 sharpFormat->save(calendar); 2067 sharpFormat->save(calendar);
2062#endif 2068#endif
2063 if ( phoneFormat ) 2069 if ( phoneFormat )
2064 phoneFormat->save(calendar); 2070 phoneFormat->save(calendar);
2065 iL = calendar->rawIncidences(); 2071 iL = calendar->rawIncidences();
2066 inc = iL.first(); 2072 inc = iL.first();
2067 Incidence* loc; 2073 Incidence* loc;
2068 while ( inc ) { 2074 while ( inc ) {
2069 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 2075 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
2070 loc = mCalendar->incidence(inc->uid() ); 2076 loc = mCalendar->incidence(inc->uid() );
2071 if ( loc ) { 2077 if ( loc ) {
2072 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 2078 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
2073 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 2079 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
2074 } 2080 }
2075 } 2081 }
2076 inc = iL.next(); 2082 inc = iL.next();
2077 } 2083 }
2078 Incidence* lse = getLastSyncEvent(); 2084 Incidence* lse = getLastSyncEvent();
2079 if ( lse ) { 2085 if ( lse ) {
2080 lse->setReadOnly( false ); 2086 lse->setReadOnly( false );
2081 lse->setDescription( "" ); 2087 lse->setDescription( "" );
2082 lse->setReadOnly( true ); 2088 lse->setReadOnly( true );
2083 } 2089 }
2084 } 2090 }
2085 } else { 2091 } else {
2086 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 2092 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
2087 } 2093 }
2088 setModified( true ); 2094 setModified( true );
2089 } else { 2095 } else {
2090 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 2096 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
2091 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 2097 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
2092 question, i18n("Ok")) ; 2098 question, i18n("Ok")) ;
2093 2099
2094 } 2100 }
2095 delete calendar; 2101 delete calendar;
2096 updateView(); 2102 updateView();
2097 emit tempDisableBR(false); 2103 emit tempDisableBR(false);
2098 return ;//syncOK; 2104 return ;//syncOK;
2099 2105
2100} 2106}
2101 2107
2102bool CalendarView::importBday() 2108bool CalendarView::importBday()
2103{ 2109{
2104#ifndef KORG_NOKABC 2110#ifndef KORG_NOKABC
2105 2111
2106#ifdef DESKTOP_VERSION 2112#ifdef DESKTOP_VERSION
2107 int curCal = mCalendar->defaultCalendar(); 2113 int curCal = mCalendar->defaultCalendar();
2108 int bd = mCalEditView->getBirtdayID(); 2114 int bd = mCalEditView->getBirtdayID();
2109 if ( bd == 0 ) 2115 if ( bd == 0 )
2110 return false; 2116 return false;
2111 mCalendar->setDefaultCalendar( bd ); 2117 mCalendar->setDefaultCalendar( bd );
2112 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 2118 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
2113 KABC::AddressBook::Iterator it; 2119 KABC::AddressBook::Iterator it;
2114 int count = 0; 2120 int count = 0;
2115 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2121 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2116 ++count; 2122 ++count;
2117 } 2123 }
2118 QProgressBar bar(count,0 ); 2124 Q3ProgressBar bar(count,0 );
2119 int w = 300; 2125 int w = 300;
2120 if ( QApplication::desktop()->width() < 320 ) 2126 if ( QApplication::desktop()->width() < 320 )
2121 w = 220; 2127 w = 220;
2122 int h = bar.sizeHint().height() ; 2128 int h = bar.sizeHint().height() ;
2123 int dw = QApplication::desktop()->width(); 2129 int dw = QApplication::desktop()->width();
2124 int dh = QApplication::desktop()->height(); 2130 int dh = QApplication::desktop()->height();
2125 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2131 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2126 bar.show(); 2132 bar.show();
2127 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 2133 bar.setCaption (i18n("Reading addressbook - close to abort!") );
2128 qApp->processEvents(); 2134 qApp->processEvents();
2129 count = 0; 2135 count = 0;
2130 int addCount = 0; 2136 int addCount = 0;
2131 KCal::Attendee* a = 0; 2137 KCal::Attendee* a = 0;
2132 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2138 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2133 if ( ! bar.isVisible() ) 2139 if ( ! bar.isVisible() )
2134 return false; 2140 return false;
2135 bar.setProgress( count++ ); 2141 bar.setProgress( count++ );
2136 qApp->processEvents(); 2142 qApp->processEvents();
2137 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 2143 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
2138 if ( (*it).birthday().date().isValid() ){ 2144 if ( (*it).birthday().date().isValid() ){
2139 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2145 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2140 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 2146 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
2141 ++addCount; 2147 ++addCount;
2142 } 2148 }
2143 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 2149 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
2144 if ( anni.isValid() ){ 2150 if ( anni.isValid() ){
2145 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2151 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2146 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 2152 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
2147 ++addCount; 2153 ++addCount;
2148 } 2154 }
2149 } 2155 }
2150 mCalendar->setDefaultCalendar( curCal ); 2156 mCalendar->setDefaultCalendar( curCal );
2151 updateView(); 2157 updateView();
2152 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2158 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2153#else //DESKTOP_VERSION 2159#else //DESKTOP_VERSION
2154 2160
2155 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 2161 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
2156 // the result should now arrive through method insertBirthdays 2162 // the result should now arrive through method insertBirthdays
2157 2163
2158#endif //DESKTOP_VERSION 2164#endif //DESKTOP_VERSION
2159 2165
2160#endif //KORG_NOKABC 2166#endif //KORG_NOKABC
2161 2167
2162 2168
2163 return true; 2169 return true;
2164} 2170}
2165 2171
2166// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 2172// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
2167void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 2173void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
2168 const QStringList& anniversaryList, const QStringList& realNameList, 2174 const QStringList& anniversaryList, const QStringList& realNameList,
2169 const QStringList& emailList, const QStringList& assembledNameList, 2175 const QStringList& emailList, const QStringList& assembledNameList,
2170 const QStringList& uidList) 2176 const QStringList& uidList)
2171{ 2177{
2172 2178
2173 //qDebug("KO::CalendarView::insertBirthdays"); 2179 //qDebug("KO::CalendarView::insertBirthdays");
2174 if (uid == this->name()) 2180 if (uid == this->name())
2175 { 2181 {
2176 int curCal = mCalendar->defaultCalendar(); 2182 int curCal = mCalendar->defaultCalendar();
2177 int bd = mCalEditView->getBirtdayID(); 2183 int bd = mCalEditView->getBirtdayID();
2178 if ( bd == 0 ) 2184 if ( bd == 0 )
2179 return; 2185 return;
2180 mCalendar->setDefaultCalendar( bd ); 2186 mCalendar->setDefaultCalendar( bd );
2181 2187
2182 2188
2183 int count = birthdayList.count(); 2189 int count = birthdayList.count();
2184 int addCount = 0; 2190 int addCount = 0;
2185 KCal::Attendee* a = 0; 2191 KCal::Attendee* a = 0;
2186 2192
2187 //qDebug("CalView 1 %i", count); 2193 //qDebug("CalView 1 %i", count);
2188 2194
2189 QProgressBar bar(count,0 ); 2195 Q3ProgressBar bar(count,0 );
2190 int w = 300; 2196 int w = 300;
2191 if ( QApplication::desktop()->width() < 320 ) 2197 if ( QApplication::desktop()->width() < 320 )
2192 w = 220; 2198 w = 220;
2193 int h = bar.sizeHint().height() ; 2199 int h = bar.sizeHint().height() ;
2194 int dw = QApplication::desktop()->width(); 2200 int dw = QApplication::desktop()->width();
2195 int dh = QApplication::desktop()->height(); 2201 int dh = QApplication::desktop()->height();
2196 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2202 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2197 bar.show(); 2203 bar.show();
2198 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 2204 bar.setCaption (i18n("inserting birthdays - close to abort!") );
2199 qApp->processEvents(); 2205 qApp->processEvents();
2200 2206
2201 QDate birthday; 2207 QDate birthday;
2202 QDate anniversary; 2208 QDate anniversary;
2203 QString realName; 2209 QString realName;
2204 QString email; 2210 QString email;
2205 QString assembledName; 2211 QString assembledName;
2206 QString uid; 2212 QString uid;
2207 bool ok = true; 2213 bool ok = true;
2208 for ( int i = 0; i < count; i++) 2214 for ( int i = 0; i < count; i++)
2209 { 2215 {
2210 if ( ! bar.isVisible() ) 2216 if ( ! bar.isVisible() )
2211 return; 2217 return;
2212 bar.setProgress( i ); 2218 bar.setProgress( i );
2213 qApp->processEvents(); 2219 qApp->processEvents();
2214 2220
2215 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 2221 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
2216 if (!ok) { 2222 if (!ok) {
2217 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 2223 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
2218 } 2224 }
2219 2225
2220 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 2226 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
2221 if (!ok) { 2227 if (!ok) {
2222 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 2228 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
2223 } 2229 }
2224 realName = realNameList[i]; 2230 realName = realNameList[i];
2225 email = emailList[i]; 2231 email = emailList[i];
2226 assembledName = assembledNameList[i]; 2232 assembledName = assembledNameList[i];
2227 uid = uidList[i]; 2233 uid = uidList[i];
2228 //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() ); 2234 //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() );
2229 2235
2230 if ( birthday.isValid() ){ 2236 if ( birthday.isValid() ){
2231 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2237 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2232 KCal::Attendee::ReqParticipant,uid) ; 2238 KCal::Attendee::ReqParticipant,uid) ;
2233 if ( addAnniversary( birthday, assembledName, a, true ) ) 2239 if ( addAnniversary( birthday, assembledName, a, true ) )
2234 ++addCount; 2240 ++addCount;
2235 } 2241 }
2236 2242
2237 if ( anniversary.isValid() ){ 2243 if ( anniversary.isValid() ){
@@ -2305,111 +2311,111 @@ bool CalendarView::importQtopia( const QString &categories,
2305 qApp->processEvents(); 2311 qApp->processEvents();
2306 CalendarLocal* calendar = new CalendarLocal(); 2312 CalendarLocal* calendar = new CalendarLocal();
2307 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2313 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2308 bool syncOK = false; 2314 bool syncOK = false;
2309 QtopiaFormat qtopiaFormat; 2315 QtopiaFormat qtopiaFormat;
2310 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2316 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2311 bool loadOk = true; 2317 bool loadOk = true;
2312 if ( !categories.isEmpty() ) 2318 if ( !categories.isEmpty() )
2313 loadOk = qtopiaFormat.load( calendar, categories ); 2319 loadOk = qtopiaFormat.load( calendar, categories );
2314 if ( loadOk && !datebook.isEmpty() ) 2320 if ( loadOk && !datebook.isEmpty() )
2315 loadOk = qtopiaFormat.load( calendar, datebook ); 2321 loadOk = qtopiaFormat.load( calendar, datebook );
2316 if ( loadOk && !todolist.isEmpty() ) 2322 if ( loadOk && !todolist.isEmpty() )
2317 loadOk = qtopiaFormat.load( calendar, todolist ); 2323 loadOk = qtopiaFormat.load( calendar, todolist );
2318 2324
2319 if ( loadOk ) { 2325 if ( loadOk ) {
2320 getEventViewerDialog()->setSyncMode( true ); 2326 getEventViewerDialog()->setSyncMode( true );
2321 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2327 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2322 getEventViewerDialog()->setSyncMode( false ); 2328 getEventViewerDialog()->setSyncMode( false );
2323 qApp->processEvents(); 2329 qApp->processEvents();
2324 if ( syncOK ) { 2330 if ( syncOK ) {
2325 if ( mSyncManager->mWriteBackFile ) 2331 if ( mSyncManager->mWriteBackFile )
2326 { 2332 {
2327 // write back XML file 2333 // write back XML file
2328 2334
2329 } 2335 }
2330 setModified( true ); 2336 setModified( true );
2331 } 2337 }
2332 } else { 2338 } else {
2333 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2339 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2334 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2340 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2335 question, i18n("Ok")) ; 2341 question, i18n("Ok")) ;
2336 } 2342 }
2337 delete calendar; 2343 delete calendar;
2338 updateView(); 2344 updateView();
2339 return syncOK; 2345 return syncOK;
2340 2346
2341 2347
2342#endif 2348#endif
2343 2349
2344} 2350}
2345 2351
2346void CalendarView::setSyncEventsReadOnly() 2352void CalendarView::setSyncEventsReadOnly()
2347{ 2353{
2348 mCalendar->setSyncEventsReadOnly(); 2354 mCalendar->setSyncEventsReadOnly();
2349} 2355}
2350 2356
2351bool CalendarView::loadCalendars() 2357bool CalendarView::loadCalendars()
2352{ 2358{
2353 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2359 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2354 KopiCalendarFile * cal = calendars.first(); 2360 KopiCalendarFile * cal = calendars.first();
2355 mCalendar->setDefaultCalendar( 1 ); 2361 mCalendar->setDefaultCalendar( 1 );
2356 openCalendar( MainWindow::defaultFileName(), false ); 2362 openCalendar( MainWindow::defaultFileName(), false );
2357 cal = calendars.next(); 2363 cal = calendars.next();
2358 while ( cal ) { 2364 while ( cal ) {
2359 addCalendar( cal ); 2365 addCalendar( cal );
2360 cal = calendars.next(); 2366 cal = calendars.next();
2361 } 2367 }
2362 restoreCalendarSettings(); 2368 restoreCalendarSettings();
2363 return true; 2369 return true;
2364} 2370}
2365bool CalendarView::restoreCalendarSettings() 2371bool CalendarView::restoreCalendarSettings()
2366{ 2372{
2367 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2373 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2368 KopiCalendarFile * cal = calendars.first(); 2374 KopiCalendarFile * cal = calendars.first();
2369 while ( cal ) { 2375 while ( cal ) {
2370 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2376 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2371 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2377 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2372 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2378 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2373 if ( cal->isStandard ) 2379 if ( cal->isStandard )
2374 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2380 mCalendar->setDefaultCalendar( cal->mCalNumber );
2375 cal = calendars.next(); 2381 cal = calendars.next();
2376 } 2382 }
2377 setSyncEventsReadOnly(); 2383 setSyncEventsReadOnly();
2378 mCalendar->reInitAlarmSettings(); 2384 mCalendar->reInitAlarmSettings();
2379 updateUnmanagedViews(); 2385 updateUnmanagedViews();
2380 updateView(); 2386 updateView();
2381 return true; 2387 return true;
2382} 2388}
2383void CalendarView::addCalendarId( int id ) 2389void CalendarView::addCalendarId( int id )
2384{ 2390{
2385 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2391 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2386 if ( cal ) 2392 if ( cal )
2387 addCalendar( cal ); 2393 addCalendar( cal );
2388} 2394}
2389bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2395bool CalendarView::addCalendar( KopiCalendarFile * cal )
2390{ 2396{
2391 cal->mErrorOnLoad = false; 2397 cal->mErrorOnLoad = false;
2392 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2398 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2393 cal->mLoadDt = QDateTime::currentDateTime(); 2399 cal->mLoadDt = QDateTime::currentDateTime();
2394 return true; 2400 return true;
2395 } 2401 }
2396 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2402 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2397 cal->mErrorOnLoad = true; 2403 cal->mErrorOnLoad = true;
2398 return false; 2404 return false;
2399} 2405}
2400bool CalendarView::openCalendar(QString filename, bool merge) 2406bool CalendarView::openCalendar(QString filename, bool merge)
2401{ 2407{
2402 2408
2403 if (filename.isEmpty()) { 2409 if (filename.isEmpty()) {
2404 return false; 2410 return false;
2405 } 2411 }
2406 2412
2407 if (!QFile::exists(filename)) { 2413 if (!QFile::exists(filename)) {
2408 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2414 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2409 return false; 2415 return false;
2410 } 2416 }
2411 2417
2412 globalFlagBlockAgenda = 1; 2418 globalFlagBlockAgenda = 1;
2413 clearAllViews(); 2419 clearAllViews();
2414 if (!merge) { 2420 if (!merge) {
2415 mViewManager->setDocumentId( filename ); 2421 mViewManager->setDocumentId( filename );
@@ -2484,159 +2490,159 @@ void CalendarView::mergeFileResource( QString fn ,QString resource )
2484 int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); 2490 int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
2485 if ( !exclusiveResource ) { 2491 if ( !exclusiveResource ) {
2486 qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() ); 2492 qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() );
2487 return; 2493 return;
2488 } 2494 }
2489 clearAllViews(); 2495 clearAllViews();
2490 mCalendar->setCalendarRemove( exclusiveResource ); 2496 mCalendar->setCalendarRemove( exclusiveResource );
2491 mCalendar->setDefaultCalendar(exclusiveResource); 2497 mCalendar->setDefaultCalendar(exclusiveResource);
2492 mCalendar->setAllCalendarEnabled( true ); 2498 mCalendar->setAllCalendarEnabled( true );
2493 if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { 2499 if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) {
2494 qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); 2500 qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() );
2495 } 2501 }
2496 restoreCalendarSettings(); 2502 restoreCalendarSettings();
2497} 2503}
2498void CalendarView::showOpenError() 2504void CalendarView::showOpenError()
2499{ 2505{
2500 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2506 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2501} 2507}
2502void CalendarView::setLoadedFileVersion(QDateTime dt) 2508void CalendarView::setLoadedFileVersion(QDateTime dt)
2503{ 2509{
2504 loadedFileVersion = dt; 2510 loadedFileVersion = dt;
2505} 2511}
2506bool CalendarView::checkFileChanged(QString fn) 2512bool CalendarView::checkFileChanged(QString fn)
2507{ 2513{
2508 QFileInfo finf ( fn ); 2514 QFileInfo finf ( fn );
2509 if ( !finf.exists() ) 2515 if ( !finf.exists() )
2510 return true; 2516 return true;
2511 QDateTime dt = finf.lastModified (); 2517 QDateTime dt = finf.lastModified ();
2512 if ( dt <= loadedFileVersion ) 2518 if ( dt <= loadedFileVersion )
2513 return false; 2519 return false;
2514 return true; 2520 return true;
2515 2521
2516} 2522}
2517void CalendarView::watchSavedFile() 2523void CalendarView::watchSavedFile()
2518{ 2524{
2519 QFileInfo finf ( MainWindow::defaultFileName()); 2525 QFileInfo finf ( MainWindow::defaultFileName());
2520 if ( !finf.exists() ) 2526 if ( !finf.exists() )
2521 return; 2527 return;
2522 QDateTime dt = finf.lastModified (); 2528 QDateTime dt = finf.lastModified ();
2523 if ( dt < loadedFileVersion ) { 2529 if ( dt < loadedFileVersion ) {
2524 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2530 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2525 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2531 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2526 return; 2532 return;
2527 } 2533 }
2528 loadedFileVersion = dt; 2534 loadedFileVersion = dt;
2529} 2535}
2530bool CalendarView::checkAllFileVersions() 2536bool CalendarView::checkAllFileVersions()
2531{ 2537{
2532 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2538 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2533 KopiCalendarFile * cal = calendars.first(); 2539 KopiCalendarFile * cal = calendars.first();
2534 mCalendar->setDefaultCalendar( 1 ); 2540 mCalendar->setDefaultCalendar( 1 );
2535 mCalendar->setDefaultCalendarEnabledOnly(); 2541 mCalendar->setDefaultCalendarEnabledOnly();
2536 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2542 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2537 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2543 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2538 restoreCalendarSettings(); 2544 restoreCalendarSettings();
2539 return false; 2545 return false;
2540 } 2546 }
2541 } 2547 }
2542 cal = calendars.next(); 2548 cal = calendars.next();
2543 QDateTime storeTemp = loadedFileVersion; 2549 QDateTime storeTemp = loadedFileVersion;
2544 while ( cal ) { 2550 while ( cal ) {
2545 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2551 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2546 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2552 mCalendar->setDefaultCalendar( cal->mCalNumber );
2547 mCalendar->setDefaultCalendarEnabledOnly(); 2553 mCalendar->setDefaultCalendarEnabledOnly();
2548 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2554 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2549 if ( !checkFileVersion(cal->mFileName )) { 2555 if ( !checkFileVersion(cal->mFileName )) {
2550 loadedFileVersion = storeTemp; 2556 loadedFileVersion = storeTemp;
2551 restoreCalendarSettings(); 2557 restoreCalendarSettings();
2552 return false; 2558 return false;
2553 } 2559 }
2554 } 2560 }
2555 cal = calendars.next(); 2561 cal = calendars.next();
2556 } 2562 }
2557 loadedFileVersion = storeTemp; 2563 loadedFileVersion = storeTemp;
2558 return true; 2564 return true;
2559} 2565}
2560bool CalendarView::checkFileVersion(QString fn) 2566bool CalendarView::checkFileVersion(QString fn)
2561{ 2567{
2562 QFileInfo finf ( fn ); 2568 QFileInfo finf ( fn );
2563 if ( !finf.exists() ) 2569 if ( !finf.exists() )
2564 return true; 2570 return true;
2565 QDateTime dt = finf.lastModified (); 2571 QDateTime dt = finf.lastModified ();
2566 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2572 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2567 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2573 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2568 if ( dt <= loadedFileVersion ) 2574 if ( dt <= loadedFileVersion )
2569 return true; 2575 return true;
2570 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2576 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2571 i18n("KO/Pi Warning"),i18n("Overwrite"), 2577 i18n("KO/Pi Warning"),i18n("Overwrite"),
2572 i18n("Sync+save")); 2578 i18n("Sync+save"));
2573 2579
2574 if ( km == KMessageBox::Cancel ) 2580 if ( km == KMessageBox::Cancel )
2575 return false; 2581 return false;
2576 if ( km == KMessageBox::Yes ) 2582 if ( km == KMessageBox::Yes )
2577 return true; 2583 return true;
2578 2584
2579 setSyncDevice("deleteaftersync" ); 2585 setSyncDevice("deleteaftersync" );
2580 mSyncManager->mAskForPreferences = true; 2586 mSyncManager->mAskForPreferences = true;
2581 mSyncManager->mSyncAlgoPrefs = 3; 2587 mSyncManager->mSyncAlgoPrefs = 3;
2582 mSyncManager->mWriteBackFile = false; 2588 mSyncManager->mWriteBackFile = false;
2583 mSyncManager->mWriteBackExistingOnly = false; 2589 mSyncManager->mWriteBackExistingOnly = false;
2584 mSyncManager->mShowSyncSummary = false; 2590 mSyncManager->mShowSyncSummary = false;
2585 mMultiResourceSync = false; 2591 mMultiResourceSync = false;
2586 syncCalendar( fn, 3 ); 2592 syncCalendar( fn, 3 );
2587 Event * e = getLastSyncEvent(); 2593 Event * e = getLastSyncEvent();
2588 if ( e ) 2594 if ( e )
2589 mCalendar->deleteEvent( e ); 2595 mCalendar->deleteEvent( e );
2590 return true; 2596 return true;
2591} 2597}
2592bool CalendarView::saveCalendars() 2598bool CalendarView::saveCalendars()
2593{ 2599{
2594 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2600 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2595 KopiCalendarFile * cal = calendars.first(); 2601 KopiCalendarFile * cal = calendars.first();
2596 mCalendar->setDefaultCalendar( 1 ); 2602 mCalendar->setDefaultCalendar( 1 );
2597 mCalendar->setDefaultCalendarEnabledOnly(); 2603 mCalendar->setDefaultCalendarEnabledOnly();
2598 QString saveError; 2604 QString saveError;
2599 if ( !saveCalendar( MainWindow::defaultFileName() ) ) 2605 if ( !saveCalendar( MainWindow::defaultFileName() ) )
2600 saveError = cal->mName +"\n"; 2606 saveError = cal->mName +"\n";
2601 cal = calendars.next(); 2607 cal = calendars.next();
2602 while ( cal ) { 2608 while ( cal ) {
2603 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2609 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2604 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2610 mCalendar->setDefaultCalendar( cal->mCalNumber );
2605 mCalendar->setDefaultCalendarEnabledOnly(); 2611 mCalendar->setDefaultCalendarEnabledOnly();
2606 if ( saveCalendar( cal->mFileName ) ) 2612 if ( saveCalendar( cal->mFileName ) )
2607 cal->mLoadDt = QDateTime::currentDateTime(); 2613 cal->mLoadDt = QDateTime::currentDateTime();
2608 else 2614 else
2609 saveError += cal->mName + "\n"; 2615 saveError += cal->mName + "\n";
2610 } 2616 }
2611 cal = calendars.next(); 2617 cal = calendars.next();
2612 } 2618 }
2613 restoreCalendarSettings(); 2619 restoreCalendarSettings();
2614 //saveError = "test error"; 2620 //saveError = "test error";
2615 if ( !saveError.isEmpty() ) { 2621 if ( !saveError.isEmpty() ) {
2616 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; 2622 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
2617 KMessageBox::error(this, saveError, i18n("Error saving data")); 2623 KMessageBox::error(this, saveError, i18n("Error saving data"));
2618 return false; 2624 return false;
2619 } 2625 }
2620 return true; 2626 return true;
2621} 2627}
2622bool CalendarView::saveCalendarResource(QString filename, QString resource) 2628bool CalendarView::saveCalendarResource(QString filename, QString resource)
2623{ 2629{
2624 if ( resource == "ALL" ) { 2630 if ( resource == "ALL" ) {
2625 mCalendar->setAllCalendarEnabled( true ); 2631 mCalendar->setAllCalendarEnabled( true );
2626 bool retval = saveCalendar( filename ); 2632 bool retval = saveCalendar( filename );
2627 restoreCalendarSettings(); 2633 restoreCalendarSettings();
2628 return retval; 2634 return retval;
2629 } 2635 }
2630 int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); 2636 int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
2631 if ( !exclusiveResource ) { 2637 if ( !exclusiveResource ) {
2632 qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() ); 2638 qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() );
2633 return false; 2639 return false;
2634 } 2640 }
2635 mCalendar->setDefaultCalendar( exclusiveResource ); 2641 mCalendar->setDefaultCalendar( exclusiveResource );
2636 mCalendar->setDefaultCalendarEnabledOnly(); 2642 mCalendar->setDefaultCalendarEnabledOnly();
2637 mCalendar->setSyncEventsEnabled(); 2643 mCalendar->setSyncEventsEnabled();
2638 bool res = saveCalendar( filename ); 2644 bool res = saveCalendar( filename );
2639 restoreCalendarSettings(); 2645 restoreCalendarSettings();
2640 return res; 2646 return res;
2641 2647
2642} 2648}
@@ -2650,273 +2656,273 @@ bool CalendarView::saveCalendar( QString filename )
2650 2656
2651 2657
2652 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2658 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2653 mStorage->setSaveFormat( new ICalFormat() ); 2659 mStorage->setSaveFormat( new ICalFormat() );
2654 mStorage->setFileName( filename ); 2660 mStorage->setFileName( filename );
2655 bool success; 2661 bool success;
2656 success = mStorage->save(); 2662 success = mStorage->save();
2657 if ( !success ) { 2663 if ( !success ) {
2658 return false; 2664 return false;
2659 } 2665 }
2660 if ( filename == MainWindow::defaultFileName() ) { 2666 if ( filename == MainWindow::defaultFileName() ) {
2661 setLoadedFileVersion( lfv ); 2667 setLoadedFileVersion( lfv );
2662 watchSavedFile(); 2668 watchSavedFile();
2663 } 2669 }
2664 return true; 2670 return true;
2665} 2671}
2666 2672
2667void CalendarView::closeCalendar() 2673void CalendarView::closeCalendar()
2668{ 2674{
2669 2675
2670 // child windows no longer valid 2676 // child windows no longer valid
2671 clearAllViews(); 2677 clearAllViews();
2672 emit closingDown(); 2678 emit closingDown();
2673 2679
2674 mCalendar->close(); 2680 mCalendar->close();
2675 setModified(false); 2681 setModified(false);
2676 updateView(); 2682 updateView();
2677} 2683}
2678 2684
2679void CalendarView::archiveCalendar() 2685void CalendarView::archiveCalendar()
2680{ 2686{
2681 mDialogManager->showArchiveDialog(); 2687 mDialogManager->showArchiveDialog();
2682} 2688}
2683 2689
2684 2690
2685void CalendarView::readSettings() 2691void CalendarView::readSettings()
2686{ 2692{
2687 2693
2688 2694
2689 // mViewManager->showAgendaView(); 2695 // mViewManager->showAgendaView();
2690 QString str; 2696 QString str;
2691 //qDebug("CalendarView::readSettings() "); 2697 //qDebug("CalendarView::readSettings() ");
2692 // read settings from the KConfig, supplying reasonable 2698 // read settings from the KConfig, supplying reasonable
2693 // defaults where none are to be found 2699 // defaults where none are to be found
2694 KConfig *config = KOGlobals::config(); 2700 KConfig *config = KOGlobals::config();
2695#ifndef KORG_NOSPLITTER 2701#ifndef KORG_NOSPLITTER
2696 config->setGroup("KOrganizer Geometry"); 2702 config->setGroup("KOrganizer Geometry");
2697 2703
2698 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2704 Q3ValueList<int> sizes = config->readIntListEntry("Separator1");
2699 if (sizes.count() != 2) { 2705 if (sizes.count() != 2) {
2700 sizes << mDateNavigator->minimumSizeHint().width(); 2706 sizes << mDateNavigator->minimumSizeHint().width();
2701 sizes << 300; 2707 sizes << 300;
2702 } 2708 }
2703 mPanner->setSizes(sizes); 2709 mPanner->setSizes(sizes);
2704 2710
2705 sizes = config->readIntListEntry("Separator2"); 2711 sizes = config->readIntListEntry("Separator2");
2706 if ( ( mResourceView && sizes.count() == 4 ) || 2712 if ( ( mResourceView && sizes.count() == 4 ) ||
2707 ( !mResourceView && sizes.count() == 3 ) ) { 2713 ( !mResourceView && sizes.count() == 3 ) ) {
2708 mLeftSplitter->setSizes(sizes); 2714 mLeftSplitter->setSizes(sizes);
2709 } 2715 }
2710#endif 2716#endif
2711 globalFlagBlockAgenda = 1; 2717 globalFlagBlockAgenda = 1;
2712 mViewManager->showAgendaView(); 2718 mViewManager->showAgendaView();
2713 //mViewManager->readSettings( config ); 2719 //mViewManager->readSettings( config );
2714 mTodoList->restoreLayout(config,QString("Todo Layout")); 2720 mTodoList->restoreLayout(config,QString("Todo Layout"));
2715 readFilterSettings(config); 2721 readFilterSettings(config);
2716 2722
2717#ifdef DESKTOP_VERSION 2723#ifdef DESKTOP_VERSION
2718 config->setGroup("WidgetLayout"); 2724 config->setGroup("WidgetLayout");
2719 QStringList list; 2725 QStringList list;
2720 list = config->readListEntry("MainLayout"); 2726 list = config->readListEntry("MainLayout");
2721 int x,y,w,h; 2727 int x,y,w,h;
2722 if ( ! list.isEmpty() ) { 2728 if ( ! list.isEmpty() ) {
2723 x = list[0].toInt(); 2729 x = list[0].toInt();
2724 y = list[1].toInt(); 2730 y = list[1].toInt();
2725 w = list[2].toInt(); 2731 w = list[2].toInt();
2726 h = list[3].toInt(); 2732 h = list[3].toInt();
2727 KApplication::testCoords( &x,&y,&w,&h ); 2733 KApplication::testCoords( &x,&y,&w,&h );
2728 topLevelWidget()->setGeometry(x,y,w,h); 2734 topLevelWidget()->setGeometry(x,y,w,h);
2729 2735
2730 } else { 2736 } else {
2731 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2737 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2732 } 2738 }
2733 list = config->readListEntry("EditEventLayout"); 2739 list = config->readListEntry("EditEventLayout");
2734 if ( ! list.isEmpty() ) { 2740 if ( ! list.isEmpty() ) {
2735 x = list[0].toInt(); 2741 x = list[0].toInt();
2736 y = list[1].toInt(); 2742 y = list[1].toInt();
2737 w = list[2].toInt(); 2743 w = list[2].toInt();
2738 h = list[3].toInt(); 2744 h = list[3].toInt();
2739 KApplication::testCoords( &x,&y,&w,&h ); 2745 KApplication::testCoords( &x,&y,&w,&h );
2740 mEventEditor->setGeometry(x,y,w,h); 2746 mEventEditor->setGeometry(x,y,w,h);
2741 2747
2742 } 2748 }
2743 list = config->readListEntry("EditTodoLayout"); 2749 list = config->readListEntry("EditTodoLayout");
2744 if ( ! list.isEmpty() ) { 2750 if ( ! list.isEmpty() ) {
2745 x = list[0].toInt(); 2751 x = list[0].toInt();
2746 y = list[1].toInt(); 2752 y = list[1].toInt();
2747 w = list[2].toInt(); 2753 w = list[2].toInt();
2748 h = list[3].toInt(); 2754 h = list[3].toInt();
2749 KApplication::testCoords( &x,&y,&w,&h ); 2755 KApplication::testCoords( &x,&y,&w,&h );
2750 mTodoEditor->setGeometry(x,y,w,h); 2756 mTodoEditor->setGeometry(x,y,w,h);
2751 2757
2752 } 2758 }
2753 list = config->readListEntry("ViewerLayout"); 2759 list = config->readListEntry("ViewerLayout");
2754 if ( ! list.isEmpty() ) { 2760 if ( ! list.isEmpty() ) {
2755 x = list[0].toInt(); 2761 x = list[0].toInt();
2756 y = list[1].toInt(); 2762 y = list[1].toInt();
2757 w = list[2].toInt(); 2763 w = list[2].toInt();
2758 h = list[3].toInt(); 2764 h = list[3].toInt();
2759 KApplication::testCoords( &x,&y,&w,&h ); 2765 KApplication::testCoords( &x,&y,&w,&h );
2760 getEventViewerDialog()->setGeometry(x,y,w,h); 2766 getEventViewerDialog()->setGeometry(x,y,w,h);
2761 } 2767 }
2762#endif 2768#endif
2763 config->setGroup( "Views" ); 2769 config->setGroup( "Views" );
2764 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2770 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2765 2771
2766 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2772 Q3ValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2767 2773
2768 int resetval = 0; 2774 int resetval = 0;
2769 int maxVal = 0; 2775 int maxVal = 0;
2770 if (sizes.count() != 3) { 2776 if (sizes.count() != 3) {
2771 if ( KOPrefs::instance()->mVerticalScreen ) { 2777 if ( KOPrefs::instance()->mVerticalScreen ) {
2772 resetval = mDateNavigator->sizeHint().width()+2; 2778 resetval = mDateNavigator->sizeHint().width()+2;
2773 } else { 2779 } else {
2774 resetval = mDateNavigator->sizeHint().height()+2; 2780 resetval = mDateNavigator->sizeHint().height()+2;
2775 } 2781 }
2776 } 2782 }
2777 if ( resetval ) { 2783 if ( resetval ) {
2778 sizes.clear(); 2784 sizes.clear();
2779 if ( KOPrefs::instance()->mVerticalScreen ) { 2785 if ( KOPrefs::instance()->mVerticalScreen ) {
2780 maxVal = QApplication::desktop()->width() -10; 2786 maxVal = QApplication::desktop()->width() -10;
2781 } else { 2787 } else {
2782 maxVal = QApplication::desktop()->height()-10; 2788 maxVal = QApplication::desktop()->height()-10;
2783 } 2789 }
2784 sizes << resetval; 2790 sizes << resetval;
2785 if ( maxVal < resetval + resetval) 2791 if ( maxVal < resetval + resetval)
2786 resetval = maxVal - resetval; 2792 resetval = maxVal - resetval;
2787 sizes << resetval; 2793 sizes << resetval;
2788 sizes << 100; 2794 sizes << 100;
2789 } 2795 }
2790 mLeftFrame->setSizes(sizes); 2796 mLeftFrame->setSizes(sizes);
2791 sizes = config->readIntListEntry("Main Splitter Frame"); 2797 sizes = config->readIntListEntry("Main Splitter Frame");
2792 resetval = 0; 2798 resetval = 0;
2793 maxVal = 0; 2799 maxVal = 0;
2794 if (sizes.count() != 2) { 2800 if (sizes.count() != 2) {
2795 if ( !KOPrefs::instance()->mVerticalScreen ) { 2801 if ( !KOPrefs::instance()->mVerticalScreen ) {
2796 resetval = mDateNavigator->sizeHint().width()+2; 2802 resetval = mDateNavigator->sizeHint().width()+2;
2797 } else { 2803 } else {
2798 resetval = mDateNavigator->sizeHint().height()+2; 2804 resetval = mDateNavigator->sizeHint().height()+2;
2799 } 2805 }
2800 } 2806 }
2801 if ( resetval ) { 2807 if ( resetval ) {
2802 sizes.clear(); 2808 sizes.clear();
2803 if ( !KOPrefs::instance()->mVerticalScreen ) { 2809 if ( !KOPrefs::instance()->mVerticalScreen ) {
2804 maxVal = QApplication::desktop()->width() -10; 2810 maxVal = QApplication::desktop()->width() -10;
2805 } else { 2811 } else {
2806 maxVal = QApplication::desktop()->height()-10; 2812 maxVal = QApplication::desktop()->height()-10;
2807 } 2813 }
2808 sizes << resetval; 2814 sizes << resetval;
2809 if ( maxVal < resetval + resetval) 2815 if ( maxVal < resetval + resetval)
2810 resetval = maxVal - resetval; 2816 resetval = maxVal - resetval;
2811 sizes << resetval; 2817 sizes << resetval;
2812 } 2818 }
2813 mMainFrame->setSizes(sizes); 2819 mMainFrame->setSizes(sizes);
2814 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2820 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2815 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2821 else if ( dateCount == 7 ) mNavigator->selectWeek();
2816 else mNavigator->selectDates( dateCount ); 2822 else mNavigator->selectDates( dateCount );
2817 // mViewManager->readSettings( config ); 2823 // mViewManager->readSettings( config );
2818 updateConfig(); 2824 updateConfig();
2819 globalFlagBlockAgenda = 2; 2825 globalFlagBlockAgenda = 2;
2820 mViewManager->readSettings( config ); 2826 mViewManager->readSettings( config );
2821 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2827 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2822} 2828}
2823 2829
2824void CalendarView::checkSuspendAlarm() 2830void CalendarView::checkSuspendAlarm()
2825{ 2831{
2826 if ( mSuspendTimer->isActive() ) { 2832 if ( mSuspendTimer->isActive() ) {
2827 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2833 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2828 } 2834 }
2829} 2835}
2830void CalendarView::writeSettings() 2836void CalendarView::writeSettings()
2831{ 2837{
2832 // kdDebug() << "CalendarView::writeSettings" << endl; 2838 // kdDebug() << "CalendarView::writeSettings" << endl;
2833 2839
2834 KConfig *config = KOGlobals::config(); 2840 KConfig *config = KOGlobals::config();
2835 2841
2836 mViewManager->writeSettings( config ); 2842 mViewManager->writeSettings( config );
2837 mTodoList->saveLayout(config,QString("Todo Layout")); 2843 mTodoList->saveLayout(config,QString("Todo Layout"));
2838 mDialogManager->writeSettings( config ); 2844 mDialogManager->writeSettings( config );
2839 //KOPrefs::instance()->usrWriteConfig(); 2845 //KOPrefs::instance()->usrWriteConfig();
2840 KOPrefs::instance()->writeConfig(); 2846 KOPrefs::instance()->writeConfig();
2841 2847
2842 writeFilterSettings(config); 2848 writeFilterSettings(config);
2843 config->setGroup( "AppRun" ); 2849 config->setGroup( "AppRun" );
2844 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2850 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2845 int days = dt.daysTo( QDate::currentDate() ); 2851 int days = dt.daysTo( (QDateTime)QDate::currentDate() );
2846 dt = dt.addDays( days ); 2852 dt = dt.addDays( days );
2847 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2853 int secs = dt.secsTo( QDateTime::currentDateTime() );
2848 config->writeEntry( "LatestProgramStopDays", days ); 2854 config->writeEntry( "LatestProgramStopDays", days );
2849 config->writeEntry( "LatestProgramStopSecs", secs ); 2855 config->writeEntry( "LatestProgramStopSecs", secs );
2850 //qDebug("KO: Writing stop time: %d ", secs); 2856 //qDebug("KO: Writing stop time: %d ", secs);
2851 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2857 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2852 //QDateTime latest = dt.addSecs ( secs ); 2858 //QDateTime latest = dt.addSecs ( secs );
2853 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2859 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2854 config->setGroup( "Views" ); 2860 config->setGroup( "Views" );
2855 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2861 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2856 2862
2857#if 0 2863#if 0
2858 qDebug("********************* "); 2864 qDebug("********************* ");
2859 qDebug("Testcode secsto "); 2865 qDebug("Testcode secsto ");
2860 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2866 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2861 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2867 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2862 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2868 int secsto = dt_nodaylight.secsTo( dt_daylight );
2863 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2869 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2864 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2870 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2865 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2871 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2866 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2872 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2867 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2873 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2868 qDebug("********************* testcode end"); 2874 qDebug("********************* testcode end");
2869 2875
2870#endif 2876#endif
2871 2877
2872 QValueList<int> listINT = mLeftFrame->sizes(); 2878 Q3ValueList<int> listINT = mLeftFrame->sizes();
2873 config->writeEntry("Left Splitter Frame",listINT); 2879 config->writeEntry("Left Splitter Frame",listINT);
2874 QValueList<int> listINT2 = mMainFrame->sizes(); 2880 Q3ValueList<int> listINT2 = mMainFrame->sizes();
2875 config->writeEntry("Main Splitter Frame",listINT2); 2881 config->writeEntry("Main Splitter Frame",listINT2);
2876#ifdef DESKTOP_VERSION 2882#ifdef DESKTOP_VERSION
2877 config->setGroup("WidgetLayout"); 2883 config->setGroup("WidgetLayout");
2878 QStringList list ;//= config->readListEntry("MainLayout"); 2884 QStringList list ;//= config->readListEntry("MainLayout");
2879 int x,y,w,h; 2885 int x,y,w,h;
2880 QWidget* wid; 2886 QWidget* wid;
2881 wid = topLevelWidget(); 2887 wid = topLevelWidget();
2882 x = wid->geometry().x(); 2888 x = wid->geometry().x();
2883 y = wid->geometry().y(); 2889 y = wid->geometry().y();
2884 w = wid->width(); 2890 w = wid->width();
2885 h = wid->height(); 2891 h = wid->height();
2886 list.clear(); 2892 list.clear();
2887 list << QString::number( x ); 2893 list << QString::number( x );
2888 list << QString::number( y ); 2894 list << QString::number( y );
2889 list << QString::number( w ); 2895 list << QString::number( w );
2890 list << QString::number( h ); 2896 list << QString::number( h );
2891 config->writeEntry("MainLayout",list ); 2897 config->writeEntry("MainLayout",list );
2892 2898
2893 wid = mEventEditor; 2899 wid = mEventEditor;
2894 x = wid->geometry().x(); 2900 x = wid->geometry().x();
2895 y = wid->geometry().y(); 2901 y = wid->geometry().y();
2896 w = wid->width(); 2902 w = wid->width();
2897 h = wid->height(); 2903 h = wid->height();
2898 list.clear(); 2904 list.clear();
2899 list << QString::number( x ); 2905 list << QString::number( x );
2900 list << QString::number( y ); 2906 list << QString::number( y );
2901 list << QString::number( w ); 2907 list << QString::number( w );
2902 list << QString::number( h ); 2908 list << QString::number( h );
2903 config->writeEntry("EditEventLayout",list ); 2909 config->writeEntry("EditEventLayout",list );
2904 2910
2905 wid = mTodoEditor; 2911 wid = mTodoEditor;
2906 x = wid->geometry().x(); 2912 x = wid->geometry().x();
2907 y = wid->geometry().y(); 2913 y = wid->geometry().y();
2908 w = wid->width(); 2914 w = wid->width();
2909 h = wid->height(); 2915 h = wid->height();
2910 list.clear(); 2916 list.clear();
2911 list << QString::number( x ); 2917 list << QString::number( x );
2912 list << QString::number( y ); 2918 list << QString::number( y );
2913 list << QString::number( w ); 2919 list << QString::number( w );
2914 list << QString::number( h ); 2920 list << QString::number( h );
2915 config->writeEntry("EditTodoLayout",list ); 2921 config->writeEntry("EditTodoLayout",list );
2916 wid = getEventViewerDialog(); 2922 wid = getEventViewerDialog();
2917 x = wid->geometry().x(); 2923 x = wid->geometry().x();
2918 y = wid->geometry().y(); 2924 y = wid->geometry().y();
2919 w = wid->width(); 2925 w = wid->width();
2920 h = wid->height(); 2926 h = wid->height();
2921 list.clear(); 2927 list.clear();
2922 list << QString::number( x ); 2928 list << QString::number( x );
@@ -3121,97 +3127,97 @@ void CalendarView::changeEventDisplay(Event *which, int action)
3121#ifdef DESKTOP_VERSION 3127#ifdef DESKTOP_VERSION
3122 time = 500; 3128 time = 500;
3123#endif 3129#endif
3124 bool checkC = false; 3130 bool checkC = false;
3125 if ( mConflictingEvent->doesFloat() ) { 3131 if ( mConflictingEvent->doesFloat() ) {
3126 checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay 3132 checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay
3127 || KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3133 || KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3128 } else { 3134 } else {
3129 checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay 3135 checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay
3130 || KOPrefs::instance()->mCheckConflictsNonADNonAD; 3136 || KOPrefs::instance()->mCheckConflictsNonADNonAD;
3131 } 3137 }
3132 if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) 3138 if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent )
3133 checkC = false; 3139 checkC = false;
3134 if ( checkC ) 3140 if ( checkC )
3135 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); 3141 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) );
3136 } 3142 }
3137 // } 3143 // }
3138 } else { 3144 } else {
3139 mViewManager->currentView()->updateView(); 3145 mViewManager->currentView()->updateView();
3140 } 3146 }
3141} 3147}
3142void CalendarView::checkConflictForEvent() 3148void CalendarView::checkConflictForEvent()
3143{ 3149{
3144 3150
3145 if (!KOPrefs::instance()->mConfirm) 3151 if (!KOPrefs::instance()->mConfirm)
3146 return; 3152 return;
3147 if ( ! mConflictingEvent ) return; 3153 if ( ! mConflictingEvent ) return;
3148 Event * conflictingEvent = mConflictingEvent; 3154 Event * conflictingEvent = mConflictingEvent;
3149 mConflictingEvent = 0; 3155 mConflictingEvent = 0;
3150 QDateTime current = QDateTime::currentDateTime(); 3156 QDateTime current = QDateTime::currentDateTime();
3151 if ( ! conflictingEvent->matchTime( &current, 0 ) ) { 3157 if ( ! conflictingEvent->matchTime( &current, 0 ) ) {
3152 return; 3158 return;
3153 } 3159 }
3154 CalFilter *filterIN = 0; 3160 CalFilter *filterIN = 0;
3155 CalFilter *filterALL = 0; 3161 CalFilter *filterALL = 0;
3156 CalFilter *filter = mFilters.first(); 3162 CalFilter *filter = mFilters.first();
3157 while(filter) { 3163 while(filter) {
3158 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) 3164 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem)
3159 filterIN = filter; 3165 filterIN = filter;
3160 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) 3166 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem )
3161 filterALL = filter; 3167 filterALL = filter;
3162 filter = mFilters.next(); 3168 filter = mFilters.next();
3163 } 3169 }
3164 if ( filterIN ) { 3170 if ( filterIN ) {
3165 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { 3171 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) {
3166 return; 3172 return;
3167 } 3173 }
3168 } 3174 }
3169 QPtrList<Event> testlist = mCalendar->events(); 3175 Q3PtrList<Event> testlist = mCalendar->events();
3170 Event * test = testlist.first(); 3176 Event * test = testlist.first();
3171 QDateTime conflict; 3177 QDateTime conflict;
3172 QDateTime retVal; 3178 QDateTime retVal;
3173 bool found = false; 3179 bool found = false;
3174 Event * cE = 0; 3180 Event * cE = 0;
3175 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; 3181 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay;
3176 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3182 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3177 if ( !conflictingEvent->doesFloat() ) { 3183 if ( !conflictingEvent->doesFloat() ) {
3178 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; 3184 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay;
3179 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; 3185 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD;
3180 } 3186 }
3181 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 3187 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
3182 while ( test ) { 3188 while ( test ) {
3183 qApp->processEvents(); 3189 qApp->processEvents();
3184 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); 3190 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad );
3185 3191
3186 if ( !skip ) { 3192 if ( !skip ) {
3187 if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) 3193 if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent )
3188 skip = true; 3194 skip = true;
3189 } 3195 }
3190 if ( !skip ) { 3196 if ( !skip ) {
3191 if ( filterALL ) { 3197 if ( filterALL ) {
3192 if ( !filterALL->filterCalendarItem( test ) ) { 3198 if ( !filterALL->filterCalendarItem( test ) ) {
3193 skip = true; 3199 skip = true;
3194 } 3200 }
3195 } 3201 }
3196 if ( !skip ) { 3202 if ( !skip ) {
3197 if ( found ) 3203 if ( found )
3198 skip = !test->matchTime( &current, &conflict ); 3204 skip = !test->matchTime( &current, &conflict );
3199 else 3205 else
3200 skip = !test->matchTime( &current, 0 ); 3206 skip = !test->matchTime( &current, 0 );
3201 if ( !skip ) { 3207 if ( !skip ) {
3202 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 3208 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
3203 if ( ! found ) { 3209 if ( ! found ) {
3204 conflict = retVal; 3210 conflict = retVal;
3205 cE = test; 3211 cE = test;
3206 } else { 3212 } else {
3207 if ( retVal < conflict ) { 3213 if ( retVal < conflict ) {
3208 conflict = retVal; 3214 conflict = retVal;
3209 cE = test; 3215 cE = test;
3210 } 3216 }
3211 } 3217 }
3212 found = true; 3218 found = true;
3213 } 3219 }
3214 } 3220 }
3215 } 3221 }
3216 } 3222 }
3217 test = testlist.next(); 3223 test = testlist.next();
@@ -3383,192 +3389,192 @@ void CalendarView::slotSelectPickerDate( QDate d)
3383 tim = QTime ( 0,0,0 ); 3389 tim = QTime ( 0,0,0 );
3384 to->setFloats( true ); 3390 to->setFloats( true );
3385 to->setHasDueDate( true ); 3391 to->setHasDueDate( true );
3386 } 3392 }
3387 QDateTime dt ( d,tim ); 3393 QDateTime dt ( d,tim );
3388 to->setDtDue( dt ); 3394 to->setDtDue( dt );
3389 3395
3390 if ( to->hasStartDate() ) { 3396 if ( to->hasStartDate() ) {
3391 if ( len>0 ) 3397 if ( len>0 )
3392 to->setDtStart(to->dtDue().addSecs( -len )); 3398 to->setDtStart(to->dtDue().addSecs( -len ));
3393 else 3399 else
3394 if (to->dtStart() > to->dtDue() ) 3400 if (to->dtStart() > to->dtDue() )
3395 to->setDtStart(to->dtDue().addDays( -3 )); 3401 to->setDtStart(to->dtDue().addDays( -3 ));
3396 } 3402 }
3397 3403
3398 todoChanged( to ); 3404 todoChanged( to );
3399 } else if ( mMoveIncidence->typeID() == eventID ) { 3405 } else if ( mMoveIncidence->typeID() == eventID ) {
3400 if ( mMoveIncidence->doesRecur() ) { 3406 if ( mMoveIncidence->doesRecur() ) {
3401#if 0 3407#if 0
3402 // PENDING implement this 3408 // PENDING implement this
3403 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 3409 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
3404 mCalendar()->addIncidence( newInc ); 3410 mCalendar()->addIncidence( newInc );
3405 if ( mMoveIncidence->typeID() == todoID ) 3411 if ( mMoveIncidence->typeID() == todoID )
3406 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 3412 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
3407 else 3413 else
3408 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 3414 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
3409 mMoveIncidence = newInc; 3415 mMoveIncidence = newInc;
3410 3416
3411#endif 3417#endif
3412 } 3418 }
3413 QTime tim = mMoveIncidence->dtStart().time(); 3419 QTime tim = mMoveIncidence->dtStart().time();
3414 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 3420 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
3415 QDateTime dt ( d,tim ); 3421 QDateTime dt ( d,tim );
3416 mMoveIncidence->setDtStart( dt ); 3422 mMoveIncidence->setDtStart( dt );
3417 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 3423 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
3418 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 3424 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
3419 } else if ( mMoveIncidence->typeID() == journalID ) { 3425 } else if ( mMoveIncidence->typeID() == journalID ) {
3420 QTime tim = mMoveIncidence->dtStart().time(); 3426 QTime tim = mMoveIncidence->dtStart().time();
3421 QDateTime dt ( d,tim ); 3427 QDateTime dt ( d,tim );
3422 mMoveIncidence->setDtStart( dt ); 3428 mMoveIncidence->setDtStart( dt );
3423 updateView(); 3429 updateView();
3424 } 3430 }
3425 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 3431 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
3426 } 3432 }
3427} 3433}
3428 3434
3429void CalendarView::removeCategories() 3435void CalendarView::removeCategories()
3430{ 3436{
3431 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3437 Q3PtrList<Incidence> incList = mCalendar->rawIncidences();
3432 QStringList catList = KOPrefs::instance()->mCustomCategories; 3438 QStringList catList = KOPrefs::instance()->mCustomCategories;
3433 QStringList catIncList; 3439 QStringList catIncList;
3434 QStringList newCatList; 3440 QStringList newCatList;
3435 Incidence* inc = incList.first(); 3441 Incidence* inc = incList.first();
3436 uint i; 3442 uint i;
3437 while ( inc ) { 3443 while ( inc ) {
3438 newCatList.clear(); 3444 newCatList.clear();
3439 catIncList = inc->categories() ; 3445 catIncList = inc->categories() ;
3440 for( i = 0; i< catIncList.count(); ++i ) { 3446 for( i = 0; i< catIncList.count(); ++i ) {
3441 if ( catList.contains (catIncList[i])) 3447 if ( catList.contains (catIncList[i]))
3442 newCatList.append( catIncList[i] ); 3448 newCatList.append( catIncList[i] );
3443 } 3449 }
3444 newCatList.sort(); 3450 newCatList.sort();
3445 inc->setCategories( newCatList.join(",") ); 3451 inc->setCategories( newCatList.join(",") );
3446 inc = incList.next(); 3452 inc = incList.next();
3447 } 3453 }
3448} 3454}
3449 3455
3450int CalendarView::addCategories() 3456int CalendarView::addCategories()
3451{ 3457{
3452 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3458 Q3PtrList<Incidence> incList = mCalendar->rawIncidences();
3453 QStringList catList = KOPrefs::instance()->mCustomCategories; 3459 QStringList catList = KOPrefs::instance()->mCustomCategories;
3454 QStringList catIncList; 3460 QStringList catIncList;
3455 Incidence* inc = incList.first(); 3461 Incidence* inc = incList.first();
3456 uint i; 3462 uint i;
3457 int count = 0; 3463 int count = 0;
3458 while ( inc ) { 3464 while ( inc ) {
3459 catIncList = inc->categories() ; 3465 catIncList = inc->categories() ;
3460 for( i = 0; i< catIncList.count(); ++i ) { 3466 for( i = 0; i< catIncList.count(); ++i ) {
3461 if ( !catList.contains (catIncList[i])) { 3467 if ( !catList.contains (catIncList[i])) {
3462 catList.append( catIncList[i] ); 3468 catList.append( catIncList[i] );
3463 //qDebug("add cat %s ", catIncList[i].latin1()); 3469 //qDebug("add cat %s ", catIncList[i].latin1());
3464 ++count; 3470 ++count;
3465 } 3471 }
3466 } 3472 }
3467 inc = incList.next(); 3473 inc = incList.next();
3468 } 3474 }
3469 catList.sort(); 3475 catList.sort();
3470 KOPrefs::instance()->mCustomCategories = catList; 3476 KOPrefs::instance()->mCustomCategories = catList;
3471 return count; 3477 return count;
3472} 3478}
3473 3479
3474void CalendarView::editCategories() 3480void CalendarView::editCategories()
3475{ 3481{
3476 qDebug("CalendarView::editCategories() "); 3482 qDebug("CalendarView::editCategories() ");
3477 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 3483 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
3478 ced.exec(); 3484 ced.exec();
3479} 3485}
3480void CalendarView::manageCategories() 3486void CalendarView::manageCategories()
3481{ 3487{
3482 KOCatPrefs* cp = new KOCatPrefs(); 3488 KOCatPrefs* cp = new KOCatPrefs();
3483 cp->show(); 3489 cp->show();
3484 int w =cp->sizeHint().width() ; 3490 int w =cp->sizeHint().width() ;
3485 int h = cp->sizeHint().height() ; 3491 int h = cp->sizeHint().height() ;
3486 int dw = QApplication::desktop()->width(); 3492 int dw = QApplication::desktop()->width();
3487 int dh = QApplication::desktop()->height(); 3493 int dh = QApplication::desktop()->height();
3488 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 3494 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
3489 if ( !cp->exec() ) { 3495 if ( !cp->exec() ) {
3490 delete cp; 3496 delete cp;
3491 return; 3497 return;
3492 } 3498 }
3493 int count = 0; 3499 int count = 0;
3494 if ( cp->addCat() ) { 3500 if ( cp->addCat() ) {
3495 count = addCategories(); 3501 count = addCategories();
3496 if ( count ) { 3502 if ( count ) {
3497 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 3503 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
3498 writeSettings(); 3504 writeSettings();
3499 } else 3505 } else
3500 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 3506 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
3501 } else { 3507 } else {
3502 removeCategories(); 3508 removeCategories();
3503 updateView(); 3509 updateView();
3504 } 3510 }
3505 delete cp; 3511 delete cp;
3506} 3512}
3507 3513
3508void CalendarView::beamIncidence(Incidence * Inc) 3514void CalendarView::beamIncidence(Incidence * Inc)
3509{ 3515{
3510 QPtrList<Incidence> delSel ; 3516 Q3PtrList<Incidence> delSel ;
3511 delSel.append(Inc); 3517 delSel.append(Inc);
3512 beamIncidenceList( delSel ); 3518 beamIncidenceList( delSel );
3513} 3519}
3514void CalendarView::beamCalendar() 3520void CalendarView::beamCalendar()
3515{ 3521{
3516 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 3522 Q3PtrList<Incidence> delSel = mCalendar->rawIncidences();
3517 //qDebug("beamCalendar() "); 3523 //qDebug("beamCalendar() ");
3518 beamIncidenceList( delSel ); 3524 beamIncidenceList( delSel );
3519} 3525}
3520void CalendarView::beamFilteredCalendar() 3526void CalendarView::beamFilteredCalendar()
3521{ 3527{
3522 QPtrList<Incidence> delSel = mCalendar->incidences(); 3528 Q3PtrList<Incidence> delSel = mCalendar->incidences();
3523 //qDebug("beamFilteredCalendar() "); 3529 //qDebug("beamFilteredCalendar() ");
3524 beamIncidenceList( delSel ); 3530 beamIncidenceList( delSel );
3525} 3531}
3526void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 3532void CalendarView::beamIncidenceList(Q3PtrList<Incidence> delSel )
3527{ 3533{
3528 3534
3529 KOBeamPrefs beamDialog; 3535 KOBeamPrefs beamDialog;
3530 if ( beamDialog.exec () == QDialog::Rejected ) 3536 if ( beamDialog.exec () == QDialog::Rejected )
3531 return; 3537 return;
3532#ifdef DESKTOP_VERSION 3538#ifdef DESKTOP_VERSION
3533 QString fn = locateLocal( "tmp", "kopibeamfile" ); 3539 QString fn = locateLocal( "tmp", "kopibeamfile" );
3534#else 3540#else
3535 QString fn = "/tmp/kopibeamfile"; 3541 QString fn = "/tmp/kopibeamfile";
3536#endif 3542#endif
3537 QString mes; 3543 QString mes;
3538 bool createbup = true; 3544 bool createbup = true;
3539 if ( createbup ) { 3545 if ( createbup ) {
3540 QString description = "\n"; 3546 QString description = "\n";
3541 CalendarLocal* cal = new CalendarLocal(); 3547 CalendarLocal* cal = new CalendarLocal();
3542 if ( beamDialog.beamLocal() ) 3548 if ( beamDialog.beamLocal() )
3543 cal->setLocalTime(); 3549 cal->setLocalTime();
3544 else 3550 else
3545 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3551 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3546 Incidence *incidence = delSel.first(); 3552 Incidence *incidence = delSel.first();
3547 bool addText = false; 3553 bool addText = false;
3548 if ( delSel.count() < 10 ) 3554 if ( delSel.count() < 10 )
3549 addText = true; 3555 addText = true;
3550 else { 3556 else {
3551 description.sprintf(i18n(" %d items?"),delSel.count() ); 3557 description.sprintf(i18n(" %d items?"),delSel.count() );
3552 } 3558 }
3553 while ( incidence ) { 3559 while ( incidence ) {
3554 Incidence *in = incidence->clone(); 3560 Incidence *in = incidence->clone();
3555 if ( ! in->summary().isEmpty() ) { 3561 if ( ! in->summary().isEmpty() ) {
3556 in->setDescription(""); 3562 in->setDescription("");
3557 } else { 3563 } else {
3558 in->setSummary( in->description().left(20)); 3564 in->setSummary( in->description().left(20));
3559 in->setDescription(""); 3565 in->setDescription("");
3560 } 3566 }
3561 if ( addText ) 3567 if ( addText )
3562 description += in->summary() + "\n"; 3568 description += in->summary() + "\n";
3563 cal->addIncidence( in ); 3569 cal->addIncidence( in );
3564 incidence = delSel.next(); 3570 incidence = delSel.next();
3565 } 3571 }
3566 if ( beamDialog.beamVcal() ) { 3572 if ( beamDialog.beamVcal() ) {
3567 fn += ".vcs"; 3573 fn += ".vcs";
3568 FileStorage storage( cal, fn, new VCalFormat ); 3574 FileStorage storage( cal, fn, new VCalFormat );
3569 storage.save(); 3575 storage.save();
3570 } else { 3576 } else {
3571 fn += ".ics"; 3577 fn += ".ics";
3572 FileStorage storage( cal, fn, new ICalFormat( ) ); 3578 FileStorage storage( cal, fn, new ICalFormat( ) );
3573 storage.save(); 3579 storage.save();
3574 } 3580 }
@@ -4270,97 +4276,97 @@ void CalendarView::action_mail()
4270 4276
4271#if 0 4277#if 0
4272 Event *anEvent = 0; 4278 Event *anEvent = 0;
4273 if (mViewManager->currentView()->isEventView()) { 4279 if (mViewManager->currentView()->isEventView()) {
4274 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 4280 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
4275 } 4281 }
4276 4282
4277 if (!anEvent) { 4283 if (!anEvent) {
4278 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 4284 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
4279 return; 4285 return;
4280 } 4286 }
4281 if(anEvent->attendeeCount() == 0 ) { 4287 if(anEvent->attendeeCount() == 0 ) {
4282 KMessageBox::sorry(this, 4288 KMessageBox::sorry(this,
4283 i18n("Can't generate mail:\nNo attendees defined.\n")); 4289 i18n("Can't generate mail:\nNo attendees defined.\n"));
4284 return; 4290 return;
4285 } 4291 }
4286 4292
4287 mailobject.emailEvent(anEvent); 4293 mailobject.emailEvent(anEvent);
4288#endif 4294#endif
4289} 4295}
4290 4296
4291 4297
4292void CalendarView::schedule_publish(Incidence *incidence) 4298void CalendarView::schedule_publish(Incidence *incidence)
4293{ 4299{
4294 Event *event = 0; 4300 Event *event = 0;
4295 Todo *todo = 0; 4301 Todo *todo = 0;
4296 4302
4297 if (incidence == 0) { 4303 if (incidence == 0) {
4298 incidence = mViewManager->currentView()->selectedIncidences().first(); 4304 incidence = mViewManager->currentView()->selectedIncidences().first();
4299 if (incidence == 0) { 4305 if (incidence == 0) {
4300 incidence = mTodoList->selectedIncidences().first(); 4306 incidence = mTodoList->selectedIncidences().first();
4301 } 4307 }
4302 } 4308 }
4303 if ( incidence && incidence->typeID() == eventID ) { 4309 if ( incidence && incidence->typeID() == eventID ) {
4304 event = static_cast<Event *>(incidence); 4310 event = static_cast<Event *>(incidence);
4305 } else { 4311 } else {
4306 if ( incidence && incidence->typeID() == todoID ) { 4312 if ( incidence && incidence->typeID() == todoID ) {
4307 todo = static_cast<Todo *>(incidence); 4313 todo = static_cast<Todo *>(incidence);
4308 } 4314 }
4309 } 4315 }
4310 4316
4311 if (!event && !todo) { 4317 if (!event && !todo) {
4312 KMessageBox::sorry(this,i18n("No event selected.")); 4318 KMessageBox::sorry(this,i18n("No event selected."));
4313 return; 4319 return;
4314 } 4320 }
4315 4321
4316 PublishDialog *publishdlg = new PublishDialog(); 4322 PublishDialog *publishdlg = new PublishDialog();
4317 if (incidence->attendeeCount()>0) { 4323 if (incidence->attendeeCount()>0) {
4318 QPtrList<Attendee> attendees = incidence->attendees(); 4324 Q3PtrList<Attendee> attendees = incidence->attendees();
4319 attendees.first(); 4325 attendees.first();
4320 while ( attendees.current()!=0 ) { 4326 while ( attendees.current()!=0 ) {
4321 publishdlg->addAttendee(attendees.current()); 4327 publishdlg->addAttendee(attendees.current());
4322 attendees.next(); 4328 attendees.next();
4323 } 4329 }
4324 } 4330 }
4325 bool send = true; 4331 bool send = true;
4326 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 4332 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
4327 if ( publishdlg->exec() != QDialog::Accepted ) 4333 if ( publishdlg->exec() != QDialog::Accepted )
4328 send = false; 4334 send = false;
4329 } 4335 }
4330 if ( send ) { 4336 if ( send ) {
4331 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4337 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4332 if ( event ) { 4338 if ( event ) {
4333 Event *ev = new Event(*event); 4339 Event *ev = new Event(*event);
4334 ev->registerObserver(0); 4340 ev->registerObserver(0);
4335 ev->clearAttendees(); 4341 ev->clearAttendees();
4336 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 4342 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
4337 delete(ev); 4343 delete(ev);
4338 } 4344 }
4339 } else { 4345 } else {
4340 if ( todo ) { 4346 if ( todo ) {
4341 Todo *ev = new Todo(*todo); 4347 Todo *ev = new Todo(*todo);
4342 ev->registerObserver(0); 4348 ev->registerObserver(0);
4343 ev->clearAttendees(); 4349 ev->clearAttendees();
4344 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 4350 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
4345 delete(ev); 4351 delete(ev);
4346 } 4352 }
4347 } 4353 }
4348 } 4354 }
4349 } 4355 }
4350 delete publishdlg; 4356 delete publishdlg;
4351} 4357}
4352 4358
4353void CalendarView::schedule_request(Incidence *incidence) 4359void CalendarView::schedule_request(Incidence *incidence)
4354{ 4360{
4355 schedule(Scheduler::Request,incidence); 4361 schedule(Scheduler::Request,incidence);
4356} 4362}
4357 4363
4358void CalendarView::schedule_refresh(Incidence *incidence) 4364void CalendarView::schedule_refresh(Incidence *incidence)
4359{ 4365{
4360 schedule(Scheduler::Refresh,incidence); 4366 schedule(Scheduler::Refresh,incidence);
4361} 4367}
4362 4368
4363void CalendarView::schedule_cancel(Incidence *incidence) 4369void CalendarView::schedule_cancel(Incidence *incidence)
4364{ 4370{
4365 schedule(Scheduler::Cancel,incidence); 4371 schedule(Scheduler::Cancel,incidence);
4366} 4372}
@@ -4679,248 +4685,248 @@ void CalendarView::checkClipboard()
4679 } 4685 }
4680#endif 4686#endif
4681} 4687}
4682 4688
4683void CalendarView::showDates(const DateList &selectedDates) 4689void CalendarView::showDates(const DateList &selectedDates)
4684{ 4690{
4685 // kdDebug() << "CalendarView::selectDates()" << endl; 4691 // kdDebug() << "CalendarView::selectDates()" << endl;
4686 4692
4687 4693
4688 if ( !mBlockShowDates ) { 4694 if ( !mBlockShowDates ) {
4689 if ( mViewManager->currentView() ) { 4695 if ( mViewManager->currentView() ) {
4690 updateView( selectedDates.first(), selectedDates.last() ); 4696 updateView( selectedDates.first(), selectedDates.last() );
4691 } else { 4697 } else {
4692 mViewManager->showAgendaView(); 4698 mViewManager->showAgendaView();
4693 } 4699 }
4694 } 4700 }
4695 4701
4696 QDate date = selectedDates.first(); 4702 QDate date = selectedDates.first();
4697 if ( ! date.isValid() ) { 4703 if ( ! date.isValid() ) {
4698 topLevelWidget()->setCaption(""); 4704 topLevelWidget()->setCaption("");
4699 return; 4705 return;
4700 } 4706 }
4701 4707
4702 QString selDates; 4708 QString selDates;
4703 selDates = KGlobal::locale()->formatDate( date, true); 4709 selDates = KGlobal::locale()->formatDate( date, true);
4704 if (selectedDates.first() < selectedDates.last() ) 4710 if (selectedDates.first() < selectedDates.last() )
4705 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 4711 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
4706 else { 4712 else {
4707 QString addString; 4713 QString addString;
4708 if ( date == QDateTime::currentDateTime().date() ) 4714 if ( date == QDateTime::currentDateTime().date() )
4709 addString = i18n("Today"); 4715 addString = i18n("Today");
4710 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 4716 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
4711 addString = i18n("Tomorrow"); 4717 addString = i18n("Tomorrow");
4712 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 4718 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
4713 addString = i18n("Yesterday"); 4719 addString = i18n("Yesterday");
4714 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 4720 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
4715 addString = i18n("Day before yesterday"); 4721 addString = i18n("Day before yesterday");
4716 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 4722 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
4717 addString = i18n("Day after tomorrow"); 4723 addString = i18n("Day after tomorrow");
4718 if ( !addString.isEmpty() ) { 4724 if ( !addString.isEmpty() ) {
4719 topLevelWidget()->setCaption( addString+", " + selDates ); 4725 topLevelWidget()->setCaption( addString+", " + selDates );
4720 return; 4726 return;
4721 } 4727 }
4722 } 4728 }
4723 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 4729 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
4724 4730
4725} 4731}
4726 4732
4727QPtrList<CalFilter> CalendarView::filters() 4733Q3PtrList<CalFilter> CalendarView::filters()
4728{ 4734{
4729 return mFilters; 4735 return mFilters;
4730 4736
4731} 4737}
4732void CalendarView::editFilters() 4738void CalendarView::editFilters()
4733{ 4739{
4734 // kdDebug() << "CalendarView::editFilters()" << endl; 4740 // kdDebug() << "CalendarView::editFilters()" << endl;
4735 4741
4736 CalFilter *filter = mFilters.first(); 4742 CalFilter *filter = mFilters.first();
4737 while(filter) { 4743 while(filter) {
4738 filter = mFilters.next(); 4744 filter = mFilters.next();
4739 } 4745 }
4740 4746
4741 mDialogManager->showFilterEditDialog(&mFilters); 4747 mDialogManager->showFilterEditDialog(&mFilters);
4742 updateFilter(); 4748 updateFilter();
4743} 4749}
4744void CalendarView::toggleFilter() 4750void CalendarView::toggleFilter()
4745{ 4751{
4746 if ( mLeftFrame->isHidden() ) { 4752 if ( mLeftFrame->isHidden() ) {
4747 toggleExpand(); 4753 toggleExpand();
4748 showFilter( true ); 4754 showFilter( true );
4749 } else 4755 } else
4750 showFilter(! mCalEditView->isVisible()); 4756 showFilter(! mCalEditView->isVisible());
4751} 4757}
4752 4758
4753KOFilterView *CalendarView::filterView() 4759KOFilterView *CalendarView::filterView()
4754{ 4760{
4755 return mFilterView; 4761 return mFilterView;
4756} 4762}
4757void CalendarView::selectFilter( int fil ) 4763void CalendarView::selectFilter( int fil )
4758{ 4764{
4759 mFilterView->setSelectedFilter( fil ); 4765 mFilterView->setSelectedFilter( fil );
4760 updateUnmanagedViews(); 4766 updateUnmanagedViews();
4761} 4767}
4762void CalendarView::showFilter(bool visible) 4768void CalendarView::showFilter(bool visible)
4763{ 4769{
4764#if 1 4770#if 1
4765 if (visible) { 4771 if (visible) {
4766 mCalEditView->readConfig(); 4772 mCalEditView->readConfig();
4767 mCalEditView->show(); 4773 mCalEditView->show();
4768 QValueList<int> sizes; 4774 Q3ValueList<int> sizes;
4769 sizes = mLeftFrame->sizes(); 4775 sizes = mLeftFrame->sizes();
4770 if ( sizes.count() == 4 && sizes[3] < 20 ) { 4776 if ( sizes.count() == 4 && sizes[3] < 20 ) {
4771 sizes.clear(); 4777 sizes.clear();
4772 sizes << 100; 4778 sizes << 100;
4773 sizes << 0; 4779 sizes << 0;
4774 sizes << 0; 4780 sizes << 0;
4775 sizes << 100; 4781 sizes << 100;
4776 mLeftFrame->setSizes(sizes); 4782 mLeftFrame->setSizes(sizes);
4777 } 4783 }
4778#if 0 4784#if 0
4779 sizes = mLeftFrame->sizes(); 4785 sizes = mLeftFrame->sizes();
4780 int ccc = 0; 4786 int ccc = 0;
4781 while ( ccc < sizes.count()) { 4787 while ( ccc < sizes.count()) {
4782 qDebug("size %d %d ", ccc, sizes[ccc]); 4788 qDebug("size %d %d ", ccc, sizes[ccc]);
4783 ++ccc; 4789 ++ccc;
4784 } 4790 }
4785#endif 4791#endif
4786 4792
4787 } 4793 }
4788 else { 4794 else {
4789 mCalEditView->hide(); 4795 mCalEditView->hide();
4790 } 4796 }
4791#else 4797#else
4792 if (visible) mFilterView->show(); 4798 if (visible) mFilterView->show();
4793 else mFilterView->hide(); 4799 else mFilterView->hide();
4794#endif 4800#endif
4795} 4801}
4796void CalendarView::toggleFilerEnabled( ) 4802void CalendarView::toggleFilerEnabled( )
4797{ 4803{
4798 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 4804 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
4799 if ( !mFilterView->filtersEnabled() ) 4805 if ( !mFilterView->filtersEnabled() )
4800 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 4806 topLevelWidget()->setCaption( i18n("Filter disabled ") );
4801 updateUnmanagedViews(); 4807 updateUnmanagedViews();
4802 4808
4803} 4809}
4804void CalendarView::updateFilter() 4810void CalendarView::updateFilter()
4805{ 4811{
4806 CalFilter *filter = mFilterView->selectedFilter(); 4812 CalFilter *filter = mFilterView->selectedFilter();
4807 if (filter) { 4813 if (filter) {
4808 QString mess; 4814 QString mess;
4809 if (mFilterView->filtersEnabled()) { 4815 if (mFilterView->filtersEnabled()) {
4810 mess = i18n("Filter selected: ")+filter->name(); 4816 mess = i18n("Filter selected: ")+filter->name();
4811 filter->setEnabled(true); 4817 filter->setEnabled(true);
4812 } 4818 }
4813 else filter->setEnabled(false); 4819 else filter->setEnabled(false);
4814 mCalendar->setFilter(filter); 4820 mCalendar->setFilter(filter);
4815 updateView(); 4821 updateView();
4816 if ( !mess.isEmpty() ) 4822 if ( !mess.isEmpty() )
4817 topLevelWidget()->setCaption( mess ); 4823 topLevelWidget()->setCaption( mess );
4818 4824
4819 } 4825 }
4820 emit filtersUpdated(); 4826 emit filtersUpdated();
4821} 4827}
4822 4828
4823void CalendarView::filterEdited() 4829void CalendarView::filterEdited()
4824{ 4830{
4825 mFilterView->updateFilters(); 4831 mFilterView->updateFilters();
4826 updateFilter(); 4832 updateFilter();
4827 writeSettings(); 4833 writeSettings();
4828} 4834}
4829 4835
4830 4836
4831void CalendarView::takeOverEvent() 4837void CalendarView::takeOverEvent()
4832{ 4838{
4833 Incidence *incidence = currentSelection(); 4839 Incidence *incidence = currentSelection();
4834 4840
4835 if (!incidence) return; 4841 if (!incidence) return;
4836 4842
4837 incidence->setOrganizer(KOPrefs::instance()->email()); 4843 incidence->setOrganizer(KOPrefs::instance()->email());
4838 incidence->recreate(); 4844 incidence->recreate();
4839 incidence->setReadOnly(false); 4845 incidence->setReadOnly(false);
4840 4846
4841 updateView(); 4847 updateView();
4842} 4848}
4843 4849
4844void CalendarView::takeOverCalendar() 4850void CalendarView::takeOverCalendar()
4845{ 4851{
4846 // TODO: Create Calendar::allIncidences() function and use it here 4852 // TODO: Create Calendar::allIncidences() function and use it here
4847 4853
4848 clearAllViews(); 4854 clearAllViews();
4849 QPtrList<Event> events = mCalendar->events(); 4855 Q3PtrList<Event> events = mCalendar->events();
4850 for(uint i=0; i<events.count(); ++i) { 4856 for(uint i=0; i<events.count(); ++i) {
4851 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4857 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4852 events.at(i)->recreate(); 4858 events.at(i)->recreate();
4853 events.at(i)->setReadOnly(false); 4859 events.at(i)->setReadOnly(false);
4854 } 4860 }
4855 4861
4856 QPtrList<Todo> todos = mCalendar->todos(); 4862 Q3PtrList<Todo> todos = mCalendar->todos();
4857 for(uint i=0; i<todos.count(); ++i) { 4863 for(uint i=0; i<todos.count(); ++i) {
4858 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4864 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4859 todos.at(i)->recreate(); 4865 todos.at(i)->recreate();
4860 todos.at(i)->setReadOnly(false); 4866 todos.at(i)->setReadOnly(false);
4861 } 4867 }
4862 4868
4863 QPtrList<Journal> journals = mCalendar->journals(); 4869 Q3PtrList<Journal> journals = mCalendar->journals();
4864 for(uint i=0; i<journals.count(); ++i) { 4870 for(uint i=0; i<journals.count(); ++i) {
4865 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4871 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4866 journals.at(i)->recreate(); 4872 journals.at(i)->recreate();
4867 journals.at(i)->setReadOnly(false); 4873 journals.at(i)->setReadOnly(false);
4868 } 4874 }
4869 4875
4870 updateView(); 4876 updateView();
4871} 4877}
4872 4878
4873void CalendarView::showIntro() 4879void CalendarView::showIntro()
4874{ 4880{
4875 kdDebug() << "To be implemented." << endl; 4881 kdDebug() << "To be implemented." << endl;
4876} 4882}
4877 4883
4878QWidgetStack *CalendarView::viewStack() 4884Q3WidgetStack *CalendarView::viewStack()
4879{ 4885{
4880 return mRightFrame; 4886 return mRightFrame;
4881} 4887}
4882 4888
4883QWidget *CalendarView::leftFrame() 4889QWidget *CalendarView::leftFrame()
4884{ 4890{
4885 return ( QWidget *)mLeftFrame; 4891 return ( QWidget *)mLeftFrame;
4886} 4892}
4887 4893
4888DateNavigator *CalendarView::dateNavigator() 4894DateNavigator *CalendarView::dateNavigator()
4889{ 4895{
4890 return mNavigator; 4896 return mNavigator;
4891} 4897}
4892 4898
4893KDateNavigator* CalendarView::dateNavigatorWidget() 4899KDateNavigator* CalendarView::dateNavigatorWidget()
4894{ 4900{
4895 return mDateNavigator->navigatorView(); 4901 return mDateNavigator->navigatorView();
4896} 4902}
4897void CalendarView::toggleDateNavigatorWidget() 4903void CalendarView::toggleDateNavigatorWidget()
4898{ 4904{
4899 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4905 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4900 4906
4901 if (!KOPrefs::instance()->mShowDateNavigator ) 4907 if (!KOPrefs::instance()->mShowDateNavigator )
4902 mDateNavigator->hide(); 4908 mDateNavigator->hide();
4903 else 4909 else
4904 mDateNavigator->show(); 4910 mDateNavigator->show();
4905} 4911}
4906void CalendarView::addView(KOrg::BaseView *view) 4912void CalendarView::addView(KOrg::BaseView *view)
4907{ 4913{
4908 mViewManager->addView(view); 4914 mViewManager->addView(view);
4909} 4915}
4910 4916
4911void CalendarView::showView(KOrg::BaseView *view) 4917void CalendarView::showView(KOrg::BaseView *view)
4912{ 4918{
4913 mViewManager->showView(view, mLeftFrame->isVisible()); 4919 mViewManager->showView(view, mLeftFrame->isVisible());
4914} 4920}
4915 4921
4916Incidence *CalendarView::currentSelection() 4922Incidence *CalendarView::currentSelection()
4917{ 4923{
4918 return mViewManager->currentSelection(); 4924 return mViewManager->currentSelection();
4919} 4925}
4920void CalendarView::toggleAllDaySize() 4926void CalendarView::toggleAllDaySize()
4921{ 4927{
4922 /* 4928 /*
4923 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4929 if ( KOPrefs::instance()->mAllDaySize > 47 )
4924 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4930 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4925 else 4931 else
4926 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4932 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
@@ -5015,124 +5021,124 @@ void CalendarView::showIncidence(Incidence *incidence)
5015 } 5021 }
5016 } 5022 }
5017 if ( incidence ) { 5023 if ( incidence ) {
5018 ShowIncidenceVisitor v; 5024 ShowIncidenceVisitor v;
5019 v.act( incidence, this ); 5025 v.act( incidence, this );
5020 } 5026 }
5021} 5027}
5022 5028
5023void CalendarView::editIncidence(Incidence *incidence) 5029void CalendarView::editIncidence(Incidence *incidence)
5024{ 5030{
5025 if ( incidence ) { 5031 if ( incidence ) {
5026 5032
5027 EditIncidenceVisitor v; 5033 EditIncidenceVisitor v;
5028 v.act( incidence, this ); 5034 v.act( incidence, this );
5029 5035
5030 } 5036 }
5031} 5037}
5032 5038
5033void CalendarView::deleteIncidence(Incidence *incidence) 5039void CalendarView::deleteIncidence(Incidence *incidence)
5034{ 5040{
5035 //qDebug(" CalendarView::deleteIncidence "); 5041 //qDebug(" CalendarView::deleteIncidence ");
5036 if ( incidence == 0 ) { 5042 if ( incidence == 0 ) {
5037 updateView(); 5043 updateView();
5038 emit updateSearchDialog(); 5044 emit updateSearchDialog();
5039 return; 5045 return;
5040 } 5046 }
5041 if ( incidence ) { 5047 if ( incidence ) {
5042 DeleteIncidenceVisitor v; 5048 DeleteIncidenceVisitor v;
5043 v.act( incidence, this ); 5049 v.act( incidence, this );
5044 } 5050 }
5045} 5051}
5046 5052
5047 5053
5048void CalendarView::lookForOutgoingMessages() 5054void CalendarView::lookForOutgoingMessages()
5049{ 5055{
5050 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 5056 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
5051 ogd->loadMessages(); 5057 ogd->loadMessages();
5052} 5058}
5053 5059
5054void CalendarView::lookForIncomingMessages() 5060void CalendarView::lookForIncomingMessages()
5055{ 5061{
5056 IncomingDialog *icd = mDialogManager->incomingDialog(); 5062 IncomingDialog *icd = mDialogManager->incomingDialog();
5057 icd->retrieve(); 5063 icd->retrieve();
5058} 5064}
5059 5065
5060bool CalendarView::removeCompletedSubTodos( Todo* t ) 5066bool CalendarView::removeCompletedSubTodos( Todo* t )
5061{ 5067{
5062 bool deleteTodo = true; 5068 bool deleteTodo = true;
5063 QPtrList<Incidence> subTodos; 5069 Q3PtrList<Incidence> subTodos;
5064 Incidence *aTodo; 5070 Incidence *aTodo;
5065 subTodos = t->relations(); 5071 subTodos = t->relations();
5066 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 5072 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
5067 if (! removeCompletedSubTodos( (Todo*) aTodo )) 5073 if (! removeCompletedSubTodos( (Todo*) aTodo ))
5068 deleteTodo = false; 5074 deleteTodo = false;
5069 } 5075 }
5070 if ( deleteTodo ) { 5076 if ( deleteTodo ) {
5071 if ( t->isCompleted() && !t->doesRecur()) { 5077 if ( t->isCompleted() && !t->doesRecur()) {
5072 checkExternalId( t ); 5078 checkExternalId( t );
5073 mCalendar->deleteTodo( t ); 5079 mCalendar->deleteTodo( t );
5074 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 5080 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
5075 } 5081 }
5076 else 5082 else
5077 deleteTodo = false; 5083 deleteTodo = false;
5078 } 5084 }
5079 return deleteTodo; 5085 return deleteTodo;
5080 5086
5081} 5087}
5082void CalendarView::purgeCompleted() 5088void CalendarView::purgeCompleted()
5083{ 5089{
5084 int result = KMessageBox::warningContinueCancel(this, 5090 int result = KMessageBox::warningContinueCancel(this,
5085 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 5091 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
5086 5092
5087 if (result == KMessageBox::Continue) { 5093 if (result == KMessageBox::Continue) {
5088 5094
5089 QPtrList<Todo> todoCal; 5095 Q3PtrList<Todo> todoCal;
5090 QPtrList<Todo> rootTodos; 5096 Q3PtrList<Todo> rootTodos;
5091 //QPtrList<Incidence> rel; 5097 //QPtrList<Incidence> rel;
5092 Todo *aTodo; 5098 Todo *aTodo;
5093 todoCal = calendar()->todos(); 5099 todoCal = calendar()->todos();
5094 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 5100 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
5095 if ( !aTodo->relatedTo() ) 5101 if ( !aTodo->relatedTo() )
5096 rootTodos.append( aTodo ); 5102 rootTodos.append( aTodo );
5097 } 5103 }
5098 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 5104 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
5099 removeCompletedSubTodos( aTodo ); 5105 removeCompletedSubTodos( aTodo );
5100 } 5106 }
5101 5107
5102 updateView(); 5108 updateView();
5103 } 5109 }
5104} 5110}
5105 5111
5106void CalendarView::slotCalendarChanged() 5112void CalendarView::slotCalendarChanged()
5107{ 5113{
5108 ; 5114 ;
5109} 5115}
5110 5116
5111void CalendarView::keyPressEvent ( QKeyEvent *e) 5117void CalendarView::keyPressEvent ( QKeyEvent *e)
5112{ 5118{
5113 //qDebug("CalendarView::keyPressEvent "); 5119 //qDebug("CalendarView::keyPressEvent ");
5114 e->ignore(); 5120 e->ignore();
5115} 5121}
5116 5122
5117void CalendarView::multiResourceSyncStart( bool start ) 5123void CalendarView::multiResourceSyncStart( bool start )
5118{ 5124{
5119 mMultiResourceSync = start; 5125 mMultiResourceSync = start;
5120 5126
5121} 5127}
5122bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) 5128bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource)
5123{ 5129{
5124 5130
5125 if ( manager != mSyncManager) 5131 if ( manager != mSyncManager)
5126 qDebug("KO: Internal error-1. SyncManager mismatch "); 5132 qDebug("KO: Internal error-1. SyncManager mismatch ");
5127 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 5133 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
5128 qDebug("KO: SyncKDE request detected!"); 5134 qDebug("KO: SyncKDE request detected!");
5129 } 5135 }
5130 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5136 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5131 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5137 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5132 if ( !resource.isEmpty() ) { 5138 if ( !resource.isEmpty() ) {
5133 int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); 5139 int exclusiveSyncResource = KOPrefs::instance()->getFuzzyCalendarID( resource );
5134 qDebug( "KO: Sync request for resource: %s", resource.latin1() ); 5140 qDebug( "KO: Sync request for resource: %s", resource.latin1() );
5135 5141
5136 if ( !exclusiveSyncResource ) { 5142 if ( !exclusiveSyncResource ) {
5137 qDebug( "KO: Requested sync resource not found: %s", resource.latin1() ); 5143 qDebug( "KO: Requested sync resource not found: %s", resource.latin1() );
5138 return false; 5144 return false;