summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp63
-rw-r--r--korganizer/calendarview.h7
-rw-r--r--korganizer/kofilterview.cpp2
-rw-r--r--korganizer/mainwindow.cpp4
-rw-r--r--libkcal/calendar.cpp5
-rw-r--r--libkcal/calendar.h9
-rw-r--r--libkcal/calendarlocal.cpp56
-rw-r--r--libkcal/calendarlocal.h6
8 files changed, 142 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b3686aa..07ec459 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3503 +1,3564 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preton.brown@yale.edu) 8 Preston Brown (preton.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
142 142
143{ 143{
144 mAlarms = alarms; 144 mAlarms = alarms;
145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
146 QString mText = "<table width=\"100%\">\n"; 146 QString mText = "<table width=\"100%\">\n";
147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
148#ifdef DESKTOP_VERSION 148#ifdef DESKTOP_VERSION
149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
150#else 150#else
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
152#endif 152#endif
153 // mText += "<img src=\""; 153 // mText += "<img src=\"";
154 // mText += ipath; 154 // mText += ipath;
155 // mText += "\">"; 155 // mText += "\">";
156 //mEventDate = QDate::currentDate(); 156 //mEventDate = QDate::currentDate();
157#ifdef DESKTOP_VERSION 157#ifdef DESKTOP_VERSION
158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
159#else 159#else
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
161#endif 161#endif
162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
163 163
164 Incidence * inc = getNextInc( start ); 164 Incidence * inc = getNextInc( start );
165 int time = 0; 165 int time = 0;
166 //mText += "<table>"; 166 //mText += "<table>";
167 while ( inc ) { 167 while ( inc ) {
168 QDateTime dt ; 168 QDateTime dt ;
169 QString tempText = "<a "; 169 QString tempText = "<a ";
170 bool ok; 170 bool ok;
171 dt = inc->getNextOccurence( start, &ok ); 171 dt = inc->getNextOccurence( start, &ok );
172 if ( !ok ) continue; 172 if ( !ok ) continue;
173 if ( inc->typeID() == eventID ) { 173 if ( inc->typeID() == eventID ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->typeID() == todoID ) { 175 } else if ( inc->typeID() == todoID ) {
176 tempText += "href=\"todo:"; 176 tempText += "href=\"todo:";
177 } 177 }
178 tempText += inc->uid() + "\">"; 178 tempText += inc->uid() + "\">";
179 if ( inc->typeID() == todoID ) 179 if ( inc->typeID() == todoID )
180 tempText += i18n("Todo: "); 180 tempText += i18n("Todo: ");
181 if ( inc->summary().length() > 0 ) 181 if ( inc->summary().length() > 0 )
182 tempText += inc->summary(); 182 tempText += inc->summary();
183 else 183 else
184 tempText += i18n("-no summary-"); 184 tempText += i18n("-no summary-");
185 QString timestr; 185 QString timestr;
186 if (!inc->doesFloat()) 186 if (!inc->doesFloat())
187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
188 else 188 else
189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
190 if ( dt.date() < QDate::currentDate() && time == 0 ) { 190 if ( dt.date() < QDate::currentDate() && time == 0 ) {
191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
192 mText += "<table>"; 192 mText += "<table>";
193 time = 1; 193 time = 1;
194 } 194 }
195 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 195 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
196 if ( time > 0 ) 196 if ( time > 0 )
197 mText +="</table>"; 197 mText +="</table>";
198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
199 mText += "<table>"; 199 mText += "<table>";
200 time = 2; 200 time = 2;
201 201
202 } 202 }
203 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 203 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
204 if ( time > 0 ) 204 if ( time > 0 )
205 mText +="</table>"; 205 mText +="</table>";
206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
207 mText += "<table>"; 207 mText += "<table>";
208 time = 3; 208 time = 3;
209 } 209 }
210 mText +="<tr><td><b>"; 210 mText +="<tr><td><b>";
211 mText += timestr; 211 mText += timestr;
212 mText += "</b></td><td>"; 212 mText += "</b></td><td>";
213 mText += tempText; 213 mText += tempText;
214 mText += "</td></tr>\n"; 214 mText += "</td></tr>\n";
215 inc = getNextInc( start ); 215 inc = getNextInc( start );
216 } 216 }
217 mText +="</table>"; 217 mText +="</table>";
218 setText( mText ); 218 setText( mText );
219} 219}
220 220
221MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 221MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
222{ 222{
223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
224} 224}
225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
226{ 226{
227 QDateTime dt ; 227 QDateTime dt ;
228 Incidence * retInc; 228 Incidence * retInc;
229 Incidence * inc = mAlarms.first(); 229 Incidence * inc = mAlarms.first();
230 if ( inc == 0 ) 230 if ( inc == 0 )
231 return 0; 231 return 0;
232 bool ok; 232 bool ok;
233 dt = inc->getNextOccurence( start, &ok ); 233 dt = inc->getNextOccurence( start, &ok );
234 if ( ! ok ) return 0; 234 if ( ! ok ) return 0;
235 QDateTime dtn ; 235 QDateTime dtn ;
236 retInc = inc; 236 retInc = inc;
237 inc = mAlarms.next(); 237 inc = mAlarms.next();
238 while ( inc ) { 238 while ( inc ) {
239 dtn = inc->getNextOccurence( start, &ok ); 239 dtn = inc->getNextOccurence( start, &ok );
240 if ( ! ok ) return 0; 240 if ( ! ok ) return 0;
241 if ( dtn < dt ) { 241 if ( dtn < dt ) {
242 dt = dtn; 242 dt = dtn;
243 retInc = inc; 243 retInc = inc;
244 } 244 }
245 inc = mAlarms.next(); 245 inc = mAlarms.next();
246 } 246 }
247 mAlarms.remove( retInc ); 247 mAlarms.remove( retInc );
248 return retInc; 248 return retInc;
249 249
250} 250}
251void MissedAlarmTextBrowser::setSource(const QString & n) 251void MissedAlarmTextBrowser::setSource(const QString & n)
252{ 252{
253 if (n.startsWith("event:")) { 253 if (n.startsWith("event:")) {
254#ifdef DESKTOP_VERSION 254#ifdef DESKTOP_VERSION
255 emit showIncidence(n.mid(8)); 255 emit showIncidence(n.mid(8));
256#else 256#else
257 emit showIncidence(n.mid(6)); 257 emit showIncidence(n.mid(6));
258#endif 258#endif
259 return; 259 return;
260 } else if (n.startsWith("todo:")) { 260 } else if (n.startsWith("todo:")) {
261#ifdef DESKTOP_VERSION 261#ifdef DESKTOP_VERSION
262 emit showIncidence(n.mid(7)); 262 emit showIncidence(n.mid(7));
263#else 263#else
264 emit showIncidence(n.mid(5)); 264 emit showIncidence(n.mid(5));
265#endif 265#endif
266 return; 266 return;
267 } 267 }
268} 268}
269 269
270 270
271class KOBeamPrefs : public QDialog 271class KOBeamPrefs : public QDialog
272{ 272{
273 public: 273 public:
274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
275 QDialog( parent, name, true ) 275 QDialog( parent, name, true )
276 { 276 {
277 setCaption( i18n("Beam Options") ); 277 setCaption( i18n("Beam Options") );
278 QVBoxLayout* lay = new QVBoxLayout( this ); 278 QVBoxLayout* lay = new QVBoxLayout( this );
279 lay->setSpacing( 3 ); 279 lay->setSpacing( 3 );
280 lay->setMargin( 3 ); 280 lay->setMargin( 3 );
281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
282 lay->addWidget( format ); 282 lay->addWidget( format );
283 format->setExclusive ( true ) ; 283 format->setExclusive ( true ) ;
284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
285 lay->addWidget( time ); time->setExclusive ( true ) ; 285 lay->addWidget( time ); time->setExclusive ( true ) ;
286 vcal = new QRadioButton(" vCalendar ", format ); 286 vcal = new QRadioButton(" vCalendar ", format );
287 ical = new QRadioButton(" iCalendar ", format ); 287 ical = new QRadioButton(" iCalendar ", format );
288 vcal->setChecked( true ); 288 vcal->setChecked( true );
289 tz = new QRadioButton(i18n(" With timezone "), time ); 289 tz = new QRadioButton(i18n(" With timezone "), time );
290 local = new QRadioButton(i18n(" Local time "), time ); 290 local = new QRadioButton(i18n(" Local time "), time );
291 tz->setChecked( true ); 291 tz->setChecked( true );
292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
293 lay->addWidget( ok ); 293 lay->addWidget( ok );
294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
295 lay->addWidget( cancel ); 295 lay->addWidget( cancel );
296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
298 resize( 200, 200 ); 298 resize( 200, 200 );
299 } 299 }
300 300
301 bool beamVcal() { return vcal->isChecked(); } 301 bool beamVcal() { return vcal->isChecked(); }
302 bool beamLocal() { return local->isChecked(); } 302 bool beamLocal() { return local->isChecked(); }
303private: 303private:
304 QRadioButton* vcal, *ical, *local, *tz; 304 QRadioButton* vcal, *ical, *local, *tz;
305}; 305};
306class KOCatPrefs : public QDialog 306class KOCatPrefs : public QDialog
307{ 307{
308 public: 308 public:
309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
310 QDialog( parent, name, true ) 310 QDialog( parent, name, true )
311 { 311 {
312 setCaption( i18n("Manage new Categories") ); 312 setCaption( i18n("Manage new Categories") );
313 QVBoxLayout* lay = new QVBoxLayout( this ); 313 QVBoxLayout* lay = new QVBoxLayout( this );
314 lay->setSpacing( 3 ); 314 lay->setSpacing( 3 );
315 lay->setMargin( 3 ); 315 lay->setMargin( 3 );
316 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 316 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
317 lay->addWidget( lab ); 317 lay->addWidget( lab );
318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
319 lay->addWidget( format ); 319 lay->addWidget( format );
320 format->setExclusive ( true ) ; 320 format->setExclusive ( true ) ;
321 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 321 addCatBut = new QRadioButton(i18n("Add to category list"), format );
322 new QRadioButton(i18n("Remove from Events/Todos"), format ); 322 new QRadioButton(i18n("Remove from Events/Todos"), format );
323 addCatBut->setChecked( true ); 323 addCatBut->setChecked( true );
324 QPushButton * ok = new QPushButton( i18n("OK"), this ); 324 QPushButton * ok = new QPushButton( i18n("OK"), this );
325 lay->addWidget( ok ); 325 lay->addWidget( ok );
326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
327 lay->addWidget( cancel ); 327 lay->addWidget( cancel );
328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
330 resize( 200, 200 ); 330 resize( 200, 200 );
331 } 331 }
332 332
333 bool addCat() { return addCatBut->isChecked(); } 333 bool addCat() { return addCatBut->isChecked(); }
334private: 334private:
335 QRadioButton* addCatBut; 335 QRadioButton* addCatBut;
336}; 336};
337 337
338 338
339 339
340CalendarView::CalendarView( CalendarResources *calendar, 340CalendarView::CalendarView( CalendarResources *calendar,
341 QWidget *parent, const char *name ) 341 QWidget *parent, const char *name )
342 : CalendarViewBase( parent, name ), 342 : CalendarViewBase( parent, name ),
343 mCalendar( calendar ), 343 mCalendar( calendar ),
344 mResourceManager( calendar->resourceManager() ) 344 mResourceManager( calendar->resourceManager() )
345{ 345{
346 346
347 mEventEditor = 0; 347 mEventEditor = 0;
348 mTodoEditor = 0; 348 mTodoEditor = 0;
349 349
350 init(); 350 init();
351} 351}
352 352
353CalendarView::CalendarView( Calendar *calendar, 353CalendarView::CalendarView( Calendar *calendar,
354 QWidget *parent, const char *name ) 354 QWidget *parent, const char *name )
355 : CalendarViewBase( parent, name ), 355 : CalendarViewBase( parent, name ),
356 mCalendar( calendar ), 356 mCalendar( calendar ),
357 mResourceManager( 0 ) 357 mResourceManager( 0 )
358{ 358{
359 359
360 mEventEditor = 0; 360 mEventEditor = 0;
361 mTodoEditor = 0; 361 mTodoEditor = 0;
362 init(); 362 init();
363} 363}
364 364
365void CalendarView::init() 365void CalendarView::init()
366{ 366{
367 mNextAlarmDateTime = QDateTime::currentDateTime(); 367 mNextAlarmDateTime = QDateTime::currentDateTime();
368 setFocusPolicy ( NoFocus ); 368 setFocusPolicy ( NoFocus );
369 mViewerCallerIsSearchDialog = false; 369 mViewerCallerIsSearchDialog = false;
370 mBlockShowDates = false; 370 mBlockShowDates = false;
371 beamDialog = new KOBeamPrefs(); 371 beamDialog = new KOBeamPrefs();
372 mDatePickerMode = 0; 372 mDatePickerMode = 0;
373 mCurrentSyncDevice = ""; 373 mCurrentSyncDevice = "";
374 writeLocale(); 374 writeLocale();
375 mViewManager = new KOViewManager( this ); 375 mViewManager = new KOViewManager( this );
376 mDialogManager = new KODialogManager( this ); 376 mDialogManager = new KODialogManager( this );
377 mEventViewerDialog = 0; 377 mEventViewerDialog = 0;
378 mModified = false; 378 mModified = false;
379 mReadOnly = false; 379 mReadOnly = false;
380 mSelectedIncidence = 0; 380 mSelectedIncidence = 0;
381 mCalPrinter = 0; 381 mCalPrinter = 0;
382 mFilters.setAutoDelete(true); 382 mFilters.setAutoDelete(true);
383 383
384 mCalendar->registerObserver( this ); 384 mCalendar->registerObserver( this );
385 // TODO: Make sure that view is updated, when calendar is changed. 385 // TODO: Make sure that view is updated, when calendar is changed.
386 386
387 mStorage = new FileStorage( mCalendar ); 387 mStorage = new FileStorage( mCalendar );
388 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 388 mNavigator = new DateNavigator( this, "datevav", mViewManager );
389 389
390 QBoxLayout *topLayout = (QBoxLayout*)layout(); 390 QBoxLayout *topLayout = (QBoxLayout*)layout();
391#ifndef KORG_NOSPLITTER 391#ifndef KORG_NOSPLITTER
392 // create the main layout frames. 392 // create the main layout frames.
393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
394 topLayout->addWidget(mPanner); 394 topLayout->addWidget(mPanner);
395 395
396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
397 "CalendarView::LeftFrame"); 397 "CalendarView::LeftFrame");
398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
399 399
400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
401 "CalendarView::DateNavigator" ); 401 "CalendarView::DateNavigator" );
402 402
403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
405 mTodoList->setNavigator( mNavigator ); 405 mTodoList->setNavigator( mNavigator );
406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
407 407
408#ifdef KORG_NORESOURCEVIEW 408#ifdef KORG_NORESOURCEVIEW
409 mResourceView = 0; 409 mResourceView = 0;
410#else 410#else
411 if ( mResourceManager ) { 411 if ( mResourceManager ) {
412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
413 mResourceView->updateView(); 413 mResourceView->updateView();
414 connect( mResourceView, SIGNAL( resourcesChanged() ), 414 connect( mResourceView, SIGNAL( resourcesChanged() ),
415 SLOT( updateView() ) ); 415 SLOT( updateView() ) );
416 } else { 416 } else {
417 mResourceView = 0; 417 mResourceView = 0;
418 } 418 }
419#endif 419#endif
420 QWidget *rightBox = new QWidget( mPanner ); 420 QWidget *rightBox = new QWidget( mPanner );
421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
422 422
423 mRightFrame = new QWidgetStack( rightBox ); 423 mRightFrame = new QWidgetStack( rightBox );
424 rightLayout->addWidget( mRightFrame, 1 ); 424 rightLayout->addWidget( mRightFrame, 1 );
425 425
426 mLeftFrame = mLeftSplitter; 426 mLeftFrame = mLeftSplitter;
427#else 427#else
428 //QWidget *mainBox = new QWidget( this ); 428 //QWidget *mainBox = new QWidget( this );
429 //QWidget *leftFrame = new QWidget( mainBox ); 429 //QWidget *leftFrame = new QWidget( mainBox );
430 //QBoxLayout * mainBoxLayout; 430 //QBoxLayout * mainBoxLayout;
431 if ( KOPrefs::instance()->mVerticalScreen ) { 431 if ( KOPrefs::instance()->mVerticalScreen ) {
432 //mainBoxLayout = new QVBoxLayout(mainBox); 432 //mainBoxLayout = new QVBoxLayout(mainBox);
433 //leftFrameLayout = new QHBoxLayout(leftFrame ); 433 //leftFrameLayout = new QHBoxLayout(leftFrame );
434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
438 } else { 438 } else {
439 //mainBoxLayout = new QHBoxLayout(mainBox); 439 //mainBoxLayout = new QHBoxLayout(mainBox);
440 //leftFrameLayout = new QVBoxLayout(leftFrame ); 440 //leftFrameLayout = new QVBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
445 } 445 }
446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
447 //QBoxLayout * leftFrameLayout; 447 //QBoxLayout * leftFrameLayout;
448 topLayout->addWidget( mMainFrame ); 448 topLayout->addWidget( mMainFrame );
449 //mainBoxLayout->addWidget (mLeftFrame); 449 //mainBoxLayout->addWidget (mLeftFrame);
450 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 450 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
451 "CalendarView::DateNavigator" ); 451 "CalendarView::DateNavigator" );
452#if 0 452#if 0
453 // FIXME 453 // FIXME
454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
455 "CalendarView::DateNavigator", QDate::currentDate()); 455 "CalendarView::DateNavigator", QDate::currentDate());
456#endif 456#endif
457 // mDateNavigator->blockSignals( true ); 457 // mDateNavigator->blockSignals( true );
458 //leftFrameLayout->addWidget( mDateNavigator ); 458 //leftFrameLayout->addWidget( mDateNavigator );
459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
462 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
463 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
464 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
465 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
462 mTodoList->setNavigator( mNavigator ); 466 mTodoList->setNavigator( mNavigator );
463#if 0 467#if 0
464 if ( QApplication::desktop()->width() < 480 ) { 468 if ( QApplication::desktop()->width() < 480 ) {
465 leftFrameLayout->addWidget(mFilterView); 469 leftFrameLayout->addWidget(mFilterView);
466 leftFrameLayout->addWidget(mTodoList, 2 ); 470 leftFrameLayout->addWidget(mTodoList, 2 );
467 471
468 } else { 472 } else {
469 leftFrameLayout->addWidget(mTodoList,2 ); 473 leftFrameLayout->addWidget(mTodoList,2 );
470 leftFrameLayout->addWidget(mFilterView ); 474 leftFrameLayout->addWidget(mFilterView );
471 } 475 }
472#endif 476#endif
473 mFilterView->hide(); 477 mFilterView->hide();
474 mCalEditView->hide(); 478 mCalEditView->hide();
475 QWidget *rightBox = new QWidget( mMainFrame ); 479 QWidget *rightBox = new QWidget( mMainFrame );
476 //mainBoxLayout->addWidget ( rightBox, 10 ); 480 //mainBoxLayout->addWidget ( rightBox, 10 );
477 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 481 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
478 mRightFrame = new QWidgetStack( rightBox ); 482 mRightFrame = new QWidgetStack( rightBox );
479 rightLayout->addWidget( mRightFrame, 10 ); 483 rightLayout->addWidget( mRightFrame, 10 );
480 484
481 //mLeftFrame = (QWidget *)leftFrame; 485 //mLeftFrame = (QWidget *)leftFrame;
482 if ( KOPrefs::instance()->mVerticalScreen ) { 486 if ( KOPrefs::instance()->mVerticalScreen ) {
483 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 487 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
484 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 488 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
485 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 489 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
486 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 490 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
487 } else { 491 } else {
488 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 492 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
489 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 493 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
490 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 494 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
491 } 495 }
492 if ( !KOPrefs::instance()->mShowDateNavigator) 496 if ( !KOPrefs::instance()->mShowDateNavigator)
493 mDateNavigator->hide(); 497 mDateNavigator->hide();
494 //qDebug("Calendarview Size %d %d ", width(), height()); 498 //qDebug("Calendarview Size %d %d ", width(), height());
495#endif 499#endif
496 500
497 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 501 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
498 SLOT( showDates( const KCal::DateList & ) ) ); 502 SLOT( showDates( const KCal::DateList & ) ) );
499 503
500 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 504 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
501 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 505 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
502 506
503 507
504 508
505 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 509 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
506 mViewManager, SLOT( showMonth( const QDate & ) ) ); 510 mViewManager, SLOT( showMonth( const QDate & ) ) );
507 511
508 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 512 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
509 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 513 mNavigator, SLOT( selectWeek( const QDate & ) ) );
510 514
511 connect( mDateNavigator, SIGNAL( goPrevYear() ), 515 connect( mDateNavigator, SIGNAL( goPrevYear() ),
512 mNavigator, SLOT( selectPreviousYear() ) ); 516 mNavigator, SLOT( selectPreviousYear() ) );
513 connect( mDateNavigator, SIGNAL( goNextYear() ), 517 connect( mDateNavigator, SIGNAL( goNextYear() ),
514 mNavigator, SLOT( selectNextYear() ) ); 518 mNavigator, SLOT( selectNextYear() ) );
515 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 519 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
516 mNavigator, SLOT( selectPreviousMonth() ) ); 520 mNavigator, SLOT( selectPreviousMonth() ) );
517 connect( mDateNavigator, SIGNAL( goNextMonth() ), 521 connect( mDateNavigator, SIGNAL( goNextMonth() ),
518 mNavigator, SLOT( selectNextMonth() ) ); 522 mNavigator, SLOT( selectNextMonth() ) );
519 523
520 connect( mDateNavigator, SIGNAL( goPrevious() ), 524 connect( mDateNavigator, SIGNAL( goPrevious() ),
521 mNavigator, SLOT( selectPrevious() ) ); 525 mNavigator, SLOT( selectPrevious() ) );
522 connect( mDateNavigator, SIGNAL( goNext() ), 526 connect( mDateNavigator, SIGNAL( goNext() ),
523 mNavigator, SLOT( selectNext() ) ); 527 mNavigator, SLOT( selectNext() ) );
524 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 528 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
525 mNavigator, SLOT( slotMonthSelect( int ) ) ); 529 mNavigator, SLOT( slotMonthSelect( int ) ) );
526 530
527 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 531 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
528 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 532 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
529#if 0 533#if 0
530 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 534 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
531 SLOT( incidenceAdded( Incidence *) ) ); 535 SLOT( incidenceAdded( Incidence *) ) );
532#endif 536#endif
533 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 537 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
534 538
535 connect( this, SIGNAL( configChanged() ), 539 connect( this, SIGNAL( configChanged() ),
536 mDateNavigator, SLOT( updateConfig() ) ); 540 mDateNavigator, SLOT( updateConfig() ) );
537 541
538 connect( mTodoList, SIGNAL( newTodoSignal() ), 542 connect( mTodoList, SIGNAL( newTodoSignal() ),
539 SLOT( newTodo() ) ); 543 SLOT( newTodo() ) );
540 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 544 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
541 SLOT( newSubTodo( Todo * ) ) ); 545 SLOT( newSubTodo( Todo * ) ) );
542 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 546 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
543 SLOT( editTodo( Todo * ) ) ); 547 SLOT( editTodo( Todo * ) ) );
544 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 548 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
545 SLOT( showTodo( Todo *) ) ); 549 SLOT( showTodo( Todo *) ) );
546 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 550 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
547 SLOT( deleteTodo( Todo *) ) ); 551 SLOT( deleteTodo( Todo *) ) );
548 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 552 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
549 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 553 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
550 SLOT( purgeCompleted() ) ); 554 SLOT( purgeCompleted() ) );
551 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 555 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
552 SIGNAL( todoModified( Todo *, int ) ) ); 556 SIGNAL( todoModified( Todo *, int ) ) );
553 557
554 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 558 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
555 this, SLOT ( cloneIncidence( Incidence * ) ) ); 559 this, SLOT ( cloneIncidence( Incidence * ) ) );
556 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 560 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
557 this, SLOT (cancelIncidence( Incidence * ) ) ); 561 this, SLOT (cancelIncidence( Incidence * ) ) );
558 562
559 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 563 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
560 this, SLOT ( moveIncidence( Incidence * ) ) ); 564 this, SLOT ( moveIncidence( Incidence * ) ) );
561 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 565 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
562 this, SLOT ( beamIncidence( Incidence * ) ) ); 566 this, SLOT ( beamIncidence( Incidence * ) ) );
563 567
564 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 568 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
565 this, SLOT ( todo_unsub( Todo * ) ) ); 569 this, SLOT ( todo_unsub( Todo * ) ) );
566 570
567 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 571 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
568 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 572 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
569 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 573 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
570 SLOT( updateTodo( Todo *, int ) ) ); 574 SLOT( updateTodo( Todo *, int ) ) );
571 connect( this, SIGNAL( todoModified( Todo *, int )), this, 575 connect( this, SIGNAL( todoModified( Todo *, int )), this,
572 SLOT( changeTodoDisplay( Todo *, int ) ) ); 576 SLOT( changeTodoDisplay( Todo *, int ) ) );
573 577
574 578
575 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 579 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
576 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 580 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
577 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 581 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
578 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 582 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
579 583
580 584
581 585
582 586
583 587
584 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 588 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
585 SLOT(checkClipboard())); 589 SLOT(checkClipboard()));
586 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 590 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
587 SLOT( processTodoListSelection( Incidence * ) ) ); 591 SLOT( processTodoListSelection( Incidence * ) ) );
588 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 592 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
589 593
590 // kdDebug() << "CalendarView::CalendarView() done" << endl; 594 // kdDebug() << "CalendarView::CalendarView() done" << endl;
591 595
592 mDateFrame = new QVBox(0,0,WType_Popup); 596 mDateFrame = new QVBox(0,0,WType_Popup);
593 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 597 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
594 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 598 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
595 mDateFrame->setLineWidth(3); 599 mDateFrame->setLineWidth(3);
596 mDateFrame->hide(); 600 mDateFrame->hide();
597 mDateFrame->setCaption( i18n( "Pick a date to display")); 601 mDateFrame->setCaption( i18n( "Pick a date to display"));
598 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 602 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
599 603
600 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 604 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
601 605
602 mEventEditor = mDialogManager->getEventEditor(); 606 mEventEditor = mDialogManager->getEventEditor();
603 mTodoEditor = mDialogManager->getTodoEditor(); 607 mTodoEditor = mDialogManager->getTodoEditor();
604 608
605 mFlagEditDescription = false; 609 mFlagEditDescription = false;
606 610
607 mSuspendTimer = new QTimer( this ); 611 mSuspendTimer = new QTimer( this );
608 mAlarmTimer = new QTimer( this ); 612 mAlarmTimer = new QTimer( this );
609 mRecheckAlarmTimer = new QTimer( this ); 613 mRecheckAlarmTimer = new QTimer( this );
610 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 614 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
611 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 615 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
612 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 616 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
613 mAlarmDialog = new AlarmDialog( this ); 617 mAlarmDialog = new AlarmDialog( this );
614 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 618 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
615 mAlarmDialog->setServerNotification( false ); 619 mAlarmDialog->setServerNotification( false );
616 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 620 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
617 621
618 622
619#ifndef DESKTOP_VERSION 623#ifndef DESKTOP_VERSION
620//US listen for arriving address resultsets 624//US listen for arriving address resultsets
621 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 625 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
622 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 626 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
623#endif 627#endif
624 mDateNavigator->setCalendar( mCalendar ); 628 mDateNavigator->setCalendar( mCalendar );
625} 629}
626 630
627 631
628CalendarView::~CalendarView() 632CalendarView::~CalendarView()
629{ 633{
630 // kdDebug() << "~CalendarView()" << endl; 634 // kdDebug() << "~CalendarView()" << endl;
631 //qDebug("CalendarView::~CalendarView() "); 635 //qDebug("CalendarView::~CalendarView() ");
632 delete mDialogManager; 636 delete mDialogManager;
633 delete mViewManager; 637 delete mViewManager;
634 delete mStorage; 638 delete mStorage;
635 delete mDateFrame ; 639 delete mDateFrame ;
636 delete beamDialog; 640 delete beamDialog;
637 delete mEventViewerDialog; 641 delete mEventViewerDialog;
638 //kdDebug() << "~CalendarView() done" << endl; 642 //kdDebug() << "~CalendarView() done" << endl;
639} 643}
640void CalendarView::checkAlarms() 644void CalendarView::checkAlarms()
641{ 645{
642 KConfig *config = KOGlobals::config(); 646 KConfig *config = KOGlobals::config();
643 config->setGroup( "AppRun" ); 647 config->setGroup( "AppRun" );
644 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 648 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
645 int daysto = dt.daysTo( QDate::currentDate() ); 649 int daysto = dt.daysTo( QDate::currentDate() );
646 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 650 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
647 dt = dt.addDays( days ); 651 dt = dt.addDays( days );
648 int secto = dt.secsTo( QDateTime::currentDateTime() ); 652 int secto = dt.secsTo( QDateTime::currentDateTime() );
649 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 653 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
650 //qDebug("KO: Reading program stop %d ", secs); 654 //qDebug("KO: Reading program stop %d ", secs);
651 //secs -= ( 3600 * 24*3 ); // debug only 655 //secs -= ( 3600 * 24*3 ); // debug only
652 QDateTime latest = dt.addSecs ( secs ); 656 QDateTime latest = dt.addSecs ( secs );
653 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 657 qDebug("KO: Last termination on %s ", latest.toString().latin1());
654 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 658 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
655 QPtrList<Incidence> el = mCalendar->rawIncidences(); 659 QPtrList<Incidence> el = mCalendar->rawIncidences();
656 QPtrList<Incidence> al; 660 QPtrList<Incidence> al;
657 Incidence* inL = el.first(); 661 Incidence* inL = el.first();
658 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 662 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
659 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 663 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
660 while ( inL ) { 664 while ( inL ) {
661 bool ok = false; 665 bool ok = false;
662 int offset = 0; 666 int offset = 0;
663 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 667 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
664 if ( ok ) { 668 if ( ok ) {
665 //qDebug("OK %s",next.toString().latin1()); 669 //qDebug("OK %s",next.toString().latin1());
666 if ( next < cur ) { 670 if ( next < cur ) {
667 al.append( inL ); 671 al.append( inL );
668 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 672 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
669 } 673 }
670 } 674 }
671 inL = el.next(); 675 inL = el.next();
672 } 676 }
673 if ( al.count() ) { 677 if ( al.count() ) {
674 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 678 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
675 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 679 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
676 QVBoxLayout* lay = new QVBoxLayout( dia ); 680 QVBoxLayout* lay = new QVBoxLayout( dia );
677 lay->setSpacing( 0 ); 681 lay->setSpacing( 0 );
678 lay->setMargin( 0 ); 682 lay->setMargin( 0 );
679 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 683 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
680 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 684 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
681 lay->addWidget( matb ); 685 lay->addWidget( matb );
682 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 686 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
683 int wid = 210; 687 int wid = 210;
684 int x = QApplication::desktop()->width() - wid - 7; 688 int x = QApplication::desktop()->width() - wid - 7;
685 int y = QApplication::desktop()->height() - wid - 70; 689 int y = QApplication::desktop()->height() - wid - 70;
686 dia->setGeometry ( x,y,wid,wid); 690 dia->setGeometry ( x,y,wid,wid);
687 } else { 691 } else {
688 int si = 220; 692 int si = 220;
689 if ( QApplication::desktop()->width() > 470 ) 693 if ( QApplication::desktop()->width() > 470 )
690 si = 400; 694 si = 400;
691 dia->resize(si,si/2); 695 dia->resize(si,si/2);
692 } 696 }
693 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 697 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
694 dia->show(); 698 dia->show();
695 699
696 } 700 }
697} 701}
698void CalendarView::showDay( QDate d ) 702void CalendarView::showDay( QDate d )
699{ 703{
700 dateNavigator()->blockSignals( true ); 704 dateNavigator()->blockSignals( true );
701 dateNavigator()->selectDate( d ); 705 dateNavigator()->selectDate( d );
702 dateNavigator()->blockSignals( false ); 706 dateNavigator()->blockSignals( false );
703 mViewManager->showDayView(); 707 mViewManager->showDayView();
704 //dateNavigator()->selectDate( d ); 708 //dateNavigator()->selectDate( d );
705} 709}
706void CalendarView::timerAlarm() 710void CalendarView::timerAlarm()
707{ 711{
708 //qDebug("CalendarView::timerAlarm() "); 712 //qDebug("CalendarView::timerAlarm() ");
709 computeAlarm(mAlarmNotification ); 713 computeAlarm(mAlarmNotification );
710} 714}
711 715
712void CalendarView::suspendAlarm() 716void CalendarView::suspendAlarm()
713{ 717{
714 //qDebug(" CalendarView::suspendAlarm() "); 718 //qDebug(" CalendarView::suspendAlarm() ");
715 computeAlarm(mSuspendAlarmNotification ); 719 computeAlarm(mSuspendAlarmNotification );
716 720
717} 721}
718 722
719void CalendarView::startAlarm( QString mess , QString filename) 723void CalendarView::startAlarm( QString mess , QString filename)
720{ 724{
721 725
722 topLevelWidget()->showNormal(); 726 topLevelWidget()->showNormal();
723 topLevelWidget()->setActiveWindow(); 727 topLevelWidget()->setActiveWindow();
724 topLevelWidget()->raise(); 728 topLevelWidget()->raise();
725 729
726 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 730 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
727 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 731 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
728 732
729} 733}
730 734
731void CalendarView::checkNextTimerAlarm() 735void CalendarView::checkNextTimerAlarm()
732{ 736{
733 mCalendar->checkAlarmForIncidence( 0, true ); 737 mCalendar->checkAlarmForIncidence( 0, true );
734} 738}
735 739
736void CalendarView::computeAlarm( QString msg ) 740void CalendarView::computeAlarm( QString msg )
737{ 741{
738 742
739 QString mess = msg; 743 QString mess = msg;
740 QString mAlarmMessage = mess.mid( 9 ); 744 QString mAlarmMessage = mess.mid( 9 );
741 QString filename = MainWindow::resourcePath(); 745 QString filename = MainWindow::resourcePath();
742 filename += "koalarm.wav"; 746 filename += "koalarm.wav";
743 QString tempfilename; 747 QString tempfilename;
744 if ( mess.left( 13 ) == "suspend_alarm") { 748 if ( mess.left( 13 ) == "suspend_alarm") {
745 bool error = false; 749 bool error = false;
746 int len = mess.mid( 13 ).find("+++"); 750 int len = mess.mid( 13 ).find("+++");
747 if ( len < 2 ) 751 if ( len < 2 )
748 error = true; 752 error = true;
749 else { 753 else {
750 tempfilename = mess.mid( 13, len ); 754 tempfilename = mess.mid( 13, len );
751 if ( !QFile::exists( tempfilename ) ) 755 if ( !QFile::exists( tempfilename ) )
752 error = true; 756 error = true;
753 } 757 }
754 if ( ! error ) { 758 if ( ! error ) {
755 filename = tempfilename; 759 filename = tempfilename;
756 } 760 }
757 mAlarmMessage = mess.mid( 13+len+3 ); 761 mAlarmMessage = mess.mid( 13+len+3 );
758 //qDebug("suspend file %s ",tempfilename.latin1() ); 762 //qDebug("suspend file %s ",tempfilename.latin1() );
759 startAlarm( mAlarmMessage, filename); 763 startAlarm( mAlarmMessage, filename);
760 return; 764 return;
761 } 765 }
762 if ( mess.left( 11 ) == "timer_alarm") { 766 if ( mess.left( 11 ) == "timer_alarm") {
763 //mTimerTime = 0; 767 //mTimerTime = 0;
764 startAlarm( mess.mid( 11 ), filename ); 768 startAlarm( mess.mid( 11 ), filename );
765 return; 769 return;
766 } 770 }
767 if ( mess.left( 10 ) == "proc_alarm") { 771 if ( mess.left( 10 ) == "proc_alarm") {
768 bool error = false; 772 bool error = false;
769 int len = mess.mid( 10 ).find("+++"); 773 int len = mess.mid( 10 ).find("+++");
770 if ( len < 2 ) 774 if ( len < 2 )
771 error = true; 775 error = true;
772 else { 776 else {
773 tempfilename = mess.mid( 10, len ); 777 tempfilename = mess.mid( 10, len );
774 if ( !QFile::exists( tempfilename ) ) 778 if ( !QFile::exists( tempfilename ) )
775 error = true; 779 error = true;
776 } 780 }
777 if ( error ) { 781 if ( error ) {
778 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 782 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
779 mAlarmMessage += mess.mid( 10+len+3+9 ); 783 mAlarmMessage += mess.mid( 10+len+3+9 );
780 } else { 784 } else {
781 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 785 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
782 //qDebug("-----system command %s ",tempfilename.latin1() ); 786 //qDebug("-----system command %s ",tempfilename.latin1() );
783#ifndef _WIN32_ 787#ifndef _WIN32_
784 if ( vfork () == 0 ) { 788 if ( vfork () == 0 ) {
785 execl ( tempfilename.latin1(), 0 ); 789 execl ( tempfilename.latin1(), 0 );
786 return; 790 return;
787 } 791 }
788#else 792#else
789 QProcess* p = new QProcess(); 793 QProcess* p = new QProcess();
790 p->addArgument( tempfilename.latin1() ); 794 p->addArgument( tempfilename.latin1() );
791 p->start(); 795 p->start();
792 return; 796 return;
793#endif 797#endif
794 798
795 return; 799 return;
796 } 800 }
797 801
798 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 802 //qDebug("+++++++system command %s ",tempfilename.latin1() );
799 } 803 }
800 if ( mess.left( 11 ) == "audio_alarm") { 804 if ( mess.left( 11 ) == "audio_alarm") {
801 bool error = false; 805 bool error = false;
802 int len = mess.mid( 11 ).find("+++"); 806 int len = mess.mid( 11 ).find("+++");
803 if ( len < 2 ) 807 if ( len < 2 )
804 error = true; 808 error = true;
805 else { 809 else {
806 tempfilename = mess.mid( 11, len ); 810 tempfilename = mess.mid( 11, len );
807 if ( !QFile::exists( tempfilename ) ) 811 if ( !QFile::exists( tempfilename ) )
808 error = true; 812 error = true;
809 } 813 }
810 if ( ! error ) { 814 if ( ! error ) {
811 filename = tempfilename; 815 filename = tempfilename;
812 } 816 }
813 mAlarmMessage = mess.mid( 11+len+3+9 ); 817 mAlarmMessage = mess.mid( 11+len+3+9 );
814 //qDebug("audio file command %s ",tempfilename.latin1() ); 818 //qDebug("audio file command %s ",tempfilename.latin1() );
815 } 819 }
816 if ( mess.left( 9 ) == "cal_alarm") { 820 if ( mess.left( 9 ) == "cal_alarm") {
817 mAlarmMessage = mess.mid( 9 ) ; 821 mAlarmMessage = mess.mid( 9 ) ;
818 } 822 }
819 823
820 startAlarm( mAlarmMessage, filename ); 824 startAlarm( mAlarmMessage, filename );
821 825
822 826
823} 827}
824 828
825void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 829void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
826{ 830{
827 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 831 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
828 832
829 mSuspendAlarmNotification = noti; 833 mSuspendAlarmNotification = noti;
830 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 834 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
831 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 835 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
832 mSuspendTimer->start( ms , true ); 836 mSuspendTimer->start( ms , true );
833 837
834} 838}
835 839
836void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 840void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
837{ 841{
838 mNextAlarmDateTime = qdt; 842 mNextAlarmDateTime = qdt;
839 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 843 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
840 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 844 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
841#ifndef DESKTOP_VERSION 845#ifndef DESKTOP_VERSION
842 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 846 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
843#endif 847#endif
844 return; 848 return;
845 } 849 }
846 int maxSec; 850 int maxSec;
847 //maxSec = 5; //testing only 851 //maxSec = 5; //testing only
848 maxSec = 86400+3600; // one day+1hour 852 maxSec = 86400+3600; // one day+1hour
849 mAlarmNotification = noti; 853 mAlarmNotification = noti;
850 int sec = QDateTime::currentDateTime().secsTo( qdt ); 854 int sec = QDateTime::currentDateTime().secsTo( qdt );
851 if ( sec > maxSec ) { 855 if ( sec > maxSec ) {
852 mRecheckAlarmTimer->start( maxSec * 1000 ); 856 mRecheckAlarmTimer->start( maxSec * 1000 );
853 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 857 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
854 return; 858 return;
855 } else { 859 } else {
856 mRecheckAlarmTimer->stop(); 860 mRecheckAlarmTimer->stop();
857 } 861 }
858 //qDebug("Alarm timer started with secs: %d ", sec); 862 //qDebug("Alarm timer started with secs: %d ", sec);
859 mAlarmTimer->start( sec *1000 , true ); 863 mAlarmTimer->start( sec *1000 , true );
860 864
861} 865}
862// called by mRecheckAlarmTimer to get next alarm 866// called by mRecheckAlarmTimer to get next alarm
863// we need this, because a QTimer has only a max range of 25 days 867// we need this, because a QTimer has only a max range of 25 days
864void CalendarView::recheckTimerAlarm() 868void CalendarView::recheckTimerAlarm()
865{ 869{
866 mAlarmTimer->stop(); 870 mAlarmTimer->stop();
867 mRecheckAlarmTimer->stop(); 871 mRecheckAlarmTimer->stop();
868 mCalendar->checkAlarmForIncidence( 0, true ); 872 mCalendar->checkAlarmForIncidence( 0, true );
869} 873}
870void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 874void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
871{ 875{
872 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 876 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
873 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 877 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
874#ifndef DESKTOP_VERSION 878#ifndef DESKTOP_VERSION
875 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 879 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
876#endif 880#endif
877 return; 881 return;
878 } 882 }
879 mAlarmTimer->stop(); 883 mAlarmTimer->stop();
880} 884}
881void CalendarView::selectWeekNum ( int num ) 885void CalendarView::selectWeekNum ( int num )
882{ 886{
883 dateNavigator()->blockSignals( true ); 887 dateNavigator()->blockSignals( true );
884 dateNavigator()->selectWeek( num ); 888 dateNavigator()->selectWeek( num );
885 dateNavigator()->blockSignals( false ); 889 dateNavigator()->blockSignals( false );
886 mViewManager->showWeekView(); 890 mViewManager->showWeekView();
887} 891}
888KOViewManager *CalendarView::viewManager() 892KOViewManager *CalendarView::viewManager()
889{ 893{
890 return mViewManager; 894 return mViewManager;
891} 895}
892 896
893KODialogManager *CalendarView::dialogManager() 897KODialogManager *CalendarView::dialogManager()
894{ 898{
895 return mDialogManager; 899 return mDialogManager;
896} 900}
897 901
898QDate CalendarView::startDate() 902QDate CalendarView::startDate()
899{ 903{
900 DateList dates = mNavigator->selectedDates(); 904 DateList dates = mNavigator->selectedDates();
901 905
902 return dates.first(); 906 return dates.first();
903} 907}
904 908
905QDate CalendarView::endDate() 909QDate CalendarView::endDate()
906{ 910{
907 DateList dates = mNavigator->selectedDates(); 911 DateList dates = mNavigator->selectedDates();
908 912
909 return dates.last(); 913 return dates.last();
910} 914}
911 915
912 916
913void CalendarView::createPrinter() 917void CalendarView::createPrinter()
914{ 918{
915#ifndef KORG_NOPRINTER 919#ifndef KORG_NOPRINTER
916 if (!mCalPrinter) { 920 if (!mCalPrinter) {
917 mCalPrinter = new CalPrinter(this, mCalendar); 921 mCalPrinter = new CalPrinter(this, mCalendar);
918 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 922 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
919 } 923 }
920#endif 924#endif
921} 925}
922 926
923 927
924//KOPrefs::instance()->mWriteBackFile 928//KOPrefs::instance()->mWriteBackFile
925//KOPrefs::instance()->mWriteBackExistingOnly 929//KOPrefs::instance()->mWriteBackExistingOnly
926 930
927// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 931// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
928// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 932// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
929// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 933// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
930// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 934// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
931// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 935// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
932// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 936// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
933 937
934int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 938int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
935{ 939{
936 940
937 // 0 equal 941 // 0 equal
938 // 1 take local 942 // 1 take local
939 // 2 take remote 943 // 2 take remote
940 // 3 cancel 944 // 3 cancel
941 QDateTime lastSync = mLastCalendarSync; 945 QDateTime lastSync = mLastCalendarSync;
942 QDateTime localMod = local->lastModified(); 946 QDateTime localMod = local->lastModified();
943 QDateTime remoteMod = remote->lastModified(); 947 QDateTime remoteMod = remote->lastModified();
944 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 948 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
945 bool remCh, locCh; 949 bool remCh, locCh;
946 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 950 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
947 //if ( remCh ) 951 //if ( remCh )
948 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 952 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
949 locCh = ( localMod > mLastCalendarSync ); 953 locCh = ( localMod > mLastCalendarSync );
950 if ( !remCh && ! locCh ) { 954 if ( !remCh && ! locCh ) {
951 //qDebug("both not changed "); 955 //qDebug("both not changed ");
952 lastSync = localMod.addDays(1); 956 lastSync = localMod.addDays(1);
953 if ( mode <= SYNC_PREF_ASK ) 957 if ( mode <= SYNC_PREF_ASK )
954 return 0; 958 return 0;
955 } else { 959 } else {
956 if ( locCh ) { 960 if ( locCh ) {
957 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 961 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
958 lastSync = localMod.addDays( -1 ); 962 lastSync = localMod.addDays( -1 );
959 if ( !remCh ) 963 if ( !remCh )
960 remoteMod = ( lastSync.addDays( -1 ) ); 964 remoteMod = ( lastSync.addDays( -1 ) );
961 } else { 965 } else {
962 //qDebug(" not loc changed "); 966 //qDebug(" not loc changed ");
963 lastSync = localMod.addDays( 1 ); 967 lastSync = localMod.addDays( 1 );
964 if ( remCh ) 968 if ( remCh )
965 remoteMod =( lastSync.addDays( 1 ) ); 969 remoteMod =( lastSync.addDays( 1 ) );
966 970
967 } 971 }
968 } 972 }
969 full = true; 973 full = true;
970 if ( mode < SYNC_PREF_ASK ) 974 if ( mode < SYNC_PREF_ASK )
971 mode = SYNC_PREF_ASK; 975 mode = SYNC_PREF_ASK;
972 } else { 976 } else {
973 if ( localMod == remoteMod ) 977 if ( localMod == remoteMod )
974 // if ( local->revision() == remote->revision() ) 978 // if ( local->revision() == remote->revision() )
975 return 0; 979 return 0;
976 980
977 } 981 }
978 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 982 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
979 983
980 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 984 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
981 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 985 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
982 //full = true; //debug only 986 //full = true; //debug only
983 if ( full ) { 987 if ( full ) {
984 bool equ = false; 988 bool equ = false;
985 if ( local->typeID() == eventID ) { 989 if ( local->typeID() == eventID ) {
986 equ = (*((Event*) local) == *((Event*) remote)); 990 equ = (*((Event*) local) == *((Event*) remote));
987 } 991 }
988 else if ( local->typeID() == todoID ) 992 else if ( local->typeID() == todoID )
989 equ = (*((Todo*) local) == (*(Todo*) remote)); 993 equ = (*((Todo*) local) == (*(Todo*) remote));
990 else if ( local->typeID() == journalID ) 994 else if ( local->typeID() == journalID )
991 equ = (*((Journal*) local) == *((Journal*) remote)); 995 equ = (*((Journal*) local) == *((Journal*) remote));
992 if ( equ ) { 996 if ( equ ) {
993 //qDebug("equal "); 997 //qDebug("equal ");
994 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
995 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 999 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
996 } 1000 }
997 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1001 if ( mode < SYNC_PREF_FORCE_LOCAL )
998 return 0; 1002 return 0;
999 1003
1000 }//else //debug only 1004 }//else //debug only
1001 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1005 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1002 } 1006 }
1003 int result; 1007 int result;
1004 bool localIsNew; 1008 bool localIsNew;
1005 //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() ); 1009 //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() );
1006 1010
1007 1011
1008 // ************************************************ 1012 // ************************************************
1009 // ************************************************ 1013 // ************************************************
1010 // ************************************************ 1014 // ************************************************
1011 // We may have that lastSync > remoteMod AND lastSync > localMod 1015 // We may have that lastSync > remoteMod AND lastSync > localMod
1012 // BUT remoteMod != localMod 1016 // BUT remoteMod != localMod
1013 1017
1014 1018
1015 if ( full && mode < SYNC_PREF_NEWEST ) 1019 if ( full && mode < SYNC_PREF_NEWEST )
1016 mode = SYNC_PREF_ASK; 1020 mode = SYNC_PREF_ASK;
1017 1021
1018 switch( mode ) { 1022 switch( mode ) {
1019 case SYNC_PREF_LOCAL: 1023 case SYNC_PREF_LOCAL:
1020 if ( lastSync > remoteMod ) 1024 if ( lastSync > remoteMod )
1021 return 1; 1025 return 1;
1022 if ( lastSync > localMod ) 1026 if ( lastSync > localMod )
1023 return 2; 1027 return 2;
1024 return 1; 1028 return 1;
1025 break; 1029 break;
1026 case SYNC_PREF_REMOTE: 1030 case SYNC_PREF_REMOTE:
1027 if ( lastSync > localMod ) 1031 if ( lastSync > localMod )
1028 return 2; 1032 return 2;
1029 if ( lastSync > remoteMod ) 1033 if ( lastSync > remoteMod )
1030 return 1; 1034 return 1;
1031 return 2; 1035 return 2;
1032 break; 1036 break;
1033 case SYNC_PREF_NEWEST: 1037 case SYNC_PREF_NEWEST:
1034 if ( localMod >= remoteMod ) 1038 if ( localMod >= remoteMod )
1035 return 1; 1039 return 1;
1036 else 1040 else
1037 return 2; 1041 return 2;
1038 break; 1042 break;
1039 case SYNC_PREF_ASK: 1043 case SYNC_PREF_ASK:
1040 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1044 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1041 if ( lastSync > remoteMod && lastSync > localMod) 1045 if ( lastSync > remoteMod && lastSync > localMod)
1042 return 0; 1046 return 0;
1043 if ( lastSync > remoteMod ) 1047 if ( lastSync > remoteMod )
1044 return 1; 1048 return 1;
1045 if ( lastSync > localMod ) 1049 if ( lastSync > localMod )
1046 return 2; 1050 return 2;
1047 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1051 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1048 localIsNew = localMod >= remoteMod; 1052 localIsNew = localMod >= remoteMod;
1049 if ( localIsNew ) 1053 if ( localIsNew )
1050 getEventViewerDialog()->setColorMode( 1 ); 1054 getEventViewerDialog()->setColorMode( 1 );
1051 else 1055 else
1052 getEventViewerDialog()->setColorMode( 2 ); 1056 getEventViewerDialog()->setColorMode( 2 );
1053 getEventViewerDialog()->setIncidence(local); 1057 getEventViewerDialog()->setIncidence(local);
1054 if ( localIsNew ) 1058 if ( localIsNew )
1055 getEventViewerDialog()->setColorMode( 2 ); 1059 getEventViewerDialog()->setColorMode( 2 );
1056 else 1060 else
1057 getEventViewerDialog()->setColorMode( 1 ); 1061 getEventViewerDialog()->setColorMode( 1 );
1058 getEventViewerDialog()->addIncidence(remote); 1062 getEventViewerDialog()->addIncidence(remote);
1059 getEventViewerDialog()->setColorMode( 0 ); 1063 getEventViewerDialog()->setColorMode( 0 );
1060 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1064 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1061 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1065 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1062 getEventViewerDialog()->showMe(); 1066 getEventViewerDialog()->showMe();
1063 result = getEventViewerDialog()->executeS( localIsNew ); 1067 result = getEventViewerDialog()->executeS( localIsNew );
1064 return result; 1068 return result;
1065 1069
1066 break; 1070 break;
1067 case SYNC_PREF_FORCE_LOCAL: 1071 case SYNC_PREF_FORCE_LOCAL:
1068 return 1; 1072 return 1;
1069 break; 1073 break;
1070 case SYNC_PREF_FORCE_REMOTE: 1074 case SYNC_PREF_FORCE_REMOTE:
1071 return 2; 1075 return 2;
1072 break; 1076 break;
1073 1077
1074 default: 1078 default:
1075 // SYNC_PREF_TAKE_BOTH not implemented 1079 // SYNC_PREF_TAKE_BOTH not implemented
1076 break; 1080 break;
1077 } 1081 }
1078 return 0; 1082 return 0;
1079} 1083}
1080Event* CalendarView::getLastSyncEvent() 1084Event* CalendarView::getLastSyncEvent()
1081{ 1085{
1082 Event* lse; 1086 Event* lse;
1083 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1087 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1084 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1088 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1085 if (!lse) { 1089 if (!lse) {
1086 lse = new Event(); 1090 lse = new Event();
1087 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1091 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1088 QString sum = ""; 1092 QString sum = "";
1089 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1093 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1090 sum = "E: "; 1094 sum = "E: ";
1091 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1095 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1092 lse->setDtStart( mLastCalendarSync ); 1096 lse->setDtStart( mLastCalendarSync );
1093 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1097 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1094 lse->setCategories( i18n("SyncEvent") ); 1098 lse->setCategories( i18n("SyncEvent") );
1095 lse->setReadOnly( true ); 1099 lse->setReadOnly( true );
1096 mCalendar->addEvent( lse ); 1100 mCalendar->addEvent( lse );
1097 } 1101 }
1098 1102
1099 return lse; 1103 return lse;
1100 1104
1101} 1105}
1102 1106
1103// we check, if the to delete event has a id for a profile 1107// we check, if the to delete event has a id for a profile
1104// if yes, we set this id in the profile to delete 1108// if yes, we set this id in the profile to delete
1105void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1109void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1106{ 1110{
1107 if ( lastSync.count() == 0 ) { 1111 if ( lastSync.count() == 0 ) {
1108 //qDebug(" lastSync.count() == 0"); 1112 //qDebug(" lastSync.count() == 0");
1109 return; 1113 return;
1110 } 1114 }
1111 if ( toDelete->typeID() == journalID ) 1115 if ( toDelete->typeID() == journalID )
1112 return; 1116 return;
1113 1117
1114 Event* eve = lastSync.first(); 1118 Event* eve = lastSync.first();
1115 1119
1116 while ( eve ) { 1120 while ( eve ) {
1117 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1121 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1118 if ( !id.isEmpty() ) { 1122 if ( !id.isEmpty() ) {
1119 QString des = eve->description(); 1123 QString des = eve->description();
1120 QString pref = "e"; 1124 QString pref = "e";
1121 if ( toDelete->typeID() == todoID ) 1125 if ( toDelete->typeID() == todoID )
1122 pref = "t"; 1126 pref = "t";
1123 des += pref+ id + ","; 1127 des += pref+ id + ",";
1124 eve->setReadOnly( false ); 1128 eve->setReadOnly( false );
1125 eve->setDescription( des ); 1129 eve->setDescription( des );
1126 //qDebug("setdes %s ", des.latin1()); 1130 //qDebug("setdes %s ", des.latin1());
1127 eve->setReadOnly( true ); 1131 eve->setReadOnly( true );
1128 } 1132 }
1129 eve = lastSync.next(); 1133 eve = lastSync.next();
1130 } 1134 }
1131 1135
1132} 1136}
1133void CalendarView::checkExternalId( Incidence * inc ) 1137void CalendarView::checkExternalId( Incidence * inc )
1134{ 1138{
1135 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1139 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1136 checkExternSyncEvent( lastSync, inc ); 1140 checkExternSyncEvent( lastSync, inc );
1137 1141
1138} 1142}
1139bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1143bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1140{ 1144{
1141 bool syncOK = true; 1145 bool syncOK = true;
1142 int addedEvent = 0; 1146 int addedEvent = 0;
1143 int addedEventR = 0; 1147 int addedEventR = 0;
1144 int deletedEventR = 0; 1148 int deletedEventR = 0;
1145 int deletedEventL = 0; 1149 int deletedEventL = 0;
1146 int changedLocal = 0; 1150 int changedLocal = 0;
1147 int changedRemote = 0; 1151 int changedRemote = 0;
1148 int filteredIN = 0; 1152 int filteredIN = 0;
1149 int filteredOUT = 0; 1153 int filteredOUT = 0;
1150 //QPtrList<Event> el = local->rawEvents(); 1154 //QPtrList<Event> el = local->rawEvents();
1151 Event* eventR; 1155 Event* eventR;
1152 QString uid; 1156 QString uid;
1153 int take; 1157 int take;
1154 Event* eventL; 1158 Event* eventL;
1155 Event* eventRSync; 1159 Event* eventRSync;
1156 Event* eventLSync; 1160 Event* eventLSync;
1157 clearAllViews(); 1161 clearAllViews();
1158 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1162 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1159 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1163 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1160 bool fullDateRange = false; 1164 bool fullDateRange = false;
1161 local->resetTempSyncStat(); 1165 local->resetTempSyncStat();
1162 mLastCalendarSync = QDateTime::currentDateTime(); 1166 mLastCalendarSync = QDateTime::currentDateTime();
1163 if ( mSyncManager->syncWithDesktop() ) { 1167 if ( mSyncManager->syncWithDesktop() ) {
1164 remote->resetPilotStat(1); 1168 remote->resetPilotStat(1);
1165 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1169 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1166 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1170 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1167 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1171 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1168 } else { 1172 } else {
1169 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1173 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1170 } 1174 }
1171 } 1175 }
1172 QDateTime modifiedCalendar = mLastCalendarSync; 1176 QDateTime modifiedCalendar = mLastCalendarSync;
1173 eventLSync = getLastSyncEvent(); 1177 eventLSync = getLastSyncEvent();
1174 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1178 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1175 if ( eventR ) { 1179 if ( eventR ) {
1176 eventRSync = (Event*) eventR->clone(); 1180 eventRSync = (Event*) eventR->clone();
1177 remote->deleteEvent(eventR ); 1181 remote->deleteEvent(eventR );
1178 1182
1179 } else { 1183 } else {
1180 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1184 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1181 eventRSync = (Event*)eventLSync->clone(); 1185 eventRSync = (Event*)eventLSync->clone();
1182 } else { 1186 } else {
1183 fullDateRange = true; 1187 fullDateRange = true;
1184 eventRSync = new Event(); 1188 eventRSync = new Event();
1185 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1189 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1186 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1190 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1187 eventRSync->setDtStart( mLastCalendarSync ); 1191 eventRSync->setDtStart( mLastCalendarSync );
1188 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1192 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1189 eventRSync->setCategories( i18n("SyncEvent") ); 1193 eventRSync->setCategories( i18n("SyncEvent") );
1190 } 1194 }
1191 } 1195 }
1192 if ( eventLSync->dtStart() == mLastCalendarSync ) 1196 if ( eventLSync->dtStart() == mLastCalendarSync )
1193 fullDateRange = true; 1197 fullDateRange = true;
1194 1198
1195 if ( ! fullDateRange ) { 1199 if ( ! fullDateRange ) {
1196 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1200 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1197 1201
1198 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1202 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1199 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1203 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1200 fullDateRange = true; 1204 fullDateRange = true;
1201 } 1205 }
1202 } 1206 }
1203 if ( mSyncManager->syncWithDesktop() ) { 1207 if ( mSyncManager->syncWithDesktop() ) {
1204 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1208 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1205 } 1209 }
1206 if ( fullDateRange ) 1210 if ( fullDateRange )
1207 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1211 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1208 else 1212 else
1209 mLastCalendarSync = eventLSync->dtStart(); 1213 mLastCalendarSync = eventLSync->dtStart();
1210 // for resyncing if own file has changed 1214 // for resyncing if own file has changed
1211 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1215 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1212 mLastCalendarSync = loadedFileVersion; 1216 mLastCalendarSync = loadedFileVersion;
1213 //qDebug("setting mLastCalendarSync "); 1217 //qDebug("setting mLastCalendarSync ");
1214 } 1218 }
1215 //qDebug("*************************** "); 1219 //qDebug("*************************** ");
1216 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1220 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1217 QPtrList<Incidence> er = remote->rawIncidences(); 1221 QPtrList<Incidence> er = remote->rawIncidences();
1218 Incidence* inR = er.first(); 1222 Incidence* inR = er.first();
1219 Incidence* inL; 1223 Incidence* inL;
1220 QProgressBar bar( er.count(),0 ); 1224 QProgressBar bar( er.count(),0 );
1221 bar.setCaption (i18n("Syncing - close to abort!") ); 1225 bar.setCaption (i18n("Syncing - close to abort!") );
1222 1226
1223 // ************** setting up filter ************* 1227 // ************** setting up filter *************
1224 CalFilter *filterIN = 0; 1228 CalFilter *filterIN = 0;
1225 CalFilter *filterOUT = 0; 1229 CalFilter *filterOUT = 0;
1226 CalFilter *filter = mFilters.first(); 1230 CalFilter *filter = mFilters.first();
1227 while(filter) { 1231 while(filter) {
1228 if ( filter->name() == mSyncManager->mFilterInCal ) 1232 if ( filter->name() == mSyncManager->mFilterInCal )
1229 filterIN = filter; 1233 filterIN = filter;
1230 if ( filter->name() == mSyncManager->mFilterOutCal ) 1234 if ( filter->name() == mSyncManager->mFilterOutCal )
1231 filterOUT = filter; 1235 filterOUT = filter;
1232 filter = mFilters.next(); 1236 filter = mFilters.next();
1233 } 1237 }
1234 int w = 300; 1238 int w = 300;
1235 if ( QApplication::desktop()->width() < 320 ) 1239 if ( QApplication::desktop()->width() < 320 )
1236 w = 220; 1240 w = 220;
1237 int h = bar.sizeHint().height() ; 1241 int h = bar.sizeHint().height() ;
1238 int dw = QApplication::desktop()->width(); 1242 int dw = QApplication::desktop()->width();
1239 int dh = QApplication::desktop()->height(); 1243 int dh = QApplication::desktop()->height();
1240 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1244 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1241 bar.show(); 1245 bar.show();
1242 int modulo = (er.count()/10)+1; 1246 int modulo = (er.count()/10)+1;
1243 int incCounter = 0; 1247 int incCounter = 0;
1244 while ( inR ) { 1248 while ( inR ) {
1245 if ( ! bar.isVisible() ) 1249 if ( ! bar.isVisible() )
1246 return false; 1250 return false;
1247 if ( incCounter % modulo == 0 ) 1251 if ( incCounter % modulo == 0 )
1248 bar.setProgress( incCounter ); 1252 bar.setProgress( incCounter );
1249 ++incCounter; 1253 ++incCounter;
1250 uid = inR->uid(); 1254 uid = inR->uid();
1251 bool skipIncidence = false; 1255 bool skipIncidence = false;
1252 if ( uid.left(15) == QString("last-syncEvent-") ) 1256 if ( uid.left(15) == QString("last-syncEvent-") )
1253 skipIncidence = true; 1257 skipIncidence = true;
1254 QString idS; 1258 QString idS;
1255 qApp->processEvents(); 1259 qApp->processEvents();
1256 if ( !skipIncidence ) { 1260 if ( !skipIncidence ) {
1257 inL = local->incidence( uid ); 1261 inL = local->incidence( uid );
1258 if ( inL ) { // maybe conflict - same uid in both calendars 1262 if ( inL ) { // maybe conflict - same uid in both calendars
1259 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1263 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1260 //qDebug("take %d %s ", take, inL->summary().latin1()); 1264 //qDebug("take %d %s ", take, inL->summary().latin1());
1261 if ( take == 3 ) 1265 if ( take == 3 )
1262 return false; 1266 return false;
1263 if ( take == 1 ) {// take local ********************** 1267 if ( take == 1 ) {// take local **********************
1264 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1268 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1265 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1269 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1266 else 1270 else
1267 idS = inR->IDStr(); 1271 idS = inR->IDStr();
1268 remote->deleteIncidence( inR ); 1272 remote->deleteIncidence( inR );
1269 inR = inL->clone(); 1273 inR = inL->clone();
1270 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1274 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1271 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1275 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1272 inR->setIDStr( idS ); 1276 inR->setIDStr( idS );
1273 remote->addIncidence( inR ); 1277 remote->addIncidence( inR );
1274 if ( mSyncManager->syncWithDesktop() ) 1278 if ( mSyncManager->syncWithDesktop() )
1275 inR->setPilotId( 2 ); 1279 inR->setPilotId( 2 );
1276 ++changedRemote; 1280 ++changedRemote;
1277 } else {// take remote ********************** 1281 } else {// take remote **********************
1278 idS = inL->IDStr(); 1282 idS = inL->IDStr();
1279 int pid = inL->pilotId(); 1283 int pid = inL->pilotId();
1280 local->deleteIncidence( inL ); 1284 local->deleteIncidence( inL );
1281 inL = inR->clone(); 1285 inL = inR->clone();
1282 if ( mSyncManager->syncWithDesktop() ) 1286 if ( mSyncManager->syncWithDesktop() )
1283 inL->setPilotId( pid ); 1287 inL->setPilotId( pid );
1284 inL->setIDStr( idS ); 1288 inL->setIDStr( idS );
1285 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1289 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1286 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1290 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1287 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1291 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1288 } 1292 }
1289 local->addIncidence( inL ); 1293 local->addIncidence( inL );
1290 ++changedLocal; 1294 ++changedLocal;
1291 } 1295 }
1292 } 1296 }
1293 } else { // no conflict ********** add or delete remote 1297 } else { // no conflict ********** add or delete remote
1294 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1298 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1295 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1299 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1296 QString des = eventLSync->description(); 1300 QString des = eventLSync->description();
1297 QString pref = "e"; 1301 QString pref = "e";
1298 if ( inR->typeID() == todoID ) 1302 if ( inR->typeID() == todoID )
1299 pref = "t"; 1303 pref = "t";
1300 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1304 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1301 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1305 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1302 //remote->deleteIncidence( inR ); 1306 //remote->deleteIncidence( inR );
1303 ++deletedEventR; 1307 ++deletedEventR;
1304 } else { 1308 } else {
1305 inR->setLastModified( modifiedCalendar ); 1309 inR->setLastModified( modifiedCalendar );
1306 inL = inR->clone(); 1310 inL = inR->clone();
1307 inL->setIDStr( ":" ); 1311 inL->setIDStr( ":" );
1308 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1312 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1309 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1313 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1310 local->addIncidence( inL ); 1314 local->addIncidence( inL );
1311 ++addedEvent; 1315 ++addedEvent;
1312 1316
1313 } 1317 }
1314 } else { 1318 } else {
1315 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1319 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1316 inR->setLastModified( modifiedCalendar ); 1320 inR->setLastModified( modifiedCalendar );
1317 inL = inR->clone(); 1321 inL = inR->clone();
1318 inL->setIDStr( ":" ); 1322 inL->setIDStr( ":" );
1319 local->addIncidence( inL ); 1323 local->addIncidence( inL );
1320 ++addedEvent; 1324 ++addedEvent;
1321 1325
1322 } else { 1326 } else {
1323 checkExternSyncEvent(eventRSyncSharp, inR); 1327 checkExternSyncEvent(eventRSyncSharp, inR);
1324 remote->deleteIncidence( inR ); 1328 remote->deleteIncidence( inR );
1325 ++deletedEventR; 1329 ++deletedEventR;
1326 } 1330 }
1327 } 1331 }
1328 } else { 1332 } else {
1329 ++filteredIN; 1333 ++filteredIN;
1330 } 1334 }
1331 } 1335 }
1332 } 1336 }
1333 inR = er.next(); 1337 inR = er.next();
1334 } 1338 }
1335 QPtrList<Incidence> el = local->rawIncidences(); 1339 QPtrList<Incidence> el = local->rawIncidences();
1336 inL = el.first(); 1340 inL = el.first();
1337 modulo = (el.count()/10)+1; 1341 modulo = (el.count()/10)+1;
1338 bar.setCaption (i18n("Add / remove events") ); 1342 bar.setCaption (i18n("Add / remove events") );
1339 bar.setTotalSteps ( el.count() ) ; 1343 bar.setTotalSteps ( el.count() ) ;
1340 bar.show(); 1344 bar.show();
1341 incCounter = 0; 1345 incCounter = 0;
1342 1346
1343 while ( inL ) { 1347 while ( inL ) {
1344 1348
1345 qApp->processEvents(); 1349 qApp->processEvents();
1346 if ( ! bar.isVisible() ) 1350 if ( ! bar.isVisible() )
1347 return false; 1351 return false;
1348 if ( incCounter % modulo == 0 ) 1352 if ( incCounter % modulo == 0 )
1349 bar.setProgress( incCounter ); 1353 bar.setProgress( incCounter );
1350 ++incCounter; 1354 ++incCounter;
1351 uid = inL->uid(); 1355 uid = inL->uid();
1352 bool skipIncidence = false; 1356 bool skipIncidence = false;
1353 if ( uid.left(15) == QString("last-syncEvent-") ) 1357 if ( uid.left(15) == QString("last-syncEvent-") )
1354 skipIncidence = true; 1358 skipIncidence = true;
1355 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1359 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1356 skipIncidence = true; 1360 skipIncidence = true;
1357 if ( !skipIncidence ) { 1361 if ( !skipIncidence ) {
1358 inR = remote->incidence( uid ); 1362 inR = remote->incidence( uid );
1359 if ( ! inR ) { 1363 if ( ! inR ) {
1360 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1364 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1361 // no conflict ********** add or delete local 1365 // no conflict ********** add or delete local
1362 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1366 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1363 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1367 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1364 checkExternSyncEvent(eventLSyncSharp, inL); 1368 checkExternSyncEvent(eventLSyncSharp, inL);
1365 local->deleteIncidence( inL ); 1369 local->deleteIncidence( inL );
1366 ++deletedEventL; 1370 ++deletedEventL;
1367 } else { 1371 } else {
1368 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1372 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1369 inL->removeID(mCurrentSyncDevice ); 1373 inL->removeID(mCurrentSyncDevice );
1370 ++addedEventR; 1374 ++addedEventR;
1371 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1375 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1372 inL->setLastModified( modifiedCalendar ); 1376 inL->setLastModified( modifiedCalendar );
1373 inR = inL->clone(); 1377 inR = inL->clone();
1374 inR->setIDStr( ":" ); 1378 inR->setIDStr( ":" );
1375 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1379 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1376 remote->addIncidence( inR ); 1380 remote->addIncidence( inR );
1377 } 1381 }
1378 } 1382 }
1379 } else { 1383 } else {
1380 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1384 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1381 checkExternSyncEvent(eventLSyncSharp, inL); 1385 checkExternSyncEvent(eventLSyncSharp, inL);
1382 local->deleteIncidence( inL ); 1386 local->deleteIncidence( inL );
1383 ++deletedEventL; 1387 ++deletedEventL;
1384 } else { 1388 } else {
1385 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1389 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1386 ++addedEventR; 1390 ++addedEventR;
1387 inL->setLastModified( modifiedCalendar ); 1391 inL->setLastModified( modifiedCalendar );
1388 inR = inL->clone(); 1392 inR = inL->clone();
1389 inR->setIDStr( ":" ); 1393 inR->setIDStr( ":" );
1390 remote->addIncidence( inR ); 1394 remote->addIncidence( inR );
1391 } 1395 }
1392 } 1396 }
1393 } 1397 }
1394 } else { 1398 } else {
1395 ++filteredOUT; 1399 ++filteredOUT;
1396 } 1400 }
1397 } 1401 }
1398 } 1402 }
1399 inL = el.next(); 1403 inL = el.next();
1400 } 1404 }
1401 int delFut = 0; 1405 int delFut = 0;
1402 int remRem = 0; 1406 int remRem = 0;
1403 if ( mSyncManager->mWriteBackInFuture ) { 1407 if ( mSyncManager->mWriteBackInFuture ) {
1404 er = remote->rawIncidences(); 1408 er = remote->rawIncidences();
1405 remRem = er.count(); 1409 remRem = er.count();
1406 inR = er.first(); 1410 inR = er.first();
1407 QDateTime dt; 1411 QDateTime dt;
1408 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1412 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1409 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1413 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1410 while ( inR ) { 1414 while ( inR ) {
1411 if ( inR->typeID() == todoID ) { 1415 if ( inR->typeID() == todoID ) {
1412 Todo * t = (Todo*)inR; 1416 Todo * t = (Todo*)inR;
1413 if ( t->hasDueDate() ) 1417 if ( t->hasDueDate() )
1414 dt = t->dtDue(); 1418 dt = t->dtDue();
1415 else 1419 else
1416 dt = cur.addSecs( 62 ); 1420 dt = cur.addSecs( 62 );
1417 } 1421 }
1418 else if (inR->typeID() == eventID ) { 1422 else if (inR->typeID() == eventID ) {
1419 bool ok; 1423 bool ok;
1420 dt = inR->getNextOccurence( cur, &ok ); 1424 dt = inR->getNextOccurence( cur, &ok );
1421 if ( !ok ) 1425 if ( !ok )
1422 dt = cur.addSecs( -62 ); 1426 dt = cur.addSecs( -62 );
1423 } 1427 }
1424 else 1428 else
1425 dt = inR->dtStart(); 1429 dt = inR->dtStart();
1426 if ( dt < cur || dt > end ) { 1430 if ( dt < cur || dt > end ) {
1427 remote->deleteIncidence( inR ); 1431 remote->deleteIncidence( inR );
1428 ++delFut; 1432 ++delFut;
1429 } 1433 }
1430 inR = er.next(); 1434 inR = er.next();
1431 } 1435 }
1432 } 1436 }
1433 bar.hide(); 1437 bar.hide();
1434 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1438 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1435 eventLSync->setReadOnly( false ); 1439 eventLSync->setReadOnly( false );
1436 eventLSync->setDtStart( mLastCalendarSync ); 1440 eventLSync->setDtStart( mLastCalendarSync );
1437 eventRSync->setDtStart( mLastCalendarSync ); 1441 eventRSync->setDtStart( mLastCalendarSync );
1438 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1442 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1439 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1443 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1440 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1444 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1441 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1445 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1442 eventLSync->setReadOnly( true ); 1446 eventLSync->setReadOnly( true );
1443 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1447 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1444 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1448 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1445 remote->addEvent( eventRSync ); 1449 remote->addEvent( eventRSync );
1446 else 1450 else
1447 delete eventRSync; 1451 delete eventRSync;
1448 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1452 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1449 QString mes; 1453 QString mes;
1450 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 ); 1454 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 );
1451 QString delmess; 1455 QString delmess;
1452 if ( delFut ) { 1456 if ( delFut ) {
1453 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); 1457 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);
1454 mes += delmess; 1458 mes += delmess;
1455 } 1459 }
1456 mes = i18n("Local calendar changed!\n") +mes; 1460 mes = i18n("Local calendar changed!\n") +mes;
1457 mCalendar->checkAlarmForIncidence( 0, true ); 1461 mCalendar->checkAlarmForIncidence( 0, true );
1458 qDebug( mes ); 1462 qDebug( mes );
1459 if ( mSyncManager->mShowSyncSummary ) { 1463 if ( mSyncManager->mShowSyncSummary ) {
1460 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1464 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1461 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1465 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1462 qDebug("KO: WB cancelled "); 1466 qDebug("KO: WB cancelled ");
1463 mSyncManager->mWriteBackFile = false; 1467 mSyncManager->mWriteBackFile = false;
1464 return syncOK; 1468 return syncOK;
1465 } 1469 }
1466 } 1470 }
1467 return syncOK; 1471 return syncOK;
1468} 1472}
1469 1473
1470void CalendarView::setSyncDevice( QString s ) 1474void CalendarView::setSyncDevice( QString s )
1471{ 1475{
1472 mCurrentSyncDevice= s; 1476 mCurrentSyncDevice= s;
1473} 1477}
1474void CalendarView::setSyncName( QString s ) 1478void CalendarView::setSyncName( QString s )
1475{ 1479{
1476 mCurrentSyncName= s; 1480 mCurrentSyncName= s;
1477} 1481}
1478bool CalendarView::syncCalendar(QString filename, int mode) 1482bool CalendarView::syncCalendar(QString filename, int mode)
1479{ 1483{
1480 //qDebug("syncCalendar %s ", filename.latin1()); 1484 //qDebug("syncCalendar %s ", filename.latin1());
1481 mGlobalSyncMode = SYNC_MODE_NORMAL; 1485 mGlobalSyncMode = SYNC_MODE_NORMAL;
1482 CalendarLocal* calendar = new CalendarLocal(); 1486 CalendarLocal* calendar = new CalendarLocal();
1483 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1487 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1484 FileStorage* storage = new FileStorage( calendar ); 1488 FileStorage* storage = new FileStorage( calendar );
1485 bool syncOK = false; 1489 bool syncOK = false;
1486 storage->setFileName( filename ); 1490 storage->setFileName( filename );
1487 // qDebug("loading ... "); 1491 // qDebug("loading ... ");
1488 if ( storage->load() ) { 1492 if ( storage->load() ) {
1489 getEventViewerDialog()->setSyncMode( true ); 1493 getEventViewerDialog()->setSyncMode( true );
1490 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1494 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1491 getEventViewerDialog()->setSyncMode( false ); 1495 getEventViewerDialog()->setSyncMode( false );
1492 if ( syncOK ) { 1496 if ( syncOK ) {
1493 if ( mSyncManager->mWriteBackFile ) 1497 if ( mSyncManager->mWriteBackFile )
1494 { 1498 {
1495 storage->setSaveFormat( new ICalFormat() ); 1499 storage->setSaveFormat( new ICalFormat() );
1496 storage->save(); 1500 storage->save();
1497 } 1501 }
1498 } 1502 }
1499 setModified( true ); 1503 setModified( true );
1500 } 1504 }
1501 delete storage; 1505 delete storage;
1502 delete calendar; 1506 delete calendar;
1503 if ( syncOK ) 1507 if ( syncOK )
1504 updateView(); 1508 updateView();
1505 return syncOK; 1509 return syncOK;
1506} 1510}
1507 1511
1508void CalendarView::syncExternal( int mode ) 1512void CalendarView::syncExternal( int mode )
1509{ 1513{
1510 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1514 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1511 1515
1512 qApp->processEvents(); 1516 qApp->processEvents();
1513 CalendarLocal* calendar = new CalendarLocal(); 1517 CalendarLocal* calendar = new CalendarLocal();
1514 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1518 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1515 bool syncOK = false; 1519 bool syncOK = false;
1516 bool loadSuccess = false; 1520 bool loadSuccess = false;
1517 PhoneFormat* phoneFormat = 0; 1521 PhoneFormat* phoneFormat = 0;
1518 emit tempDisableBR(true); 1522 emit tempDisableBR(true);
1519#ifndef DESKTOP_VERSION 1523#ifndef DESKTOP_VERSION
1520 SharpFormat* sharpFormat = 0; 1524 SharpFormat* sharpFormat = 0;
1521 if ( mode == 0 ) { // sharp 1525 if ( mode == 0 ) { // sharp
1522 sharpFormat = new SharpFormat () ; 1526 sharpFormat = new SharpFormat () ;
1523 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1527 loadSuccess = sharpFormat->load( calendar, mCalendar );
1524 1528
1525 } else 1529 } else
1526#endif 1530#endif
1527 if ( mode == 1 ) { // phone 1531 if ( mode == 1 ) { // phone
1528 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1532 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1529 mSyncManager->mPhoneDevice, 1533 mSyncManager->mPhoneDevice,
1530 mSyncManager->mPhoneConnection, 1534 mSyncManager->mPhoneConnection,
1531 mSyncManager->mPhoneModel); 1535 mSyncManager->mPhoneModel);
1532 loadSuccess = phoneFormat->load( calendar,mCalendar); 1536 loadSuccess = phoneFormat->load( calendar,mCalendar);
1533 1537
1534 } else { 1538 } else {
1535 emit tempDisableBR(false); 1539 emit tempDisableBR(false);
1536 return; 1540 return;
1537 } 1541 }
1538 if ( loadSuccess ) { 1542 if ( loadSuccess ) {
1539 getEventViewerDialog()->setSyncMode( true ); 1543 getEventViewerDialog()->setSyncMode( true );
1540 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1544 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1541 getEventViewerDialog()->setSyncMode( false ); 1545 getEventViewerDialog()->setSyncMode( false );
1542 qApp->processEvents(); 1546 qApp->processEvents();
1543 if ( syncOK ) { 1547 if ( syncOK ) {
1544 if ( mSyncManager->mWriteBackFile ) 1548 if ( mSyncManager->mWriteBackFile )
1545 { 1549 {
1546 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1550 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1547 Incidence* inc = iL.first(); 1551 Incidence* inc = iL.first();
1548 if ( phoneFormat ) { 1552 if ( phoneFormat ) {
1549 while ( inc ) { 1553 while ( inc ) {
1550 inc->removeID(mCurrentSyncDevice); 1554 inc->removeID(mCurrentSyncDevice);
1551 inc = iL.next(); 1555 inc = iL.next();
1552 } 1556 }
1553 } 1557 }
1554#ifndef DESKTOP_VERSION 1558#ifndef DESKTOP_VERSION
1555 if ( sharpFormat ) 1559 if ( sharpFormat )
1556 sharpFormat->save(calendar); 1560 sharpFormat->save(calendar);
1557#endif 1561#endif
1558 if ( phoneFormat ) 1562 if ( phoneFormat )
1559 phoneFormat->save(calendar); 1563 phoneFormat->save(calendar);
1560 iL = calendar->rawIncidences(); 1564 iL = calendar->rawIncidences();
1561 inc = iL.first(); 1565 inc = iL.first();
1562 Incidence* loc; 1566 Incidence* loc;
1563 while ( inc ) { 1567 while ( inc ) {
1564 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1568 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1565 loc = mCalendar->incidence(inc->uid() ); 1569 loc = mCalendar->incidence(inc->uid() );
1566 if ( loc ) { 1570 if ( loc ) {
1567 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1571 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1568 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1572 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1569 } 1573 }
1570 } 1574 }
1571 inc = iL.next(); 1575 inc = iL.next();
1572 } 1576 }
1573 Incidence* lse = getLastSyncEvent(); 1577 Incidence* lse = getLastSyncEvent();
1574 if ( lse ) { 1578 if ( lse ) {
1575 lse->setReadOnly( false ); 1579 lse->setReadOnly( false );
1576 lse->setDescription( "" ); 1580 lse->setDescription( "" );
1577 lse->setReadOnly( true ); 1581 lse->setReadOnly( true );
1578 } 1582 }
1579 } 1583 }
1580 } else { 1584 } else {
1581 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1585 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1582 } 1586 }
1583 setModified( true ); 1587 setModified( true );
1584 } else { 1588 } else {
1585 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1589 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1586 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1590 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1587 question, i18n("Ok")) ; 1591 question, i18n("Ok")) ;
1588 1592
1589 } 1593 }
1590 delete calendar; 1594 delete calendar;
1591 updateView(); 1595 updateView();
1592 emit tempDisableBR(false); 1596 emit tempDisableBR(false);
1593 return ;//syncOK; 1597 return ;//syncOK;
1594 1598
1595} 1599}
1596 1600
1597bool CalendarView::importBday() 1601bool CalendarView::importBday()
1598{ 1602{
1599#ifndef KORG_NOKABC 1603#ifndef KORG_NOKABC
1600 1604
1601#ifdef DESKTOP_VERSION 1605#ifdef DESKTOP_VERSION
1602 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1606 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1603 KABC::AddressBook::Iterator it; 1607 KABC::AddressBook::Iterator it;
1604 int count = 0; 1608 int count = 0;
1605 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1609 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1606 ++count; 1610 ++count;
1607 } 1611 }
1608 QProgressBar bar(count,0 ); 1612 QProgressBar bar(count,0 );
1609 int w = 300; 1613 int w = 300;
1610 if ( QApplication::desktop()->width() < 320 ) 1614 if ( QApplication::desktop()->width() < 320 )
1611 w = 220; 1615 w = 220;
1612 int h = bar.sizeHint().height() ; 1616 int h = bar.sizeHint().height() ;
1613 int dw = QApplication::desktop()->width(); 1617 int dw = QApplication::desktop()->width();
1614 int dh = QApplication::desktop()->height(); 1618 int dh = QApplication::desktop()->height();
1615 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1619 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1616 bar.show(); 1620 bar.show();
1617 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1621 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1618 qApp->processEvents(); 1622 qApp->processEvents();
1619 count = 0; 1623 count = 0;
1620 int addCount = 0; 1624 int addCount = 0;
1621 KCal::Attendee* a = 0; 1625 KCal::Attendee* a = 0;
1622 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1626 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1623 if ( ! bar.isVisible() ) 1627 if ( ! bar.isVisible() )
1624 return false; 1628 return false;
1625 bar.setProgress( count++ ); 1629 bar.setProgress( count++ );
1626 qApp->processEvents(); 1630 qApp->processEvents();
1627 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1631 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1628 if ( (*it).birthday().date().isValid() ){ 1632 if ( (*it).birthday().date().isValid() ){
1629 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1633 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1630 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1634 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1631 ++addCount; 1635 ++addCount;
1632 } 1636 }
1633 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1637 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1634 if ( anni.isValid() ){ 1638 if ( anni.isValid() ){
1635 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1639 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1636 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1640 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1637 ++addCount; 1641 ++addCount;
1638 } 1642 }
1639 } 1643 }
1640 updateView(); 1644 updateView();
1641 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1645 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1642#else //DESKTOP_VERSION 1646#else //DESKTOP_VERSION
1643 1647
1644 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1648 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1645 // the result should now arrive through method insertBirthdays 1649 // the result should now arrive through method insertBirthdays
1646 1650
1647#endif //DESKTOP_VERSION 1651#endif //DESKTOP_VERSION
1648 1652
1649#endif //KORG_NOKABC 1653#endif //KORG_NOKABC
1650 1654
1651 1655
1652 return true; 1656 return true;
1653} 1657}
1654 1658
1655// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1659// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1656void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1660void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1657 const QStringList& anniversaryList, const QStringList& realNameList, 1661 const QStringList& anniversaryList, const QStringList& realNameList,
1658 const QStringList& emailList, const QStringList& assembledNameList, 1662 const QStringList& emailList, const QStringList& assembledNameList,
1659 const QStringList& uidList) 1663 const QStringList& uidList)
1660{ 1664{
1661 //qDebug("KO::CalendarView::insertBirthdays"); 1665 //qDebug("KO::CalendarView::insertBirthdays");
1662 if (uid == this->name()) 1666 if (uid == this->name())
1663 { 1667 {
1664 int count = birthdayList.count(); 1668 int count = birthdayList.count();
1665 int addCount = 0; 1669 int addCount = 0;
1666 KCal::Attendee* a = 0; 1670 KCal::Attendee* a = 0;
1667 1671
1668 //qDebug("CalView 1 %i", count); 1672 //qDebug("CalView 1 %i", count);
1669 1673
1670 QProgressBar bar(count,0 ); 1674 QProgressBar bar(count,0 );
1671 int w = 300; 1675 int w = 300;
1672 if ( QApplication::desktop()->width() < 320 ) 1676 if ( QApplication::desktop()->width() < 320 )
1673 w = 220; 1677 w = 220;
1674 int h = bar.sizeHint().height() ; 1678 int h = bar.sizeHint().height() ;
1675 int dw = QApplication::desktop()->width(); 1679 int dw = QApplication::desktop()->width();
1676 int dh = QApplication::desktop()->height(); 1680 int dh = QApplication::desktop()->height();
1677 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1681 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1678 bar.show(); 1682 bar.show();
1679 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1683 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1680 qApp->processEvents(); 1684 qApp->processEvents();
1681 1685
1682 QDate birthday; 1686 QDate birthday;
1683 QDate anniversary; 1687 QDate anniversary;
1684 QString realName; 1688 QString realName;
1685 QString email; 1689 QString email;
1686 QString assembledName; 1690 QString assembledName;
1687 QString uid; 1691 QString uid;
1688 bool ok = true; 1692 bool ok = true;
1689 for ( int i = 0; i < count; i++) 1693 for ( int i = 0; i < count; i++)
1690 { 1694 {
1691 if ( ! bar.isVisible() ) 1695 if ( ! bar.isVisible() )
1692 return; 1696 return;
1693 bar.setProgress( i ); 1697 bar.setProgress( i );
1694 qApp->processEvents(); 1698 qApp->processEvents();
1695 1699
1696 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1700 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1697 if (!ok) { 1701 if (!ok) {
1698 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1702 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1699 } 1703 }
1700 1704
1701 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1705 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1702 if (!ok) { 1706 if (!ok) {
1703 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1707 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1704 } 1708 }
1705 realName = realNameList[i]; 1709 realName = realNameList[i];
1706 email = emailList[i]; 1710 email = emailList[i];
1707 assembledName = assembledNameList[i]; 1711 assembledName = assembledNameList[i];
1708 uid = uidList[i]; 1712 uid = uidList[i];
1709 //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() ); 1713 //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() );
1710 1714
1711 if ( birthday.isValid() ){ 1715 if ( birthday.isValid() ){
1712 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1716 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1713 KCal::Attendee::ReqParticipant,uid) ; 1717 KCal::Attendee::ReqParticipant,uid) ;
1714 if ( addAnniversary( birthday, assembledName, a, true ) ) 1718 if ( addAnniversary( birthday, assembledName, a, true ) )
1715 ++addCount; 1719 ++addCount;
1716 } 1720 }
1717 1721
1718 if ( anniversary.isValid() ){ 1722 if ( anniversary.isValid() ){
1719 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1723 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1720 KCal::Attendee::ReqParticipant,uid) ; 1724 KCal::Attendee::ReqParticipant,uid) ;
1721 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1725 if ( addAnniversary( anniversary, assembledName, a, false ) )
1722 ++addCount; 1726 ++addCount;
1723 } 1727 }
1724 } 1728 }
1725 1729
1726 updateView(); 1730 updateView();
1727 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1731 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1728 1732
1729 } 1733 }
1730 1734
1731} 1735}
1732 1736
1733 1737
1734 1738
1735bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1739bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1736{ 1740{
1737 //qDebug("addAnni "); 1741 //qDebug("addAnni ");
1738 Event * ev = new Event(); 1742 Event * ev = new Event();
1739 ev->setOrganizer(KOPrefs::instance()->email()); 1743 ev->setOrganizer(KOPrefs::instance()->email());
1740 if ( a ) { 1744 if ( a ) {
1741 ev->addAttendee( a ); 1745 ev->addAttendee( a );
1742 } 1746 }
1743 QString kind; 1747 QString kind;
1744 if ( birthday ) { 1748 if ( birthday ) {
1745 kind = i18n( "Birthday" ); 1749 kind = i18n( "Birthday" );
1746 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1750 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1747 } 1751 }
1748 else { 1752 else {
1749 kind = i18n( "Anniversary" ); 1753 kind = i18n( "Anniversary" );
1750 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1754 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1751 } 1755 }
1752 ev->setCategories( kind ); 1756 ev->setCategories( kind );
1753 ev->setDtStart( QDateTime(date) ); 1757 ev->setDtStart( QDateTime(date) );
1754 ev->setDtEnd( QDateTime(date) ); 1758 ev->setDtEnd( QDateTime(date) );
1755 ev->setFloats( true ); 1759 ev->setFloats( true );
1756 Recurrence * rec = ev->recurrence(); 1760 Recurrence * rec = ev->recurrence();
1757 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1761 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1758 rec->addYearlyNum( date.month() ); 1762 rec->addYearlyNum( date.month() );
1759 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1763 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1760 delete ev; 1764 delete ev;
1761 return false; 1765 return false;
1762 } 1766 }
1763 return true; 1767 return true;
1764 1768
1765} 1769}
1766bool CalendarView::importQtopia( const QString &categories, 1770bool CalendarView::importQtopia( const QString &categories,
1767 const QString &datebook, 1771 const QString &datebook,
1768 const QString &todolist ) 1772 const QString &todolist )
1769{ 1773{
1770 1774
1771 QtopiaFormat qtopiaFormat; 1775 QtopiaFormat qtopiaFormat;
1772 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1776 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1773 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1777 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1774 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1778 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1775 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1779 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1776 1780
1777 updateView(); 1781 updateView();
1778 return true; 1782 return true;
1779 1783
1780#if 0 1784#if 0
1781 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1785 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1782 mCurrentSyncDevice = "qtopia-XML"; 1786 mCurrentSyncDevice = "qtopia-XML";
1783 if ( mSyncManager->mAskForPreferences ) 1787 if ( mSyncManager->mAskForPreferences )
1784 edit_sync_options(); 1788 edit_sync_options();
1785 qApp->processEvents(); 1789 qApp->processEvents();
1786 CalendarLocal* calendar = new CalendarLocal(); 1790 CalendarLocal* calendar = new CalendarLocal();
1787 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1791 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1788 bool syncOK = false; 1792 bool syncOK = false;
1789 QtopiaFormat qtopiaFormat; 1793 QtopiaFormat qtopiaFormat;
1790 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1794 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1791 bool loadOk = true; 1795 bool loadOk = true;
1792 if ( !categories.isEmpty() ) 1796 if ( !categories.isEmpty() )
1793 loadOk = qtopiaFormat.load( calendar, categories ); 1797 loadOk = qtopiaFormat.load( calendar, categories );
1794 if ( loadOk && !datebook.isEmpty() ) 1798 if ( loadOk && !datebook.isEmpty() )
1795 loadOk = qtopiaFormat.load( calendar, datebook ); 1799 loadOk = qtopiaFormat.load( calendar, datebook );
1796 if ( loadOk && !todolist.isEmpty() ) 1800 if ( loadOk && !todolist.isEmpty() )
1797 loadOk = qtopiaFormat.load( calendar, todolist ); 1801 loadOk = qtopiaFormat.load( calendar, todolist );
1798 1802
1799 if ( loadOk ) { 1803 if ( loadOk ) {
1800 getEventViewerDialog()->setSyncMode( true ); 1804 getEventViewerDialog()->setSyncMode( true );
1801 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1805 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1802 getEventViewerDialog()->setSyncMode( false ); 1806 getEventViewerDialog()->setSyncMode( false );
1803 qApp->processEvents(); 1807 qApp->processEvents();
1804 if ( syncOK ) { 1808 if ( syncOK ) {
1805 if ( mSyncManager->mWriteBackFile ) 1809 if ( mSyncManager->mWriteBackFile )
1806 { 1810 {
1807 // write back XML file 1811 // write back XML file
1808 1812
1809 } 1813 }
1810 setModified( true ); 1814 setModified( true );
1811 } 1815 }
1812 } else { 1816 } else {
1813 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1817 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1814 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1818 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1815 question, i18n("Ok")) ; 1819 question, i18n("Ok")) ;
1816 } 1820 }
1817 delete calendar; 1821 delete calendar;
1818 updateView(); 1822 updateView();
1819 return syncOK; 1823 return syncOK;
1820 1824
1821 1825
1822#endif 1826#endif
1823 1827
1824} 1828}
1825 1829
1826void CalendarView::setSyncEventsReadOnly() 1830void CalendarView::setSyncEventsReadOnly()
1827{ 1831{
1828 Event * ev; 1832 Event * ev;
1829 QPtrList<Event> eL = mCalendar->rawEvents(); 1833 QPtrList<Event> eL = mCalendar->rawEvents();
1830 ev = eL.first(); 1834 ev = eL.first();
1831 while ( ev ) { 1835 while ( ev ) {
1832 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1836 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1833 ev->setReadOnly( true ); 1837 ev->setReadOnly( true );
1834 ev = eL.next(); 1838 ev = eL.next();
1835 } 1839 }
1836} 1840}
1841
1842bool CalendarView::loadCalendars()
1843{
1844 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1845 KopiCalendarFile * cal = calendars.first();
1846 mCalendar->setDefaultCalendar( 1 );
1847 openCalendar( MainWindow::defaultFileName(), false );
1848 cal = calendars.next();
1849 while ( cal ) {
1850 addCalendar( cal );
1851 cal = calendars.next();
1852 }
1853 restoreCalendarSettings();
1854 mCalendar->reInitAlarmSettings();
1855 setSyncEventsReadOnly();
1856 updateUnmanagedViews();
1857 updateView();
1858}
1859bool CalendarView::restoreCalendarSettings()
1860{
1861 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1862 KopiCalendarFile * cal = calendars.first();
1863 while ( cal ) {
1864 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1865 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1866 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1867 if ( cal->isStandard )
1868 mCalendar->setDefaultCalendar( cal->mCalNumber );
1869 cal = calendars.next();
1870 }
1871}
1872bool CalendarView::addCalendar( KopiCalendarFile * cal )
1873{
1874
1875 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber ))
1876 return true;
1877 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1878 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1879 return false;
1880}
1837bool CalendarView::openCalendar(QString filename, bool merge) 1881bool CalendarView::openCalendar(QString filename, bool merge)
1838{ 1882{
1839 1883
1840 if (filename.isEmpty()) { 1884 if (filename.isEmpty()) {
1841 return false; 1885 return false;
1842 } 1886 }
1843 1887
1844 if (!QFile::exists(filename)) { 1888 if (!QFile::exists(filename)) {
1845 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1889 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1846 return false; 1890 return false;
1847 } 1891 }
1848 1892
1849 globalFlagBlockAgenda = 1; 1893 globalFlagBlockAgenda = 1;
1850 clearAllViews(); 1894 clearAllViews();
1851 if (!merge) { 1895 if (!merge) {
1852 mViewManager->setDocumentId( filename ); 1896 mViewManager->setDocumentId( filename );
1853 mCalendar->close(); 1897 mCalendar->close();
1854 } 1898 }
1855 mStorage->setFileName( filename ); 1899 mStorage->setFileName( filename );
1856 1900
1857 if ( mStorage->load() ) { 1901 if ( mStorage->load() ) {
1858 if ( merge ) ;//setModified( true ); 1902 if ( merge ) ;//setModified( true );
1859 else { 1903 else {
1860 //setModified( true ); 1904 //setModified( true );
1861 mViewManager->setDocumentId( filename ); 1905 mViewManager->setDocumentId( filename );
1862 mDialogManager->setDocumentId( filename ); 1906 mDialogManager->setDocumentId( filename );
1863 mTodoList->setDocumentId( filename ); 1907 mTodoList->setDocumentId( filename );
1864 } 1908 }
1865 globalFlagBlockAgenda = 2; 1909 globalFlagBlockAgenda = 2;
1866 // if ( getLastSyncEvent() ) 1910 // if ( getLastSyncEvent() )
1867 // getLastSyncEvent()->setReadOnly( true ); 1911 // getLastSyncEvent()->setReadOnly( true );
1868 mCalendar->reInitAlarmSettings(); 1912 mCalendar->reInitAlarmSettings();
1869 setSyncEventsReadOnly(); 1913 setSyncEventsReadOnly();
1870 updateUnmanagedViews(); 1914 updateUnmanagedViews();
1871 updateView(); 1915 updateView();
1872 if ( filename != MainWindow::defaultFileName() ) { 1916 if ( filename != MainWindow::defaultFileName() ) {
1873 saveCalendar( MainWindow::defaultFileName() ); 1917 saveCalendar( MainWindow::defaultFileName() );
1874 } else { 1918 } else {
1875 QFileInfo finf ( MainWindow::defaultFileName()); 1919 QFileInfo finf ( MainWindow::defaultFileName());
1876 if ( finf.exists() ) { 1920 if ( finf.exists() ) {
1877 setLoadedFileVersion( finf.lastModified () ); 1921 setLoadedFileVersion( finf.lastModified () );
1878 } 1922 }
1879 } 1923 }
1880 return true; 1924 return true;
1881 } else { 1925 } else {
1882 // while failing to load, the calendar object could 1926 // while failing to load, the calendar object could
1883 // have become partially populated. Clear it out. 1927 // have become partially populated. Clear it out.
1884 if ( !merge ) { 1928 if ( !merge ) {
1885 mCalendar->close(); 1929 mCalendar->close();
1886 mViewManager->setDocumentId( filename ); 1930 mViewManager->setDocumentId( filename );
1887 mDialogManager->setDocumentId( filename ); 1931 mDialogManager->setDocumentId( filename );
1888 mTodoList->setDocumentId( filename ); 1932 mTodoList->setDocumentId( filename );
1889 } 1933 }
1890 1934
1891 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1935 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1892 1936
1893 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1937 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1894 globalFlagBlockAgenda = 2; 1938 globalFlagBlockAgenda = 2;
1895 mCalendar->reInitAlarmSettings(); 1939 mCalendar->reInitAlarmSettings();
1896 setSyncEventsReadOnly(); 1940 setSyncEventsReadOnly();
1897 updateUnmanagedViews(); 1941 updateUnmanagedViews();
1898 updateView(); 1942 updateView();
1899 } 1943 }
1900 return false; 1944 return false;
1901} 1945}
1902void CalendarView::showOpenError() 1946void CalendarView::showOpenError()
1903{ 1947{
1904 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1948 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1905} 1949}
1906void CalendarView::setLoadedFileVersion(QDateTime dt) 1950void CalendarView::setLoadedFileVersion(QDateTime dt)
1907{ 1951{
1908 loadedFileVersion = dt; 1952 loadedFileVersion = dt;
1909} 1953}
1910bool CalendarView::checkFileChanged(QString fn) 1954bool CalendarView::checkFileChanged(QString fn)
1911{ 1955{
1912 QFileInfo finf ( fn ); 1956 QFileInfo finf ( fn );
1913 if ( !finf.exists() ) 1957 if ( !finf.exists() )
1914 return true; 1958 return true;
1915 QDateTime dt = finf.lastModified (); 1959 QDateTime dt = finf.lastModified ();
1916 if ( dt <= loadedFileVersion ) 1960 if ( dt <= loadedFileVersion )
1917 return false; 1961 return false;
1918 return true; 1962 return true;
1919 1963
1920} 1964}
1921void CalendarView::watchSavedFile() 1965void CalendarView::watchSavedFile()
1922{ 1966{
1923 QFileInfo finf ( MainWindow::defaultFileName()); 1967 QFileInfo finf ( MainWindow::defaultFileName());
1924 if ( !finf.exists() ) 1968 if ( !finf.exists() )
1925 return; 1969 return;
1926 QDateTime dt = finf.lastModified (); 1970 QDateTime dt = finf.lastModified ();
1927 if ( dt < loadedFileVersion ) { 1971 if ( dt < loadedFileVersion ) {
1928 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1972 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1929 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1973 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1930 return; 1974 return;
1931 } 1975 }
1932 loadedFileVersion = dt; 1976 loadedFileVersion = dt;
1933} 1977}
1934 1978
1935bool CalendarView::checkFileVersion(QString fn) 1979bool CalendarView::checkFileVersion(QString fn)
1936{ 1980{
1937 QFileInfo finf ( fn ); 1981 QFileInfo finf ( fn );
1938 if ( !finf.exists() ) 1982 if ( !finf.exists() )
1939 return true; 1983 return true;
1940 QDateTime dt = finf.lastModified (); 1984 QDateTime dt = finf.lastModified ();
1941 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1985 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1942 //qDebug("file on disk version %s",dt.toString().latin1()); 1986 //qDebug("file on disk version %s",dt.toString().latin1());
1943 if ( dt <= loadedFileVersion ) 1987 if ( dt <= loadedFileVersion )
1944 return true; 1988 return true;
1945 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)) , 1989 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)) ,
1946 i18n("KO/Pi Warning"),i18n("Overwrite"), 1990 i18n("KO/Pi Warning"),i18n("Overwrite"),
1947 i18n("Sync+save")); 1991 i18n("Sync+save"));
1948 1992
1949 if ( km == KMessageBox::Cancel ) 1993 if ( km == KMessageBox::Cancel )
1950 return false; 1994 return false;
1951 if ( km == KMessageBox::Yes ) 1995 if ( km == KMessageBox::Yes )
1952 return true; 1996 return true;
1953 1997
1954 setSyncDevice("deleteaftersync" ); 1998 setSyncDevice("deleteaftersync" );
1955 mSyncManager->mAskForPreferences = true; 1999 mSyncManager->mAskForPreferences = true;
1956 mSyncManager->mSyncAlgoPrefs = 3; 2000 mSyncManager->mSyncAlgoPrefs = 3;
1957 mSyncManager->mWriteBackFile = false; 2001 mSyncManager->mWriteBackFile = false;
1958 mSyncManager->mWriteBackExistingOnly = false; 2002 mSyncManager->mWriteBackExistingOnly = false;
1959 mSyncManager->mShowSyncSummary = false; 2003 mSyncManager->mShowSyncSummary = false;
1960 syncCalendar( fn, 3 ); 2004 syncCalendar( fn, 3 );
1961 Event * e = getLastSyncEvent(); 2005 Event * e = getLastSyncEvent();
1962 if ( e ) 2006 if ( e )
1963 deleteEvent ( e ); 2007 deleteEvent ( e );
1964 updateView(); 2008 updateView();
1965 return true; 2009 return true;
1966} 2010}
1967 2011bool CalendarView::saveCalendars()
2012{
2013 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2014 KopiCalendarFile * cal = calendars.first();
2015 mCalendar->setDefaultCalendar( 1 );
2016 mCalendar->setDefaultCalendarEnabledOnly();
2017 saveCalendar( MainWindow::defaultFileName() );
2018 cal = calendars.next();
2019 while ( cal ) {
2020 if ( !cal->isReadOnly ) {
2021 mCalendar->setDefaultCalendar( cal->mCalNumber );
2022 mCalendar->setDefaultCalendarEnabledOnly();
2023 saveCalendar( cal->mFileName );
2024 }
2025 cal = calendars.next();
2026 }
2027 restoreCalendarSettings();
2028}
1968bool CalendarView::saveCalendar( QString filename ) 2029bool CalendarView::saveCalendar( QString filename )
1969{ 2030{
1970 2031
1971 // Store back all unsaved data into calendar object 2032 // Store back all unsaved data into calendar object
1972 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2033 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1973 if ( mViewManager->currentView() ) 2034 if ( mViewManager->currentView() )
1974 mViewManager->currentView()->flushView(); 2035 mViewManager->currentView()->flushView();
1975 2036
1976 2037
1977 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2038 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1978 mStorage->setSaveFormat( new ICalFormat() ); 2039 mStorage->setSaveFormat( new ICalFormat() );
1979 mStorage->setFileName( filename ); 2040 mStorage->setFileName( filename );
1980 bool success; 2041 bool success;
1981 success = mStorage->save(); 2042 success = mStorage->save();
1982 if ( !success ) { 2043 if ( !success ) {
1983 return false; 2044 return false;
1984 } 2045 }
1985 if ( filename == MainWindow::defaultFileName() ) { 2046 if ( filename == MainWindow::defaultFileName() ) {
1986 setLoadedFileVersion( lfv ); 2047 setLoadedFileVersion( lfv );
1987 watchSavedFile(); 2048 watchSavedFile();
1988 } 2049 }
1989 return true; 2050 return true;
1990} 2051}
1991 2052
1992void CalendarView::closeCalendar() 2053void CalendarView::closeCalendar()
1993{ 2054{
1994 2055
1995 // child windows no longer valid 2056 // child windows no longer valid
1996 clearAllViews(); 2057 clearAllViews();
1997 emit closingDown(); 2058 emit closingDown();
1998 2059
1999 mCalendar->close(); 2060 mCalendar->close();
2000 setModified(false); 2061 setModified(false);
2001 updateView(); 2062 updateView();
2002} 2063}
2003 2064
2004void CalendarView::archiveCalendar() 2065void CalendarView::archiveCalendar()
2005{ 2066{
2006 mDialogManager->showArchiveDialog(); 2067 mDialogManager->showArchiveDialog();
2007} 2068}
2008 2069
2009 2070
2010void CalendarView::readSettings() 2071void CalendarView::readSettings()
2011{ 2072{
2012 2073
2013 2074
2014 // mViewManager->showAgendaView(); 2075 // mViewManager->showAgendaView();
2015 QString str; 2076 QString str;
2016 //qDebug("CalendarView::readSettings() "); 2077 //qDebug("CalendarView::readSettings() ");
2017 // read settings from the KConfig, supplying reasonable 2078 // read settings from the KConfig, supplying reasonable
2018 // defaults where none are to be found 2079 // defaults where none are to be found
2019 KConfig *config = KOGlobals::config(); 2080 KConfig *config = KOGlobals::config();
2020#ifndef KORG_NOSPLITTER 2081#ifndef KORG_NOSPLITTER
2021 config->setGroup("KOrganizer Geometry"); 2082 config->setGroup("KOrganizer Geometry");
2022 2083
2023 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2084 QValueList<int> sizes = config->readIntListEntry("Separator1");
2024 if (sizes.count() != 2) { 2085 if (sizes.count() != 2) {
2025 sizes << mDateNavigator->minimumSizeHint().width(); 2086 sizes << mDateNavigator->minimumSizeHint().width();
2026 sizes << 300; 2087 sizes << 300;
2027 } 2088 }
2028 mPanner->setSizes(sizes); 2089 mPanner->setSizes(sizes);
2029 2090
2030 sizes = config->readIntListEntry("Separator2"); 2091 sizes = config->readIntListEntry("Separator2");
2031 if ( ( mResourceView && sizes.count() == 4 ) || 2092 if ( ( mResourceView && sizes.count() == 4 ) ||
2032 ( !mResourceView && sizes.count() == 3 ) ) { 2093 ( !mResourceView && sizes.count() == 3 ) ) {
2033 mLeftSplitter->setSizes(sizes); 2094 mLeftSplitter->setSizes(sizes);
2034 } 2095 }
2035#endif 2096#endif
2036 globalFlagBlockAgenda = 1; 2097 globalFlagBlockAgenda = 1;
2037 mViewManager->showAgendaView(); 2098 mViewManager->showAgendaView();
2038 //mViewManager->readSettings( config ); 2099 //mViewManager->readSettings( config );
2039 mTodoList->restoreLayout(config,QString("Todo Layout")); 2100 mTodoList->restoreLayout(config,QString("Todo Layout"));
2040 readFilterSettings(config); 2101 readFilterSettings(config);
2041 2102
2042#ifdef DESKTOP_VERSION 2103#ifdef DESKTOP_VERSION
2043 config->setGroup("WidgetLayout"); 2104 config->setGroup("WidgetLayout");
2044 QStringList list; 2105 QStringList list;
2045 list = config->readListEntry("MainLayout"); 2106 list = config->readListEntry("MainLayout");
2046 int x,y,w,h; 2107 int x,y,w,h;
2047 if ( ! list.isEmpty() ) { 2108 if ( ! list.isEmpty() ) {
2048 x = list[0].toInt(); 2109 x = list[0].toInt();
2049 y = list[1].toInt(); 2110 y = list[1].toInt();
2050 w = list[2].toInt(); 2111 w = list[2].toInt();
2051 h = list[3].toInt(); 2112 h = list[3].toInt();
2052 KApplication::testCoords( &x,&y,&w,&h ); 2113 KApplication::testCoords( &x,&y,&w,&h );
2053 topLevelWidget()->setGeometry(x,y,w,h); 2114 topLevelWidget()->setGeometry(x,y,w,h);
2054 2115
2055 } else { 2116 } else {
2056 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2117 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2057 } 2118 }
2058 list = config->readListEntry("EditEventLayout"); 2119 list = config->readListEntry("EditEventLayout");
2059 if ( ! list.isEmpty() ) { 2120 if ( ! list.isEmpty() ) {
2060 x = list[0].toInt(); 2121 x = list[0].toInt();
2061 y = list[1].toInt(); 2122 y = list[1].toInt();
2062 w = list[2].toInt(); 2123 w = list[2].toInt();
2063 h = list[3].toInt(); 2124 h = list[3].toInt();
2064 KApplication::testCoords( &x,&y,&w,&h ); 2125 KApplication::testCoords( &x,&y,&w,&h );
2065 mEventEditor->setGeometry(x,y,w,h); 2126 mEventEditor->setGeometry(x,y,w,h);
2066 2127
2067 } 2128 }
2068 list = config->readListEntry("EditTodoLayout"); 2129 list = config->readListEntry("EditTodoLayout");
2069 if ( ! list.isEmpty() ) { 2130 if ( ! list.isEmpty() ) {
2070 x = list[0].toInt(); 2131 x = list[0].toInt();
2071 y = list[1].toInt(); 2132 y = list[1].toInt();
2072 w = list[2].toInt(); 2133 w = list[2].toInt();
2073 h = list[3].toInt(); 2134 h = list[3].toInt();
2074 KApplication::testCoords( &x,&y,&w,&h ); 2135 KApplication::testCoords( &x,&y,&w,&h );
2075 mTodoEditor->setGeometry(x,y,w,h); 2136 mTodoEditor->setGeometry(x,y,w,h);
2076 2137
2077 } 2138 }
2078 list = config->readListEntry("ViewerLayout"); 2139 list = config->readListEntry("ViewerLayout");
2079 if ( ! list.isEmpty() ) { 2140 if ( ! list.isEmpty() ) {
2080 x = list[0].toInt(); 2141 x = list[0].toInt();
2081 y = list[1].toInt(); 2142 y = list[1].toInt();
2082 w = list[2].toInt(); 2143 w = list[2].toInt();
2083 h = list[3].toInt(); 2144 h = list[3].toInt();
2084 KApplication::testCoords( &x,&y,&w,&h ); 2145 KApplication::testCoords( &x,&y,&w,&h );
2085 getEventViewerDialog()->setGeometry(x,y,w,h); 2146 getEventViewerDialog()->setGeometry(x,y,w,h);
2086 } 2147 }
2087#endif 2148#endif
2088 config->setGroup( "Views" ); 2149 config->setGroup( "Views" );
2089 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2150 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2090 2151
2091 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2152 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2092 2153
2093 int resetval = 0; 2154 int resetval = 0;
2094 int maxVal = 0; 2155 int maxVal = 0;
2095 if (sizes.count() != 3) { 2156 if (sizes.count() != 3) {
2096 if ( KOPrefs::instance()->mVerticalScreen ) { 2157 if ( KOPrefs::instance()->mVerticalScreen ) {
2097 resetval = mDateNavigator->sizeHint().width()+2; 2158 resetval = mDateNavigator->sizeHint().width()+2;
2098 } else { 2159 } else {
2099 resetval = mDateNavigator->sizeHint().height()+2; 2160 resetval = mDateNavigator->sizeHint().height()+2;
2100 } 2161 }
2101 } 2162 }
2102 if ( resetval ) { 2163 if ( resetval ) {
2103 sizes.clear(); 2164 sizes.clear();
2104 if ( KOPrefs::instance()->mVerticalScreen ) { 2165 if ( KOPrefs::instance()->mVerticalScreen ) {
2105 maxVal = QApplication::desktop()->width() -10; 2166 maxVal = QApplication::desktop()->width() -10;
2106 } else { 2167 } else {
2107 maxVal = QApplication::desktop()->height()-10; 2168 maxVal = QApplication::desktop()->height()-10;
2108 } 2169 }
2109 sizes << resetval; 2170 sizes << resetval;
2110 if ( maxVal < resetval + resetval) 2171 if ( maxVal < resetval + resetval)
2111 resetval = maxVal - resetval; 2172 resetval = maxVal - resetval;
2112 sizes << resetval; 2173 sizes << resetval;
2113 sizes << 100; 2174 sizes << 100;
2114 } 2175 }
2115 mLeftFrame->setSizes(sizes); 2176 mLeftFrame->setSizes(sizes);
2116 sizes = config->readIntListEntry("Main Splitter Frame"); 2177 sizes = config->readIntListEntry("Main Splitter Frame");
2117 resetval = 0; 2178 resetval = 0;
2118 maxVal = 0; 2179 maxVal = 0;
2119 if (sizes.count() != 2) { 2180 if (sizes.count() != 2) {
2120 if ( !KOPrefs::instance()->mVerticalScreen ) { 2181 if ( !KOPrefs::instance()->mVerticalScreen ) {
2121 resetval = mDateNavigator->sizeHint().width()+2; 2182 resetval = mDateNavigator->sizeHint().width()+2;
2122 } else { 2183 } else {
2123 resetval = mDateNavigator->sizeHint().height()+2; 2184 resetval = mDateNavigator->sizeHint().height()+2;
2124 } 2185 }
2125 } 2186 }
2126 if ( resetval ) { 2187 if ( resetval ) {
2127 sizes.clear(); 2188 sizes.clear();
2128 if ( !KOPrefs::instance()->mVerticalScreen ) { 2189 if ( !KOPrefs::instance()->mVerticalScreen ) {
2129 maxVal = QApplication::desktop()->width() -10; 2190 maxVal = QApplication::desktop()->width() -10;
2130 } else { 2191 } else {
2131 maxVal = QApplication::desktop()->height()-10; 2192 maxVal = QApplication::desktop()->height()-10;
2132 } 2193 }
2133 sizes << resetval; 2194 sizes << resetval;
2134 if ( maxVal < resetval + resetval) 2195 if ( maxVal < resetval + resetval)
2135 resetval = maxVal - resetval; 2196 resetval = maxVal - resetval;
2136 sizes << resetval; 2197 sizes << resetval;
2137 } 2198 }
2138 mMainFrame->setSizes(sizes); 2199 mMainFrame->setSizes(sizes);
2139 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2200 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2140 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2201 else if ( dateCount == 7 ) mNavigator->selectWeek();
2141 else mNavigator->selectDates( dateCount ); 2202 else mNavigator->selectDates( dateCount );
2142 // mViewManager->readSettings( config ); 2203 // mViewManager->readSettings( config );
2143 updateConfig(); 2204 updateConfig();
2144 globalFlagBlockAgenda = 2; 2205 globalFlagBlockAgenda = 2;
2145 mViewManager->readSettings( config ); 2206 mViewManager->readSettings( config );
2146 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2207 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2147} 2208}
2148 2209
2149 2210
2150void CalendarView::writeSettings() 2211void CalendarView::writeSettings()
2151{ 2212{
2152 // kdDebug() << "CalendarView::writeSettings" << endl; 2213 // kdDebug() << "CalendarView::writeSettings" << endl;
2153 2214
2154 KConfig *config = KOGlobals::config(); 2215 KConfig *config = KOGlobals::config();
2155 2216
2156 mViewManager->writeSettings( config ); 2217 mViewManager->writeSettings( config );
2157 mTodoList->saveLayout(config,QString("Todo Layout")); 2218 mTodoList->saveLayout(config,QString("Todo Layout"));
2158 mDialogManager->writeSettings( config ); 2219 mDialogManager->writeSettings( config );
2159 //KOPrefs::instance()->usrWriteConfig(); 2220 //KOPrefs::instance()->usrWriteConfig();
2160 KOPrefs::instance()->writeConfig(); 2221 KOPrefs::instance()->writeConfig();
2161 2222
2162 writeFilterSettings(config); 2223 writeFilterSettings(config);
2163 config->setGroup( "AppRun" ); 2224 config->setGroup( "AppRun" );
2164 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2225 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2165 int days = dt.daysTo( QDate::currentDate() ); 2226 int days = dt.daysTo( QDate::currentDate() );
2166 dt = dt.addDays( days ); 2227 dt = dt.addDays( days );
2167 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2228 int secs = dt.secsTo( QDateTime::currentDateTime() );
2168 config->writeEntry( "LatestProgramStopDays", days ); 2229 config->writeEntry( "LatestProgramStopDays", days );
2169 config->writeEntry( "LatestProgramStopSecs", secs ); 2230 config->writeEntry( "LatestProgramStopSecs", secs );
2170 //qDebug("KO: Writing stop time: %d ", secs); 2231 //qDebug("KO: Writing stop time: %d ", secs);
2171 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2232 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2172 //QDateTime latest = dt.addSecs ( secs ); 2233 //QDateTime latest = dt.addSecs ( secs );
2173 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2234 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2174 config->setGroup( "Views" ); 2235 config->setGroup( "Views" );
2175 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2236 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2176 2237
2177#if 0 2238#if 0
2178 qDebug("********************* "); 2239 qDebug("********************* ");
2179 qDebug("Testcode secsto "); 2240 qDebug("Testcode secsto ");
2180 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2241 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2181 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2242 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2182 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2243 int secsto = dt_nodaylight.secsTo( dt_daylight );
2183 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2244 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2184 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2245 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2185 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2246 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2186 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2247 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2187 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2248 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2188 qDebug("********************* testcode end"); 2249 qDebug("********************* testcode end");
2189 2250
2190#endif 2251#endif
2191 2252
2192 QValueList<int> listINT = mLeftFrame->sizes(); 2253 QValueList<int> listINT = mLeftFrame->sizes();
2193 config->writeEntry("Left Splitter Frame",listINT); 2254 config->writeEntry("Left Splitter Frame",listINT);
2194 QValueList<int> listINT2 = mMainFrame->sizes(); 2255 QValueList<int> listINT2 = mMainFrame->sizes();
2195 config->writeEntry("Main Splitter Frame",listINT2); 2256 config->writeEntry("Main Splitter Frame",listINT2);
2196#ifdef DESKTOP_VERSION 2257#ifdef DESKTOP_VERSION
2197 config->setGroup("WidgetLayout"); 2258 config->setGroup("WidgetLayout");
2198 QStringList list ;//= config->readListEntry("MainLayout"); 2259 QStringList list ;//= config->readListEntry("MainLayout");
2199 int x,y,w,h; 2260 int x,y,w,h;
2200 QWidget* wid; 2261 QWidget* wid;
2201 wid = topLevelWidget(); 2262 wid = topLevelWidget();
2202 x = wid->geometry().x(); 2263 x = wid->geometry().x();
2203 y = wid->geometry().y(); 2264 y = wid->geometry().y();
2204 w = wid->width(); 2265 w = wid->width();
2205 h = wid->height(); 2266 h = wid->height();
2206 list.clear(); 2267 list.clear();
2207 list << QString::number( x ); 2268 list << QString::number( x );
2208 list << QString::number( y ); 2269 list << QString::number( y );
2209 list << QString::number( w ); 2270 list << QString::number( w );
2210 list << QString::number( h ); 2271 list << QString::number( h );
2211 config->writeEntry("MainLayout",list ); 2272 config->writeEntry("MainLayout",list );
2212 2273
2213 wid = mEventEditor; 2274 wid = mEventEditor;
2214 x = wid->geometry().x(); 2275 x = wid->geometry().x();
2215 y = wid->geometry().y(); 2276 y = wid->geometry().y();
2216 w = wid->width(); 2277 w = wid->width();
2217 h = wid->height(); 2278 h = wid->height();
2218 list.clear(); 2279 list.clear();
2219 list << QString::number( x ); 2280 list << QString::number( x );
2220 list << QString::number( y ); 2281 list << QString::number( y );
2221 list << QString::number( w ); 2282 list << QString::number( w );
2222 list << QString::number( h ); 2283 list << QString::number( h );
2223 config->writeEntry("EditEventLayout",list ); 2284 config->writeEntry("EditEventLayout",list );
2224 2285
2225 wid = mTodoEditor; 2286 wid = mTodoEditor;
2226 x = wid->geometry().x(); 2287 x = wid->geometry().x();
2227 y = wid->geometry().y(); 2288 y = wid->geometry().y();
2228 w = wid->width(); 2289 w = wid->width();
2229 h = wid->height(); 2290 h = wid->height();
2230 list.clear(); 2291 list.clear();
2231 list << QString::number( x ); 2292 list << QString::number( x );
2232 list << QString::number( y ); 2293 list << QString::number( y );
2233 list << QString::number( w ); 2294 list << QString::number( w );
2234 list << QString::number( h ); 2295 list << QString::number( h );
2235 config->writeEntry("EditTodoLayout",list ); 2296 config->writeEntry("EditTodoLayout",list );
2236 wid = getEventViewerDialog(); 2297 wid = getEventViewerDialog();
2237 x = wid->geometry().x(); 2298 x = wid->geometry().x();
2238 y = wid->geometry().y(); 2299 y = wid->geometry().y();
2239 w = wid->width(); 2300 w = wid->width();
2240 h = wid->height(); 2301 h = wid->height();
2241 list.clear(); 2302 list.clear();
2242 list << QString::number( x ); 2303 list << QString::number( x );
2243 list << QString::number( y ); 2304 list << QString::number( y );
2244 list << QString::number( w ); 2305 list << QString::number( w );
2245 list << QString::number( h ); 2306 list << QString::number( h );
2246 config->writeEntry("ViewerLayout",list ); 2307 config->writeEntry("ViewerLayout",list );
2247 wid = mDialogManager->getSearchDialog(); 2308 wid = mDialogManager->getSearchDialog();
2248 if ( wid ) { 2309 if ( wid ) {
2249 x = wid->geometry().x(); 2310 x = wid->geometry().x();
2250 y = wid->geometry().y(); 2311 y = wid->geometry().y();
2251 w = wid->width(); 2312 w = wid->width();
2252 h = wid->height(); 2313 h = wid->height();
2253 list.clear(); 2314 list.clear();
2254 list << QString::number( x ); 2315 list << QString::number( x );
2255 list << QString::number( y ); 2316 list << QString::number( y );
2256 list << QString::number( w ); 2317 list << QString::number( w );
2257 list << QString::number( h ); 2318 list << QString::number( h );
2258 config->writeEntry("SearchLayout",list ); 2319 config->writeEntry("SearchLayout",list );
2259 } 2320 }
2260#endif 2321#endif
2261 2322
2262 2323
2263 config->sync(); 2324 config->sync();
2264} 2325}
2265 2326
2266void CalendarView::readFilterSettings(KConfig *config) 2327void CalendarView::readFilterSettings(KConfig *config)
2267{ 2328{
2268 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2329 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2269 2330
2270 mFilters.clear(); 2331 mFilters.clear();
2271 2332
2272 config->setGroup("General"); 2333 config->setGroup("General");
2273 QStringList filterList = config->readListEntry("CalendarFilters"); 2334 QStringList filterList = config->readListEntry("CalendarFilters");
2274 2335
2275 QStringList::ConstIterator it = filterList.begin(); 2336 QStringList::ConstIterator it = filterList.begin();
2276 QStringList::ConstIterator end = filterList.end(); 2337 QStringList::ConstIterator end = filterList.end();
2277 while(it != end) { 2338 while(it != end) {
2278 // kdDebug() << " filter: " << (*it) << endl; 2339 // kdDebug() << " filter: " << (*it) << endl;
2279 2340
2280 CalFilter *filter; 2341 CalFilter *filter;
2281 filter = new CalFilter(*it); 2342 filter = new CalFilter(*it);
2282 config->setGroup("Filter_" + (*it).utf8()); 2343 config->setGroup("Filter_" + (*it).utf8());
2283 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2344 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2284 filter->setCriteria(config->readNumEntry("Criteria",0)); 2345 filter->setCriteria(config->readNumEntry("Criteria",0));
2285 filter->setCategoryList(config->readListEntry("CategoryList")); 2346 filter->setCategoryList(config->readListEntry("CategoryList"));
2286 mFilters.append(filter); 2347 mFilters.append(filter);
2287 2348
2288 ++it; 2349 ++it;
2289 } 2350 }
2290 2351
2291 if (mFilters.count() == 0) { 2352 if (mFilters.count() == 0) {
2292 CalFilter *filter = new CalFilter(i18n("Default")); 2353 CalFilter *filter = new CalFilter(i18n("Default"));
2293 mFilters.append(filter); 2354 mFilters.append(filter);
2294 } 2355 }
2295 mFilterView->updateFilters(); 2356 mFilterView->updateFilters();
2296 config->setGroup("FilterView"); 2357 config->setGroup("FilterView");
2297 2358
2298 mFilterView->blockSignals(true); 2359 mFilterView->blockSignals(true);
2299 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2360 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2300 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2361 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2301 mFilterView->blockSignals(false); 2362 mFilterView->blockSignals(false);
2302 // We do it manually to avoid it being done twice by the above calls 2363 // We do it manually to avoid it being done twice by the above calls
2303 updateFilter(); 2364 updateFilter();
2304} 2365}
2305 2366
2306void CalendarView::writeFilterSettings(KConfig *config) 2367void CalendarView::writeFilterSettings(KConfig *config)
2307{ 2368{
2308 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2369 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2309 2370
2310 QStringList filterList; 2371 QStringList filterList;
2311 2372
2312 CalFilter *filter = mFilters.first(); 2373 CalFilter *filter = mFilters.first();
2313 while(filter) { 2374 while(filter) {
2314 // kdDebug() << " fn: " << filter->name() << endl; 2375 // kdDebug() << " fn: " << filter->name() << endl;
2315 filterList << filter->name(); 2376 filterList << filter->name();
2316 config->setGroup("Filter_" + filter->name().utf8()); 2377 config->setGroup("Filter_" + filter->name().utf8());
2317 config->writeEntry("Criteria",filter->criteria()); 2378 config->writeEntry("Criteria",filter->criteria());
2318 config->writeEntry("CategoryList",filter->categoryList()); 2379 config->writeEntry("CategoryList",filter->categoryList());
2319 filter = mFilters.next(); 2380 filter = mFilters.next();
2320 } 2381 }
2321 config->setGroup("General"); 2382 config->setGroup("General");
2322 config->writeEntry("CalendarFilters",filterList); 2383 config->writeEntry("CalendarFilters",filterList);
2323 2384
2324 config->setGroup("FilterView"); 2385 config->setGroup("FilterView");
2325 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2386 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2326 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2387 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2327} 2388}
2328 2389
2329 2390
2330void CalendarView::goToday() 2391void CalendarView::goToday()
2331{ 2392{
2332 if ( mViewManager->currentView()->isMonthView() ) 2393 if ( mViewManager->currentView()->isMonthView() )
2333 mNavigator->selectTodayMonth(); 2394 mNavigator->selectTodayMonth();
2334 else 2395 else
2335 mNavigator->selectToday(); 2396 mNavigator->selectToday();
2336} 2397}
2337 2398
2338void CalendarView::goNext() 2399void CalendarView::goNext()
2339{ 2400{
2340 mNavigator->selectNext(); 2401 mNavigator->selectNext();
2341} 2402}
2342 2403
2343void CalendarView::goPrevious() 2404void CalendarView::goPrevious()
2344{ 2405{
2345 mNavigator->selectPrevious(); 2406 mNavigator->selectPrevious();
2346} 2407}
2347void CalendarView::goNextMonth() 2408void CalendarView::goNextMonth()
2348{ 2409{
2349 mNavigator->selectNextMonth(); 2410 mNavigator->selectNextMonth();
2350} 2411}
2351 2412
2352void CalendarView::goPreviousMonth() 2413void CalendarView::goPreviousMonth()
2353{ 2414{
2354 mNavigator->selectPreviousMonth(); 2415 mNavigator->selectPreviousMonth();
2355} 2416}
2356void CalendarView::writeLocale() 2417void CalendarView::writeLocale()
2357{ 2418{
2358 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2419 //KPimGlobalPrefs::instance()->setGlobalConfig();
2359#if 0 2420#if 0
2360 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2421 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2361 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2422 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2362 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2423 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2363 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2424 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2364 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2425 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2365 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2426 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2366 dummy = KOPrefs::instance()->mUserDateFormatShort; 2427 dummy = KOPrefs::instance()->mUserDateFormatShort;
2367 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2428 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2368 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2429 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2369 KOPrefs::instance()->mDaylightsavingStart, 2430 KOPrefs::instance()->mDaylightsavingStart,
2370 KOPrefs::instance()->mDaylightsavingEnd ); 2431 KOPrefs::instance()->mDaylightsavingEnd );
2371 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2432 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2372#endif 2433#endif
2373} 2434}
2374void CalendarView::updateConfig() 2435void CalendarView::updateConfig()
2375{ 2436{
2376 writeLocale(); 2437 writeLocale();
2377 if ( KOPrefs::instance()->mUseAppColors ) 2438 if ( KOPrefs::instance()->mUseAppColors )
2378 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2439 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2379 emit configChanged(); 2440 emit configChanged();
2380 mTodoList->updateConfig(); 2441 mTodoList->updateConfig();
2381 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2442 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2382 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2443 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2383 // To make the "fill window" configurations work 2444 // To make the "fill window" configurations work
2384 //mViewManager->raiseCurrentView(); 2445 //mViewManager->raiseCurrentView();
2385} 2446}
2386 2447
2387 2448
2388void CalendarView::eventChanged(Event *event) 2449void CalendarView::eventChanged(Event *event)
2389{ 2450{
2390 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2451 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2391 //updateUnmanagedViews(); 2452 //updateUnmanagedViews();
2392} 2453}
2393 2454
2394void CalendarView::eventAdded(Event *event) 2455void CalendarView::eventAdded(Event *event)
2395{ 2456{
2396 changeEventDisplay(event,KOGlobals::EVENTADDED); 2457 changeEventDisplay(event,KOGlobals::EVENTADDED);
2397} 2458}
2398 2459
2399void CalendarView::eventToBeDeleted(Event *) 2460void CalendarView::eventToBeDeleted(Event *)
2400{ 2461{
2401 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2462 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2402} 2463}
2403 2464
2404void CalendarView::eventDeleted() 2465void CalendarView::eventDeleted()
2405{ 2466{
2406 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2467 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2407} 2468}
2408void CalendarView::changeTodoDisplay(Todo *which, int action) 2469void CalendarView::changeTodoDisplay(Todo *which, int action)
2409{ 2470{
2410 changeIncidenceDisplay((Incidence *)which, action); 2471 changeIncidenceDisplay((Incidence *)which, action);
2411 mDateNavigator->updateView(); //LR 2472 mDateNavigator->updateView(); //LR
2412 //mDialogManager->updateSearchDialog(); 2473 //mDialogManager->updateSearchDialog();
2413 2474
2414 if (which) { 2475 if (which) {
2415 mViewManager->updateWNview(); 2476 mViewManager->updateWNview();
2416 //mTodoList->updateView(); 2477 //mTodoList->updateView();
2417 } 2478 }
2418 2479
2419} 2480}
2420 2481
2421void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2482void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2422{ 2483{
2423 updateUnmanagedViews(); 2484 updateUnmanagedViews();
2424 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2485 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2425 if ( action == KOGlobals::EVENTDELETED ) { //delete 2486 if ( action == KOGlobals::EVENTDELETED ) { //delete
2426 mCalendar->checkAlarmForIncidence( 0, true ); 2487 mCalendar->checkAlarmForIncidence( 0, true );
2427 if ( mEventViewerDialog ) 2488 if ( mEventViewerDialog )
2428 mEventViewerDialog->hide(); 2489 mEventViewerDialog->hide();
2429 } 2490 }
2430 else 2491 else
2431 mCalendar->checkAlarmForIncidence( which , false ); 2492 mCalendar->checkAlarmForIncidence( which , false );
2432} 2493}
2433 2494
2434// most of the changeEventDisplays() right now just call the view's 2495// most of the changeEventDisplays() right now just call the view's
2435// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2496// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2436void CalendarView::changeEventDisplay(Event *which, int action) 2497void CalendarView::changeEventDisplay(Event *which, int action)
2437{ 2498{
2438 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2499 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2439 changeIncidenceDisplay((Incidence *)which, action); 2500 changeIncidenceDisplay((Incidence *)which, action);
2440 mDateNavigator->updateView(); 2501 mDateNavigator->updateView();
2441 //mDialogManager->updateSearchDialog(); 2502 //mDialogManager->updateSearchDialog();
2442 2503
2443 if (which) { 2504 if (which) {
2444 // If there is an event view visible update the display 2505 // If there is an event view visible update the display
2445 mViewManager->currentView()->changeEventDisplay(which,action); 2506 mViewManager->currentView()->changeEventDisplay(which,action);
2446 // TODO: check, if update needed 2507 // TODO: check, if update needed
2447 // if (which->getTodoStatus()) { 2508 // if (which->getTodoStatus()) {
2448 mTodoList->updateView(); 2509 mTodoList->updateView();
2449 // } 2510 // }
2450 } else { 2511 } else {
2451 mViewManager->currentView()->updateView(); 2512 mViewManager->currentView()->updateView();
2452 } 2513 }
2453} 2514}
2454 2515
2455 2516
2456void CalendarView::updateTodoViews() 2517void CalendarView::updateTodoViews()
2457{ 2518{
2458 mTodoList->updateView(); 2519 mTodoList->updateView();
2459 mViewManager->currentView()->updateView(); 2520 mViewManager->currentView()->updateView();
2460 2521
2461} 2522}
2462 2523
2463 2524
2464void CalendarView::updateView(const QDate &start, const QDate &end) 2525void CalendarView::updateView(const QDate &start, const QDate &end)
2465{ 2526{
2466 mTodoList->updateView(); 2527 mTodoList->updateView();
2467 mViewManager->updateView(start, end); 2528 mViewManager->updateView(start, end);
2468 //mDateNavigator->updateView(); 2529 //mDateNavigator->updateView();
2469} 2530}
2470 2531
2471void CalendarView::clearAllViews() 2532void CalendarView::clearAllViews()
2472{ 2533{
2473 mTodoList->clearList(); 2534 mTodoList->clearList();
2474 mViewManager->clearAllViews(); 2535 mViewManager->clearAllViews();
2475 SearchDialog * sd = mDialogManager->getSearchDialog(); 2536 SearchDialog * sd = mDialogManager->getSearchDialog();
2476 if ( sd ) { 2537 if ( sd ) {
2477 KOListView* kol = sd->listview(); 2538 KOListView* kol = sd->listview();
2478 if ( kol ) 2539 if ( kol )
2479 kol->clearList(); 2540 kol->clearList();
2480 } 2541 }
2481} 2542}
2482void CalendarView::updateView() 2543void CalendarView::updateView()
2483{ 2544{
2484 DateList tmpList = mNavigator->selectedDates(); 2545 DateList tmpList = mNavigator->selectedDates();
2485 2546
2486 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2547 if ( KOPrefs::instance()->mHideNonStartedTodos )
2487 mTodoList->updateView(); 2548 mTodoList->updateView();
2488 // We assume that the navigator only selects consecutive days. 2549 // We assume that the navigator only selects consecutive days.
2489 updateView( tmpList.first(), tmpList.last() ); 2550 updateView( tmpList.first(), tmpList.last() );
2490} 2551}
2491 2552
2492void CalendarView::updateUnmanagedViews() 2553void CalendarView::updateUnmanagedViews()
2493{ 2554{
2494 mDateNavigator->updateDayMatrix(); 2555 mDateNavigator->updateDayMatrix();
2495} 2556}
2496 2557
2497int CalendarView::msgItemDelete(const QString name) 2558int CalendarView::msgItemDelete(const QString name)
2498{ 2559{
2499 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2560 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2500 i18n("This item will be\npermanently deleted."), 2561 i18n("This item will be\npermanently deleted."),
2501 i18n("KO/Pi Confirmation"),i18n("Delete")); 2562 i18n("KO/Pi Confirmation"),i18n("Delete"));
2502} 2563}
2503 2564
2504 2565
2505void CalendarView::edit_cut() 2566void CalendarView::edit_cut()
2506{ 2567{
2507 Event *anEvent=0; 2568 Event *anEvent=0;
2508 2569
2509 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2570 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2510 2571
2511 if (mViewManager->currentView()->isEventView()) { 2572 if (mViewManager->currentView()->isEventView()) {
2512 if ( incidence && incidence->typeID() == eventID ) { 2573 if ( incidence && incidence->typeID() == eventID ) {
2513 anEvent = static_cast<Event *>(incidence); 2574 anEvent = static_cast<Event *>(incidence);
2514 } 2575 }
2515 } 2576 }
2516 2577
2517 if (!anEvent) { 2578 if (!anEvent) {
2518 KNotifyClient::beep(); 2579 KNotifyClient::beep();
2519 return; 2580 return;
2520 } 2581 }
2521 DndFactory factory( mCalendar ); 2582 DndFactory factory( mCalendar );
2522 factory.cutIncidence(anEvent); 2583 factory.cutIncidence(anEvent);
2523 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2584 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2524} 2585}
2525 2586
2526void CalendarView::edit_copy() 2587void CalendarView::edit_copy()
2527{ 2588{
2528 Event *anEvent=0; 2589 Event *anEvent=0;
2529 2590
2530 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2591 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2531 2592
2532 if (mViewManager->currentView()->isEventView()) { 2593 if (mViewManager->currentView()->isEventView()) {
2533 if ( incidence && incidence->typeID() == eventID ) { 2594 if ( incidence && incidence->typeID() == eventID ) {
2534 anEvent = static_cast<Event *>(incidence); 2595 anEvent = static_cast<Event *>(incidence);
2535 } 2596 }
2536 } 2597 }
2537 2598
2538 if (!anEvent) { 2599 if (!anEvent) {
2539 KNotifyClient::beep(); 2600 KNotifyClient::beep();
2540 return; 2601 return;
2541 } 2602 }
2542 DndFactory factory( mCalendar ); 2603 DndFactory factory( mCalendar );
2543 factory.copyIncidence(anEvent); 2604 factory.copyIncidence(anEvent);
2544} 2605}
2545 2606
2546void CalendarView::edit_paste() 2607void CalendarView::edit_paste()
2547{ 2608{
2548 QDate date = mNavigator->selectedDates().first(); 2609 QDate date = mNavigator->selectedDates().first();
2549 2610
2550 DndFactory factory( mCalendar ); 2611 DndFactory factory( mCalendar );
2551 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2612 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2552 2613
2553 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2614 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2554} 2615}
2555void CalendarView::edit_global_options() 2616void CalendarView::edit_global_options()
2556{ 2617{
2557 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2618 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2558 emit save(); 2619 emit save();
2559 emit saveStopTimer(); 2620 emit saveStopTimer();
2560 mDialogManager->showGlobalOptionsDialog(); 2621 mDialogManager->showGlobalOptionsDialog();
2561 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2622 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2562 emit saveStopTimer(); 2623 emit saveStopTimer();
2563 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!"), 2624 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!"),
2564 i18n("Timezone settings"),i18n("Reload"))) { 2625 i18n("Timezone settings"),i18n("Reload"))) {
2565 qDebug("KO: TZ reload cancelled "); 2626 qDebug("KO: TZ reload cancelled ");
2566 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2627 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2567 return; 2628 return;
2568 } 2629 }
2569 qDebug("KO: Timezone change "); 2630 qDebug("KO: Timezone change ");
2570 openCalendar( MainWindow::defaultFileName() ); 2631 openCalendar( MainWindow::defaultFileName() );
2571 setModified(true); 2632 setModified(true);
2572 } 2633 }
2573 else 2634 else
2574 qDebug("KO: No tz change "); 2635 qDebug("KO: No tz change ");
2575} 2636}
2576void CalendarView::edit_options() 2637void CalendarView::edit_options()
2577{ 2638{
2578 mDialogManager->showOptionsDialog(); 2639 mDialogManager->showOptionsDialog();
2579} 2640}
2580 2641
2581 2642
2582void CalendarView::slotSelectPickerDate( QDate d) 2643void CalendarView::slotSelectPickerDate( QDate d)
2583{ 2644{
2584 mDateFrame->hide(); 2645 mDateFrame->hide();
2585 if ( mDatePickerMode == 1 ) { 2646 if ( mDatePickerMode == 1 ) {
2586 mNavigator->slotDaySelect( d ); 2647 mNavigator->slotDaySelect( d );
2587 } else if ( mDatePickerMode == 2 ) { 2648 } else if ( mDatePickerMode == 2 ) {
2588 if ( mMoveIncidence->typeID() == todoID ) { 2649 if ( mMoveIncidence->typeID() == todoID ) {
2589 Todo * to = (Todo *) mMoveIncidence; 2650 Todo * to = (Todo *) mMoveIncidence;
2590 QTime tim; 2651 QTime tim;
2591 int len = 0; 2652 int len = 0;
2592 if ( to->hasStartDate() && to->hasDueDate() ) 2653 if ( to->hasStartDate() && to->hasDueDate() )
2593 len = to->dtStart().secsTo( to->dtDue()); 2654 len = to->dtStart().secsTo( to->dtDue());
2594 if ( to->hasDueDate() ) 2655 if ( to->hasDueDate() )
2595 tim = to->dtDue().time(); 2656 tim = to->dtDue().time();
2596 else { 2657 else {
2597 tim = QTime ( 0,0,0 ); 2658 tim = QTime ( 0,0,0 );
2598 to->setFloats( true ); 2659 to->setFloats( true );
2599 to->setHasDueDate( true ); 2660 to->setHasDueDate( true );
2600 } 2661 }
2601 QDateTime dt ( d,tim ); 2662 QDateTime dt ( d,tim );
2602 to->setDtDue( dt ); 2663 to->setDtDue( dt );
2603 2664
2604 if ( to->hasStartDate() ) { 2665 if ( to->hasStartDate() ) {
2605 if ( len>0 ) 2666 if ( len>0 )
2606 to->setDtStart(to->dtDue().addSecs( -len )); 2667 to->setDtStart(to->dtDue().addSecs( -len ));
2607 else 2668 else
2608 if (to->dtStart() > to->dtDue() ) 2669 if (to->dtStart() > to->dtDue() )
2609 to->setDtStart(to->dtDue().addDays( -3 )); 2670 to->setDtStart(to->dtDue().addDays( -3 ));
2610 } 2671 }
2611 2672
2612 todoChanged( to ); 2673 todoChanged( to );
2613 } else { 2674 } else {
2614 if ( mMoveIncidence->doesRecur() ) { 2675 if ( mMoveIncidence->doesRecur() ) {
2615#if 0 2676#if 0
2616 // PENDING implement this 2677 // PENDING implement this
2617 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2678 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2618 mCalendar()->addIncidence( newInc ); 2679 mCalendar()->addIncidence( newInc );
2619 if ( mMoveIncidence->typeID() == todoID ) 2680 if ( mMoveIncidence->typeID() == todoID )
2620 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2681 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2621 else 2682 else
2622 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2683 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2623 mMoveIncidence = newInc; 2684 mMoveIncidence = newInc;
2624 2685
2625#endif 2686#endif
2626 } 2687 }
2627 QTime tim = mMoveIncidence->dtStart().time(); 2688 QTime tim = mMoveIncidence->dtStart().time();
2628 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2689 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2629 QDateTime dt ( d,tim ); 2690 QDateTime dt ( d,tim );
2630 mMoveIncidence->setDtStart( dt ); 2691 mMoveIncidence->setDtStart( dt );
2631 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2692 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2632 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2693 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2633 } 2694 }
2634 2695
2635 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2696 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2636 } 2697 }
2637} 2698}
2638 2699
2639void CalendarView::removeCategories() 2700void CalendarView::removeCategories()
2640{ 2701{
2641 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2702 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2642 QStringList catList = KOPrefs::instance()->mCustomCategories; 2703 QStringList catList = KOPrefs::instance()->mCustomCategories;
2643 QStringList catIncList; 2704 QStringList catIncList;
2644 QStringList newCatList; 2705 QStringList newCatList;
2645 Incidence* inc = incList.first(); 2706 Incidence* inc = incList.first();
2646 int i; 2707 int i;
2647 int count = 0; 2708 int count = 0;
2648 while ( inc ) { 2709 while ( inc ) {
2649 newCatList.clear(); 2710 newCatList.clear();
2650 catIncList = inc->categories() ; 2711 catIncList = inc->categories() ;
2651 for( i = 0; i< catIncList.count(); ++i ) { 2712 for( i = 0; i< catIncList.count(); ++i ) {
2652 if ( catList.contains (catIncList[i])) 2713 if ( catList.contains (catIncList[i]))
2653 newCatList.append( catIncList[i] ); 2714 newCatList.append( catIncList[i] );
2654 } 2715 }
2655 newCatList.sort(); 2716 newCatList.sort();
2656 inc->setCategories( newCatList.join(",") ); 2717 inc->setCategories( newCatList.join(",") );
2657 inc = incList.next(); 2718 inc = incList.next();
2658 } 2719 }
2659} 2720}
2660 2721
2661int CalendarView::addCategories() 2722int CalendarView::addCategories()
2662{ 2723{
2663 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2724 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2664 QStringList catList = KOPrefs::instance()->mCustomCategories; 2725 QStringList catList = KOPrefs::instance()->mCustomCategories;
2665 QStringList catIncList; 2726 QStringList catIncList;
2666 Incidence* inc = incList.first(); 2727 Incidence* inc = incList.first();
2667 int i; 2728 int i;
2668 int count = 0; 2729 int count = 0;
2669 while ( inc ) { 2730 while ( inc ) {
2670 catIncList = inc->categories() ; 2731 catIncList = inc->categories() ;
2671 for( i = 0; i< catIncList.count(); ++i ) { 2732 for( i = 0; i< catIncList.count(); ++i ) {
2672 if ( !catList.contains (catIncList[i])) { 2733 if ( !catList.contains (catIncList[i])) {
2673 catList.append( catIncList[i] ); 2734 catList.append( catIncList[i] );
2674 //qDebug("add cat %s ", catIncList[i].latin1()); 2735 //qDebug("add cat %s ", catIncList[i].latin1());
2675 ++count; 2736 ++count;
2676 } 2737 }
2677 } 2738 }
2678 inc = incList.next(); 2739 inc = incList.next();
2679 } 2740 }
2680 catList.sort(); 2741 catList.sort();
2681 KOPrefs::instance()->mCustomCategories = catList; 2742 KOPrefs::instance()->mCustomCategories = catList;
2682 return count; 2743 return count;
2683} 2744}
2684 2745
2685void CalendarView::manageCategories() 2746void CalendarView::manageCategories()
2686{ 2747{
2687 KOCatPrefs* cp = new KOCatPrefs(); 2748 KOCatPrefs* cp = new KOCatPrefs();
2688 cp->show(); 2749 cp->show();
2689 int w =cp->sizeHint().width() ; 2750 int w =cp->sizeHint().width() ;
2690 int h = cp->sizeHint().height() ; 2751 int h = cp->sizeHint().height() ;
2691 int dw = QApplication::desktop()->width(); 2752 int dw = QApplication::desktop()->width();
2692 int dh = QApplication::desktop()->height(); 2753 int dh = QApplication::desktop()->height();
2693 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2754 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2694 if ( !cp->exec() ) { 2755 if ( !cp->exec() ) {
2695 delete cp; 2756 delete cp;
2696 return; 2757 return;
2697 } 2758 }
2698 int count = 0; 2759 int count = 0;
2699 if ( cp->addCat() ) { 2760 if ( cp->addCat() ) {
2700 count = addCategories(); 2761 count = addCategories();
2701 if ( count ) { 2762 if ( count ) {
2702 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2763 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2703 writeSettings(); 2764 writeSettings();
2704 } else 2765 } else
2705 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2766 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2706 } else { 2767 } else {
2707 removeCategories(); 2768 removeCategories();
2708 updateView(); 2769 updateView();
2709 } 2770 }
2710 delete cp; 2771 delete cp;
2711} 2772}
2712 2773
2713void CalendarView::beamIncidence(Incidence * Inc) 2774void CalendarView::beamIncidence(Incidence * Inc)
2714{ 2775{
2715 QPtrList<Incidence> delSel ; 2776 QPtrList<Incidence> delSel ;
2716 delSel.append(Inc); 2777 delSel.append(Inc);
2717 beamIncidenceList( delSel ); 2778 beamIncidenceList( delSel );
2718} 2779}
2719void CalendarView::beamCalendar() 2780void CalendarView::beamCalendar()
2720{ 2781{
2721 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2782 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2722 //qDebug("beamCalendar() "); 2783 //qDebug("beamCalendar() ");
2723 beamIncidenceList( delSel ); 2784 beamIncidenceList( delSel );
2724} 2785}
2725void CalendarView::beamFilteredCalendar() 2786void CalendarView::beamFilteredCalendar()
2726{ 2787{
2727 QPtrList<Incidence> delSel = mCalendar->incidences(); 2788 QPtrList<Incidence> delSel = mCalendar->incidences();
2728 //qDebug("beamFilteredCalendar() "); 2789 //qDebug("beamFilteredCalendar() ");
2729 beamIncidenceList( delSel ); 2790 beamIncidenceList( delSel );
2730} 2791}
2731void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2792void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2732{ 2793{
2733 if ( beamDialog->exec () == QDialog::Rejected ) 2794 if ( beamDialog->exec () == QDialog::Rejected )
2734 return; 2795 return;
2735#ifdef DESKTOP_VERSION 2796#ifdef DESKTOP_VERSION
2736 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2797 QString fn = locateLocal( "tmp", "kopibeamfile" );
2737#else 2798#else
2738 QString fn = "/tmp/kopibeamfile"; 2799 QString fn = "/tmp/kopibeamfile";
2739#endif 2800#endif
2740 QString mes; 2801 QString mes;
2741 bool createbup = true; 2802 bool createbup = true;
2742 if ( createbup ) { 2803 if ( createbup ) {
2743 QString description = "\n"; 2804 QString description = "\n";
2744 CalendarLocal* cal = new CalendarLocal(); 2805 CalendarLocal* cal = new CalendarLocal();
2745 if ( beamDialog->beamLocal() ) 2806 if ( beamDialog->beamLocal() )
2746 cal->setLocalTime(); 2807 cal->setLocalTime();
2747 else 2808 else
2748 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2809 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2749 Incidence *incidence = delSel.first(); 2810 Incidence *incidence = delSel.first();
2750 bool addText = false; 2811 bool addText = false;
2751 if ( delSel.count() < 10 ) 2812 if ( delSel.count() < 10 )
2752 addText = true; 2813 addText = true;
2753 else { 2814 else {
2754 description.sprintf(i18n(" %d items?"),delSel.count() ); 2815 description.sprintf(i18n(" %d items?"),delSel.count() );
2755 } 2816 }
2756 while ( incidence ) { 2817 while ( incidence ) {
2757 Incidence *in = incidence->clone(); 2818 Incidence *in = incidence->clone();
2758 if ( ! in->summary().isEmpty() ) { 2819 if ( ! in->summary().isEmpty() ) {
2759 in->setDescription(""); 2820 in->setDescription("");
2760 } else { 2821 } else {
2761 in->setSummary( in->description().left(20)); 2822 in->setSummary( in->description().left(20));
2762 in->setDescription(""); 2823 in->setDescription("");
2763 } 2824 }
2764 if ( addText ) 2825 if ( addText )
2765 description += in->summary() + "\n"; 2826 description += in->summary() + "\n";
2766 cal->addIncidence( in ); 2827 cal->addIncidence( in );
2767 incidence = delSel.next(); 2828 incidence = delSel.next();
2768 } 2829 }
2769 if ( beamDialog->beamVcal() ) { 2830 if ( beamDialog->beamVcal() ) {
2770 fn += ".vcs"; 2831 fn += ".vcs";
2771 FileStorage storage( cal, fn, new VCalFormat ); 2832 FileStorage storage( cal, fn, new VCalFormat );
2772 storage.save(); 2833 storage.save();
2773 } else { 2834 } else {
2774 fn += ".ics"; 2835 fn += ".ics";
2775 FileStorage storage( cal, fn, new ICalFormat( ) ); 2836 FileStorage storage( cal, fn, new ICalFormat( ) );
2776 storage.save(); 2837 storage.save();
2777 } 2838 }
2778 delete cal; 2839 delete cal;
2779 mes = i18n("KO/Pi: Ready for beaming"); 2840 mes = i18n("KO/Pi: Ready for beaming");
2780 topLevelWidget()->setCaption(mes); 2841 topLevelWidget()->setCaption(mes);
2781 KApplication::convert2latin1( fn ); 2842 KApplication::convert2latin1( fn );
2782#ifndef DESKTOP_VERSION 2843#ifndef DESKTOP_VERSION
2783 Ir *ir = new Ir( this ); 2844 Ir *ir = new Ir( this );
2784 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2845 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2785 ir->send( fn, description, "text/x-vCalendar" ); 2846 ir->send( fn, description, "text/x-vCalendar" );
2786#endif 2847#endif
2787 } 2848 }
2788} 2849}
2789void CalendarView::beamDone( Ir *ir ) 2850void CalendarView::beamDone( Ir *ir )
2790{ 2851{
2791#ifndef DESKTOP_VERSION 2852#ifndef DESKTOP_VERSION
2792 delete ir; 2853 delete ir;
2793#endif 2854#endif
2794 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2855 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2795 topLevelWidget()->raise(); 2856 topLevelWidget()->raise();
2796} 2857}
2797 2858
2798void CalendarView::moveIncidence(Incidence * inc ) 2859void CalendarView::moveIncidence(Incidence * inc )
2799{ 2860{
2800 if ( !inc ) return; 2861 if ( !inc ) return;
2801 showDatePickerPopup(); 2862 showDatePickerPopup();
2802 mDatePickerMode = 2; 2863 mDatePickerMode = 2;
2803 mMoveIncidence = inc ; 2864 mMoveIncidence = inc ;
2804 QDate da; 2865 QDate da;
2805 if ( mMoveIncidence->typeID() == todoID ) { 2866 if ( mMoveIncidence->typeID() == todoID ) {
2806 Todo * to = (Todo *) mMoveIncidence; 2867 Todo * to = (Todo *) mMoveIncidence;
2807 if ( to->hasDueDate() ) 2868 if ( to->hasDueDate() )
2808 da = to->dtDue().date(); 2869 da = to->dtDue().date();
2809 else 2870 else
2810 da = QDate::currentDate(); 2871 da = QDate::currentDate();
2811 } else { 2872 } else {
2812 da = mMoveIncidence->dtStart().date(); 2873 da = mMoveIncidence->dtStart().date();
2813 } 2874 }
2814 //PENDING set date for recurring incidence to date of recurrence 2875 //PENDING set date for recurring incidence to date of recurrence
2815 //mMoveIncidenceOldDate; 2876 //mMoveIncidenceOldDate;
2816 mDatePicker->setDate( da ); 2877 mDatePicker->setDate( da );
2817} 2878}
2818void CalendarView::showDatePickerPopup() 2879void CalendarView::showDatePickerPopup()
2819{ 2880{
2820 if ( mDateFrame->isVisible() ) 2881 if ( mDateFrame->isVisible() )
2821 mDateFrame->hide(); 2882 mDateFrame->hide();
2822 else { 2883 else {
2823 int offX = 0, offY = 0; 2884 int offX = 0, offY = 0;
2824#ifdef DESKTOP_VERSION 2885#ifdef DESKTOP_VERSION
2825 int w =mDatePicker->sizeHint().width() ; 2886 int w =mDatePicker->sizeHint().width() ;
2826 int h = mDatePicker->sizeHint().height() ; 2887 int h = mDatePicker->sizeHint().height() ;
2827 int dw = topLevelWidget()->width(); 2888 int dw = topLevelWidget()->width();
2828 int dh = topLevelWidget()->height(); 2889 int dh = topLevelWidget()->height();
2829 offX = topLevelWidget()->x(); 2890 offX = topLevelWidget()->x();
2830 offY = topLevelWidget()->y(); 2891 offY = topLevelWidget()->y();
2831#else 2892#else
2832 int w =mDatePicker->sizeHint().width() ; 2893 int w =mDatePicker->sizeHint().width() ;
2833 int h = mDatePicker->sizeHint().height() ; 2894 int h = mDatePicker->sizeHint().height() ;
2834 int dw = QApplication::desktop()->width(); 2895 int dw = QApplication::desktop()->width();
2835 int dh = QApplication::desktop()->height(); 2896 int dh = QApplication::desktop()->height();
2836#endif 2897#endif
2837 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2898 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2838 mDateFrame->show(); 2899 mDateFrame->show();
2839 } 2900 }
2840} 2901}
2841void CalendarView::showDatePicker( ) 2902void CalendarView::showDatePicker( )
2842{ 2903{
2843 showDatePickerPopup(); 2904 showDatePickerPopup();
2844 mDatePickerMode = 1; 2905 mDatePickerMode = 1;
2845 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2906 mDatePicker->setDate( mNavigator->selectedDates().first() );
2846} 2907}
2847 2908
2848void CalendarView::showEventEditor() 2909void CalendarView::showEventEditor()
2849{ 2910{
2850#ifdef DESKTOP_VERSION 2911#ifdef DESKTOP_VERSION
2851 int x,y,w,h; 2912 int x,y,w,h;
2852 x = mEventEditor->geometry().x(); 2913 x = mEventEditor->geometry().x();
2853 y = mEventEditor->geometry().y(); 2914 y = mEventEditor->geometry().y();
2854 w = mEventEditor->width(); 2915 w = mEventEditor->width();
2855 h = mEventEditor->height(); 2916 h = mEventEditor->height();
2856 mEventEditor->show(); 2917 mEventEditor->show();
2857 mEventEditor->setGeometry(x,y,w,h); 2918 mEventEditor->setGeometry(x,y,w,h);
2858#else 2919#else
2859 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2920 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2860 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2921 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2861 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2922 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2862 qApp->processEvents(); 2923 qApp->processEvents();
2863 delete mEventEditor; 2924 delete mEventEditor;
2864 mEventEditor = mDialogManager->getEventEditor(); 2925 mEventEditor = mDialogManager->getEventEditor();
2865 topLevelWidget()->setCaption( i18n("") ); 2926 topLevelWidget()->setCaption( i18n("") );
2866 } 2927 }
2867 mEventEditor->showMaximized(); 2928 mEventEditor->showMaximized();
2868#endif 2929#endif
2869} 2930}
2870void CalendarView::showTodoEditor() 2931void CalendarView::showTodoEditor()
2871{ 2932{
2872#ifdef DESKTOP_VERSION 2933#ifdef DESKTOP_VERSION
2873 int x,y,w,h; 2934 int x,y,w,h;
2874 x = mTodoEditor->geometry().x(); 2935 x = mTodoEditor->geometry().x();
2875 y = mTodoEditor->geometry().y(); 2936 y = mTodoEditor->geometry().y();
2876 w = mTodoEditor->width(); 2937 w = mTodoEditor->width();
2877 h = mTodoEditor->height(); 2938 h = mTodoEditor->height();
2878 mTodoEditor->show(); 2939 mTodoEditor->show();
2879 mTodoEditor->setGeometry(x,y,w,h); 2940 mTodoEditor->setGeometry(x,y,w,h);
2880#else 2941#else
2881 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2942 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2882 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2943 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2883 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2944 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2884 qApp->processEvents(); 2945 qApp->processEvents();
2885 delete mTodoEditor; 2946 delete mTodoEditor;
2886 mTodoEditor = mDialogManager->getTodoEditor(); 2947 mTodoEditor = mDialogManager->getTodoEditor();
2887 topLevelWidget()->setCaption( i18n("") ); 2948 topLevelWidget()->setCaption( i18n("") );
2888 } 2949 }
2889 mTodoEditor->showMaximized(); 2950 mTodoEditor->showMaximized();
2890#endif 2951#endif
2891} 2952}
2892 2953
2893void CalendarView::cloneIncidence() 2954void CalendarView::cloneIncidence()
2894{ 2955{
2895 Incidence *incidence = currentSelection(); 2956 Incidence *incidence = currentSelection();
2896 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2957 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2897 if ( incidence ) { 2958 if ( incidence ) {
2898 cloneIncidence(incidence); 2959 cloneIncidence(incidence);
2899 } 2960 }
2900} 2961}
2901void CalendarView::moveIncidence() 2962void CalendarView::moveIncidence()
2902{ 2963{
2903 Incidence *incidence = currentSelection(); 2964 Incidence *incidence = currentSelection();
2904 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2965 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2905 if ( incidence ) { 2966 if ( incidence ) {
2906 moveIncidence(incidence); 2967 moveIncidence(incidence);
2907 } 2968 }
2908} 2969}
2909void CalendarView::beamIncidence() 2970void CalendarView::beamIncidence()
2910{ 2971{
2911 Incidence *incidence = currentSelection(); 2972 Incidence *incidence = currentSelection();
2912 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2973 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2913 if ( incidence ) { 2974 if ( incidence ) {
2914 beamIncidence(incidence); 2975 beamIncidence(incidence);
2915 } 2976 }
2916} 2977}
2917void CalendarView::toggleCancelIncidence() 2978void CalendarView::toggleCancelIncidence()
2918{ 2979{
2919 Incidence *incidence = currentSelection(); 2980 Incidence *incidence = currentSelection();
2920 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2981 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2921 if ( incidence ) { 2982 if ( incidence ) {
2922 cancelIncidence(incidence); 2983 cancelIncidence(incidence);
2923 } 2984 }
2924} 2985}
2925 2986
2926 2987
2927void CalendarView::cancelIncidence(Incidence * inc ) 2988void CalendarView::cancelIncidence(Incidence * inc )
2928{ 2989{
2929 inc->setCancelled( ! inc->cancelled() ); 2990 inc->setCancelled( ! inc->cancelled() );
2930 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2991 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2931 updateView(); 2992 updateView();
2932} 2993}
2933void CalendarView::cloneIncidence(Incidence * orgInc ) 2994void CalendarView::cloneIncidence(Incidence * orgInc )
2934{ 2995{
2935 Incidence * newInc = orgInc->clone(); 2996 Incidence * newInc = orgInc->clone();
2936 newInc->recreate(); 2997 newInc->recreate();
2937 2998
2938 if ( newInc->typeID() == todoID ) { 2999 if ( newInc->typeID() == todoID ) {
2939 Todo* t = (Todo*) newInc; 3000 Todo* t = (Todo*) newInc;
2940 bool cloneSub = false; 3001 bool cloneSub = false;
2941 if ( orgInc->relations().count() ) { 3002 if ( orgInc->relations().count() ) {
2942 int result = KMessageBox::warningYesNoCancel(this, 3003 int result = KMessageBox::warningYesNoCancel(this,
2943 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 ) ), 3004 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 ) ),
2944 i18n("Todo has subtodos"), 3005 i18n("Todo has subtodos"),
2945 i18n("Yes"), 3006 i18n("Yes"),
2946 i18n("No")); 3007 i18n("No"));
2947 3008
2948 if ( result == KMessageBox::Cancel ) { 3009 if ( result == KMessageBox::Cancel ) {
2949 delete t; 3010 delete t;
2950 return; 3011 return;
2951 } 3012 }
2952 if (result == KMessageBox::Yes) cloneSub = true; 3013 if (result == KMessageBox::Yes) cloneSub = true;
2953 } 3014 }
2954 showTodoEditor(); 3015 showTodoEditor();
2955 mTodoEditor->editTodo( t ); 3016 mTodoEditor->editTodo( t );
2956 if ( mTodoEditor->exec() ) { 3017 if ( mTodoEditor->exec() ) {
2957 if ( cloneSub ) { 3018 if ( cloneSub ) {
2958 orgInc->cloneRelations( t ); 3019 orgInc->cloneRelations( t );
2959 mCalendar->addIncidenceBranch( t ); 3020 mCalendar->addIncidenceBranch( t );
2960 updateView(); 3021 updateView();
2961 3022
2962 } else { 3023 } else {
2963 mCalendar->addTodo( t ); 3024 mCalendar->addTodo( t );
2964 updateView(); 3025 updateView();
2965 } 3026 }
2966 } else { 3027 } else {
2967 delete t; 3028 delete t;
2968 } 3029 }
2969 } 3030 }
2970 else { 3031 else {
2971 Event* e = (Event*) newInc; 3032 Event* e = (Event*) newInc;
2972 showEventEditor(); 3033 showEventEditor();
2973 mEventEditor->editEvent( e ); 3034 mEventEditor->editEvent( e );
2974 if ( mEventEditor->exec() ) { 3035 if ( mEventEditor->exec() ) {
2975 mCalendar->addEvent( e ); 3036 mCalendar->addEvent( e );
2976 updateView(); 3037 updateView();
2977 } else { 3038 } else {
2978 delete e; 3039 delete e;
2979 } 3040 }
2980 } 3041 }
2981 setActiveWindow(); 3042 setActiveWindow();
2982} 3043}
2983 3044
2984void CalendarView::newEvent() 3045void CalendarView::newEvent()
2985{ 3046{
2986 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3047 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2987 KOAgendaView *aView = mViewManager->agendaView(); 3048 KOAgendaView *aView = mViewManager->agendaView();
2988 if (aView) { 3049 if (aView) {
2989 if (aView->selectionStart().isValid()) { 3050 if (aView->selectionStart().isValid()) {
2990 if (aView->selectedIsAllDay()) { 3051 if (aView->selectedIsAllDay()) {
2991 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3052 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2992 } else { 3053 } else {
2993 newEvent(aView->selectionStart(),aView->selectionEnd()); 3054 newEvent(aView->selectionStart(),aView->selectionEnd());
2994 } 3055 }
2995 return; 3056 return;
2996 } 3057 }
2997 } 3058 }
2998 3059
2999 QDate date = mNavigator->selectedDates().first(); 3060 QDate date = mNavigator->selectedDates().first();
3000 QDateTime current = QDateTime::currentDateTime(); 3061 QDateTime current = QDateTime::currentDateTime();
3001 if ( date <= current.date() ) { 3062 if ( date <= current.date() ) {
3002 int hour = current.time().hour() +1; 3063 int hour = current.time().hour() +1;
3003 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3064 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3004 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3065 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3005 } else 3066 } else
3006 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3067 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3007 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3068 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3008 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3069 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3009} 3070}
3010 3071
3011void CalendarView::newEvent(QDateTime fh) 3072void CalendarView::newEvent(QDateTime fh)
3012{ 3073{
3013 newEvent(fh, 3074 newEvent(fh,
3014 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3075 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3015} 3076}
3016 3077
3017void CalendarView::newEvent(QDate dt) 3078void CalendarView::newEvent(QDate dt)
3018{ 3079{
3019 newEvent(QDateTime(dt, QTime(0,0,0)), 3080 newEvent(QDateTime(dt, QTime(0,0,0)),
3020 QDateTime(dt, QTime(0,0,0)), true); 3081 QDateTime(dt, QTime(0,0,0)), true);
3021} 3082}
3022void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3083void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3023{ 3084{
3024 newEvent(fromHint, toHint, false); 3085 newEvent(fromHint, toHint, false);
3025} 3086}
3026void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3087void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3027{ 3088{
3028 3089
3029 showEventEditor(); 3090 showEventEditor();
3030 mEventEditor->newEvent(fromHint,toHint,allDay); 3091 mEventEditor->newEvent(fromHint,toHint,allDay);
3031 if ( mFilterView->filtersEnabled() ) { 3092 if ( mFilterView->filtersEnabled() ) {
3032 CalFilter *filter = mFilterView->selectedFilter(); 3093 CalFilter *filter = mFilterView->selectedFilter();
3033 if (filter && filter->showCategories()) { 3094 if (filter && filter->showCategories()) {
3034 mEventEditor->setCategories(filter->categoryList().join(",") ); 3095 mEventEditor->setCategories(filter->categoryList().join(",") );
3035 } 3096 }
3036 if ( filter ) 3097 if ( filter )
3037 mEventEditor->setSecrecy( filter->getSecrecy() ); 3098 mEventEditor->setSecrecy( filter->getSecrecy() );
3038 } 3099 }
3039 mEventEditor->exec(); 3100 mEventEditor->exec();
3040 setActiveWindow(); 3101 setActiveWindow();
3041} 3102}
3042void CalendarView::todoAdded(Todo * t) 3103void CalendarView::todoAdded(Todo * t)
3043{ 3104{
3044 3105
3045 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3106 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3046 updateTodoViews(); 3107 updateTodoViews();
3047} 3108}
3048void CalendarView::todoChanged(Todo * t) 3109void CalendarView::todoChanged(Todo * t)
3049{ 3110{
3050 emit todoModified( t, 4 ); 3111 emit todoModified( t, 4 );
3051 // updateTodoViews(); 3112 // updateTodoViews();
3052} 3113}
3053void CalendarView::todoToBeDeleted(Todo *) 3114void CalendarView::todoToBeDeleted(Todo *)
3054{ 3115{
3055 //qDebug("todoToBeDeleted(Todo *) "); 3116 //qDebug("todoToBeDeleted(Todo *) ");
3056 updateTodoViews(); 3117 updateTodoViews();
3057} 3118}
3058void CalendarView::todoDeleted() 3119void CalendarView::todoDeleted()
3059{ 3120{
3060 //qDebug(" todoDeleted()"); 3121 //qDebug(" todoDeleted()");
3061 updateTodoViews(); 3122 updateTodoViews();
3062} 3123}
3063 3124
3064 3125
3065void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3126void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3066{ 3127{
3067 showTodoEditor(); 3128 showTodoEditor();
3068 mTodoEditor->newTodo(dt,0,allday); 3129 mTodoEditor->newTodo(dt,0,allday);
3069 if ( mFilterView->filtersEnabled() ) { 3130 if ( mFilterView->filtersEnabled() ) {
3070 CalFilter *filter = mFilterView->selectedFilter(); 3131 CalFilter *filter = mFilterView->selectedFilter();
3071 if (filter && filter->showCategories()) { 3132 if (filter && filter->showCategories()) {
3072 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3133 mTodoEditor->setCategories(filter->categoryList().join(",") );
3073 } 3134 }
3074 if ( filter ) 3135 if ( filter )
3075 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3136 mTodoEditor->setSecrecy( filter->getSecrecy() );
3076 } 3137 }
3077 mTodoEditor->exec(); 3138 mTodoEditor->exec();
3078 setActiveWindow(); 3139 setActiveWindow();
3079} 3140}
3080 3141
3081void CalendarView::newTodo() 3142void CalendarView::newTodo()
3082{ 3143{
3083 newTodoDateTime( QDateTime(),true ); 3144 newTodoDateTime( QDateTime(),true );
3084} 3145}
3085 3146
3086void CalendarView::newSubTodo() 3147void CalendarView::newSubTodo()
3087{ 3148{
3088 Todo *todo = selectedTodo(); 3149 Todo *todo = selectedTodo();
3089 if ( todo ) newSubTodo( todo ); 3150 if ( todo ) newSubTodo( todo );
3090} 3151}
3091 3152
3092void CalendarView::newSubTodo(Todo *parentEvent) 3153void CalendarView::newSubTodo(Todo *parentEvent)
3093{ 3154{
3094 3155
3095 showTodoEditor(); 3156 showTodoEditor();
3096 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3157 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3097 mTodoEditor->exec(); 3158 mTodoEditor->exec();
3098 setActiveWindow(); 3159 setActiveWindow();
3099} 3160}
3100 3161
3101void CalendarView::newFloatingEvent() 3162void CalendarView::newFloatingEvent()
3102{ 3163{
3103 DateList tmpList = mNavigator->selectedDates(); 3164 DateList tmpList = mNavigator->selectedDates();
3104 QDate date = tmpList.first(); 3165 QDate date = tmpList.first();
3105 3166
3106 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3167 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3107 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3168 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3108} 3169}
3109 3170
3110 3171
3111void CalendarView::editEvent( Event *event ) 3172void CalendarView::editEvent( Event *event )
3112{ 3173{
3113 3174
3114 if ( !event ) return; 3175 if ( !event ) return;
3115 if ( event->isReadOnly() ) { 3176 if ( event->isReadOnly() ) {
3116 showEvent( event ); 3177 showEvent( event );
3117 return; 3178 return;
3118 } 3179 }
3119 showEventEditor(); 3180 showEventEditor();
3120 mEventEditor->editEvent( event , mFlagEditDescription); 3181 mEventEditor->editEvent( event , mFlagEditDescription);
3121 mEventEditor->exec(); 3182 mEventEditor->exec();
3122 setActiveWindow(); 3183 setActiveWindow();
3123 3184
3124} 3185}
3125void CalendarView::editJournal( Journal *jour ) 3186void CalendarView::editJournal( Journal *jour )
3126{ 3187{
3127 if ( !jour ) return; 3188 if ( !jour ) return;
3128 mDialogManager->hideSearchDialog(); 3189 mDialogManager->hideSearchDialog();
3129 mViewManager->showJournalView(); 3190 mViewManager->showJournalView();
3130 mNavigator->slotDaySelect( jour->dtStart().date() ); 3191 mNavigator->slotDaySelect( jour->dtStart().date() );
3131} 3192}
3132void CalendarView::editTodo( Todo *todo ) 3193void CalendarView::editTodo( Todo *todo )
3133{ 3194{
3134 if ( !todo ) return; 3195 if ( !todo ) return;
3135 3196
3136 if ( todo->isReadOnly() ) { 3197 if ( todo->isReadOnly() ) {
3137 showTodo( todo ); 3198 showTodo( todo );
3138 return; 3199 return;
3139 } 3200 }
3140 showTodoEditor(); 3201 showTodoEditor();
3141 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3202 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3142 mTodoEditor->exec(); 3203 mTodoEditor->exec();
3143 setActiveWindow(); 3204 setActiveWindow();
3144 3205
3145} 3206}
3146 3207
3147KOEventViewerDialog* CalendarView::getEventViewerDialog() 3208KOEventViewerDialog* CalendarView::getEventViewerDialog()
3148{ 3209{
3149 if ( !mEventViewerDialog ) { 3210 if ( !mEventViewerDialog ) {
3150 mEventViewerDialog = new KOEventViewerDialog(0); 3211 mEventViewerDialog = new KOEventViewerDialog(0);
3151 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3212 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3152 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3213 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3153 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3214 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3154 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3215 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3155 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3216 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3156 viewManager(), SLOT( showAgendaView( bool ) ) ); 3217 viewManager(), SLOT( showAgendaView( bool ) ) );
3157 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3218 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3158 this, SLOT( slotViewerClosed() ) ); 3219 this, SLOT( slotViewerClosed() ) );
3159 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3220 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3160 this, SLOT( todoChanged(Todo *) ) ); 3221 this, SLOT( todoChanged(Todo *) ) );
3161 mEventViewerDialog->resize( 640, 480 ); 3222 mEventViewerDialog->resize( 640, 480 );
3162 3223
3163 } 3224 }
3164 return mEventViewerDialog; 3225 return mEventViewerDialog;
3165} 3226}
3166void CalendarView::showEvent(Event *event) 3227void CalendarView::showEvent(Event *event)
3167{ 3228{
3168 getEventViewerDialog()->setEvent(event); 3229 getEventViewerDialog()->setEvent(event);
3169 getEventViewerDialog()->showMe(); 3230 getEventViewerDialog()->showMe();
3170} 3231}
3171 3232
3172void CalendarView::showTodo(Todo *event) 3233void CalendarView::showTodo(Todo *event)
3173{ 3234{
3174 getEventViewerDialog()->setTodo(event); 3235 getEventViewerDialog()->setTodo(event);
3175 getEventViewerDialog()->showMe(); 3236 getEventViewerDialog()->showMe();
3176} 3237}
3177void CalendarView::showJournal( Journal *jour ) 3238void CalendarView::showJournal( Journal *jour )
3178{ 3239{
3179 getEventViewerDialog()->setJournal(jour); 3240 getEventViewerDialog()->setJournal(jour);
3180 getEventViewerDialog()->showMe(); 3241 getEventViewerDialog()->showMe();
3181 3242
3182} 3243}
3183// void CalendarView::todoModified (Todo *event, int changed) 3244// void CalendarView::todoModified (Todo *event, int changed)
3184// { 3245// {
3185// // if (mDialogList.find (event) != mDialogList.end ()) { 3246// // if (mDialogList.find (event) != mDialogList.end ()) {
3186// // kdDebug() << "Todo modified and open" << endl; 3247// // kdDebug() << "Todo modified and open" << endl;
3187// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3248// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3188// // temp->modified (changed); 3249// // temp->modified (changed);
3189 3250
3190// // } 3251// // }
3191 3252
3192// mViewManager->updateView(); 3253// mViewManager->updateView();
3193// } 3254// }
3194 3255
3195void CalendarView::appointment_show() 3256void CalendarView::appointment_show()
3196{ 3257{
3197 Event *anEvent = 0; 3258 Event *anEvent = 0;
3198 3259
3199 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3260 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3200 3261
3201 if (mViewManager->currentView()->isEventView()) { 3262 if (mViewManager->currentView()->isEventView()) {
3202 if ( incidence && incidence->typeID() == eventID ) { 3263 if ( incidence && incidence->typeID() == eventID ) {
3203 anEvent = static_cast<Event *>(incidence); 3264 anEvent = static_cast<Event *>(incidence);
3204 } 3265 }
3205 } 3266 }
3206 3267
3207 if (!anEvent) { 3268 if (!anEvent) {
3208 KNotifyClient::beep(); 3269 KNotifyClient::beep();
3209 return; 3270 return;
3210 } 3271 }
3211 3272
3212 showEvent(anEvent); 3273 showEvent(anEvent);
3213} 3274}
3214 3275
3215void CalendarView::appointment_edit() 3276void CalendarView::appointment_edit()
3216{ 3277{
3217 Event *anEvent = 0; 3278 Event *anEvent = 0;
3218 3279
3219 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3280 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3220 3281
3221 if (mViewManager->currentView()->isEventView()) { 3282 if (mViewManager->currentView()->isEventView()) {
3222 if ( incidence && incidence->typeID() == eventID ) { 3283 if ( incidence && incidence->typeID() == eventID ) {
3223 anEvent = static_cast<Event *>(incidence); 3284 anEvent = static_cast<Event *>(incidence);
3224 } 3285 }
3225 } 3286 }
3226 3287
3227 if (!anEvent) { 3288 if (!anEvent) {
3228 KNotifyClient::beep(); 3289 KNotifyClient::beep();
3229 return; 3290 return;
3230 } 3291 }
3231 3292
3232 editEvent(anEvent); 3293 editEvent(anEvent);
3233} 3294}
3234 3295
3235void CalendarView::appointment_delete() 3296void CalendarView::appointment_delete()
3236{ 3297{
3237 Event *anEvent = 0; 3298 Event *anEvent = 0;
3238 3299
3239 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3300 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3240 3301
3241 if (mViewManager->currentView()->isEventView()) { 3302 if (mViewManager->currentView()->isEventView()) {
3242 if ( incidence && incidence->typeID() == eventID ) { 3303 if ( incidence && incidence->typeID() == eventID ) {
3243 anEvent = static_cast<Event *>(incidence); 3304 anEvent = static_cast<Event *>(incidence);
3244 } 3305 }
3245 } 3306 }
3246 3307
3247 if (!anEvent) { 3308 if (!anEvent) {
3248 KNotifyClient::beep(); 3309 KNotifyClient::beep();
3249 return; 3310 return;
3250 } 3311 }
3251 3312
3252 deleteEvent(anEvent); 3313 deleteEvent(anEvent);
3253} 3314}
3254 3315
3255void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3316void CalendarView::todo_resub( Todo * parent, Todo * sub )
3256{ 3317{
3257 if (!sub) return; 3318 if (!sub) return;
3258 if ( sub->relatedTo() == parent ) 3319 if ( sub->relatedTo() == parent )
3259 return; 3320 return;
3260 sub->setRelatedTo(parent); 3321 sub->setRelatedTo(parent);
3261 sub->updated(); 3322 sub->updated();
3262 setModified(true); 3323 setModified(true);
3263 updateView(); 3324 updateView();
3264} 3325}
3265void CalendarView::todo_unsub(Todo *anTodo ) 3326void CalendarView::todo_unsub(Todo *anTodo )
3266{ 3327{
3267 todo_resub( 0, anTodo ); 3328 todo_resub( 0, anTodo );
3268} 3329}
3269 3330
3270void CalendarView::deleteTodo(Todo *todo) 3331void CalendarView::deleteTodo(Todo *todo)
3271{ 3332{
3272 if (!todo) { 3333 if (!todo) {
3273 KNotifyClient::beep(); 3334 KNotifyClient::beep();
3274 return; 3335 return;
3275 } 3336 }
3276 if (KOPrefs::instance()->mConfirm) { 3337 if (KOPrefs::instance()->mConfirm) {
3277 QString text = todo->summary().left(20); 3338 QString text = todo->summary().left(20);
3278 if (!todo->relations().isEmpty()) { 3339 if (!todo->relations().isEmpty()) {
3279 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3340 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3280 3341
3281 } 3342 }
3282 switch (msgItemDelete(text)) { 3343 switch (msgItemDelete(text)) {
3283 case KMessageBox::Continue: // OK 3344 case KMessageBox::Continue: // OK
3284 bool deleteT = false; 3345 bool deleteT = false;
3285 if (!todo->relations().isEmpty()) { 3346 if (!todo->relations().isEmpty()) {
3286 deleteT = removeCompletedSubTodos( todo ); 3347 deleteT = removeCompletedSubTodos( todo );
3287 } 3348 }
3288 // deleteT == true: todo already deleted in removeCompletedSubTodos 3349 // deleteT == true: todo already deleted in removeCompletedSubTodos
3289 if ( !deleteT ) { 3350 if ( !deleteT ) {
3290 checkExternalId( todo ); 3351 checkExternalId( todo );
3291 calendar()->deleteTodo(todo); 3352 calendar()->deleteTodo(todo);
3292 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3353 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3293 updateView(); 3354 updateView();
3294 } 3355 }
3295 break; 3356 break;
3296 } // switch 3357 } // switch
3297 } else { 3358 } else {
3298 checkExternalId( todo ); 3359 checkExternalId( todo );
3299 mCalendar->deleteTodo(todo); 3360 mCalendar->deleteTodo(todo);
3300 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3361 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3301 updateView(); 3362 updateView();
3302 } 3363 }
3303 3364
3304 emit updateSearchDialog(); 3365 emit updateSearchDialog();
3305} 3366}
3306void CalendarView::deleteJournal(Journal *jour) 3367void CalendarView::deleteJournal(Journal *jour)
3307{ 3368{
3308 if (!jour) { 3369 if (!jour) {
3309 KNotifyClient::beep(); 3370 KNotifyClient::beep();
3310 return; 3371 return;
3311 } 3372 }
3312 if (KOPrefs::instance()->mConfirm) { 3373 if (KOPrefs::instance()->mConfirm) {
3313 switch (msgItemDelete( jour->description().left(20))) { 3374 switch (msgItemDelete( jour->description().left(20))) {
3314 case KMessageBox::Continue: // OK 3375 case KMessageBox::Continue: // OK
3315 calendar()->deleteJournal(jour); 3376 calendar()->deleteJournal(jour);
3316 updateView(); 3377 updateView();
3317 break; 3378 break;
3318 } // switch 3379 } // switch
3319 } else { 3380 } else {
3320 calendar()->deleteJournal(jour);; 3381 calendar()->deleteJournal(jour);;
3321 updateView(); 3382 updateView();
3322 } 3383 }
3323 emit updateSearchDialog(); 3384 emit updateSearchDialog();
3324} 3385}
3325 3386
3326void CalendarView::deleteEvent(Event *anEvent) 3387void CalendarView::deleteEvent(Event *anEvent)
3327{ 3388{
3328 if (!anEvent) { 3389 if (!anEvent) {
3329 KNotifyClient::beep(); 3390 KNotifyClient::beep();
3330 return; 3391 return;
3331 } 3392 }
3332 3393
3333 if (anEvent->recurrence()->doesRecur()) { 3394 if (anEvent->recurrence()->doesRecur()) {
3334 QDate itemDate = mViewManager->currentSelectionDate(); 3395 QDate itemDate = mViewManager->currentSelectionDate();
3335 int km; 3396 int km;
3336 if (!itemDate.isValid()) { 3397 if (!itemDate.isValid()) {
3337 //kdDebug() << "Date Not Valid" << endl; 3398 //kdDebug() << "Date Not Valid" << endl;
3338 if (KOPrefs::instance()->mConfirm) { 3399 if (KOPrefs::instance()->mConfirm) {
3339 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3400 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3340 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3401 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3341 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3402 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3342 if ( km == KMessageBox::Continue ) 3403 if ( km == KMessageBox::Continue )
3343 km = KMessageBox::No; // No = all below 3404 km = KMessageBox::No; // No = all below
3344 } else 3405 } else
3345 km = KMessageBox::No; 3406 km = KMessageBox::No;
3346 } else { 3407 } else {
3347 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3408 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3348 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3409 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3349 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3410 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3350 i18n("KO/Pi Confirmation"),i18n("Current"), 3411 i18n("KO/Pi Confirmation"),i18n("Current"),
3351 i18n("All")); 3412 i18n("All"));
3352 } 3413 }
3353 switch(km) { 3414 switch(km) {
3354 3415
3355 case KMessageBox::No: // Continue // all 3416 case KMessageBox::No: // Continue // all
3356 //qDebug("KMessageBox::No "); 3417 //qDebug("KMessageBox::No ");
3357 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3418 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3358 schedule(Scheduler::Cancel,anEvent); 3419 schedule(Scheduler::Cancel,anEvent);
3359 3420
3360 checkExternalId( anEvent); 3421 checkExternalId( anEvent);
3361 mCalendar->deleteEvent(anEvent); 3422 mCalendar->deleteEvent(anEvent);
3362 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3423 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3363 break; 3424 break;
3364 3425
3365 // Disabled because it does not work 3426 // Disabled because it does not work
3366 //#if 0 3427 //#if 0
3367 case KMessageBox::Yes: // just this one 3428 case KMessageBox::Yes: // just this one
3368 //QDate qd = mNavigator->selectedDates().first(); 3429 //QDate qd = mNavigator->selectedDates().first();
3369 //if (!qd.isValid()) { 3430 //if (!qd.isValid()) {
3370 // kdDebug() << "no date selected, or invalid date" << endl; 3431 // kdDebug() << "no date selected, or invalid date" << endl;
3371 // KNotifyClient::beep(); 3432 // KNotifyClient::beep();
3372 // return; 3433 // return;
3373 //} 3434 //}
3374 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3435 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3375 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3436 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3376 anEvent->addExDate(itemDate); 3437 anEvent->addExDate(itemDate);
3377 int duration = anEvent->recurrence()->duration(); 3438 int duration = anEvent->recurrence()->duration();
3378 if ( duration > 0 ) { 3439 if ( duration > 0 ) {
3379 anEvent->recurrence()->setDuration( duration - 1 ); 3440 anEvent->recurrence()->setDuration( duration - 1 );
3380 } 3441 }
3381 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3442 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3382 } 3443 }
3383 break; 3444 break;
3384 //#endif 3445 //#endif
3385 } // switch 3446 } // switch
3386 } else { 3447 } else {
3387 if (KOPrefs::instance()->mConfirm) { 3448 if (KOPrefs::instance()->mConfirm) {
3388 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3449 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3389 i18n("\nAre you sure you want\nto delete this event?"), 3450 i18n("\nAre you sure you want\nto delete this event?"),
3390 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3451 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3391 case KMessageBox::Continue: // OK 3452 case KMessageBox::Continue: // OK
3392 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3453 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3393 schedule(Scheduler::Cancel,anEvent); 3454 schedule(Scheduler::Cancel,anEvent);
3394 checkExternalId( anEvent); 3455 checkExternalId( anEvent);
3395 mCalendar->deleteEvent(anEvent); 3456 mCalendar->deleteEvent(anEvent);
3396 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3457 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3397 break; 3458 break;
3398 } // switch 3459 } // switch
3399 } else { 3460 } else {
3400 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3461 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3401 schedule(Scheduler::Cancel,anEvent); 3462 schedule(Scheduler::Cancel,anEvent);
3402 checkExternalId( anEvent); 3463 checkExternalId( anEvent);
3403 mCalendar->deleteEvent(anEvent); 3464 mCalendar->deleteEvent(anEvent);
3404 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3465 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3405 } 3466 }
3406 } // if-else 3467 } // if-else
3407 emit updateSearchDialog(); 3468 emit updateSearchDialog();
3408} 3469}
3409 3470
3410bool CalendarView::deleteEvent(const QString &uid) 3471bool CalendarView::deleteEvent(const QString &uid)
3411{ 3472{
3412 Event *ev = mCalendar->event(uid); 3473 Event *ev = mCalendar->event(uid);
3413 if (ev) { 3474 if (ev) {
3414 deleteEvent(ev); 3475 deleteEvent(ev);
3415 return true; 3476 return true;
3416 } else { 3477 } else {
3417 return false; 3478 return false;
3418 } 3479 }
3419} 3480}
3420 3481
3421/*****************************************************************************/ 3482/*****************************************************************************/
3422 3483
3423void CalendarView::action_mail() 3484void CalendarView::action_mail()
3424{ 3485{
3425#ifndef KORG_NOMAIL 3486#ifndef KORG_NOMAIL
3426 KOMailClient mailClient; 3487 KOMailClient mailClient;
3427 3488
3428 Incidence *incidence = currentSelection(); 3489 Incidence *incidence = currentSelection();
3429 3490
3430 if (!incidence) { 3491 if (!incidence) {
3431 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3492 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3432 return; 3493 return;
3433 } 3494 }
3434 if(incidence->attendeeCount() == 0 ) { 3495 if(incidence->attendeeCount() == 0 ) {
3435 KMessageBox::sorry(this, 3496 KMessageBox::sorry(this,
3436 i18n("Can't generate mail:\nNo attendees defined.\n")); 3497 i18n("Can't generate mail:\nNo attendees defined.\n"));
3437 return; 3498 return;
3438 } 3499 }
3439 3500
3440 CalendarLocal cal_tmp; 3501 CalendarLocal cal_tmp;
3441 Event *event = 0; 3502 Event *event = 0;
3442 Event *ev = 0; 3503 Event *ev = 0;
3443 if ( incidence && incidence->typeID() == eventID ) { 3504 if ( incidence && incidence->typeID() == eventID ) {
3444 event = static_cast<Event *>(incidence); 3505 event = static_cast<Event *>(incidence);
3445 ev = new Event(*event); 3506 ev = new Event(*event);
3446 cal_tmp.addEvent(ev); 3507 cal_tmp.addEvent(ev);
3447 } 3508 }
3448 ICalFormat mForm(); 3509 ICalFormat mForm();
3449 QString attachment = mForm.toString( &cal_tmp ); 3510 QString attachment = mForm.toString( &cal_tmp );
3450 if (ev) delete(ev); 3511 if (ev) delete(ev);
3451 3512
3452 mailClient.mailAttendees(currentSelection(), attachment); 3513 mailClient.mailAttendees(currentSelection(), attachment);
3453 3514
3454#endif 3515#endif
3455 3516
3456#if 0 3517#if 0
3457 Event *anEvent = 0; 3518 Event *anEvent = 0;
3458 if (mViewManager->currentView()->isEventView()) { 3519 if (mViewManager->currentView()->isEventView()) {
3459 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3520 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3460 } 3521 }
3461 3522
3462 if (!anEvent) { 3523 if (!anEvent) {
3463 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3524 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3464 return; 3525 return;
3465 } 3526 }
3466 if(anEvent->attendeeCount() == 0 ) { 3527 if(anEvent->attendeeCount() == 0 ) {
3467 KMessageBox::sorry(this, 3528 KMessageBox::sorry(this,
3468 i18n("Can't generate mail:\nNo attendees defined.\n")); 3529 i18n("Can't generate mail:\nNo attendees defined.\n"));
3469 return; 3530 return;
3470 } 3531 }
3471 3532
3472 mailobject.emailEvent(anEvent); 3533 mailobject.emailEvent(anEvent);
3473#endif 3534#endif
3474} 3535}
3475 3536
3476 3537
3477void CalendarView::schedule_publish(Incidence *incidence) 3538void CalendarView::schedule_publish(Incidence *incidence)
3478{ 3539{
3479 Event *event = 0; 3540 Event *event = 0;
3480 Todo *todo = 0; 3541 Todo *todo = 0;
3481 3542
3482 if (incidence == 0) { 3543 if (incidence == 0) {
3483 incidence = mViewManager->currentView()->selectedIncidences().first(); 3544 incidence = mViewManager->currentView()->selectedIncidences().first();
3484 if (incidence == 0) { 3545 if (incidence == 0) {
3485 incidence = mTodoList->selectedIncidences().first(); 3546 incidence = mTodoList->selectedIncidences().first();
3486 } 3547 }
3487 } 3548 }
3488 if ( incidence && incidence->typeID() == eventID ) { 3549 if ( incidence && incidence->typeID() == eventID ) {
3489 event = static_cast<Event *>(incidence); 3550 event = static_cast<Event *>(incidence);
3490 } else { 3551 } else {
3491 if ( incidence && incidence->typeID() == todoID ) { 3552 if ( incidence && incidence->typeID() == todoID ) {
3492 todo = static_cast<Todo *>(incidence); 3553 todo = static_cast<Todo *>(incidence);
3493 } 3554 }
3494 } 3555 }
3495 3556
3496 if (!event && !todo) { 3557 if (!event && !todo) {
3497 KMessageBox::sorry(this,i18n("No event selected.")); 3558 KMessageBox::sorry(this,i18n("No event selected."));
3498 return; 3559 return;
3499 } 3560 }
3500 3561
3501 PublishDialog *publishdlg = new PublishDialog(); 3562 PublishDialog *publishdlg = new PublishDialog();
3502 if (incidence->attendeeCount()>0) { 3563 if (incidence->attendeeCount()>0) {
3503 QPtrList<Attendee> attendees = incidence->attendees(); 3564 QPtrList<Attendee> attendees = incidence->attendees();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index cdce072..0144ba4 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,645 +1,650 @@
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//#include <koprefs.h>
47 48
48class QWidgetStack; 49class QWidgetStack;
49class QSplitter; 50class QSplitter;
50 51class KopiCalendarFile;
51class CalPrinter; 52class CalPrinter;
52class KOFilterView; 53class KOFilterView;
53class KOCalEditView; 54class KOCalEditView;
54class KOViewManager; 55class KOViewManager;
55class KODialogManager; 56class KODialogManager;
56class KOTodoView; 57class KOTodoView;
57class KDateNavigator; 58class KDateNavigator;
58class DateNavigatorContainer; 59class DateNavigatorContainer;
59class DateNavigator; 60class DateNavigator;
60class KOIncidenceEditor; 61class KOIncidenceEditor;
61class KDatePicker; 62class KDatePicker;
62class ResourceView; 63class ResourceView;
63class KOEventEditor; 64class KOEventEditor;
64class KOTodoEditor ; 65class KOTodoEditor ;
65class KOEventViewerDialog; 66class KOEventViewerDialog;
66class KOBeamPrefs; 67class KOBeamPrefs;
67class KSyncProfile; 68class KSyncProfile;
68class AlarmDialog; 69class AlarmDialog;
69class KCal::Attendee; 70class KCal::Attendee;
70 71
71namespace KCal { class FileStorage; } 72namespace KCal { class FileStorage; }
72 73
73using namespace KCal; 74using namespace KCal;
74 75
75/** 76/**
76 This is the main calendar widget. It provides the different vies on t he 77 This is the main calendar widget. It provides the different vies on t he
77 calendar data as well as the date navigator. It also handles synchronisation 78 calendar data as well as the date navigator. It also handles synchronisation
78 of the different views and controls the different dialogs like preferences, 79 of the different views and controls the different dialogs like preferences,
79 event editor, search dialog etc. 80 event editor, search dialog etc.
80 81
81 @short main calendar view widget 82 @short main calendar view widget
82 @author Cornelius Schumacher 83 @author Cornelius Schumacher
83*/ 84*/
84 85
85#include <qtextbrowser.h> 86#include <qtextbrowser.h>
86#include <qtextcodec.h> 87#include <qtextcodec.h>
87 88
88class MissedAlarmTextBrowser : public QTextBrowser { 89class MissedAlarmTextBrowser : public QTextBrowser {
89 Q_OBJECT 90 Q_OBJECT
90 public: 91 public:
91 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 92 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
92 ~MissedAlarmTextBrowser(); 93 ~MissedAlarmTextBrowser();
93 void setSource(const QString & n); 94 void setSource(const QString & n);
94 95
95 private: 96 private:
96 Incidence * getNextInc(QDateTime start ); 97 Incidence * getNextInc(QDateTime start );
97 QPtrList<Incidence> mAlarms; 98 QPtrList<Incidence> mAlarms;
98 signals: 99 signals:
99 void showIncidence( QString uid); 100 void showIncidence( QString uid);
100}; 101};
101 102
102 103
103class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 104class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
104{ 105{
105 Q_OBJECT 106 Q_OBJECT
106 public: 107 public:
107 /** 108 /**
108 Constructs a new calendar view widget. 109 Constructs a new calendar view widget.
109 110
110 @param calendar calendar document 111 @param calendar calendar document
111 @param parent parent window 112 @param parent parent window
112 @param name Qt internal widget object name 113 @param name Qt internal widget object name
113 */ 114 */
114 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 115 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
115 const char *name = 0 ); 116 const char *name = 0 );
116 CalendarView( Calendar *calendar, QWidget *parent = 0, 117 CalendarView( Calendar *calendar, QWidget *parent = 0,
117 const char *name = 0 ); 118 const char *name = 0 );
118 virtual ~CalendarView(); 119 virtual ~CalendarView();
119 120
120 Calendar *calendar() { return mCalendar; } 121 Calendar *calendar() { return mCalendar; }
121 122
122 KOViewManager *viewManager(); 123 KOViewManager *viewManager();
123 KODialogManager *dialogManager(); 124 KODialogManager *dialogManager();
124 125
125 QDate startDate(); 126 QDate startDate();
126 QDate endDate(); 127 QDate endDate();
127 128
128 QWidgetStack *viewStack(); 129 QWidgetStack *viewStack();
129 QWidget *leftFrame(); 130 QWidget *leftFrame();
130 131
131 DateNavigator *dateNavigator(); 132 DateNavigator *dateNavigator();
132 KDateNavigator *dateNavigatorWidget(); 133 KDateNavigator *dateNavigatorWidget();
133 134
134 void addView(KOrg::BaseView *); 135 void addView(KOrg::BaseView *);
135 void showView(KOrg::BaseView *); 136 void showView(KOrg::BaseView *);
136 KOEventViewerDialog* getEventViewerDialog(); 137 KOEventViewerDialog* getEventViewerDialog();
137 Incidence *currentSelection(); 138 Incidence *currentSelection();
138 139
139 signals: 140 signals:
140 void save (); 141 void save ();
141 void saveStopTimer (); 142 void saveStopTimer ();
142 void tempDisableBR(bool); 143 void tempDisableBR(bool);
143 /** This todo has been modified */ 144 /** This todo has been modified */
144 void todoModified(Todo *, int); 145 void todoModified(Todo *, int);
145 146
146 /** when change is made to options dialog, the topwidget will catch this 147 /** when change is made to options dialog, the topwidget will catch this
147 * and emit this signal which notifies all widgets which have registered 148 * and emit this signal which notifies all widgets which have registered
148 * for notification to update their settings. */ 149 * for notification to update their settings. */
149 void configChanged(); 150 void configChanged();
150 /** emitted when the topwidget is closing down, so that any attached 151 /** emitted when the topwidget is closing down, so that any attached
151 child windows can also close. */ 152 child windows can also close. */
152 void closingDown(); 153 void closingDown();
153 /** emitted right before we die */ 154 /** emitted right before we die */
154 void closed(QWidget *); 155 void closed(QWidget *);
155 156
156 /** Emitted when state of modified flag changes */ 157 /** Emitted when state of modified flag changes */
157 void modifiedChanged(bool); 158 void modifiedChanged(bool);
158 void signalmodified(); 159 void signalmodified();
159 160
160 /** Emitted when state of read-only flag changes */ 161 /** Emitted when state of read-only flag changes */
161 void readOnlyChanged(bool); 162 void readOnlyChanged(bool);
162 163
163 /** Emitted when the unit of navigation changes */ 164 /** Emitted when the unit of navigation changes */
164 void changeNavStringPrev(const QString &); 165 void changeNavStringPrev(const QString &);
165 void changeNavStringNext(const QString &); 166 void changeNavStringNext(const QString &);
166 167
167 /** Emitted when state of events selection has changed and user is organizer*/ 168 /** Emitted when state of events selection has changed and user is organizer*/
168 void organizerEventsSelected(bool); 169 void organizerEventsSelected(bool);
169 /** Emitted when state of events selection has changed and user is attendee*/ 170 /** Emitted when state of events selection has changed and user is attendee*/
170 void groupEventsSelected(bool); 171 void groupEventsSelected(bool);
171 /** 172 /**
172 Emitted when an incidence gets selected. If the selection is cleared the 173 Emitted when an incidence gets selected. If the selection is cleared the
173 signal is emitted with 0 as argument. 174 signal is emitted with 0 as argument.
174 */ 175 */
175 void incidenceSelected( Incidence * ); 176 void incidenceSelected( Incidence * );
176 /** Emitted, when a todoitem is selected or deselected. */ 177 /** Emitted, when a todoitem is selected or deselected. */
177 void todoSelected( bool ); 178 void todoSelected( bool );
178 179
179 /** 180 /**
180 Emitted, when clipboard content changes. Parameter indicates if paste 181 Emitted, when clipboard content changes. Parameter indicates if paste
181 is possible or not. 182 is possible or not.
182 */ 183 */
183 void pasteEnabled(bool); 184 void pasteEnabled(bool);
184 185
185 /** Emitted, when the number of incoming messages has changed. */ 186 /** Emitted, when the number of incoming messages has changed. */
186 void numIncomingChanged(int); 187 void numIncomingChanged(int);
187 188
188 /** Emitted, when the number of outgoing messages has changed. */ 189 /** Emitted, when the number of outgoing messages has changed. */
189 void numOutgoingChanged(int); 190 void numOutgoingChanged(int);
190 191
191 /** Send status message, which can e.g. be displayed in the status bar. */ 192 /** Send status message, which can e.g. be displayed in the status bar. */
192 void statusMessage(const QString &); 193 void statusMessage(const QString &);
193 194
194 void calendarViewExpanded( bool ); 195 void calendarViewExpanded( bool );
195 void updateSearchDialog(); 196 void updateSearchDialog();
196 197
197 198
198 public slots: 199 public slots:
199 void checkAlarms(); 200 void checkAlarms();
200 void slotprintSelInc(); 201 void slotprintSelInc();
201 void showNextAlarms(); 202 void showNextAlarms();
202 void showOpenError(); 203 void showOpenError();
203 void watchSavedFile(); 204 void watchSavedFile();
204 void recheckTimerAlarm(); 205 void recheckTimerAlarm();
205 void checkNextTimerAlarm(); 206 void checkNextTimerAlarm();
206 void addAlarm(const QDateTime &qdt, const QString &noti ); 207 void addAlarm(const QDateTime &qdt, const QString &noti );
207 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 208 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
208 void removeAlarm(const QDateTime &qdt, const QString &noti ); 209 void removeAlarm(const QDateTime &qdt, const QString &noti );
209 210
210 /** options dialog made a changed to the configuration. we catch this 211 /** options dialog made a changed to the configuration. we catch this
211 * and notify all widgets which need to update their configuration. */ 212 * and notify all widgets which need to update their configuration. */
212 void updateConfig(); 213 void updateConfig();
213 214
214 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 215 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
215 const QStringList& anniversaryList, const QStringList& realNameList, 216 const QStringList& anniversaryList, const QStringList& realNameList,
216 const QStringList& emailList, const QStringList& assembledNameList, 217 const QStringList& emailList, const QStringList& assembledNameList,
217 const QStringList& uidList); 218 const QStringList& uidList);
218 219
219 /** 220 /**
220 Load calendar from file \a filename. If \a merge is true, load 221 Load calendar from file \a filename. If \a merge is true, load
221 calendar into existing one, if it is false, clear calendar, before 222 calendar into existing one, if it is false, clear calendar, before
222 loading. Return true, if calendar could be successfully loaded. 223 loading. Return true, if calendar could be successfully loaded.
223 */ 224 */
224 bool openCalendar(QString filename, bool merge=false); 225 bool openCalendar(QString filename, bool merge=false);
226 bool loadCalendars();
227 bool saveCalendars();
228 bool restoreCalendarSettings();
229 bool addCalendar( KopiCalendarFile * );
225 bool syncCalendar(QString filename,int mode = 0 ); 230 bool syncCalendar(QString filename,int mode = 0 );
226 231
227 /** 232 /**
228 Save calendar data to file. Return true if calendar could be 233 Save calendar data to file. Return true if calendar could be
229 successfully saved. 234 successfully saved.
230 */ 235 */
231 bool saveCalendar(QString filename); 236 bool saveCalendar(QString filename);
232 237
233 /** 238 /**
234 Close calendar. Clear calendar data and reset views to display an empty 239 Close calendar. Clear calendar data and reset views to display an empty
235 calendar. 240 calendar.
236 */ 241 */
237 void closeCalendar(); 242 void closeCalendar();
238 243
239 /** Archive old events of calendar */ 244 /** Archive old events of calendar */
240 void archiveCalendar(); 245 void archiveCalendar();
241 246
242 void showIncidence(); 247 void showIncidence();
243 void editIncidence(); 248 void editIncidence();
244 void editIncidenceDescription(); 249 void editIncidenceDescription();
245 void deleteIncidence(); 250 void deleteIncidence();
246 void cloneIncidence(); 251 void cloneIncidence();
247 void moveIncidence(); 252 void moveIncidence();
248 void beamIncidence(); 253 void beamIncidence();
249 void toggleCancelIncidence(); 254 void toggleCancelIncidence();
250 255
251 /** create an editeventwin with supplied date/time, and if bool is true, 256 /** create an editeventwin with supplied date/time, and if bool is true,
252 * make the event take all day. */ 257 * make the event take all day. */
253 void newEvent(QDateTime, QDateTime, bool allDay ); 258 void newEvent(QDateTime, QDateTime, bool allDay );
254 void newEvent(QDateTime, QDateTime); 259 void newEvent(QDateTime, QDateTime);
255 void newEvent(QDateTime fh); 260 void newEvent(QDateTime fh);
256 void newEvent(QDate dt); 261 void newEvent(QDate dt);
257 /** create new event without having a date hint. Takes current date as 262 /** create new event without having a date hint. Takes current date as
258 default hint. */ 263 default hint. */
259 void newEvent(); 264 void newEvent();
260 void newFloatingEvent(); 265 void newFloatingEvent();
261 266
262 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 267 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
263 void showIncidence(Incidence *); 268 void showIncidence(Incidence *);
264 void showIncidence(QString uid); 269 void showIncidence(QString uid);
265 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 270 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
266 void editIncidence(Incidence *); 271 void editIncidence(Incidence *);
267 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 272 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
268 void deleteIncidence(Incidence *); 273 void deleteIncidence(Incidence *);
269 void cloneIncidence(Incidence *); 274 void cloneIncidence(Incidence *);
270 void cancelIncidence(Incidence *); 275 void cancelIncidence(Incidence *);
271 /** Create an editor for the supplied event. */ 276 /** Create an editor for the supplied event. */
272 void editEvent(Event *); 277 void editEvent(Event *);
273 /** Delete the supplied event. */ 278 /** Delete the supplied event. */
274 void deleteEvent(Event *); 279 void deleteEvent(Event *);
275 /** Delete the event with the given unique ID. Returns false, if event wasn't 280 /** Delete the event with the given unique ID. Returns false, if event wasn't
276 found. */ 281 found. */
277 bool deleteEvent(const QString &uid); 282 bool deleteEvent(const QString &uid);
278 /** Create a read-only viewer dialog for the supplied event. */ 283 /** Create a read-only viewer dialog for the supplied event. */
279 void showEvent(Event *); 284 void showEvent(Event *);
280 285
281 void editJournal(Journal *); 286 void editJournal(Journal *);
282 void showJournal(Journal *); 287 void showJournal(Journal *);
283 void deleteJournal(Journal *); 288 void deleteJournal(Journal *);
284 /** Create an editor dialog for a todo */ 289 /** Create an editor dialog for a todo */
285 void editTodo(Todo *); 290 void editTodo(Todo *);
286 /** Create a read-only viewer dialog for the supplied todo */ 291 /** Create a read-only viewer dialog for the supplied todo */
287 void showTodo(Todo *); 292 void showTodo(Todo *);
288 /** create new todo */ 293 /** create new todo */
289 void newTodo(); 294 void newTodo();
290 void newTodoDateTime(QDateTime, bool allday); 295 void newTodoDateTime(QDateTime, bool allday);
291 /** create new todo with a parent todo */ 296 /** create new todo with a parent todo */
292 void newSubTodo(); 297 void newSubTodo();
293 /** create new todo with a parent todo */ 298 /** create new todo with a parent todo */
294 void newSubTodo(Todo *); 299 void newSubTodo(Todo *);
295 /** Delete todo */ 300 /** Delete todo */
296 void deleteTodo(Todo *); 301 void deleteTodo(Todo *);
297 302
298 303
299 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 304 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
300 * emitted as result. */ 305 * emitted as result. */
301 void checkClipboard(); 306 void checkClipboard();
302 307
303 /** using the KConfig associated with the kapp variable, read in the 308 /** using the KConfig associated with the kapp variable, read in the
304 * settings from the config file. 309 * settings from the config file.
305 */ 310 */
306 void readSettings(); 311 void readSettings();
307 312
308 /** write current state to config file. */ 313 /** write current state to config file. */
309 void writeSettings(); 314 void writeSettings();
310 315
311 /** read settings for calendar filters */ 316 /** read settings for calendar filters */
312 void readFilterSettings(KConfig *config); 317 void readFilterSettings(KConfig *config);
313 318
314 /** write settings for calendar filters */ 319 /** write settings for calendar filters */
315 void writeFilterSettings(KConfig *config); 320 void writeFilterSettings(KConfig *config);
316 321
317 /** passes on the message that an event has changed to the currently 322 /** passes on the message that an event has changed to the currently
318 * activated view so that it can make appropriate display changes. */ 323 * activated view so that it can make appropriate display changes. */
319 void changeEventDisplay(Event *, int); 324 void changeEventDisplay(Event *, int);
320 void changeIncidenceDisplay(Incidence *, int); 325 void changeIncidenceDisplay(Incidence *, int);
321 void changeTodoDisplay(Todo *, int); 326 void changeTodoDisplay(Todo *, int);
322 327
323 void eventAdded(Event *); 328 void eventAdded(Event *);
324 void eventChanged(Event *); 329 void eventChanged(Event *);
325 void eventToBeDeleted(Event *); 330 void eventToBeDeleted(Event *);
326 void eventDeleted(); 331 void eventDeleted();
327 332
328 void todoAdded(Todo *); 333 void todoAdded(Todo *);
329 void todoChanged(Todo *); 334 void todoChanged(Todo *);
330 void todoToBeDeleted(Todo *); 335 void todoToBeDeleted(Todo *);
331 void todoDeleted(); 336 void todoDeleted();
332 337
333 void updateView(const QDate &start, const QDate &end); 338 void updateView(const QDate &start, const QDate &end);
334 void updateView(); 339 void updateView();
335 void clearAllViews(); 340 void clearAllViews();
336 341
337 /** Full update of visible todo views */ 342 /** Full update of visible todo views */
338 void updateTodoViews(); 343 void updateTodoViews();
339 344
340 void updateUnmanagedViews(); 345 void updateUnmanagedViews();
341 346
342 /** cut the current appointment to the clipboard */ 347 /** cut the current appointment to the clipboard */
343 void edit_cut(); 348 void edit_cut();
344 349
345 /** copy the current appointment(s) to the clipboard */ 350 /** copy the current appointment(s) to the clipboard */
346 void edit_copy(); 351 void edit_copy();
347 352
348 /** paste the current vobject(s) in the clipboard buffer into calendar */ 353 /** paste the current vobject(s) in the clipboard buffer into calendar */
349 void edit_paste(); 354 void edit_paste();
350 355
351 /** edit viewing and configuration options. */ 356 /** edit viewing and configuration options. */
352 void edit_options(); 357 void edit_options();
353 void edit_global_options(); 358 void edit_global_options();
354 /** 359 /**
355 Functions for printing, previewing a print, and setting up printing 360 Functions for printing, previewing a print, and setting up printing
356 parameters. 361 parameters.
357 */ 362 */
358 void print(); 363 void print();
359 void printSetup(); 364 void printSetup();
360 void printPreview(); 365 void printPreview();
361 366
362 /** Export as iCalendar file */ 367 /** Export as iCalendar file */
363 void exportICalendar(); 368 void exportICalendar();
364 369
365 /** Export as vCalendar file */ 370 /** Export as vCalendar file */
366 bool exportVCalendar( QString fn); 371 bool exportVCalendar( QString fn);
367 372
368 /** pop up a dialog to show an existing appointment. */ 373 /** pop up a dialog to show an existing appointment. */
369 void appointment_show(); 374 void appointment_show();
370 /** 375 /**
371 * pop up an Appointment Dialog to edit an existing appointment.Get 376 * pop up an Appointment Dialog to edit an existing appointment.Get
372 * information on the appointment from the list of unique IDs that is 377 * information on the appointment from the list of unique IDs that is
373 * currently in the View, called currIds. 378 * currently in the View, called currIds.
374 */ 379 */
375 void appointment_edit(); 380 void appointment_edit();
376 /** 381 /**
377 * pop up dialog confirming deletion of currently selected event in the 382 * pop up dialog confirming deletion of currently selected event in the
378 * View. 383 * View.
379 */ 384 */
380 void appointment_delete(); 385 void appointment_delete();
381 386
382 /** mails the currently selected event to a particular user as a vCalendar 387 /** mails the currently selected event to a particular user as a vCalendar
383 attachment. */ 388 attachment. */
384 void action_mail(); 389 void action_mail();
385 390
386 /* frees a subtodo from it's relation */ 391 /* frees a subtodo from it's relation */
387 void todo_unsub( Todo * ); 392 void todo_unsub( Todo * );
388 void todo_resub( Todo * parent, Todo * sub ); 393 void todo_resub( Todo * parent, Todo * sub );
389 394
390 /** Take ownership of selected event. */ 395 /** Take ownership of selected event. */
391 void takeOverEvent(); 396 void takeOverEvent();
392 397
393 /** Take ownership of all events in calendar. */ 398 /** Take ownership of all events in calendar. */
394 void takeOverCalendar(); 399 void takeOverCalendar();
395 400
396 /** query whether or not the calendar is "dirty". */ 401 /** query whether or not the calendar is "dirty". */
397 bool isModified(); 402 bool isModified();
398 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 403 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
399 void setModified(bool modified=true); 404 void setModified(bool modified=true);
400 405
401 /** query if the calendar is read-only. */ 406 /** query if the calendar is read-only. */
402 bool isReadOnly(); 407 bool isReadOnly();
403 /** set state of calendar to read-only */ 408 /** set state of calendar to read-only */
404 void setReadOnly(bool readOnly=true); 409 void setReadOnly(bool readOnly=true);
405 410
406 void eventUpdated(Incidence *); 411 void eventUpdated(Incidence *);
407 412
408 /* iTIP scheduling actions */ 413 /* iTIP scheduling actions */
409 void schedule_publish(Incidence *incidence = 0); 414 void schedule_publish(Incidence *incidence = 0);
410 void schedule_request(Incidence *incidence = 0); 415 void schedule_request(Incidence *incidence = 0);
411 void schedule_refresh(Incidence *incidence = 0); 416 void schedule_refresh(Incidence *incidence = 0);
412 void schedule_cancel(Incidence *incidence = 0); 417 void schedule_cancel(Incidence *incidence = 0);
413 void schedule_add(Incidence *incidence = 0); 418 void schedule_add(Incidence *incidence = 0);
414 void schedule_reply(Incidence *incidence = 0); 419 void schedule_reply(Incidence *incidence = 0);
415 void schedule_counter(Incidence *incidence = 0); 420 void schedule_counter(Incidence *incidence = 0);
416 void schedule_declinecounter(Incidence *incidence = 0); 421 void schedule_declinecounter(Incidence *incidence = 0);
417 void schedule_publish_freebusy(int daysToPublish = 30); 422 void schedule_publish_freebusy(int daysToPublish = 30);
418 423
419 void openAddressbook(); 424 void openAddressbook();
420 425
421 void editFilters(); 426 void editFilters();
422 void toggleFilerEnabled(); 427 void toggleFilerEnabled();
423 QPtrList<CalFilter> filters(); 428 QPtrList<CalFilter> filters();
424 void toggleFilter(); 429 void toggleFilter();
425 void showFilter(bool visible); 430 void showFilter(bool visible);
426 void updateFilter(); 431 void updateFilter();
427 void filterEdited(); 432 void filterEdited();
428 void selectFilter( int ); 433 void selectFilter( int );
429 KOFilterView *filterView(); 434 KOFilterView *filterView();
430 435
431 void showIntro(); 436 void showIntro();
432 437
433 /** Move the curdatepient view date to today */ 438 /** Move the curdatepient view date to today */
434 void goToday(); 439 void goToday();
435 440
436 /** Move to the next date(s) in the current view */ 441 /** Move to the next date(s) in the current view */
437 void goNext(); 442 void goNext();
438 443
439 /** Move to the previous date(s) in the current view */ 444 /** Move to the previous date(s) in the current view */
440 void goPrevious(); 445 void goPrevious();
441 /** Move to the next date(s) in the current view */ 446 /** Move to the next date(s) in the current view */
442 void goNextMonth(); 447 void goNextMonth();
443 448
444 /** Move to the previous date(s) in the current view */ 449 /** Move to the previous date(s) in the current view */
445 void goPreviousMonth(); 450 void goPreviousMonth();
446 451
447 void toggleExpand(); 452 void toggleExpand();
448 void toggleDateNavigatorWidget(); 453 void toggleDateNavigatorWidget();
449 void toggleAllDaySize(); 454 void toggleAllDaySize();
450 void dialogClosing(Incidence *); 455 void dialogClosing(Incidence *);
451 456
452 /** Look for new messages in the inbox */ 457 /** Look for new messages in the inbox */
453 void lookForIncomingMessages(); 458 void lookForIncomingMessages();
454 /** Look for new messages in the outbox */ 459 /** Look for new messages in the outbox */
455 void lookForOutgoingMessages(); 460 void lookForOutgoingMessages();
456 461
457 void processMainViewSelection( Incidence * ); 462 void processMainViewSelection( Incidence * );
458 void processTodoListSelection( Incidence * ); 463 void processTodoListSelection( Incidence * );
459 464
460 void processIncidenceSelection( Incidence * ); 465 void processIncidenceSelection( Incidence * );
461 466
462 void purgeCompleted(); 467 void purgeCompleted();
463 bool removeCompletedSubTodos( Todo* ); 468 bool removeCompletedSubTodos( Todo* );
464 void slotCalendarChanged(); 469 void slotCalendarChanged();
465 bool importBday(); 470 bool importBday();
466 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 471 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
467 bool importQtopia( const QString &categoriesFile, 472 bool importQtopia( const QString &categoriesFile,
468 const QString &datebookFile, 473 const QString &datebookFile,
469 const QString &tasklistFile ); 474 const QString &tasklistFile );
470 void syncExternal( int mode ); 475 void syncExternal( int mode );
471 void slotSelectPickerDate( QDate ) ; 476 void slotSelectPickerDate( QDate ) ;
472 void showDatePicker() ; 477 void showDatePicker() ;
473 void showDatePickerPopup() ; 478 void showDatePickerPopup() ;
474 void moveIncidence(Incidence *) ; 479 void moveIncidence(Incidence *) ;
475 void beamIncidence(Incidence *) ; 480 void beamIncidence(Incidence *) ;
476 void beamCalendar() ; 481 void beamCalendar() ;
477 void beamFilteredCalendar() ; 482 void beamFilteredCalendar() ;
478 void beamIncidenceList(QPtrList<Incidence>) ; 483 void beamIncidenceList(QPtrList<Incidence>) ;
479 void manageCategories(); 484 void manageCategories();
480 int addCategories(); 485 int addCategories();
481 void removeCategories(); 486 void removeCategories();
482 void setSyncDevice( QString ); 487 void setSyncDevice( QString );
483 void setSyncName( QString ); 488 void setSyncName( QString );
484 void showDay( QDate ); 489 void showDay( QDate );
485 void undo_delete(); 490 void undo_delete();
486 protected slots: 491 protected slots:
487 void resetFocus(); 492 void resetFocus();
488 void slotViewerClosed(); 493 void slotViewerClosed();
489 void timerAlarm(); 494 void timerAlarm();
490 void suspendAlarm(); 495 void suspendAlarm();
491 void beamDone( Ir *ir ); 496 void beamDone( Ir *ir );
492 /** Select a view or adapt the current view to display the specified dates. */ 497 /** Select a view or adapt the current view to display the specified dates. */
493 void showDates( const KCal::DateList & ); 498 void showDates( const KCal::DateList & );
494 void selectWeekNum ( int ); 499 void selectWeekNum ( int );
495 500
496 public: 501 public:
497 // show a standard warning 502 // show a standard warning
498 // returns KMsgBox::yesNoCancel() 503 // returns KMsgBox::yesNoCancel()
499 int msgCalModified(); 504 int msgCalModified();
500 virtual bool sync(KSyncManager* manager, QString filename, int mode); 505 virtual bool sync(KSyncManager* manager, QString filename, int mode);
501 506
502 virtual bool syncExternal(KSyncManager* manager, QString resource); 507 virtual bool syncExternal(KSyncManager* manager, QString resource);
503 virtual void removeSyncInfo( QString syncProfile); 508 virtual void removeSyncInfo( QString syncProfile);
504 void setSyncManager(KSyncManager* manager); 509 void setSyncManager(KSyncManager* manager);
505 void setLoadedFileVersion(QDateTime); 510 void setLoadedFileVersion(QDateTime);
506 bool checkFileVersion(QString fn); 511 bool checkFileVersion(QString fn);
507 bool checkFileChanged(QString fn); 512 bool checkFileChanged(QString fn);
508 Event* getLastSyncEvent(); 513 Event* getLastSyncEvent();
509 /** Adapt navigation units correpsonding to step size of navigation of the 514 /** Adapt navigation units correpsonding to step size of navigation of the
510 * current view. 515 * current view.
511 */ 516 */
512 void adaptNavigationUnits(); 517 void adaptNavigationUnits();
513 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 518 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
514 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 519 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
515 //Attendee* getYourAttendee(Event *event); 520 //Attendee* getYourAttendee(Event *event);
516 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 521 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
517 protected: 522 protected:
518 void schedule(Scheduler::Method, Incidence *incidence = 0); 523 void schedule(Scheduler::Method, Incidence *incidence = 0);
519 524
520 // returns KMsgBox::OKCandel() 525 // returns KMsgBox::OKCandel()
521 int msgItemDelete(const QString name); 526 int msgItemDelete(const QString name);
522 void showEventEditor(); 527 void showEventEditor();
523 void showTodoEditor(); 528 void showTodoEditor();
524 void writeLocale(); 529 void writeLocale();
525 Todo *selectedTodo(); 530 Todo *selectedTodo();
526 531
527 private: 532 private:
528 QDateTime mNextAlarmDateTime; 533 QDateTime mNextAlarmDateTime;
529 bool mViewerCallerIsSearchDialog; 534 bool mViewerCallerIsSearchDialog;
530 bool mBlockShowDates; 535 bool mBlockShowDates;
531 KSyncManager* mSyncManager; 536 KSyncManager* mSyncManager;
532 AlarmDialog * mAlarmDialog; 537 AlarmDialog * mAlarmDialog;
533 QString mAlarmNotification; 538 QString mAlarmNotification;
534 QString mSuspendAlarmNotification; 539 QString mSuspendAlarmNotification;
535 QTimer* mSuspendTimer; 540 QTimer* mSuspendTimer;
536 QTimer* mAlarmTimer; 541 QTimer* mAlarmTimer;
537 QTimer* mRecheckAlarmTimer; 542 QTimer* mRecheckAlarmTimer;
538 void computeAlarm( QString ); 543 void computeAlarm( QString );
539 void startAlarm( QString, QString ); 544 void startAlarm( QString, QString );
540 void setSyncEventsReadOnly(); 545 void setSyncEventsReadOnly();
541 546
542 QDateTime loadedFileVersion; 547 QDateTime loadedFileVersion;
543 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 548 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
544 void checkExternalId( Incidence * inc ); 549 void checkExternalId( Incidence * inc );
545 int mGlobalSyncMode; 550 int mGlobalSyncMode;
546 QString mCurrentSyncDevice; 551 QString mCurrentSyncDevice;
547 QString mCurrentSyncName; 552 QString mCurrentSyncName;
548 KOBeamPrefs* beamDialog; 553 KOBeamPrefs* beamDialog;
549 void init(); 554 void init();
550 int mDatePickerMode; 555 int mDatePickerMode;
551 bool mFlagEditDescription; 556 bool mFlagEditDescription;
552 QDateTime mLastCalendarSync; 557 QDateTime mLastCalendarSync;
553 void createPrinter(); 558 void createPrinter();
554 559
555 void calendarModified( bool, Calendar * ); 560 void calendarModified( bool, Calendar * );
556 561
557 CalPrinter *mCalPrinter; 562 CalPrinter *mCalPrinter;
558 563
559 QSplitter *mPanner; 564 QSplitter *mPanner;
560 QSplitter *mLeftSplitter; 565 QSplitter *mLeftSplitter;
561 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; 566 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
562 QWidgetStack *mRightFrame; 567 QWidgetStack *mRightFrame;
563 568
564 KDatePicker* mDatePicker; 569 KDatePicker* mDatePicker;
565 QVBox* mDateFrame; 570 QVBox* mDateFrame;
566 571
567 DateNavigatorContainer *mDateNavigator; // widget showing small month view. 572 DateNavigatorContainer *mDateNavigator; // widget showing small month view.
568 573
569 KOFilterView *mFilterView; 574 KOFilterView *mFilterView;
570 KOCalEditView *mCalEditView; 575 KOCalEditView *mCalEditView;
571 576
572 ResourceView *mResourceView; 577 ResourceView *mResourceView;
573 578
574 // calendar object for this viewing instance 579 // calendar object for this viewing instance
575 Calendar *mCalendar; 580 Calendar *mCalendar;
576 581
577 CalendarResourceManager *mResourceManager; 582 CalendarResourceManager *mResourceManager;
578 583
579 FileStorage *mStorage; 584 FileStorage *mStorage;
580 585
581 DateNavigator *mNavigator; 586 DateNavigator *mNavigator;
582 587
583 KOViewManager *mViewManager; 588 KOViewManager *mViewManager;
584 KODialogManager *mDialogManager; 589 KODialogManager *mDialogManager;
585 590
586 // Calendar filters 591 // Calendar filters
587 QPtrList<CalFilter> mFilters; 592 QPtrList<CalFilter> mFilters;
588 593
589 // various housekeeping variables. 594 // various housekeeping variables.
590 bool mModified; // flag indicating if calendar is modified 595 bool mModified; // flag indicating if calendar is modified
591 bool mReadOnly; // flag indicating if calendar is read-only 596 bool mReadOnly; // flag indicating if calendar is read-only
592 QDate mSaveSingleDate; 597 QDate mSaveSingleDate;
593 598
594 Incidence *mSelectedIncidence; 599 Incidence *mSelectedIncidence;
595 Incidence *mMoveIncidence; 600 Incidence *mMoveIncidence;
596 QDate mMoveIncidenceOldDate; 601 QDate mMoveIncidenceOldDate;
597 KOTodoView *mTodoList; 602 KOTodoView *mTodoList;
598 KOEventEditor * mEventEditor; 603 KOEventEditor * mEventEditor;
599 KOTodoEditor * mTodoEditor; 604 KOTodoEditor * mTodoEditor;
600 KOEventViewerDialog * mEventViewerDialog; 605 KOEventViewerDialog * mEventViewerDialog;
601 void keyPressEvent ( QKeyEvent *e) ; 606 void keyPressEvent ( QKeyEvent *e) ;
602 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 607 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
603}; 608};
604 609
605 610
606class CalendarViewVisitor : public Incidence::Visitor 611class CalendarViewVisitor : public Incidence::Visitor
607{ 612{
608 public: 613 public:
609 CalendarViewVisitor() : mView( 0 ) {} 614 CalendarViewVisitor() : mView( 0 ) {}
610 615
611 bool act( Incidence *incidence, CalendarView *view ) 616 bool act( Incidence *incidence, CalendarView *view )
612 { 617 {
613 mView = view; 618 mView = view;
614 return incidence->accept( *this ); 619 return incidence->accept( *this );
615 } 620 }
616 621
617 protected: 622 protected:
618 CalendarView *mView; 623 CalendarView *mView;
619}; 624};
620 625
621class ShowIncidenceVisitor : public CalendarViewVisitor 626class ShowIncidenceVisitor : public CalendarViewVisitor
622{ 627{
623 protected: 628 protected:
624 bool visit( Event *event ) { mView->showEvent( event ); return true; } 629 bool visit( Event *event ) { mView->showEvent( event ); return true; }
625 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 630 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
626 bool visit( Journal * j ) { mView->showJournal( j );return true; } 631 bool visit( Journal * j ) { mView->showJournal( j );return true; }
627}; 632};
628 633
629class EditIncidenceVisitor : public CalendarViewVisitor 634class EditIncidenceVisitor : public CalendarViewVisitor
630{ 635{
631 protected: 636 protected:
632 bool visit( Event *event ) { mView->editEvent( event ); return true; } 637 bool visit( Event *event ) { mView->editEvent( event ); return true; }
633 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 638 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
634 bool visit( Journal *j ) { mView->editJournal( j); return true; } 639 bool visit( Journal *j ) { mView->editJournal( j); return true; }
635}; 640};
636 641
637class DeleteIncidenceVisitor : public CalendarViewVisitor 642class DeleteIncidenceVisitor : public CalendarViewVisitor
638{ 643{
639 protected: 644 protected:
640 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 645 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
641 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 646 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
642 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 647 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
643}; 648};
644 649
645#endif 650#endif
diff --git a/korganizer/kofilterview.cpp b/korganizer/kofilterview.cpp
index 2dd4567..29a4393 100644
--- a/korganizer/kofilterview.cpp
+++ b/korganizer/kofilterview.cpp
@@ -1,383 +1,383 @@
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> 27#include <qlayout.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qdialog.h> 29#include <qdialog.h>
30 30
31 31
32#include <libkcal/calfilter.h> 32#include <libkcal/calfilter.h>
33 33
34#include "kofilterview.h" 34#include "kofilterview.h"
35#include "koprefs.h" 35#include "koprefs.h"
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kcolorbutton.h> 38#include <kcolorbutton.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40 40
41 41
42#include <kurlrequester.h> 42#include <kurlrequester.h>
43#include <klineedit.h> 43#include <klineedit.h>
44 44
45class KONewCalPrefs : public QDialog 45class KONewCalPrefs : public QDialog
46{ 46{
47 public: 47 public:
48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) : 48 KONewCalPrefs( QWidget *parent=0, const char *name=0 ) :
49 QDialog( parent, name, true ) 49 QDialog( parent, name, true )
50 { 50 {
51 setCaption( i18n("Add new Calendar") ); 51 setCaption( i18n("Add new Calendar") );
52 QVBoxLayout* lay = new QVBoxLayout( this ); 52 QVBoxLayout* lay = new QVBoxLayout( this );
53 lay->setSpacing( 3 ); 53 lay->setSpacing( 3 );
54 lay->setMargin( 3 ); 54 lay->setMargin( 3 );
55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this ); 55 QLabel * lab = new QLabel( i18n("<b>Name of new calendar:</b>"), this );
56 lay->addWidget( lab ); 56 lay->addWidget( lab );
57 nameE = new KLineEdit( this ); 57 nameE = new KLineEdit( this );
58 lay->addWidget( nameE ); 58 lay->addWidget( nameE );
59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this ); 59 lab = new QLabel( i18n("Local ical (*.ics) file:"), this );
60 lay->addWidget( lab ); 60 lay->addWidget( lab );
61 url = new KURLRequester ( this ); 61 url = new KURLRequester ( this );
62 lay->addWidget( url ); 62 lay->addWidget( url );
63 QPushButton * ok = new QPushButton( i18n("OK"), this ); 63 QPushButton * ok = new QPushButton( i18n("OK"), this );
64 lay->addWidget( ok ); 64 lay->addWidget( ok );
65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 65 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
66 lay->addWidget( cancel ); 66 lay->addWidget( cancel );
67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 67 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 68 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
69 resize( 200, 200 ); 69 //resize( 200, 200 );
70 } 70 }
71 71
72 QString calName() { return nameE->text(); } 72 QString calName() { return nameE->text(); }
73 QString calFileName() { return url->url(); } 73 QString calFileName() { return url->url(); }
74private: 74private:
75 KLineEdit* nameE; 75 KLineEdit* nameE;
76 KURLRequester *url; 76 KURLRequester *url;
77}; 77};
78 78
79 79
80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent, 80KOFilterView::KOFilterView(QPtrList<CalFilter> *filterList,QWidget* parent,
81 const char* name,WFlags fl ) 81 const char* name,WFlags fl )
82 : KOFilterView_base(parent,name,fl) 82 : KOFilterView_base(parent,name,fl)
83{ 83{
84 mFilters = filterList; 84 mFilters = filterList;
85 85
86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged())); 86 connect(mSelectionCombo,SIGNAL(activated(int)),SIGNAL(filterChanged()));
87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged())); 87 connect(mEnabledCheck,SIGNAL(clicked()),SIGNAL(filterChanged()));
88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters())); 88 connect(mEditButton,SIGNAL(clicked()),SIGNAL(editFilters()));
89} 89}
90 90
91KOFilterView::~KOFilterView() 91KOFilterView::~KOFilterView()
92{ 92{
93 // no need to delete child widgets, Qt does it all for us 93 // no need to delete child widgets, Qt does it all for us
94} 94}
95 95
96bool KOFilterView::filtersEnabled() 96bool KOFilterView::filtersEnabled()
97{ 97{
98 return mEnabledCheck->isChecked(); 98 return mEnabledCheck->isChecked();
99} 99}
100 100
101void KOFilterView::setFiltersEnabled(bool set) 101void KOFilterView::setFiltersEnabled(bool set)
102{ 102{
103 mEnabledCheck->setChecked(set); 103 mEnabledCheck->setChecked(set);
104 emit filterChanged(); 104 emit filterChanged();
105} 105}
106 106
107 107
108void KOFilterView::updateFilters() 108void KOFilterView::updateFilters()
109{ 109{
110 mSelectionCombo->clear(); 110 mSelectionCombo->clear();
111 111
112 CalFilter *filter = mFilters->first(); 112 CalFilter *filter = mFilters->first();
113 while(filter) { 113 while(filter) {
114 mSelectionCombo->insertItem(filter->name()); 114 mSelectionCombo->insertItem(filter->name());
115 filter = mFilters->next(); 115 filter = mFilters->next();
116 } 116 }
117} 117}
118 118
119CalFilter *KOFilterView::selectedFilter() 119CalFilter *KOFilterView::selectedFilter()
120{ 120{
121 CalFilter *f = mFilters->at(mSelectionCombo->currentItem()); 121 CalFilter *f = mFilters->at(mSelectionCombo->currentItem());
122 return f; 122 return f;
123} 123}
124 124
125void KOFilterView::setSelectedFilter(QString filterName) 125void KOFilterView::setSelectedFilter(QString filterName)
126{ 126{
127 int filter_num = mSelectionCombo->count(); 127 int filter_num = mSelectionCombo->count();
128 int i; 128 int i;
129 for (i=0;i<filter_num;i++) { 129 for (i=0;i<filter_num;i++) {
130 if (mSelectionCombo->text(i)==filterName) 130 if (mSelectionCombo->text(i)==filterName)
131 mSelectionCombo->setCurrentItem(i); 131 mSelectionCombo->setCurrentItem(i);
132 } 132 }
133 emit filterChanged(); 133 emit filterChanged();
134} 134}
135void KOFilterView::setSelectedFilter( int fil ) 135void KOFilterView::setSelectedFilter( int fil )
136{ 136{
137 if ( fil >= mSelectionCombo->count() ) 137 if ( fil >= mSelectionCombo->count() )
138 return; 138 return;
139 mSelectionCombo->setCurrentItem( fil ); 139 mSelectionCombo->setCurrentItem( fil );
140 emit filterChanged(); 140 emit filterChanged();
141} 141}
142 142
143 143
144 144
145KOCalEditView::KOCalEditView(QWidget* parent, 145KOCalEditView::KOCalEditView(QWidget* parent,
146 const char* name ) 146 const char* name )
147 : QWidget(parent,name) 147 : QWidget(parent,name)
148{ 148{
149 mw = 0; 149 mw = 0;
150 ml = new QVBoxLayout ( this ); 150 ml = new QVBoxLayout ( this );
151} 151}
152 152
153KOCalEditView::~KOCalEditView() 153KOCalEditView::~KOCalEditView()
154{ 154{
155 // no need to delete child widgets, Qt does it all for us 155 // no need to delete child widgets, Qt does it all for us
156} 156}
157void KOCalEditView::selectCal(int id ,bool b) 157void KOCalEditView::selectCal(int id ,bool b)
158{ 158{
159 KOPrefs::instance()->getCalendar( id )->isEnabled = b; 159 KOPrefs::instance()->getCalendar( id )->isEnabled = b;
160 emit calendarEnabled ( id, b ); 160 emit calendarEnabled ( id, b );
161 161
162} 162}
163void KOCalEditView::selectStdCal( int id, bool b ) 163void KOCalEditView::selectStdCal( int id, bool b )
164{ 164{
165 165
166 if ( !b ) { 166 if ( !b ) {
167 KOCalCheckButton* it = (KOCalCheckButton*) sender(); 167 KOCalCheckButton* it = (KOCalCheckButton*) sender();
168 if ( it ) { 168 if ( it ) {
169 it->blockSignals( true ); 169 it->blockSignals( true );
170 it->setChecked( true ); 170 it->setChecked( true );
171 it->blockSignals( false ); 171 it->blockSignals( false );
172 return; 172 return;
173 } 173 }
174 return; 174 return;
175 } 175 }
176 KOCalCheckButton* sen = (KOCalCheckButton*) sender(); 176 KOCalCheckButton* sen = (KOCalCheckButton*) sender();
177 KOCalCheckButton* it = mStdandardB.first(); 177 KOCalCheckButton* it = mStdandardB.first();
178 while ( it ) { 178 while ( it ) {
179 if ( it->isChecked() ) { 179 if ( it->isChecked() ) {
180 if ( it != sen ) { 180 if ( it != sen ) {
181 it->blockSignals( true ); 181 it->blockSignals( true );
182 it->setChecked( false ); 182 it->setChecked( false );
183 it->blockSignals( false ); 183 it->blockSignals( false );
184 break; 184 break;
185 } 185 }
186 } 186 }
187 it = mStdandardB.next(); 187 it = mStdandardB.next();
188 } 188 }
189 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 189 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
190 while ( kkf ) { 190 while ( kkf ) {
191 kkf->isStandard = false; 191 kkf->isStandard = false;
192 kkf = KOPrefs::instance()->mCalendars.next(); 192 kkf = KOPrefs::instance()->mCalendars.next();
193 } 193 }
194 KOPrefs::instance()->getCalendar( id )->isStandard = true; 194 KOPrefs::instance()->getCalendar( id )->isStandard = true;
195 emit setCalendarDefault ( id ); 195 emit setCalendarDefault ( id );
196} 196}
197 197
198void KOCalEditView::selectCalAlarm(int id ,bool b ) 198void KOCalEditView::selectCalAlarm(int id ,bool b )
199{ 199{
200 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b; 200 KOPrefs::instance()->getCalendar( id )->isAlarmEnabled = b;
201 emit alarmEnabled ( id , b ); 201 emit alarmEnabled ( id , b );
202} 202}
203void KOCalEditView::selectReadOnly(int id ,bool b ) 203void KOCalEditView::selectReadOnly(int id ,bool b )
204{ 204{
205 KOPrefs::instance()->getCalendar( id )->isReadOnly = b; 205 KOPrefs::instance()->getCalendar( id )->isReadOnly = b;
206 emit calendarReadonly ( id , b ); 206 emit calendarReadonly ( id , b );
207 207
208} 208}
209void KOCalEditView::setColor( const QColor& c, int id ) 209void KOCalEditView::setColor( const QColor& c, int id )
210{ 210{
211 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c; 211 KOPrefs::instance()->getCalendar( id )->mDefaultColor = c;
212} 212}
213void KOCalEditView::deleteCal( int id ) 213void KOCalEditView::deleteCal( int id )
214{ 214{
215 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 215 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
216 QString name = kkf->mName; 216 QString name = kkf->mName;
217 QString file = kkf->mFileName; 217 QString file = kkf->mFileName;
218 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return; 218 if ( KMessageBox::warningContinueCancel( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b><tr> Do you want to remove this calendar from KO/Pi? (The file is not removed, of course!)").arg(name).arg(file) ) != KMessageBox::Continue ) return;
219 emit removeCalendar ( id ); 219 emit removeCalendar ( id );
220 KOPrefs::instance()->mCalendars.remove ( kkf ); 220 KOPrefs::instance()->mCalendars.remove ( kkf );
221 readConfig(); 221 readConfig();
222} 222}
223void KOCalEditView::infoCal( int id ) 223void KOCalEditView::infoCal( int id )
224{ 224{
225 QString name = KOPrefs::instance()->getCalendar( id )->mName; 225 QString name = KOPrefs::instance()->getCalendar( id )->mName;
226 QString file = KOPrefs::instance()->getCalendar( id )->mFileName; 226 QString file = KOPrefs::instance()->getCalendar( id )->mFileName;
227 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) ); 227 KMessageBox::information( this, i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file) );
228} 228}
229void KOCalEditView::readConfig() 229void KOCalEditView::readConfig()
230{ 230{
231 231
232 mStdandardB.clear(); 232 mStdandardB.clear();
233 mEnabledB.clear(); 233 mEnabledB.clear();
234 mAlarmB.clear(); 234 mAlarmB.clear();
235 mROB.clear(); 235 mROB.clear();
236 236
237 if ( mw ) delete mw; 237 if ( mw ) delete mw;
238 mw = new QWidget ( this ); 238 mw = new QWidget ( this );
239 ml->addWidget ( mw ); 239 ml->addWidget ( mw );
240 240
241 mainLayout = new QGridLayout ( mw , 2, 8 ); 241 mainLayout = new QGridLayout ( mw , 2, 8 );
242 //mainLayout->setSpacing( 3 ); 242 //mainLayout->setSpacing( 3 );
243 QPushButton * addBut = new QPushButton ( mw ); 243 QPushButton * addBut = new QPushButton ( mw );
244 mainLayout->addWidget( addBut,0,0 ); 244 mainLayout->addWidget( addBut,0,0 );
245 addBut->setPixmap ( SmallIcon("plus")); 245 addBut->setPixmap ( SmallIcon("plus"));
246 connect(addBut,SIGNAL(clicked()),SLOT(addCal())); 246 connect(addBut,SIGNAL(clicked()),SLOT(addCal()));
247 addBut->setMaximumWidth( addBut->sizeHint().height() ); 247 addBut->setMaximumWidth( addBut->sizeHint().height() );
248 248
249 addBut = new QPushButton ( mw ); 249 addBut = new QPushButton ( mw );
250 mainLayout->addWidget( addBut,0,1 ); 250 mainLayout->addWidget( addBut,0,1 );
251 addBut->setPixmap ( SmallIcon("eye")); 251 addBut->setPixmap ( SmallIcon("eye"));
252 connect(addBut,SIGNAL(clicked()),SLOT(enableAll())); 252 connect(addBut,SIGNAL(clicked()),SLOT(enableAll()));
253 addBut->setMaximumWidth( addBut->sizeHint().height() ); 253 addBut->setMaximumWidth( addBut->sizeHint().height() );
254 254
255 QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw ); 255 QLabel* lab = new QLabel ( " "+i18n("Calendar")+" ", mw );
256 mainLayout->addWidget( lab,0,2 ); 256 mainLayout->addWidget( lab,0,2 );
257 257
258 addBut = new QPushButton ( mw ); 258 addBut = new QPushButton ( mw );
259 mainLayout->addWidget( addBut,0,3 ); 259 mainLayout->addWidget( addBut,0,3 );
260 addBut->setPixmap ( SmallIcon("bell")); 260 addBut->setPixmap ( SmallIcon("bell"));
261 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm())); 261 connect(addBut,SIGNAL(clicked()),SLOT(enableAlarm()));
262 addBut->setMaximumWidth( addBut->sizeHint().height() ); 262 addBut->setMaximumWidth( addBut->sizeHint().height() );
263 263
264 addBut = new QPushButton ( mw ); 264 addBut = new QPushButton ( mw );
265 mainLayout->addWidget( addBut,0,4 ); 265 mainLayout->addWidget( addBut,0,4 );
266 addBut->setPixmap ( SmallIcon("pencil")); 266 addBut->setPixmap ( SmallIcon("pencil"));
267 connect(addBut,SIGNAL(clicked()),SLOT(disableRO())); 267 connect(addBut,SIGNAL(clicked()),SLOT(disableRO()));
268 addBut->setMaximumWidth( addBut->sizeHint().height() ); 268 addBut->setMaximumWidth( addBut->sizeHint().height() );
269 269
270 lab = new QLabel ( i18n(" Color "), mw ); 270 lab = new QLabel ( i18n(" Color "), mw );
271 mainLayout->addWidget( lab,0,5 ); 271 mainLayout->addWidget( lab,0,5 );
272#if 0 272#if 0
273 addBut = new QPushButton ( mw ); 273 addBut = new QPushButton ( mw );
274 mainLayout->addWidget( addBut,0,6 ); 274 mainLayout->addWidget( addBut,0,6 );
275 addBut->setPixmap ( SmallIcon("minus")); 275 addBut->setPixmap ( SmallIcon("minus"));
276 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll())); 276 connect(addBut,SIGNAL(clicked()),SLOT(deleteAll()));
277 addBut->setMaximumWidth( addBut->sizeHint().height() ); 277 addBut->setMaximumWidth( addBut->sizeHint().height() );
278#endif 278#endif
279 279
280 280
281 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 281 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
282 int row = 1; 282 int row = 1;
283 while ( kkf ) { 283 while ( kkf ) {
284 284
285 KOCalCheckButton* cb = new KOCalCheckButton( mw ); 285 KOCalCheckButton* cb = new KOCalCheckButton( mw );
286 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb ); 286 mainLayout->addWidget( cb,row,0 );mStdandardB.append( cb );
287 cb->setChecked( kkf->isStandard ); 287 cb->setChecked( kkf->isStandard );
288 cb->setNum( kkf->mCalNumber ); 288 cb->setNum( kkf->mCalNumber );
289 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) ); 289 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectStdCal(int,bool) ) );
290 cb = new KOCalCheckButton( mw ); 290 cb = new KOCalCheckButton( mw );
291 mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb ); 291 mainLayout->addWidget( cb,row,1 );mEnabledB.append( cb );
292 cb->setChecked( kkf->isEnabled ); 292 cb->setChecked( kkf->isEnabled );
293 cb->setNum( kkf->mCalNumber ); 293 cb->setNum( kkf->mCalNumber );
294 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) ); 294 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCal(int,bool) ) );
295 KOCalButton* name = new KOCalButton( mw ); 295 KOCalButton* name = new KOCalButton( mw );
296 name->setNum( kkf->mCalNumber ); 296 name->setNum( kkf->mCalNumber );
297 name->setText( kkf->mName ); 297 name->setText( kkf->mName );
298 mainLayout->addWidget( name,row,2 ); 298 mainLayout->addWidget( name,row,2 );
299 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) ); 299 connect (name, SIGNAL (selectNum(int)), SLOT ( infoCal(int) ) );
300 cb = new KOCalCheckButton( mw ); 300 cb = new KOCalCheckButton( mw );
301 mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb ); 301 mainLayout->addWidget( cb,row,3 );mAlarmB.append( cb );
302 cb->setChecked( kkf->isAlarmEnabled ); 302 cb->setChecked( kkf->isAlarmEnabled );
303 cb->setNum( kkf->mCalNumber ); 303 cb->setNum( kkf->mCalNumber );
304 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) ); 304 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectCalAlarm(int,bool) ) );
305 cb = new KOCalCheckButton( mw ); 305 cb = new KOCalCheckButton( mw );
306 mainLayout->addWidget( cb,row,4 );mROB.append( cb ); 306 mainLayout->addWidget( cb,row,4 );mROB.append( cb );
307 cb->setChecked( kkf->isReadOnly ); 307 cb->setChecked( kkf->isReadOnly );
308 cb->setNum( kkf->mCalNumber ); 308 cb->setNum( kkf->mCalNumber );
309 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) ); 309 connect (cb, SIGNAL (selectNum(int,bool)), SLOT ( selectReadOnly(int,bool) ) );
310 KColorButton *colb = new KColorButton( mw ); 310 KColorButton *colb = new KColorButton( mw );
311 mainLayout->addWidget( colb,row,5 ); 311 mainLayout->addWidget( colb,row,5 );
312 colb->setID( kkf->mCalNumber ); 312 colb->setID( kkf->mCalNumber );
313 colb->setColor( kkf->mDefaultColor ); 313 colb->setColor( kkf->mDefaultColor );
314 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) ); 314 connect (colb, SIGNAL (changedID(const QColor&, int )), SLOT ( setColor(const QColor&,int) ) );
315 if ( row > 1) { 315 if ( row > 1) {
316 KOCalButton* calb = new KOCalButton( mw ); 316 KOCalButton* calb = new KOCalButton( mw );
317 mainLayout->addWidget( calb,row,6 ); 317 mainLayout->addWidget( calb,row,6 );
318 calb->setNum( kkf->mCalNumber ); 318 calb->setNum( kkf->mCalNumber );
319 calb->setPixmap ( SmallIcon("minus")); 319 calb->setPixmap ( SmallIcon("minus"));
320 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) ); 320 connect (calb, SIGNAL (selectNum(int)), SLOT ( deleteCal(int) ) );
321 int hei = calb->sizeHint().height(); 321 int hei = calb->sizeHint().height();
322 //calb->setMaximumSize( hei*9/10, hei*9/10 ); 322 //calb->setMaximumSize( hei*9/10, hei*9/10 );
323 } 323 }
324 ++row; 324 ++row;
325 kkf = KOPrefs::instance()->mCalendars.next(); 325 kkf = KOPrefs::instance()->mCalendars.next();
326 } 326 }
327 lab = new QLabel ( "", mw ); 327 lab = new QLabel ( "", mw );
328 mainLayout->addWidget( lab,row,0 ); 328 mainLayout->addWidget( lab,row,0 );
329 mw->show(); 329 mw->show();
330 330
331} 331}
332void KOCalEditView::addCal() 332void KOCalEditView::addCal()
333{ 333{
334 qDebug("addcal "); 334 qDebug("addcal ");
335 KONewCalPrefs prefs ( this ); 335 KONewCalPrefs prefs ( this );
336 if ( ! prefs.exec() ) 336 if ( ! prefs.exec() )
337 return; 337 return;
338 QString name = prefs.calName(); 338 QString name = prefs.calName();
339 QString file = prefs.calFileName(); 339 QString file = prefs.calFileName();
340 QFileInfo fi ( file ); 340 QFileInfo fi ( file );
341 if (!fi.exists() ) { 341 if (!fi.exists() ) {
342 KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!")); 342 KMessageBox::information( this, i18n("File does not exist!\nNo calendar added!"));
343 return; 343 return;
344 } 344 }
345 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar(); 345 KopiCalendarFile * kkf = KOPrefs::instance()->getNewCalendar();
346 kkf->mName = name; 346 kkf->mName = name;
347 kkf->mFileName = file; 347 kkf->mFileName = file;
348 emit calendarAdded( kkf->mCalNumber ); 348 emit calendarAdded( kkf->mCalNumber );
349 readConfig(); 349 readConfig();
350} 350}
351void KOCalEditView::enableAll() 351void KOCalEditView::enableAll()
352{ 352{
353 toggleList( mEnabledB ); 353 toggleList( mEnabledB );
354} 354}
355void KOCalEditView::enableAlarm() 355void KOCalEditView::enableAlarm()
356{ 356{
357 toggleList( mAlarmB ); 357 toggleList( mAlarmB );
358} 358}
359void KOCalEditView::disableRO() 359void KOCalEditView::disableRO()
360{ 360{
361 toggleList( mROB ); 361 toggleList( mROB );
362} 362}
363void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list ) 363void KOCalEditView::toggleList ( QPtrList<KOCalCheckButton> list )
364{ 364{
365 bool dis = false; 365 bool dis = false;
366 KOCalCheckButton* it = list.first(); 366 KOCalCheckButton* it = list.first();
367 while ( it ) { 367 while ( it ) {
368 if ( !it->isChecked() ) { 368 if ( !it->isChecked() ) {
369 dis = true; 369 dis = true;
370 break; 370 break;
371 } 371 }
372 it = list.next(); 372 it = list.next();
373 } 373 }
374 it = list.first(); 374 it = list.first();
375 while ( it ) { 375 while ( it ) {
376 it->setChecked(dis); 376 it->setChecked(dis);
377 it = list.next(); 377 it = list.next();
378 } 378 }
379} 379}
380void KOCalEditView::deleteAll() 380void KOCalEditView::deleteAll()
381{ 381{
382 qDebug("delteAll"); 382 qDebug("delteAll");
383} 383}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 95e1607..f05ada5 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2518 +1,2518 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64#include <kglobalsettings.h> 64#include <kglobalsettings.h>
65 65
66using namespace KCal; 66using namespace KCal;
67#ifndef _WIN32_ 67#ifndef _WIN32_
68#include <unistd.h> 68#include <unistd.h>
69#else 69#else
70#ifdef _OL_IMPORT_ 70#ifdef _OL_IMPORT_
71#include "koimportoldialog.h" 71#include "koimportoldialog.h"
72#endif 72#endif
73#endif 73#endif
74#include "mainwindow.h" 74#include "mainwindow.h"
75 75
76 76
77class KOex2phonePrefs : public QDialog 77class KOex2phonePrefs : public QDialog
78{ 78{
79 public: 79 public:
80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
81 QDialog( parent, name, true ) 81 QDialog( parent, name, true )
82 { 82 {
83 setCaption( i18n("Export to phone options") ); 83 setCaption( i18n("Export to phone options") );
84 QVBoxLayout* lay = new QVBoxLayout( this ); 84 QVBoxLayout* lay = new QVBoxLayout( this );
85 lay->setSpacing( 3 ); 85 lay->setSpacing( 3 );
86 lay->setMargin( 3 ); 86 lay->setMargin( 3 );
87 QLabel *lab; 87 QLabel *lab;
88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
89 lab->setAlignment (AlignHCenter ); 89 lab->setAlignment (AlignHCenter );
90 QHBox* temphb; 90 QHBox* temphb;
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("I/O device: "), temphb ); 92 new QLabel( i18n("I/O device: "), temphb );
93 mPhoneDevice = new QLineEdit( temphb); 93 mPhoneDevice = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Connection: "), temphb ); 96 new QLabel( i18n("Connection: "), temphb );
97 mPhoneConnection = new QLineEdit( temphb); 97 mPhoneConnection = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 temphb = new QHBox( this ); 99 temphb = new QHBox( this );
100 new QLabel( i18n("Model(opt.): "), temphb ); 100 new QLabel( i18n("Model(opt.): "), temphb );
101 mPhoneModel = new QLineEdit( temphb); 101 mPhoneModel = new QLineEdit( temphb);
102 lay->addWidget( temphb ); 102 lay->addWidget( temphb );
103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
104 mWriteBackFuture->setChecked( true ); 104 mWriteBackFuture->setChecked( true );
105 lay->addWidget( mWriteBackFuture ); 105 lay->addWidget( mWriteBackFuture );
106 temphb = new QHBox( this ); 106 temphb = new QHBox( this );
107 new QLabel( i18n("Max. weeks in future: ") , temphb ); 107 new QLabel( i18n("Max. weeks in future: ") , temphb );
108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
109 mWriteBackFutureWeeks->setValue( 8 ); 109 mWriteBackFutureWeeks->setValue( 8 );
110 lay->addWidget( temphb ); 110 lay->addWidget( temphb );
111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
112 lab->setAlignment (AlignHCenter ); 112 lab->setAlignment (AlignHCenter );
113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
114 lay->addWidget( ok ); 114 lay->addWidget( ok );
115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
116 lay->addWidget( cancel ); 116 lay->addWidget( cancel );
117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
119 resize( 220, 240 ); 119 resize( 220, 240 );
120 qApp->processEvents(); 120 qApp->processEvents();
121 int dw = QApplication::desktop()->width(); 121 int dw = QApplication::desktop()->width();
122 int dh = QApplication::desktop()->height(); 122 int dh = QApplication::desktop()->height();
123 move( (dw-width())/2, (dh - height() )/2 ); 123 move( (dw-width())/2, (dh - height() )/2 );
124 } 124 }
125 125
126public: 126public:
127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
128 QCheckBox* mWriteBackFuture; 128 QCheckBox* mWriteBackFuture;
129 QSpinBox* mWriteBackFutureWeeks; 129 QSpinBox* mWriteBackFutureWeeks;
130}; 130};
131 131
132int globalFlagBlockStartup; 132int globalFlagBlockStartup;
133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
134 QMainWindow( parent, name ) 134 QMainWindow( parent, name )
135{ 135{
136 136
137 mClosed = false; 137 mClosed = false;
138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
139 QString confFile = locateLocal("config","korganizerrc"); 139 QString confFile = locateLocal("config","korganizerrc");
140 QFileInfo finf ( confFile ); 140 QFileInfo finf ( confFile );
141 bool showWarning = !finf.exists(); 141 bool showWarning = !finf.exists();
142 setIcon(SmallIcon( "ko24" ) ); 142 setIcon(SmallIcon( "ko24" ) );
143 mBlockAtStartup = true; 143 mBlockAtStartup = true;
144 mFlagKeyPressed = false; 144 mFlagKeyPressed = false;
145 setCaption("KO/Pi"); 145 setCaption("KO/Pi");
146 KOPrefs *p = KOPrefs::instance(); 146 KOPrefs *p = KOPrefs::instance();
147 KPimGlobalPrefs::instance()->setGlobalConfig(); 147 KPimGlobalPrefs::instance()->setGlobalConfig();
148 p->mCurrentDisplayedView = 0; 148 p->mCurrentDisplayedView = 0;
149 if ( p->mHourSize > 22 ) 149 if ( p->mHourSize > 22 )
150 p->mHourSize = 22; 150 p->mHourSize = 22;
151 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
152 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
153 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
154 tbd = Bottom; 154 tbd = Bottom;
155 else 155 else
156 tbd = Top; 156 tbd = Top;
157 } 157 }
158 else { 158 else {
159 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
160 tbd = Right; 160 tbd = Right;
161 else 161 else
162 tbd = Left; 162 tbd = Left;
163 } 163 }
164 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
166 globalFlagBlockStartup = 1; 166 globalFlagBlockStartup = 1;
167 iconToolBar = new QPEToolBar( this ); 167 iconToolBar = new QPEToolBar( this );
168 addToolBar (iconToolBar , tbd ); 168 addToolBar (iconToolBar , tbd );
169 169
170#ifdef DESKTOP_VERSION 170#ifdef DESKTOP_VERSION
171 if ( KOPrefs::instance()->mShowIconFilter ) 171 if ( KOPrefs::instance()->mShowIconFilter )
172#else 172#else
173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) 173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
174#endif 174#endif
175 175
176{ 176{
177 if ( p->mToolBarHorF ) { 177 if ( p->mToolBarHorF ) {
178 if ( p->mToolBarUpF ) 178 if ( p->mToolBarUpF )
179 tbd = Bottom; 179 tbd = Bottom;
180 else 180 else
181 tbd = Top; 181 tbd = Top;
182 } 182 }
183 else { 183 else {
184 if ( p->mToolBarUpF ) 184 if ( p->mToolBarUpF )
185 tbd = Right; 185 tbd = Right;
186 else 186 else
187 tbd = Left; 187 tbd = Left;
188 } 188 }
189 filterToolBar = new QPEToolBar ( this ); 189 filterToolBar = new QPEToolBar ( this );
190 filterMenubar = new QMenuBar( 0 ); 190 filterMenubar = new QMenuBar( 0 );
191 QFontMetrics fm ( filterMenubar->font() ); 191 QFontMetrics fm ( filterMenubar->font() );
192 192
193 filterPopupMenu = new QPopupMenu( this ); 193 filterPopupMenu = new QPopupMenu( this );
194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
195 QString addTest = "A"; 195 QString addTest = "A";
196 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 196 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
197#ifdef DESKTOP_VERSION 197#ifdef DESKTOP_VERSION
198 addTest = "AAABBBCCCx"; 198 addTest = "AAABBBCCCx";
199#else 199#else
200 addTest = "AAx"; 200 addTest = "AAx";
201#endif 201#endif
202 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 202 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
203 addToolBar (filterToolBar , tbd ); 203 addToolBar (filterToolBar , tbd );
204 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 204 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
205 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 205 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
206 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 206 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
207 filterToolBar->hide(); 207 filterToolBar->hide();
208 } else { 208 } else {
209 filterToolBar = 0; 209 filterToolBar = 0;
210 filterMenubar = 0; 210 filterMenubar = 0;
211 filterPopupMenu = 0; 211 filterPopupMenu = 0;
212 } 212 }
213 if ( p->mShowIconOnetoolbar ) { 213 if ( p->mShowIconOnetoolbar ) {
214 viewToolBar = iconToolBar ; 214 viewToolBar = iconToolBar ;
215 navigatorToolBar = iconToolBar ; 215 navigatorToolBar = iconToolBar ;
216 } else { 216 } else {
217#ifndef DESKTOP_VERSION 217#ifndef DESKTOP_VERSION
218 setToolBarsMovable( false ); 218 setToolBarsMovable( false );
219#endif 219#endif
220 if ( p->mToolBarHorV ) { 220 if ( p->mToolBarHorV ) {
221 if ( p->mToolBarUpV ) 221 if ( p->mToolBarUpV )
222 tbd = Bottom; 222 tbd = Bottom;
223 else 223 else
224 tbd = Top; 224 tbd = Top;
225 } 225 }
226 else { 226 else {
227 if ( p->mToolBarUpV ) 227 if ( p->mToolBarUpV )
228 tbd = Right; 228 tbd = Right;
229 else 229 else
230 tbd = Left; 230 tbd = Left;
231 } 231 }
232 viewToolBar = new QPEToolBar( this ); 232 viewToolBar = new QPEToolBar( this );
233 addToolBar (viewToolBar , tbd ); 233 addToolBar (viewToolBar , tbd );
234 if ( p->mToolBarHorN ) { 234 if ( p->mToolBarHorN ) {
235 if ( p->mToolBarUpN ) 235 if ( p->mToolBarUpN )
236 tbd = Bottom; 236 tbd = Bottom;
237 else 237 else
238 tbd = Top; 238 tbd = Top;
239 } 239 }
240 else { 240 else {
241 if ( p->mToolBarUpN ) 241 if ( p->mToolBarUpN )
242 tbd = Right; 242 tbd = Right;
243 else 243 else
244 tbd = Left; 244 tbd = Left;
245 } 245 }
246 navigatorToolBar = new QPEToolBar( this ); 246 navigatorToolBar = new QPEToolBar( this );
247 addToolBar (navigatorToolBar , tbd ); 247 addToolBar (navigatorToolBar , tbd );
248 } 248 }
249 249
250 250
251 251
252 mCalendarModifiedFlag = false; 252 mCalendarModifiedFlag = false;
253 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 253 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
254 splash->setAlignment ( AlignCenter ); 254 splash->setAlignment ( AlignCenter );
255 setCentralWidget( splash ); 255 setCentralWidget( splash );
256#ifndef DESKTOP_VERSION 256#ifndef DESKTOP_VERSION
257 showMaximized(); 257 showMaximized();
258#endif 258#endif
259 259
260 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 260 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
261 setDefaultPreferences(); 261 setDefaultPreferences();
262 mCalendar = new CalendarLocal(); 262 mCalendar = new CalendarLocal();
263 mView = new CalendarView( mCalendar, this,"mCalendar " ); 263 mView = new CalendarView( mCalendar, this,"mCalendar " );
264 mView->hide(); 264 mView->hide();
265 //mView->resize(splash->size() ); 265 //mView->resize(splash->size() );
266 initActions(); 266 initActions();
267 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 267 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
268 mSyncManager->setBlockSave(false); 268 mSyncManager->setBlockSave(false);
269 mView->setSyncManager(mSyncManager); 269 mView->setSyncManager(mSyncManager);
270#ifndef DESKTOP_VERSION 270#ifndef DESKTOP_VERSION
271 iconToolBar->show(); 271 iconToolBar->show();
272 qApp->processEvents(); 272 qApp->processEvents();
273#endif 273#endif
274 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 274 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
275 int vh = height() ; 275 int vh = height() ;
276 int vw = width(); 276 int vw = width();
277 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 277 //qDebug("Toolbar hei %d ",iconToolBar->height() );
278 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 278 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
279 vh -= iconToolBar->height(); 279 vh -= iconToolBar->height();
280 } else { 280 } else {
281 vw -= iconToolBar->height(); 281 vw -= iconToolBar->height();
282 } 282 }
283 //mView->setMaximumSize( splash->size() ); 283 //mView->setMaximumSize( splash->size() );
284 //mView->resize( splash->size() ); 284 //mView->resize( splash->size() );
285 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 285 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
286 mView->readSettings(); 286 mView->readSettings();
287 bool newFile = false; 287 bool newFile = false;
288 if( !QFile::exists( defaultFileName() ) ) { 288 if( !QFile::exists( defaultFileName() ) ) {
289 QFileInfo finfo ( defaultFileName() ); 289 QFileInfo finfo ( defaultFileName() );
290 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 290 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
291 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 291 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
292 finfo.setFile( oldFile ); 292 finfo.setFile( oldFile );
293 if (finfo.exists() ) { 293 if (finfo.exists() ) {
294 KMessageBox::information( this, message); 294 KMessageBox::information( this, message);
295 mView->openCalendar( oldFile ); 295 mView->openCalendar( oldFile );
296 qApp->processEvents(); 296 qApp->processEvents();
297 } else { 297 } else {
298 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 298 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
299 finfo.setFile( oldFile ); 299 finfo.setFile( oldFile );
300 if (finfo.exists() ) { 300 if (finfo.exists() ) {
301 KMessageBox::information( this, message); 301 KMessageBox::information( this, message);
302 mView->openCalendar( oldFile ); 302 mView->openCalendar( oldFile );
303 qApp->processEvents(); 303 qApp->processEvents();
304 } 304 }
305 } 305 }
306 mView->saveCalendar( defaultFileName() ); 306 mView->saveCalendar( defaultFileName() );
307 newFile = true; 307 newFile = true;
308 } 308 }
309 309
310 QTime neededSaveTime = QDateTime::currentDateTime().time(); 310 QTime neededSaveTime = QDateTime::currentDateTime().time();
311 mView->openCalendar( defaultFileName() ); 311 mView->loadCalendars();
312 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 312 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
313 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 313 qDebug("KO: Calendar loading time: %d ms",msNeeded );
314 314
315 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 315 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
316 KOPrefs::instance()->setAllDefaults(); 316 KOPrefs::instance()->setAllDefaults();
317 int count = mView->addCategories(); 317 int count = mView->addCategories();
318 } 318 }
319 processIncidenceSelection( 0 ); 319 processIncidenceSelection( 0 );
320 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 320 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
321 SLOT( processIncidenceSelection( Incidence * ) ) ); 321 SLOT( processIncidenceSelection( Incidence * ) ) );
322 connect( mView, SIGNAL( modifiedChanged( bool ) ), 322 connect( mView, SIGNAL( modifiedChanged( bool ) ),
323 SLOT( slotModifiedChanged( bool ) ) ); 323 SLOT( slotModifiedChanged( bool ) ) );
324 324
325 325
326 connect( mView, SIGNAL( tempDisableBR(bool) ), 326 connect( mView, SIGNAL( tempDisableBR(bool) ),
327 SLOT( disableBR(bool) ) ); 327 SLOT( disableBR(bool) ) );
328 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 328 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
329 mView->setModified( false ); 329 mView->setModified( false );
330 mBlockAtStartup = false; 330 mBlockAtStartup = false;
331 mView->setModified( false ); 331 mView->setModified( false );
332 setCentralWidget( mView ); 332 setCentralWidget( mView );
333 globalFlagBlockStartup = 0; 333 globalFlagBlockStartup = 0;
334 mView->show(); 334 mView->show();
335 delete splash; 335 delete splash;
336 if ( newFile ) 336 if ( newFile )
337 mView->updateConfig(); 337 mView->updateConfig();
338 // qApp->processEvents(); 338 // qApp->processEvents();
339 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 339 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
340 //fillSyncMenu(); 340 //fillSyncMenu();
341 341
342 342
343 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 343 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
344 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 344 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
345 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 345 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
346 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 346 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
347 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 347 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
348 mSyncManager->setDefaultFileName( sentSyncFile()); 348 mSyncManager->setDefaultFileName( sentSyncFile());
349 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 349 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
350 mSyncManager->fillSyncMenu(); 350 mSyncManager->fillSyncMenu();
351 351
352 352
353 353
354 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 354 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
355 if ( showWarning ) { 355 if ( showWarning ) {
356 KMessageBox::information( this, 356 KMessageBox::information( this,
357 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 357 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
358 qApp->processEvents(); 358 qApp->processEvents();
359 mView->dialogManager()->showSyncOptions(); 359 mView->dialogManager()->showSyncOptions();
360 } 360 }
361 361
362 //US listen for result adressed from Ka/Pi 362 //US listen for result adressed from Ka/Pi
363#ifndef DESKTOP_VERSION 363#ifndef DESKTOP_VERSION
364 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 364 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
365#endif 365#endif
366#ifndef DESKTOP_VERSION 366#ifndef DESKTOP_VERSION
367 infrared = 0; 367 infrared = 0;
368#endif 368#endif
369 updateFilterToolbar(); 369 updateFilterToolbar();
370 updateWeek( mView->startDate() ); 370 updateWeek( mView->startDate() );
371 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 371 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
372 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 372 SLOT( updateWeekNum( const KCal::DateList & ) ) );
373 mBRdisabled = false; 373 mBRdisabled = false;
374 //toggleBeamReceive(); 374 //toggleBeamReceive();
375 int tiint= 3000; 375 int tiint= 3000;
376#ifndef DESKTOP_VERSION 376#ifndef DESKTOP_VERSION
377 tiint = 5000; 377 tiint = 5000;
378#endif 378#endif
379 QTimer::singleShot( tiint, mView, SLOT ( checkAlarms() )); 379 QTimer::singleShot( tiint, mView, SLOT ( checkAlarms() ));
380} 380}
381MainWindow::~MainWindow() 381MainWindow::~MainWindow()
382{ 382{
383 //qDebug("MainWindow::~MainWindow() "); 383 //qDebug("MainWindow::~MainWindow() ");
384 //save toolbar location 384 //save toolbar location
385 delete mCalendar; 385 delete mCalendar;
386 delete mSyncManager; 386 delete mSyncManager;
387#ifndef DESKTOP_VERSION 387#ifndef DESKTOP_VERSION
388 if ( infrared ) 388 if ( infrared )
389 delete infrared; 389 delete infrared;
390#endif 390#endif
391 391
392 392
393} 393}
394 394
395void MainWindow::disableBR(bool b) 395void MainWindow::disableBR(bool b)
396{ 396{
397#ifndef DESKTOP_VERSION 397#ifndef DESKTOP_VERSION
398 if ( b ) { 398 if ( b ) {
399 if ( infrared ) { 399 if ( infrared ) {
400 toggleBeamReceive(); 400 toggleBeamReceive();
401 mBRdisabled = true; 401 mBRdisabled = true;
402 } 402 }
403 mBRdisabled = true; 403 mBRdisabled = true;
404 } else { 404 } else {
405 if ( mBRdisabled ) { 405 if ( mBRdisabled ) {
406 mBRdisabled = false; 406 mBRdisabled = false;
407 //makes no sense,because other cal ap is probably running 407 //makes no sense,because other cal ap is probably running
408 // toggleBeamReceive(); 408 // toggleBeamReceive();
409 } 409 }
410 } 410 }
411#endif 411#endif
412 412
413} 413}
414bool MainWindow::beamReceiveEnabled() 414bool MainWindow::beamReceiveEnabled()
415{ 415{
416#ifndef DESKTOP_VERSION 416#ifndef DESKTOP_VERSION
417 return ( infrared != 0 ); 417 return ( infrared != 0 );
418#endif 418#endif
419 return false; 419 return false;
420} 420}
421 421
422void MainWindow::toggleBeamReceive() 422void MainWindow::toggleBeamReceive()
423{ 423{
424 if ( mBRdisabled ) 424 if ( mBRdisabled )
425 return; 425 return;
426#ifndef DESKTOP_VERSION 426#ifndef DESKTOP_VERSION
427 if ( infrared ) { 427 if ( infrared ) {
428 qDebug("KO: Disable BeamReceive "); 428 qDebug("KO: Disable BeamReceive ");
429 delete infrared; 429 delete infrared;
430 infrared = 0; 430 infrared = 0;
431 brAction->setOn(false); 431 brAction->setOn(false);
432 return; 432 return;
433 } 433 }
434 qDebug("KO: Enable BeamReceive "); 434 qDebug("KO: Enable BeamReceive ");
435 brAction->setOn(true); 435 brAction->setOn(true);
436 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 436 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
437 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 437 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
438#endif 438#endif
439} 439}
440void MainWindow::showMaximized () 440void MainWindow::showMaximized ()
441{ 441{
442#ifndef DESKTOP_VERSION 442#ifndef DESKTOP_VERSION
443 if ( ! globalFlagBlockStartup ) 443 if ( ! globalFlagBlockStartup )
444 if ( mClosed ) 444 if ( mClosed )
445 mView->goToday(); 445 mView->goToday();
446#endif 446#endif
447 QWidget::showMaximized () ; 447 QWidget::showMaximized () ;
448 mClosed = false; 448 mClosed = false;
449} 449}
450void MainWindow::closeEvent( QCloseEvent* ce ) 450void MainWindow::closeEvent( QCloseEvent* ce )
451{ 451{
452 452
453 453
454 454
455 if ( ! KOPrefs::instance()->mAskForQuit ) { 455 if ( ! KOPrefs::instance()->mAskForQuit ) {
456 saveOnClose(); 456 saveOnClose();
457 mClosed = true; 457 mClosed = true;
458 ce->accept(); 458 ce->accept();
459 return; 459 return;
460 460
461 } 461 }
462 462
463 switch( QMessageBox::information( this, "KO/Pi", 463 switch( QMessageBox::information( this, "KO/Pi",
464 i18n("Do you really want\nto close KO/Pi?"), 464 i18n("Do you really want\nto close KO/Pi?"),
465 i18n("Close"), i18n("No"), 465 i18n("Close"), i18n("No"),
466 0, 0 ) ) { 466 0, 0 ) ) {
467 case 0: 467 case 0:
468 saveOnClose(); 468 saveOnClose();
469 mClosed = true; 469 mClosed = true;
470 ce->accept(); 470 ce->accept();
471 break; 471 break;
472 case 1: 472 case 1:
473 ce->ignore(); 473 ce->ignore();
474 break; 474 break;
475 case 2: 475 case 2:
476 476
477 default: 477 default:
478 break; 478 break;
479 } 479 }
480 480
481 481
482} 482}
483 483
484void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 484void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
485{ 485{
486 QDataStream stream( data, IO_ReadOnly ); 486 QDataStream stream( data, IO_ReadOnly );
487 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 487 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
488 //QString datamess; 488 //QString datamess;
489 //qDebug("message "); 489 //qDebug("message ");
490 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 490 qDebug("KO: QCOP message received: %s ", cmsg.data() );
491 491
492 if ( cmsg == "setDocument(QString)" ) { 492 if ( cmsg == "setDocument(QString)" ) {
493 QDataStream stream( data, IO_ReadOnly ); 493 QDataStream stream( data, IO_ReadOnly );
494 QString fileName; 494 QString fileName;
495 stream >> fileName; 495 stream >> fileName;
496 //qDebug("filename %s ", fileName.latin1()); 496 //qDebug("filename %s ", fileName.latin1());
497 showMaximized(); 497 showMaximized();
498 raise(); 498 raise();
499 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 499 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
500 mSyncManager->slotSyncMenu( 1002 ); 500 mSyncManager->slotSyncMenu( 1002 );
501 return; 501 return;
502 } 502 }
503 503
504 if ( cmsg == "-writeFile" ) { 504 if ( cmsg == "-writeFile" ) {
505 // I made from the "-writeFile" an "-writeAlarm" 505 // I made from the "-writeFile" an "-writeAlarm"
506 mView->viewManager()->showWhatsNextView(); 506 mView->viewManager()->showWhatsNextView();
507 mCalendar->checkAlarmForIncidence( 0, true); 507 mCalendar->checkAlarmForIncidence( 0, true);
508 showMaximized(); 508 showMaximized();
509 raise(); 509 raise();
510 return; 510 return;
511 511
512 } 512 }
513 if ( cmsg == "-writeFileSilent" ) { 513 if ( cmsg == "-writeFileSilent" ) {
514 // I made from the "-writeFile" an "-writeAlarm" 514 // I made from the "-writeFile" an "-writeAlarm"
515 // mView->viewManager()->showWhatsNextView(); 515 // mView->viewManager()->showWhatsNextView();
516 mCalendar->checkAlarmForIncidence( 0, true); 516 mCalendar->checkAlarmForIncidence( 0, true);
517 //showMaximized(); 517 //showMaximized();
518 //raise(); 518 //raise();
519 hide(); 519 hide();
520 return; 520 return;
521 } 521 }
522 if ( cmsg == "-newCountdown" ) { 522 if ( cmsg == "-newCountdown" ) {
523 qDebug("newCountdown "); 523 qDebug("newCountdown ");
524 524
525 } 525 }
526 QString msg ; 526 QString msg ;
527 QString allmsg = cmsg; 527 QString allmsg = cmsg;
528 while ( allmsg.length() > 0 ) { 528 while ( allmsg.length() > 0 ) {
529 int nextC = allmsg.find( "-", 1 ); 529 int nextC = allmsg.find( "-", 1 );
530 if ( nextC == -1 ) { 530 if ( nextC == -1 ) {
531 msg = allmsg; 531 msg = allmsg;
532 allmsg = ""; 532 allmsg = "";
533 } else{ 533 } else{
534 msg = allmsg.left( nextC ); 534 msg = allmsg.left( nextC );
535 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 535 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
536 } 536 }
537 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 537 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
538 if ( msg == "-newEvent" ) { 538 if ( msg == "-newEvent" ) {
539 mView->newEvent(); 539 mView->newEvent();
540 } 540 }
541 if ( msg == "-newTodo" ) { 541 if ( msg == "-newTodo" ) {
542 mView->newTodo(); 542 mView->newTodo();
543 543
544 } 544 }
545 if ( msg == "-showWN" ) { 545 if ( msg == "-showWN" ) {
546 mView->viewManager()->showWhatsNextView(); 546 mView->viewManager()->showWhatsNextView();
547 } 547 }
548 if ( msg == "-showTodo" ) { 548 if ( msg == "-showTodo" ) {
549 mView->viewManager()->showTodoView(); 549 mView->viewManager()->showTodoView();
550 } 550 }
551 if ( msg == "-showList" ) { 551 if ( msg == "-showList" ) {
552 mView->viewManager()->showListView(); 552 mView->viewManager()->showListView();
553 } 553 }
554 else if ( msg == "-showDay" ) { 554 else if ( msg == "-showDay" ) {
555 mView->viewManager()->showDayView(); 555 mView->viewManager()->showDayView();
556 } 556 }
557 else if ( msg == "-showWWeek" ) { 557 else if ( msg == "-showWWeek" ) {
558 mView->viewManager()->showWorkWeekView(); 558 mView->viewManager()->showWorkWeekView();
559 } 559 }
560 else if ( msg == "-ringSync" ) { 560 else if ( msg == "-ringSync" ) {
561 mSyncManager->multiSync( false ); 561 mSyncManager->multiSync( false );
562 } 562 }
563 else if ( msg == "-showWeek" ) { 563 else if ( msg == "-showWeek" ) {
564 mView->viewManager()->showWeekView(); 564 mView->viewManager()->showWeekView();
565 } 565 }
566 else if ( msg == "-showTodo" ) { 566 else if ( msg == "-showTodo" ) {
567 mView->viewManager()->showTodoView(); 567 mView->viewManager()->showTodoView();
568 } 568 }
569 else if ( msg == "-showJournal" ) { 569 else if ( msg == "-showJournal" ) {
570 mView->dateNavigator()->selectDates( 1 ); 570 mView->dateNavigator()->selectDates( 1 );
571 mView->dateNavigator()->selectToday(); 571 mView->dateNavigator()->selectToday();
572 mView->viewManager()->showJournalView(); 572 mView->viewManager()->showJournalView();
573 } 573 }
574 else if ( msg == "-showKO" ) { 574 else if ( msg == "-showKO" ) {
575 mView->viewManager()->showNextXView(); 575 mView->viewManager()->showNextXView();
576 } 576 }
577 else if ( msg == "-showWNext" ) { 577 else if ( msg == "-showWNext" ) {
578 mView->viewManager()->showWhatsNextView(); 578 mView->viewManager()->showWhatsNextView();
579 } 579 }
580 else if ( msg == "nextView()" ) { 580 else if ( msg == "nextView()" ) {
581 mView->viewManager()->showNextView(); 581 mView->viewManager()->showNextView();
582 } 582 }
583 else if ( msg == "-showNextXView" ) { 583 else if ( msg == "-showNextXView" ) {
584 mView->viewManager()->showNextXView(); 584 mView->viewManager()->showNextXView();
585 } 585 }
586 586
587 587
588 } 588 }
589 589
590 showMaximized(); 590 showMaximized();
591 raise(); 591 raise();
592} 592}
593 593
594QPixmap MainWindow::loadPixmap( QString name ) 594QPixmap MainWindow::loadPixmap( QString name )
595{ 595{
596 return SmallIcon( name ); 596 return SmallIcon( name );
597 597
598} 598}
599void MainWindow::setUsesBigPixmaps ( bool b ) 599void MainWindow::setUsesBigPixmaps ( bool b )
600{ 600{
601 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 601 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
602 if ( b ) 602 if ( b )
603 qDebug("KO: BigPixmaps are not supported "); 603 qDebug("KO: BigPixmaps are not supported ");
604} 604}
605void MainWindow::initActions() 605void MainWindow::initActions()
606{ 606{
607 //KOPrefs::instance()->mShowFullMenu 607 //KOPrefs::instance()->mShowFullMenu
608 iconToolBar->clear(); 608 iconToolBar->clear();
609 KOPrefs *p = KOPrefs::instance(); 609 KOPrefs *p = KOPrefs::instance();
610 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 610 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
611 611
612 QPopupMenu *viewMenu = new QPopupMenu( this ); 612 QPopupMenu *viewMenu = new QPopupMenu( this );
613 QPopupMenu *actionMenu = new QPopupMenu( this ); 613 QPopupMenu *actionMenu = new QPopupMenu( this );
614 QPopupMenu *importMenu = new QPopupMenu( this ); 614 QPopupMenu *importMenu = new QPopupMenu( this );
615 QPopupMenu *importMenu_X = new QPopupMenu( this ); 615 QPopupMenu *importMenu_X = new QPopupMenu( this );
616 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 616 QPopupMenu *exportMenu_X = new QPopupMenu( this );
617 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 617 QPopupMenu *beamMenu_X = new QPopupMenu( this );
618 selectFilterMenu = new QPopupMenu( this ); 618 selectFilterMenu = new QPopupMenu( this );
619 selectFilterMenu->setCheckable( true ); 619 selectFilterMenu->setCheckable( true );
620 syncMenu = new QPopupMenu( this ); 620 syncMenu = new QPopupMenu( this );
621 configureAgendaMenu = new QPopupMenu( this ); 621 configureAgendaMenu = new QPopupMenu( this );
622 configureToolBarMenu = new QPopupMenu( this ); 622 configureToolBarMenu = new QPopupMenu( this );
623 QPopupMenu *helpMenu = new QPopupMenu( this ); 623 QPopupMenu *helpMenu = new QPopupMenu( this );
624 QIconSet icon; 624 QIconSet icon;
625 int pixWid = 22, pixHei = 22; 625 int pixWid = 22, pixHei = 22;
626 QString pathString = ""; 626 QString pathString = "";
627 if ( !p->mToolBarMiniIcons ) { 627 if ( !p->mToolBarMiniIcons ) {
628 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) { 628 if ( QApplication::desktop()->width() < 480 /*|| QApplication::desktop()->height() < 320*/) {
629 pathString += "icons16/"; 629 pathString += "icons16/";
630 pixWid = 18; pixHei = 16; 630 pixWid = 18; pixHei = 16;
631 } 631 }
632 } else { 632 } else {
633 pathString += "iconsmini/"; 633 pathString += "iconsmini/";
634 pixWid = 18; pixHei = 16; 634 pixWid = 18; pixHei = 16;
635 } 635 }
636 if ( KOPrefs::instance()->mShowFullMenu ) { 636 if ( KOPrefs::instance()->mShowFullMenu ) {
637 QMenuBar *menuBar1; 637 QMenuBar *menuBar1;
638 menuBar1 = menuBar(); 638 menuBar1 = menuBar();
639 menuBar1->insertItem( i18n("File"), importMenu ); 639 menuBar1->insertItem( i18n("File"), importMenu );
640 menuBar1->insertItem( i18n("View"), viewMenu ); 640 menuBar1->insertItem( i18n("View"), viewMenu );
641 menuBar1->insertItem( i18n("Actions"), actionMenu ); 641 menuBar1->insertItem( i18n("Actions"), actionMenu );
642#ifdef DESKTOP_VERSION 642#ifdef DESKTOP_VERSION
643 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 643 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
644 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 644 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
645#else 645#else
646 menuBar1->insertItem( i18n("Sync"), syncMenu ); 646 menuBar1->insertItem( i18n("Sync"), syncMenu );
647 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 647 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
648#endif 648#endif
649 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 649 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
650 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 650 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
651 menuBar1->insertItem( i18n("Help"), helpMenu ); 651 menuBar1->insertItem( i18n("Help"), helpMenu );
652 } else { 652 } else {
653 QPEMenuBar *menuBar1; 653 QPEMenuBar *menuBar1;
654 menuBar1 = new QPEMenuBar( iconToolBar ); 654 menuBar1 = new QPEMenuBar( iconToolBar );
655 QPopupMenu *menuBar = new QPopupMenu( this ); 655 QPopupMenu *menuBar = new QPopupMenu( this );
656 icon = loadPixmap( pathString + "z_menu" ); 656 icon = loadPixmap( pathString + "z_menu" );
657 menuBar1->insertItem( icon.pixmap(), menuBar); 657 menuBar1->insertItem( icon.pixmap(), menuBar);
658 //menuBar1->insertItem( i18n("ME"), menuBar); 658 //menuBar1->insertItem( i18n("ME"), menuBar);
659 menuBar->insertItem( i18n("File"), importMenu ); 659 menuBar->insertItem( i18n("File"), importMenu );
660 menuBar->insertItem( i18n("View"), viewMenu ); 660 menuBar->insertItem( i18n("View"), viewMenu );
661 menuBar->insertItem( i18n("Actions"), actionMenu ); 661 menuBar->insertItem( i18n("Actions"), actionMenu );
662 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 662 menuBar->insertItem( i18n("Synchronize"), syncMenu );
663 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 663 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
664 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 664 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
665 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 665 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
666 menuBar->insertItem( i18n("Help"), helpMenu ); 666 menuBar->insertItem( i18n("Help"), helpMenu );
667 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 667 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
668 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 668 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
669 } 669 }
670 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 670 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
671 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 671 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
672 672
673 673
674 mWeekBgColor = iconToolBar->backgroundColor(); 674 mWeekBgColor = iconToolBar->backgroundColor();
675 mWeekPixmap.resize( pixWid , pixHei ); 675 mWeekPixmap.resize( pixWid , pixHei );
676 mWeekPixmap.fill( mWeekBgColor ); 676 mWeekPixmap.fill( mWeekBgColor );
677 icon = mWeekPixmap; 677 icon = mWeekPixmap;
678 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 678 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
679 if ( p-> mShowIconWeekNum ) 679 if ( p-> mShowIconWeekNum )
680 mWeekAction->addTo( iconToolBar ); 680 mWeekAction->addTo( iconToolBar );
681 mWeekFont = font(); 681 mWeekFont = font();
682 682
683 int fontPoint = mWeekFont.pointSize(); 683 int fontPoint = mWeekFont.pointSize();
684 QFontMetrics f( mWeekFont ); 684 QFontMetrics f( mWeekFont );
685 int fontWid = f.width( "30" ); 685 int fontWid = f.width( "30" );
686 while ( fontWid > pixWid ) { 686 while ( fontWid > pixWid ) {
687 --fontPoint; 687 --fontPoint;
688 mWeekFont.setPointSize( fontPoint ); 688 mWeekFont.setPointSize( fontPoint );
689 QFontMetrics f( mWeekFont ); 689 QFontMetrics f( mWeekFont );
690 fontWid = f.width( "30" ); 690 fontWid = f.width( "30" );
691 //qDebug("dec-- "); 691 //qDebug("dec-- ");
692 } 692 }
693 693
694 connect( mWeekAction, SIGNAL( activated() ), 694 connect( mWeekAction, SIGNAL( activated() ),
695 this, SLOT( weekAction() ) ); 695 this, SLOT( weekAction() ) );
696 696
697 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 697 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
698 if ( p->mShowIconFilterview ) { 698 if ( p->mShowIconFilterview ) {
699 icon = loadPixmap( pathString + "filter" ); 699 icon = loadPixmap( pathString + "filter" );
700 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 700 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
701 connect( actionFilterMenuTB, SIGNAL( activated() ), 701 connect( actionFilterMenuTB, SIGNAL( activated() ),
702 this, SLOT( fillFilterMenuTB() ) ); 702 this, SLOT( fillFilterMenuTB() ) );
703 actionFilterMenuTB->addTo( iconToolBar ); 703 actionFilterMenuTB->addTo( iconToolBar );
704 selectFilterMenuTB = new QPopupMenu( this ); 704 selectFilterMenuTB = new QPopupMenu( this );
705 selectFilterMenuTB->setCheckable( true ); 705 selectFilterMenuTB->setCheckable( true );
706 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 706 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
707 } 707 }
708 708
709 //#endif 709 //#endif
710 // ****************** 710 // ******************
711 QAction *action; 711 QAction *action;
712 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 712 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
713 configureToolBarMenu->setCheckable( true ); 713 configureToolBarMenu->setCheckable( true );
714 714
715 715
716 configureAgendaMenu->setCheckable( true ); 716 configureAgendaMenu->setCheckable( true );
717 int iii ; 717 int iii ;
718 for ( iii = 1;iii<= 10 ;++iii ){ 718 for ( iii = 1;iii<= 10 ;++iii ){
719 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 719 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
720 } 720 }
721 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 721 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
722 722
723 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 723 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
724 this, SLOT( showConfigureAgenda( ) ) ); 724 this, SLOT( showConfigureAgenda( ) ) );
725 725
726 icon = loadPixmap( pathString + "configure" ); 726 icon = loadPixmap( pathString + "configure" );
727 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this ); 727 action = new QAction( i18n("Configure"),icon, i18n("Configure KO/Pi..."), 0, this );
728 action->addTo( actionMenu ); 728 action->addTo( actionMenu );
729 connect( action, SIGNAL( activated() ), 729 connect( action, SIGNAL( activated() ),
730 mView, SLOT( edit_options() ) ); 730 mView, SLOT( edit_options() ) );
731 icon = loadPixmap( pathString + "configure" ); 731 icon = loadPixmap( pathString + "configure" );
732 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this ); 732 action = new QAction( i18n("Configure"),icon, i18n("Global Settings..."), 0, this );
733 action->addTo( actionMenu ); 733 action->addTo( actionMenu );
734 connect( action, SIGNAL( activated() ), 734 connect( action, SIGNAL( activated() ),
735 mView, SLOT( edit_global_options() ) ); 735 mView, SLOT( edit_global_options() ) );
736 actionMenu->insertSeparator(); 736 actionMenu->insertSeparator();
737 737
738 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 738 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
739 action->addTo( actionMenu ); 739 action->addTo( actionMenu );
740 connect( action, SIGNAL( activated() ), 740 connect( action, SIGNAL( activated() ),
741 mView, SLOT( undo_delete() ) ); 741 mView, SLOT( undo_delete() ) );
742 actionMenu->insertSeparator(); 742 actionMenu->insertSeparator();
743 743
744 icon = loadPixmap( pathString + "newevent" ); 744 icon = loadPixmap( pathString + "newevent" );
745 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 745 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
746 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 746 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
747 configureToolBarMenu->insertSeparator(); 747 configureToolBarMenu->insertSeparator();
748 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 748 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
749 configureToolBarMenu->insertSeparator(); 749 configureToolBarMenu->insertSeparator();
750 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 750 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
751 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 751 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
752 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 752 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
753 ne_action->addTo( actionMenu ); 753 ne_action->addTo( actionMenu );
754 connect( ne_action, SIGNAL( activated() ), 754 connect( ne_action, SIGNAL( activated() ),
755 mView, SLOT( newEvent() ) ); 755 mView, SLOT( newEvent() ) );
756 icon = loadPixmap( pathString + "newtodo" ); 756 icon = loadPixmap( pathString + "newtodo" );
757 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 757 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
758 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 758 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
759 nt_action->addTo( actionMenu ); 759 nt_action->addTo( actionMenu );
760 connect( nt_action, SIGNAL( activated() ), 760 connect( nt_action, SIGNAL( activated() ),
761 mView, SLOT( newTodo() ) ); 761 mView, SLOT( newTodo() ) );
762 762
763 icon = loadPixmap( pathString + "today" ); 763 icon = loadPixmap( pathString + "today" );
764 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 764 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
765 today_action->addTo( viewMenu ); 765 today_action->addTo( viewMenu );
766 connect( today_action, SIGNAL( activated() ), 766 connect( today_action, SIGNAL( activated() ),
767 mView, SLOT( goToday() ) ); 767 mView, SLOT( goToday() ) );
768 viewMenu->insertSeparator(); 768 viewMenu->insertSeparator();
769 769
770 // *********************** 770 // ***********************
771 if ( KOPrefs::instance()->mVerticalScreen ) { 771 if ( KOPrefs::instance()->mVerticalScreen ) {
772 icon = SmallIcon( "1updownarrow" ); 772 icon = SmallIcon( "1updownarrow" );
773 } else { 773 } else {
774 icon = SmallIcon("1leftrightarrow" ); 774 icon = SmallIcon("1leftrightarrow" );
775 } 775 }
776 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 776 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
777 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 777 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
778 FSaction->addTo( viewMenu ); 778 FSaction->addTo( viewMenu );
779 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 779 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
780 780
781 icon = loadPixmap( pathString + "navi" ); 781 icon = loadPixmap( pathString + "navi" );
782 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 782 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
783 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 783 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
784 action->addTo( viewMenu ); 784 action->addTo( viewMenu );
785 connect( action, SIGNAL( activated() ), 785 connect( action, SIGNAL( activated() ),
786 mView, SLOT( toggleDateNavigatorWidget() ) ); 786 mView, SLOT( toggleDateNavigatorWidget() ) );
787 mToggleNav = action ; 787 mToggleNav = action ;
788 icon = loadPixmap( pathString + "filter" ); 788 icon = loadPixmap( pathString + "filter" );
789 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 789 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
790 icon = loadPixmap( pathString + "configure" ); 790 icon = loadPixmap( pathString + "configure" );
791 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this ); 791 action = new QAction( i18n("Toggle Resource View"), icon, i18n("Toggle Resource View"), 0, this );
792 action->addTo( viewMenu ); 792 action->addTo( viewMenu );
793 connect( action, SIGNAL( activated() ), 793 connect( action, SIGNAL( activated() ),
794 mView, SLOT( toggleFilter() ) ); 794 mView, SLOT( toggleFilter() ) );
795 mToggleFilter = action; 795 mToggleFilter = action;
796 icon = loadPixmap( pathString + "allday" ); 796 icon = loadPixmap( pathString + "allday" );
797 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 797 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
798 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 798 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
799 action->addTo( viewMenu ); 799 action->addTo( viewMenu );
800 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
801 mView, SLOT( toggleAllDaySize() ) ); 801 mView, SLOT( toggleAllDaySize() ) );
802 mToggleAllday = action; 802 mToggleAllday = action;
803 803
804 804
805 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 805 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
806 mToggleNav, SLOT( setEnabled ( bool ) ) ); 806 mToggleNav, SLOT( setEnabled ( bool ) ) );
807 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 807 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
808 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 808 mToggleFilter, SLOT( setEnabled ( bool ) ) );
809 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 809 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
810 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 810 mToggleAllday, SLOT( setEnabled ( bool ) ) );
811 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 811 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
812 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); 812 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) );
813 813
814 viewMenu->insertSeparator(); 814 viewMenu->insertSeparator();
815 icon = loadPixmap( pathString + "picker" ); 815 icon = loadPixmap( pathString + "picker" );
816 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 816 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
817 action->addTo( viewMenu ); 817 action->addTo( viewMenu );
818 connect( action, SIGNAL( activated() ), 818 connect( action, SIGNAL( activated() ),
819 mView, SLOT( showDatePicker() ) ); 819 mView, SLOT( showDatePicker() ) );
820 action->addTo( iconToolBar ); 820 action->addTo( iconToolBar );
821 viewMenu->insertSeparator(); 821 viewMenu->insertSeparator();
822 822
823 if ( p-> mShowIconToggleFull ) 823 if ( p-> mShowIconToggleFull )
824 FSaction->addTo( iconToolBar ); 824 FSaction->addTo( iconToolBar );
825 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 825 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
826 826
827 //******************** 827 //********************
828 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 828 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
829 829
830 830
831 icon = loadPixmap( pathString + "whatsnext" ); 831 icon = loadPixmap( pathString + "whatsnext" );
832 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 832 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
833 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 833 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
834 whatsnext_action->addTo( viewMenu ); 834 whatsnext_action->addTo( viewMenu );
835 connect( whatsnext_action, SIGNAL( activated() ), 835 connect( whatsnext_action, SIGNAL( activated() ),
836 mView->viewManager(), SLOT( showWhatsNextView() ) ); 836 mView->viewManager(), SLOT( showWhatsNextView() ) );
837 837
838 icon = loadPixmap( pathString + "xdays" ); 838 icon = loadPixmap( pathString + "xdays" );
839 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 839 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
840 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 840 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
841 xdays_action->addTo( viewMenu ); 841 xdays_action->addTo( viewMenu );
842 connect( xdays_action, SIGNAL( activated() ), 842 connect( xdays_action, SIGNAL( activated() ),
843 mView->viewManager(), SLOT( showNextXView() ) ); 843 mView->viewManager(), SLOT( showNextXView() ) );
844 844
845 845
846 icon = loadPixmap( pathString + "journal" ); 846 icon = loadPixmap( pathString + "journal" );
847 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 847 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
848 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 848 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
849 viewjournal_action->addTo( viewMenu ); 849 viewjournal_action->addTo( viewMenu );
850 connect( viewjournal_action, SIGNAL( activated() ), 850 connect( viewjournal_action, SIGNAL( activated() ),
851 mView->viewManager(), SLOT( showJournalView() ) ); 851 mView->viewManager(), SLOT( showJournalView() ) );
852 852
853 853
854 icon = loadPixmap( pathString + "day" ); 854 icon = loadPixmap( pathString + "day" );
855 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 855 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
856 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 856 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
857 day1_action->addTo( viewMenu ); 857 day1_action->addTo( viewMenu );
858 // action->addTo( toolBar ); 858 // action->addTo( toolBar );
859 connect( day1_action, SIGNAL( activated() ), 859 connect( day1_action, SIGNAL( activated() ),
860 mView->viewManager(), SLOT( showDayView() ) ); 860 mView->viewManager(), SLOT( showDayView() ) );
861 861
862 icon = loadPixmap( pathString + "workweek" ); 862 icon = loadPixmap( pathString + "workweek" );
863 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 863 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
864 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 864 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
865 day5_action->addTo( viewMenu ); 865 day5_action->addTo( viewMenu );
866 connect( day5_action, SIGNAL( activated() ), 866 connect( day5_action, SIGNAL( activated() ),
867 mView->viewManager(), SLOT( showWorkWeekView() ) ); 867 mView->viewManager(), SLOT( showWorkWeekView() ) );
868 868
869 icon = loadPixmap( pathString + "week" ); 869 icon = loadPixmap( pathString + "week" );
870 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 870 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
871 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 871 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
872 day7_action->addTo( viewMenu ); 872 day7_action->addTo( viewMenu );
873 connect( day7_action, SIGNAL( activated() ), 873 connect( day7_action, SIGNAL( activated() ),
874 mView->viewManager(), SLOT( showWeekView() ) ); 874 mView->viewManager(), SLOT( showWeekView() ) );
875 875
876 icon = loadPixmap( pathString + "workweek2" ); 876 icon = loadPixmap( pathString + "workweek2" );
877 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 877 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
878 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 878 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
879 day6_action->addTo( viewMenu ); 879 day6_action->addTo( viewMenu );
880 connect( day6_action, SIGNAL( activated() ), 880 connect( day6_action, SIGNAL( activated() ),
881 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 881 mView->viewManager(), SLOT( showMonthViewWeek() ) );
882 882
883 icon = loadPixmap( pathString + "month" ); 883 icon = loadPixmap( pathString + "month" );
884 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 884 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
885 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 885 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
886 month_action->addTo( viewMenu ); 886 month_action->addTo( viewMenu );
887 connect( month_action, SIGNAL( activated() ), 887 connect( month_action, SIGNAL( activated() ),
888 mView->viewManager(), SLOT( showMonthView() ) ); 888 mView->viewManager(), SLOT( showMonthView() ) );
889 889
890 icon = loadPixmap( pathString + "list" ); 890 icon = loadPixmap( pathString + "list" );
891 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 891 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
892 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 892 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
893 showlist_action->addTo( viewMenu ); 893 showlist_action->addTo( viewMenu );
894 connect( showlist_action, SIGNAL( activated() ), 894 connect( showlist_action, SIGNAL( activated() ),
895 mView->viewManager(), SLOT( showListView() ) ); 895 mView->viewManager(), SLOT( showListView() ) );
896 896
897 icon = loadPixmap( pathString + "todo" ); 897 icon = loadPixmap( pathString + "todo" );
898 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 898 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
899 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 899 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
900 todoview_action->addTo( viewMenu ); 900 todoview_action->addTo( viewMenu );
901 connect( todoview_action, SIGNAL( activated() ), 901 connect( todoview_action, SIGNAL( activated() ),
902 mView->viewManager(), SLOT( showTodoView() ) ); 902 mView->viewManager(), SLOT( showTodoView() ) );
903 903
904 904
905 905
906#if 0 906#if 0
907 action = new QAction( "view_timespan", "Time Span", 0, this ); 907 action = new QAction( "view_timespan", "Time Span", 0, this );
908 action->addTo( viewMenu ); 908 action->addTo( viewMenu );
909 connect( action, SIGNAL( activated() ), 909 connect( action, SIGNAL( activated() ),
910 mView->viewManager(), SLOT( showTimeSpanView() ) ); 910 mView->viewManager(), SLOT( showTimeSpanView() ) );
911#endif 911#endif
912 912
913 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 913 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
914 this ); 914 this );
915 mNewSubTodoAction->addTo( actionMenu ); 915 mNewSubTodoAction->addTo( actionMenu );
916 connect( mNewSubTodoAction, SIGNAL( activated() ), 916 connect( mNewSubTodoAction, SIGNAL( activated() ),
917 mView, SLOT( newSubTodo() ) ); 917 mView, SLOT( newSubTodo() ) );
918 918
919 actionMenu->insertSeparator(); 919 actionMenu->insertSeparator();
920 920
921 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 921 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
922 mShowAction->addTo( actionMenu ); 922 mShowAction->addTo( actionMenu );
923 connect( mShowAction, SIGNAL( activated() ), 923 connect( mShowAction, SIGNAL( activated() ),
924 mView, SLOT( showIncidence() ) ); 924 mView, SLOT( showIncidence() ) );
925 925
926 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 926 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
927 mEditAction->addTo( actionMenu ); 927 mEditAction->addTo( actionMenu );
928 connect( mEditAction, SIGNAL( activated() ), 928 connect( mEditAction, SIGNAL( activated() ),
929 mView, SLOT( editIncidence() ) ); 929 mView, SLOT( editIncidence() ) );
930 930
931 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 931 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
932 mDeleteAction->addTo( actionMenu ); 932 mDeleteAction->addTo( actionMenu );
933 connect( mDeleteAction, SIGNAL( activated() ), 933 connect( mDeleteAction, SIGNAL( activated() ),
934 mView, SLOT( deleteIncidence() ) ); 934 mView, SLOT( deleteIncidence() ) );
935 935
936 936
937 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 937 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
938 mCloneAction->addTo( actionMenu ); 938 mCloneAction->addTo( actionMenu );
939 connect( mCloneAction, SIGNAL( activated() ), 939 connect( mCloneAction, SIGNAL( activated() ),
940 mView, SLOT( cloneIncidence() ) ); 940 mView, SLOT( cloneIncidence() ) );
941 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 941 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
942 mMoveAction->addTo( actionMenu ); 942 mMoveAction->addTo( actionMenu );
943 connect( mMoveAction, SIGNAL( activated() ), 943 connect( mMoveAction, SIGNAL( activated() ),
944 mView, SLOT( moveIncidence() ) ); 944 mView, SLOT( moveIncidence() ) );
945 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 945 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
946 mBeamAction->addTo( actionMenu ); 946 mBeamAction->addTo( actionMenu );
947 connect( mBeamAction, SIGNAL( activated() ), 947 connect( mBeamAction, SIGNAL( activated() ),
948 mView, SLOT( beamIncidence() ) ); 948 mView, SLOT( beamIncidence() ) );
949 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 949 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
950 mCancelAction->addTo( actionMenu ); 950 mCancelAction->addTo( actionMenu );
951 connect( mCancelAction, SIGNAL( activated() ), 951 connect( mCancelAction, SIGNAL( activated() ),
952 mView, SLOT( toggleCancelIncidence() ) ); 952 mView, SLOT( toggleCancelIncidence() ) );
953 953
954 actionMenu->insertSeparator(); 954 actionMenu->insertSeparator();
955 955
956 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 956 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
957 this ); 957 this );
958 action->addTo( actionMenu ); 958 action->addTo( actionMenu );
959 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 959 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
960 960
961 icon = loadPixmap( pathString + "search" ); 961 icon = loadPixmap( pathString + "search" );
962 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 962 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
963 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 963 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
964 search_action->addTo( actionMenu ); 964 search_action->addTo( actionMenu );
965 connect( search_action, SIGNAL( activated() ), 965 connect( search_action, SIGNAL( activated() ),
966 mView->dialogManager(), SLOT( showSearchDialog() ) ); 966 mView->dialogManager(), SLOT( showSearchDialog() ) );
967 967
968 968
969 969
970 if ( KOPrefs::instance()->mShowFullMenu ) { 970 if ( KOPrefs::instance()->mShowFullMenu ) {
971 actionMenu->insertSeparator(); 971 actionMenu->insertSeparator();
972 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 972 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
973 973
974 } 974 }
975 // actionMenu->insertSeparator(); 975 // actionMenu->insertSeparator();
976 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 976 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
977 this ); 977 this );
978 action->addTo( importMenu_X ); 978 action->addTo( importMenu_X );
979 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 979 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
980 action = new QAction( "import_quick", i18n("Import last file"), 0, 980 action = new QAction( "import_quick", i18n("Import last file"), 0,
981 this ); 981 this );
982 action->addTo( importMenu_X ); 982 action->addTo( importMenu_X );
983 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 983 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
984 importMenu_X->insertSeparator(); 984 importMenu_X->insertSeparator();
985 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 985 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
986 this ); 986 this );
987 action->addTo( importMenu_X ); 987 action->addTo( importMenu_X );
988 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 988 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
989 //#ifndef DESKTOP_VERSION 989 //#ifndef DESKTOP_VERSION
990 importMenu_X->insertSeparator(); 990 importMenu_X->insertSeparator();
991 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 991 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
992 this ); 992 this );
993 action->addTo( importMenu_X ); 993 action->addTo( importMenu_X );
994 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 994 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
995 //#else 995 //#else
996#ifdef _OL_IMPORT_ 996#ifdef _OL_IMPORT_
997 importMenu_X->insertSeparator(); 997 importMenu_X->insertSeparator();
998 action = new QAction( "import_ol", i18n("Import from OL"), 0, 998 action = new QAction( "import_ol", i18n("Import from OL"), 0,
999 this ); 999 this );
1000 action->addTo( importMenu_X ); 1000 action->addTo( importMenu_X );
1001 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 1001 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
1002#endif 1002#endif
1003 //#endif 1003 //#endif
1004 1004
1005 //importMenu->insertSeparator(); 1005 //importMenu->insertSeparator();
1006 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 1006 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
1007 this ); 1007 this );
1008 action->addTo( importMenu ); 1008 action->addTo( importMenu );
1009 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 1009 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
1010 1010
1011 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 1011 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
1012 this ); 1012 this );
1013 action->addTo( importMenu ); 1013 action->addTo( importMenu );
1014 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1014 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
1015 importMenu->insertSeparator(); 1015 importMenu->insertSeparator();
1016 importMenu->insertItem( i18n("Import"), importMenu_X ); 1016 importMenu->insertItem( i18n("Import"), importMenu_X );
1017 //importMenu->insertSeparator(); 1017 //importMenu->insertSeparator();
1018 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1018 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1019 this ); 1019 this );
1020 action->addTo( exportMenu_X ); 1020 action->addTo( exportMenu_X );
1021 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1021 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1022 1022
1023 1023
1024 //LR 1024 //LR
1025 QPopupMenu *ex2phone = new QPopupMenu( this ); 1025 QPopupMenu *ex2phone = new QPopupMenu( this );
1026 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1026 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1027 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1027 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1028 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1028 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1029 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1029 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1030 1030
1031 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1031 importMenu->insertItem( i18n("Export"), exportMenu_X );
1032#ifndef DESKTOP_VERSION 1032#ifndef DESKTOP_VERSION
1033 //importMenu->insertSeparator(); 1033 //importMenu->insertSeparator();
1034 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1034 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1035 this ); 1035 this );
1036 brAction->addTo( beamMenu_X ); 1036 brAction->addTo( beamMenu_X );
1037 brAction->setToggleAction (true ) ; 1037 brAction->setToggleAction (true ) ;
1038 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1038 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1039 1039
1040 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1040 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1041 this ); 1041 this );
1042 action->addTo( beamMenu_X ); 1042 action->addTo( beamMenu_X );
1043 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1043 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1044 1044
1045 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1045 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1046 this ); 1046 this );
1047 action->addTo( beamMenu_X ); 1047 action->addTo( beamMenu_X );
1048 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1048 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1049 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1049 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1050#else 1050#else
1051 //importMenu->insertSeparator(); 1051 //importMenu->insertSeparator();
1052 icon = loadPixmap( pathString + "print" ); 1052 icon = loadPixmap( pathString + "print" );
1053 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1053 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1054 action->addTo( beamMenu_X ); 1054 action->addTo( beamMenu_X );
1055 connect( action, SIGNAL( activated() ), 1055 connect( action, SIGNAL( activated() ),
1056 this, SLOT( printCal() ) ); 1056 this, SLOT( printCal() ) );
1057 1057
1058 icon = loadPixmap( pathString + "print" ); 1058 icon = loadPixmap( pathString + "print" );
1059 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1059 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1060 action->addTo( beamMenu_X ); 1060 action->addTo( beamMenu_X );
1061 connect( action, SIGNAL( activated() ), 1061 connect( action, SIGNAL( activated() ),
1062 this, SLOT( printSel() ) ); 1062 this, SLOT( printSel() ) );
1063 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1063 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1064 action->addTo( beamMenu_X ); 1064 action->addTo( beamMenu_X );
1065 connect( action, SIGNAL( activated() ), 1065 connect( action, SIGNAL( activated() ),
1066 mView->viewManager(), SLOT( slotprintWNV() ) ); 1066 mView->viewManager(), SLOT( slotprintWNV() ) );
1067 1067
1068 1068
1069 icon = loadPixmap( pathString + "print" ); 1069 icon = loadPixmap( pathString + "print" );
1070 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this ); 1070 action = new QAction( i18n("Print List View..."),icon,i18n("Print List View..."), 0, this );
1071 action->addTo( beamMenu_X ); 1071 action->addTo( beamMenu_X );
1072 connect( action, SIGNAL( activated() ), 1072 connect( action, SIGNAL( activated() ),
1073 this, SLOT( printListView() ) ); 1073 this, SLOT( printListView() ) );
1074 1074
1075 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1075 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1076 action->addTo( beamMenu_X ); 1076 action->addTo( beamMenu_X );
1077 connect( action, SIGNAL( activated() ), 1077 connect( action, SIGNAL( activated() ),
1078 mView, SLOT( slotprintSelInc() ) ); 1078 mView, SLOT( slotprintSelInc() ) );
1079 1079
1080 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1080 importMenu->insertItem( i18n("Print"), beamMenu_X );
1081#endif 1081#endif
1082 importMenu->insertSeparator(); 1082 importMenu->insertSeparator();
1083 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1083 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1084 this ); 1084 this );
1085 action->addTo( importMenu ); 1085 action->addTo( importMenu );
1086 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1086 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1087 importMenu->insertSeparator(); 1087 importMenu->insertSeparator();
1088 action = new QAction( "beam all", i18n("Save"), 0, 1088 action = new QAction( "beam all", i18n("Save"), 0,
1089 this ); 1089 this );
1090 action->addTo( importMenu ); 1090 action->addTo( importMenu );
1091 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1091 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1092 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1092 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1093 this ); 1093 this );
1094 action->addTo( importMenu ); 1094 action->addTo( importMenu );
1095 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1095 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1096 1096
1097 //menuBar->insertItem( "Configure",configureMenu ); 1097 //menuBar->insertItem( "Configure",configureMenu );
1098 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1098 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1099 icon = loadPixmap( "korganizer/korganizer" ); 1099 icon = loadPixmap( "korganizer/korganizer" );
1100 1100
1101 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1101 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1102 action->addTo( helpMenu ); 1102 action->addTo( helpMenu );
1103 connect( action, SIGNAL( activated() ), 1103 connect( action, SIGNAL( activated() ),
1104 SLOT( whatsNew() ) ); 1104 SLOT( whatsNew() ) );
1105 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1105 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1106 action->addTo( helpMenu ); 1106 action->addTo( helpMenu );
1107 connect( action, SIGNAL( activated() ), 1107 connect( action, SIGNAL( activated() ),
1108 SLOT( features() ) ); 1108 SLOT( features() ) );
1109 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1109 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1110 action->addTo( helpMenu ); 1110 action->addTo( helpMenu );
1111 connect( action, SIGNAL( activated() ), 1111 connect( action, SIGNAL( activated() ),
1112 SLOT( keyBindings() ) ); 1112 SLOT( keyBindings() ) );
1113 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1113 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1114 action->addTo( helpMenu ); 1114 action->addTo( helpMenu );
1115 connect( action, SIGNAL( activated() ), 1115 connect( action, SIGNAL( activated() ),
1116 SLOT( storagehowto() ) ); 1116 SLOT( storagehowto() ) );
1117 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1117 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1118 action->addTo( helpMenu ); 1118 action->addTo( helpMenu );
1119 connect( action, SIGNAL( activated() ), 1119 connect( action, SIGNAL( activated() ),
1120 SLOT( timetrackinghowto() ) ); 1120 SLOT( timetrackinghowto() ) );
1121 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1121 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1122 action->addTo( helpMenu ); 1122 action->addTo( helpMenu );
1123 connect( action, SIGNAL( activated() ), 1123 connect( action, SIGNAL( activated() ),
1124 SLOT( synchowto() ) ); 1124 SLOT( synchowto() ) );
1125 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1125 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1126 action->addTo( helpMenu ); 1126 action->addTo( helpMenu );
1127 connect( action, SIGNAL( activated() ), 1127 connect( action, SIGNAL( activated() ),
1128 SLOT( kdesynchowto() ) ); 1128 SLOT( kdesynchowto() ) );
1129 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1129 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1130 action->addTo( helpMenu ); 1130 action->addTo( helpMenu );
1131 connect( action, SIGNAL( activated() ), 1131 connect( action, SIGNAL( activated() ),
1132 SLOT( multisynchowto() ) ); 1132 SLOT( multisynchowto() ) );
1133 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1133 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1134 action->addTo( helpMenu ); 1134 action->addTo( helpMenu );
1135 connect( action, SIGNAL( activated() ), 1135 connect( action, SIGNAL( activated() ),
1136 SLOT( aboutAutoSaving() ) ); 1136 SLOT( aboutAutoSaving() ) );
1137 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1137 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1138 action->addTo( helpMenu ); 1138 action->addTo( helpMenu );
1139 connect( action, SIGNAL( activated() ), 1139 connect( action, SIGNAL( activated() ),
1140 SLOT( aboutKnownBugs() ) ); 1140 SLOT( aboutKnownBugs() ) );
1141 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1141 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1142 action->addTo( helpMenu ); 1142 action->addTo( helpMenu );
1143 connect( action, SIGNAL( activated() ), 1143 connect( action, SIGNAL( activated() ),
1144 SLOT( usertrans() ) ); 1144 SLOT( usertrans() ) );
1145 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1145 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1146 action->addTo( helpMenu ); 1146 action->addTo( helpMenu );
1147 connect( action, SIGNAL( activated() ), 1147 connect( action, SIGNAL( activated() ),
1148 SLOT( faq() ) ); 1148 SLOT( faq() ) );
1149 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1149 action = new QAction( "licence", i18n("Licence..."), 0, this );
1150 action->addTo( helpMenu ); 1150 action->addTo( helpMenu );
1151 connect( action, SIGNAL( activated() ), 1151 connect( action, SIGNAL( activated() ),
1152 SLOT( licence() ) ); 1152 SLOT( licence() ) );
1153 action = new QAction( "about", i18n("About..."), 0, this ); 1153 action = new QAction( "about", i18n("About..."), 0, this );
1154 action->addTo( helpMenu ); 1154 action->addTo( helpMenu );
1155 connect( action, SIGNAL( activated() ), 1155 connect( action, SIGNAL( activated() ),
1156 SLOT( about() ) ); 1156 SLOT( about() ) );
1157 //menuBar->insertSeparator(); 1157 //menuBar->insertSeparator();
1158 1158
1159 // ****************************************************** 1159 // ******************************************************
1160 // menubar icons 1160 // menubar icons
1161 1161
1162 1162
1163 1163
1164 //menuBar->insertItem( iconToolBar ); 1164 //menuBar->insertItem( iconToolBar );
1165 //xdays_action 1165 //xdays_action
1166 if (p-> mShowIconNewEvent) 1166 if (p-> mShowIconNewEvent)
1167 ne_action->addTo( iconToolBar ); 1167 ne_action->addTo( iconToolBar );
1168 if (p->mShowIconNewTodo ) 1168 if (p->mShowIconNewTodo )
1169 nt_action->addTo( iconToolBar ); 1169 nt_action->addTo( iconToolBar );
1170 if (p-> mShowIconSearch) 1170 if (p-> mShowIconSearch)
1171 search_action->addTo( iconToolBar ); 1171 search_action->addTo( iconToolBar );
1172 if (p-> mShowIconWhatsThis) 1172 if (p-> mShowIconWhatsThis)
1173 QWhatsThis::whatsThisButton ( iconToolBar ); 1173 QWhatsThis::whatsThisButton ( iconToolBar );
1174 if (p-> mShowIconNext) 1174 if (p-> mShowIconNext)
1175 whatsnext_action->addTo( viewToolBar ); 1175 whatsnext_action->addTo( viewToolBar );
1176 if (p-> mShowIconNextDays) 1176 if (p-> mShowIconNextDays)
1177 xdays_action->addTo( viewToolBar ); 1177 xdays_action->addTo( viewToolBar );
1178 if (p-> mShowIconJournal) 1178 if (p-> mShowIconJournal)
1179 viewjournal_action->addTo( viewToolBar ); 1179 viewjournal_action->addTo( viewToolBar );
1180 if (p-> mShowIconDay1) 1180 if (p-> mShowIconDay1)
1181 day1_action->addTo( viewToolBar ); 1181 day1_action->addTo( viewToolBar );
1182 if (p-> mShowIconDay5) 1182 if (p-> mShowIconDay5)
1183 day5_action->addTo( viewToolBar ); 1183 day5_action->addTo( viewToolBar );
1184 if (p-> mShowIconDay7) 1184 if (p-> mShowIconDay7)
1185 day7_action->addTo( viewToolBar ); 1185 day7_action->addTo( viewToolBar );
1186 if (p-> mShowIconDay6) 1186 if (p-> mShowIconDay6)
1187 day6_action->addTo( viewToolBar ); 1187 day6_action->addTo( viewToolBar );
1188 if (p-> mShowIconMonth) 1188 if (p-> mShowIconMonth)
1189 month_action->addTo( viewToolBar ); 1189 month_action->addTo( viewToolBar );
1190 if (p-> mShowIconList) 1190 if (p-> mShowIconList)
1191 showlist_action->addTo( viewToolBar ); 1191 showlist_action->addTo( viewToolBar );
1192 if (p-> mShowIconTodoview) 1192 if (p-> mShowIconTodoview)
1193 todoview_action->addTo( viewToolBar ); 1193 todoview_action->addTo( viewToolBar );
1194 1194
1195 icon = loadPixmap( pathString + "2leftarrowB" ); 1195 icon = loadPixmap( pathString + "2leftarrowB" );
1196 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1196 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1197 if (p-> mShowIconBackFast) { 1197 if (p-> mShowIconBackFast) {
1198 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1198 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1199 connect( action, SIGNAL( activated() ), 1199 connect( action, SIGNAL( activated() ),
1200 mView, SLOT( goPreviousMonth() ) ); 1200 mView, SLOT( goPreviousMonth() ) );
1201 action->addTo( navigatorToolBar ); 1201 action->addTo( navigatorToolBar );
1202 } 1202 }
1203 icon = loadPixmap( pathString + "1leftarrowB" ); 1203 icon = loadPixmap( pathString + "1leftarrowB" );
1204 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1204 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1205 if (p-> mShowIconBack) { 1205 if (p-> mShowIconBack) {
1206 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1206 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1207 connect( action, SIGNAL( activated() ), 1207 connect( action, SIGNAL( activated() ),
1208 mView, SLOT( goPrevious() ) ); 1208 mView, SLOT( goPrevious() ) );
1209 action->addTo( navigatorToolBar ); 1209 action->addTo( navigatorToolBar );
1210 } 1210 }
1211 icon = loadPixmap( pathString + "today" ); 1211 icon = loadPixmap( pathString + "today" );
1212 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1212 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1213 if (p-> mShowIconToday) 1213 if (p-> mShowIconToday)
1214 today_action->addTo( navigatorToolBar ); 1214 today_action->addTo( navigatorToolBar );
1215 icon = loadPixmap( pathString + "1rightarrowB" ); 1215 icon = loadPixmap( pathString + "1rightarrowB" );
1216 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1216 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1217 if (p-> mShowIconForward) { 1217 if (p-> mShowIconForward) {
1218 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1218 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1219 connect( action, SIGNAL( activated() ), 1219 connect( action, SIGNAL( activated() ),
1220 mView, SLOT( goNext() ) ); 1220 mView, SLOT( goNext() ) );
1221 action->addTo( navigatorToolBar ); 1221 action->addTo( navigatorToolBar );
1222 } 1222 }
1223 icon = loadPixmap( pathString + "2rightarrowB" ); 1223 icon = loadPixmap( pathString + "2rightarrowB" );
1224 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1224 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1225 if (p-> mShowIconForwardFast) { 1225 if (p-> mShowIconForwardFast) {
1226 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1226 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1227 connect( action, SIGNAL( activated() ), 1227 connect( action, SIGNAL( activated() ),
1228 mView, SLOT( goNextMonth() ) ); 1228 mView, SLOT( goNextMonth() ) );
1229 action->addTo( navigatorToolBar ); 1229 action->addTo( navigatorToolBar );
1230 } 1230 }
1231 1231
1232 1232
1233 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1233 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1234 1234
1235 1235
1236 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1236 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1237 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1237 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1238 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1238 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1239 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1239 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1240 1240
1241 if (p-> mShowIconNewEvent) 1241 if (p-> mShowIconNewEvent)
1242 configureToolBarMenu->setItemChecked( 10, true ); 1242 configureToolBarMenu->setItemChecked( 10, true );
1243 if (p->mShowIconNewTodo ) 1243 if (p->mShowIconNewTodo )
1244 configureToolBarMenu->setItemChecked( 20, true ); 1244 configureToolBarMenu->setItemChecked( 20, true );
1245 if (p-> mShowIconSearch) 1245 if (p-> mShowIconSearch)
1246 configureToolBarMenu->setItemChecked( 120, true ); 1246 configureToolBarMenu->setItemChecked( 120, true );
1247 if (p-> mShowIconList) 1247 if (p-> mShowIconList)
1248 configureToolBarMenu->setItemChecked( 30, true ); 1248 configureToolBarMenu->setItemChecked( 30, true );
1249 if (p-> mShowIconDay1) 1249 if (p-> mShowIconDay1)
1250 configureToolBarMenu->setItemChecked( 40, true ); 1250 configureToolBarMenu->setItemChecked( 40, true );
1251 if (p-> mShowIconDay5) 1251 if (p-> mShowIconDay5)
1252 configureToolBarMenu->setItemChecked( 50, true ); 1252 configureToolBarMenu->setItemChecked( 50, true );
1253 if (p-> mShowIconDay6) 1253 if (p-> mShowIconDay6)
1254 configureToolBarMenu->setItemChecked( 75, true ); 1254 configureToolBarMenu->setItemChecked( 75, true );
1255 if (p-> mShowIconDay7) 1255 if (p-> mShowIconDay7)
1256 configureToolBarMenu->setItemChecked( 60, true ); 1256 configureToolBarMenu->setItemChecked( 60, true );
1257 if (p-> mShowIconMonth) 1257 if (p-> mShowIconMonth)
1258 configureToolBarMenu->setItemChecked( 70, true ); 1258 configureToolBarMenu->setItemChecked( 70, true );
1259 if (p-> mShowIconTodoview) 1259 if (p-> mShowIconTodoview)
1260 configureToolBarMenu->setItemChecked( 80, true ); 1260 configureToolBarMenu->setItemChecked( 80, true );
1261 if (p-> mShowIconBackFast) 1261 if (p-> mShowIconBackFast)
1262 configureToolBarMenu->setItemChecked( 200, true ); 1262 configureToolBarMenu->setItemChecked( 200, true );
1263 if (p-> mShowIconBack) 1263 if (p-> mShowIconBack)
1264 configureToolBarMenu->setItemChecked( 210, true ); 1264 configureToolBarMenu->setItemChecked( 210, true );
1265 if (p-> mShowIconToday) 1265 if (p-> mShowIconToday)
1266 configureToolBarMenu->setItemChecked( 130, true ); 1266 configureToolBarMenu->setItemChecked( 130, true );
1267 if (p-> mShowIconForward) 1267 if (p-> mShowIconForward)
1268 configureToolBarMenu->setItemChecked( 220, true ); 1268 configureToolBarMenu->setItemChecked( 220, true );
1269 if (p-> mShowIconForwardFast) 1269 if (p-> mShowIconForwardFast)
1270 configureToolBarMenu->setItemChecked( 230, true ); 1270 configureToolBarMenu->setItemChecked( 230, true );
1271 if (p-> mShowIconNextDays) 1271 if (p-> mShowIconNextDays)
1272 configureToolBarMenu->setItemChecked( 100, true ); 1272 configureToolBarMenu->setItemChecked( 100, true );
1273 if (p-> mShowIconNext) 1273 if (p-> mShowIconNext)
1274 configureToolBarMenu->setItemChecked( 110, true ); 1274 configureToolBarMenu->setItemChecked( 110, true );
1275 if (p-> mShowIconJournal) 1275 if (p-> mShowIconJournal)
1276 configureToolBarMenu->setItemChecked( 90, true ); 1276 configureToolBarMenu->setItemChecked( 90, true );
1277 if (p-> mShowIconWhatsThis) 1277 if (p-> mShowIconWhatsThis)
1278 configureToolBarMenu->setItemChecked( 300, true ); 1278 configureToolBarMenu->setItemChecked( 300, true );
1279 if (p-> mShowIconWeekNum) 1279 if (p-> mShowIconWeekNum)
1280 configureToolBarMenu->setItemChecked( 400, true ); 1280 configureToolBarMenu->setItemChecked( 400, true );
1281 if (!p-> mShowIconStretch) { 1281 if (!p-> mShowIconStretch) {
1282 QLabel* dummy = new QLabel( iconToolBar ); 1282 QLabel* dummy = new QLabel( iconToolBar );
1283 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1283 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1284 dummy->setMinimumWidth( 0 ); 1284 dummy->setMinimumWidth( 0 );
1285 iconToolBar->setStretchableWidget ( dummy ) ; 1285 iconToolBar->setStretchableWidget ( dummy ) ;
1286 } 1286 }
1287 else { 1287 else {
1288 iconToolBar->setHorizontalStretchable (true ); 1288 iconToolBar->setHorizontalStretchable (true );
1289 viewToolBar->setHorizontalStretchable (true ); 1289 viewToolBar->setHorizontalStretchable (true );
1290 navigatorToolBar->setHorizontalStretchable (true ); 1290 navigatorToolBar->setHorizontalStretchable (true );
1291 iconToolBar->setVerticalStretchable (true ); 1291 iconToolBar->setVerticalStretchable (true );
1292 viewToolBar->setVerticalStretchable (true ); 1292 viewToolBar->setVerticalStretchable (true );
1293 navigatorToolBar->setVerticalStretchable (true ); 1293 navigatorToolBar->setVerticalStretchable (true );
1294 configureToolBarMenu->setItemChecked( 5, true ); 1294 configureToolBarMenu->setItemChecked( 5, true );
1295 } 1295 }
1296 if (p-> mShowIconFilter) 1296 if (p-> mShowIconFilter)
1297 configureToolBarMenu->setItemChecked( 7, true ); 1297 configureToolBarMenu->setItemChecked( 7, true );
1298 if (p-> mShowIconOnetoolbar) 1298 if (p-> mShowIconOnetoolbar)
1299 configureToolBarMenu->setItemChecked( 6, true ); 1299 configureToolBarMenu->setItemChecked( 6, true );
1300 1300
1301 1301
1302 if ( filterMenubar ) { 1302 if ( filterMenubar ) {
1303 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); 1303 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1304 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); 1304 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) );
1305 } 1305 }
1306 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1306 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1307 configureAgenda( p->mHourSize ); 1307 configureAgenda( p->mHourSize );
1308 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1308 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1309} 1309}
1310 1310
1311void MainWindow::exportToPhone( int mode ) 1311void MainWindow::exportToPhone( int mode )
1312{ 1312{
1313 1313
1314 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1314 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1315 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1315 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1316 KOex2phonePrefs ex2phone; 1316 KOex2phonePrefs ex2phone;
1317 1317
1318 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1318 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1319 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1319 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1320 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1320 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1321 if ( mode == 1 ) 1321 if ( mode == 1 )
1322 ex2phone.setCaption(i18n("Export complete calendar")); 1322 ex2phone.setCaption(i18n("Export complete calendar"));
1323 if ( mode == 2 ) 1323 if ( mode == 2 )
1324 ex2phone.setCaption(i18n("Export filtered calendar")); 1324 ex2phone.setCaption(i18n("Export filtered calendar"));
1325 1325
1326 if ( !ex2phone.exec() ) { 1326 if ( !ex2phone.exec() ) {
1327 return; 1327 return;
1328 } 1328 }
1329 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1329 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1330 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1330 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1331 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1331 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1332 1332
1333 int inFuture = 0; 1333 int inFuture = 0;
1334 if ( ex2phone.mWriteBackFuture->isChecked() ) 1334 if ( ex2phone.mWriteBackFuture->isChecked() )
1335 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1335 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1336 QPtrList<Incidence> delSel; 1336 QPtrList<Incidence> delSel;
1337 if ( mode == 1 ) 1337 if ( mode == 1 )
1338 delSel = mCalendar->rawIncidences(); 1338 delSel = mCalendar->rawIncidences();
1339 if ( mode == 2 ) 1339 if ( mode == 2 )
1340 delSel = mCalendar->incidences(); 1340 delSel = mCalendar->incidences();
1341 CalendarLocal* cal = new CalendarLocal(); 1341 CalendarLocal* cal = new CalendarLocal();
1342 cal->setLocalTime(); 1342 cal->setLocalTime();
1343 Incidence *incidence = delSel.first(); 1343 Incidence *incidence = delSel.first();
1344 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1344 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1345 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1345 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1346 while ( incidence ) { 1346 while ( incidence ) {
1347 if ( incidence->typeID() != journalID ) { 1347 if ( incidence->typeID() != journalID ) {
1348 bool add = true; 1348 bool add = true;
1349 if ( inFuture ) { 1349 if ( inFuture ) {
1350 QDateTime dt; 1350 QDateTime dt;
1351 if ( incidence->typeID() == todoID ) { 1351 if ( incidence->typeID() == todoID ) {
1352 Todo * t = (Todo*)incidence; 1352 Todo * t = (Todo*)incidence;
1353 if ( t->hasDueDate() ) 1353 if ( t->hasDueDate() )
1354 dt = t->dtDue(); 1354 dt = t->dtDue();
1355 else 1355 else
1356 dt = cur.addSecs( 62 ); 1356 dt = cur.addSecs( 62 );
1357 } 1357 }
1358 else { 1358 else {
1359 bool ok; 1359 bool ok;
1360 dt = incidence->getNextOccurence( cur, &ok ); 1360 dt = incidence->getNextOccurence( cur, &ok );
1361 if ( !ok ) 1361 if ( !ok )
1362 dt = cur.addSecs( -62 ); 1362 dt = cur.addSecs( -62 );
1363 } 1363 }
1364 if ( dt < cur || dt > end ) { 1364 if ( dt < cur || dt > end ) {
1365 add = false; 1365 add = false;
1366 } 1366 }
1367 } 1367 }
1368 if ( add ) { 1368 if ( add ) {
1369 Incidence *in = incidence->clone(); 1369 Incidence *in = incidence->clone();
1370 cal->addIncidence( in ); 1370 cal->addIncidence( in );
1371 } 1371 }
1372 } 1372 }
1373 incidence = delSel.next(); 1373 incidence = delSel.next();
1374 } 1374 }
1375 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1375 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1376 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1376 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1377 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1377 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1378 1378
1379 setCaption( i18n("Writing to phone...")); 1379 setCaption( i18n("Writing to phone..."));
1380 if ( PhoneFormat::writeToPhone( cal ) ) 1380 if ( PhoneFormat::writeToPhone( cal ) )
1381 setCaption( i18n("Export to phone successful!")); 1381 setCaption( i18n("Export to phone successful!"));
1382 else 1382 else
1383 setCaption( i18n("Error exporting to phone!")); 1383 setCaption( i18n("Error exporting to phone!"));
1384 delete cal; 1384 delete cal;
1385} 1385}
1386 1386
1387 1387
1388void MainWindow::setDefaultPreferences() 1388void MainWindow::setDefaultPreferences()
1389{ 1389{
1390 KOPrefs *p = KOPrefs::instance(); 1390 KOPrefs *p = KOPrefs::instance();
1391 1391
1392 p->mCompactDialogs = true; 1392 p->mCompactDialogs = true;
1393 p->mConfirm = true; 1393 p->mConfirm = true;
1394 // p->mEnableQuickTodo = false; 1394 // p->mEnableQuickTodo = false;
1395 1395
1396} 1396}
1397 1397
1398QString MainWindow::resourcePath() 1398QString MainWindow::resourcePath()
1399{ 1399{
1400 return KGlobal::iconLoader()->iconPath(); 1400 return KGlobal::iconLoader()->iconPath();
1401} 1401}
1402 1402
1403void MainWindow::displayText( QString text ,QString cap ) 1403void MainWindow::displayText( QString text ,QString cap )
1404{ 1404{
1405 QDialog dia( this, "name", true ); ; 1405 QDialog dia( this, "name", true ); ;
1406 dia.setCaption( cap ); 1406 dia.setCaption( cap );
1407 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1407 QVBoxLayout* lay = new QVBoxLayout( &dia );
1408 lay->setSpacing( 3 ); 1408 lay->setSpacing( 3 );
1409 lay->setMargin( 3 ); 1409 lay->setMargin( 3 );
1410 QTextBrowser tb ( &dia ); 1410 QTextBrowser tb ( &dia );
1411 lay->addWidget( &tb ); 1411 lay->addWidget( &tb );
1412 tb.setText( text ); 1412 tb.setText( text );
1413#ifdef DESKTOP_VERSION 1413#ifdef DESKTOP_VERSION
1414 dia.resize( 640, 480); 1414 dia.resize( 640, 480);
1415#else 1415#else
1416 dia.showMaximized(); 1416 dia.showMaximized();
1417#endif 1417#endif
1418 dia.exec(); 1418 dia.exec();
1419} 1419}
1420 1420
1421void MainWindow::features() 1421void MainWindow::features()
1422{ 1422{
1423 1423
1424 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1424 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1425} 1425}
1426 1426
1427void MainWindow::usertrans() 1427void MainWindow::usertrans()
1428{ 1428{
1429 1429
1430 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1430 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1431} 1431}
1432 1432
1433void MainWindow::storagehowto() 1433void MainWindow::storagehowto()
1434{ 1434{
1435 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1435 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1436} 1436}
1437void MainWindow::timetrackinghowto() 1437void MainWindow::timetrackinghowto()
1438{ 1438{
1439 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1439 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1440} 1440}
1441void MainWindow::kdesynchowto() 1441void MainWindow::kdesynchowto()
1442{ 1442{
1443 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1443 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1444} 1444}
1445void MainWindow::multisynchowto() 1445void MainWindow::multisynchowto()
1446{ 1446{
1447 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1447 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1448} 1448}
1449void MainWindow::synchowto() 1449void MainWindow::synchowto()
1450{ 1450{
1451 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1451 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1452} 1452}
1453void MainWindow::faq() 1453void MainWindow::faq()
1454{ 1454{
1455 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1455 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1456 1456
1457} 1457}
1458void MainWindow::whatsNew() 1458void MainWindow::whatsNew()
1459{ 1459{
1460 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1460 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1461 1461
1462} 1462}
1463void MainWindow::licence() 1463void MainWindow::licence()
1464{ 1464{
1465 KApplication::showLicence(); 1465 KApplication::showLicence();
1466 1466
1467} 1467}
1468void MainWindow::about() 1468void MainWindow::about()
1469{ 1469{
1470 QString version; 1470 QString version;
1471#include <../version> 1471#include <../version>
1472 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1472 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1473 i18n("KOrganizer/Platform-independent\n") + 1473 i18n("KOrganizer/Platform-independent\n") +
1474 "(KO/Pi) " + version + " - " + 1474 "(KO/Pi) " + version + " - " +
1475 1475
1476#ifdef DESKTOP_VERSION 1476#ifdef DESKTOP_VERSION
1477 i18n("Desktop Edition\n") + 1477 i18n("Desktop Edition\n") +
1478#else 1478#else
1479 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1479 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1480#endif 1480#endif
1481 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1481 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1482} 1482}
1483void MainWindow::keyBindings() 1483void MainWindow::keyBindings()
1484{ 1484{
1485 QString cap = i18n("KO/Pi Keys + Colors"); 1485 QString cap = i18n("KO/Pi Keys + Colors");
1486 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1486 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1487 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1487 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1488 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1488 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1489 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1489 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1490 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1490 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1491 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1491 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1492 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+ 1492 i18n("<p><b>R</b>: Toggle Resource View |<b>F</b>: Edit filter </p>\n")+
1493 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1493 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1494 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1494 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1495 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1495 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1496 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1496 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1497 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1497 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1498 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1498 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1499 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1499 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1500 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1500 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1501 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1501 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1502 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1502 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1503 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1503 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1504 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1504 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1505 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1505 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1506 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1506 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1507 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1507 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1508 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1508 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1509 i18n("<p><h3>In agenda view:</h3></p>\n") + 1509 i18n("<p><h3>In agenda view:</h3></p>\n") +
1510 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1510 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1511 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1511 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1512 i18n("<p><h3>In todo view:</h3></p>\n") + 1512 i18n("<p><h3>In todo view:</h3></p>\n") +
1513 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1513 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1514 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1514 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1515 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1515 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1516 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1516 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1517 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1517 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1518 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1518 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1519 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1519 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1520 i18n("<p><h3>In list view:</h3></p>\n") + 1520 i18n("<p><h3>In list view:</h3></p>\n") +
1521 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1521 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1522 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1522 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1523 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1523 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1524 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1524 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1525 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1525 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1526 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1526 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1527 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1527 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1528 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1528 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1529 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1529 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1530 i18n("<p><b>E</b>: Edit item</p>\n") + 1530 i18n("<p><b>E</b>: Edit item</p>\n") +
1531 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1531 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1532 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1532 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1533 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1533 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1534 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1534 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1535 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1535 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1536 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1536 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1537 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1537 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1538 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1538 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1539 i18n("<p><b>White</b>: Item readonly</p>\n"); 1539 i18n("<p><b>White</b>: Item readonly</p>\n");
1540 displayText( text, cap); 1540 displayText( text, cap);
1541} 1541}
1542void MainWindow::aboutAutoSaving() 1542void MainWindow::aboutAutoSaving()
1543{ 1543{
1544 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1544 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1545 1545
1546 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1546 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1547 1547
1548} 1548}
1549void MainWindow::aboutKnownBugs() 1549void MainWindow::aboutKnownBugs()
1550{ 1550{
1551 QMessageBox* msg; 1551 QMessageBox* msg;
1552 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1552 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1553 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1553 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1554 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1554 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1555 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1555 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1556 i18n("\nor report them in the bugtracker on\n") + 1556 i18n("\nor report them in the bugtracker on\n") +
1557 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1557 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1558 QMessageBox::NoIcon, 1558 QMessageBox::NoIcon,
1559 QMessageBox::Ok, 1559 QMessageBox::Ok,
1560 QMessageBox::NoButton, 1560 QMessageBox::NoButton,
1561 QMessageBox::NoButton); 1561 QMessageBox::NoButton);
1562 msg->exec(); 1562 msg->exec();
1563 delete msg; 1563 delete msg;
1564 1564
1565} 1565}
1566 1566
1567QString MainWindow::defaultFileName() 1567QString MainWindow::defaultFileName()
1568{ 1568{
1569 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1569 return locateLocal( "data", "korganizer/mycalendar.ics" );
1570} 1570}
1571QString MainWindow::syncFileName() 1571QString MainWindow::syncFileName()
1572{ 1572{
1573#ifdef DESKTOP_VERSION 1573#ifdef DESKTOP_VERSION
1574 return locateLocal( "tmp", "synccalendar.ics" ); 1574 return locateLocal( "tmp", "synccalendar.ics" );
1575#else 1575#else
1576 return QString( "/tmp/synccalendar.ics" ); 1576 return QString( "/tmp/synccalendar.ics" );
1577#endif 1577#endif
1578} 1578}
1579#include "koglobals.h" 1579#include "koglobals.h"
1580#include <kcalendarsystem.h> 1580#include <kcalendarsystem.h>
1581void MainWindow::updateWeek(QDate seda) 1581void MainWindow::updateWeek(QDate seda)
1582{ 1582{
1583 int weekNum = KGlobal::locale()->weekNum ( seda ); 1583 int weekNum = KGlobal::locale()->weekNum ( seda );
1584 mWeekPixmap.fill( mWeekBgColor ); 1584 mWeekPixmap.fill( mWeekBgColor );
1585 QPainter p ( &mWeekPixmap ); 1585 QPainter p ( &mWeekPixmap );
1586 p.setFont( mWeekFont ); 1586 p.setFont( mWeekFont );
1587 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1587 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1588 p.end(); 1588 p.end();
1589 QIconSet icon3 ( mWeekPixmap ); 1589 QIconSet icon3 ( mWeekPixmap );
1590 mWeekAction->setIconSet ( icon3 ); 1590 mWeekAction->setIconSet ( icon3 );
1591 1591
1592} 1592}
1593void MainWindow::updateWeekNum(const DateList &selectedDates) 1593void MainWindow::updateWeekNum(const DateList &selectedDates)
1594{ 1594{
1595 updateWeek( selectedDates.first() ); 1595 updateWeek( selectedDates.first() );
1596} 1596}
1597void MainWindow::processIncidenceSelection( Incidence *incidence ) 1597void MainWindow::processIncidenceSelection( Incidence *incidence )
1598{ 1598{
1599 1599
1600 if ( !incidence ) { 1600 if ( !incidence ) {
1601 enableIncidenceActions( false ); 1601 enableIncidenceActions( false );
1602 1602
1603 mNewSubTodoAction->setEnabled( false ); 1603 mNewSubTodoAction->setEnabled( false );
1604 setCaptionToDates(); 1604 setCaptionToDates();
1605 return; 1605 return;
1606 1606
1607 } 1607 }
1608 1608
1609 //KGlobal::locale()->formatDateTime(nextA, true); 1609 //KGlobal::locale()->formatDateTime(nextA, true);
1610 QString startString = ""; 1610 QString startString = "";
1611 if ( incidence->typeID() != todoID ) { 1611 if ( incidence->typeID() != todoID ) {
1612 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1612 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1613 if ( incidence->doesFloat() ) { 1613 if ( incidence->doesFloat() ) {
1614 startString += ": "+incidence->dtStartDateStr( true ); 1614 startString += ": "+incidence->dtStartDateStr( true );
1615 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1615 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1616 1616
1617 } else { 1617 } else {
1618 startString = ": "+incidence->dtStartStr(true); 1618 startString = ": "+incidence->dtStartStr(true);
1619 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1619 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1620 1620
1621 } 1621 }
1622 1622
1623 } else { 1623 } else {
1624 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1624 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1625 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1625 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1626 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1626 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1627 1627
1628 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1628 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1629 bool ok; 1629 bool ok;
1630 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1630 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1631 if ( ok ) { 1631 if ( ok ) {
1632 int years = noc.date().year() - incidence->dtStart().date().year(); 1632 int years = noc.date().year() - incidence->dtStart().date().year();
1633 startString += i18n(" (%1 y.)"). arg( years ); 1633 startString += i18n(" (%1 y.)"). arg( years );
1634 } 1634 }
1635 } 1635 }
1636 else 1636 else
1637 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1637 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1638 } 1638 }
1639 1639
1640 } 1640 }
1641 else 1641 else
1642 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1642 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1643 if ( !incidence->location().isEmpty() ) 1643 if ( !incidence->location().isEmpty() )
1644 startString += " (" +incidence->location()+")"; 1644 startString += " (" +incidence->location()+")";
1645 setCaption( incidence->summary()+startString); 1645 setCaption( incidence->summary()+startString);
1646 1646
1647 enableIncidenceActions( true ); 1647 enableIncidenceActions( true );
1648 1648
1649 if ( incidence->typeID() == eventID ) { 1649 if ( incidence->typeID() == eventID ) {
1650 mShowAction->setText( i18n("Show Event...") ); 1650 mShowAction->setText( i18n("Show Event...") );
1651 mEditAction->setText( i18n("Edit Event...") ); 1651 mEditAction->setText( i18n("Edit Event...") );
1652 mDeleteAction->setText( i18n("Delete Event...") ); 1652 mDeleteAction->setText( i18n("Delete Event...") );
1653 1653
1654 mNewSubTodoAction->setEnabled( false ); 1654 mNewSubTodoAction->setEnabled( false );
1655 } else if ( incidence->typeID() == todoID ) { 1655 } else if ( incidence->typeID() == todoID ) {
1656 mShowAction->setText( i18n("Show Todo...") ); 1656 mShowAction->setText( i18n("Show Todo...") );
1657 mEditAction->setText( i18n("Edit Todo...") ); 1657 mEditAction->setText( i18n("Edit Todo...") );
1658 mDeleteAction->setText( i18n("Delete Todo...") ); 1658 mDeleteAction->setText( i18n("Delete Todo...") );
1659 1659
1660 mNewSubTodoAction->setEnabled( true ); 1660 mNewSubTodoAction->setEnabled( true );
1661 } else { 1661 } else {
1662 mShowAction->setText( i18n("Show...") ); 1662 mShowAction->setText( i18n("Show...") );
1663 mShowAction->setText( i18n("Edit...") ); 1663 mShowAction->setText( i18n("Edit...") );
1664 mShowAction->setText( i18n("Delete...") ); 1664 mShowAction->setText( i18n("Delete...") );
1665 1665
1666 mNewSubTodoAction->setEnabled( false ); 1666 mNewSubTodoAction->setEnabled( false );
1667 } 1667 }
1668} 1668}
1669 1669
1670void MainWindow::enableIncidenceActions( bool enabled ) 1670void MainWindow::enableIncidenceActions( bool enabled )
1671{ 1671{
1672 mShowAction->setEnabled( enabled ); 1672 mShowAction->setEnabled( enabled );
1673 mEditAction->setEnabled( enabled ); 1673 mEditAction->setEnabled( enabled );
1674 mDeleteAction->setEnabled( enabled ); 1674 mDeleteAction->setEnabled( enabled );
1675 1675
1676 mCloneAction->setEnabled( enabled ); 1676 mCloneAction->setEnabled( enabled );
1677 mMoveAction->setEnabled( enabled ); 1677 mMoveAction->setEnabled( enabled );
1678 mBeamAction->setEnabled( enabled ); 1678 mBeamAction->setEnabled( enabled );
1679 mCancelAction->setEnabled( enabled ); 1679 mCancelAction->setEnabled( enabled );
1680} 1680}
1681 1681
1682void MainWindow::importOL() 1682void MainWindow::importOL()
1683{ 1683{
1684#ifdef _OL_IMPORT_ 1684#ifdef _OL_IMPORT_
1685 mView->clearAllViews(); 1685 mView->clearAllViews();
1686 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1686 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1687 id->exec(); 1687 id->exec();
1688 delete id; 1688 delete id;
1689 mView->calendar()->checkAlarmForIncidence( 0, true ); 1689 mView->calendar()->checkAlarmForIncidence( 0, true );
1690 mView->updateView(); 1690 mView->updateView();
1691#endif 1691#endif
1692} 1692}
1693void MainWindow::importBday() 1693void MainWindow::importBday()
1694{ 1694{
1695 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1695 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1696 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1696 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1697 i18n("Import!"), i18n("Cancel"), 0, 1697 i18n("Import!"), i18n("Cancel"), 0,
1698 0, 1 ); 1698 0, 1 );
1699 if ( result == 0 ) { 1699 if ( result == 0 ) {
1700 mView->importBday(); 1700 mView->importBday();
1701 1701
1702 } 1702 }
1703 1703
1704 1704
1705} 1705}
1706void MainWindow::importQtopia() 1706void MainWindow::importQtopia()
1707{ 1707{
1708 //#ifndef DESKTOP_VERSION 1708 //#ifndef DESKTOP_VERSION
1709 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1709 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1710#ifdef DESKTOP_VERSION 1710#ifdef DESKTOP_VERSION
1711 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1711 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1712#endif 1712#endif
1713 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1713 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1714 i18n("Import!"), i18n("Cancel"), 0, 1714 i18n("Import!"), i18n("Cancel"), 0,
1715 0, 1 ); 1715 0, 1 );
1716 if ( result == 0 ) { 1716 if ( result == 0 ) {
1717#ifndef DESKTOP_VERSION 1717#ifndef DESKTOP_VERSION
1718 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1718 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1719 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1719 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1720 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1720 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1721#else 1721#else
1722 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1722 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1723 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1723 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1724 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1724 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1725#endif 1725#endif
1726 mView->importQtopia( categories, datebook, todolist ); 1726 mView->importQtopia( categories, datebook, todolist );
1727 } 1727 }
1728 mView->calendar()->reInitAlarmSettings(); 1728 mView->calendar()->reInitAlarmSettings();
1729#if 0 1729#if 0
1730 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1730 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1731 i18n("Not supported \non desktop!\n"), 1731 i18n("Not supported \non desktop!\n"),
1732 i18n("Ok"), i18n("Cancel"), 0, 1732 i18n("Ok"), i18n("Cancel"), 0,
1733 0, 1 ); 1733 0, 1 );
1734 1734
1735#endif 1735#endif
1736} 1736}
1737 1737
1738void MainWindow::saveOnClose() 1738void MainWindow::saveOnClose()
1739{ 1739{
1740 KOPrefs *p = KOPrefs::instance(); 1740 KOPrefs *p = KOPrefs::instance();
1741 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1741 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1742 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1742 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1743 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1743 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1744 if ( filterToolBar ) { 1744 if ( filterToolBar ) {
1745 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1745 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1746 } 1746 }
1747#ifdef DESKTOP_VERSION 1747#ifdef DESKTOP_VERSION
1748 1748
1749 QPoint myP; 1749 QPoint myP;
1750 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1750 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1751 if ( p->mToolBarHor ) 1751 if ( p->mToolBarHor )
1752 p->mToolBarUp = myP.y() > height()/2; 1752 p->mToolBarUp = myP.y() > height()/2;
1753 else 1753 else
1754 p->mToolBarUp = myP.x() > width()/2; 1754 p->mToolBarUp = myP.x() > width()/2;
1755 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1755 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1756 if ( p->mToolBarHorV ) 1756 if ( p->mToolBarHorV )
1757 p->mToolBarUpV = myP.y() > height()/2; 1757 p->mToolBarUpV = myP.y() > height()/2;
1758 else 1758 else
1759 p->mToolBarUpV = myP.x() > width()/2 ; 1759 p->mToolBarUpV = myP.x() > width()/2 ;
1760 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1760 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1761 if ( p->mToolBarHorN ) 1761 if ( p->mToolBarHorN )
1762 p->mToolBarUpN = myP.y() > height()/2; 1762 p->mToolBarUpN = myP.y() > height()/2;
1763 else 1763 else
1764 p->mToolBarUpN = myP.x() > width()/2 ; 1764 p->mToolBarUpN = myP.x() > width()/2 ;
1765 if ( filterToolBar ) { 1765 if ( filterToolBar ) {
1766 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1766 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1767 if ( p->mToolBarHorF ) 1767 if ( p->mToolBarHorF )
1768 p->mToolBarUpF = myP.y() > height()/2; 1768 p->mToolBarUpF = myP.y() > height()/2;
1769 else 1769 else
1770 p->mToolBarUpF = myP.x() > width()/2 ; 1770 p->mToolBarUpF = myP.x() > width()/2 ;
1771 } 1771 }
1772#else 1772#else
1773 if ( p->mToolBarHor ) 1773 if ( p->mToolBarHor )
1774 p->mToolBarUp = iconToolBar->y() > height()/2; 1774 p->mToolBarUp = iconToolBar->y() > height()/2;
1775 else 1775 else
1776 p->mToolBarUp = iconToolBar->x() > width()/2; 1776 p->mToolBarUp = iconToolBar->x() > width()/2;
1777 if ( p->mToolBarHorV ) 1777 if ( p->mToolBarHorV )
1778 p->mToolBarUpV = viewToolBar->y() > height()/2; 1778 p->mToolBarUpV = viewToolBar->y() > height()/2;
1779 else 1779 else
1780 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1780 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1781 1781
1782 if ( p->mToolBarHorN ) 1782 if ( p->mToolBarHorN )
1783 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1783 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1784 else 1784 else
1785 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1785 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1786 if ( filterToolBar ) { 1786 if ( filterToolBar ) {
1787 if ( p->mToolBarHorF ) 1787 if ( p->mToolBarHorF )
1788 p->mToolBarUpF = filterToolBar->y() > height()/2; 1788 p->mToolBarUpF = filterToolBar->y() > height()/2;
1789 else 1789 else
1790 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1790 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1791 } 1791 }
1792#endif 1792#endif
1793 1793
1794 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1794 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1795 save(); 1795 save();
1796 mView->writeSettings(); 1796 mView->writeSettings();
1797} 1797}
1798void MainWindow::slotModifiedChanged( bool changed ) 1798void MainWindow::slotModifiedChanged( bool changed )
1799{ 1799{
1800 if ( mBlockAtStartup ) 1800 if ( mBlockAtStartup )
1801 return; 1801 return;
1802 1802
1803 int msec; 1803 int msec;
1804 // we store the changes after 1 minute, 1804 // we store the changes after 1 minute,
1805 // and for safety reasons after 10 minutes again 1805 // and for safety reasons after 10 minutes again
1806 if ( !mSyncManager->blockSave() ) 1806 if ( !mSyncManager->blockSave() )
1807 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1807 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1808 else 1808 else
1809 msec = 1000 * 600; 1809 msec = 1000 * 600;
1810 mSaveTimer.start( msec, true ); // 1 minute 1810 mSaveTimer.start( msec, true ); // 1 minute
1811 qDebug("KO: Saving File in %d secs!", msec/1000); 1811 qDebug("KO: Saving File in %d secs!", msec/1000);
1812 mCalendarModifiedFlag = true; 1812 mCalendarModifiedFlag = true;
1813} 1813}
1814void MainWindow::saveStopTimer() 1814void MainWindow::saveStopTimer()
1815{ 1815{
1816 mSaveTimer.stop(); 1816 mSaveTimer.stop();
1817} 1817}
1818void MainWindow::save() 1818void MainWindow::save()
1819{ 1819{
1820 if ( !mCalendarModifiedFlag ) { 1820 if ( !mCalendarModifiedFlag ) {
1821 qDebug("KO: Calendar not modified. Nothing saved."); 1821 qDebug("KO: Calendar not modified. Nothing saved.");
1822 return; 1822 return;
1823 } 1823 }
1824 if ( mSyncManager->blockSave() ) 1824 if ( mSyncManager->blockSave() )
1825 return; 1825 return;
1826 mSyncManager->setBlockSave(true); 1826 mSyncManager->setBlockSave(true);
1827 if ( mView->checkFileVersion( defaultFileName()) ) { 1827 if ( mView->checkFileVersion( defaultFileName()) ) {
1828 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1828 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1829 QDate reference ( 2000,1,1); 1829 QDate reference ( 2000,1,1);
1830 int daysTo = reference.daysTo ( QDate::currentDate() ); 1830 int daysTo = reference.daysTo ( QDate::currentDate() );
1831 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1831 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1832 setCaption(i18n("Creating backup ... please wait ..." )); 1832 setCaption(i18n("Creating backup ... please wait ..." ));
1833 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1833 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1834 // we need the file path, the backup dir and the number of bups as param 1834 // we need the file path, the backup dir and the number of bups as param
1835 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1835 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1836 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1836 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1837 bupDir = KGlobalSettings::backupDataDir(); 1837 bupDir = KGlobalSettings::backupDataDir();
1838 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1838 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1839 if ( retval == 0 ) { 1839 if ( retval == 0 ) {
1840 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1840 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1841 // retval == 0 : backup skipped for today, try again tomorrow 1841 // retval == 0 : backup skipped for today, try again tomorrow
1842 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1842 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1843 } else if ( retval == 1 ){ 1843 } else if ( retval == 1 ){
1844 qDebug("KO: Backup created."); 1844 qDebug("KO: Backup created.");
1845 // backup ok 1845 // backup ok
1846 KOPrefs::instance()->mLastBackupDate = daysTo; 1846 KOPrefs::instance()->mLastBackupDate = daysTo;
1847 1847
1848 } else if ( retval == 2 ){ 1848 } else if ( retval == 2 ){
1849 qDebug("KO: Backup globally cancelled."); 1849 qDebug("KO: Backup globally cancelled.");
1850 // backup globally cancelled 1850 // backup globally cancelled
1851 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1851 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1852 } 1852 }
1853 // retval == 3: do nothing, try again later 1853 // retval == 3: do nothing, try again later
1854 } 1854 }
1855 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1855 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1856 } 1856 }
1857 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1857 QTime neededSaveTime = QDateTime::currentDateTime().time();
1858 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1858 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1859 qDebug("KO: Start saving data to file!"); 1859 qDebug("KO: Start saving data to file!");
1860 mView->saveCalendar( defaultFileName() ); 1860 mView->saveCalendars();
1861 mCalendarModifiedFlag = false; 1861 mCalendarModifiedFlag = false;
1862 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1862 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1863 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1863 qDebug("KO: Needed %d ms for saving.",msNeeded );
1864 QString savemes; 1864 QString savemes;
1865 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1865 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1866 setCaption(savemes); 1866 setCaption(savemes);
1867 } else 1867 } else
1868 setCaption(i18n("Saving cancelled!")); 1868 setCaption(i18n("Saving cancelled!"));
1869 mSyncManager->setBlockSave( false ); 1869 mSyncManager->setBlockSave( false );
1870} 1870}
1871 1871
1872void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1872void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1873{ 1873{
1874 if ( !e->isAutoRepeat() ) { 1874 if ( !e->isAutoRepeat() ) {
1875 mFlagKeyPressed = false; 1875 mFlagKeyPressed = false;
1876 } 1876 }
1877} 1877}
1878void MainWindow::keyPressEvent ( QKeyEvent * e ) 1878void MainWindow::keyPressEvent ( QKeyEvent * e )
1879{ 1879{
1880 qApp->processEvents(); 1880 qApp->processEvents();
1881 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1881 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1882 e->ignore(); 1882 e->ignore();
1883 // qDebug(" ignore %d",e->isAutoRepeat() ); 1883 // qDebug(" ignore %d",e->isAutoRepeat() );
1884 return; 1884 return;
1885 } 1885 }
1886 if (! e->isAutoRepeat() ) 1886 if (! e->isAutoRepeat() )
1887 mFlagKeyPressed = true; 1887 mFlagKeyPressed = true;
1888 KOPrefs *p = KOPrefs::instance(); 1888 KOPrefs *p = KOPrefs::instance();
1889 bool showSelectedDates = false; 1889 bool showSelectedDates = false;
1890 int size; 1890 int size;
1891 int pro = 0; 1891 int pro = 0;
1892 //qDebug("MainWindow::keyPressEvent "); 1892 //qDebug("MainWindow::keyPressEvent ");
1893 switch ( e->key() ) { 1893 switch ( e->key() ) {
1894 case Qt::Key_Right: 1894 case Qt::Key_Right:
1895 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1895 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1896 mView->goNextMonth(); 1896 mView->goNextMonth();
1897 else 1897 else
1898 mView->goNext(); 1898 mView->goNext();
1899 showSelectedDates = true; 1899 showSelectedDates = true;
1900 break; 1900 break;
1901 case Qt::Key_Left: 1901 case Qt::Key_Left:
1902 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1902 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1903 mView->goPreviousMonth(); 1903 mView->goPreviousMonth();
1904 else 1904 else
1905 mView->goPrevious(); 1905 mView->goPrevious();
1906 showSelectedDates = true; 1906 showSelectedDates = true;
1907 break; 1907 break;
1908 case Qt::Key_Down: 1908 case Qt::Key_Down:
1909 mView->viewManager()->agendaView()->scrollOneHourDown(); 1909 mView->viewManager()->agendaView()->scrollOneHourDown();
1910 break; 1910 break;
1911 case Qt::Key_Up: 1911 case Qt::Key_Up:
1912 mView->viewManager()->agendaView()->scrollOneHourUp(); 1912 mView->viewManager()->agendaView()->scrollOneHourUp();
1913 break; 1913 break;
1914 case Qt::Key_K: 1914 case Qt::Key_K:
1915 mView->viewManager()->showMonthViewWeek(); 1915 mView->viewManager()->showMonthViewWeek();
1916 break; 1916 break;
1917 case Qt::Key_I: 1917 case Qt::Key_I:
1918 mView->showIncidence(); 1918 mView->showIncidence();
1919 break; 1919 break;
1920 case Qt::Key_Delete: 1920 case Qt::Key_Delete:
1921 case Qt::Key_Backspace: 1921 case Qt::Key_Backspace:
1922 mView->deleteIncidence(); 1922 mView->deleteIncidence();
1923 break; 1923 break;
1924 case Qt::Key_D: 1924 case Qt::Key_D:
1925 mView->viewManager()->showDayView(); 1925 mView->viewManager()->showDayView();
1926 showSelectedDates = true; 1926 showSelectedDates = true;
1927 break; 1927 break;
1928 case Qt::Key_O: 1928 case Qt::Key_O:
1929 mView->toggleFilerEnabled( ); 1929 mView->toggleFilerEnabled( );
1930 break; 1930 break;
1931 case Qt::Key_0: 1931 case Qt::Key_0:
1932 case Qt::Key_1: 1932 case Qt::Key_1:
1933 case Qt::Key_2: 1933 case Qt::Key_2:
1934 case Qt::Key_3: 1934 case Qt::Key_3:
1935 case Qt::Key_4: 1935 case Qt::Key_4:
1936 case Qt::Key_5: 1936 case Qt::Key_5:
1937 case Qt::Key_6: 1937 case Qt::Key_6:
1938 case Qt::Key_7: 1938 case Qt::Key_7:
1939 case Qt::Key_8: 1939 case Qt::Key_8:
1940 case Qt::Key_9: 1940 case Qt::Key_9:
1941 pro = e->key()-48; 1941 pro = e->key()-48;
1942 if ( pro == 0 ) 1942 if ( pro == 0 )
1943 pro = 10; 1943 pro = 10;
1944 if ( e->state() == Qt::ControlButton) 1944 if ( e->state() == Qt::ControlButton)
1945 pro += 10; 1945 pro += 10;
1946 break; 1946 break;
1947 case Qt::Key_M: 1947 case Qt::Key_M:
1948 mView->viewManager()->showMonthView(); 1948 mView->viewManager()->showMonthView();
1949 showSelectedDates = true; 1949 showSelectedDates = true;
1950 break; 1950 break;
1951 case Qt::Key_Insert: 1951 case Qt::Key_Insert:
1952 mView->newEvent(); 1952 mView->newEvent();
1953 break; 1953 break;
1954 case Qt::Key_S : 1954 case Qt::Key_S :
1955 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1955 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1956 mView->newSubTodo(); 1956 mView->newSubTodo();
1957 else 1957 else
1958 mView->dialogManager()->showSearchDialog(); 1958 mView->dialogManager()->showSearchDialog();
1959 break; 1959 break;
1960 case Qt::Key_Y : 1960 case Qt::Key_Y :
1961 case Qt::Key_Z : 1961 case Qt::Key_Z :
1962 mView->viewManager()->showWorkWeekView(); 1962 mView->viewManager()->showWorkWeekView();
1963 showSelectedDates = true; 1963 showSelectedDates = true;
1964 break; 1964 break;
1965 case Qt::Key_U : 1965 case Qt::Key_U :
1966 mView->viewManager()->showWeekView(); 1966 mView->viewManager()->showWeekView();
1967 showSelectedDates = true; 1967 showSelectedDates = true;
1968 break; 1968 break;
1969 case Qt::Key_H : 1969 case Qt::Key_H :
1970 keyBindings(); 1970 keyBindings();
1971 break; 1971 break;
1972 case Qt::Key_W: 1972 case Qt::Key_W:
1973 mView->viewManager()->showWhatsNextView(); 1973 mView->viewManager()->showWhatsNextView();
1974 break; 1974 break;
1975 case Qt::Key_L: 1975 case Qt::Key_L:
1976 mView->viewManager()->showListView(); 1976 mView->viewManager()->showListView();
1977 break; 1977 break;
1978 case Qt::Key_N: 1978 case Qt::Key_N:
1979 mView->viewManager()->showNextView(); 1979 mView->viewManager()->showNextView();
1980 break; 1980 break;
1981 case Qt::Key_V: 1981 case Qt::Key_V:
1982 mView->viewManager()->showTodoView(); 1982 mView->viewManager()->showTodoView();
1983 break; 1983 break;
1984 case Qt::Key_C: 1984 case Qt::Key_C:
1985 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1985 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1986 break; 1986 break;
1987 case Qt::Key_P: 1987 case Qt::Key_P:
1988 mView->showDatePicker( ); 1988 mView->showDatePicker( );
1989 break; 1989 break;
1990 case Qt::Key_F: 1990 case Qt::Key_F:
1991 mView->editFilters(); 1991 mView->editFilters();
1992 break; 1992 break;
1993 case Qt::Key_R: 1993 case Qt::Key_R:
1994 mView->toggleFilter(); 1994 mView->toggleFilter();
1995 break; 1995 break;
1996 case Qt::Key_X: 1996 case Qt::Key_X:
1997 if ( e->state() == Qt::ControlButton ) 1997 if ( e->state() == Qt::ControlButton )
1998 mView->toggleDateNavigatorWidget(); 1998 mView->toggleDateNavigatorWidget();
1999 else { 1999 else {
2000 mView->viewManager()->showNextXView(); 2000 mView->viewManager()->showNextXView();
2001 showSelectedDates = true; 2001 showSelectedDates = true;
2002 } 2002 }
2003 break; 2003 break;
2004 case Qt::Key_Space: 2004 case Qt::Key_Space:
2005 mView->toggleExpand(); 2005 mView->toggleExpand();
2006 break; 2006 break;
2007 case Qt::Key_A: 2007 case Qt::Key_A:
2008 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 2008 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
2009 mView->showNextAlarms(); 2009 mView->showNextAlarms();
2010 else 2010 else
2011 mView->toggleAllDaySize(); 2011 mView->toggleAllDaySize();
2012 break; 2012 break;
2013 case Qt::Key_T: 2013 case Qt::Key_T:
2014 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2014 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2015 mView->newTodo(); 2015 mView->newTodo();
2016 else { 2016 else {
2017 mView->goToday(); 2017 mView->goToday();
2018 showSelectedDates = true; 2018 showSelectedDates = true;
2019 } 2019 }
2020 break; 2020 break;
2021 case Qt::Key_J: 2021 case Qt::Key_J:
2022 mView->viewManager()->showJournalView(); 2022 mView->viewManager()->showJournalView();
2023 break; 2023 break;
2024 case Qt::Key_B: 2024 case Qt::Key_B:
2025 mView->editIncidenceDescription();; 2025 mView->editIncidenceDescription();;
2026 break; 2026 break;
2027 // case Qt::Key_Return: 2027 // case Qt::Key_Return:
2028 case Qt::Key_E: 2028 case Qt::Key_E:
2029 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2029 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2030 mView->newEvent(); 2030 mView->newEvent();
2031 else 2031 else
2032 mView->editIncidence(); 2032 mView->editIncidence();
2033 break; 2033 break;
2034 case Qt::Key_Plus: 2034 case Qt::Key_Plus:
2035 size = p->mHourSize +2; 2035 size = p->mHourSize +2;
2036 if ( size <= 22 ) 2036 if ( size <= 22 )
2037 configureAgenda( size ); 2037 configureAgenda( size );
2038 break; 2038 break;
2039 case Qt::Key_Minus: 2039 case Qt::Key_Minus:
2040 size = p->mHourSize - 2; 2040 size = p->mHourSize - 2;
2041 if ( size >= 4 ) 2041 if ( size >= 4 )
2042 configureAgenda( size ); 2042 configureAgenda( size );
2043 break; 2043 break;
2044 2044
2045 2045
2046 default: 2046 default:
2047 e->ignore(); 2047 e->ignore();
2048 } 2048 }
2049 if ( pro > 0 ) { 2049 if ( pro > 0 ) {
2050 mView->selectFilter( pro-1 ); 2050 mView->selectFilter( pro-1 );
2051 } 2051 }
2052 if ( showSelectedDates ) { 2052 if ( showSelectedDates ) {
2053 ;// setCaptionToDates(); 2053 ;// setCaptionToDates();
2054 } 2054 }
2055 2055
2056} 2056}
2057void MainWindow::fillFilterMenuTB() 2057void MainWindow::fillFilterMenuTB()
2058{ 2058{
2059 selectFilterMenuTB->clear(); 2059 selectFilterMenuTB->clear();
2060 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2060 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2061 selectFilterMenuTB->insertSeparator(); 2061 selectFilterMenuTB->insertSeparator();
2062 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2062 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2063 2063
2064 selectFilterMenuTB->insertSeparator(); 2064 selectFilterMenuTB->insertSeparator();
2065 QPtrList<CalFilter> fili = mView->filters(); 2065 QPtrList<CalFilter> fili = mView->filters();
2066 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2066 CalFilter *curfilter = mView->filterView()->selectedFilter();
2067 CalFilter *filter = fili.first(); 2067 CalFilter *filter = fili.first();
2068 int iii = 2; 2068 int iii = 2;
2069 bool checkitem = mView->filterView()->filtersEnabled(); 2069 bool checkitem = mView->filterView()->filtersEnabled();
2070 while(filter) { 2070 while(filter) {
2071 selectFilterMenuTB->insertItem( filter->name(), iii ); 2071 selectFilterMenuTB->insertItem( filter->name(), iii );
2072 if ( filter == curfilter) 2072 if ( filter == curfilter)
2073 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2073 selectFilterMenuTB->setItemChecked( iii, checkitem );
2074 filter = fili.next(); 2074 filter = fili.next();
2075 ++iii; 2075 ++iii;
2076 } 2076 }
2077 if ( !checkitem ) 2077 if ( !checkitem )
2078 selectFilterMenuTB->setItemChecked( 1, true ); 2078 selectFilterMenuTB->setItemChecked( 1, true );
2079 2079
2080 int x = 0; 2080 int x = 0;
2081 int y = iconToolBar->height(); 2081 int y = iconToolBar->height();
2082 int dX = 0; 2082 int dX = 0;
2083 int dY = 0; 2083 int dY = 0;
2084 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2084 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2085 if ( iconToolBar->y() > height()/2 ) { 2085 if ( iconToolBar->y() > height()/2 ) {
2086 dY = selectFilterMenuTB->sizeHint().height()+8; 2086 dY = selectFilterMenuTB->sizeHint().height()+8;
2087 y = 0; 2087 y = 0;
2088 } 2088 }
2089 } else { 2089 } else {
2090 if ( iconToolBar->x() > width()/2 ) { // right side 2090 if ( iconToolBar->x() > width()/2 ) { // right side
2091 x=0; 2091 x=0;
2092 dX= selectFilterMenuTB->sizeHint().width()+8; 2092 dX= selectFilterMenuTB->sizeHint().width()+8;
2093 y = 0; 2093 y = 0;
2094 } else { 2094 } else {
2095 x= iconToolBar->width(); 2095 x= iconToolBar->width();
2096 y = 0; 2096 y = 0;
2097 } 2097 }
2098 } 2098 }
2099 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2099 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2100 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2100 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2101} 2101}
2102void MainWindow::fillFilterMenu() 2102void MainWindow::fillFilterMenu()
2103{ 2103{
2104 selectFilterMenu->clear(); 2104 selectFilterMenu->clear();
2105 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2105 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2106 selectFilterMenu->insertSeparator(); 2106 selectFilterMenu->insertSeparator();
2107 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2107 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2108 2108
2109 selectFilterMenu->insertSeparator(); 2109 selectFilterMenu->insertSeparator();
2110 QPtrList<CalFilter> fili = mView->filters(); 2110 QPtrList<CalFilter> fili = mView->filters();
2111 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2111 CalFilter *curfilter = mView->filterView()->selectedFilter();
2112 CalFilter *filter = fili.first(); 2112 CalFilter *filter = fili.first();
2113 int iii = 2; 2113 int iii = 2;
2114 bool checkitem = mView->filterView()->filtersEnabled(); 2114 bool checkitem = mView->filterView()->filtersEnabled();
2115 while(filter) { 2115 while(filter) {
2116 selectFilterMenu->insertItem( filter->name(), iii ); 2116 selectFilterMenu->insertItem( filter->name(), iii );
2117 if ( filter == curfilter) 2117 if ( filter == curfilter)
2118 selectFilterMenu->setItemChecked( iii, checkitem ); 2118 selectFilterMenu->setItemChecked( iii, checkitem );
2119 filter = fili.next(); 2119 filter = fili.next();
2120 ++iii; 2120 ++iii;
2121 } 2121 }
2122 if ( !checkitem ) 2122 if ( !checkitem )
2123 selectFilterMenu->setItemChecked( 1, true ); 2123 selectFilterMenu->setItemChecked( 1, true );
2124} 2124}
2125void MainWindow::fillFilterMenuPopup() 2125void MainWindow::fillFilterMenuPopup()
2126{ 2126{
2127 filterPopupMenu->clear(); 2127 filterPopupMenu->clear();
2128 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2128 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2129 2129
2130 filterPopupMenu->insertSeparator(); 2130 filterPopupMenu->insertSeparator();
2131 QPtrList<CalFilter> fili = mView->filters(); 2131 QPtrList<CalFilter> fili = mView->filters();
2132 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2132 CalFilter *curfilter = mView->filterView()->selectedFilter();
2133 CalFilter *filter = fili.first(); 2133 CalFilter *filter = fili.first();
2134 int iii = 1; 2134 int iii = 1;
2135 bool checkitem = mView->filterView()->filtersEnabled(); 2135 bool checkitem = mView->filterView()->filtersEnabled();
2136 while(filter) { 2136 while(filter) {
2137 filterPopupMenu->insertItem( filter->name(), iii ); 2137 filterPopupMenu->insertItem( filter->name(), iii );
2138 if ( filter == curfilter) 2138 if ( filter == curfilter)
2139 filterPopupMenu->setItemChecked( iii, checkitem ); 2139 filterPopupMenu->setItemChecked( iii, checkitem );
2140 filter = fili.next(); 2140 filter = fili.next();
2141 ++iii; 2141 ++iii;
2142 } 2142 }
2143 if ( !checkitem ) 2143 if ( !checkitem )
2144 filterPopupMenu->setItemChecked( 0, true ); 2144 filterPopupMenu->setItemChecked( 0, true );
2145} 2145}
2146void MainWindow::selectFilter( int fil ) 2146void MainWindow::selectFilter( int fil )
2147{ 2147{
2148 2148
2149 if ( fil == 0 ) { 2149 if ( fil == 0 ) {
2150 mView->editFilters( ); 2150 mView->editFilters( );
2151 } else if ( fil == 1 ){ 2151 } else if ( fil == 1 ){
2152 if ( mView->filterView()->filtersEnabled() ) 2152 if ( mView->filterView()->filtersEnabled() )
2153 mView->toggleFilerEnabled( ); 2153 mView->toggleFilerEnabled( );
2154 } else { 2154 } else {
2155 if ( !mView->filterView()->filtersEnabled() ) { 2155 if ( !mView->filterView()->filtersEnabled() ) {
2156 mView->filterView()->blockSignals( true ); 2156 mView->filterView()->blockSignals( true );
2157 mView->toggleFilerEnabled( ); 2157 mView->toggleFilerEnabled( );
2158 mView->filterView()->blockSignals( false ); 2158 mView->filterView()->blockSignals( false );
2159 } 2159 }
2160 mView->selectFilter( fil-2 ); 2160 mView->selectFilter( fil-2 );
2161 } 2161 }
2162} 2162}
2163void MainWindow::updateFilterToolbar() 2163void MainWindow::updateFilterToolbar()
2164{ 2164{
2165 if ( filterMenubar ) { 2165 if ( filterMenubar ) {
2166 if ( !mView->filterView()->filtersEnabled() ) { 2166 if ( !mView->filterView()->filtersEnabled() ) {
2167 filterMenubar->changeItem( 0, i18n("No Filter") ); 2167 filterMenubar->changeItem( 0, i18n("No Filter") );
2168 } else { 2168 } else {
2169 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2169 CalFilter *curfilter = mView->filterView()->selectedFilter();
2170 if ( curfilter ) { 2170 if ( curfilter ) {
2171 filterMenubar->changeItem( 0, curfilter->name() ); 2171 filterMenubar->changeItem( 0, curfilter->name() );
2172 } 2172 }
2173 } 2173 }
2174 } 2174 }
2175} 2175}
2176void MainWindow::selectFilterPopup( int fil ) 2176void MainWindow::selectFilterPopup( int fil )
2177{ 2177{
2178 selectFilter( fil + 1 ); 2178 selectFilter( fil + 1 );
2179 2179
2180} 2180}
2181void MainWindow::configureToolBar( int item ) 2181void MainWindow::configureToolBar( int item )
2182{ 2182{
2183 2183
2184 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2184 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2185 KOPrefs *p = KOPrefs::instance(); 2185 KOPrefs *p = KOPrefs::instance();
2186 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2186 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2187 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2187 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2188 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2188 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2189 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2189 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2190 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2190 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2191 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2191 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2192 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2192 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2193 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2193 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2194 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2194 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2195 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2195 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2196 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2196 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2197 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2197 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2198 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2198 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2199 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2199 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2200 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2200 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2201 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2201 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2202 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2202 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2203 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2203 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2204 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2204 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2205 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2205 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2206 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2206 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2207 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2207 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2208 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2208 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2209 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2209 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2210 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2210 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2211 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2211 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2212 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2212 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2213 // initActions(); 2213 // initActions();
2214} 2214}
2215void MainWindow::setCaption ( const QString & c ) 2215void MainWindow::setCaption ( const QString & c )
2216{ 2216{
2217 QString cap = c; 2217 QString cap = c;
2218 cap.replace( QRegExp("\n"), " " ); 2218 cap.replace( QRegExp("\n"), " " );
2219 cap = cap.stripWhiteSpace(); 2219 cap = cap.stripWhiteSpace();
2220 if ( cap.isEmpty() ) 2220 if ( cap.isEmpty() )
2221 cap = "KO/Pi"; 2221 cap = "KO/Pi";
2222 QWidget::setCaption( cap ); 2222 QWidget::setCaption( cap );
2223} 2223}
2224void MainWindow::setCaptionToDates() 2224void MainWindow::setCaptionToDates()
2225{ 2225{
2226 QString selDates; 2226 QString selDates;
2227 QDate date = mView->startDate(); 2227 QDate date = mView->startDate();
2228 if ( ! date.isValid() ) { 2228 if ( ! date.isValid() ) {
2229 setCaption(""); 2229 setCaption("");
2230 return; 2230 return;
2231 } 2231 }
2232 selDates = KGlobal::locale()->formatDate( date, true); 2232 selDates = KGlobal::locale()->formatDate( date, true);
2233 if (mView->startDate() < mView->endDate() ) 2233 if (mView->startDate() < mView->endDate() )
2234 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2234 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2235 else { 2235 else {
2236 QString addString; 2236 QString addString;
2237 if ( date == QDateTime::currentDateTime().date() ) 2237 if ( date == QDateTime::currentDateTime().date() )
2238 addString = i18n("Today"); 2238 addString = i18n("Today");
2239 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2239 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2240 addString = i18n("Tomorrow"); 2240 addString = i18n("Tomorrow");
2241 if ( !addString.isEmpty() ) 2241 if ( !addString.isEmpty() )
2242 selDates = addString+", "+selDates ; 2242 selDates = addString+", "+selDates ;
2243 } 2243 }
2244 setCaption( i18n("Dates: ") + selDates ); 2244 setCaption( i18n("Dates: ") + selDates );
2245 2245
2246} 2246}
2247void MainWindow::showConfigureAgenda( ) 2247void MainWindow::showConfigureAgenda( )
2248{ 2248{
2249 int iii; 2249 int iii;
2250 for ( iii = 1;iii<= 10 ;++iii ){ 2250 for ( iii = 1;iii<= 10 ;++iii ){
2251 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2251 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2252 } 2252 }
2253 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2253 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2254} 2254}
2255void MainWindow::configureAgenda( int item ) 2255void MainWindow::configureAgenda( int item )
2256{ 2256{
2257 if ( KOPrefs::instance()->mHourSize == item ) 2257 if ( KOPrefs::instance()->mHourSize == item )
2258 return; 2258 return;
2259 KOPrefs::instance()->mHourSize=item; 2259 KOPrefs::instance()->mHourSize=item;
2260 mView->viewManager()->agendaView()->updateConfig(); 2260 mView->viewManager()->agendaView()->updateConfig();
2261} 2261}
2262 2262
2263void MainWindow::saveCalendar() 2263void MainWindow::saveCalendar()
2264{ 2264{
2265 QString fn = KOPrefs::instance()->mLastSaveFile; 2265 QString fn = KOPrefs::instance()->mLastSaveFile;
2266 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 2266 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
2267 2267
2268 if ( fn == "" ) 2268 if ( fn == "" )
2269 return; 2269 return;
2270 QFileInfo info; 2270 QFileInfo info;
2271 info.setFile( fn ); 2271 info.setFile( fn );
2272 QString mes; 2272 QString mes;
2273 bool createbup = true; 2273 bool createbup = true;
2274 if ( info. exists() ) { 2274 if ( info. exists() ) {
2275 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 2275 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
2276 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2276 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2277 i18n("Overwrite!"), i18n("Cancel"), 0, 2277 i18n("Overwrite!"), i18n("Cancel"), 0,
2278 0, 1 ); 2278 0, 1 );
2279 if ( result != 0 ) { 2279 if ( result != 0 ) {
2280 createbup = false; 2280 createbup = false;
2281 } 2281 }
2282 } 2282 }
2283 if ( createbup ) { 2283 if ( createbup ) {
2284 mView->saveCalendar( fn ); 2284 mView->saveCalendar( fn );
2285 mes = i18n("KO/Pi:Saved %1").arg(fn); 2285 mes = i18n("KO/Pi:Saved %1").arg(fn);
2286 KOPrefs::instance()->mLastSaveFile = fn; 2286 KOPrefs::instance()->mLastSaveFile = fn;
2287 setCaption(mes); 2287 setCaption(mes);
2288 } 2288 }
2289} 2289}
2290void MainWindow::loadCalendar() 2290void MainWindow::loadCalendar()
2291{ 2291{
2292 2292
2293 QString fn = KOPrefs::instance()->mLastLoadFile; 2293 QString fn = KOPrefs::instance()->mLastLoadFile;
2294 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2294 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2295 2295
2296 if ( fn == "" ) 2296 if ( fn == "" )
2297 return; 2297 return;
2298 QFileInfo info; 2298 QFileInfo info;
2299 info.setFile( fn ); 2299 info.setFile( fn );
2300 QString mess; 2300 QString mess;
2301 bool loadbup = true; 2301 bool loadbup = true;
2302 if ( info. exists() ) { 2302 if ( info. exists() ) {
2303 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2303 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2304 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2304 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2305 mess, 2305 mess,
2306 i18n("Load!"), i18n("Cancel"), 0, 2306 i18n("Load!"), i18n("Cancel"), 0,
2307 0, 1 ); 2307 0, 1 );
2308 if ( result != 0 ) { 2308 if ( result != 0 ) {
2309 loadbup = false; 2309 loadbup = false;
2310 } 2310 }
2311 } else { 2311 } else {
2312 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2312 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2313 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2313 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2314 0, 1 ); 2314 0, 1 );
2315 2315
2316 return; 2316 return;
2317 } 2317 }
2318 if ( loadbup ) { 2318 if ( loadbup ) {
2319 mView->openCalendar( fn ); 2319 mView->openCalendar( fn );
2320 KOPrefs::instance()->mLastLoadFile = fn; 2320 KOPrefs::instance()->mLastLoadFile = fn;
2321 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2321 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2322 setCaption(mess); 2322 setCaption(mess);
2323 } 2323 }
2324 2324
2325} 2325}
2326void MainWindow::quickImportIcal() 2326void MainWindow::quickImportIcal()
2327{ 2327{
2328 importFile( KOPrefs::instance()->mLastImportFile, false ); 2328 importFile( KOPrefs::instance()->mLastImportFile, false );
2329} 2329}
2330void MainWindow::importFile( QString fn, bool quick ) 2330void MainWindow::importFile( QString fn, bool quick )
2331{ 2331{
2332 QFileInfo info; 2332 QFileInfo info;
2333 info.setFile( fn ); 2333 info.setFile( fn );
2334 QString mess; 2334 QString mess;
2335 bool loadbup = true; 2335 bool loadbup = true;
2336 if ( !info. exists() ) { 2336 if ( !info. exists() ) {
2337 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2337 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2338 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2338 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2339 mess ); 2339 mess );
2340 return; 2340 return;
2341 } 2341 }
2342 int result = 0; 2342 int result = 0;
2343 if ( !quick ) { 2343 if ( !quick ) {
2344 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2344 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2345 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2345 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2346 mess, 2346 mess,
2347 "Import", "Cancel", 0, 2347 "Import", "Cancel", 0,
2348 0, 1 ); 2348 0, 1 );
2349 } 2349 }
2350 if ( result == 0 ) { 2350 if ( result == 0 ) {
2351 if ( mView->openCalendar( fn, true )) { 2351 if ( mView->openCalendar( fn, true )) {
2352 KOPrefs::instance()->mLastImportFile = fn; 2352 KOPrefs::instance()->mLastImportFile = fn;
2353 setCaption(i18n("Imported file successfully")); 2353 setCaption(i18n("Imported file successfully"));
2354 } else { 2354 } else {
2355 setCaption(i18n("Error importing file")); 2355 setCaption(i18n("Error importing file"));
2356 } 2356 }
2357 } 2357 }
2358} 2358}
2359 2359
2360void MainWindow::importIcal() 2360void MainWindow::importIcal()
2361{ 2361{
2362 2362
2363 QString fn =KOPrefs::instance()->mLastImportFile; 2363 QString fn =KOPrefs::instance()->mLastImportFile;
2364 2364
2365 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2365 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2366 if ( fn == "" ) 2366 if ( fn == "" )
2367 return; 2367 return;
2368 importFile( fn, true ); 2368 importFile( fn, true );
2369 2369
2370} 2370}
2371 2371
2372void MainWindow::exportVCalendar() 2372void MainWindow::exportVCalendar()
2373{ 2373{
2374 QString fn = KOPrefs::instance()->mLastVcalFile; 2374 QString fn = KOPrefs::instance()->mLastVcalFile;
2375 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2375 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2376 if ( fn == "" ) 2376 if ( fn == "" )
2377 return; 2377 return;
2378 QFileInfo info; 2378 QFileInfo info;
2379 info.setFile( fn ); 2379 info.setFile( fn );
2380 QString mes; 2380 QString mes;
2381 bool createbup = true; 2381 bool createbup = true;
2382 if ( info. exists() ) { 2382 if ( info. exists() ) {
2383 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2383 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2384 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2384 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2385 i18n("Overwrite!"), i18n("Cancel"), 0, 2385 i18n("Overwrite!"), i18n("Cancel"), 0,
2386 0, 1 ); 2386 0, 1 );
2387 if ( result != 0 ) { 2387 if ( result != 0 ) {
2388 createbup = false; 2388 createbup = false;
2389 } 2389 }
2390 } 2390 }
2391 if ( createbup ) { 2391 if ( createbup ) {
2392 if ( mView->exportVCalendar( fn ) ) { 2392 if ( mView->exportVCalendar( fn ) ) {
2393 KOPrefs::instance()->mLastVcalFile = fn; 2393 KOPrefs::instance()->mLastVcalFile = fn;
2394 if ( fn.length() > 20 ) 2394 if ( fn.length() > 20 )
2395 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2395 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2396 else 2396 else
2397 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2397 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2398 setCaption(mes); 2398 setCaption(mes);
2399 } 2399 }
2400 } 2400 }
2401 2401
2402} 2402}
2403QString MainWindow::sentSyncFile() 2403QString MainWindow::sentSyncFile()
2404{ 2404{
2405#ifdef DESKTOP_VERSION 2405#ifdef DESKTOP_VERSION
2406 return locateLocal( "tmp", "copysynccal.ics" ); 2406 return locateLocal( "tmp", "copysynccal.ics" );
2407#else 2407#else
2408 return QString( "/tmp/copysynccal.ics" ); 2408 return QString( "/tmp/copysynccal.ics" );
2409#endif 2409#endif
2410} 2410}
2411 2411
2412void MainWindow::syncFileRequest() 2412void MainWindow::syncFileRequest()
2413{ 2413{
2414 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2414 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2415 mSyncManager->slotSyncMenu( 999 ); 2415 mSyncManager->slotSyncMenu( 999 );
2416 } 2416 }
2417 2417
2418 setCaption(i18n("Saving Data to temp file ..." )); 2418 setCaption(i18n("Saving Data to temp file ..." ));
2419 mView->saveCalendar( sentSyncFile() ); 2419 mView->saveCalendar( sentSyncFile() );
2420 setCaption(i18n("Data saved to temp file!" )); 2420 setCaption(i18n("Data saved to temp file!" ));
2421 2421
2422} 2422}
2423void MainWindow::getFile( bool success ) 2423void MainWindow::getFile( bool success )
2424{ 2424{
2425 if ( ! success ) { 2425 if ( ! success ) {
2426 setCaption( i18n("Error receiving file. Nothing changed!") ); 2426 setCaption( i18n("Error receiving file. Nothing changed!") );
2427 return; 2427 return;
2428 } 2428 }
2429 mView->openCalendar( sentSyncFile() ); 2429 mView->openCalendar( sentSyncFile() );
2430 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2430 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2431 mSyncManager->slotSyncMenu( 999 ); 2431 mSyncManager->slotSyncMenu( 999 );
2432 } 2432 }
2433 setCaption( i18n("Pi-Sync successful!") ); 2433 setCaption( i18n("Pi-Sync successful!") );
2434} 2434}
2435void MainWindow::printListView() 2435void MainWindow::printListView()
2436{ 2436{
2437 2437
2438 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items."); 2438 QString message = i18n("You can make a printout of the <b>List View</b> and the list view in the <b>Search Dialog</b>! To do this, please go to the <b>List View/Search Dialog</b>. Right click on the list. Select in the popup menu the entry <b>Print complete list</b>. That prints the list as you see it. You can remove items from the list before printing without deleting the corresponding event/todo! Simply select all items you do not want to print out. Then right click on one of the items and choose <b>Hide selected items</b>. After that you can print the list without these items.");
2439 2439
2440 KMessageBox::information( this, message); 2440 KMessageBox::information( this, message);
2441} 2441}
2442void MainWindow::printSel( ) 2442void MainWindow::printSel( )
2443{ 2443{
2444 mView->viewManager()->agendaView()->agenda()->printSelection(); 2444 mView->viewManager()->agendaView()->agenda()->printSelection();
2445} 2445}
2446 2446
2447void MainWindow::printCal() 2447void MainWindow::printCal()
2448{ 2448{
2449 mView->print();//mCp->showDialog(); 2449 mView->print();//mCp->showDialog();
2450} 2450}
2451 2451
2452 2452
2453#include "libkdepim/kdatepicker.h" 2453#include "libkdepim/kdatepicker.h"
2454#include <kdatetbl.h> 2454#include <kdatetbl.h>
2455 2455
2456void MainWindow::weekAction() 2456void MainWindow::weekAction()
2457{ 2457{
2458 int month; 2458 int month;
2459 KPopupFrame* popup = new KPopupFrame(this); 2459 KPopupFrame* popup = new KPopupFrame(this);
2460 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2460 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2461 // ----- 2461 // -----
2462 picker->resize(picker->sizeHint()); 2462 picker->resize(picker->sizeHint());
2463 popup->setMainWidget(picker); 2463 popup->setMainWidget(picker);
2464 picker->setFocus(); 2464 picker->setFocus();
2465 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2465 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2466 int x = 0; 2466 int x = 0;
2467 int y = iconToolBar->height(); 2467 int y = iconToolBar->height();
2468 int dX = 0; 2468 int dX = 0;
2469 int dY = 0; 2469 int dY = 0;
2470 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2470 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2471 if ( iconToolBar->y() > height()/2 ) { 2471 if ( iconToolBar->y() > height()/2 ) {
2472 dY = picker->sizeHint().height()+8; 2472 dY = picker->sizeHint().height()+8;
2473 y = 0; 2473 y = 0;
2474 } 2474 }
2475 } else { 2475 } else {
2476 if ( iconToolBar->x() > width()/2 ) { // right side 2476 if ( iconToolBar->x() > width()/2 ) { // right side
2477 x=0; 2477 x=0;
2478 dX= picker->sizeHint().width()+8; 2478 dX= picker->sizeHint().width()+8;
2479 y = 0; 2479 y = 0;
2480 } else { 2480 } else {
2481 x= iconToolBar->width(); 2481 x= iconToolBar->width();
2482 y = 0; 2482 y = 0;
2483 } 2483 }
2484 } 2484 }
2485 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2485 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2486 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2486 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2487 { 2487 {
2488 month = picker->getResult(); 2488 month = picker->getResult();
2489 emit selectWeek ( month ); 2489 emit selectWeek ( month );
2490 //qDebug("weekSelected %d ", month); 2490 //qDebug("weekSelected %d ", month);
2491 } 2491 }
2492 delete popup; 2492 delete popup;
2493} 2493}
2494 2494
2495void MainWindow::hideEvent ( QHideEvent * ) 2495void MainWindow::hideEvent ( QHideEvent * )
2496{ 2496{
2497 QString message; 2497 QString message;
2498 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2498 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2499 if ( nextA.isValid() ) { 2499 if ( nextA.isValid() ) {
2500 QString sum = mCalendar->nextSummary(); 2500 QString sum = mCalendar->nextSummary();
2501 2501
2502 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); 2502 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false));
2503 setCaption( message ); 2503 setCaption( message );
2504 } 2504 }
2505} 2505}
2506 2506
2507void MainWindow::resizeEvent( QResizeEvent* e) 2507void MainWindow::resizeEvent( QResizeEvent* e)
2508{ 2508{
2509#ifndef DESKTOP_VERSION 2509#ifndef DESKTOP_VERSION
2510 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2510 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2511 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2511 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2512 filterToolBar->hide(); 2512 filterToolBar->hide();
2513 else 2513 else
2514 filterToolBar->show(); 2514 filterToolBar->show();
2515 } 2515 }
2516#endif 2516#endif
2517 QMainWindow::resizeEvent( e); 2517 QMainWindow::resizeEvent( e);
2518} 2518}
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index f4350d9..5092d1a 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -1,483 +1,488 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library 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 GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <stdlib.h> 22#include <stdlib.h>
23#include <time.h> 23#include <time.h>
24 24
25#include <kdebug.h> 25#include <kdebug.h>
26#include <kglobal.h> 26#include <kglobal.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#include "exceptions.h" 29#include "exceptions.h"
30#include "calfilter.h" 30#include "calfilter.h"
31 31
32#include "calendar.h" 32#include "calendar.h"
33#include "syncdefines.h" 33#include "syncdefines.h"
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37Calendar::Calendar() 37Calendar::Calendar()
38{ 38{
39 39
40 init(); 40 init();
41 setTimeZoneId( " 00:00 Europe/London(UTC)" ); 41 setTimeZoneId( " 00:00 Europe/London(UTC)" );
42} 42}
43 43
44Calendar::Calendar( const QString &timeZoneId ) 44Calendar::Calendar( const QString &timeZoneId )
45{ 45{
46 46
47 init(); 47 init();
48 setTimeZoneId(timeZoneId); 48 setTimeZoneId(timeZoneId);
49} 49}
50 50
51void Calendar::init() 51void Calendar::init()
52{ 52{
53 mObserver = 0; 53 mObserver = 0;
54 mNewObserver = false; 54 mNewObserver = false;
55 mUndoIncidence = 0; 55 mUndoIncidence = 0;
56 mDeleteIncidencesOnClose = true;
56 mModified = false; 57 mModified = false;
57 mDefaultCalendar = 1; 58 mDefaultCalendar = 1;
58 // Setup default filter, which does nothing 59 // Setup default filter, which does nothing
59 mDefaultFilter = new CalFilter; 60 mDefaultFilter = new CalFilter;
60 mFilter = mDefaultFilter; 61 mFilter = mDefaultFilter;
61 mFilter->setEnabled(false); 62 mFilter->setEnabled(false);
62 63
63 // initialize random numbers. This is a hack, and not 64 // initialize random numbers. This is a hack, and not
64 // even that good of one at that. 65 // even that good of one at that.
65// srandom(time(0)); 66// srandom(time(0));
66 67
67 // user information... 68 // user information...
68 setOwner(i18n("Unknown Name")); 69 setOwner(i18n("Unknown Name"));
69 setEmail(i18n("unknown@nowhere")); 70 setEmail(i18n("unknown@nowhere"));
70 71
71#if 0 72#if 0
72 tmpStr = KOPrefs::instance()->mTimeZone; 73 tmpStr = KOPrefs::instance()->mTimeZone;
73// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; 74// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl;
74 int dstSetting = KOPrefs::instance()->mDaylightSavings; 75 int dstSetting = KOPrefs::instance()->mDaylightSavings;
75 extern long int timezone; 76 extern long int timezone;
76 struct tm *now; 77 struct tm *now;
77 time_t curtime; 78 time_t curtime;
78 curtime = time(0); 79 curtime = time(0);
79 now = localtime(&curtime); 80 now = localtime(&curtime);
80 int hourOff = - ((timezone / 60) / 60); 81 int hourOff = - ((timezone / 60) / 60);
81 if (now->tm_isdst) 82 if (now->tm_isdst)
82 hourOff += 1; 83 hourOff += 1;
83 QString tzStr; 84 QString tzStr;
84 tzStr.sprintf("%.2d%.2d", 85 tzStr.sprintf("%.2d%.2d",
85 hourOff, 86 hourOff,
86 abs((timezone / 60) % 60)); 87 abs((timezone / 60) % 60));
87 88
88 // if no time zone was in the config file, write what we just discovered. 89 // if no time zone was in the config file, write what we just discovered.
89 if (tmpStr.isEmpty()) { 90 if (tmpStr.isEmpty()) {
90// KOPrefs::instance()->mTimeZone = tzStr; 91// KOPrefs::instance()->mTimeZone = tzStr;
91 } else { 92 } else {
92 tzStr = tmpStr; 93 tzStr = tmpStr;
93 } 94 }
94 95
95 // if daylight savings has changed since last load time, we need 96 // if daylight savings has changed since last load time, we need
96 // to rewrite these settings to the config file. 97 // to rewrite these settings to the config file.
97 if ((now->tm_isdst && !dstSetting) || 98 if ((now->tm_isdst && !dstSetting) ||
98 (!now->tm_isdst && dstSetting)) { 99 (!now->tm_isdst && dstSetting)) {
99 KOPrefs::instance()->mTimeZone = tzStr; 100 KOPrefs::instance()->mTimeZone = tzStr;
100 KOPrefs::instance()->mDaylightSavings = now->tm_isdst; 101 KOPrefs::instance()->mDaylightSavings = now->tm_isdst;
101 } 102 }
102 103
103 setTimeZone(tzStr); 104 setTimeZone(tzStr);
104#endif 105#endif
105 106
106// KOPrefs::instance()->writeConfig(); 107// KOPrefs::instance()->writeConfig();
107} 108}
108 109
109Calendar::~Calendar() 110Calendar::~Calendar()
110{ 111{
111 delete mDefaultFilter; 112 delete mDefaultFilter;
112 if ( mUndoIncidence ) 113 if ( mUndoIncidence )
113 delete mUndoIncidence; 114 delete mUndoIncidence;
114} 115}
116void Calendar::setDontDeleteIncidencesOnClose ()
117{
118 mDeleteIncidencesOnClose = false;
119}
115void Calendar::setDefaultCalendar( int d ) 120void Calendar::setDefaultCalendar( int d )
116{ 121{
117 mDefaultCalendar = d; 122 mDefaultCalendar = d;
118} 123}
119int Calendar::defaultCalendar() 124int Calendar::defaultCalendar()
120{ 125{
121 return mDefaultCalendar; 126 return mDefaultCalendar;
122} 127}
123const QString &Calendar::getOwner() const 128const QString &Calendar::getOwner() const
124{ 129{
125 return mOwner; 130 return mOwner;
126} 131}
127 132
128bool Calendar::undoDeleteIncidence() 133bool Calendar::undoDeleteIncidence()
129{ 134{
130 if (!mUndoIncidence) 135 if (!mUndoIncidence)
131 return false; 136 return false;
132 addIncidence(mUndoIncidence); 137 addIncidence(mUndoIncidence);
133 mUndoIncidence = 0; 138 mUndoIncidence = 0;
134 return true; 139 return true;
135} 140}
136void Calendar::setOwner(const QString &os) 141void Calendar::setOwner(const QString &os)
137{ 142{
138 int i; 143 int i;
139 mOwner = os; 144 mOwner = os;
140 i = mOwner.find(','); 145 i = mOwner.find(',');
141 if (i != -1) 146 if (i != -1)
142 mOwner = mOwner.left(i); 147 mOwner = mOwner.left(i);
143 148
144 setModified( true ); 149 setModified( true );
145} 150}
146 151
147void Calendar::setTimeZone(const QString & tz) 152void Calendar::setTimeZone(const QString & tz)
148{ 153{
149 bool neg = FALSE; 154 bool neg = FALSE;
150 int hours, minutes; 155 int hours, minutes;
151 QString tmpStr(tz); 156 QString tmpStr(tz);
152 157
153 if (tmpStr.left(1) == "-") 158 if (tmpStr.left(1) == "-")
154 neg = TRUE; 159 neg = TRUE;
155 if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+") 160 if (tmpStr.left(1) == "-" || tmpStr.left(1) == "+")
156 tmpStr.remove(0, 1); 161 tmpStr.remove(0, 1);
157 hours = tmpStr.left(2).toInt(); 162 hours = tmpStr.left(2).toInt();
158 if (tmpStr.length() > 2) 163 if (tmpStr.length() > 2)
159 minutes = tmpStr.right(2).toInt(); 164 minutes = tmpStr.right(2).toInt();
160 else 165 else
161 minutes = 0; 166 minutes = 0;
162 mTimeZone = (60*hours+minutes); 167 mTimeZone = (60*hours+minutes);
163 if (neg) 168 if (neg)
164 mTimeZone = -mTimeZone; 169 mTimeZone = -mTimeZone;
165 mLocalTime = false; 170 mLocalTime = false;
166 171
167 setModified( true ); 172 setModified( true );
168} 173}
169 174
170QString Calendar::getTimeZoneStr() const 175QString Calendar::getTimeZoneStr() const
171{ 176{
172 if (mLocalTime) 177 if (mLocalTime)
173 return ""; 178 return "";
174 QString tmpStr; 179 QString tmpStr;
175 int hours = abs(mTimeZone / 60); 180 int hours = abs(mTimeZone / 60);
176 int minutes = abs(mTimeZone % 60); 181 int minutes = abs(mTimeZone % 60);
177 bool neg = mTimeZone < 0; 182 bool neg = mTimeZone < 0;
178 183
179 tmpStr.sprintf("%c%.2d%.2d", 184 tmpStr.sprintf("%c%.2d%.2d",
180 (neg ? '-' : '+'), 185 (neg ? '-' : '+'),
181 hours, minutes); 186 hours, minutes);
182 return tmpStr; 187 return tmpStr;
183} 188}
184 189
185void Calendar::setTimeZone(int tz) 190void Calendar::setTimeZone(int tz)
186{ 191{
187 mTimeZone = tz; 192 mTimeZone = tz;
188 mLocalTime = false; 193 mLocalTime = false;
189 194
190 setModified( true ); 195 setModified( true );
191} 196}
192 197
193int Calendar::getTimeZone() const 198int Calendar::getTimeZone() const
194{ 199{
195 return mTimeZone; 200 return mTimeZone;
196} 201}
197 202
198void Calendar::setTimeZoneId(const QString &id) 203void Calendar::setTimeZoneId(const QString &id)
199{ 204{
200 mTimeZoneId = id; 205 mTimeZoneId = id;
201 mLocalTime = false; 206 mLocalTime = false;
202 mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); 207 mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId);
203 if ( mTimeZone > 1000) 208 if ( mTimeZone > 1000)
204 setLocalTime(); 209 setLocalTime();
205 //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); 210 //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone);
206 setModified( true ); 211 setModified( true );
207} 212}
208 213
209QString Calendar::timeZoneId() const 214QString Calendar::timeZoneId() const
210{ 215{
211 return mTimeZoneId; 216 return mTimeZoneId;
212} 217}
213 218
214void Calendar::setLocalTime() 219void Calendar::setLocalTime()
215{ 220{
216 //qDebug("Calendar::setLocalTime() "); 221 //qDebug("Calendar::setLocalTime() ");
217 mLocalTime = true; 222 mLocalTime = true;
218 mTimeZone = 0; 223 mTimeZone = 0;
219 mTimeZoneId = ""; 224 mTimeZoneId = "";
220 225
221 setModified( true ); 226 setModified( true );
222} 227}
223 228
224bool Calendar::isLocalTime() const 229bool Calendar::isLocalTime() const
225{ 230{
226 return mLocalTime; 231 return mLocalTime;
227} 232}
228 233
229const QString &Calendar::getEmail() 234const QString &Calendar::getEmail()
230{ 235{
231 return mOwnerEmail; 236 return mOwnerEmail;
232} 237}
233 238
234void Calendar::setEmail(const QString &e) 239void Calendar::setEmail(const QString &e)
235{ 240{
236 mOwnerEmail = e; 241 mOwnerEmail = e;
237 242
238 setModified( true ); 243 setModified( true );
239} 244}
240 245
241void Calendar::setFilter(CalFilter *filter) 246void Calendar::setFilter(CalFilter *filter)
242{ 247{
243 mFilter = filter; 248 mFilter = filter;
244} 249}
245 250
246CalFilter *Calendar::filter() 251CalFilter *Calendar::filter()
247{ 252{
248 return mFilter; 253 return mFilter;
249} 254}
250 255
251QPtrList<Incidence> Calendar::incidences() 256QPtrList<Incidence> Calendar::incidences()
252{ 257{
253 QPtrList<Incidence> incidences; 258 QPtrList<Incidence> incidences;
254 259
255 Incidence *i; 260 Incidence *i;
256 261
257 QPtrList<Event> e = events(); 262 QPtrList<Event> e = events();
258 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 263 for( i = e.first(); i; i = e.next() ) incidences.append( i );
259 264
260 QPtrList<Todo> t = todos(); 265 QPtrList<Todo> t = todos();
261 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 266 for( i = t.first(); i; i = t.next() ) incidences.append( i );
262 267
263 QPtrList<Journal> j = journals(); 268 QPtrList<Journal> j = journals();
264 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 269 for( i = j.first(); i; i = j.next() ) incidences.append( i );
265 270
266 return incidences; 271 return incidences;
267} 272}
268 273
269void Calendar::resetPilotStat(int id ) 274void Calendar::resetPilotStat(int id )
270{ 275{
271 QPtrList<Incidence> incidences; 276 QPtrList<Incidence> incidences;
272 277
273 Incidence *i; 278 Incidence *i;
274 279
275 QPtrList<Event> e = rawEvents(); 280 QPtrList<Event> e = rawEvents();
276 for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); 281 for( i = e.first(); i; i = e.next() ) i->setPilotId( id );
277 282
278 QPtrList<Todo> t = rawTodos(); 283 QPtrList<Todo> t = rawTodos();
279 for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); 284 for( i = t.first(); i; i = t.next() ) i->setPilotId( id );
280 285
281 QPtrList<Journal> j = journals(); 286 QPtrList<Journal> j = journals();
282 for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); 287 for( i = j.first(); i; i = j.next() ) i->setPilotId( id );
283} 288}
284void Calendar::resetTempSyncStat() 289void Calendar::resetTempSyncStat()
285{ 290{
286 QPtrList<Incidence> incidences; 291 QPtrList<Incidence> incidences;
287 292
288 Incidence *i; 293 Incidence *i;
289 294
290 QPtrList<Event> e = rawEvents(); 295 QPtrList<Event> e = rawEvents();
291 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 296 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
292 297
293 QPtrList<Todo> t = rawTodos(); 298 QPtrList<Todo> t = rawTodos();
294 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 299 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
295 300
296 QPtrList<Journal> j = journals(); 301 QPtrList<Journal> j = journals();
297 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 302 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
298} 303}
299QPtrList<Incidence> Calendar::rawIncidences() 304QPtrList<Incidence> Calendar::rawIncidences()
300{ 305{
301 QPtrList<Incidence> incidences; 306 QPtrList<Incidence> incidences;
302 307
303 Incidence *i; 308 Incidence *i;
304 309
305 QPtrList<Event> e = rawEvents(); 310 QPtrList<Event> e = rawEvents();
306 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 311 for( i = e.first(); i; i = e.next() ) incidences.append( i );
307 312
308 QPtrList<Todo> t = rawTodos(); 313 QPtrList<Todo> t = rawTodos();
309 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 314 for( i = t.first(); i; i = t.next() ) incidences.append( i );
310 315
311 QPtrList<Journal> j = journals(); 316 QPtrList<Journal> j = journals();
312 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 317 for( i = j.first(); i; i = j.next() ) incidences.append( i );
313 318
314 return incidences; 319 return incidences;
315} 320}
316 321
317QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 322QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
318{ 323{
319 QPtrList<Event> el = rawEventsForDate(date,sorted); 324 QPtrList<Event> el = rawEventsForDate(date,sorted);
320 mFilter->apply(&el); 325 mFilter->apply(&el);
321 return el; 326 return el;
322} 327}
323 328
324QPtrList<Event> Calendar::events( const QDateTime &qdt ) 329QPtrList<Event> Calendar::events( const QDateTime &qdt )
325{ 330{
326 QPtrList<Event> el = rawEventsForDate(qdt); 331 QPtrList<Event> el = rawEventsForDate(qdt);
327 mFilter->apply(&el); 332 mFilter->apply(&el);
328 return el; 333 return el;
329} 334}
330 335
331QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 336QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
332 bool inclusive) 337 bool inclusive)
333{ 338{
334 QPtrList<Event> el = rawEvents(start,end,inclusive); 339 QPtrList<Event> el = rawEvents(start,end,inclusive);
335 mFilter->apply(&el); 340 mFilter->apply(&el);
336 return el; 341 return el;
337} 342}
338 343
339QPtrList<Event> Calendar::events() 344QPtrList<Event> Calendar::events()
340{ 345{
341 QPtrList<Event> el = rawEvents(); 346 QPtrList<Event> el = rawEvents();
342 mFilter->apply(&el); 347 mFilter->apply(&el);
343 return el; 348 return el;
344} 349}
345void Calendar::addIncidenceBranch(Incidence *i) 350void Calendar::addIncidenceBranch(Incidence *i)
346{ 351{
347 addIncidence( i ); 352 addIncidence( i );
348 Incidence * inc; 353 Incidence * inc;
349 QPtrList<Incidence> Relations = i->relations(); 354 QPtrList<Incidence> Relations = i->relations();
350 for (inc=Relations.first();inc;inc=Relations.next()) { 355 for (inc=Relations.first();inc;inc=Relations.next()) {
351 addIncidenceBranch( inc ); 356 addIncidenceBranch( inc );
352 } 357 }
353} 358}
354 359
355bool Calendar::addIncidence(Incidence *i) 360bool Calendar::addIncidence(Incidence *i)
356{ 361{
357 Incidence::AddVisitor<Calendar> v(this); 362 Incidence::AddVisitor<Calendar> v(this);
358 i->setCalID( mDefaultCalendar ); 363 i->setCalID( mDefaultCalendar );
359 i->setCalEnabled( true ); 364 i->setCalEnabled( true );
360 return i->accept(v); 365 return i->accept(v);
361} 366}
362void Calendar::deleteIncidence(Incidence *in) 367void Calendar::deleteIncidence(Incidence *in)
363{ 368{
364 if ( in->typeID() == eventID ) 369 if ( in->typeID() == eventID )
365 deleteEvent( (Event*) in ); 370 deleteEvent( (Event*) in );
366 else if ( in->typeID() == todoID ) 371 else if ( in->typeID() == todoID )
367 deleteTodo( (Todo*) in); 372 deleteTodo( (Todo*) in);
368 else if ( in->typeID() == journalID ) 373 else if ( in->typeID() == journalID )
369 deleteJournal( (Journal*) in ); 374 deleteJournal( (Journal*) in );
370} 375}
371 376
372Incidence* Calendar::incidence( const QString& uid ) 377Incidence* Calendar::incidence( const QString& uid )
373{ 378{
374 Incidence* i; 379 Incidence* i;
375 380
376 if( (i = todo( uid )) != 0 ) 381 if( (i = todo( uid )) != 0 )
377 return i; 382 return i;
378 if( (i = event( uid )) != 0 ) 383 if( (i = event( uid )) != 0 )
379 return i; 384 return i;
380 if( (i = journal( uid )) != 0 ) 385 if( (i = journal( uid )) != 0 )
381 return i; 386 return i;
382 387
383 return 0; 388 return 0;
384} 389}
385 390
386QPtrList<Todo> Calendar::todos() 391QPtrList<Todo> Calendar::todos()
387{ 392{
388 QPtrList<Todo> tl = rawTodos(); 393 QPtrList<Todo> tl = rawTodos();
389 mFilter->apply( &tl ); 394 mFilter->apply( &tl );
390 return tl; 395 return tl;
391} 396}
392 397
393// When this is called, the todo have already been added to the calendar. 398// When this is called, the todo have already been added to the calendar.
394// This method is only about linking related todos 399// This method is only about linking related todos
395void Calendar::setupRelations( Incidence *incidence ) 400void Calendar::setupRelations( Incidence *incidence )
396{ 401{
397 QString uid = incidence->uid(); 402 QString uid = incidence->uid();
398 //qDebug("Calendar::setupRelations "); 403 //qDebug("Calendar::setupRelations ");
399 // First, go over the list of orphans and see if this is their parent 404 // First, go over the list of orphans and see if this is their parent
400 while( Incidence* i = mOrphans[ uid ] ) { 405 while( Incidence* i = mOrphans[ uid ] ) {
401 mOrphans.remove( uid ); 406 mOrphans.remove( uid );
402 i->setRelatedTo( incidence ); 407 i->setRelatedTo( incidence );
403 incidence->addRelation( i ); 408 incidence->addRelation( i );
404 mOrphanUids.remove( i->uid() ); 409 mOrphanUids.remove( i->uid() );
405 } 410 }
406 411
407 // Now see about this incidences parent 412 // Now see about this incidences parent
408 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) { 413 if( !incidence->relatedTo() && !incidence->relatedToUid().isEmpty() ) {
409 // This incidence has a uid it is related to, but is not registered to it yet 414 // This incidence has a uid it is related to, but is not registered to it yet
410 // Try to find it 415 // Try to find it
411 Incidence* parent = this->incidence( incidence->relatedToUid() ); 416 Incidence* parent = this->incidence( incidence->relatedToUid() );
412 if( parent ) { 417 if( parent ) {
413 // Found it 418 // Found it
414 incidence->setRelatedTo( parent ); 419 incidence->setRelatedTo( parent );
415 parent->addRelation( incidence ); 420 parent->addRelation( incidence );
416 } else { 421 } else {
417 // Not found, put this in the mOrphans list 422 // Not found, put this in the mOrphans list
418 mOrphans.insert( incidence->relatedToUid(), incidence ); 423 mOrphans.insert( incidence->relatedToUid(), incidence );
419 mOrphanUids.insert( incidence->uid(), incidence ); 424 mOrphanUids.insert( incidence->uid(), incidence );
420 } 425 }
421 } 426 }
422} 427}
423 428
424// If a task with subtasks is deleted, move it's subtasks to the orphans list 429// If a task with subtasks is deleted, move it's subtasks to the orphans list
425void Calendar::removeRelations( Incidence *incidence ) 430void Calendar::removeRelations( Incidence *incidence )
426{ 431{
427 // qDebug("Calendar::removeRelations "); 432 // qDebug("Calendar::removeRelations ");
428 QString uid = incidence->uid(); 433 QString uid = incidence->uid();
429 434
430 QPtrList<Incidence> relations = incidence->relations(); 435 QPtrList<Incidence> relations = incidence->relations();
431 for( Incidence* i = relations.first(); i; i = relations.next() ) 436 for( Incidence* i = relations.first(); i; i = relations.next() )
432 if( !mOrphanUids.find( i->uid() ) ) { 437 if( !mOrphanUids.find( i->uid() ) ) {
433 mOrphans.insert( uid, i ); 438 mOrphans.insert( uid, i );
434 mOrphanUids.insert( i->uid(), i ); 439 mOrphanUids.insert( i->uid(), i );
435 i->setRelatedTo( 0 ); 440 i->setRelatedTo( 0 );
436 i->setRelatedToUid( uid ); 441 i->setRelatedToUid( uid );
437 } 442 }
438 443
439 // If this incidence is related to something else, tell that about it 444 // If this incidence is related to something else, tell that about it
440 if( incidence->relatedTo() ) 445 if( incidence->relatedTo() )
441 incidence->relatedTo()->removeRelation( incidence ); 446 incidence->relatedTo()->removeRelation( incidence );
442 447
443 // Remove this one from the orphans list 448 // Remove this one from the orphans list
444 if( mOrphanUids.remove( uid ) ) 449 if( mOrphanUids.remove( uid ) )
445 // This incidence is located in the orphans list - it should be removed 450 // This incidence is located in the orphans list - it should be removed
446 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 451 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
447 // Removing wasn't that easy 452 // Removing wasn't that easy
448 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 453 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
449 if( it.current()->uid() == uid ) { 454 if( it.current()->uid() == uid ) {
450 mOrphans.remove( it.currentKey() ); 455 mOrphans.remove( it.currentKey() );
451 break; 456 break;
452 } 457 }
453 } 458 }
454 } 459 }
455} 460}
456 461
457void Calendar::registerObserver( Observer *observer ) 462void Calendar::registerObserver( Observer *observer )
458{ 463{
459 mObserver = observer; 464 mObserver = observer;
460 mNewObserver = true; 465 mNewObserver = true;
461} 466}
462 467
463void Calendar::setModified( bool modified ) 468void Calendar::setModified( bool modified )
464{ 469{
465 if ( mObserver ) mObserver->calendarModified( modified, this ); 470 if ( mObserver ) mObserver->calendarModified( modified, this );
466 if ( modified != mModified || mNewObserver ) { 471 if ( modified != mModified || mNewObserver ) {
467 mNewObserver = false; 472 mNewObserver = false;
468 // if ( mObserver ) mObserver->calendarModified( modified, this ); 473 // if ( mObserver ) mObserver->calendarModified( modified, this );
469 mModified = modified; 474 mModified = modified;
470 } 475 }
471} 476}
472 477
473void Calendar::setLoadedProductId( const QString &id ) 478void Calendar::setLoadedProductId( const QString &id )
474{ 479{
475 mLoadedProductId = id; 480 mLoadedProductId = id;
476} 481}
477 482
478QString Calendar::loadedProductId() 483QString Calendar::loadedProductId()
479{ 484{
480 return mLoadedProductId; 485 return mLoadedProductId;
481} 486}
482 487
483//#include "calendar.moc" 488//#include "calendar.moc"
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4c6760f..73f82bb 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -1,366 +1,373 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library 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 GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef CALENDAR_H 22#ifndef CALENDAR_H
23#define CALENDAR_H 23#define CALENDAR_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "event.h" 32#include "event.h"
33#include "todo.h" 33#include "todo.h"
34#include "journal.h" 34#include "journal.h"
35#include "calfilter.h" 35#include "calfilter.h"
36 36
37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ 37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
38 38
39class KConfig; 39class KConfig;
40 40
41namespace KCal { 41namespace KCal {
42 42
43 43
44/** 44/**
45 This is the main "calendar" object class for KOrganizer. It holds 45 This is the main "calendar" object class for KOrganizer. It holds
46 information like all appointments/events, user information, etc. etc. 46 information like all appointments/events, user information, etc. etc.
47 one calendar is associated with each CalendarView (@see calendarview.h). 47 one calendar is associated with each CalendarView (@see calendarview.h).
48 This is an abstract base class defining the interface to a calendar. It is 48 This is an abstract base class defining the interface to a calendar. It is
49 implemented by subclasses like @see CalendarLocal, which use different 49 implemented by subclasses like @see CalendarLocal, which use different
50 methods to store and access the data. 50 methods to store and access the data.
51 51
52 Ownership of events etc. is handled by the following policy: As soon as an 52 Ownership of events etc. is handled by the following policy: As soon as an
53 event (or any other subclass of IncidenceBase) object is added to the 53 event (or any other subclass of IncidenceBase) object is added to the
54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes 54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
55 care of deleting it. All Events returned by the query functions are returned 55 care of deleting it. All Events returned by the query functions are returned
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 Incidence * undoIncidence() { return mUndoIncidence; }; 68 Incidence * undoIncidence() { return mUndoIncidence; };
69 bool undoDeleteIncidence(); 69 bool undoDeleteIncidence();
70 void deleteIncidence(Incidence *in); 70 void deleteIncidence(Incidence *in);
71 void resetTempSyncStat(); 71 void resetTempSyncStat();
72 void resetPilotStat(int id); 72 void resetPilotStat(int id);
73 /** 73 /**
74 Clears out the current calendar, freeing all used memory etc. 74 Clears out the current calendar, freeing all used memory etc.
75 */ 75 */
76 virtual void close() = 0; 76 virtual void close() = 0;
77 virtual void addCalendar( Calendar* ) = 0;
78 virtual bool addCalendarFile( QString name, int id ) = 0;
77 79
78 /** 80 /**
79 Sync changes in memory to persistant storage. 81 Sync changes in memory to persistant storage.
80 */ 82 */
81 virtual void save() = 0; 83 virtual void save() = 0;
82 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 84 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
83 virtual void removeSyncInfo( QString syncProfile) = 0; 85 virtual void removeSyncInfo( QString syncProfile) = 0;
84 virtual bool isSaving() { return false; } 86 virtual bool isSaving() { return false; }
85 87
86 /** 88 /**
87 Return the owner of the calendar's full name. 89 Return the owner of the calendar's full name.
88 */ 90 */
89 const QString &getOwner() const; 91 const QString &getOwner() const;
90 /** 92 /**
91 Set the owner of the calendar. Should be owner's full name. 93 Set the owner of the calendar. Should be owner's full name.
92 */ 94 */
93 void setOwner( const QString &os ); 95 void setOwner( const QString &os );
94 /** 96 /**
95 Return the email address of the calendar owner. 97 Return the email address of the calendar owner.
96 */ 98 */
97 const QString &getEmail(); 99 const QString &getEmail();
98 /** 100 /**
99 Set the email address of the calendar owner. 101 Set the email address of the calendar owner.
100 */ 102 */
101 void setEmail( const QString & ); 103 void setEmail( const QString & );
102 104
103 /** 105 /**
104 Set time zone from a timezone string (e.g. -2:00) 106 Set time zone from a timezone string (e.g. -2:00)
105 */ 107 */
106 void setTimeZone( const QString &tz ); 108 void setTimeZone( const QString &tz );
107 /** 109 /**
108 Set time zone from a minutes value (e.g. -60) 110 Set time zone from a minutes value (e.g. -60)
109 */ 111 */
110 void setTimeZone( int tz ); 112 void setTimeZone( int tz );
111 /** 113 /**
112 Return time zone as offest in minutes. 114 Return time zone as offest in minutes.
113 */ 115 */
114 int getTimeZone() const; 116 int getTimeZone() const;
115 /** 117 /**
116 Compute an ISO 8601 format string from the time zone. 118 Compute an ISO 8601 format string from the time zone.
117 */ 119 */
118 QString getTimeZoneStr() const; 120 QString getTimeZoneStr() const;
119 /** 121 /**
120 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 122 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
121 values). 123 values).
122 */ 124 */
123 void setTimeZoneId( const QString & ); 125 void setTimeZoneId( const QString & );
124 /** 126 /**
125 Return time zone id. 127 Return time zone id.
126 */ 128 */
127 QString timeZoneId() const; 129 QString timeZoneId() const;
128 /** 130 /**
129 Use local time, not UTC or a time zone. 131 Use local time, not UTC or a time zone.
130 */ 132 */
131 void setLocalTime(); 133 void setLocalTime();
132 /** 134 /**
133 Return whether local time is being used. 135 Return whether local time is being used.
134 */ 136 */
135 bool isLocalTime() const; 137 bool isLocalTime() const;
136 138
137 /** 139 /**
138 Add an incidence to calendar. 140 Add an incidence to calendar.
139 141
140 @return true on success, false on error. 142 @return true on success, false on error.
141 */ 143 */
142 virtual bool addIncidence( Incidence * ); 144 virtual bool addIncidence( Incidence * );
143 145
144 // Adds an incidence and all relatedto incidences to the cal 146 // Adds an incidence and all relatedto incidences to the cal
145 void addIncidenceBranch( Incidence * ); 147 void addIncidenceBranch( Incidence * );
146 /** 148 /**
147 Return filtered list of all incidences of this calendar. 149 Return filtered list of all incidences of this calendar.
148 */ 150 */
149 virtual QPtrList<Incidence> incidences(); 151 virtual QPtrList<Incidence> incidences();
150 152
151 /** 153 /**
152 Return unfiltered list of all incidences of this calendar. 154 Return unfiltered list of all incidences of this calendar.
153 */ 155 */
154 virtual QPtrList<Incidence> rawIncidences(); 156 virtual QPtrList<Incidence> rawIncidences();
155 157
156 /** 158 /**
157 Adds a Event to this calendar object. 159 Adds a Event to this calendar object.
158 @param anEvent a pointer to the event to add 160 @param anEvent a pointer to the event to add
159 161
160 @return true on success, false on error. 162 @return true on success, false on error.
161 */ 163 */
162 virtual bool addEventNoDup( Event *event ) = 0; 164 virtual bool addEventNoDup( Event *event ) = 0;
163 virtual bool addAnniversaryNoDup( Event *event ) = 0; 165 virtual bool addAnniversaryNoDup( Event *event ) = 0;
164 virtual bool addEvent( Event *anEvent ) = 0; 166 virtual bool addEvent( Event *anEvent ) = 0;
165 /** 167 /**
166 Delete event from calendar. 168 Delete event from calendar.
167 */ 169 */
168 virtual void deleteEvent( Event * ) = 0; 170 virtual void deleteEvent( Event * ) = 0;
169 /** 171 /**
170 Retrieves an event on the basis of the unique string ID. 172 Retrieves an event on the basis of the unique string ID.
171 */ 173 */
172 virtual Event *event( const QString &UniqueStr ) = 0; 174 virtual Event *event( const QString &UniqueStr ) = 0;
173 virtual Event *event( QString, QString ) = 0; 175 virtual Event *event( QString, QString ) = 0;
174 /** 176 /**
175 Builds and then returns a list of all events that match for the 177 Builds and then returns a list of all events that match for the
176 date specified. useful for dayView, etc. etc. 178 date specified. useful for dayView, etc. etc.
177 The calendar filter is applied. 179 The calendar filter is applied.
178 */ 180 */
179 QPtrList<Event> events( const QDate &date, bool sorted = false); 181 QPtrList<Event> events( const QDate &date, bool sorted = false);
180 /** 182 /**
181 Get events, which occur on the given date. 183 Get events, which occur on the given date.
182 The calendar filter is applied. 184 The calendar filter is applied.
183 */ 185 */
184 QPtrList<Event> events( const QDateTime &qdt ); 186 QPtrList<Event> events( const QDateTime &qdt );
185 /** 187 /**
186 Get events in a range of dates. If inclusive is set to true, only events 188 Get events in a range of dates. If inclusive is set to true, only events
187 are returned, which are completely included in the range. 189 are returned, which are completely included in the range.
188 The calendar filter is applied. 190 The calendar filter is applied.
189 */ 191 */
190 QPtrList<Event> events( const QDate &start, const QDate &end, 192 QPtrList<Event> events( const QDate &start, const QDate &end,
191 bool inclusive = false); 193 bool inclusive = false);
192 /** 194 /**
193 Return filtered list of all events in calendar. 195 Return filtered list of all events in calendar.
194 */ 196 */
195 virtual QPtrList<Event> events(); 197 virtual QPtrList<Event> events();
196 /** 198 /**
197 Return unfiltered list of all events in calendar. 199 Return unfiltered list of all events in calendar.
198 */ 200 */
199 virtual QPtrList<Event> rawEvents() = 0; 201 virtual QPtrList<Event> rawEvents() = 0;
200 202
201 /** 203 /**
202 Add a todo to the todolist. 204 Add a todo to the todolist.
203 205
204 @return true on success, false on error. 206 @return true on success, false on error.
205 */ 207 */
206 virtual bool addTodo( Todo *todo ) = 0; 208 virtual bool addTodo( Todo *todo ) = 0;
207 virtual bool addTodoNoDup( Todo *todo ) = 0; 209 virtual bool addTodoNoDup( Todo *todo ) = 0;
208 /** 210 /**
209 Remove a todo from the todolist. 211 Remove a todo from the todolist.
210 */ 212 */
211 virtual void deleteTodo( Todo * ) = 0; 213 virtual void deleteTodo( Todo * ) = 0;
212 virtual void deleteJournal( Journal * ) = 0; 214 virtual void deleteJournal( Journal * ) = 0;
213 /** 215 /**
214 Return filterd list of todos. 216 Return filterd list of todos.
215 */ 217 */
216 virtual QPtrList<Todo> todos(); 218 virtual QPtrList<Todo> todos();
217 /** 219 /**
218 Searches todolist for an event with this unique string identifier, 220 Searches todolist for an event with this unique string identifier,
219 returns a pointer or null. 221 returns a pointer or null.
220 */ 222 */
221 virtual Todo *todo( const QString &uid ) = 0; 223 virtual Todo *todo( const QString &uid ) = 0;
222 virtual Todo *todo( QString, QString ) = 0; 224 virtual Todo *todo( QString, QString ) = 0;
223 /** 225 /**
224 Returns list of todos due on the specified date. 226 Returns list of todos due on the specified date.
225 */ 227 */
226 virtual QPtrList<Todo> todos( const QDate &date ) = 0; 228 virtual QPtrList<Todo> todos( const QDate &date ) = 0;
227 /** 229 /**
228 Return unfiltered list of todos. 230 Return unfiltered list of todos.
229 */ 231 */
230 virtual QPtrList<Todo> rawTodos() = 0; 232 virtual QPtrList<Todo> rawTodos() = 0;
231 233
232 /** 234 /**
233 Add a Journal entry to calendar. 235 Add a Journal entry to calendar.
234 236
235 @return true on success, false on error. 237 @return true on success, false on error.
236 */ 238 */
237 virtual bool addJournal( Journal * ) = 0; 239 virtual bool addJournal( Journal * ) = 0;
238 /** 240 /**
239 Return Journal for given date. 241 Return Journal for given date.
240 */ 242 */
241 virtual Journal *journal( const QDate & ) = 0; 243 virtual Journal *journal( const QDate & ) = 0;
242 /** 244 /**
243 Return Journal with given UID. 245 Return Journal with given UID.
244 */ 246 */
245 virtual Journal *journal( const QString &UID ) = 0; 247 virtual Journal *journal( const QString &UID ) = 0;
246 /** 248 /**
247 Return list of all Journal entries. 249 Return list of all Journal entries.
248 */ 250 */
249 virtual QPtrList<Journal> journals() = 0; 251 virtual QPtrList<Journal> journals() = 0;
250 252
251 /** 253 /**
252 Searches all incidence types for an incidence with this unique 254 Searches all incidence types for an incidence with this unique
253 string identifier, returns a pointer or null. 255 string identifier, returns a pointer or null.
254 */ 256 */
255 Incidence* incidence( const QString&UID ); 257 Incidence* incidence( const QString&UID );
256 258
257 /** 259 /**
258 Setup relations for an incidence. 260 Setup relations for an incidence.
259 */ 261 */
260 virtual void setupRelations( Incidence * ); 262 virtual void setupRelations( Incidence * );
261 /** 263 /**
262 Remove all relations to an incidence 264 Remove all relations to an incidence
263 */ 265 */
264 virtual void removeRelations( Incidence * ); 266 virtual void removeRelations( Incidence * );
265 267
266 /** 268 /**
267 Set calendar filter, which filters events for the events() functions. 269 Set calendar filter, which filters events for the events() functions.
268 The Filter object is owned by the caller. 270 The Filter object is owned by the caller.
269 */ 271 */
270 void setFilter( CalFilter * ); 272 void setFilter( CalFilter * );
271 /** 273 /**
272 Return calendar filter. 274 Return calendar filter.
273 */ 275 */
274 CalFilter *filter(); 276 CalFilter *filter();
275 virtual QDateTime nextAlarm( int daysTo ) = 0; 277 virtual QDateTime nextAlarm( int daysTo ) = 0;
276 virtual QString nextSummary( ) const = 0; 278 virtual QString nextSummary( ) const = 0;
277 virtual void reInitAlarmSettings() = 0; 279 virtual void reInitAlarmSettings() = 0;
278 virtual QDateTime nextAlarmEventDateTime() const = 0; 280 virtual QDateTime nextAlarmEventDateTime() const = 0;
279 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0; 281 virtual void checkAlarmForIncidence( Incidence *, bool ) = 0;
280 /** 282 /**
281 Return all alarms, which ocur in the given time interval. 283 Return all alarms, which ocur in the given time interval.
282 */ 284 */
283 virtual Alarm::List alarms( const QDateTime &from, 285 virtual Alarm::List alarms( const QDateTime &from,
284 const QDateTime &to ) = 0; 286 const QDateTime &to ) = 0;
285 287
286 class Observer { 288 class Observer {
287 public: 289 public:
288 virtual void calendarModified( bool, Calendar * ) = 0; 290 virtual void calendarModified( bool, Calendar * ) = 0;
289 }; 291 };
290 292
291 void registerObserver( Observer * ); 293 void registerObserver( Observer * );
292 294
293 void setModified( bool ); 295 void setModified( bool );
294 296
295 /** 297 /**
296 Set product id returned by loadedProductId(). This function is only 298 Set product id returned by loadedProductId(). This function is only
297 useful for the calendar loading code. 299 useful for the calendar loading code.
298 */ 300 */
299 void setLoadedProductId( const QString & ); 301 void setLoadedProductId( const QString & );
300 /** 302 /**
301 Return product id taken from file that has been loaded. Returns 303 Return product id taken from file that has been loaded. Returns
302 QString::null, if no calendar has been loaded. 304 QString::null, if no calendar has been loaded.
303 */ 305 */
304 QString loadedProductId(); 306 QString loadedProductId();
305 void setDefaultCalendar( int );
306 int defaultCalendar(); 307 int defaultCalendar();
308 void setDontDeleteIncidencesOnClose ();
309 public slots:
310 void setDefaultCalendar( int );
307 virtual void setCalendarEnabled( int id, bool enable ) = 0; 311 virtual void setCalendarEnabled( int id, bool enable ) = 0;
308 virtual void setAlarmEnabled( int id, bool enable ) = 0; 312 virtual void setAlarmEnabled( int id, bool enable ) = 0;
313 virtual void setReadOnly( int id, bool enable ) = 0;
309 virtual void setDefaultCalendarEnabledOnly() = 0; 314 virtual void setDefaultCalendarEnabledOnly() = 0;
310 signals: 315 signals:
311 void calendarChanged(); 316 void calendarChanged();
312 void calendarSaved(); 317 void calendarSaved();
313 void calendarLoaded(); 318 void calendarLoaded();
314 void addAlarm(const QDateTime &qdt, const QString &noti ); 319 void addAlarm(const QDateTime &qdt, const QString &noti );
315 void removeAlarm(const QDateTime &qdt, const QString &noti ); 320 void removeAlarm(const QDateTime &qdt, const QString &noti );
316 321
317 protected: 322 protected:
318 /** 323 /**
319 Get unfiltered events, which occur on the given date. 324 Get unfiltered events, which occur on the given date.
320 */ 325 */
321 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; 326 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
322 /** 327 /**
323 Get unfiltered events, which occur on the given date. 328 Get unfiltered events, which occur on the given date.
324 */ 329 */
325 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 330 virtual QPtrList<Event> rawEventsForDate( const QDate &date,
326 bool sorted = false ) = 0; 331 bool sorted = false ) = 0;
327 /** 332 /**
328 Get events in a range of dates. If inclusive is set to true, only events 333 Get events in a range of dates. If inclusive is set to true, only events
329 are returned, which are completely included in the range. 334 are returned, which are completely included in the range.
330 */ 335 */
331 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 336 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
332 bool inclusive = false ) = 0; 337 bool inclusive = false ) = 0;
333 338
334 Incidence *mNextAlarmIncidence; 339 Incidence *mNextAlarmIncidence;
335 Incidence *mUndoIncidence; 340 Incidence *mUndoIncidence;
336 int mDefaultCalendar; 341 int mDefaultCalendar;
342 bool mDeleteIncidencesOnClose;
337 343
338private: 344private:
339 void init(); 345 void init();
340 346
341 QString mOwner; // who the calendar belongs to 347 QString mOwner; // who the calendar belongs to
342 QString mOwnerEmail; // email address of the owner 348 QString mOwnerEmail; // email address of the owner
343 int mTimeZone; // timezone OFFSET from GMT (MINUTES) 349 int mTimeZone; // timezone OFFSET from GMT (MINUTES)
344 bool mLocalTime; // use local time, not UTC or a time zone 350 bool mLocalTime; // use local time, not UTC or a time zone
345 351
352
346 CalFilter *mFilter; 353 CalFilter *mFilter;
347 CalFilter *mDefaultFilter; 354 CalFilter *mDefaultFilter;
348 355
349 356
350 QString mTimeZoneId; 357 QString mTimeZoneId;
351 358
352 Observer *mObserver; 359 Observer *mObserver;
353 bool mNewObserver; 360 bool mNewObserver;
354 361
355 bool mModified; 362 bool mModified;
356 363
357 QString mLoadedProductId; 364 QString mLoadedProductId;
358 365
359 // This list is used to put together related todos 366 // This list is used to put together related todos
360 QDict<Incidence> mOrphans; 367 QDict<Incidence> mOrphans;
361 QDict<Incidence> mOrphanUids; 368 QDict<Incidence> mOrphanUids;
362}; 369};
363 370
364} 371}
365 372
366#endif 373#endif
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index c5500bf..e48122a 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -1,782 +1,834 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#include <klocale.h> 30#include <klocale.h>
31 31
32#include "vcaldrag.h" 32#include "vcaldrag.h"
33#include "vcalformat.h" 33#include "vcalformat.h"
34#include "icalformat.h" 34#include "icalformat.h"
35#include "exceptions.h" 35#include "exceptions.h"
36#include "incidence.h" 36#include "incidence.h"
37#include "journal.h" 37#include "journal.h"
38#include "filestorage.h" 38#include "filestorage.h"
39#include "calfilter.h" 39#include "calfilter.h"
40 40
41#include "calendarlocal.h" 41#include "calendarlocal.h"
42 42
43// #ifndef DESKTOP_VERSION 43// #ifndef DESKTOP_VERSION
44// #include <qtopia/alarmserver.h> 44// #include <qtopia/alarmserver.h>
45// #endif 45// #endif
46using namespace KCal; 46using namespace KCal;
47 47
48CalendarLocal::CalendarLocal() 48CalendarLocal::CalendarLocal()
49 : Calendar() 49 : Calendar()
50{ 50{
51 init(); 51 init();
52} 52}
53 53
54CalendarLocal::CalendarLocal(const QString &timeZoneId) 54CalendarLocal::CalendarLocal(const QString &timeZoneId)
55 : Calendar(timeZoneId) 55 : Calendar(timeZoneId)
56{ 56{
57 init(); 57 init();
58} 58}
59 59
60void CalendarLocal::init() 60void CalendarLocal::init()
61{ 61{
62 mNextAlarmIncidence = 0; 62 mNextAlarmIncidence = 0;
63} 63}
64 64
65 65
66CalendarLocal::~CalendarLocal() 66CalendarLocal::~CalendarLocal()
67{ 67{
68 close(); 68 if ( mDeleteIncidencesOnClose )
69 close();
70}
71bool CalendarLocal::addCalendarFile( QString name, int id )
72{
73 CalendarLocal calendar( timeZoneId() );
74 calendar.setDefaultCalendar( id );
75 if ( calendar.load( name ) ) {
76 addCalendar( &calendar );
77 return true;
78 }
79 return false;
80}
81void CalendarLocal::addCalendar( Calendar* cal )
82{
83 cal->setDontDeleteIncidencesOnClose();
84 {
85 QPtrList<Event> EventList = cal->rawEvents();
86 Event * ev = EventList.first();
87 while ( ev ) {
88 mEventList.append( ev );
89 ev = EventList.next();
90 }
91 }
92 {
93 QPtrList<Todo> TodoList = cal->rawTodos();
94 Todo * ev = TodoList.first();
95 while ( ev ) {
96 mTodoList.append( ev );
97 ev = TodoList.next();
98 }
99 }
100 {
101 QPtrList<Journal> JournalList = cal->journals();
102 Journal * ev = JournalList.first();
103 while ( ev ) {
104 mJournalList.append( ev );
105 ev = JournalList.next();
106 }
107 }
69} 108}
70
71bool CalendarLocal::load( const QString &fileName ) 109bool CalendarLocal::load( const QString &fileName )
72{ 110{
73 FileStorage storage( this, fileName ); 111 FileStorage storage( this, fileName );
74 return storage.load(); 112 return storage.load();
75} 113}
76 114
77bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 115bool CalendarLocal::save( const QString &fileName, CalFormat *format )
78{ 116{
79 FileStorage storage( this, fileName, format ); 117 FileStorage storage( this, fileName, format );
80 return storage.save(); 118 return storage.save();
81} 119}
82 120
83void CalendarLocal::close() 121void CalendarLocal::close()
84{ 122{
85 123
86 Todo * i; 124 Todo * i;
87 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); 125 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
88 126
89 mEventList.setAutoDelete( true ); 127 mEventList.setAutoDelete( true );
90 mTodoList.setAutoDelete( true ); 128 mTodoList.setAutoDelete( true );
91 mJournalList.setAutoDelete( false ); 129 mJournalList.setAutoDelete( false );
92 130
93 mEventList.clear(); 131 mEventList.clear();
94 mTodoList.clear(); 132 mTodoList.clear();
95 mJournalList.clear(); 133 mJournalList.clear();
96 134
97 mEventList.setAutoDelete( false ); 135 mEventList.setAutoDelete( false );
98 mTodoList.setAutoDelete( false ); 136 mTodoList.setAutoDelete( false );
99 mJournalList.setAutoDelete( false ); 137 mJournalList.setAutoDelete( false );
100 138
101 setModified( false ); 139 setModified( false );
102} 140}
103 141
104bool CalendarLocal::addAnniversaryNoDup( Event *event ) 142bool CalendarLocal::addAnniversaryNoDup( Event *event )
105{ 143{
106 QString cat; 144 QString cat;
107 bool isBirthday = true; 145 bool isBirthday = true;
108 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 146 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
109 isBirthday = false; 147 isBirthday = false;
110 cat = i18n( "Anniversary" ); 148 cat = i18n( "Anniversary" );
111 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 149 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
112 isBirthday = true; 150 isBirthday = true;
113 cat = i18n( "Birthday" ); 151 cat = i18n( "Birthday" );
114 } else { 152 } else {
115 qDebug("addAnniversaryNoDup called without fitting category! "); 153 qDebug("addAnniversaryNoDup called without fitting category! ");
116 return false; 154 return false;
117 } 155 }
118 Event * eve; 156 Event * eve;
119 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 157 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
120 if ( !(eve->categories().contains( cat ) )) 158 if ( !(eve->categories().contains( cat ) ))
121 continue; 159 continue;
122 // now we have an event with fitting category 160 // now we have an event with fitting category
123 if ( eve->dtStart().date() != event->dtStart().date() ) 161 if ( eve->dtStart().date() != event->dtStart().date() )
124 continue; 162 continue;
125 // now we have an event with fitting category+date 163 // now we have an event with fitting category+date
126 if ( eve->summary() != event->summary() ) 164 if ( eve->summary() != event->summary() )
127 continue; 165 continue;
128 // now we have an event with fitting category+date+summary 166 // now we have an event with fitting category+date+summary
129 return false; 167 return false;
130 } 168 }
131 return addEvent( event ); 169 return addEvent( event );
132 170
133} 171}
134bool CalendarLocal::addEventNoDup( Event *event ) 172bool CalendarLocal::addEventNoDup( Event *event )
135{ 173{
136 Event * eve; 174 Event * eve;
137 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 175 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
138 if ( *eve == *event ) { 176 if ( *eve == *event ) {
139 //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); 177 //qDebug("CalendarLocal::Duplicate event found! Not inserted! ");
140 return false; 178 return false;
141 } 179 }
142 } 180 }
143 return addEvent( event ); 181 return addEvent( event );
144} 182}
145 183
146bool CalendarLocal::addEvent( Event *event ) 184bool CalendarLocal::addEvent( Event *event )
147{ 185{
148 insertEvent( event ); 186 insertEvent( event );
149 187
150 event->registerObserver( this ); 188 event->registerObserver( this );
151 189
152 setModified( true ); 190 setModified( true );
153 event->setCalID( mDefaultCalendar ); 191 event->setCalID( mDefaultCalendar );
154 event->setCalEnabled( true ); 192 event->setCalEnabled( true );
155 193
156 return true; 194 return true;
157} 195}
158 196
159void CalendarLocal::deleteEvent( Event *event ) 197void CalendarLocal::deleteEvent( Event *event )
160{ 198{
161 if ( mUndoIncidence ) delete mUndoIncidence; 199 if ( mUndoIncidence ) delete mUndoIncidence;
162 mUndoIncidence = event->clone(); 200 mUndoIncidence = event->clone();
163 if ( mEventList.removeRef( event ) ) { 201 if ( mEventList.removeRef( event ) ) {
164 setModified( true ); 202 setModified( true );
165 } 203 }
166} 204}
167 205
168 206
169Event *CalendarLocal::event( const QString &uid ) 207Event *CalendarLocal::event( const QString &uid )
170{ 208{
171 209
172 Event *event; 210 Event *event;
173 211
174 for ( event = mEventList.first(); event; event = mEventList.next() ) { 212 for ( event = mEventList.first(); event; event = mEventList.next() ) {
175 if ( event->uid() == uid && event->calEnabled() ) { 213 if ( event->uid() == uid && event->calEnabled() ) {
176 return event; 214 return event;
177 } 215 }
178 } 216 }
179 217
180 return 0; 218 return 0;
181} 219}
182bool CalendarLocal::addTodoNoDup( Todo *todo ) 220bool CalendarLocal::addTodoNoDup( Todo *todo )
183{ 221{
184 Todo * eve; 222 Todo * eve;
185 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { 223 for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) {
186 if ( *eve == *todo ) { 224 if ( *eve == *todo ) {
187 //qDebug("duplicate todo found! not inserted! "); 225 //qDebug("duplicate todo found! not inserted! ");
188 return false; 226 return false;
189 } 227 }
190 } 228 }
191 return addTodo( todo ); 229 return addTodo( todo );
192} 230}
193bool CalendarLocal::addTodo( Todo *todo ) 231bool CalendarLocal::addTodo( Todo *todo )
194{ 232{
195 mTodoList.append( todo ); 233 mTodoList.append( todo );
196 234
197 todo->registerObserver( this ); 235 todo->registerObserver( this );
198 236
199 // Set up subtask relations 237 // Set up subtask relations
200 setupRelations( todo ); 238 setupRelations( todo );
201 239
202 setModified( true ); 240 setModified( true );
203 todo->setCalID( mDefaultCalendar ); 241 todo->setCalID( mDefaultCalendar );
204 todo->setCalEnabled( true ); 242 todo->setCalEnabled( true );
205 return true; 243 return true;
206} 244}
207 245
208void CalendarLocal::deleteTodo( Todo *todo ) 246void CalendarLocal::deleteTodo( Todo *todo )
209{ 247{
210 // Handle orphaned children 248 // Handle orphaned children
211 if ( mUndoIncidence ) delete mUndoIncidence; 249 if ( mUndoIncidence ) delete mUndoIncidence;
212 removeRelations( todo ); 250 removeRelations( todo );
213 mUndoIncidence = todo->clone(); 251 mUndoIncidence = todo->clone();
214 252
215 if ( mTodoList.removeRef( todo ) ) { 253 if ( mTodoList.removeRef( todo ) ) {
216 setModified( true ); 254 setModified( true );
217 } 255 }
218} 256}
219 257
220QPtrList<Todo> CalendarLocal::rawTodos() 258QPtrList<Todo> CalendarLocal::rawTodos()
221{ 259{
222 QPtrList<Todo> el; 260 QPtrList<Todo> el;
223 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 261 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
224 if ( it->calEnabled() ) el.append( it ); 262 if ( it->calEnabled() ) el.append( it );
225 return el; 263 return el;
226} 264}
227Todo *CalendarLocal::todo( QString syncProf, QString id ) 265Todo *CalendarLocal::todo( QString syncProf, QString id )
228{ 266{
229 Todo *todo; 267 Todo *todo;
230 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 268 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
231 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 269 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
232 } 270 }
233 271
234 return 0; 272 return 0;
235} 273}
236void CalendarLocal::removeSyncInfo( QString syncProfile) 274void CalendarLocal::removeSyncInfo( QString syncProfile)
237{ 275{
238 QPtrList<Incidence> all = rawIncidences() ; 276 QPtrList<Incidence> all = rawIncidences() ;
239 Incidence *inc; 277 Incidence *inc;
240 for ( inc = all.first(); inc; inc = all.next() ) { 278 for ( inc = all.first(); inc; inc = all.next() ) {
241 inc->removeID( syncProfile ); 279 inc->removeID( syncProfile );
242 } 280 }
243 if ( syncProfile.isEmpty() ) { 281 if ( syncProfile.isEmpty() ) {
244 QPtrList<Event> el; 282 QPtrList<Event> el;
245 Event *todo; 283 Event *todo;
246 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 284 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
247 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 285 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
248 el.append( todo ); 286 el.append( todo );
249 } 287 }
250 for ( todo = el.first(); todo; todo = el.next() ) { 288 for ( todo = el.first(); todo; todo = el.next() ) {
251 deleteIncidence ( todo ); 289 deleteIncidence ( todo );
252 } 290 }
253 } else { 291 } else {
254 Event *lse = event( "last-syncEvent-"+ syncProfile); 292 Event *lse = event( "last-syncEvent-"+ syncProfile);
255 if ( lse ) 293 if ( lse )
256 deleteIncidence ( lse ); 294 deleteIncidence ( lse );
257 } 295 }
258} 296}
259QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 297QPtrList<Event> CalendarLocal::getExternLastSyncEvents()
260{ 298{
261 QPtrList<Event> el; 299 QPtrList<Event> el;
262 Event *todo; 300 Event *todo;
263 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 301 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
264 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 302 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
265 if ( todo->summary().left(3) == "E: " ) 303 if ( todo->summary().left(3) == "E: " )
266 el.append( todo ); 304 el.append( todo );
267 } 305 }
268 306
269 return el; 307 return el;
270 308
271} 309}
272Event *CalendarLocal::event( QString syncProf, QString id ) 310Event *CalendarLocal::event( QString syncProf, QString id )
273{ 311{
274 Event *todo; 312 Event *todo;
275 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 313 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
276 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 314 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
277 } 315 }
278 316
279 return 0; 317 return 0;
280} 318}
281Todo *CalendarLocal::todo( const QString &uid ) 319Todo *CalendarLocal::todo( const QString &uid )
282{ 320{
283 Todo *todo; 321 Todo *todo;
284 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 322 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
285 if ( todo->calEnabled() && todo->uid() == uid ) return todo; 323 if ( todo->calEnabled() && todo->uid() == uid ) return todo;
286 } 324 }
287 325
288 return 0; 326 return 0;
289} 327}
290QString CalendarLocal::nextSummary() const 328QString CalendarLocal::nextSummary() const
291{ 329{
292 return mNextSummary; 330 return mNextSummary;
293} 331}
294QDateTime CalendarLocal::nextAlarmEventDateTime() const 332QDateTime CalendarLocal::nextAlarmEventDateTime() const
295{ 333{
296 return mNextAlarmEventDateTime; 334 return mNextAlarmEventDateTime;
297} 335}
298void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) 336void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted)
299{ 337{
300 //mNextAlarmIncidence 338 //mNextAlarmIncidence
301 //mNextAlarmDateTime 339 //mNextAlarmDateTime
302 //return mNextSummary; 340 //return mNextSummary;
303 //return mNextAlarmEventDateTime; 341 //return mNextAlarmEventDateTime;
304 bool newNextAlarm = false; 342 bool newNextAlarm = false;
305 bool computeNextAlarm = false; 343 bool computeNextAlarm = false;
306 bool ok; 344 bool ok;
307 int offset; 345 int offset;
308 QDateTime nextA; 346 QDateTime nextA;
309 // QString nextSum; 347 // QString nextSum;
310 //QDateTime nextEvent; 348 //QDateTime nextEvent;
311 if ( mNextAlarmIncidence == 0 || incidence == 0 ) { 349 if ( mNextAlarmIncidence == 0 || incidence == 0 ) {
312 computeNextAlarm = true; 350 computeNextAlarm = true;
313 } else { 351 } else {
314 if ( ! deleted ) { 352 if ( ! deleted ) {
315 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 353 nextA = incidence->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
316 if ( ok ) { 354 if ( ok ) {
317 if ( nextA < mNextAlarmDateTime ) { 355 if ( nextA < mNextAlarmDateTime ) {
318 deRegisterAlarm(); 356 deRegisterAlarm();
319 mNextAlarmDateTime = nextA; 357 mNextAlarmDateTime = nextA;
320 mNextSummary = incidence->summary(); 358 mNextSummary = incidence->summary();
321 mNextAlarmEventDateTime = nextA.addSecs(offset ) ; 359 mNextAlarmEventDateTime = nextA.addSecs(offset ) ;
322 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 360 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
323 newNextAlarm = true; 361 newNextAlarm = true;
324 mNextAlarmIncidence = incidence; 362 mNextAlarmIncidence = incidence;
325 } else { 363 } else {
326 if ( incidence == mNextAlarmIncidence ) { 364 if ( incidence == mNextAlarmIncidence ) {
327 computeNextAlarm = true; 365 computeNextAlarm = true;
328 } 366 }
329 } 367 }
330 } else { 368 } else {
331 if ( mNextAlarmIncidence == incidence ) { 369 if ( mNextAlarmIncidence == incidence ) {
332 computeNextAlarm = true; 370 computeNextAlarm = true;
333 } 371 }
334 } 372 }
335 } else { // deleted 373 } else { // deleted
336 if ( incidence == mNextAlarmIncidence ) { 374 if ( incidence == mNextAlarmIncidence ) {
337 computeNextAlarm = true; 375 computeNextAlarm = true;
338 } 376 }
339 } 377 }
340 } 378 }
341 if ( computeNextAlarm ) { 379 if ( computeNextAlarm ) {
342 deRegisterAlarm(); 380 deRegisterAlarm();
343 nextA = nextAlarm( 1000 ); 381 nextA = nextAlarm( 1000 );
344 if (! mNextAlarmIncidence ) { 382 if (! mNextAlarmIncidence ) {
345 return; 383 return;
346 } 384 }
347 newNextAlarm = true; 385 newNextAlarm = true;
348 } 386 }
349 if ( newNextAlarm ) 387 if ( newNextAlarm )
350 registerAlarm(); 388 registerAlarm();
351} 389}
352QString CalendarLocal:: getAlarmNotification() 390QString CalendarLocal:: getAlarmNotification()
353{ 391{
354 QString ret; 392 QString ret;
355 // this should not happen 393 // this should not happen
356 if (! mNextAlarmIncidence ) 394 if (! mNextAlarmIncidence )
357 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; 395 return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString;
358 Alarm* alarm = mNextAlarmIncidence->alarms().first(); 396 Alarm* alarm = mNextAlarmIncidence->alarms().first();
359 if ( alarm->type() == Alarm::Procedure ) { 397 if ( alarm->type() == Alarm::Procedure ) {
360 ret = "proc_alarm" + alarm->programFile()+"+++"; 398 ret = "proc_alarm" + alarm->programFile()+"+++";
361 } else { 399 } else {
362 ret = "audio_alarm" +alarm->audioFile() +"+++"; 400 ret = "audio_alarm" +alarm->audioFile() +"+++";
363 } 401 }
364 ret += "cal_alarm"+ mNextSummary.left( 25 ); 402 ret += "cal_alarm"+ mNextSummary.left( 25 );
365 if ( mNextSummary.length() > 25 ) 403 if ( mNextSummary.length() > 25 )
366 ret += "\n" + mNextSummary.mid(25, 25 ); 404 ret += "\n" + mNextSummary.mid(25, 25 );
367 ret+= "\n"+mNextAlarmEventDateTimeString; 405 ret+= "\n"+mNextAlarmEventDateTimeString;
368 return ret; 406 return ret;
369} 407}
370void CalendarLocal::registerAlarm() 408void CalendarLocal::registerAlarm()
371{ 409{
372 mLastAlarmNotificationString = getAlarmNotification(); 410 mLastAlarmNotificationString = getAlarmNotification();
373 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); 411 // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() );
374 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 412 emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
375// #ifndef DESKTOP_VERSION 413// #ifndef DESKTOP_VERSION
376// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); 414// AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() );
377// #endif 415// #endif
378} 416}
379void CalendarLocal::deRegisterAlarm() 417void CalendarLocal::deRegisterAlarm()
380{ 418{
381 if ( mLastAlarmNotificationString.isNull() ) 419 if ( mLastAlarmNotificationString.isNull() )
382 return; 420 return;
383 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); 421 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() );
384 422
385 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 423 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
386 mNextAlarmEventDateTime = QDateTime(); 424 mNextAlarmEventDateTime = QDateTime();
387// #ifndef DESKTOP_VERSION 425// #ifndef DESKTOP_VERSION
388// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); 426// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() );
389// #endif 427// #endif
390} 428}
391 429
392QPtrList<Todo> CalendarLocal::todos( const QDate &date ) 430QPtrList<Todo> CalendarLocal::todos( const QDate &date )
393{ 431{
394 QPtrList<Todo> todos; 432 QPtrList<Todo> todos;
395 433
396 Todo *todo; 434 Todo *todo;
397 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 435 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
398 if ( !todo->calEnabled() ) continue; 436 if ( !todo->calEnabled() ) continue;
399 if ( todo->hasDueDate() && todo->dtDue().date() == date ) { 437 if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
400 todos.append( todo ); 438 todos.append( todo );
401 } 439 }
402 } 440 }
403 441
404 filter()->apply( &todos ); 442 filter()->apply( &todos );
405 return todos; 443 return todos;
406} 444}
407void CalendarLocal::reInitAlarmSettings() 445void CalendarLocal::reInitAlarmSettings()
408{ 446{
409 if ( !mNextAlarmIncidence ) { 447 if ( !mNextAlarmIncidence ) {
410 nextAlarm( 1000 ); 448 nextAlarm( 1000 );
411 } 449 }
412 deRegisterAlarm(); 450 deRegisterAlarm();
413 mNextAlarmIncidence = 0; 451 mNextAlarmIncidence = 0;
414 checkAlarmForIncidence( 0, false ); 452 checkAlarmForIncidence( 0, false );
415 453
416} 454}
417 455
418 456
419 457
420QDateTime CalendarLocal::nextAlarm( int daysTo ) 458QDateTime CalendarLocal::nextAlarm( int daysTo )
421{ 459{
422 QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo ); 460 QDateTime nextA = QDateTime::currentDateTime().addDays( daysTo );
423 QDateTime start = QDateTime::currentDateTime().addSecs( 30 ); 461 QDateTime start = QDateTime::currentDateTime().addSecs( 30 );
424 QDateTime next; 462 QDateTime next;
425 Event *e; 463 Event *e;
426 bool ok; 464 bool ok;
427 bool found = false; 465 bool found = false;
428 int offset; 466 int offset;
429 mNextAlarmIncidence = 0; 467 mNextAlarmIncidence = 0;
430 for( e = mEventList.first(); e; e = mEventList.next() ) { 468 for( e = mEventList.first(); e; e = mEventList.next() ) {
431 if ( !e->calEnabled() ) continue; 469 if ( !e->calEnabled() ) continue;
432 next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 470 next = e->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
433 if ( ok ) { 471 if ( ok ) {
434 if ( next < nextA ) { 472 if ( next < nextA ) {
435 nextA = next; 473 nextA = next;
436 found = true; 474 found = true;
437 mNextSummary = e->summary(); 475 mNextSummary = e->summary();
438 mNextAlarmEventDateTime = next.addSecs(offset ) ; 476 mNextAlarmEventDateTime = next.addSecs(offset ) ;
439 mNextAlarmIncidence = (Incidence *) e; 477 mNextAlarmIncidence = (Incidence *) e;
440 } 478 }
441 } 479 }
442 } 480 }
443 Todo *t; 481 Todo *t;
444 for( t = mTodoList.first(); t; t = mTodoList.next() ) { 482 for( t = mTodoList.first(); t; t = mTodoList.next() ) {
445 if ( !t->calEnabled() ) continue; 483 if ( !t->calEnabled() ) continue;
446 next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; 484 next = t->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ;
447 if ( ok ) { 485 if ( ok ) {
448 if ( next < nextA ) { 486 if ( next < nextA ) {
449 nextA = next; 487 nextA = next;
450 found = true; 488 found = true;
451 mNextSummary = t->summary(); 489 mNextSummary = t->summary();
452 mNextAlarmEventDateTime = next.addSecs(offset ); 490 mNextAlarmEventDateTime = next.addSecs(offset );
453 mNextAlarmIncidence = (Incidence *) t; 491 mNextAlarmIncidence = (Incidence *) t;
454 } 492 }
455 } 493 }
456 } 494 }
457 if ( mNextAlarmIncidence ) { 495 if ( mNextAlarmIncidence ) {
458 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); 496 mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime);
459 mNextAlarmDateTime = nextA; 497 mNextAlarmDateTime = nextA;
460 } 498 }
461 return nextA; 499 return nextA;
462} 500}
463Alarm::List CalendarLocal::alarmsTo( const QDateTime &to ) 501Alarm::List CalendarLocal::alarmsTo( const QDateTime &to )
464{ 502{
465 return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to ); 503 return alarms( QDateTime( QDate( 1900, 1, 1 ) ), to );
466} 504}
467 505
468Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to ) 506Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
469{ 507{
470 508
471 Alarm::List alarms; 509 Alarm::List alarms;
472 510
473 Event *e; 511 Event *e;
474 512
475 for( e = mEventList.first(); e; e = mEventList.next() ) { 513 for( e = mEventList.first(); e; e = mEventList.next() ) {
476 if ( !e->calEnabled() ) continue; 514 if ( !e->calEnabled() ) continue;
477 if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to ); 515 if ( e->doesRecur() ) appendRecurringAlarms( alarms, e, from, to );
478 else appendAlarms( alarms, e, from, to ); 516 else appendAlarms( alarms, e, from, to );
479 } 517 }
480 518
481 Todo *t; 519 Todo *t;
482 for( t = mTodoList.first(); t; t = mTodoList.next() ) { 520 for( t = mTodoList.first(); t; t = mTodoList.next() ) {
483 if ( !t->calEnabled() ) continue; 521 if ( !t->calEnabled() ) continue;
484 appendAlarms( alarms, t, from, to ); 522 appendAlarms( alarms, t, from, to );
485 } 523 }
486 524
487 return alarms; 525 return alarms;
488} 526}
489 527
490void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, 528void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence,
491 const QDateTime &from, const QDateTime &to ) 529 const QDateTime &from, const QDateTime &to )
492{ 530{
493 QPtrList<Alarm> alarmList = incidence->alarms(); 531 QPtrList<Alarm> alarmList = incidence->alarms();
494 Alarm *alarm; 532 Alarm *alarm;
495 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 533 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
496// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() 534// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text()
497// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; 535// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl;
498 if ( alarm->enabled() ) { 536 if ( alarm->enabled() ) {
499 if ( alarm->time() >= from && alarm->time() <= to ) { 537 if ( alarm->time() >= from && alarm->time() <= to ) {
500 alarms.append( alarm ); 538 alarms.append( alarm );
501 } 539 }
502 } 540 }
503 } 541 }
504} 542}
505 543
506void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, 544void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms,
507 Incidence *incidence, 545 Incidence *incidence,
508 const QDateTime &from, 546 const QDateTime &from,
509 const QDateTime &to ) 547 const QDateTime &to )
510{ 548{
511 549
512 QPtrList<Alarm> alarmList = incidence->alarms(); 550 QPtrList<Alarm> alarmList = incidence->alarms();
513 Alarm *alarm; 551 Alarm *alarm;
514 QDateTime qdt; 552 QDateTime qdt;
515 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 553 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
516 if (incidence->recursOn(from.date())) { 554 if (incidence->recursOn(from.date())) {
517 qdt.setTime(alarm->time().time()); 555 qdt.setTime(alarm->time().time());
518 qdt.setDate(from.date()); 556 qdt.setDate(from.date());
519 } 557 }
520 else qdt = alarm->time(); 558 else qdt = alarm->time();
521 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); 559 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1());
522 if ( alarm->enabled() ) { 560 if ( alarm->enabled() ) {
523 if ( qdt >= from && qdt <= to ) { 561 if ( qdt >= from && qdt <= to ) {
524 alarms.append( alarm ); 562 alarms.append( alarm );
525 } 563 }
526 } 564 }
527 } 565 }
528} 566}
529 567
530 568
531/****************************** PROTECTED METHODS ****************************/ 569/****************************** PROTECTED METHODS ****************************/
532 570
533// after changes are made to an event, this should be called. 571// after changes are made to an event, this should be called.
534void CalendarLocal::update( IncidenceBase *incidence ) 572void CalendarLocal::update( IncidenceBase *incidence )
535{ 573{
536 incidence->setSyncStatus( Event::SYNCMOD ); 574 incidence->setSyncStatus( Event::SYNCMOD );
537 incidence->setLastModified( QDateTime::currentDateTime() ); 575 incidence->setLastModified( QDateTime::currentDateTime() );
538 // we should probably update the revision number here, 576 // we should probably update the revision number here,
539 // or internally in the Event itself when certain things change. 577 // or internally in the Event itself when certain things change.
540 // need to verify with ical documentation. 578 // need to verify with ical documentation.
541 579
542 setModified( true ); 580 setModified( true );
543} 581}
544 582
545void CalendarLocal::insertEvent( Event *event ) 583void CalendarLocal::insertEvent( Event *event )
546{ 584{
547 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); 585 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event );
548} 586}
549 587
550 588
551QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) 589QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
552{ 590{
553 QPtrList<Event> eventList; 591 QPtrList<Event> eventList;
554 592
555 Event *event; 593 Event *event;
556 for( event = mEventList.first(); event; event = mEventList.next() ) { 594 for( event = mEventList.first(); event; event = mEventList.next() ) {
557 if ( !event->calEnabled() ) continue; 595 if ( !event->calEnabled() ) continue;
558 if ( event->doesRecur() ) { 596 if ( event->doesRecur() ) {
559 if ( event->isMultiDay() ) { 597 if ( event->isMultiDay() ) {
560 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); 598 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
561 int i; 599 int i;
562 for ( i = 0; i <= extraDays; i++ ) { 600 for ( i = 0; i <= extraDays; i++ ) {
563 if ( event->recursOn( qd.addDays( -i ) ) ) { 601 if ( event->recursOn( qd.addDays( -i ) ) ) {
564 eventList.append( event ); 602 eventList.append( event );
565 break; 603 break;
566 } 604 }
567 } 605 }
568 } else { 606 } else {
569 if ( event->recursOn( qd ) ) 607 if ( event->recursOn( qd ) )
570 eventList.append( event ); 608 eventList.append( event );
571 } 609 }
572 } else { 610 } else {
573 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { 611 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) {
574 eventList.append( event ); 612 eventList.append( event );
575 } 613 }
576 } 614 }
577 } 615 }
578 616
579 if ( !sorted ) { 617 if ( !sorted ) {
580 return eventList; 618 return eventList;
581 } 619 }
582 620
583 // kdDebug(5800) << "Sorting events for date\n" << endl; 621 // kdDebug(5800) << "Sorting events for date\n" << endl;
584 // now, we have to sort it based on dtStart.time() 622 // now, we have to sort it based on dtStart.time()
585 QPtrList<Event> eventListSorted; 623 QPtrList<Event> eventListSorted;
586 Event *sortEvent; 624 Event *sortEvent;
587 for ( event = eventList.first(); event; event = eventList.next() ) { 625 for ( event = eventList.first(); event; event = eventList.next() ) {
588 sortEvent = eventListSorted.first(); 626 sortEvent = eventListSorted.first();
589 int i = 0; 627 int i = 0;
590 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) 628 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() )
591 { 629 {
592 i++; 630 i++;
593 sortEvent = eventListSorted.next(); 631 sortEvent = eventListSorted.next();
594 } 632 }
595 eventListSorted.insert( i, event ); 633 eventListSorted.insert( i, event );
596 } 634 }
597 return eventListSorted; 635 return eventListSorted;
598} 636}
599 637
600 638
601QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, 639QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
602 bool inclusive ) 640 bool inclusive )
603{ 641{
604 Event *event = 0; 642 Event *event = 0;
605 643
606 QPtrList<Event> eventList; 644 QPtrList<Event> eventList;
607 645
608 // Get non-recurring events 646 // Get non-recurring events
609 for( event = mEventList.first(); event; event = mEventList.next() ) { 647 for( event = mEventList.first(); event; event = mEventList.next() ) {
610 if ( !event->calEnabled() ) continue; 648 if ( !event->calEnabled() ) continue;
611 if ( event->doesRecur() ) { 649 if ( event->doesRecur() ) {
612 QDate rStart = event->dtStart().date(); 650 QDate rStart = event->dtStart().date();
613 bool found = false; 651 bool found = false;
614 if ( inclusive ) { 652 if ( inclusive ) {
615 if ( rStart >= start && rStart <= end ) { 653 if ( rStart >= start && rStart <= end ) {
616 // Start date of event is in range. Now check for end date. 654 // Start date of event is in range. Now check for end date.
617 // if duration is negative, event recurs forever, so do not include it. 655 // if duration is negative, event recurs forever, so do not include it.
618 if ( event->recurrence()->duration() == 0 ) { // End date set 656 if ( event->recurrence()->duration() == 0 ) { // End date set
619 QDate rEnd = event->recurrence()->endDate(); 657 QDate rEnd = event->recurrence()->endDate();
620 if ( rEnd >= start && rEnd <= end ) { // End date within range 658 if ( rEnd >= start && rEnd <= end ) { // End date within range
621 found = true; 659 found = true;
622 } 660 }
623 } else if ( event->recurrence()->duration() > 0 ) { // Duration set 661 } else if ( event->recurrence()->duration() > 0 ) { // Duration set
624 // TODO: Calculate end date from duration. Should be done in Event 662 // TODO: Calculate end date from duration. Should be done in Event
625 // For now exclude all events with a duration. 663 // For now exclude all events with a duration.
626 } 664 }
627 } 665 }
628 } else { 666 } else {
629 bool founOne; 667 bool founOne;
630 QDate next = event->getNextOccurence( start, &founOne ).date(); 668 QDate next = event->getNextOccurence( start, &founOne ).date();
631 if ( founOne ) { 669 if ( founOne ) {
632 if ( next <= end ) { 670 if ( next <= end ) {
633 found = true; 671 found = true;
634 } 672 }
635 } 673 }
636 674
637 /* 675 /*
638 // crap !!! 676 // crap !!!
639 if ( rStart <= end ) { // Start date not after range 677 if ( rStart <= end ) { // Start date not after range
640 if ( rStart >= start ) { // Start date within range 678 if ( rStart >= start ) { // Start date within range
641 found = true; 679 found = true;
642 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever 680 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever
643 found = true; 681 found = true;
644 } else if ( event->recurrence()->duration() == 0 ) { // End date set 682 } else if ( event->recurrence()->duration() == 0 ) { // End date set
645 QDate rEnd = event->recurrence()->endDate(); 683 QDate rEnd = event->recurrence()->endDate();
646 if ( rEnd >= start && rEnd <= end ) { // End date within range 684 if ( rEnd >= start && rEnd <= end ) { // End date within range
647 found = true; 685 found = true;
648 } 686 }
649 } else { // Duration set 687 } else { // Duration set
650 // TODO: Calculate end date from duration. Should be done in Event 688 // TODO: Calculate end date from duration. Should be done in Event
651 // For now include all events with a duration. 689 // For now include all events with a duration.
652 found = true; 690 found = true;
653 } 691 }
654 } 692 }
655 */ 693 */
656 694
657 } 695 }
658 696
659 if ( found ) eventList.append( event ); 697 if ( found ) eventList.append( event );
660 } else { 698 } else {
661 QDate s = event->dtStart().date(); 699 QDate s = event->dtStart().date();
662 QDate e = event->dtEnd().date(); 700 QDate e = event->dtEnd().date();
663 701
664 if ( inclusive ) { 702 if ( inclusive ) {
665 if ( s >= start && e <= end ) { 703 if ( s >= start && e <= end ) {
666 eventList.append( event ); 704 eventList.append( event );
667 } 705 }
668 } else { 706 } else {
669 if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { 707 if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) {
670 eventList.append( event ); 708 eventList.append( event );
671 } 709 }
672 } 710 }
673 } 711 }
674 } 712 }
675 713
676 return eventList; 714 return eventList;
677} 715}
678 716
679QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) 717QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
680{ 718{
681 return rawEventsForDate( qdt.date() ); 719 return rawEventsForDate( qdt.date() );
682} 720}
683 721
684QPtrList<Event> CalendarLocal::rawEvents() 722QPtrList<Event> CalendarLocal::rawEvents()
685{ 723{
686 QPtrList<Event> el; 724 QPtrList<Event> el;
687 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 725 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
688 if ( it->calEnabled() ) el.append( it ); 726 if ( it->calEnabled() ) el.append( it );
689 return el; 727 return el;
690} 728}
691 729
692bool CalendarLocal::addJournal(Journal *journal) 730bool CalendarLocal::addJournal(Journal *journal)
693{ 731{
694 if ( journal->dtStart().isValid()) 732 if ( journal->dtStart().isValid())
695 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; 733 kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl;
696 else 734 else
697 kdDebug(5800) << "Adding Journal without a DTSTART" << endl; 735 kdDebug(5800) << "Adding Journal without a DTSTART" << endl;
698 736
699 mJournalList.append(journal); 737 mJournalList.append(journal);
700 738
701 journal->registerObserver( this ); 739 journal->registerObserver( this );
702 740
703 setModified( true ); 741 setModified( true );
704 journal->setCalID( mDefaultCalendar ); 742 journal->setCalID( mDefaultCalendar );
705 journal->setCalEnabled( true ); 743 journal->setCalEnabled( true );
706 return true; 744 return true;
707} 745}
708 746
709void CalendarLocal::deleteJournal( Journal *journal ) 747void CalendarLocal::deleteJournal( Journal *journal )
710{ 748{
711 if ( mUndoIncidence ) delete mUndoIncidence; 749 if ( mUndoIncidence ) delete mUndoIncidence;
712 mUndoIncidence = journal->clone(); 750 mUndoIncidence = journal->clone();
713 mUndoIncidence->setSummary( mUndoIncidence->description().left(25)); 751 mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
714 if ( mJournalList.removeRef(journal) ) { 752 if ( mJournalList.removeRef(journal) ) {
715 setModified( true ); 753 setModified( true );
716 } 754 }
717} 755}
718 756
719Journal *CalendarLocal::journal( const QDate &date ) 757Journal *CalendarLocal::journal( const QDate &date )
720{ 758{
721// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 759// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
722 760
723 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 761 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
724 if ( it->calEnabled() && it->dtStart().date() == date ) 762 if ( it->calEnabled() && it->dtStart().date() == date )
725 return it; 763 return it;
726 764
727 return 0; 765 return 0;
728} 766}
729 767
730Journal *CalendarLocal::journal( const QString &uid ) 768Journal *CalendarLocal::journal( const QString &uid )
731{ 769{
732 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 770 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
733 if ( it->calEnabled() && it->uid() == uid ) 771 if ( it->calEnabled() && it->uid() == uid )
734 return it; 772 return it;
735 773
736 return 0; 774 return 0;
737} 775}
738 776
739QPtrList<Journal> CalendarLocal::journals() 777QPtrList<Journal> CalendarLocal::journals()
740{ 778{
741 QPtrList<Journal> el; 779 QPtrList<Journal> el;
742 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 780 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
743 if ( it->calEnabled() ) el.append( it ); 781 if ( it->calEnabled() ) el.append( it );
744 return el; 782 return el;
745} 783}
746 784
747void CalendarLocal::setCalendarEnabled( int id, bool enable ) 785void CalendarLocal::setCalendarEnabled( int id, bool enable )
748{ 786{
749 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 787 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
750 if ( it->calID() == id ) it->setCalEnabled( enable ); 788 if ( it->calID() == id ) it->setCalEnabled( enable );
751 789
752 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 790 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
753 if ( it->calID() == id ) it->setCalEnabled( enable ); 791 if ( it->calID() == id ) it->setCalEnabled( enable );
754 792
755 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 793 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
756 if ( it->calID() == id ) it->setCalEnabled( enable ); 794 if ( it->calID() == id ) it->setCalEnabled( enable );
757 795
758} 796}
797
798void CalendarLocal::setReadOnly( int id, bool enable )
799{
800 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
801 if ( it->calID() == id ) it->setReadOnly( enable );
802
803 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
804 if ( it->calID() == id ) it->setReadOnly( enable );
805
806 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
807 if ( it->calID() == id ) it->setReadOnly( enable );
808
809}
810
759void CalendarLocal::setAlarmEnabled( int id, bool enable ) 811void CalendarLocal::setAlarmEnabled( int id, bool enable )
760{ 812{
761 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 813 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
762 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 814 if ( it->calID() == id ) it->setAlarmEnabled( enable );
763 815
764 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 816 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
765 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 817 if ( it->calID() == id ) it->setAlarmEnabled( enable );
766 818
767 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 819 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
768 if ( it->calID() == id ) it->setAlarmEnabled( enable ); 820 if ( it->calID() == id ) it->setAlarmEnabled( enable );
769 821
770} 822}
771void CalendarLocal::setDefaultCalendarEnabledOnly() 823void CalendarLocal::setDefaultCalendarEnabledOnly()
772{ 824{
773 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 825 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
774 it->setCalEnabled( it->calID() == mDefaultCalendar ); 826 it->setCalEnabled( it->calID() == mDefaultCalendar );
775 827
776 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 828 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
777 it->setCalEnabled( it->calID() == mDefaultCalendar); 829 it->setCalEnabled( it->calID() == mDefaultCalendar);
778 830
779 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 831 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
780 it->setCalEnabled( it->calID() == mDefaultCalendar); 832 it->setCalEnabled( it->calID() == mDefaultCalendar);
781 833
782} 834}
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index b25fcbe..65f6aa7 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -1,221 +1,223 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22#ifndef KCAL_CALENDARLOCAL_H 22#ifndef KCAL_CALENDARLOCAL_H
23#define KCAL_CALENDARLOCAL_H 23#define KCAL_CALENDARLOCAL_H
24 24
25#include "calendar.h" 25#include "calendar.h"
26 26
27namespace KCal { 27namespace KCal {
28 28
29class CalFormat; 29class CalFormat;
30 30
31/** 31/**
32 This class provides a calendar stored as a local file. 32 This class provides a calendar stored as a local file.
33*/ 33*/
34class CalendarLocal : public Calendar 34class CalendarLocal : public Calendar
35{ 35{
36 public: 36 public:
37 /** 37 /**
38 Constructs a new calendar, with variables initialized to sane values. 38 Constructs a new calendar, with variables initialized to sane values.
39 */ 39 */
40 CalendarLocal(); 40 CalendarLocal();
41 /** 41 /**
42 Constructs a new calendar, with variables initialized to sane values. 42 Constructs a new calendar, with variables initialized to sane values.
43 */ 43 */
44 CalendarLocal( const QString &timeZoneId ); 44 CalendarLocal( const QString &timeZoneId );
45 ~CalendarLocal(); 45 ~CalendarLocal();
46 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id );
47 /** 48 /**
48 Loads a calendar on disk in vCalendar or iCalendar format into the current 49 Loads a calendar on disk in vCalendar or iCalendar format into the current
49 calendar. Any information already present is lost. 50 calendar. Any information already present is lost.
50 @return true, if successfull, false on error. 51 @return true, if successfull, false on error.
51 @param fileName the name of the calendar on disk. 52 @param fileName the name of the calendar on disk.
52 */ 53 */
53 bool load( const QString &fileName ); 54 bool load( const QString &fileName );
54 /** 55 /**
55 Writes out the calendar to disk in the specified \a format. 56 Writes out the calendar to disk in the specified \a format.
56 CalendarLocal takes ownership of the CalFormat object. 57 CalendarLocal takes ownership of the CalFormat object.
57 @return true, if successfull, false on error. 58 @return true, if successfull, false on error.
58 @param fileName the name of the file 59 @param fileName the name of the file
59 */ 60 */
60 bool save( const QString &fileName, CalFormat *format = 0 ); 61 bool save( const QString &fileName, CalFormat *format = 0 );
61 62
62 /** 63 /**
63 Clears out the current calendar, freeing all used memory etc. etc. 64 Clears out the current calendar, freeing all used memory etc. etc.
64 */ 65 */
65 void close(); 66 void close();
66 67
67 void save() {} 68 void save() {}
68 69
69 /** 70 /**
70 Add Event to calendar. 71 Add Event to calendar.
71 */ 72 */
72 void removeSyncInfo( QString syncProfile); 73 void removeSyncInfo( QString syncProfile);
73 bool addAnniversaryNoDup( Event *event ); 74 bool addAnniversaryNoDup( Event *event );
74 bool addEventNoDup( Event *event ); 75 bool addEventNoDup( Event *event );
75 bool addEvent( Event *event ); 76 bool addEvent( Event *event );
76 /** 77 /**
77 Deletes an event from this calendar. 78 Deletes an event from this calendar.
78 */ 79 */
79 void deleteEvent( Event *event ); 80 void deleteEvent( Event *event );
80 81
81 /** 82 /**
82 Retrieves an event on the basis of the unique string ID. 83 Retrieves an event on the basis of the unique string ID.
83 */ 84 */
84 Event *event( const QString &uid ); 85 Event *event( const QString &uid );
85 /** 86 /**
86 Return unfiltered list of all events in calendar. 87 Return unfiltered list of all events in calendar.
87 */ 88 */
88 QPtrList<Event> rawEvents(); 89 QPtrList<Event> rawEvents();
89 QPtrList<Event> getExternLastSyncEvents(); 90 QPtrList<Event> getExternLastSyncEvents();
90 /** 91 /**
91 Add a todo to the todolist. 92 Add a todo to the todolist.
92 */ 93 */
93 bool addTodo( Todo *todo ); 94 bool addTodo( Todo *todo );
94 bool addTodoNoDup( Todo *todo ); 95 bool addTodoNoDup( Todo *todo );
95 /** 96 /**
96 Remove a todo from the todolist. 97 Remove a todo from the todolist.
97 */ 98 */
98 void deleteTodo( Todo * ); 99 void deleteTodo( Todo * );
99 /** 100 /**
100 Searches todolist for an event with this unique string identifier, 101 Searches todolist for an event with this unique string identifier,
101 returns a pointer or null. 102 returns a pointer or null.
102 */ 103 */
103 Todo *todo( const QString &uid ); 104 Todo *todo( const QString &uid );
104 /** 105 /**
105 Return list of all todos. 106 Return list of all todos.
106 */ 107 */
107 QPtrList<Todo> rawTodos(); 108 QPtrList<Todo> rawTodos();
108 /** 109 /**
109 Returns list of todos due on the specified date. 110 Returns list of todos due on the specified date.
110 */ 111 */
111 QPtrList<Todo> todos( const QDate &date ); 112 QPtrList<Todo> todos( const QDate &date );
112 /** 113 /**
113 Return list of all todos. 114 Return list of all todos.
114 115
115 Workaround because compiler does not recognize function of base class. 116 Workaround because compiler does not recognize function of base class.
116 */ 117 */
117 QPtrList<Todo> todos() { return Calendar::todos(); } 118 QPtrList<Todo> todos() { return Calendar::todos(); }
118 119
119 /** 120 /**
120 Add a Journal entry to calendar. 121 Add a Journal entry to calendar.
121 */ 122 */
122 bool addJournal( Journal * ); 123 bool addJournal( Journal * );
123 /** 124 /**
124 Remove a Journal from the calendar. 125 Remove a Journal from the calendar.
125 */ 126 */
126 void deleteJournal( Journal * ); 127 void deleteJournal( Journal * );
127 /** 128 /**
128 Return Journal for given date. 129 Return Journal for given date.
129 */ 130 */
130 Journal *journal( const QDate & ); 131 Journal *journal( const QDate & );
131 /** 132 /**
132 Return Journal with given UID. 133 Return Journal with given UID.
133 */ 134 */
134 Journal *journal( const QString &uid ); 135 Journal *journal( const QString &uid );
135 /** 136 /**
136 Return list of all Journals stored in calendar. 137 Return list of all Journals stored in calendar.
137 */ 138 */
138 QPtrList<Journal> journals(); 139 QPtrList<Journal> journals();
139 140
140 /** 141 /**
141 Return all alarms, which ocur in the given time interval. 142 Return all alarms, which ocur in the given time interval.
142 */ 143 */
143 Alarm::List alarms( const QDateTime &from, const QDateTime &to ); 144 Alarm::List alarms( const QDateTime &from, const QDateTime &to );
144 145
145 /** 146 /**
146 Return all alarms, which ocur before given date. 147 Return all alarms, which ocur before given date.
147 */ 148 */
148 Alarm::List alarmsTo( const QDateTime &to ); 149 Alarm::List alarmsTo( const QDateTime &to );
149 150
150 QDateTime nextAlarm( int daysTo ) ; 151 QDateTime nextAlarm( int daysTo ) ;
151 QDateTime nextAlarmEventDateTime() const; 152 QDateTime nextAlarmEventDateTime() const;
152 void checkAlarmForIncidence( Incidence *, bool deleted ) ; 153 void checkAlarmForIncidence( Incidence *, bool deleted ) ;
153 void registerAlarm(); 154 void registerAlarm();
154 void deRegisterAlarm(); 155 void deRegisterAlarm();
155 QString getAlarmNotification(); 156 QString getAlarmNotification();
156 QString nextSummary() const ; 157 QString nextSummary() const ;
157 /** 158 /**
158 This method should be called whenever a Event is modified directly 159 This method should be called whenever a Event is modified directly
159 via it's pointer. It makes sure that the calendar is internally 160 via it's pointer. It makes sure that the calendar is internally
160 consistent. 161 consistent.
161 */ 162 */
162 void update( IncidenceBase *incidence ); 163 void update( IncidenceBase *incidence );
163 164
164 /** 165 /**
165 Builds and then returns a list of all events that match for the 166 Builds and then returns a list of all events that match for the
166 date specified. useful for dayView, etc. etc. 167 date specified. useful for dayView, etc. etc.
167 */ 168 */
168 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); 169 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
169 /** 170 /**
170 Get unfiltered events for date \a qdt. 171 Get unfiltered events for date \a qdt.
171 */ 172 */
172 QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); 173 QPtrList<Event> rawEventsForDate( const QDateTime &qdt );
173 /** 174 /**
174 Get unfiltered events in a range of dates. If inclusive is set to true, 175 Get unfiltered events in a range of dates. If inclusive is set to true,
175 only events are returned, which are completely included in the range. 176 only events are returned, which are completely included in the range.
176 */ 177 */
177 QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 178 QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
178 bool inclusive = false ); 179 bool inclusive = false );
179 Todo *todo( QString, QString ); 180 Todo *todo( QString, QString );
180 Event *event( QString, QString ); 181 Event *event( QString, QString );
181 182
182 183public slots:
183 void setCalendarEnabled( int id, bool enable ); 184 void setCalendarEnabled( int id, bool enable );
184 void setAlarmEnabled( int id, bool enable ); 185 void setAlarmEnabled( int id, bool enable );
186 void setReadOnly( int id, bool enable );
185 void setDefaultCalendarEnabledOnly(); 187 void setDefaultCalendarEnabledOnly();
186 188
187 protected: 189 protected:
188 190
189 // Event* mNextAlarmEvent; 191 // Event* mNextAlarmEvent;
190 QString mNextSummary; 192 QString mNextSummary;
191 QString mNextAlarmEventDateTimeString; 193 QString mNextAlarmEventDateTimeString;
192 QString mLastAlarmNotificationString; 194 QString mLastAlarmNotificationString;
193 QDateTime mNextAlarmEventDateTime; 195 QDateTime mNextAlarmEventDateTime;
194 QDateTime mNextAlarmDateTime; 196 QDateTime mNextAlarmDateTime;
195 void reInitAlarmSettings(); 197 void reInitAlarmSettings();
196 198
197 /** Notification function of IncidenceBase::Observer. */ 199 /** Notification function of IncidenceBase::Observer. */
198 void incidenceUpdated( IncidenceBase *i ) { update( i ); } 200 void incidenceUpdated( IncidenceBase *i ) { update( i ); }
199 201
200 /** inserts an event into its "proper place" in the calendar. */ 202 /** inserts an event into its "proper place" in the calendar. */
201 void insertEvent( Event *event ); 203 void insertEvent( Event *event );
202 204
203 /** Append alarms of incidence in interval to list of alarms. */ 205 /** Append alarms of incidence in interval to list of alarms. */
204 void appendAlarms( Alarm::List &alarms, Incidence *incidence, 206 void appendAlarms( Alarm::List &alarms, Incidence *incidence,
205 const QDateTime &from, const QDateTime &to ); 207 const QDateTime &from, const QDateTime &to );
206 208
207 /** Append alarms of recurring events in interval to list of alarms. */ 209 /** Append alarms of recurring events in interval to list of alarms. */
208 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, 210 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,
209 const QDateTime &from, const QDateTime &to ); 211 const QDateTime &from, const QDateTime &to );
210 212
211 private: 213 private:
212 void init(); 214 void init();
213 215
214 QPtrList<Event> mEventList; 216 QPtrList<Event> mEventList;
215 QPtrList<Todo> mTodoList; 217 QPtrList<Todo> mTodoList;
216 QPtrList<Journal> mJournalList; 218 QPtrList<Journal> mJournalList;
217}; 219};
218 220
219} 221}
220 222
221#endif 223#endif