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