summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp60
-rw-r--r--korganizer/calendarview.h8
-rw-r--r--korganizer/koviewmanager.cpp10
3 files changed, 50 insertions, 28 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 697093e..776cdd3 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,1416 +1,1441 @@
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
372 mDatePickerMode = 0; 372 mDatePickerMode = 0;
373 mCurrentSyncDevice = ""; 373 mCurrentSyncDevice = "";
374 writeLocale();
375 mViewManager = new KOViewManager( this ); 374 mViewManager = new KOViewManager( this );
376 mDialogManager = new KODialogManager( this ); 375 mDialogManager = new KODialogManager( this );
377 mEventViewerDialog = 0; 376 mEventViewerDialog = 0;
378 mModified = false; 377 mModified = false;
379 mReadOnly = false; 378 mReadOnly = false;
380 mSelectedIncidence = 0; 379 mSelectedIncidence = 0;
381 mCalPrinter = 0; 380 mCalPrinter = 0;
382 mFilters.setAutoDelete(true); 381 mFilters.setAutoDelete(true);
383 382
384 mCalendar->registerObserver( this ); 383 mCalendar->registerObserver( this );
385 // TODO: Make sure that view is updated, when calendar is changed. 384 // TODO: Make sure that view is updated, when calendar is changed.
386 385
387 mStorage = new FileStorage( mCalendar ); 386 mStorage = new FileStorage( mCalendar );
388 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 387 mNavigator = new DateNavigator( this, "datevav", mViewManager );
389 388
390 QBoxLayout *topLayout = (QBoxLayout*)layout(); 389 QBoxLayout *topLayout = (QBoxLayout*)layout();
391#ifndef KORG_NOSPLITTER 390#ifndef KORG_NOSPLITTER
392 // create the main layout frames. 391 // create the main layout frames.
393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 392 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
394 topLayout->addWidget(mPanner); 393 topLayout->addWidget(mPanner);
395 394
396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 395 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
397 "CalendarView::LeftFrame"); 396 "CalendarView::LeftFrame");
398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 397 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
399 398
400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 399 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
401 "CalendarView::DateNavigator" ); 400 "CalendarView::DateNavigator" );
402 401
403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 402 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 403 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
405 mTodoList->setNavigator( mNavigator ); 404 mTodoList->setNavigator( mNavigator );
406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 405 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
407 406
408#ifdef KORG_NORESOURCEVIEW 407#ifdef KORG_NORESOURCEVIEW
409 mResourceView = 0; 408 mResourceView = 0;
410#else 409#else
411 if ( mResourceManager ) { 410 if ( mResourceManager ) {
412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 411 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
413 mResourceView->updateView(); 412 mResourceView->updateView();
414 connect( mResourceView, SIGNAL( resourcesChanged() ), 413 connect( mResourceView, SIGNAL( resourcesChanged() ),
415 SLOT( updateView() ) ); 414 SLOT( updateView() ) );
416 } else { 415 } else {
417 mResourceView = 0; 416 mResourceView = 0;
418 } 417 }
419#endif 418#endif
420 QWidget *rightBox = new QWidget( mPanner ); 419 QWidget *rightBox = new QWidget( mPanner );
421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 420 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
422 421
423 mRightFrame = new QWidgetStack( rightBox ); 422 mRightFrame = new QWidgetStack( rightBox );
424 rightLayout->addWidget( mRightFrame, 1 ); 423 rightLayout->addWidget( mRightFrame, 1 );
425 424
426 mLeftFrame = mLeftSplitter; 425 mLeftFrame = mLeftSplitter;
427#else 426#else
428 //QWidget *mainBox = new QWidget( this ); 427 //QWidget *mainBox = new QWidget( this );
429 //QWidget *leftFrame = new QWidget( mainBox ); 428 //QWidget *leftFrame = new QWidget( mainBox );
430 //QBoxLayout * mainBoxLayout; 429 //QBoxLayout * mainBoxLayout;
431 if ( KOPrefs::instance()->mVerticalScreen ) { 430 if ( KOPrefs::instance()->mVerticalScreen ) {
432 //mainBoxLayout = new QVBoxLayout(mainBox); 431 //mainBoxLayout = new QVBoxLayout(mainBox);
433 //leftFrameLayout = new QHBoxLayout(leftFrame ); 432 //leftFrameLayout = new QHBoxLayout(leftFrame );
434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 433 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 434 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 435 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 436 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
438 } else { 437 } else {
439 //mainBoxLayout = new QHBoxLayout(mainBox); 438 //mainBoxLayout = new QHBoxLayout(mainBox);
440 //leftFrameLayout = new QVBoxLayout(leftFrame ); 439 //leftFrameLayout = new QVBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 440 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 441 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 442 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 443 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
445 } 444 }
446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 445 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
447 //QBoxLayout * leftFrameLayout; 446 //QBoxLayout * leftFrameLayout;
447 mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this );
448 topLayout->addWidget( mMainFrame ); 448 topLayout->addWidget( mMainFrame );
449 topLayout->addWidget( mDateScrollBar );
449 //mainBoxLayout->addWidget (mLeftFrame); 450 //mainBoxLayout->addWidget (mLeftFrame);
450 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 451 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
451 "CalendarView::DateNavigator" ); 452 "CalendarView::DateNavigator" );
452#if 0 453#if 0
453 // FIXME 454 // FIXME
454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 455 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
455 "CalendarView::DateNavigator", QDate::currentDate()); 456 "CalendarView::DateNavigator", QDate::currentDate());
456#endif 457#endif
457 // mDateNavigator->blockSignals( true ); 458 // mDateNavigator->blockSignals( true );
458 //leftFrameLayout->addWidget( mDateNavigator ); 459 //leftFrameLayout->addWidget( mDateNavigator );
459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 460 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 461 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 462 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
462 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 463 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( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
464 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); 465 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
465 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 466 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
466 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 467 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
467 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 468 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
468 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 469 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
469 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 470 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
470 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 471 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
472 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
471 mTodoList->setNavigator( mNavigator ); 473 mTodoList->setNavigator( mNavigator );
472#if 0 474#if 0
473 if ( QApplication::desktop()->width() < 480 ) { 475 if ( QApplication::desktop()->width() < 480 ) {
474 leftFrameLayout->addWidget(mFilterView); 476 leftFrameLayout->addWidget(mFilterView);
475 leftFrameLayout->addWidget(mTodoList, 2 ); 477 leftFrameLayout->addWidget(mTodoList, 2 );
476 478
477 } else { 479 } else {
478 leftFrameLayout->addWidget(mTodoList,2 ); 480 leftFrameLayout->addWidget(mTodoList,2 );
479 leftFrameLayout->addWidget(mFilterView ); 481 leftFrameLayout->addWidget(mFilterView );
480 } 482 }
481#endif 483#endif
482 mFilterView->hide(); 484 mFilterView->hide();
483 mCalEditView->hide(); 485 mCalEditView->hide();
484 QWidget *rightBox = new QWidget( mMainFrame ); 486 QWidget *rightBox = new QWidget( mMainFrame );
485 //mainBoxLayout->addWidget ( rightBox, 10 ); 487 //mainBoxLayout->addWidget ( rightBox, 10 );
486 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 488 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
487 mRightFrame = new QWidgetStack( rightBox ); 489 mRightFrame = new QWidgetStack( rightBox );
488 rightLayout->addWidget( mRightFrame, 10 ); 490 rightLayout->addWidget( mRightFrame, 10 );
489 491
490 //mLeftFrame = (QWidget *)leftFrame; 492 //mLeftFrame = (QWidget *)leftFrame;
491 if ( KOPrefs::instance()->mVerticalScreen ) { 493 if ( KOPrefs::instance()->mVerticalScreen ) {
492 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 494 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
493 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 495 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
494 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 496 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
495 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 497 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
496 } else { 498 } else {
497 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 499 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
498 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 500 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
499 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 501 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
500 } 502 }
501 if ( !KOPrefs::instance()->mShowDateNavigator) 503 if ( !KOPrefs::instance()->mShowDateNavigator)
502 mDateNavigator->hide(); 504 mDateNavigator->hide();
503 //qDebug("Calendarview Size %d %d ", width(), height()); 505 //qDebug("Calendarview Size %d %d ", width(), height());
504#endif 506#endif
505 507
506 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 508 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
507 SLOT( showDates( const KCal::DateList & ) ) ); 509 SLOT( showDates( const KCal::DateList & ) ) );
508 510
509 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 511 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
510 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 512 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
511 513
512 514
513 515
514 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 516 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
515 mViewManager, SLOT( showMonth( const QDate & ) ) ); 517 mViewManager, SLOT( showMonth( const QDate & ) ) );
516 518
517 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 519 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
518 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 520 mNavigator, SLOT( selectWeek( const QDate & ) ) );
519 521
520 connect( mDateNavigator, SIGNAL( goPrevYear() ), 522 connect( mDateNavigator, SIGNAL( goPrevYear() ),
521 mNavigator, SLOT( selectPreviousYear() ) ); 523 mNavigator, SLOT( selectPreviousYear() ) );
522 connect( mDateNavigator, SIGNAL( goNextYear() ), 524 connect( mDateNavigator, SIGNAL( goNextYear() ),
523 mNavigator, SLOT( selectNextYear() ) ); 525 mNavigator, SLOT( selectNextYear() ) );
524 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 526 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
525 mNavigator, SLOT( selectPreviousMonth() ) ); 527 mNavigator, SLOT( selectPreviousMonth() ) );
526 connect( mDateNavigator, SIGNAL( goNextMonth() ), 528 connect( mDateNavigator, SIGNAL( goNextMonth() ),
527 mNavigator, SLOT( selectNextMonth() ) ); 529 mNavigator, SLOT( selectNextMonth() ) );
528 530
529 connect( mDateNavigator, SIGNAL( goPrevious() ), 531 connect( mDateNavigator, SIGNAL( goPrevious() ),
530 mNavigator, SLOT( selectPrevious() ) ); 532 mNavigator, SLOT( selectPrevious() ) );
531 connect( mDateNavigator, SIGNAL( goNext() ), 533 connect( mDateNavigator, SIGNAL( goNext() ),
532 mNavigator, SLOT( selectNext() ) ); 534 mNavigator, SLOT( selectNext() ) );
533 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 535 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
534 mNavigator, SLOT( slotMonthSelect( int ) ) ); 536 mNavigator, SLOT( slotMonthSelect( int ) ) );
535 537
536 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 538 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
537 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 539 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
538#if 0 540#if 0
539 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 541 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
540 SLOT( incidenceAdded( Incidence *) ) ); 542 SLOT( incidenceAdded( Incidence *) ) );
541#endif 543#endif
542 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 544 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
543 545
544 connect( this, SIGNAL( configChanged() ), 546 connect( this, SIGNAL( configChanged() ),
545 mDateNavigator, SLOT( updateConfig() ) ); 547 mDateNavigator, SLOT( updateConfig() ) );
546 548
547 connect( mTodoList, SIGNAL( newTodoSignal() ), 549 connect( mTodoList, SIGNAL( newTodoSignal() ),
548 SLOT( newTodo() ) ); 550 SLOT( newTodo() ) );
549 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 551 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
550 SLOT( newSubTodo( Todo * ) ) ); 552 SLOT( newSubTodo( Todo * ) ) );
551 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 553 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
552 SLOT( editTodo( Todo * ) ) ); 554 SLOT( editTodo( Todo * ) ) );
553 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 555 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
554 SLOT( showTodo( Todo *) ) ); 556 SLOT( showTodo( Todo *) ) );
555 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 557 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
556 SLOT( deleteTodo( Todo *) ) ); 558 SLOT( deleteTodo( Todo *) ) );
557 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 559 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
558 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 560 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
559 SLOT( purgeCompleted() ) ); 561 SLOT( purgeCompleted() ) );
560 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 562 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
561 SIGNAL( todoModified( Todo *, int ) ) ); 563 SIGNAL( todoModified( Todo *, int ) ) );
562 564
563 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 565 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
564 this, SLOT ( cloneIncidence( Incidence * ) ) ); 566 this, SLOT ( cloneIncidence( Incidence * ) ) );
565 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 567 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
566 this, SLOT (cancelIncidence( Incidence * ) ) ); 568 this, SLOT (cancelIncidence( Incidence * ) ) );
567 569
568 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 570 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
569 this, SLOT ( moveIncidence( Incidence * ) ) ); 571 this, SLOT ( moveIncidence( Incidence * ) ) );
570 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 572 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
571 this, SLOT ( beamIncidence( Incidence * ) ) ); 573 this, SLOT ( beamIncidence( Incidence * ) ) );
572 574
573 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 575 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
574 this, SLOT ( todo_unsub( Todo * ) ) ); 576 this, SLOT ( todo_unsub( Todo * ) ) );
575 577
576 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 578 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
577 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 579 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
578 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 580 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
579 SLOT( updateTodo( Todo *, int ) ) ); 581 SLOT( updateTodo( Todo *, int ) ) );
580 connect( this, SIGNAL( todoModified( Todo *, int )), this, 582 connect( this, SIGNAL( todoModified( Todo *, int )), this,
581 SLOT( changeTodoDisplay( Todo *, int ) ) ); 583 SLOT( changeTodoDisplay( Todo *, int ) ) );
582 584
583 585
584 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 586 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
585 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 587 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
586 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 588 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
587 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 589 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
588 590
589 591
590 592
591 593
592 594
593 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 595 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
594 SLOT(checkClipboard())); 596 SLOT(checkClipboard()));
595 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 597 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
596 SLOT( processTodoListSelection( Incidence * ) ) ); 598 SLOT( processTodoListSelection( Incidence * ) ) );
597 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 599 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
598 600
599 // kdDebug() << "CalendarView::CalendarView() done" << endl; 601 // kdDebug() << "CalendarView::CalendarView() done" << endl;
600 602
601 mDateFrame = new QVBox(0,0,WType_Popup); 603 mDateFrame = new QVBox(0,0,WType_Popup);
602 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 604 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
603 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 605 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
604 mDateFrame->setLineWidth(3); 606 mDateFrame->setLineWidth(3);
605 mDateFrame->hide(); 607 mDateFrame->hide();
606 mDateFrame->setCaption( i18n( "Pick a date to display")); 608 mDateFrame->setCaption( i18n( "Pick a date to display"));
607 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 609 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
608 610
609 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 611 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
610 612
611 mEventEditor = mDialogManager->getEventEditor(); 613 mEventEditor = mDialogManager->getEventEditor();
612 mTodoEditor = mDialogManager->getTodoEditor(); 614 mTodoEditor = mDialogManager->getTodoEditor();
613 615
614 mFlagEditDescription = false; 616 mFlagEditDescription = false;
615 617
616 mSuspendTimer = new QTimer( this ); 618 mSuspendTimer = new QTimer( this );
617 mAlarmTimer = new QTimer( this ); 619 mAlarmTimer = new QTimer( this );
618 mRecheckAlarmTimer = new QTimer( this ); 620 mRecheckAlarmTimer = new QTimer( this );
619 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 621 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
620 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 622 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
621 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 623 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
622 mAlarmDialog = new AlarmDialog( this ); 624 mAlarmDialog = new AlarmDialog( this );
623 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 625 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
624 mAlarmDialog->setServerNotification( false ); 626 mAlarmDialog->setServerNotification( false );
625 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 627 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
626 628
627 629
628#ifndef DESKTOP_VERSION 630#ifndef DESKTOP_VERSION
629//US listen for arriving address resultsets 631//US listen for arriving address resultsets
630 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 632 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
631 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 633 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
632#endif 634#endif
633 mDateNavigator->setCalendar( mCalendar ); 635 mDateNavigator->setCalendar( mCalendar );
634} 636}
635 637
636 638
637CalendarView::~CalendarView() 639CalendarView::~CalendarView()
638{ 640{
639 // kdDebug() << "~CalendarView()" << endl; 641 // kdDebug() << "~CalendarView()" << endl;
640 //qDebug("CalendarView::~CalendarView() "); 642 //qDebug("CalendarView::~CalendarView() ");
641 delete mDialogManager; 643 delete mDialogManager;
642 delete mViewManager; 644 delete mViewManager;
643 delete mStorage; 645 delete mStorage;
644 delete mDateFrame ; 646 delete mDateFrame ;
645 delete beamDialog;
646 delete mEventViewerDialog; 647 delete mEventViewerDialog;
647 //kdDebug() << "~CalendarView() done" << endl; 648 //kdDebug() << "~CalendarView() done" << endl;
648} 649}
650void CalendarView::setScrollBarStep(int val )
651{
652 mDateScrollBar->setLineStep ( val );
653}
654void CalendarView::scrollBarValue(int val )
655{
656 static bool block = false;
657 if ( block ) return;
658 block = true;
659 val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
660 //qDebug("VAL %d ",val );
661 int count = mNavigator->selectedDates().count();
662 int year = mNavigator->selectedDates().first().year();
663 int day = mNavigator->selectedDates().first().dayOfYear();
664 if ( val == day -1 ) {
665 block = false;
666 return;
667 }
668 QDate d ( year,1,1 );
669 mNavigator->selectDates( d.addDays( val ), count );
670 block = false;
671
672}
673
649void CalendarView::checkAlarms() 674void CalendarView::checkAlarms()
650{ 675{
651 KConfig *config = KOGlobals::config(); 676 KConfig *config = KOGlobals::config();
652 config->setGroup( "AppRun" ); 677 config->setGroup( "AppRun" );
653 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 678 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
654 int daysto = dt.daysTo( QDate::currentDate() ); 679 int daysto = dt.daysTo( QDate::currentDate() );
655 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 680 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
656 dt = dt.addDays( days ); 681 dt = dt.addDays( days );
657 int secto = dt.secsTo( QDateTime::currentDateTime() ); 682 int secto = dt.secsTo( QDateTime::currentDateTime() );
658 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 683 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
659 //qDebug("KO: Reading program stop %d ", secs); 684 //qDebug("KO: Reading program stop %d ", secs);
660 //secs -= ( 3600 * 24*3 ); // debug only 685 //secs -= ( 3600 * 24*3 ); // debug only
661 QDateTime latest = dt.addSecs ( secs ); 686 QDateTime latest = dt.addSecs ( secs );
662 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 687 qDebug("KO: Last termination on %s ", latest.toString().latin1());
663 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 688 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
664 QPtrList<Incidence> el = mCalendar->rawIncidences(); 689 QPtrList<Incidence> el = mCalendar->rawIncidences();
665 QPtrList<Incidence> al; 690 QPtrList<Incidence> al;
666 Incidence* inL = el.first(); 691 Incidence* inL = el.first();
667 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 692 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
668 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 693 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
669 while ( inL ) { 694 while ( inL ) {
670 bool ok = false; 695 bool ok = false;
671 int offset = 0; 696 int offset = 0;
672 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 697 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
673 if ( ok ) { 698 if ( ok ) {
674 //qDebug("OK %s",next.toString().latin1()); 699 //qDebug("OK %s",next.toString().latin1());
675 if ( next < cur ) { 700 if ( next < cur ) {
676 al.append( inL ); 701 al.append( inL );
677 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 702 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
678 } 703 }
679 } 704 }
680 inL = el.next(); 705 inL = el.next();
681 } 706 }
682 if ( al.count() ) { 707 if ( al.count() ) {
683 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 708 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
684 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 709 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
685 QVBoxLayout* lay = new QVBoxLayout( dia ); 710 QVBoxLayout* lay = new QVBoxLayout( dia );
686 lay->setSpacing( 0 ); 711 lay->setSpacing( 0 );
687 lay->setMargin( 0 ); 712 lay->setMargin( 0 );
688 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 713 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
689 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 714 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
690 lay->addWidget( matb ); 715 lay->addWidget( matb );
691 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 716 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
692 int wid = 210; 717 int wid = 210;
693 int x = QApplication::desktop()->width() - wid - 7; 718 int x = QApplication::desktop()->width() - wid - 7;
694 int y = QApplication::desktop()->height() - wid - 70; 719 int y = QApplication::desktop()->height() - wid - 70;
695 dia->setGeometry ( x,y,wid,wid); 720 dia->setGeometry ( x,y,wid,wid);
696 } else { 721 } else {
697 int si = 220; 722 int si = 220;
698 if ( QApplication::desktop()->width() > 470 ) 723 if ( QApplication::desktop()->width() > 470 )
699 si = 400; 724 si = 400;
700 dia->resize(si,si/2); 725 dia->resize(si,si/2);
701 } 726 }
702 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 727 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
703 dia->show(); 728 dia->show();
704 729
705 } 730 }
706} 731}
707void CalendarView::showDay( QDate d ) 732void CalendarView::showDay( QDate d )
708{ 733{
709 dateNavigator()->blockSignals( true ); 734 dateNavigator()->blockSignals( true );
710 dateNavigator()->selectDate( d ); 735 dateNavigator()->selectDate( d );
711 dateNavigator()->blockSignals( false ); 736 dateNavigator()->blockSignals( false );
712 mViewManager->showDayView(); 737 mViewManager->showDayView();
713 //dateNavigator()->selectDate( d ); 738 //dateNavigator()->selectDate( d );
714} 739}
715void CalendarView::timerAlarm() 740void CalendarView::timerAlarm()
716{ 741{
717 //qDebug("CalendarView::timerAlarm() "); 742 //qDebug("CalendarView::timerAlarm() ");
718 computeAlarm(mAlarmNotification ); 743 computeAlarm(mAlarmNotification );
719} 744}
720 745
721void CalendarView::suspendAlarm() 746void CalendarView::suspendAlarm()
722{ 747{
723 //qDebug(" CalendarView::suspendAlarm() "); 748 //qDebug(" CalendarView::suspendAlarm() ");
724 computeAlarm(mSuspendAlarmNotification ); 749 computeAlarm(mSuspendAlarmNotification );
725 750
726} 751}
727 752
728void CalendarView::startAlarm( QString mess , QString filename) 753void CalendarView::startAlarm( QString mess , QString filename)
729{ 754{
730 755
731 topLevelWidget()->showNormal(); 756 topLevelWidget()->showNormal();
732 topLevelWidget()->setActiveWindow(); 757 topLevelWidget()->setActiveWindow();
733 topLevelWidget()->raise(); 758 topLevelWidget()->raise();
734 759
735 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 760 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
736 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 761 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
737 762
738} 763}
739 764
740void CalendarView::checkNextTimerAlarm() 765void CalendarView::checkNextTimerAlarm()
741{ 766{
742 mCalendar->checkAlarmForIncidence( 0, true ); 767 mCalendar->checkAlarmForIncidence( 0, true );
743} 768}
744 769
745void CalendarView::computeAlarm( QString msg ) 770void CalendarView::computeAlarm( QString msg )
746{ 771{
747 772
748 QString mess = msg; 773 QString mess = msg;
749 QString mAlarmMessage = mess.mid( 9 ); 774 QString mAlarmMessage = mess.mid( 9 );
750 QString filename = MainWindow::resourcePath(); 775 QString filename = MainWindow::resourcePath();
751 filename += "koalarm.wav"; 776 filename += "koalarm.wav";
752 QString tempfilename; 777 QString tempfilename;
753 if ( mess.left( 13 ) == "suspend_alarm") { 778 if ( mess.left( 13 ) == "suspend_alarm") {
754 bool error = false; 779 bool error = false;
755 int len = mess.mid( 13 ).find("+++"); 780 int len = mess.mid( 13 ).find("+++");
756 if ( len < 2 ) 781 if ( len < 2 )
757 error = true; 782 error = true;
758 else { 783 else {
759 tempfilename = mess.mid( 13, len ); 784 tempfilename = mess.mid( 13, len );
760 if ( !QFile::exists( tempfilename ) ) 785 if ( !QFile::exists( tempfilename ) )
761 error = true; 786 error = true;
762 } 787 }
763 if ( ! error ) { 788 if ( ! error ) {
764 filename = tempfilename; 789 filename = tempfilename;
765 } 790 }
766 mAlarmMessage = mess.mid( 13+len+3 ); 791 mAlarmMessage = mess.mid( 13+len+3 );
767 //qDebug("suspend file %s ",tempfilename.latin1() ); 792 //qDebug("suspend file %s ",tempfilename.latin1() );
768 startAlarm( mAlarmMessage, filename); 793 startAlarm( mAlarmMessage, filename);
769 return; 794 return;
770 } 795 }
771 if ( mess.left( 11 ) == "timer_alarm") { 796 if ( mess.left( 11 ) == "timer_alarm") {
772 //mTimerTime = 0; 797 //mTimerTime = 0;
773 startAlarm( mess.mid( 11 ), filename ); 798 startAlarm( mess.mid( 11 ), filename );
774 return; 799 return;
775 } 800 }
776 if ( mess.left( 10 ) == "proc_alarm") { 801 if ( mess.left( 10 ) == "proc_alarm") {
777 bool error = false; 802 bool error = false;
778 int len = mess.mid( 10 ).find("+++"); 803 int len = mess.mid( 10 ).find("+++");
779 if ( len < 2 ) 804 if ( len < 2 )
780 error = true; 805 error = true;
781 else { 806 else {
782 tempfilename = mess.mid( 10, len ); 807 tempfilename = mess.mid( 10, len );
783 if ( !QFile::exists( tempfilename ) ) 808 if ( !QFile::exists( tempfilename ) )
784 error = true; 809 error = true;
785 } 810 }
786 if ( error ) { 811 if ( error ) {
787 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 812 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
788 mAlarmMessage += mess.mid( 10+len+3+9 ); 813 mAlarmMessage += mess.mid( 10+len+3+9 );
789 } else { 814 } else {
790 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 815 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
791 //qDebug("-----system command %s ",tempfilename.latin1() ); 816 //qDebug("-----system command %s ",tempfilename.latin1() );
792#ifndef _WIN32_ 817#ifndef _WIN32_
793 if ( vfork () == 0 ) { 818 if ( vfork () == 0 ) {
794 execl ( tempfilename.latin1(), 0 ); 819 execl ( tempfilename.latin1(), 0 );
795 return; 820 return;
796 } 821 }
797#else 822#else
798 QProcess* p = new QProcess(); 823 QProcess* p = new QProcess();
799 p->addArgument( tempfilename.latin1() ); 824 p->addArgument( tempfilename.latin1() );
800 p->start(); 825 p->start();
801 return; 826 return;
802#endif 827#endif
803 828
804 return; 829 return;
805 } 830 }
806 831
807 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 832 //qDebug("+++++++system command %s ",tempfilename.latin1() );
808 } 833 }
809 if ( mess.left( 11 ) == "audio_alarm") { 834 if ( mess.left( 11 ) == "audio_alarm") {
810 bool error = false; 835 bool error = false;
811 int len = mess.mid( 11 ).find("+++"); 836 int len = mess.mid( 11 ).find("+++");
812 if ( len < 2 ) 837 if ( len < 2 )
813 error = true; 838 error = true;
814 else { 839 else {
815 tempfilename = mess.mid( 11, len ); 840 tempfilename = mess.mid( 11, len );
816 if ( !QFile::exists( tempfilename ) ) 841 if ( !QFile::exists( tempfilename ) )
817 error = true; 842 error = true;
818 } 843 }
819 if ( ! error ) { 844 if ( ! error ) {
820 filename = tempfilename; 845 filename = tempfilename;
821 } 846 }
822 mAlarmMessage = mess.mid( 11+len+3+9 ); 847 mAlarmMessage = mess.mid( 11+len+3+9 );
823 //qDebug("audio file command %s ",tempfilename.latin1() ); 848 //qDebug("audio file command %s ",tempfilename.latin1() );
824 } 849 }
825 if ( mess.left( 9 ) == "cal_alarm") { 850 if ( mess.left( 9 ) == "cal_alarm") {
826 mAlarmMessage = mess.mid( 9 ) ; 851 mAlarmMessage = mess.mid( 9 ) ;
827 } 852 }
828 853
829 startAlarm( mAlarmMessage, filename ); 854 startAlarm( mAlarmMessage, filename );
830 855
831 856
832} 857}
833 858
834void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 859void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
835{ 860{
836 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 861 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
837 862
838 mSuspendAlarmNotification = noti; 863 mSuspendAlarmNotification = noti;
839 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 864 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
840 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 865 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
841 mSuspendTimer->start( ms , true ); 866 mSuspendTimer->start( ms , true );
842 867
843} 868}
844 869
845void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 870void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
846{ 871{
847 mNextAlarmDateTime = qdt; 872 mNextAlarmDateTime = qdt;
848 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 873 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
849 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 874 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
850#ifndef DESKTOP_VERSION 875#ifndef DESKTOP_VERSION
851 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 876 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
852#endif 877#endif
853 return; 878 return;
854 } 879 }
855 int maxSec; 880 int maxSec;
856 //maxSec = 5; //testing only 881 //maxSec = 5; //testing only
857 maxSec = 86400+3600; // one day+1hour 882 maxSec = 86400+3600; // one day+1hour
858 mAlarmNotification = noti; 883 mAlarmNotification = noti;
859 int sec = QDateTime::currentDateTime().secsTo( qdt ); 884 int sec = QDateTime::currentDateTime().secsTo( qdt );
860 if ( sec > maxSec ) { 885 if ( sec > maxSec ) {
861 mRecheckAlarmTimer->start( maxSec * 1000 ); 886 mRecheckAlarmTimer->start( maxSec * 1000 );
862 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 887 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
863 return; 888 return;
864 } else { 889 } else {
865 mRecheckAlarmTimer->stop(); 890 mRecheckAlarmTimer->stop();
866 } 891 }
867 //qDebug("Alarm timer started with secs: %d ", sec); 892 //qDebug("Alarm timer started with secs: %d ", sec);
868 mAlarmTimer->start( sec *1000 , true ); 893 mAlarmTimer->start( sec *1000 , true );
869 894
870} 895}
871// called by mRecheckAlarmTimer to get next alarm 896// called by mRecheckAlarmTimer to get next alarm
872// we need this, because a QTimer has only a max range of 25 days 897// we need this, because a QTimer has only a max range of 25 days
873void CalendarView::recheckTimerAlarm() 898void CalendarView::recheckTimerAlarm()
874{ 899{
875 mAlarmTimer->stop(); 900 mAlarmTimer->stop();
876 mRecheckAlarmTimer->stop(); 901 mRecheckAlarmTimer->stop();
877 mCalendar->checkAlarmForIncidence( 0, true ); 902 mCalendar->checkAlarmForIncidence( 0, true );
878} 903}
879void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 904void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
880{ 905{
881 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 906 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
882 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 907 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
883#ifndef DESKTOP_VERSION 908#ifndef DESKTOP_VERSION
884 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 909 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
885#endif 910#endif
886 return; 911 return;
887 } 912 }
888 mAlarmTimer->stop(); 913 mAlarmTimer->stop();
889} 914}
890void CalendarView::selectWeekNum ( int num ) 915void CalendarView::selectWeekNum ( int num )
891{ 916{
892 dateNavigator()->blockSignals( true ); 917 dateNavigator()->blockSignals( true );
893 dateNavigator()->selectWeek( num ); 918 dateNavigator()->selectWeek( num );
894 dateNavigator()->blockSignals( false ); 919 dateNavigator()->blockSignals( false );
895 mViewManager->showWeekView(); 920 mViewManager->showWeekView();
896} 921}
897KOViewManager *CalendarView::viewManager() 922KOViewManager *CalendarView::viewManager()
898{ 923{
899 return mViewManager; 924 return mViewManager;
900} 925}
901 926
902KODialogManager *CalendarView::dialogManager() 927KODialogManager *CalendarView::dialogManager()
903{ 928{
904 return mDialogManager; 929 return mDialogManager;
905} 930}
906 931
907QDate CalendarView::startDate() 932QDate CalendarView::startDate()
908{ 933{
909 DateList dates = mNavigator->selectedDates(); 934 DateList dates = mNavigator->selectedDates();
910 935
911 return dates.first(); 936 return dates.first();
912} 937}
913 938
914QDate CalendarView::endDate() 939QDate CalendarView::endDate()
915{ 940{
916 DateList dates = mNavigator->selectedDates(); 941 DateList dates = mNavigator->selectedDates();
917 942
918 return dates.last(); 943 return dates.last();
919} 944}
920 945
921 946
922void CalendarView::createPrinter() 947void CalendarView::createPrinter()
923{ 948{
924#ifndef KORG_NOPRINTER 949#ifndef KORG_NOPRINTER
925 if (!mCalPrinter) { 950 if (!mCalPrinter) {
926 mCalPrinter = new CalPrinter(this, mCalendar); 951 mCalPrinter = new CalPrinter(this, mCalendar);
927 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 952 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
928 } 953 }
929#endif 954#endif
930} 955}
931 956
932 957
933//KOPrefs::instance()->mWriteBackFile 958//KOPrefs::instance()->mWriteBackFile
934//KOPrefs::instance()->mWriteBackExistingOnly 959//KOPrefs::instance()->mWriteBackExistingOnly
935 960
936// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 961// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
937// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 962// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
938// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 963// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
939// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 964// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
940// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 965// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
941// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 966// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
942 967
943int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 968int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
944{ 969{
945 970
946 // 0 equal 971 // 0 equal
947 // 1 take local 972 // 1 take local
948 // 2 take remote 973 // 2 take remote
949 // 3 cancel 974 // 3 cancel
950 QDateTime lastSync = mLastCalendarSync; 975 QDateTime lastSync = mLastCalendarSync;
951 QDateTime localMod = local->lastModified(); 976 QDateTime localMod = local->lastModified();
952 QDateTime remoteMod = remote->lastModified(); 977 QDateTime remoteMod = remote->lastModified();
953 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 978 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
954 bool remCh, locCh; 979 bool remCh, locCh;
955 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 980 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
956 //if ( remCh ) 981 //if ( remCh )
957 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 982 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
958 locCh = ( localMod > mLastCalendarSync ); 983 locCh = ( localMod > mLastCalendarSync );
959 if ( !remCh && ! locCh ) { 984 if ( !remCh && ! locCh ) {
960 //qDebug("both not changed "); 985 //qDebug("both not changed ");
961 lastSync = localMod.addDays(1); 986 lastSync = localMod.addDays(1);
962 if ( mode <= SYNC_PREF_ASK ) 987 if ( mode <= SYNC_PREF_ASK )
963 return 0; 988 return 0;
964 } else { 989 } else {
965 if ( locCh ) { 990 if ( locCh ) {
966 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 991 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
967 lastSync = localMod.addDays( -1 ); 992 lastSync = localMod.addDays( -1 );
968 if ( !remCh ) 993 if ( !remCh )
969 remoteMod = ( lastSync.addDays( -1 ) ); 994 remoteMod = ( lastSync.addDays( -1 ) );
970 } else { 995 } else {
971 //qDebug(" not loc changed "); 996 //qDebug(" not loc changed ");
972 lastSync = localMod.addDays( 1 ); 997 lastSync = localMod.addDays( 1 );
973 if ( remCh ) 998 if ( remCh )
974 remoteMod =( lastSync.addDays( 1 ) ); 999 remoteMod =( lastSync.addDays( 1 ) );
975 1000
976 } 1001 }
977 } 1002 }
978 full = true; 1003 full = true;
979 if ( mode < SYNC_PREF_ASK ) 1004 if ( mode < SYNC_PREF_ASK )
980 mode = SYNC_PREF_ASK; 1005 mode = SYNC_PREF_ASK;
981 } else { 1006 } else {
982 if ( localMod == remoteMod ) 1007 if ( localMod == remoteMod )
983 // if ( local->revision() == remote->revision() ) 1008 // if ( local->revision() == remote->revision() )
984 return 0; 1009 return 0;
985 1010
986 } 1011 }
987 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1012 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
988 1013
989 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1014 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
990 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1015 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
991 //full = true; //debug only 1016 //full = true; //debug only
992 if ( full ) { 1017 if ( full ) {
993 bool equ = false; 1018 bool equ = false;
994 if ( local->typeID() == eventID ) { 1019 if ( local->typeID() == eventID ) {
995 equ = (*((Event*) local) == *((Event*) remote)); 1020 equ = (*((Event*) local) == *((Event*) remote));
996 } 1021 }
997 else if ( local->typeID() == todoID ) 1022 else if ( local->typeID() == todoID )
998 equ = (*((Todo*) local) == (*(Todo*) remote)); 1023 equ = (*((Todo*) local) == (*(Todo*) remote));
999 else if ( local->typeID() == journalID ) 1024 else if ( local->typeID() == journalID )
1000 equ = (*((Journal*) local) == *((Journal*) remote)); 1025 equ = (*((Journal*) local) == *((Journal*) remote));
1001 if ( equ ) { 1026 if ( equ ) {
1002 //qDebug("equal "); 1027 //qDebug("equal ");
1003 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1028 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1004 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1029 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1005 } 1030 }
1006 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1031 if ( mode < SYNC_PREF_FORCE_LOCAL )
1007 return 0; 1032 return 0;
1008 1033
1009 }//else //debug only 1034 }//else //debug only
1010 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1035 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1011 } 1036 }
1012 int result; 1037 int result;
1013 bool localIsNew; 1038 bool localIsNew;
1014 //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() ); 1039 //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() );
1015 1040
1016 1041
1017 // ************************************************ 1042 // ************************************************
1018 // ************************************************ 1043 // ************************************************
1019 // ************************************************ 1044 // ************************************************
1020 // We may have that lastSync > remoteMod AND lastSync > localMod 1045 // We may have that lastSync > remoteMod AND lastSync > localMod
1021 // BUT remoteMod != localMod 1046 // BUT remoteMod != localMod
1022 1047
1023 1048
1024 if ( full && mode < SYNC_PREF_NEWEST ) 1049 if ( full && mode < SYNC_PREF_NEWEST )
1025 mode = SYNC_PREF_ASK; 1050 mode = SYNC_PREF_ASK;
1026 1051
1027 switch( mode ) { 1052 switch( mode ) {
1028 case SYNC_PREF_LOCAL: 1053 case SYNC_PREF_LOCAL:
1029 if ( lastSync > remoteMod ) 1054 if ( lastSync > remoteMod )
1030 return 1; 1055 return 1;
1031 if ( lastSync > localMod ) 1056 if ( lastSync > localMod )
1032 return 2; 1057 return 2;
1033 return 1; 1058 return 1;
1034 break; 1059 break;
1035 case SYNC_PREF_REMOTE: 1060 case SYNC_PREF_REMOTE:
1036 if ( lastSync > localMod ) 1061 if ( lastSync > localMod )
1037 return 2; 1062 return 2;
1038 if ( lastSync > remoteMod ) 1063 if ( lastSync > remoteMod )
1039 return 1; 1064 return 1;
1040 return 2; 1065 return 2;
1041 break; 1066 break;
1042 case SYNC_PREF_NEWEST: 1067 case SYNC_PREF_NEWEST:
1043 if ( localMod >= remoteMod ) 1068 if ( localMod >= remoteMod )
1044 return 1; 1069 return 1;
1045 else 1070 else
1046 return 2; 1071 return 2;
1047 break; 1072 break;
1048 case SYNC_PREF_ASK: 1073 case SYNC_PREF_ASK:
1049 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1074 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1050 if ( lastSync > remoteMod && lastSync > localMod) 1075 if ( lastSync > remoteMod && lastSync > localMod)
1051 return 0; 1076 return 0;
1052 if ( lastSync > remoteMod ) 1077 if ( lastSync > remoteMod )
1053 return 1; 1078 return 1;
1054 if ( lastSync > localMod ) 1079 if ( lastSync > localMod )
1055 return 2; 1080 return 2;
1056 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1081 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1057 localIsNew = localMod >= remoteMod; 1082 localIsNew = localMod >= remoteMod;
1058 if ( localIsNew ) 1083 if ( localIsNew )
1059 getEventViewerDialog()->setColorMode( 1 ); 1084 getEventViewerDialog()->setColorMode( 1 );
1060 else 1085 else
1061 getEventViewerDialog()->setColorMode( 2 ); 1086 getEventViewerDialog()->setColorMode( 2 );
1062 getEventViewerDialog()->setIncidence(local); 1087 getEventViewerDialog()->setIncidence(local);
1063 if ( localIsNew ) 1088 if ( localIsNew )
1064 getEventViewerDialog()->setColorMode( 2 ); 1089 getEventViewerDialog()->setColorMode( 2 );
1065 else 1090 else
1066 getEventViewerDialog()->setColorMode( 1 ); 1091 getEventViewerDialog()->setColorMode( 1 );
1067 getEventViewerDialog()->addIncidence(remote); 1092 getEventViewerDialog()->addIncidence(remote);
1068 getEventViewerDialog()->setColorMode( 0 ); 1093 getEventViewerDialog()->setColorMode( 0 );
1069 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1094 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1070 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1095 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1071 getEventViewerDialog()->showMe(); 1096 getEventViewerDialog()->showMe();
1072 result = getEventViewerDialog()->executeS( localIsNew ); 1097 result = getEventViewerDialog()->executeS( localIsNew );
1073 return result; 1098 return result;
1074 1099
1075 break; 1100 break;
1076 case SYNC_PREF_FORCE_LOCAL: 1101 case SYNC_PREF_FORCE_LOCAL:
1077 return 1; 1102 return 1;
1078 break; 1103 break;
1079 case SYNC_PREF_FORCE_REMOTE: 1104 case SYNC_PREF_FORCE_REMOTE:
1080 return 2; 1105 return 2;
1081 break; 1106 break;
1082 1107
1083 default: 1108 default:
1084 // SYNC_PREF_TAKE_BOTH not implemented 1109 // SYNC_PREF_TAKE_BOTH not implemented
1085 break; 1110 break;
1086 } 1111 }
1087 return 0; 1112 return 0;
1088} 1113}
1089Event* CalendarView::getLastSyncEvent() 1114Event* CalendarView::getLastSyncEvent()
1090{ 1115{
1091 Event* lse; 1116 Event* lse;
1092 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1117 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1093 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1118 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1094 if (!lse) { 1119 if (!lse) {
1095 lse = new Event(); 1120 lse = new Event();
1096 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1121 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1097 QString sum = ""; 1122 QString sum = "";
1098 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1123 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1099 sum = "E: "; 1124 sum = "E: ";
1100 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1125 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1101 lse->setDtStart( mLastCalendarSync ); 1126 lse->setDtStart( mLastCalendarSync );
1102 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1127 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1103 lse->setCategories( i18n("SyncEvent") ); 1128 lse->setCategories( i18n("SyncEvent") );
1104 lse->setReadOnly( true ); 1129 lse->setReadOnly( true );
1105 mCalendar->addEvent( lse ); 1130 mCalendar->addEvent( lse );
1106 } 1131 }
1107 1132
1108 return lse; 1133 return lse;
1109 1134
1110} 1135}
1111 1136
1112// we check, if the to delete event has a id for a profile 1137// we check, if the to delete event has a id for a profile
1113// if yes, we set this id in the profile to delete 1138// if yes, we set this id in the profile to delete
1114void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1139void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1115{ 1140{
1116 if ( lastSync.count() == 0 ) { 1141 if ( lastSync.count() == 0 ) {
1117 //qDebug(" lastSync.count() == 0"); 1142 //qDebug(" lastSync.count() == 0");
1118 return; 1143 return;
1119 } 1144 }
1120 if ( toDelete->typeID() == journalID ) 1145 if ( toDelete->typeID() == journalID )
1121 return; 1146 return;
1122 1147
1123 Event* eve = lastSync.first(); 1148 Event* eve = lastSync.first();
1124 1149
1125 while ( eve ) { 1150 while ( eve ) {
1126 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1151 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1127 if ( !id.isEmpty() ) { 1152 if ( !id.isEmpty() ) {
1128 QString des = eve->description(); 1153 QString des = eve->description();
1129 QString pref = "e"; 1154 QString pref = "e";
1130 if ( toDelete->typeID() == todoID ) 1155 if ( toDelete->typeID() == todoID )
1131 pref = "t"; 1156 pref = "t";
1132 des += pref+ id + ","; 1157 des += pref+ id + ",";
1133 eve->setReadOnly( false ); 1158 eve->setReadOnly( false );
1134 eve->setDescription( des ); 1159 eve->setDescription( des );
1135 //qDebug("setdes %s ", des.latin1()); 1160 //qDebug("setdes %s ", des.latin1());
1136 eve->setReadOnly( true ); 1161 eve->setReadOnly( true );
1137 } 1162 }
1138 eve = lastSync.next(); 1163 eve = lastSync.next();
1139 } 1164 }
1140 1165
1141} 1166}
1142void CalendarView::checkExternalId( Incidence * inc ) 1167void CalendarView::checkExternalId( Incidence * inc )
1143{ 1168{
1144 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1169 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1145 checkExternSyncEvent( lastSync, inc ); 1170 checkExternSyncEvent( lastSync, inc );
1146 1171
1147} 1172}
1148bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1173bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1149{ 1174{
1150 bool syncOK = true; 1175 bool syncOK = true;
1151 int addedEvent = 0; 1176 int addedEvent = 0;
1152 int addedEventR = 0; 1177 int addedEventR = 0;
1153 int deletedEventR = 0; 1178 int deletedEventR = 0;
1154 int deletedEventL = 0; 1179 int deletedEventL = 0;
1155 int changedLocal = 0; 1180 int changedLocal = 0;
1156 int changedRemote = 0; 1181 int changedRemote = 0;
1157 int filteredIN = 0; 1182 int filteredIN = 0;
1158 int filteredOUT = 0; 1183 int filteredOUT = 0;
1159 //QPtrList<Event> el = local->rawEvents(); 1184 //QPtrList<Event> el = local->rawEvents();
1160 Event* eventR; 1185 Event* eventR;
1161 QString uid; 1186 QString uid;
1162 int take; 1187 int take;
1163 Event* eventL; 1188 Event* eventL;
1164 Event* eventRSync; 1189 Event* eventRSync;
1165 Event* eventLSync; 1190 Event* eventLSync;
1166 clearAllViews(); 1191 clearAllViews();
1167 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1192 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1168 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1193 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1169 bool fullDateRange = false; 1194 bool fullDateRange = false;
1170 local->resetTempSyncStat(); 1195 local->resetTempSyncStat();
1171 mLastCalendarSync = QDateTime::currentDateTime(); 1196 mLastCalendarSync = QDateTime::currentDateTime();
1172 if ( mSyncManager->syncWithDesktop() ) { 1197 if ( mSyncManager->syncWithDesktop() ) {
1173 remote->resetPilotStat(1); 1198 remote->resetPilotStat(1);
1174 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1199 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1175 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1200 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1176 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1201 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1177 } else { 1202 } else {
1178 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1203 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1179 } 1204 }
1180 } 1205 }
1181 QDateTime modifiedCalendar = mLastCalendarSync; 1206 QDateTime modifiedCalendar = mLastCalendarSync;
1182 eventLSync = getLastSyncEvent(); 1207 eventLSync = getLastSyncEvent();
1183 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1208 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1184 if ( eventR ) { 1209 if ( eventR ) {
1185 eventRSync = (Event*) eventR->clone(); 1210 eventRSync = (Event*) eventR->clone();
1186 remote->deleteEvent(eventR ); 1211 remote->deleteEvent(eventR );
1187 1212
1188 } else { 1213 } else {
1189 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1214 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1190 eventRSync = (Event*)eventLSync->clone(); 1215 eventRSync = (Event*)eventLSync->clone();
1191 } else { 1216 } else {
1192 fullDateRange = true; 1217 fullDateRange = true;
1193 eventRSync = new Event(); 1218 eventRSync = new Event();
1194 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1219 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1195 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1220 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1196 eventRSync->setDtStart( mLastCalendarSync ); 1221 eventRSync->setDtStart( mLastCalendarSync );
1197 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1222 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1198 eventRSync->setCategories( i18n("SyncEvent") ); 1223 eventRSync->setCategories( i18n("SyncEvent") );
1199 } 1224 }
1200 } 1225 }
1201 if ( eventLSync->dtStart() == mLastCalendarSync ) 1226 if ( eventLSync->dtStart() == mLastCalendarSync )
1202 fullDateRange = true; 1227 fullDateRange = true;
1203 1228
1204 if ( ! fullDateRange ) { 1229 if ( ! fullDateRange ) {
1205 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1230 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1206 1231
1207 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1232 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1208 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1233 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1209 fullDateRange = true; 1234 fullDateRange = true;
1210 } 1235 }
1211 } 1236 }
1212 if ( mSyncManager->syncWithDesktop() ) { 1237 if ( mSyncManager->syncWithDesktop() ) {
1213 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1238 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1214 } 1239 }
1215 if ( fullDateRange ) 1240 if ( fullDateRange )
1216 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1241 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1217 else 1242 else
1218 mLastCalendarSync = eventLSync->dtStart(); 1243 mLastCalendarSync = eventLSync->dtStart();
1219 // for resyncing if own file has changed 1244 // for resyncing if own file has changed
1220 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1245 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1221 mLastCalendarSync = loadedFileVersion; 1246 mLastCalendarSync = loadedFileVersion;
1222 //qDebug("setting mLastCalendarSync "); 1247 //qDebug("setting mLastCalendarSync ");
1223 } 1248 }
1224 //qDebug("*************************** "); 1249 //qDebug("*************************** ");
1225 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1250 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1226 QPtrList<Incidence> er = remote->rawIncidences(); 1251 QPtrList<Incidence> er = remote->rawIncidences();
1227 Incidence* inR = er.first(); 1252 Incidence* inR = er.first();
1228 Incidence* inL; 1253 Incidence* inL;
1229 QProgressBar bar( er.count(),0 ); 1254 QProgressBar bar( er.count(),0 );
1230 bar.setCaption (i18n("Syncing - close to abort!") ); 1255 bar.setCaption (i18n("Syncing - close to abort!") );
1231 1256
1232 // ************** setting up filter ************* 1257 // ************** setting up filter *************
1233 CalFilter *filterIN = 0; 1258 CalFilter *filterIN = 0;
1234 CalFilter *filterOUT = 0; 1259 CalFilter *filterOUT = 0;
1235 CalFilter *filter = mFilters.first(); 1260 CalFilter *filter = mFilters.first();
1236 while(filter) { 1261 while(filter) {
1237 if ( filter->name() == mSyncManager->mFilterInCal ) 1262 if ( filter->name() == mSyncManager->mFilterInCal )
1238 filterIN = filter; 1263 filterIN = filter;
1239 if ( filter->name() == mSyncManager->mFilterOutCal ) 1264 if ( filter->name() == mSyncManager->mFilterOutCal )
1240 filterOUT = filter; 1265 filterOUT = filter;
1241 filter = mFilters.next(); 1266 filter = mFilters.next();
1242 } 1267 }
1243 int w = 300; 1268 int w = 300;
1244 if ( QApplication::desktop()->width() < 320 ) 1269 if ( QApplication::desktop()->width() < 320 )
1245 w = 220; 1270 w = 220;
1246 int h = bar.sizeHint().height() ; 1271 int h = bar.sizeHint().height() ;
1247 int dw = QApplication::desktop()->width(); 1272 int dw = QApplication::desktop()->width();
1248 int dh = QApplication::desktop()->height(); 1273 int dh = QApplication::desktop()->height();
1249 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1274 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1250 bar.show(); 1275 bar.show();
1251 int modulo = (er.count()/10)+1; 1276 int modulo = (er.count()/10)+1;
1252 int incCounter = 0; 1277 int incCounter = 0;
1253 while ( inR ) { 1278 while ( inR ) {
1254 if ( ! bar.isVisible() ) 1279 if ( ! bar.isVisible() )
1255 return false; 1280 return false;
1256 if ( incCounter % modulo == 0 ) 1281 if ( incCounter % modulo == 0 )
1257 bar.setProgress( incCounter ); 1282 bar.setProgress( incCounter );
1258 ++incCounter; 1283 ++incCounter;
1259 uid = inR->uid(); 1284 uid = inR->uid();
1260 bool skipIncidence = false; 1285 bool skipIncidence = false;
1261 if ( uid.left(15) == QString("last-syncEvent-") ) 1286 if ( uid.left(15) == QString("last-syncEvent-") )
1262 skipIncidence = true; 1287 skipIncidence = true;
1263 QString idS; 1288 QString idS;
1264 qApp->processEvents(); 1289 qApp->processEvents();
1265 if ( !skipIncidence ) { 1290 if ( !skipIncidence ) {
1266 inL = local->incidence( uid ); 1291 inL = local->incidence( uid );
1267 if ( inL ) { // maybe conflict - same uid in both calendars 1292 if ( inL ) { // maybe conflict - same uid in both calendars
1268 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1293 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1269 //qDebug("take %d %s ", take, inL->summary().latin1()); 1294 //qDebug("take %d %s ", take, inL->summary().latin1());
1270 if ( take == 3 ) 1295 if ( take == 3 )
1271 return false; 1296 return false;
1272 if ( take == 1 ) {// take local ********************** 1297 if ( take == 1 ) {// take local **********************
1273 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1298 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1274 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1299 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1275 else 1300 else
1276 idS = inR->IDStr(); 1301 idS = inR->IDStr();
1277 remote->deleteIncidence( inR ); 1302 remote->deleteIncidence( inR );
1278 inR = inL->clone(); 1303 inR = inL->clone();
1279 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1304 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1280 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1305 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1281 inR->setIDStr( idS ); 1306 inR->setIDStr( idS );
1282 remote->addIncidence( inR ); 1307 remote->addIncidence( inR );
1283 if ( mSyncManager->syncWithDesktop() ) 1308 if ( mSyncManager->syncWithDesktop() )
1284 inR->setPilotId( 2 ); 1309 inR->setPilotId( 2 );
1285 ++changedRemote; 1310 ++changedRemote;
1286 } else {// take remote ********************** 1311 } else {// take remote **********************
1287 idS = inL->IDStr(); 1312 idS = inL->IDStr();
1288 int pid = inL->pilotId(); 1313 int pid = inL->pilotId();
1289 local->deleteIncidence( inL ); 1314 local->deleteIncidence( inL );
1290 inL = inR->clone(); 1315 inL = inR->clone();
1291 if ( mSyncManager->syncWithDesktop() ) 1316 if ( mSyncManager->syncWithDesktop() )
1292 inL->setPilotId( pid ); 1317 inL->setPilotId( pid );
1293 inL->setIDStr( idS ); 1318 inL->setIDStr( idS );
1294 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1319 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1295 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1320 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1296 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1321 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1297 } 1322 }
1298 local->addIncidence( inL ); 1323 local->addIncidence( inL );
1299 ++changedLocal; 1324 ++changedLocal;
1300 } 1325 }
1301 } 1326 }
1302 } else { // no conflict ********** add or delete remote 1327 } else { // no conflict ********** add or delete remote
1303 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1328 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1304 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1329 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1305 QString des = eventLSync->description(); 1330 QString des = eventLSync->description();
1306 QString pref = "e"; 1331 QString pref = "e";
1307 if ( inR->typeID() == todoID ) 1332 if ( inR->typeID() == todoID )
1308 pref = "t"; 1333 pref = "t";
1309 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1334 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1310 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1335 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1311 //remote->deleteIncidence( inR ); 1336 //remote->deleteIncidence( inR );
1312 ++deletedEventR; 1337 ++deletedEventR;
1313 } else { 1338 } else {
1314 inR->setLastModified( modifiedCalendar ); 1339 inR->setLastModified( modifiedCalendar );
1315 inL = inR->clone(); 1340 inL = inR->clone();
1316 inL->setIDStr( ":" ); 1341 inL->setIDStr( ":" );
1317 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1342 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1318 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1343 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1319 local->addIncidence( inL ); 1344 local->addIncidence( inL );
1320 ++addedEvent; 1345 ++addedEvent;
1321 1346
1322 } 1347 }
1323 } else { 1348 } else {
1324 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1349 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1325 inR->setLastModified( modifiedCalendar ); 1350 inR->setLastModified( modifiedCalendar );
1326 inL = inR->clone(); 1351 inL = inR->clone();
1327 inL->setIDStr( ":" ); 1352 inL->setIDStr( ":" );
1328 local->addIncidence( inL ); 1353 local->addIncidence( inL );
1329 ++addedEvent; 1354 ++addedEvent;
1330 1355
1331 } else { 1356 } else {
1332 checkExternSyncEvent(eventRSyncSharp, inR); 1357 checkExternSyncEvent(eventRSyncSharp, inR);
1333 remote->deleteIncidence( inR ); 1358 remote->deleteIncidence( inR );
1334 ++deletedEventR; 1359 ++deletedEventR;
1335 } 1360 }
1336 } 1361 }
1337 } else { 1362 } else {
1338 ++filteredIN; 1363 ++filteredIN;
1339 } 1364 }
1340 } 1365 }
1341 } 1366 }
1342 inR = er.next(); 1367 inR = er.next();
1343 } 1368 }
1344 QPtrList<Incidence> el = local->rawIncidences(); 1369 QPtrList<Incidence> el = local->rawIncidences();
1345 inL = el.first(); 1370 inL = el.first();
1346 modulo = (el.count()/10)+1; 1371 modulo = (el.count()/10)+1;
1347 bar.setCaption (i18n("Add / remove events") ); 1372 bar.setCaption (i18n("Add / remove events") );
1348 bar.setTotalSteps ( el.count() ) ; 1373 bar.setTotalSteps ( el.count() ) ;
1349 bar.show(); 1374 bar.show();
1350 incCounter = 0; 1375 incCounter = 0;
1351 1376
1352 while ( inL ) { 1377 while ( inL ) {
1353 1378
1354 qApp->processEvents(); 1379 qApp->processEvents();
1355 if ( ! bar.isVisible() ) 1380 if ( ! bar.isVisible() )
1356 return false; 1381 return false;
1357 if ( incCounter % modulo == 0 ) 1382 if ( incCounter % modulo == 0 )
1358 bar.setProgress( incCounter ); 1383 bar.setProgress( incCounter );
1359 ++incCounter; 1384 ++incCounter;
1360 uid = inL->uid(); 1385 uid = inL->uid();
1361 bool skipIncidence = false; 1386 bool skipIncidence = false;
1362 if ( uid.left(15) == QString("last-syncEvent-") ) 1387 if ( uid.left(15) == QString("last-syncEvent-") )
1363 skipIncidence = true; 1388 skipIncidence = true;
1364 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1389 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1365 skipIncidence = true; 1390 skipIncidence = true;
1366 if ( !skipIncidence ) { 1391 if ( !skipIncidence ) {
1367 inR = remote->incidence( uid ); 1392 inR = remote->incidence( uid );
1368 if ( ! inR ) { 1393 if ( ! inR ) {
1369 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1394 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1370 // no conflict ********** add or delete local 1395 // no conflict ********** add or delete local
1371 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1396 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1372 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1397 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1373 checkExternSyncEvent(eventLSyncSharp, inL); 1398 checkExternSyncEvent(eventLSyncSharp, inL);
1374 local->deleteIncidence( inL ); 1399 local->deleteIncidence( inL );
1375 ++deletedEventL; 1400 ++deletedEventL;
1376 } else { 1401 } else {
1377 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1402 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1378 inL->removeID(mCurrentSyncDevice ); 1403 inL->removeID(mCurrentSyncDevice );
1379 ++addedEventR; 1404 ++addedEventR;
1380 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1405 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1381 inL->setLastModified( modifiedCalendar ); 1406 inL->setLastModified( modifiedCalendar );
1382 inR = inL->clone(); 1407 inR = inL->clone();
1383 inR->setIDStr( ":" ); 1408 inR->setIDStr( ":" );
1384 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1409 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1385 remote->addIncidence( inR ); 1410 remote->addIncidence( inR );
1386 } 1411 }
1387 } 1412 }
1388 } else { 1413 } else {
1389 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1414 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1390 checkExternSyncEvent(eventLSyncSharp, inL); 1415 checkExternSyncEvent(eventLSyncSharp, inL);
1391 local->deleteIncidence( inL ); 1416 local->deleteIncidence( inL );
1392 ++deletedEventL; 1417 ++deletedEventL;
1393 } else { 1418 } else {
1394 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1419 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1395 ++addedEventR; 1420 ++addedEventR;
1396 inL->setLastModified( modifiedCalendar ); 1421 inL->setLastModified( modifiedCalendar );
1397 inR = inL->clone(); 1422 inR = inL->clone();
1398 inR->setIDStr( ":" ); 1423 inR->setIDStr( ":" );
1399 remote->addIncidence( inR ); 1424 remote->addIncidence( inR );
1400 } 1425 }
1401 } 1426 }
1402 } 1427 }
1403 } else { 1428 } else {
1404 ++filteredOUT; 1429 ++filteredOUT;
1405 } 1430 }
1406 } 1431 }
1407 } 1432 }
1408 inL = el.next(); 1433 inL = el.next();
1409 } 1434 }
1410 int delFut = 0; 1435 int delFut = 0;
1411 int remRem = 0; 1436 int remRem = 0;
1412 if ( mSyncManager->mWriteBackInFuture ) { 1437 if ( mSyncManager->mWriteBackInFuture ) {
1413 er = remote->rawIncidences(); 1438 er = remote->rawIncidences();
1414 remRem = er.count(); 1439 remRem = er.count();
1415 inR = er.first(); 1440 inR = er.first();
1416 QDateTime dt; 1441 QDateTime dt;
@@ -1702,1950 +1727,1935 @@ void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthd
1702 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1727 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1703 qApp->processEvents(); 1728 qApp->processEvents();
1704 1729
1705 QDate birthday; 1730 QDate birthday;
1706 QDate anniversary; 1731 QDate anniversary;
1707 QString realName; 1732 QString realName;
1708 QString email; 1733 QString email;
1709 QString assembledName; 1734 QString assembledName;
1710 QString uid; 1735 QString uid;
1711 bool ok = true; 1736 bool ok = true;
1712 for ( int i = 0; i < count; i++) 1737 for ( int i = 0; i < count; i++)
1713 { 1738 {
1714 if ( ! bar.isVisible() ) 1739 if ( ! bar.isVisible() )
1715 return; 1740 return;
1716 bar.setProgress( i ); 1741 bar.setProgress( i );
1717 qApp->processEvents(); 1742 qApp->processEvents();
1718 1743
1719 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1744 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1720 if (!ok) { 1745 if (!ok) {
1721 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1746 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1722 } 1747 }
1723 1748
1724 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1749 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1725 if (!ok) { 1750 if (!ok) {
1726 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1751 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1727 } 1752 }
1728 realName = realNameList[i]; 1753 realName = realNameList[i];
1729 email = emailList[i]; 1754 email = emailList[i];
1730 assembledName = assembledNameList[i]; 1755 assembledName = assembledNameList[i];
1731 uid = uidList[i]; 1756 uid = uidList[i];
1732 //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() ); 1757 //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() );
1733 1758
1734 if ( birthday.isValid() ){ 1759 if ( birthday.isValid() ){
1735 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1760 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1736 KCal::Attendee::ReqParticipant,uid) ; 1761 KCal::Attendee::ReqParticipant,uid) ;
1737 if ( addAnniversary( birthday, assembledName, a, true ) ) 1762 if ( addAnniversary( birthday, assembledName, a, true ) )
1738 ++addCount; 1763 ++addCount;
1739 } 1764 }
1740 1765
1741 if ( anniversary.isValid() ){ 1766 if ( anniversary.isValid() ){
1742 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1767 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1743 KCal::Attendee::ReqParticipant,uid) ; 1768 KCal::Attendee::ReqParticipant,uid) ;
1744 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1769 if ( addAnniversary( anniversary, assembledName, a, false ) )
1745 ++addCount; 1770 ++addCount;
1746 } 1771 }
1747 } 1772 }
1748 1773
1749 mCalendar->setDefaultCalendar( curCal ); 1774 mCalendar->setDefaultCalendar( curCal );
1750 updateView(); 1775 updateView();
1751 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1776 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1752 1777
1753 } 1778 }
1754 1779
1755} 1780}
1756 1781
1757 1782
1758 1783
1759bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1784bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1760{ 1785{
1761 //qDebug("addAnni "); 1786 //qDebug("addAnni ");
1762 Event * ev = new Event(); 1787 Event * ev = new Event();
1763 ev->setOrganizer(KOPrefs::instance()->email()); 1788 ev->setOrganizer(KOPrefs::instance()->email());
1764 if ( a ) { 1789 if ( a ) {
1765 ev->addAttendee( a ); 1790 ev->addAttendee( a );
1766 } 1791 }
1767 QString kind; 1792 QString kind;
1768 if ( birthday ) { 1793 if ( birthday ) {
1769 kind = i18n( "Birthday" ); 1794 kind = i18n( "Birthday" );
1770 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1795 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1771 } 1796 }
1772 else { 1797 else {
1773 kind = i18n( "Anniversary" ); 1798 kind = i18n( "Anniversary" );
1774 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1799 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1775 } 1800 }
1776 ev->setCategories( kind ); 1801 ev->setCategories( kind );
1777 ev->setDtStart( QDateTime(date) ); 1802 ev->setDtStart( QDateTime(date) );
1778 ev->setDtEnd( QDateTime(date) ); 1803 ev->setDtEnd( QDateTime(date) );
1779 ev->setFloats( true ); 1804 ev->setFloats( true );
1780 Recurrence * rec = ev->recurrence(); 1805 Recurrence * rec = ev->recurrence();
1781 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1806 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1782 rec->addYearlyNum( date.month() ); 1807 rec->addYearlyNum( date.month() );
1783 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1808 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1784 delete ev; 1809 delete ev;
1785 return false; 1810 return false;
1786 } 1811 }
1787 return true; 1812 return true;
1788 1813
1789} 1814}
1790bool CalendarView::importQtopia( const QString &categories, 1815bool CalendarView::importQtopia( const QString &categories,
1791 const QString &datebook, 1816 const QString &datebook,
1792 const QString &todolist ) 1817 const QString &todolist )
1793{ 1818{
1794 1819
1795 QtopiaFormat qtopiaFormat; 1820 QtopiaFormat qtopiaFormat;
1796 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1821 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1797 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1822 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1798 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1823 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1799 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1824 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1800 1825
1801 updateView(); 1826 updateView();
1802 return true; 1827 return true;
1803 1828
1804#if 0 1829#if 0
1805 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1830 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1806 mCurrentSyncDevice = "qtopia-XML"; 1831 mCurrentSyncDevice = "qtopia-XML";
1807 if ( mSyncManager->mAskForPreferences ) 1832 if ( mSyncManager->mAskForPreferences )
1808 edit_sync_options(); 1833 edit_sync_options();
1809 qApp->processEvents(); 1834 qApp->processEvents();
1810 CalendarLocal* calendar = new CalendarLocal(); 1835 CalendarLocal* calendar = new CalendarLocal();
1811 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1836 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1812 bool syncOK = false; 1837 bool syncOK = false;
1813 QtopiaFormat qtopiaFormat; 1838 QtopiaFormat qtopiaFormat;
1814 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1839 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1815 bool loadOk = true; 1840 bool loadOk = true;
1816 if ( !categories.isEmpty() ) 1841 if ( !categories.isEmpty() )
1817 loadOk = qtopiaFormat.load( calendar, categories ); 1842 loadOk = qtopiaFormat.load( calendar, categories );
1818 if ( loadOk && !datebook.isEmpty() ) 1843 if ( loadOk && !datebook.isEmpty() )
1819 loadOk = qtopiaFormat.load( calendar, datebook ); 1844 loadOk = qtopiaFormat.load( calendar, datebook );
1820 if ( loadOk && !todolist.isEmpty() ) 1845 if ( loadOk && !todolist.isEmpty() )
1821 loadOk = qtopiaFormat.load( calendar, todolist ); 1846 loadOk = qtopiaFormat.load( calendar, todolist );
1822 1847
1823 if ( loadOk ) { 1848 if ( loadOk ) {
1824 getEventViewerDialog()->setSyncMode( true ); 1849 getEventViewerDialog()->setSyncMode( true );
1825 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1850 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1826 getEventViewerDialog()->setSyncMode( false ); 1851 getEventViewerDialog()->setSyncMode( false );
1827 qApp->processEvents(); 1852 qApp->processEvents();
1828 if ( syncOK ) { 1853 if ( syncOK ) {
1829 if ( mSyncManager->mWriteBackFile ) 1854 if ( mSyncManager->mWriteBackFile )
1830 { 1855 {
1831 // write back XML file 1856 // write back XML file
1832 1857
1833 } 1858 }
1834 setModified( true ); 1859 setModified( true );
1835 } 1860 }
1836 } else { 1861 } else {
1837 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1862 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1838 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1863 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1839 question, i18n("Ok")) ; 1864 question, i18n("Ok")) ;
1840 } 1865 }
1841 delete calendar; 1866 delete calendar;
1842 updateView(); 1867 updateView();
1843 return syncOK; 1868 return syncOK;
1844 1869
1845 1870
1846#endif 1871#endif
1847 1872
1848} 1873}
1849 1874
1850void CalendarView::setSyncEventsReadOnly() 1875void CalendarView::setSyncEventsReadOnly()
1851{ 1876{
1852 mCalendar->setSyncEventsReadOnly(); 1877 mCalendar->setSyncEventsReadOnly();
1853} 1878}
1854 1879
1855bool CalendarView::loadCalendars() 1880bool CalendarView::loadCalendars()
1856{ 1881{
1857 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1882 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1858 KopiCalendarFile * cal = calendars.first(); 1883 KopiCalendarFile * cal = calendars.first();
1859 mCalendar->setDefaultCalendar( 1 ); 1884 mCalendar->setDefaultCalendar( 1 );
1860 openCalendar( MainWindow::defaultFileName(), false ); 1885 openCalendar( MainWindow::defaultFileName(), false );
1861 cal = calendars.next(); 1886 cal = calendars.next();
1862 while ( cal ) { 1887 while ( cal ) {
1863 addCalendar( cal ); 1888 addCalendar( cal );
1864 cal = calendars.next(); 1889 cal = calendars.next();
1865 } 1890 }
1866 restoreCalendarSettings(); 1891 restoreCalendarSettings();
1867 return true; 1892 return true;
1868} 1893}
1869bool CalendarView::restoreCalendarSettings() 1894bool CalendarView::restoreCalendarSettings()
1870{ 1895{
1871 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1896 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1872 KopiCalendarFile * cal = calendars.first(); 1897 KopiCalendarFile * cal = calendars.first();
1873 while ( cal ) { 1898 while ( cal ) {
1874 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1899 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1875 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1900 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1876 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1901 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1877 if ( cal->isStandard ) 1902 if ( cal->isStandard )
1878 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1903 mCalendar->setDefaultCalendar( cal->mCalNumber );
1879 cal = calendars.next(); 1904 cal = calendars.next();
1880 } 1905 }
1881 setSyncEventsReadOnly(); 1906 setSyncEventsReadOnly();
1882 mCalendar->reInitAlarmSettings(); 1907 mCalendar->reInitAlarmSettings();
1883 updateUnmanagedViews(); 1908 updateUnmanagedViews();
1884 updateView(); 1909 updateView();
1885 return true; 1910 return true;
1886} 1911}
1887void CalendarView::addCalendarId( int id ) 1912void CalendarView::addCalendarId( int id )
1888{ 1913{
1889 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1914 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1890 addCalendar( cal ); 1915 addCalendar( cal );
1891} 1916}
1892bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1917bool CalendarView::addCalendar( KopiCalendarFile * cal )
1893{ 1918{
1894 cal->mErrorOnLoad = false; 1919 cal->mErrorOnLoad = false;
1895 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1920 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1896 cal->mLoadDt = QDateTime::currentDateTime(); 1921 cal->mLoadDt = QDateTime::currentDateTime();
1897 return true; 1922 return true;
1898 } 1923 }
1899 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1924 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1900 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); 1925 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1901 cal->mErrorOnLoad = true; 1926 cal->mErrorOnLoad = true;
1902 return false; 1927 return false;
1903} 1928}
1904bool CalendarView::openCalendar(QString filename, bool merge) 1929bool CalendarView::openCalendar(QString filename, bool merge)
1905{ 1930{
1906 1931
1907 if (filename.isEmpty()) { 1932 if (filename.isEmpty()) {
1908 return false; 1933 return false;
1909 } 1934 }
1910 1935
1911 if (!QFile::exists(filename)) { 1936 if (!QFile::exists(filename)) {
1912 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1937 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1913 return false; 1938 return false;
1914 } 1939 }
1915 1940
1916 globalFlagBlockAgenda = 1; 1941 globalFlagBlockAgenda = 1;
1917 clearAllViews(); 1942 clearAllViews();
1918 if (!merge) { 1943 if (!merge) {
1919 mViewManager->setDocumentId( filename ); 1944 mViewManager->setDocumentId( filename );
1920 mCalendar->close(); 1945 mCalendar->close();
1921 } 1946 }
1922 mStorage->setFileName( filename ); 1947 mStorage->setFileName( filename );
1923 1948
1924 if ( mStorage->load() ) { 1949 if ( mStorage->load() ) {
1925 if ( merge ) ;//setModified( true ); 1950 if ( merge ) ;//setModified( true );
1926 else { 1951 else {
1927 //setModified( true ); 1952 //setModified( true );
1928 mViewManager->setDocumentId( filename ); 1953 mViewManager->setDocumentId( filename );
1929 mDialogManager->setDocumentId( filename ); 1954 mDialogManager->setDocumentId( filename );
1930 mTodoList->setDocumentId( filename ); 1955 mTodoList->setDocumentId( filename );
1931 } 1956 }
1932 globalFlagBlockAgenda = 2; 1957 globalFlagBlockAgenda = 2;
1933 // if ( getLastSyncEvent() ) 1958 // if ( getLastSyncEvent() )
1934 // getLastSyncEvent()->setReadOnly( true ); 1959 // getLastSyncEvent()->setReadOnly( true );
1935 mCalendar->reInitAlarmSettings(); 1960 mCalendar->reInitAlarmSettings();
1936 setSyncEventsReadOnly(); 1961 setSyncEventsReadOnly();
1937 updateUnmanagedViews(); 1962 updateUnmanagedViews();
1938 updateView(); 1963 updateView();
1939 if ( filename != MainWindow::defaultFileName() ) { 1964 if ( filename != MainWindow::defaultFileName() ) {
1940 saveCalendar( MainWindow::defaultFileName() ); 1965 saveCalendar( MainWindow::defaultFileName() );
1941 } else { 1966 } else {
1942 QFileInfo finf ( MainWindow::defaultFileName()); 1967 QFileInfo finf ( MainWindow::defaultFileName());
1943 if ( finf.exists() ) { 1968 if ( finf.exists() ) {
1944 setLoadedFileVersion( finf.lastModified () ); 1969 setLoadedFileVersion( finf.lastModified () );
1945 } 1970 }
1946 } 1971 }
1947 return true; 1972 return true;
1948 } else { 1973 } else {
1949 // while failing to load, the calendar object could 1974 // while failing to load, the calendar object could
1950 // have become partially populated. Clear it out. 1975 // have become partially populated. Clear it out.
1951 if ( !merge ) { 1976 if ( !merge ) {
1952 mCalendar->close(); 1977 mCalendar->close();
1953 mViewManager->setDocumentId( filename ); 1978 mViewManager->setDocumentId( filename );
1954 mDialogManager->setDocumentId( filename ); 1979 mDialogManager->setDocumentId( filename );
1955 mTodoList->setDocumentId( filename ); 1980 mTodoList->setDocumentId( filename );
1956 } 1981 }
1957 1982
1958 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1983 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1959 1984
1960 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1985 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1961 globalFlagBlockAgenda = 2; 1986 globalFlagBlockAgenda = 2;
1962 mCalendar->reInitAlarmSettings(); 1987 mCalendar->reInitAlarmSettings();
1963 setSyncEventsReadOnly(); 1988 setSyncEventsReadOnly();
1964 updateUnmanagedViews(); 1989 updateUnmanagedViews();
1965 updateView(); 1990 updateView();
1966 } 1991 }
1967 return false; 1992 return false;
1968} 1993}
1969void CalendarView::showOpenError() 1994void CalendarView::showOpenError()
1970{ 1995{
1971 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1996 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1972} 1997}
1973void CalendarView::setLoadedFileVersion(QDateTime dt) 1998void CalendarView::setLoadedFileVersion(QDateTime dt)
1974{ 1999{
1975 loadedFileVersion = dt; 2000 loadedFileVersion = dt;
1976} 2001}
1977bool CalendarView::checkFileChanged(QString fn) 2002bool CalendarView::checkFileChanged(QString fn)
1978{ 2003{
1979 QFileInfo finf ( fn ); 2004 QFileInfo finf ( fn );
1980 if ( !finf.exists() ) 2005 if ( !finf.exists() )
1981 return true; 2006 return true;
1982 QDateTime dt = finf.lastModified (); 2007 QDateTime dt = finf.lastModified ();
1983 if ( dt <= loadedFileVersion ) 2008 if ( dt <= loadedFileVersion )
1984 return false; 2009 return false;
1985 return true; 2010 return true;
1986 2011
1987} 2012}
1988void CalendarView::watchSavedFile() 2013void CalendarView::watchSavedFile()
1989{ 2014{
1990 QFileInfo finf ( MainWindow::defaultFileName()); 2015 QFileInfo finf ( MainWindow::defaultFileName());
1991 if ( !finf.exists() ) 2016 if ( !finf.exists() )
1992 return; 2017 return;
1993 QDateTime dt = finf.lastModified (); 2018 QDateTime dt = finf.lastModified ();
1994 if ( dt < loadedFileVersion ) { 2019 if ( dt < loadedFileVersion ) {
1995 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2020 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1996 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2021 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1997 return; 2022 return;
1998 } 2023 }
1999 loadedFileVersion = dt; 2024 loadedFileVersion = dt;
2000} 2025}
2001bool CalendarView::checkAllFileVersions() 2026bool CalendarView::checkAllFileVersions()
2002{ 2027{
2003 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2028 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2004 KopiCalendarFile * cal = calendars.first(); 2029 KopiCalendarFile * cal = calendars.first();
2005 mCalendar->setDefaultCalendar( 1 ); 2030 mCalendar->setDefaultCalendar( 1 );
2006 mCalendar->setDefaultCalendarEnabledOnly(); 2031 mCalendar->setDefaultCalendarEnabledOnly();
2007 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2032 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2008 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2033 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2009 restoreCalendarSettings(); 2034 restoreCalendarSettings();
2010 return false; 2035 return false;
2011 } 2036 }
2012 } 2037 }
2013 cal = calendars.next(); 2038 cal = calendars.next();
2014 QDateTime storeTemp = loadedFileVersion; 2039 QDateTime storeTemp = loadedFileVersion;
2015 while ( cal ) { 2040 while ( cal ) {
2016 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2041 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2017 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2042 mCalendar->setDefaultCalendar( cal->mCalNumber );
2018 mCalendar->setDefaultCalendarEnabledOnly(); 2043 mCalendar->setDefaultCalendarEnabledOnly();
2019 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2044 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2020 if ( !checkFileVersion(cal->mFileName )) { 2045 if ( !checkFileVersion(cal->mFileName )) {
2021 loadedFileVersion = storeTemp; 2046 loadedFileVersion = storeTemp;
2022 restoreCalendarSettings(); 2047 restoreCalendarSettings();
2023 return false; 2048 return false;
2024 } 2049 }
2025 } 2050 }
2026 cal = calendars.next(); 2051 cal = calendars.next();
2027 } 2052 }
2028 loadedFileVersion = storeTemp; 2053 loadedFileVersion = storeTemp;
2029 return true; 2054 return true;
2030} 2055}
2031bool CalendarView::checkFileVersion(QString fn) 2056bool CalendarView::checkFileVersion(QString fn)
2032{ 2057{
2033 QFileInfo finf ( fn ); 2058 QFileInfo finf ( fn );
2034 if ( !finf.exists() ) 2059 if ( !finf.exists() )
2035 return true; 2060 return true;
2036 QDateTime dt = finf.lastModified (); 2061 QDateTime dt = finf.lastModified ();
2037 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2062 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2038 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2063 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2039 if ( dt <= loadedFileVersion ) 2064 if ( dt <= loadedFileVersion )
2040 return true; 2065 return true;
2041 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2066 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2042 i18n("KO/Pi Warning"),i18n("Overwrite"), 2067 i18n("KO/Pi Warning"),i18n("Overwrite"),
2043 i18n("Sync+save")); 2068 i18n("Sync+save"));
2044 2069
2045 if ( km == KMessageBox::Cancel ) 2070 if ( km == KMessageBox::Cancel )
2046 return false; 2071 return false;
2047 if ( km == KMessageBox::Yes ) 2072 if ( km == KMessageBox::Yes )
2048 return true; 2073 return true;
2049 2074
2050 setSyncDevice("deleteaftersync" ); 2075 setSyncDevice("deleteaftersync" );
2051 mSyncManager->mAskForPreferences = true; 2076 mSyncManager->mAskForPreferences = true;
2052 mSyncManager->mSyncAlgoPrefs = 3; 2077 mSyncManager->mSyncAlgoPrefs = 3;
2053 mSyncManager->mWriteBackFile = false; 2078 mSyncManager->mWriteBackFile = false;
2054 mSyncManager->mWriteBackExistingOnly = false; 2079 mSyncManager->mWriteBackExistingOnly = false;
2055 mSyncManager->mShowSyncSummary = false; 2080 mSyncManager->mShowSyncSummary = false;
2056 syncCalendar( fn, 3 ); 2081 syncCalendar( fn, 3 );
2057 Event * e = getLastSyncEvent(); 2082 Event * e = getLastSyncEvent();
2058 if ( e ) 2083 if ( e )
2059 mCalendar->deleteEvent( e ); 2084 mCalendar->deleteEvent( e );
2060 return true; 2085 return true;
2061} 2086}
2062bool CalendarView::saveCalendars() 2087bool CalendarView::saveCalendars()
2063{ 2088{
2064 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2089 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2065 KopiCalendarFile * cal = calendars.first(); 2090 KopiCalendarFile * cal = calendars.first();
2066 mCalendar->setDefaultCalendar( 1 ); 2091 mCalendar->setDefaultCalendar( 1 );
2067 mCalendar->setDefaultCalendarEnabledOnly(); 2092 mCalendar->setDefaultCalendarEnabledOnly();
2068 saveCalendar( MainWindow::defaultFileName() ); 2093 saveCalendar( MainWindow::defaultFileName() );
2069 cal = calendars.next(); 2094 cal = calendars.next();
2070 while ( cal ) { 2095 while ( cal ) {
2071 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2096 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2072 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2097 mCalendar->setDefaultCalendar( cal->mCalNumber );
2073 mCalendar->setDefaultCalendarEnabledOnly(); 2098 mCalendar->setDefaultCalendarEnabledOnly();
2074 if ( saveCalendar( cal->mFileName ) ) 2099 if ( saveCalendar( cal->mFileName ) )
2075 cal->mLoadDt = QDateTime::currentDateTime(); 2100 cal->mLoadDt = QDateTime::currentDateTime();
2076 } 2101 }
2077 cal = calendars.next(); 2102 cal = calendars.next();
2078 } 2103 }
2079 restoreCalendarSettings(); 2104 restoreCalendarSettings();
2080 return true; 2105 return true;
2081} 2106}
2082bool CalendarView::saveCalendar( QString filename ) 2107bool CalendarView::saveCalendar( QString filename )
2083{ 2108{
2084 2109
2085 // Store back all unsaved data into calendar object 2110 // Store back all unsaved data into calendar object
2086 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2111 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2087 if ( mViewManager->currentView() ) 2112 if ( mViewManager->currentView() )
2088 mViewManager->currentView()->flushView(); 2113 mViewManager->currentView()->flushView();
2089 2114
2090 2115
2091 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2116 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2092 mStorage->setSaveFormat( new ICalFormat() ); 2117 mStorage->setSaveFormat( new ICalFormat() );
2093 mStorage->setFileName( filename ); 2118 mStorage->setFileName( filename );
2094 bool success; 2119 bool success;
2095 success = mStorage->save(); 2120 success = mStorage->save();
2096 if ( !success ) { 2121 if ( !success ) {
2097 return false; 2122 return false;
2098 } 2123 }
2099 if ( filename == MainWindow::defaultFileName() ) { 2124 if ( filename == MainWindow::defaultFileName() ) {
2100 setLoadedFileVersion( lfv ); 2125 setLoadedFileVersion( lfv );
2101 watchSavedFile(); 2126 watchSavedFile();
2102 } 2127 }
2103 return true; 2128 return true;
2104} 2129}
2105 2130
2106void CalendarView::closeCalendar() 2131void CalendarView::closeCalendar()
2107{ 2132{
2108 2133
2109 // child windows no longer valid 2134 // child windows no longer valid
2110 clearAllViews(); 2135 clearAllViews();
2111 emit closingDown(); 2136 emit closingDown();
2112 2137
2113 mCalendar->close(); 2138 mCalendar->close();
2114 setModified(false); 2139 setModified(false);
2115 updateView(); 2140 updateView();
2116} 2141}
2117 2142
2118void CalendarView::archiveCalendar() 2143void CalendarView::archiveCalendar()
2119{ 2144{
2120 mDialogManager->showArchiveDialog(); 2145 mDialogManager->showArchiveDialog();
2121} 2146}
2122 2147
2123 2148
2124void CalendarView::readSettings() 2149void CalendarView::readSettings()
2125{ 2150{
2126 2151
2127 2152
2128 // mViewManager->showAgendaView(); 2153 // mViewManager->showAgendaView();
2129 QString str; 2154 QString str;
2130 //qDebug("CalendarView::readSettings() "); 2155 //qDebug("CalendarView::readSettings() ");
2131 // read settings from the KConfig, supplying reasonable 2156 // read settings from the KConfig, supplying reasonable
2132 // defaults where none are to be found 2157 // defaults where none are to be found
2133 KConfig *config = KOGlobals::config(); 2158 KConfig *config = KOGlobals::config();
2134#ifndef KORG_NOSPLITTER 2159#ifndef KORG_NOSPLITTER
2135 config->setGroup("KOrganizer Geometry"); 2160 config->setGroup("KOrganizer Geometry");
2136 2161
2137 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2162 QValueList<int> sizes = config->readIntListEntry("Separator1");
2138 if (sizes.count() != 2) { 2163 if (sizes.count() != 2) {
2139 sizes << mDateNavigator->minimumSizeHint().width(); 2164 sizes << mDateNavigator->minimumSizeHint().width();
2140 sizes << 300; 2165 sizes << 300;
2141 } 2166 }
2142 mPanner->setSizes(sizes); 2167 mPanner->setSizes(sizes);
2143 2168
2144 sizes = config->readIntListEntry("Separator2"); 2169 sizes = config->readIntListEntry("Separator2");
2145 if ( ( mResourceView && sizes.count() == 4 ) || 2170 if ( ( mResourceView && sizes.count() == 4 ) ||
2146 ( !mResourceView && sizes.count() == 3 ) ) { 2171 ( !mResourceView && sizes.count() == 3 ) ) {
2147 mLeftSplitter->setSizes(sizes); 2172 mLeftSplitter->setSizes(sizes);
2148 } 2173 }
2149#endif 2174#endif
2150 globalFlagBlockAgenda = 1; 2175 globalFlagBlockAgenda = 1;
2151 mViewManager->showAgendaView(); 2176 mViewManager->showAgendaView();
2152 //mViewManager->readSettings( config ); 2177 //mViewManager->readSettings( config );
2153 mTodoList->restoreLayout(config,QString("Todo Layout")); 2178 mTodoList->restoreLayout(config,QString("Todo Layout"));
2154 readFilterSettings(config); 2179 readFilterSettings(config);
2155 2180
2156#ifdef DESKTOP_VERSION 2181#ifdef DESKTOP_VERSION
2157 config->setGroup("WidgetLayout"); 2182 config->setGroup("WidgetLayout");
2158 QStringList list; 2183 QStringList list;
2159 list = config->readListEntry("MainLayout"); 2184 list = config->readListEntry("MainLayout");
2160 int x,y,w,h; 2185 int x,y,w,h;
2161 if ( ! list.isEmpty() ) { 2186 if ( ! list.isEmpty() ) {
2162 x = list[0].toInt(); 2187 x = list[0].toInt();
2163 y = list[1].toInt(); 2188 y = list[1].toInt();
2164 w = list[2].toInt(); 2189 w = list[2].toInt();
2165 h = list[3].toInt(); 2190 h = list[3].toInt();
2166 KApplication::testCoords( &x,&y,&w,&h ); 2191 KApplication::testCoords( &x,&y,&w,&h );
2167 topLevelWidget()->setGeometry(x,y,w,h); 2192 topLevelWidget()->setGeometry(x,y,w,h);
2168 2193
2169 } else { 2194 } else {
2170 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2195 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2171 } 2196 }
2172 list = config->readListEntry("EditEventLayout"); 2197 list = config->readListEntry("EditEventLayout");
2173 if ( ! list.isEmpty() ) { 2198 if ( ! list.isEmpty() ) {
2174 x = list[0].toInt(); 2199 x = list[0].toInt();
2175 y = list[1].toInt(); 2200 y = list[1].toInt();
2176 w = list[2].toInt(); 2201 w = list[2].toInt();
2177 h = list[3].toInt(); 2202 h = list[3].toInt();
2178 KApplication::testCoords( &x,&y,&w,&h ); 2203 KApplication::testCoords( &x,&y,&w,&h );
2179 mEventEditor->setGeometry(x,y,w,h); 2204 mEventEditor->setGeometry(x,y,w,h);
2180 2205
2181 } 2206 }
2182 list = config->readListEntry("EditTodoLayout"); 2207 list = config->readListEntry("EditTodoLayout");
2183 if ( ! list.isEmpty() ) { 2208 if ( ! list.isEmpty() ) {
2184 x = list[0].toInt(); 2209 x = list[0].toInt();
2185 y = list[1].toInt(); 2210 y = list[1].toInt();
2186 w = list[2].toInt(); 2211 w = list[2].toInt();
2187 h = list[3].toInt(); 2212 h = list[3].toInt();
2188 KApplication::testCoords( &x,&y,&w,&h ); 2213 KApplication::testCoords( &x,&y,&w,&h );
2189 mTodoEditor->setGeometry(x,y,w,h); 2214 mTodoEditor->setGeometry(x,y,w,h);
2190 2215
2191 } 2216 }
2192 list = config->readListEntry("ViewerLayout"); 2217 list = config->readListEntry("ViewerLayout");
2193 if ( ! list.isEmpty() ) { 2218 if ( ! list.isEmpty() ) {
2194 x = list[0].toInt(); 2219 x = list[0].toInt();
2195 y = list[1].toInt(); 2220 y = list[1].toInt();
2196 w = list[2].toInt(); 2221 w = list[2].toInt();
2197 h = list[3].toInt(); 2222 h = list[3].toInt();
2198 KApplication::testCoords( &x,&y,&w,&h ); 2223 KApplication::testCoords( &x,&y,&w,&h );
2199 getEventViewerDialog()->setGeometry(x,y,w,h); 2224 getEventViewerDialog()->setGeometry(x,y,w,h);
2200 } 2225 }
2201#endif 2226#endif
2202 config->setGroup( "Views" ); 2227 config->setGroup( "Views" );
2203 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2228 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2204 2229
2205 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2230 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2206 2231
2207 int resetval = 0; 2232 int resetval = 0;
2208 int maxVal = 0; 2233 int maxVal = 0;
2209 if (sizes.count() != 3) { 2234 if (sizes.count() != 3) {
2210 if ( KOPrefs::instance()->mVerticalScreen ) { 2235 if ( KOPrefs::instance()->mVerticalScreen ) {
2211 resetval = mDateNavigator->sizeHint().width()+2; 2236 resetval = mDateNavigator->sizeHint().width()+2;
2212 } else { 2237 } else {
2213 resetval = mDateNavigator->sizeHint().height()+2; 2238 resetval = mDateNavigator->sizeHint().height()+2;
2214 } 2239 }
2215 } 2240 }
2216 if ( resetval ) { 2241 if ( resetval ) {
2217 sizes.clear(); 2242 sizes.clear();
2218 if ( KOPrefs::instance()->mVerticalScreen ) { 2243 if ( KOPrefs::instance()->mVerticalScreen ) {
2219 maxVal = QApplication::desktop()->width() -10; 2244 maxVal = QApplication::desktop()->width() -10;
2220 } else { 2245 } else {
2221 maxVal = QApplication::desktop()->height()-10; 2246 maxVal = QApplication::desktop()->height()-10;
2222 } 2247 }
2223 sizes << resetval; 2248 sizes << resetval;
2224 if ( maxVal < resetval + resetval) 2249 if ( maxVal < resetval + resetval)
2225 resetval = maxVal - resetval; 2250 resetval = maxVal - resetval;
2226 sizes << resetval; 2251 sizes << resetval;
2227 sizes << 100; 2252 sizes << 100;
2228 } 2253 }
2229 mLeftFrame->setSizes(sizes); 2254 mLeftFrame->setSizes(sizes);
2230 sizes = config->readIntListEntry("Main Splitter Frame"); 2255 sizes = config->readIntListEntry("Main Splitter Frame");
2231 resetval = 0; 2256 resetval = 0;
2232 maxVal = 0; 2257 maxVal = 0;
2233 if (sizes.count() != 2) { 2258 if (sizes.count() != 2) {
2234 if ( !KOPrefs::instance()->mVerticalScreen ) { 2259 if ( !KOPrefs::instance()->mVerticalScreen ) {
2235 resetval = mDateNavigator->sizeHint().width()+2; 2260 resetval = mDateNavigator->sizeHint().width()+2;
2236 } else { 2261 } else {
2237 resetval = mDateNavigator->sizeHint().height()+2; 2262 resetval = mDateNavigator->sizeHint().height()+2;
2238 } 2263 }
2239 } 2264 }
2240 if ( resetval ) { 2265 if ( resetval ) {
2241 sizes.clear(); 2266 sizes.clear();
2242 if ( !KOPrefs::instance()->mVerticalScreen ) { 2267 if ( !KOPrefs::instance()->mVerticalScreen ) {
2243 maxVal = QApplication::desktop()->width() -10; 2268 maxVal = QApplication::desktop()->width() -10;
2244 } else { 2269 } else {
2245 maxVal = QApplication::desktop()->height()-10; 2270 maxVal = QApplication::desktop()->height()-10;
2246 } 2271 }
2247 sizes << resetval; 2272 sizes << resetval;
2248 if ( maxVal < resetval + resetval) 2273 if ( maxVal < resetval + resetval)
2249 resetval = maxVal - resetval; 2274 resetval = maxVal - resetval;
2250 sizes << resetval; 2275 sizes << resetval;
2251 } 2276 }
2252 mMainFrame->setSizes(sizes); 2277 mMainFrame->setSizes(sizes);
2253 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2278 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2254 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2279 else if ( dateCount == 7 ) mNavigator->selectWeek();
2255 else mNavigator->selectDates( dateCount ); 2280 else mNavigator->selectDates( dateCount );
2256 // mViewManager->readSettings( config ); 2281 // mViewManager->readSettings( config );
2257 updateConfig(); 2282 updateConfig();
2258 globalFlagBlockAgenda = 2; 2283 globalFlagBlockAgenda = 2;
2259 mViewManager->readSettings( config ); 2284 mViewManager->readSettings( config );
2260 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2285 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2261} 2286}
2262 2287
2263 2288
2264void CalendarView::writeSettings() 2289void CalendarView::writeSettings()
2265{ 2290{
2266 // kdDebug() << "CalendarView::writeSettings" << endl; 2291 // kdDebug() << "CalendarView::writeSettings" << endl;
2267 2292
2268 KConfig *config = KOGlobals::config(); 2293 KConfig *config = KOGlobals::config();
2269 2294
2270 mViewManager->writeSettings( config ); 2295 mViewManager->writeSettings( config );
2271 mTodoList->saveLayout(config,QString("Todo Layout")); 2296 mTodoList->saveLayout(config,QString("Todo Layout"));
2272 mDialogManager->writeSettings( config ); 2297 mDialogManager->writeSettings( config );
2273 //KOPrefs::instance()->usrWriteConfig(); 2298 //KOPrefs::instance()->usrWriteConfig();
2274 KOPrefs::instance()->writeConfig(); 2299 KOPrefs::instance()->writeConfig();
2275 2300
2276 writeFilterSettings(config); 2301 writeFilterSettings(config);
2277 config->setGroup( "AppRun" ); 2302 config->setGroup( "AppRun" );
2278 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2303 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2279 int days = dt.daysTo( QDate::currentDate() ); 2304 int days = dt.daysTo( QDate::currentDate() );
2280 dt = dt.addDays( days ); 2305 dt = dt.addDays( days );
2281 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2306 int secs = dt.secsTo( QDateTime::currentDateTime() );
2282 config->writeEntry( "LatestProgramStopDays", days ); 2307 config->writeEntry( "LatestProgramStopDays", days );
2283 config->writeEntry( "LatestProgramStopSecs", secs ); 2308 config->writeEntry( "LatestProgramStopSecs", secs );
2284 //qDebug("KO: Writing stop time: %d ", secs); 2309 //qDebug("KO: Writing stop time: %d ", secs);
2285 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2310 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2286 //QDateTime latest = dt.addSecs ( secs ); 2311 //QDateTime latest = dt.addSecs ( secs );
2287 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2312 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2288 config->setGroup( "Views" ); 2313 config->setGroup( "Views" );
2289 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2314 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2290 2315
2291#if 0 2316#if 0
2292 qDebug("********************* "); 2317 qDebug("********************* ");
2293 qDebug("Testcode secsto "); 2318 qDebug("Testcode secsto ");
2294 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2319 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2295 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2320 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2296 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2321 int secsto = dt_nodaylight.secsTo( dt_daylight );
2297 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2322 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2298 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2323 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2299 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2324 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2300 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2325 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2301 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2326 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2302 qDebug("********************* testcode end"); 2327 qDebug("********************* testcode end");
2303 2328
2304#endif 2329#endif
2305 2330
2306 QValueList<int> listINT = mLeftFrame->sizes(); 2331 QValueList<int> listINT = mLeftFrame->sizes();
2307 config->writeEntry("Left Splitter Frame",listINT); 2332 config->writeEntry("Left Splitter Frame",listINT);
2308 QValueList<int> listINT2 = mMainFrame->sizes(); 2333 QValueList<int> listINT2 = mMainFrame->sizes();
2309 config->writeEntry("Main Splitter Frame",listINT2); 2334 config->writeEntry("Main Splitter Frame",listINT2);
2310#ifdef DESKTOP_VERSION 2335#ifdef DESKTOP_VERSION
2311 config->setGroup("WidgetLayout"); 2336 config->setGroup("WidgetLayout");
2312 QStringList list ;//= config->readListEntry("MainLayout"); 2337 QStringList list ;//= config->readListEntry("MainLayout");
2313 int x,y,w,h; 2338 int x,y,w,h;
2314 QWidget* wid; 2339 QWidget* wid;
2315 wid = topLevelWidget(); 2340 wid = topLevelWidget();
2316 x = wid->geometry().x(); 2341 x = wid->geometry().x();
2317 y = wid->geometry().y(); 2342 y = wid->geometry().y();
2318 w = wid->width(); 2343 w = wid->width();
2319 h = wid->height(); 2344 h = wid->height();
2320 list.clear(); 2345 list.clear();
2321 list << QString::number( x ); 2346 list << QString::number( x );
2322 list << QString::number( y ); 2347 list << QString::number( y );
2323 list << QString::number( w ); 2348 list << QString::number( w );
2324 list << QString::number( h ); 2349 list << QString::number( h );
2325 config->writeEntry("MainLayout",list ); 2350 config->writeEntry("MainLayout",list );
2326 2351
2327 wid = mEventEditor; 2352 wid = mEventEditor;
2328 x = wid->geometry().x(); 2353 x = wid->geometry().x();
2329 y = wid->geometry().y(); 2354 y = wid->geometry().y();
2330 w = wid->width(); 2355 w = wid->width();
2331 h = wid->height(); 2356 h = wid->height();
2332 list.clear(); 2357 list.clear();
2333 list << QString::number( x ); 2358 list << QString::number( x );
2334 list << QString::number( y ); 2359 list << QString::number( y );
2335 list << QString::number( w ); 2360 list << QString::number( w );
2336 list << QString::number( h ); 2361 list << QString::number( h );
2337 config->writeEntry("EditEventLayout",list ); 2362 config->writeEntry("EditEventLayout",list );
2338 2363
2339 wid = mTodoEditor; 2364 wid = mTodoEditor;
2340 x = wid->geometry().x(); 2365 x = wid->geometry().x();
2341 y = wid->geometry().y(); 2366 y = wid->geometry().y();
2342 w = wid->width(); 2367 w = wid->width();
2343 h = wid->height(); 2368 h = wid->height();
2344 list.clear(); 2369 list.clear();
2345 list << QString::number( x ); 2370 list << QString::number( x );
2346 list << QString::number( y ); 2371 list << QString::number( y );
2347 list << QString::number( w ); 2372 list << QString::number( w );
2348 list << QString::number( h ); 2373 list << QString::number( h );
2349 config->writeEntry("EditTodoLayout",list ); 2374 config->writeEntry("EditTodoLayout",list );
2350 wid = getEventViewerDialog(); 2375 wid = getEventViewerDialog();
2351 x = wid->geometry().x(); 2376 x = wid->geometry().x();
2352 y = wid->geometry().y(); 2377 y = wid->geometry().y();
2353 w = wid->width(); 2378 w = wid->width();
2354 h = wid->height(); 2379 h = wid->height();
2355 list.clear(); 2380 list.clear();
2356 list << QString::number( x ); 2381 list << QString::number( x );
2357 list << QString::number( y ); 2382 list << QString::number( y );
2358 list << QString::number( w ); 2383 list << QString::number( w );
2359 list << QString::number( h ); 2384 list << QString::number( h );
2360 config->writeEntry("ViewerLayout",list ); 2385 config->writeEntry("ViewerLayout",list );
2361 wid = mDialogManager->getSearchDialog(); 2386 wid = mDialogManager->getSearchDialog();
2362 if ( wid ) { 2387 if ( wid ) {
2363 x = wid->geometry().x(); 2388 x = wid->geometry().x();
2364 y = wid->geometry().y(); 2389 y = wid->geometry().y();
2365 w = wid->width(); 2390 w = wid->width();
2366 h = wid->height(); 2391 h = wid->height();
2367 list.clear(); 2392 list.clear();
2368 list << QString::number( x ); 2393 list << QString::number( x );
2369 list << QString::number( y ); 2394 list << QString::number( y );
2370 list << QString::number( w ); 2395 list << QString::number( w );
2371 list << QString::number( h ); 2396 list << QString::number( h );
2372 config->writeEntry("SearchLayout",list ); 2397 config->writeEntry("SearchLayout",list );
2373 } 2398 }
2374#endif 2399#endif
2375 2400
2376 2401
2377 config->sync(); 2402 config->sync();
2378} 2403}
2379 2404
2380void CalendarView::readFilterSettings(KConfig *config) 2405void CalendarView::readFilterSettings(KConfig *config)
2381{ 2406{
2382 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2407 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2383 2408
2384 mFilters.clear(); 2409 mFilters.clear();
2385 2410
2386 config->setGroup("General"); 2411 config->setGroup("General");
2387 QStringList filterList = config->readListEntry("CalendarFilters"); 2412 QStringList filterList = config->readListEntry("CalendarFilters");
2388 2413
2389 QStringList::ConstIterator it = filterList.begin(); 2414 QStringList::ConstIterator it = filterList.begin();
2390 QStringList::ConstIterator end = filterList.end(); 2415 QStringList::ConstIterator end = filterList.end();
2391 while(it != end) { 2416 while(it != end) {
2392 // kdDebug() << " filter: " << (*it) << endl; 2417 // kdDebug() << " filter: " << (*it) << endl;
2393 2418
2394 CalFilter *filter; 2419 CalFilter *filter;
2395 filter = new CalFilter(*it); 2420 filter = new CalFilter(*it);
2396 config->setGroup("Filter_" + (*it).utf8()); 2421 config->setGroup("Filter_" + (*it).utf8());
2397 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2422 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2398 filter->setCriteria(config->readNumEntry("Criteria",0)); 2423 filter->setCriteria(config->readNumEntry("Criteria",0));
2399 filter->setCategoryList(config->readListEntry("CategoryList")); 2424 filter->setCategoryList(config->readListEntry("CategoryList"));
2400 mFilters.append(filter); 2425 mFilters.append(filter);
2401 2426
2402 ++it; 2427 ++it;
2403 } 2428 }
2404 2429
2405 if (mFilters.count() == 0) { 2430 if (mFilters.count() == 0) {
2406 CalFilter *filter = new CalFilter(i18n("Default")); 2431 CalFilter *filter = new CalFilter(i18n("Default"));
2407 mFilters.append(filter); 2432 mFilters.append(filter);
2408 } 2433 }
2409 mFilterView->updateFilters(); 2434 mFilterView->updateFilters();
2410 config->setGroup("FilterView"); 2435 config->setGroup("FilterView");
2411 2436
2412 mFilterView->blockSignals(true); 2437 mFilterView->blockSignals(true);
2413 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2438 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2414 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2439 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2415 mFilterView->blockSignals(false); 2440 mFilterView->blockSignals(false);
2416 // We do it manually to avoid it being done twice by the above calls 2441 // We do it manually to avoid it being done twice by the above calls
2417 updateFilter(); 2442 updateFilter();
2418} 2443}
2419 2444
2420void CalendarView::writeFilterSettings(KConfig *config) 2445void CalendarView::writeFilterSettings(KConfig *config)
2421{ 2446{
2422 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2447 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2423 2448
2424 QStringList filterList; 2449 QStringList filterList;
2425 2450
2426 CalFilter *filter = mFilters.first(); 2451 CalFilter *filter = mFilters.first();
2427 while(filter) { 2452 while(filter) {
2428 // kdDebug() << " fn: " << filter->name() << endl; 2453 // kdDebug() << " fn: " << filter->name() << endl;
2429 filterList << filter->name(); 2454 filterList << filter->name();
2430 config->setGroup("Filter_" + filter->name().utf8()); 2455 config->setGroup("Filter_" + filter->name().utf8());
2431 config->writeEntry("Criteria",filter->criteria()); 2456 config->writeEntry("Criteria",filter->criteria());
2432 config->writeEntry("CategoryList",filter->categoryList()); 2457 config->writeEntry("CategoryList",filter->categoryList());
2433 filter = mFilters.next(); 2458 filter = mFilters.next();
2434 } 2459 }
2435 config->setGroup("General"); 2460 config->setGroup("General");
2436 config->writeEntry("CalendarFilters",filterList); 2461 config->writeEntry("CalendarFilters",filterList);
2437 2462
2438 config->setGroup("FilterView"); 2463 config->setGroup("FilterView");
2439 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2464 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2440 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2465 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2441} 2466}
2442 2467
2443 2468
2444void CalendarView::goToday() 2469void CalendarView::goToday()
2445{ 2470{
2446 if ( mViewManager->currentView()->isMonthView() ) 2471 if ( mViewManager->currentView()->isMonthView() )
2447 mNavigator->selectTodayMonth(); 2472 mNavigator->selectTodayMonth();
2448 else 2473 else
2449 mNavigator->selectToday(); 2474 mNavigator->selectToday();
2450} 2475}
2451 2476
2452void CalendarView::goNext() 2477void CalendarView::goNext()
2453{ 2478{
2454 mNavigator->selectNext(); 2479 mNavigator->selectNext();
2455} 2480}
2456 2481
2457void CalendarView::goPrevious() 2482void CalendarView::goPrevious()
2458{ 2483{
2459 mNavigator->selectPrevious(); 2484 mNavigator->selectPrevious();
2460} 2485}
2461void CalendarView::goNextMonth() 2486void CalendarView::goNextMonth()
2462{ 2487{
2463 mNavigator->selectNextMonth(); 2488 mNavigator->selectNextMonth();
2464} 2489}
2465 2490
2466void CalendarView::goPreviousMonth() 2491void CalendarView::goPreviousMonth()
2467{ 2492{
2468 mNavigator->selectPreviousMonth(); 2493 mNavigator->selectPreviousMonth();
2469} 2494}
2470void CalendarView::writeLocale() 2495
2471{
2472 //KPimGlobalPrefs::instance()->setGlobalConfig();
2473#if 0
2474 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2475 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2476 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2477 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2478 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2479 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2480 dummy = KOPrefs::instance()->mUserDateFormatShort;
2481 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2482 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2483 KOPrefs::instance()->mDaylightsavingStart,
2484 KOPrefs::instance()->mDaylightsavingEnd );
2485 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2486#endif
2487}
2488void CalendarView::updateConfig() 2496void CalendarView::updateConfig()
2489{ 2497{
2490 writeLocale();
2491 if ( KOPrefs::instance()->mUseAppColors ) 2498 if ( KOPrefs::instance()->mUseAppColors )
2492 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2499 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2493 emit configChanged(); 2500 emit configChanged();
2494 mTodoList->updateConfig(); 2501 mTodoList->updateConfig();
2495 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2502 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2496 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2503 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2497 // To make the "fill window" configurations work 2504 // To make the "fill window" configurations work
2498 //mViewManager->raiseCurrentView(); 2505 //mViewManager->raiseCurrentView();
2499} 2506}
2500 2507
2501 2508
2502void CalendarView::eventChanged(Event *event) 2509void CalendarView::eventChanged(Event *event)
2503{ 2510{
2504 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2511 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2505 //updateUnmanagedViews(); 2512 //updateUnmanagedViews();
2506} 2513}
2507 2514
2508void CalendarView::eventAdded(Event *event) 2515void CalendarView::eventAdded(Event *event)
2509{ 2516{
2510 changeEventDisplay(event,KOGlobals::EVENTADDED); 2517 changeEventDisplay(event,KOGlobals::EVENTADDED);
2511} 2518}
2512 2519
2513void CalendarView::eventToBeDeleted(Event *) 2520void CalendarView::eventToBeDeleted(Event *)
2514{ 2521{
2515 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2522 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2516} 2523}
2517 2524
2518void CalendarView::eventDeleted() 2525void CalendarView::eventDeleted()
2519{ 2526{
2520 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2527 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2521} 2528}
2522void CalendarView::changeTodoDisplay(Todo *which, int action) 2529void CalendarView::changeTodoDisplay(Todo *which, int action)
2523{ 2530{
2524 changeIncidenceDisplay((Incidence *)which, action); 2531 changeIncidenceDisplay((Incidence *)which, action);
2525 mDateNavigator->updateView(); //LR 2532 mDateNavigator->updateView(); //LR
2526 //mDialogManager->updateSearchDialog(); 2533 //mDialogManager->updateSearchDialog();
2527 2534
2528 if (which) { 2535 if (which) {
2529 mViewManager->updateWNview(); 2536 mViewManager->updateWNview();
2530 //mTodoList->updateView(); 2537 //mTodoList->updateView();
2531 } 2538 }
2532 2539
2533} 2540}
2534 2541
2535void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2542void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2536{ 2543{
2537 updateUnmanagedViews(); 2544 updateUnmanagedViews();
2538 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2545 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2539 if ( action == KOGlobals::EVENTDELETED ) { //delete 2546 if ( action == KOGlobals::EVENTDELETED ) { //delete
2540 mCalendar->checkAlarmForIncidence( 0, true ); 2547 mCalendar->checkAlarmForIncidence( 0, true );
2541 if ( mEventViewerDialog ) 2548 if ( mEventViewerDialog )
2542 mEventViewerDialog->hide(); 2549 mEventViewerDialog->hide();
2543 } 2550 }
2544 else 2551 else
2545 mCalendar->checkAlarmForIncidence( which , false ); 2552 mCalendar->checkAlarmForIncidence( which , false );
2546} 2553}
2547 2554
2548// most of the changeEventDisplays() right now just call the view's 2555// most of the changeEventDisplays() right now just call the view's
2549// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2556// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2550void CalendarView::changeEventDisplay(Event *which, int action) 2557void CalendarView::changeEventDisplay(Event *which, int action)
2551{ 2558{
2552 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2559 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2553 changeIncidenceDisplay((Incidence *)which, action); 2560 changeIncidenceDisplay((Incidence *)which, action);
2554 mDateNavigator->updateView(); 2561 mDateNavigator->updateView();
2555 //mDialogManager->updateSearchDialog(); 2562 //mDialogManager->updateSearchDialog();
2556 2563
2557 if (which) { 2564 if (which) {
2558 // If there is an event view visible update the display 2565 // If there is an event view visible update the display
2559 mViewManager->currentView()->changeEventDisplay(which,action); 2566 mViewManager->currentView()->changeEventDisplay(which,action);
2560 // TODO: check, if update needed 2567 // TODO: check, if update needed
2561 // if (which->getTodoStatus()) { 2568 // if (which->getTodoStatus()) {
2562 mTodoList->updateView(); 2569 mTodoList->updateView();
2563 // } 2570 // }
2564 } else { 2571 } else {
2565 mViewManager->currentView()->updateView(); 2572 mViewManager->currentView()->updateView();
2566 } 2573 }
2567} 2574}
2568 2575
2569 2576
2570void CalendarView::updateTodoViews() 2577void CalendarView::updateTodoViews()
2571{ 2578{
2572 mTodoList->updateView(); 2579 mTodoList->updateView();
2573 mViewManager->currentView()->updateView(); 2580 mViewManager->currentView()->updateView();
2574 2581
2575} 2582}
2576 2583
2577 2584
2578void CalendarView::updateView(const QDate &start, const QDate &end) 2585void CalendarView::updateView(const QDate &start, const QDate &end)
2579{ 2586{
2587 mDateScrollBar->setValue( start.dayOfYear()-1);
2580 mTodoList->updateView(); 2588 mTodoList->updateView();
2581 mViewManager->updateView(start, end); 2589 mViewManager->updateView(start, end);
2582 //mDateNavigator->updateView(); 2590 //mDateNavigator->updateView();
2583} 2591}
2584 2592
2585void CalendarView::clearAllViews() 2593void CalendarView::clearAllViews()
2586{ 2594{
2587 mTodoList->clearList(); 2595 mTodoList->clearList();
2588 mViewManager->clearAllViews(); 2596 mViewManager->clearAllViews();
2589 SearchDialog * sd = mDialogManager->getSearchDialog(); 2597 SearchDialog * sd = mDialogManager->getSearchDialog();
2590 if ( sd ) { 2598 if ( sd ) {
2591 KOListView* kol = sd->listview(); 2599 KOListView* kol = sd->listview();
2592 if ( kol ) 2600 if ( kol )
2593 kol->clearList(); 2601 kol->clearList();
2594 } 2602 }
2595} 2603}
2596void CalendarView::updateView() 2604void CalendarView::updateView()
2597{ 2605{
2598 DateList tmpList = mNavigator->selectedDates(); 2606 DateList tmpList = mNavigator->selectedDates();
2599 2607
2600 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2608 if ( KOPrefs::instance()->mHideNonStartedTodos )
2601 mTodoList->updateView(); 2609 mTodoList->updateView();
2602 // We assume that the navigator only selects consecutive days. 2610 // We assume that the navigator only selects consecutive days.
2603 updateView( tmpList.first(), tmpList.last() ); 2611 updateView( tmpList.first(), tmpList.last() );
2604} 2612}
2605 2613
2606void CalendarView::updateUnmanagedViews() 2614void CalendarView::updateUnmanagedViews()
2607{ 2615{
2608 mDateNavigator->updateDayMatrix(); 2616 mDateNavigator->updateDayMatrix();
2609} 2617}
2610 2618
2611int CalendarView::msgItemDelete(const QString name) 2619int CalendarView::msgItemDelete(const QString name)
2612{ 2620{
2613 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2621 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2614 i18n("This item will be\npermanently deleted."), 2622 i18n("This item will be\npermanently deleted."),
2615 i18n("KO/Pi Confirmation"),i18n("Delete")); 2623 i18n("KO/Pi Confirmation"),i18n("Delete"));
2616} 2624}
2617 2625
2618 2626
2619void CalendarView::edit_cut() 2627void CalendarView::edit_cut()
2620{ 2628{
2621 Event *anEvent=0; 2629 Event *anEvent=0;
2622 2630
2623 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2631 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2624 2632
2625 if (mViewManager->currentView()->isEventView()) { 2633 if (mViewManager->currentView()->isEventView()) {
2626 if ( incidence && incidence->typeID() == eventID ) { 2634 if ( incidence && incidence->typeID() == eventID ) {
2627 anEvent = static_cast<Event *>(incidence); 2635 anEvent = static_cast<Event *>(incidence);
2628 } 2636 }
2629 } 2637 }
2630 2638
2631 if (!anEvent) { 2639 if (!anEvent) {
2632 KNotifyClient::beep(); 2640 KNotifyClient::beep();
2633 return; 2641 return;
2634 } 2642 }
2635 DndFactory factory( mCalendar ); 2643 DndFactory factory( mCalendar );
2636 factory.cutIncidence(anEvent); 2644 factory.cutIncidence(anEvent);
2637 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2645 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2638} 2646}
2639 2647
2640void CalendarView::edit_copy() 2648void CalendarView::edit_copy()
2641{ 2649{
2642 Event *anEvent=0; 2650 Event *anEvent=0;
2643 2651
2644 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2652 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2645 2653
2646 if (mViewManager->currentView()->isEventView()) { 2654 if (mViewManager->currentView()->isEventView()) {
2647 if ( incidence && incidence->typeID() == eventID ) { 2655 if ( incidence && incidence->typeID() == eventID ) {
2648 anEvent = static_cast<Event *>(incidence); 2656 anEvent = static_cast<Event *>(incidence);
2649 } 2657 }
2650 } 2658 }
2651 2659
2652 if (!anEvent) { 2660 if (!anEvent) {
2653 KNotifyClient::beep(); 2661 KNotifyClient::beep();
2654 return; 2662 return;
2655 } 2663 }
2656 DndFactory factory( mCalendar ); 2664 DndFactory factory( mCalendar );
2657 factory.copyIncidence(anEvent); 2665 factory.copyIncidence(anEvent);
2658} 2666}
2659 2667
2660void CalendarView::edit_paste() 2668void CalendarView::edit_paste()
2661{ 2669{
2662 QDate date = mNavigator->selectedDates().first(); 2670 QDate date = mNavigator->selectedDates().first();
2663 2671
2664 DndFactory factory( mCalendar ); 2672 DndFactory factory( mCalendar );
2665 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2673 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2666 2674
2667 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2675 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2668} 2676}
2669void CalendarView::edit_global_options() 2677void CalendarView::edit_global_options()
2670{ 2678{
2671 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2679 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2672 emit save(); 2680 emit save();
2673 emit saveStopTimer(); 2681 emit saveStopTimer();
2674 mDialogManager->showGlobalOptionsDialog(); 2682 mDialogManager->showGlobalOptionsDialog();
2675 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2683 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2676 emit saveStopTimer(); 2684 emit saveStopTimer();
2677 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2685 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2678 i18n("Timezone settings"),i18n("Reload"))) { 2686 i18n("Timezone settings"),i18n("Reload"))) {
2679 qDebug("KO: TZ reload cancelled "); 2687 qDebug("KO: TZ reload cancelled ");
2680 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2688 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2681 return; 2689 return;
2682 } 2690 }
2683 qDebug("KO: Timezone change "); 2691 qDebug("KO: Timezone change ");
2684 loadCalendars(); 2692 loadCalendars();
2685 setModified(true); 2693 setModified(true);
2686 } 2694 }
2687 else 2695 else
2688 qDebug("KO: No tz change "); 2696 qDebug("KO: No tz change ");
2689} 2697}
2690void CalendarView::edit_options() 2698void CalendarView::edit_options()
2691{ 2699{
2692 mDialogManager->showOptionsDialog(); 2700 mDialogManager->showOptionsDialog();
2693} 2701}
2694 2702
2695 2703
2696void CalendarView::slotSelectPickerDate( QDate d) 2704void CalendarView::slotSelectPickerDate( QDate d)
2697{ 2705{
2698 mDateFrame->hide(); 2706 mDateFrame->hide();
2699 if ( mDatePickerMode == 1 ) { 2707 if ( mDatePickerMode == 1 ) {
2700 mNavigator->slotDaySelect( d ); 2708 mNavigator->slotDaySelect( d );
2701 } else if ( mDatePickerMode == 2 ) { 2709 } else if ( mDatePickerMode == 2 ) {
2702 if ( mMoveIncidence->typeID() == todoID ) { 2710 if ( mMoveIncidence->typeID() == todoID ) {
2703 Todo * to = (Todo *) mMoveIncidence; 2711 Todo * to = (Todo *) mMoveIncidence;
2704 QTime tim; 2712 QTime tim;
2705 int len = 0; 2713 int len = 0;
2706 if ( to->hasStartDate() && to->hasDueDate() ) 2714 if ( to->hasStartDate() && to->hasDueDate() )
2707 len = to->dtStart().secsTo( to->dtDue()); 2715 len = to->dtStart().secsTo( to->dtDue());
2708 if ( to->hasDueDate() ) 2716 if ( to->hasDueDate() )
2709 tim = to->dtDue().time(); 2717 tim = to->dtDue().time();
2710 else { 2718 else {
2711 tim = QTime ( 0,0,0 ); 2719 tim = QTime ( 0,0,0 );
2712 to->setFloats( true ); 2720 to->setFloats( true );
2713 to->setHasDueDate( true ); 2721 to->setHasDueDate( true );
2714 } 2722 }
2715 QDateTime dt ( d,tim ); 2723 QDateTime dt ( d,tim );
2716 to->setDtDue( dt ); 2724 to->setDtDue( dt );
2717 2725
2718 if ( to->hasStartDate() ) { 2726 if ( to->hasStartDate() ) {
2719 if ( len>0 ) 2727 if ( len>0 )
2720 to->setDtStart(to->dtDue().addSecs( -len )); 2728 to->setDtStart(to->dtDue().addSecs( -len ));
2721 else 2729 else
2722 if (to->dtStart() > to->dtDue() ) 2730 if (to->dtStart() > to->dtDue() )
2723 to->setDtStart(to->dtDue().addDays( -3 )); 2731 to->setDtStart(to->dtDue().addDays( -3 ));
2724 } 2732 }
2725 2733
2726 todoChanged( to ); 2734 todoChanged( to );
2727 } else { 2735 } else {
2728 if ( mMoveIncidence->doesRecur() ) { 2736 if ( mMoveIncidence->doesRecur() ) {
2729#if 0 2737#if 0
2730 // PENDING implement this 2738 // PENDING implement this
2731 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2739 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2732 mCalendar()->addIncidence( newInc ); 2740 mCalendar()->addIncidence( newInc );
2733 if ( mMoveIncidence->typeID() == todoID ) 2741 if ( mMoveIncidence->typeID() == todoID )
2734 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2742 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2735 else 2743 else
2736 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2744 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2737 mMoveIncidence = newInc; 2745 mMoveIncidence = newInc;
2738 2746
2739#endif 2747#endif
2740 } 2748 }
2741 QTime tim = mMoveIncidence->dtStart().time(); 2749 QTime tim = mMoveIncidence->dtStart().time();
2742 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2750 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2743 QDateTime dt ( d,tim ); 2751 QDateTime dt ( d,tim );
2744 mMoveIncidence->setDtStart( dt ); 2752 mMoveIncidence->setDtStart( dt );
2745 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2753 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2746 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2754 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2747 } 2755 }
2748 2756
2749 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2757 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2750 } 2758 }
2751} 2759}
2752 2760
2753void CalendarView::removeCategories() 2761void CalendarView::removeCategories()
2754{ 2762{
2755 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2763 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2756 QStringList catList = KOPrefs::instance()->mCustomCategories; 2764 QStringList catList = KOPrefs::instance()->mCustomCategories;
2757 QStringList catIncList; 2765 QStringList catIncList;
2758 QStringList newCatList; 2766 QStringList newCatList;
2759 Incidence* inc = incList.first(); 2767 Incidence* inc = incList.first();
2760 int i; 2768 int i;
2761 int count = 0; 2769 int count = 0;
2762 while ( inc ) { 2770 while ( inc ) {
2763 newCatList.clear(); 2771 newCatList.clear();
2764 catIncList = inc->categories() ; 2772 catIncList = inc->categories() ;
2765 for( i = 0; i< catIncList.count(); ++i ) { 2773 for( i = 0; i< catIncList.count(); ++i ) {
2766 if ( catList.contains (catIncList[i])) 2774 if ( catList.contains (catIncList[i]))
2767 newCatList.append( catIncList[i] ); 2775 newCatList.append( catIncList[i] );
2768 } 2776 }
2769 newCatList.sort(); 2777 newCatList.sort();
2770 inc->setCategories( newCatList.join(",") ); 2778 inc->setCategories( newCatList.join(",") );
2771 inc = incList.next(); 2779 inc = incList.next();
2772 } 2780 }
2773} 2781}
2774 2782
2775int CalendarView::addCategories() 2783int CalendarView::addCategories()
2776{ 2784{
2777 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2785 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2778 QStringList catList = KOPrefs::instance()->mCustomCategories; 2786 QStringList catList = KOPrefs::instance()->mCustomCategories;
2779 QStringList catIncList; 2787 QStringList catIncList;
2780 Incidence* inc = incList.first(); 2788 Incidence* inc = incList.first();
2781 int i; 2789 int i;
2782 int count = 0; 2790 int count = 0;
2783 while ( inc ) { 2791 while ( inc ) {
2784 catIncList = inc->categories() ; 2792 catIncList = inc->categories() ;
2785 for( i = 0; i< catIncList.count(); ++i ) { 2793 for( i = 0; i< catIncList.count(); ++i ) {
2786 if ( !catList.contains (catIncList[i])) { 2794 if ( !catList.contains (catIncList[i])) {
2787 catList.append( catIncList[i] ); 2795 catList.append( catIncList[i] );
2788 //qDebug("add cat %s ", catIncList[i].latin1()); 2796 //qDebug("add cat %s ", catIncList[i].latin1());
2789 ++count; 2797 ++count;
2790 } 2798 }
2791 } 2799 }
2792 inc = incList.next(); 2800 inc = incList.next();
2793 } 2801 }
2794 catList.sort(); 2802 catList.sort();
2795 KOPrefs::instance()->mCustomCategories = catList; 2803 KOPrefs::instance()->mCustomCategories = catList;
2796 return count; 2804 return count;
2797} 2805}
2798 2806
2799void CalendarView::manageCategories() 2807void CalendarView::manageCategories()
2800{ 2808{
2801 KOCatPrefs* cp = new KOCatPrefs(); 2809 KOCatPrefs* cp = new KOCatPrefs();
2802 cp->show(); 2810 cp->show();
2803 int w =cp->sizeHint().width() ; 2811 int w =cp->sizeHint().width() ;
2804 int h = cp->sizeHint().height() ; 2812 int h = cp->sizeHint().height() ;
2805 int dw = QApplication::desktop()->width(); 2813 int dw = QApplication::desktop()->width();
2806 int dh = QApplication::desktop()->height(); 2814 int dh = QApplication::desktop()->height();
2807 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2815 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2808 if ( !cp->exec() ) { 2816 if ( !cp->exec() ) {
2809 delete cp; 2817 delete cp;
2810 return; 2818 return;
2811 } 2819 }
2812 int count = 0; 2820 int count = 0;
2813 if ( cp->addCat() ) { 2821 if ( cp->addCat() ) {
2814 count = addCategories(); 2822 count = addCategories();
2815 if ( count ) { 2823 if ( count ) {
2816 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2824 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2817 writeSettings(); 2825 writeSettings();
2818 } else 2826 } else
2819 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2827 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2820 } else { 2828 } else {
2821 removeCategories(); 2829 removeCategories();
2822 updateView(); 2830 updateView();
2823 } 2831 }
2824 delete cp; 2832 delete cp;
2825} 2833}
2826 2834
2827void CalendarView::beamIncidence(Incidence * Inc) 2835void CalendarView::beamIncidence(Incidence * Inc)
2828{ 2836{
2829 QPtrList<Incidence> delSel ; 2837 QPtrList<Incidence> delSel ;
2830 delSel.append(Inc); 2838 delSel.append(Inc);
2831 beamIncidenceList( delSel ); 2839 beamIncidenceList( delSel );
2832} 2840}
2833void CalendarView::beamCalendar() 2841void CalendarView::beamCalendar()
2834{ 2842{
2835 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2843 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2836 //qDebug("beamCalendar() "); 2844 //qDebug("beamCalendar() ");
2837 beamIncidenceList( delSel ); 2845 beamIncidenceList( delSel );
2838} 2846}
2839void CalendarView::beamFilteredCalendar() 2847void CalendarView::beamFilteredCalendar()
2840{ 2848{
2841 QPtrList<Incidence> delSel = mCalendar->incidences(); 2849 QPtrList<Incidence> delSel = mCalendar->incidences();
2842 //qDebug("beamFilteredCalendar() "); 2850 //qDebug("beamFilteredCalendar() ");
2843 beamIncidenceList( delSel ); 2851 beamIncidenceList( delSel );
2844} 2852}
2845void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2853void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2846{ 2854{
2847 if ( beamDialog->exec () == QDialog::Rejected ) 2855
2856 KOBeamPrefs beamDialog;
2857 if ( beamDialog.exec () == QDialog::Rejected )
2848 return; 2858 return;
2849#ifdef DESKTOP_VERSION 2859#ifdef DESKTOP_VERSION
2850 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2860 QString fn = locateLocal( "tmp", "kopibeamfile" );
2851#else 2861#else
2852 QString fn = "/tmp/kopibeamfile"; 2862 QString fn = "/tmp/kopibeamfile";
2853#endif 2863#endif
2854 QString mes; 2864 QString mes;
2855 bool createbup = true; 2865 bool createbup = true;
2856 if ( createbup ) { 2866 if ( createbup ) {
2857 QString description = "\n"; 2867 QString description = "\n";
2858 CalendarLocal* cal = new CalendarLocal(); 2868 CalendarLocal* cal = new CalendarLocal();
2859 if ( beamDialog->beamLocal() ) 2869 if ( beamDialog.beamLocal() )
2860 cal->setLocalTime(); 2870 cal->setLocalTime();
2861 else 2871 else
2862 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2872 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2863 Incidence *incidence = delSel.first(); 2873 Incidence *incidence = delSel.first();
2864 bool addText = false; 2874 bool addText = false;
2865 if ( delSel.count() < 10 ) 2875 if ( delSel.count() < 10 )
2866 addText = true; 2876 addText = true;
2867 else { 2877 else {
2868 description.sprintf(i18n(" %d items?"),delSel.count() ); 2878 description.sprintf(i18n(" %d items?"),delSel.count() );
2869 } 2879 }
2870 while ( incidence ) { 2880 while ( incidence ) {
2871 Incidence *in = incidence->clone(); 2881 Incidence *in = incidence->clone();
2872 if ( ! in->summary().isEmpty() ) { 2882 if ( ! in->summary().isEmpty() ) {
2873 in->setDescription(""); 2883 in->setDescription("");
2874 } else { 2884 } else {
2875 in->setSummary( in->description().left(20)); 2885 in->setSummary( in->description().left(20));
2876 in->setDescription(""); 2886 in->setDescription("");
2877 } 2887 }
2878 if ( addText ) 2888 if ( addText )
2879 description += in->summary() + "\n"; 2889 description += in->summary() + "\n";
2880 cal->addIncidence( in ); 2890 cal->addIncidence( in );
2881 incidence = delSel.next(); 2891 incidence = delSel.next();
2882 } 2892 }
2883 if ( beamDialog->beamVcal() ) { 2893 if ( beamDialog.beamVcal() ) {
2884 fn += ".vcs"; 2894 fn += ".vcs";
2885 FileStorage storage( cal, fn, new VCalFormat ); 2895 FileStorage storage( cal, fn, new VCalFormat );
2886 storage.save(); 2896 storage.save();
2887 } else { 2897 } else {
2888 fn += ".ics"; 2898 fn += ".ics";
2889 FileStorage storage( cal, fn, new ICalFormat( ) ); 2899 FileStorage storage( cal, fn, new ICalFormat( ) );
2890 storage.save(); 2900 storage.save();
2891 } 2901 }
2892 delete cal; 2902 delete cal;
2893 mes = i18n("KO/Pi: Ready for beaming"); 2903 mes = i18n("KO/Pi: Ready for beaming");
2894 topLevelWidget()->setCaption(mes); 2904 topLevelWidget()->setCaption(mes);
2895 KApplication::convert2latin1( fn ); 2905 KApplication::convert2latin1( fn );
2896#ifndef DESKTOP_VERSION 2906#ifndef DESKTOP_VERSION
2897 Ir *ir = new Ir( this ); 2907 Ir *ir = new Ir( this );
2898 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2908 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2899 ir->send( fn, description, "text/x-vCalendar" ); 2909 ir->send( fn, description, "text/x-vCalendar" );
2900#endif 2910#endif
2901 } 2911 }
2902} 2912}
2903void CalendarView::beamDone( Ir *ir ) 2913void CalendarView::beamDone( Ir *ir )
2904{ 2914{
2905#ifndef DESKTOP_VERSION 2915#ifndef DESKTOP_VERSION
2906 delete ir; 2916 delete ir;
2907#endif 2917#endif
2908 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2918 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2909 topLevelWidget()->raise(); 2919 topLevelWidget()->raise();
2910} 2920}
2911 2921
2912void CalendarView::moveIncidence(Incidence * inc ) 2922void CalendarView::moveIncidence(Incidence * inc )
2913{ 2923{
2914 if ( !inc ) return; 2924 if ( !inc ) return;
2915 showDatePickerPopup(); 2925 showDatePickerPopup();
2916 mDatePickerMode = 2; 2926 mDatePickerMode = 2;
2917 mMoveIncidence = inc ; 2927 mMoveIncidence = inc ;
2918 QDate da; 2928 QDate da;
2919 if ( mMoveIncidence->typeID() == todoID ) { 2929 if ( mMoveIncidence->typeID() == todoID ) {
2920 Todo * to = (Todo *) mMoveIncidence; 2930 Todo * to = (Todo *) mMoveIncidence;
2921 if ( to->hasDueDate() ) 2931 if ( to->hasDueDate() )
2922 da = to->dtDue().date(); 2932 da = to->dtDue().date();
2923 else 2933 else
2924 da = QDate::currentDate(); 2934 da = QDate::currentDate();
2925 } else { 2935 } else {
2926 da = mMoveIncidence->dtStart().date(); 2936 da = mMoveIncidence->dtStart().date();
2927 } 2937 }
2928 //PENDING set date for recurring incidence to date of recurrence 2938 //PENDING set date for recurring incidence to date of recurrence
2929 //mMoveIncidenceOldDate; 2939 //mMoveIncidenceOldDate;
2930 mDatePicker->setDate( da ); 2940 mDatePicker->setDate( da );
2931} 2941}
2932void CalendarView::showDatePickerPopup() 2942void CalendarView::showDatePickerPopup()
2933{ 2943{
2934 if ( mDateFrame->isVisible() ) 2944 if ( mDateFrame->isVisible() )
2935 mDateFrame->hide(); 2945 mDateFrame->hide();
2936 else { 2946 else {
2937 int offX = 0, offY = 0; 2947 int offX = 0, offY = 0;
2938#ifdef DESKTOP_VERSION 2948#ifdef DESKTOP_VERSION
2939 int w =mDatePicker->sizeHint().width() ; 2949 int w =mDatePicker->sizeHint().width() ;
2940 int h = mDatePicker->sizeHint().height() ; 2950 int h = mDatePicker->sizeHint().height() ;
2941 int dw = topLevelWidget()->width(); 2951 int dw = topLevelWidget()->width();
2942 int dh = topLevelWidget()->height(); 2952 int dh = topLevelWidget()->height();
2943 offX = topLevelWidget()->x(); 2953 offX = topLevelWidget()->x();
2944 offY = topLevelWidget()->y(); 2954 offY = topLevelWidget()->y();
2945#else 2955#else
2946 int w =mDatePicker->sizeHint().width() ; 2956 int w =mDatePicker->sizeHint().width() ;
2947 int h = mDatePicker->sizeHint().height() ; 2957 int h = mDatePicker->sizeHint().height() ;
2948 int dw = QApplication::desktop()->width(); 2958 int dw = QApplication::desktop()->width();
2949 int dh = QApplication::desktop()->height(); 2959 int dh = QApplication::desktop()->height();
2950#endif 2960#endif
2951 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2961 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2952 mDateFrame->show(); 2962 mDateFrame->show();
2953 } 2963 }
2954} 2964}
2955void CalendarView::showDatePicker( ) 2965void CalendarView::showDatePicker( )
2956{ 2966{
2957 showDatePickerPopup(); 2967 showDatePickerPopup();
2958 mDatePickerMode = 1; 2968 mDatePickerMode = 1;
2959 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2969 mDatePicker->setDate( mNavigator->selectedDates().first() );
2960} 2970}
2961 2971
2962void CalendarView::showEventEditor() 2972void CalendarView::showEventEditor()
2963{ 2973{
2964#ifdef DESKTOP_VERSION 2974#ifdef DESKTOP_VERSION
2965 int x,y,w,h; 2975 int x,y,w,h;
2966 x = mEventEditor->geometry().x(); 2976 x = mEventEditor->geometry().x();
2967 y = mEventEditor->geometry().y(); 2977 y = mEventEditor->geometry().y();
2968 w = mEventEditor->width(); 2978 w = mEventEditor->width();
2969 h = mEventEditor->height(); 2979 h = mEventEditor->height();
2970 mEventEditor->show(); 2980 mEventEditor->show();
2971 mEventEditor->setGeometry(x,y,w,h); 2981 mEventEditor->setGeometry(x,y,w,h);
2972#else 2982#else
2973 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2983 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2974 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2984 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2975 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2985 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2976 qApp->processEvents(); 2986 qApp->processEvents();
2977 delete mEventEditor; 2987 delete mEventEditor;
2978 mEventEditor = mDialogManager->getEventEditor(); 2988 mEventEditor = mDialogManager->getEventEditor();
2979 topLevelWidget()->setCaption( i18n("") ); 2989 topLevelWidget()->setCaption( i18n("") );
2980 } 2990 }
2981 mEventEditor->showMaximized(); 2991 mEventEditor->showMaximized();
2982#endif 2992#endif
2983} 2993}
2984void CalendarView::showTodoEditor() 2994void CalendarView::showTodoEditor()
2985{ 2995{
2986#ifdef DESKTOP_VERSION 2996#ifdef DESKTOP_VERSION
2987 int x,y,w,h; 2997 int x,y,w,h;
2988 x = mTodoEditor->geometry().x(); 2998 x = mTodoEditor->geometry().x();
2989 y = mTodoEditor->geometry().y(); 2999 y = mTodoEditor->geometry().y();
2990 w = mTodoEditor->width(); 3000 w = mTodoEditor->width();
2991 h = mTodoEditor->height(); 3001 h = mTodoEditor->height();
2992 mTodoEditor->show(); 3002 mTodoEditor->show();
2993 mTodoEditor->setGeometry(x,y,w,h); 3003 mTodoEditor->setGeometry(x,y,w,h);
2994#else 3004#else
2995 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3005 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2996 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3006 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2997 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3007 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2998 qApp->processEvents(); 3008 qApp->processEvents();
2999 delete mTodoEditor; 3009 delete mTodoEditor;
3000 mTodoEditor = mDialogManager->getTodoEditor(); 3010 mTodoEditor = mDialogManager->getTodoEditor();
3001 topLevelWidget()->setCaption( i18n("") ); 3011 topLevelWidget()->setCaption( i18n("") );
3002 } 3012 }
3003 mTodoEditor->showMaximized(); 3013 mTodoEditor->showMaximized();
3004#endif 3014#endif
3005} 3015}
3006 3016
3007void CalendarView::cloneIncidence() 3017void CalendarView::cloneIncidence()
3008{ 3018{
3009 Incidence *incidence = currentSelection(); 3019 Incidence *incidence = currentSelection();
3010 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3020 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3011 if ( incidence ) { 3021 if ( incidence ) {
3012 cloneIncidence(incidence); 3022 cloneIncidence(incidence);
3013 } 3023 }
3014} 3024}
3015void CalendarView::moveIncidence() 3025void CalendarView::moveIncidence()
3016{ 3026{
3017 Incidence *incidence = currentSelection(); 3027 Incidence *incidence = currentSelection();
3018 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3028 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3019 if ( incidence ) { 3029 if ( incidence ) {
3020 moveIncidence(incidence); 3030 moveIncidence(incidence);
3021 } 3031 }
3022} 3032}
3023void CalendarView::beamIncidence() 3033void CalendarView::beamIncidence()
3024{ 3034{
3025 Incidence *incidence = currentSelection(); 3035 Incidence *incidence = currentSelection();
3026 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3036 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3027 if ( incidence ) { 3037 if ( incidence ) {
3028 beamIncidence(incidence); 3038 beamIncidence(incidence);
3029 } 3039 }
3030} 3040}
3031void CalendarView::toggleCancelIncidence() 3041void CalendarView::toggleCancelIncidence()
3032{ 3042{
3033 Incidence *incidence = currentSelection(); 3043 Incidence *incidence = currentSelection();
3034 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3044 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3035 if ( incidence ) { 3045 if ( incidence ) {
3036 cancelIncidence(incidence); 3046 cancelIncidence(incidence);
3037 } 3047 }
3038} 3048}
3039 3049
3040 3050
3041void CalendarView::cancelIncidence(Incidence * inc ) 3051void CalendarView::cancelIncidence(Incidence * inc )
3042{ 3052{
3043 inc->setCancelled( ! inc->cancelled() ); 3053 inc->setCancelled( ! inc->cancelled() );
3044 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3054 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3045 updateView(); 3055 updateView();
3046} 3056}
3047void CalendarView::cloneIncidence(Incidence * orgInc ) 3057void CalendarView::cloneIncidence(Incidence * orgInc )
3048{ 3058{
3049 Incidence * newInc = orgInc->clone(); 3059 Incidence * newInc = orgInc->clone();
3050 newInc->recreate(); 3060 newInc->recreate();
3051 3061
3052 if ( newInc->typeID() == todoID ) { 3062 if ( newInc->typeID() == todoID ) {
3053 Todo* t = (Todo*) newInc; 3063 Todo* t = (Todo*) newInc;
3054 bool cloneSub = false; 3064 bool cloneSub = false;
3055 if ( orgInc->relations().count() ) { 3065 if ( orgInc->relations().count() ) {
3056 int result = KMessageBox::warningYesNoCancel(this, 3066 int result = KMessageBox::warningYesNoCancel(this,
3057 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 ) ), 3067 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 ) ),
3058 i18n("Todo has subtodos"), 3068 i18n("Todo has subtodos"),
3059 i18n("Yes"), 3069 i18n("Yes"),
3060 i18n("No")); 3070 i18n("No"));
3061 3071
3062 if ( result == KMessageBox::Cancel ) { 3072 if ( result == KMessageBox::Cancel ) {
3063 delete t; 3073 delete t;
3064 return; 3074 return;
3065 } 3075 }
3066 if (result == KMessageBox::Yes) cloneSub = true; 3076 if (result == KMessageBox::Yes) cloneSub = true;
3067 } 3077 }
3068 showTodoEditor(); 3078 showTodoEditor();
3069 mTodoEditor->editTodo( t ); 3079 mTodoEditor->editTodo( t );
3070 if ( mTodoEditor->exec() ) { 3080 if ( mTodoEditor->exec() ) {
3071 if ( cloneSub ) { 3081 if ( cloneSub ) {
3072 orgInc->cloneRelations( t ); 3082 orgInc->cloneRelations( t );
3073 mCalendar->addIncidenceBranch( t ); 3083 mCalendar->addIncidenceBranch( t );
3074 updateView(); 3084 updateView();
3075 3085
3076 } else { 3086 } else {
3077 mCalendar->addTodo( t ); 3087 mCalendar->addTodo( t );
3078 updateView(); 3088 updateView();
3079 } 3089 }
3080 } else { 3090 } else {
3081 delete t; 3091 delete t;
3082 } 3092 }
3083 } 3093 }
3084 else { 3094 else {
3085 Event* e = (Event*) newInc; 3095 Event* e = (Event*) newInc;
3086 showEventEditor(); 3096 showEventEditor();
3087 mEventEditor->editEvent( e ); 3097 mEventEditor->editEvent( e );
3088 if ( mEventEditor->exec() ) { 3098 if ( mEventEditor->exec() ) {
3089 mCalendar->addEvent( e ); 3099 mCalendar->addEvent( e );
3090 updateView(); 3100 updateView();
3091 } else { 3101 } else {
3092 delete e; 3102 delete e;
3093 } 3103 }
3094 } 3104 }
3095 setActiveWindow(); 3105 setActiveWindow();
3096} 3106}
3097 3107
3098void CalendarView::newEvent() 3108void CalendarView::newEvent()
3099{ 3109{
3100 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3110 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3101 KOAgendaView *aView = mViewManager->agendaView(); 3111 KOAgendaView *aView = mViewManager->agendaView();
3102 if (aView) { 3112 if (aView) {
3103 if (aView->selectionStart().isValid()) { 3113 if (aView->selectionStart().isValid()) {
3104 if (aView->selectedIsAllDay()) { 3114 if (aView->selectedIsAllDay()) {
3105 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3115 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3106 } else { 3116 } else {
3107 newEvent(aView->selectionStart(),aView->selectionEnd()); 3117 newEvent(aView->selectionStart(),aView->selectionEnd());
3108 } 3118 }
3109 return; 3119 return;
3110 } 3120 }
3111 } 3121 }
3112 3122
3113 QDate date = mNavigator->selectedDates().first(); 3123 QDate date = mNavigator->selectedDates().first();
3114 QDateTime current = QDateTime::currentDateTime(); 3124 QDateTime current = QDateTime::currentDateTime();
3115 if ( date <= current.date() ) { 3125 if ( date <= current.date() ) {
3116 int hour = current.time().hour() +1; 3126 int hour = current.time().hour() +1;
3117 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3127 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3118 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3128 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3119 } else 3129 } else
3120 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3130 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3121 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3131 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3122 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3132 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3123} 3133}
3124 3134
3125void CalendarView::newEvent(QDateTime fh) 3135void CalendarView::newEvent(QDateTime fh)
3126{ 3136{
3127 newEvent(fh, 3137 newEvent(fh,
3128 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3138 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3129} 3139}
3130 3140
3131void CalendarView::newEvent(QDate dt) 3141void CalendarView::newEvent(QDate dt)
3132{ 3142{
3133 newEvent(QDateTime(dt, QTime(0,0,0)), 3143 newEvent(QDateTime(dt, QTime(0,0,0)),
3134 QDateTime(dt, QTime(0,0,0)), true); 3144 QDateTime(dt, QTime(0,0,0)), true);
3135} 3145}
3136void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3146void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3137{ 3147{
3138 newEvent(fromHint, toHint, false); 3148 newEvent(fromHint, toHint, false);
3139} 3149}
3140void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3150void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3141{ 3151{
3142 3152
3143 showEventEditor(); 3153 showEventEditor();
3144 mEventEditor->newEvent(fromHint,toHint,allDay); 3154 mEventEditor->newEvent(fromHint,toHint,allDay);
3145 if ( mFilterView->filtersEnabled() ) { 3155 if ( mFilterView->filtersEnabled() ) {
3146 CalFilter *filter = mFilterView->selectedFilter(); 3156 CalFilter *filter = mFilterView->selectedFilter();
3147 if (filter && filter->showCategories()) { 3157 if (filter && filter->showCategories()) {
3148 mEventEditor->setCategories(filter->categoryList().join(",") ); 3158 mEventEditor->setCategories(filter->categoryList().join(",") );
3149 } 3159 }
3150 if ( filter ) 3160 if ( filter )
3151 mEventEditor->setSecrecy( filter->getSecrecy() ); 3161 mEventEditor->setSecrecy( filter->getSecrecy() );
3152 } 3162 }
3153 mEventEditor->exec(); 3163 mEventEditor->exec();
3154 setActiveWindow(); 3164 setActiveWindow();
3155} 3165}
3156void CalendarView::todoAdded(Todo * t) 3166void CalendarView::todoAdded(Todo * t)
3157{ 3167{
3158 3168
3159 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3169 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3160 updateTodoViews(); 3170 updateTodoViews();
3161} 3171}
3162void CalendarView::todoChanged(Todo * t) 3172void CalendarView::todoChanged(Todo * t)
3163{ 3173{
3164 emit todoModified( t, 4 ); 3174 emit todoModified( t, 4 );
3165 // updateTodoViews(); 3175 // updateTodoViews();
3166} 3176}
3167void CalendarView::todoToBeDeleted(Todo *) 3177void CalendarView::todoToBeDeleted(Todo *)
3168{ 3178{
3169 //qDebug("todoToBeDeleted(Todo *) "); 3179 //qDebug("todoToBeDeleted(Todo *) ");
3170 updateTodoViews(); 3180 updateTodoViews();
3171} 3181}
3172void CalendarView::todoDeleted() 3182void CalendarView::todoDeleted()
3173{ 3183{
3174 //qDebug(" todoDeleted()"); 3184 //qDebug(" todoDeleted()");
3175 updateTodoViews(); 3185 updateTodoViews();
3176} 3186}
3177 3187
3178 3188
3179void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3189void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3180{ 3190{
3181 showTodoEditor(); 3191 showTodoEditor();
3182 mTodoEditor->newTodo(dt,0,allday); 3192 mTodoEditor->newTodo(dt,0,allday);
3183 if ( mFilterView->filtersEnabled() ) { 3193 if ( mFilterView->filtersEnabled() ) {
3184 CalFilter *filter = mFilterView->selectedFilter(); 3194 CalFilter *filter = mFilterView->selectedFilter();
3185 if (filter && filter->showCategories()) { 3195 if (filter && filter->showCategories()) {
3186 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3196 mTodoEditor->setCategories(filter->categoryList().join(",") );
3187 } 3197 }
3188 if ( filter ) 3198 if ( filter )
3189 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3199 mTodoEditor->setSecrecy( filter->getSecrecy() );
3190 } 3200 }
3191 mTodoEditor->exec(); 3201 mTodoEditor->exec();
3192 setActiveWindow(); 3202 setActiveWindow();
3193} 3203}
3194 3204
3195void CalendarView::newTodo() 3205void CalendarView::newTodo()
3196{ 3206{
3197 newTodoDateTime( QDateTime(),true ); 3207 newTodoDateTime( QDateTime(),true );
3198} 3208}
3199 3209
3200void CalendarView::newSubTodo() 3210void CalendarView::newSubTodo()
3201{ 3211{
3202 Todo *todo = selectedTodo(); 3212 Todo *todo = selectedTodo();
3203 if ( todo ) newSubTodo( todo ); 3213 if ( todo ) newSubTodo( todo );
3204} 3214}
3205 3215
3206void CalendarView::newSubTodo(Todo *parentEvent) 3216void CalendarView::newSubTodo(Todo *parentEvent)
3207{ 3217{
3208 3218
3209 showTodoEditor(); 3219 showTodoEditor();
3210 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3220 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3211 mTodoEditor->exec(); 3221 mTodoEditor->exec();
3212 setActiveWindow(); 3222 setActiveWindow();
3213} 3223}
3214 3224
3215void CalendarView::newFloatingEvent() 3225void CalendarView::newFloatingEvent()
3216{ 3226{
3217 DateList tmpList = mNavigator->selectedDates(); 3227 DateList tmpList = mNavigator->selectedDates();
3218 QDate date = tmpList.first(); 3228 QDate date = tmpList.first();
3219 3229
3220 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3230 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3221 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3231 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3222} 3232}
3223 3233
3224 3234
3225void CalendarView::editEvent( Event *event ) 3235void CalendarView::editEvent( Event *event )
3226{ 3236{
3227 3237
3228 if ( !event ) return; 3238 if ( !event ) return;
3229 if ( event->isReadOnly() ) { 3239 if ( event->isReadOnly() ) {
3230 showEvent( event ); 3240 showEvent( event );
3231 return; 3241 return;
3232 } 3242 }
3233 showEventEditor(); 3243 showEventEditor();
3234 mEventEditor->editEvent( event , mFlagEditDescription); 3244 mEventEditor->editEvent( event , mFlagEditDescription);
3235 mEventEditor->exec(); 3245 mEventEditor->exec();
3236 setActiveWindow(); 3246 setActiveWindow();
3237 3247
3238} 3248}
3239void CalendarView::editJournal( Journal *jour ) 3249void CalendarView::editJournal( Journal *jour )
3240{ 3250{
3241 if ( !jour ) return; 3251 if ( !jour ) return;
3242 mDialogManager->hideSearchDialog(); 3252 mDialogManager->hideSearchDialog();
3243 mViewManager->showJournalView(); 3253 mViewManager->showJournalView();
3244 mNavigator->slotDaySelect( jour->dtStart().date() ); 3254 mNavigator->slotDaySelect( jour->dtStart().date() );
3245} 3255}
3246void CalendarView::editTodo( Todo *todo ) 3256void CalendarView::editTodo( Todo *todo )
3247{ 3257{
3248 if ( !todo ) return; 3258 if ( !todo ) return;
3249 3259
3250 if ( todo->isReadOnly() ) { 3260 if ( todo->isReadOnly() ) {
3251 showTodo( todo ); 3261 showTodo( todo );
3252 return; 3262 return;
3253 } 3263 }
3254 showTodoEditor(); 3264 showTodoEditor();
3255 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3265 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3256 mTodoEditor->exec(); 3266 mTodoEditor->exec();
3257 setActiveWindow(); 3267 setActiveWindow();
3258 3268
3259} 3269}
3260 3270
3261KOEventViewerDialog* CalendarView::getEventViewerDialog() 3271KOEventViewerDialog* CalendarView::getEventViewerDialog()
3262{ 3272{
3263 if ( !mEventViewerDialog ) { 3273 if ( !mEventViewerDialog ) {
3264 mEventViewerDialog = new KOEventViewerDialog(0); 3274 mEventViewerDialog = new KOEventViewerDialog(0);
3265 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3275 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3266 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3276 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3267 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3277 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3268 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3278 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3269 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3279 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3270 viewManager(), SLOT( showAgendaView( bool ) ) ); 3280 viewManager(), SLOT( showAgendaView( bool ) ) );
3271 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3281 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3272 this, SLOT( slotViewerClosed() ) ); 3282 this, SLOT( slotViewerClosed() ) );
3273 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3283 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3274 this, SLOT( todoChanged(Todo *) ) ); 3284 this, SLOT( todoChanged(Todo *) ) );
3275 mEventViewerDialog->resize( 640, 480 ); 3285 mEventViewerDialog->resize( 640, 480 );
3276 3286
3277 } 3287 }
3278 return mEventViewerDialog; 3288 return mEventViewerDialog;
3279} 3289}
3280void CalendarView::showEvent(Event *event) 3290void CalendarView::showEvent(Event *event)
3281{ 3291{
3282 getEventViewerDialog()->setEvent(event); 3292 getEventViewerDialog()->setEvent(event);
3283 getEventViewerDialog()->showMe(); 3293 getEventViewerDialog()->showMe();
3284} 3294}
3285 3295
3286void CalendarView::showTodo(Todo *event) 3296void CalendarView::showTodo(Todo *event)
3287{ 3297{
3288 getEventViewerDialog()->setTodo(event); 3298 getEventViewerDialog()->setTodo(event);
3289 getEventViewerDialog()->showMe(); 3299 getEventViewerDialog()->showMe();
3290} 3300}
3291void CalendarView::showJournal( Journal *jour ) 3301void CalendarView::showJournal( Journal *jour )
3292{ 3302{
3293 getEventViewerDialog()->setJournal(jour); 3303 getEventViewerDialog()->setJournal(jour);
3294 getEventViewerDialog()->showMe(); 3304 getEventViewerDialog()->showMe();
3295 3305
3296} 3306}
3297// void CalendarView::todoModified (Todo *event, int changed) 3307// void CalendarView::todoModified (Todo *event, int changed)
3298// { 3308// {
3299// // if (mDialogList.find (event) != mDialogList.end ()) { 3309// // if (mDialogList.find (event) != mDialogList.end ()) {
3300// // kdDebug() << "Todo modified and open" << endl; 3310// // kdDebug() << "Todo modified and open" << endl;
3301// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3311// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3302// // temp->modified (changed); 3312// // temp->modified (changed);
3303 3313
3304// // } 3314// // }
3305 3315
3306// mViewManager->updateView(); 3316// mViewManager->updateView();
3307// } 3317// }
3308 3318
3309void CalendarView::appointment_show() 3319void CalendarView::appointment_show()
3310{ 3320{
3311 Event *anEvent = 0; 3321 Event *anEvent = 0;
3312 3322
3313 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3323 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3314 3324
3315 if (mViewManager->currentView()->isEventView()) { 3325 if (mViewManager->currentView()->isEventView()) {
3316 if ( incidence && incidence->typeID() == eventID ) { 3326 if ( incidence && incidence->typeID() == eventID ) {
3317 anEvent = static_cast<Event *>(incidence); 3327 anEvent = static_cast<Event *>(incidence);
3318 } 3328 }
3319 } 3329 }
3320 3330
3321 if (!anEvent) { 3331 if (!anEvent) {
3322 KNotifyClient::beep(); 3332 KNotifyClient::beep();
3323 return; 3333 return;
3324 } 3334 }
3325 3335
3326 showEvent(anEvent); 3336 showEvent(anEvent);
3327} 3337}
3328 3338
3329void CalendarView::appointment_edit() 3339void CalendarView::appointment_edit()
3330{ 3340{
3331 Event *anEvent = 0; 3341 Event *anEvent = 0;
3332 3342
3333 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3343 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3334 3344
3335 if (mViewManager->currentView()->isEventView()) { 3345 if (mViewManager->currentView()->isEventView()) {
3336 if ( incidence && incidence->typeID() == eventID ) { 3346 if ( incidence && incidence->typeID() == eventID ) {
3337 anEvent = static_cast<Event *>(incidence); 3347 anEvent = static_cast<Event *>(incidence);
3338 } 3348 }
3339 } 3349 }
3340 3350
3341 if (!anEvent) { 3351 if (!anEvent) {
3342 KNotifyClient::beep(); 3352 KNotifyClient::beep();
3343 return; 3353 return;
3344 } 3354 }
3345 3355
3346 editEvent(anEvent); 3356 editEvent(anEvent);
3347} 3357}
3348 3358
3349void CalendarView::appointment_delete() 3359void CalendarView::appointment_delete()
3350{ 3360{
3351 Event *anEvent = 0; 3361 Event *anEvent = 0;
3352 3362
3353 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3363 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3354 3364
3355 if (mViewManager->currentView()->isEventView()) { 3365 if (mViewManager->currentView()->isEventView()) {
3356 if ( incidence && incidence->typeID() == eventID ) { 3366 if ( incidence && incidence->typeID() == eventID ) {
3357 anEvent = static_cast<Event *>(incidence); 3367 anEvent = static_cast<Event *>(incidence);
3358 } 3368 }
3359 } 3369 }
3360 3370
3361 if (!anEvent) { 3371 if (!anEvent) {
3362 KNotifyClient::beep(); 3372 KNotifyClient::beep();
3363 return; 3373 return;
3364 } 3374 }
3365 3375
3366 deleteEvent(anEvent); 3376 deleteEvent(anEvent);
3367} 3377}
3368 3378
3369void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3379void CalendarView::todo_resub( Todo * parent, Todo * sub )
3370{ 3380{
3371 if (!sub) return; 3381 if (!sub) return;
3372 if ( sub->relatedTo() == parent ) 3382 if ( sub->relatedTo() == parent )
3373 return; 3383 return;
3374 sub->setRelatedTo(parent); 3384 sub->setRelatedTo(parent);
3375 sub->updated(); 3385 sub->updated();
3376 setModified(true); 3386 setModified(true);
3377 updateView(); 3387 updateView();
3378} 3388}
3379void CalendarView::todo_unsub(Todo *anTodo ) 3389void CalendarView::todo_unsub(Todo *anTodo )
3380{ 3390{
3381 todo_resub( 0, anTodo ); 3391 todo_resub( 0, anTodo );
3382} 3392}
3383 3393
3384void CalendarView::deleteTodo(Todo *todo) 3394void CalendarView::deleteTodo(Todo *todo)
3385{ 3395{
3386 if (!todo) { 3396 if (!todo) {
3387 KNotifyClient::beep(); 3397 KNotifyClient::beep();
3388 return; 3398 return;
3389 } 3399 }
3390 if (KOPrefs::instance()->mConfirm) { 3400 if (KOPrefs::instance()->mConfirm) {
3391 QString text = todo->summary().left(20); 3401 QString text = todo->summary().left(20);
3392 if (!todo->relations().isEmpty()) { 3402 if (!todo->relations().isEmpty()) {
3393 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3403 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3394 3404
3395 } 3405 }
3396 switch (msgItemDelete(text)) { 3406 switch (msgItemDelete(text)) {
3397 case KMessageBox::Continue: // OK 3407 case KMessageBox::Continue: // OK
3398 bool deleteT = false; 3408 bool deleteT = false;
3399 if (!todo->relations().isEmpty()) { 3409 if (!todo->relations().isEmpty()) {
3400 deleteT = removeCompletedSubTodos( todo ); 3410 deleteT = removeCompletedSubTodos( todo );
3401 } 3411 }
3402 // deleteT == true: todo already deleted in removeCompletedSubTodos 3412 // deleteT == true: todo already deleted in removeCompletedSubTodos
3403 if ( !deleteT ) { 3413 if ( !deleteT ) {
3404 checkExternalId( todo ); 3414 checkExternalId( todo );
3405 calendar()->deleteTodo(todo); 3415 calendar()->deleteTodo(todo);
3406 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3416 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3407 updateView(); 3417 updateView();
3408 } 3418 }
3409 break; 3419 break;
3410 } // switch 3420 } // switch
3411 } else { 3421 } else {
3412 checkExternalId( todo ); 3422 checkExternalId( todo );
3413 mCalendar->deleteTodo(todo); 3423 mCalendar->deleteTodo(todo);
3414 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3424 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3415 updateView(); 3425 updateView();
3416 } 3426 }
3417 3427
3418 emit updateSearchDialog(); 3428 emit updateSearchDialog();
3419} 3429}
3420void CalendarView::deleteJournal(Journal *jour) 3430void CalendarView::deleteJournal(Journal *jour)
3421{ 3431{
3422 if (!jour) { 3432 if (!jour) {
3423 KNotifyClient::beep(); 3433 KNotifyClient::beep();
3424 return; 3434 return;
3425 } 3435 }
3426 if (KOPrefs::instance()->mConfirm) { 3436 if (KOPrefs::instance()->mConfirm) {
3427 switch (msgItemDelete( jour->description().left(20))) { 3437 switch (msgItemDelete( jour->description().left(20))) {
3428 case KMessageBox::Continue: // OK 3438 case KMessageBox::Continue: // OK
3429 calendar()->deleteJournal(jour); 3439 calendar()->deleteJournal(jour);
3430 updateView(); 3440 updateView();
3431 break; 3441 break;
3432 } // switch 3442 } // switch
3433 } else { 3443 } else {
3434 calendar()->deleteJournal(jour);; 3444 calendar()->deleteJournal(jour);;
3435 updateView(); 3445 updateView();
3436 } 3446 }
3437 emit updateSearchDialog(); 3447 emit updateSearchDialog();
3438} 3448}
3439 3449
3440void CalendarView::deleteEvent(Event *anEvent) 3450void CalendarView::deleteEvent(Event *anEvent)
3441{ 3451{
3442 if (!anEvent) { 3452 if (!anEvent) {
3443 KNotifyClient::beep(); 3453 KNotifyClient::beep();
3444 return; 3454 return;
3445 } 3455 }
3446 3456
3447 if (anEvent->recurrence()->doesRecur()) { 3457 if (anEvent->recurrence()->doesRecur()) {
3448 QDate itemDate = mViewManager->currentSelectionDate(); 3458 QDate itemDate = mViewManager->currentSelectionDate();
3449 int km; 3459 int km;
3450 if (!itemDate.isValid()) { 3460 if (!itemDate.isValid()) {
3451 //kdDebug() << "Date Not Valid" << endl; 3461 //kdDebug() << "Date Not Valid" << endl;
3452 if (KOPrefs::instance()->mConfirm) { 3462 if (KOPrefs::instance()->mConfirm) {
3453 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3463 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3454 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3464 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3455 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3465 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3456 if ( km == KMessageBox::Continue ) 3466 if ( km == KMessageBox::Continue )
3457 km = KMessageBox::No; // No = all below 3467 km = KMessageBox::No; // No = all below
3458 } else 3468 } else
3459 km = KMessageBox::No; 3469 km = KMessageBox::No;
3460 } else { 3470 } else {
3461 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3471 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3462 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3472 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3463 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3473 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3464 i18n("KO/Pi Confirmation"),i18n("Current"), 3474 i18n("KO/Pi Confirmation"),i18n("Current"),
3465 i18n("All")); 3475 i18n("All"));
3466 } 3476 }
3467 switch(km) { 3477 switch(km) {
3468 3478
3469 case KMessageBox::No: // Continue // all 3479 case KMessageBox::No: // Continue // all
3470 //qDebug("KMessageBox::No "); 3480 //qDebug("KMessageBox::No ");
3471 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3481 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3472 schedule(Scheduler::Cancel,anEvent); 3482 schedule(Scheduler::Cancel,anEvent);
3473 3483
3474 checkExternalId( anEvent); 3484 checkExternalId( anEvent);
3475 mCalendar->deleteEvent(anEvent); 3485 mCalendar->deleteEvent(anEvent);
3476 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3486 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3477 break; 3487 break;
3478 3488
3479 // Disabled because it does not work 3489 // Disabled because it does not work
3480 //#if 0 3490 //#if 0
3481 case KMessageBox::Yes: // just this one 3491 case KMessageBox::Yes: // just this one
3482 //QDate qd = mNavigator->selectedDates().first(); 3492 //QDate qd = mNavigator->selectedDates().first();
3483 //if (!qd.isValid()) { 3493 //if (!qd.isValid()) {
3484 // kdDebug() << "no date selected, or invalid date" << endl; 3494 // kdDebug() << "no date selected, or invalid date" << endl;
3485 // KNotifyClient::beep(); 3495 // KNotifyClient::beep();
3486 // return; 3496 // return;
3487 //} 3497 //}
3488 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3498 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3489 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3499 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3490 anEvent->addExDate(itemDate); 3500 anEvent->addExDate(itemDate);
3491 int duration = anEvent->recurrence()->duration(); 3501 int duration = anEvent->recurrence()->duration();
3492 if ( duration > 0 ) { 3502 if ( duration > 0 ) {
3493 anEvent->recurrence()->setDuration( duration - 1 ); 3503 anEvent->recurrence()->setDuration( duration - 1 );
3494 } 3504 }
3495 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3505 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3496 } 3506 }
3497 break; 3507 break;
3498 //#endif 3508 //#endif
3499 } // switch 3509 } // switch
3500 } else { 3510 } else {
3501 if (KOPrefs::instance()->mConfirm) { 3511 if (KOPrefs::instance()->mConfirm) {
3502 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3512 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3503 i18n("\nAre you sure you want\nto delete this event?"), 3513 i18n("\nAre you sure you want\nto delete this event?"),
3504 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3514 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3505 case KMessageBox::Continue: // OK 3515 case KMessageBox::Continue: // OK
3506 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3516 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3507 schedule(Scheduler::Cancel,anEvent); 3517 schedule(Scheduler::Cancel,anEvent);
3508 checkExternalId( anEvent); 3518 checkExternalId( anEvent);
3509 mCalendar->deleteEvent(anEvent); 3519 mCalendar->deleteEvent(anEvent);
3510 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3520 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3511 break; 3521 break;
3512 } // switch 3522 } // switch
3513 } else { 3523 } else {
3514 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3524 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3515 schedule(Scheduler::Cancel,anEvent); 3525 schedule(Scheduler::Cancel,anEvent);
3516 checkExternalId( anEvent); 3526 checkExternalId( anEvent);
3517 mCalendar->deleteEvent(anEvent); 3527 mCalendar->deleteEvent(anEvent);
3518 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3528 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3519 } 3529 }
3520 } // if-else 3530 } // if-else
3521 emit updateSearchDialog(); 3531 emit updateSearchDialog();
3522} 3532}
3523 3533
3524bool CalendarView::deleteEvent(const QString &uid) 3534bool CalendarView::deleteEvent(const QString &uid)
3525{ 3535{
3526 Event *ev = mCalendar->event(uid); 3536 Event *ev = mCalendar->event(uid);
3527 if (ev) { 3537 if (ev) {
3528 deleteEvent(ev); 3538 deleteEvent(ev);
3529 return true; 3539 return true;
3530 } else { 3540 } else {
3531 return false; 3541 return false;
3532 } 3542 }
3533} 3543}
3534 3544
3535/*****************************************************************************/ 3545/*****************************************************************************/
3536 3546
3537void CalendarView::action_mail() 3547void CalendarView::action_mail()
3538{ 3548{
3539#ifndef KORG_NOMAIL 3549#ifndef KORG_NOMAIL
3540 KOMailClient mailClient; 3550 KOMailClient mailClient;
3541 3551
3542 Incidence *incidence = currentSelection(); 3552 Incidence *incidence = currentSelection();
3543 3553
3544 if (!incidence) { 3554 if (!incidence) {
3545 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3555 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3546 return; 3556 return;
3547 } 3557 }
3548 if(incidence->attendeeCount() == 0 ) { 3558 if(incidence->attendeeCount() == 0 ) {
3549 KMessageBox::sorry(this, 3559 KMessageBox::sorry(this,
3550 i18n("Can't generate mail:\nNo attendees defined.\n")); 3560 i18n("Can't generate mail:\nNo attendees defined.\n"));
3551 return; 3561 return;
3552 } 3562 }
3553 3563
3554 CalendarLocal cal_tmp; 3564 CalendarLocal cal_tmp;
3555 Event *event = 0; 3565 Event *event = 0;
3556 Event *ev = 0; 3566 Event *ev = 0;
3557 if ( incidence && incidence->typeID() == eventID ) { 3567 if ( incidence && incidence->typeID() == eventID ) {
3558 event = static_cast<Event *>(incidence); 3568 event = static_cast<Event *>(incidence);
3559 ev = new Event(*event); 3569 ev = new Event(*event);
3560 cal_tmp.addEvent(ev); 3570 cal_tmp.addEvent(ev);
3561 } 3571 }
3562 ICalFormat mForm(); 3572 ICalFormat mForm();
3563 QString attachment = mForm.toString( &cal_tmp ); 3573 QString attachment = mForm.toString( &cal_tmp );
3564 if (ev) delete(ev); 3574 if (ev) delete(ev);
3565 3575
3566 mailClient.mailAttendees(currentSelection(), attachment); 3576 mailClient.mailAttendees(currentSelection(), attachment);
3567 3577
3568#endif 3578#endif
3569 3579
3570#if 0 3580#if 0
3571 Event *anEvent = 0; 3581 Event *anEvent = 0;
3572 if (mViewManager->currentView()->isEventView()) { 3582 if (mViewManager->currentView()->isEventView()) {
3573 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3583 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3574 } 3584 }
3575 3585
3576 if (!anEvent) { 3586 if (!anEvent) {
3577 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3587 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3578 return; 3588 return;
3579 } 3589 }
3580 if(anEvent->attendeeCount() == 0 ) { 3590 if(anEvent->attendeeCount() == 0 ) {
3581 KMessageBox::sorry(this, 3591 KMessageBox::sorry(this,
3582 i18n("Can't generate mail:\nNo attendees defined.\n")); 3592 i18n("Can't generate mail:\nNo attendees defined.\n"));
3583 return; 3593 return;
3584 } 3594 }
3585 3595
3586 mailobject.emailEvent(anEvent); 3596 mailobject.emailEvent(anEvent);
3587#endif 3597#endif
3588} 3598}
3589 3599
3590 3600
3591void CalendarView::schedule_publish(Incidence *incidence) 3601void CalendarView::schedule_publish(Incidence *incidence)
3592{ 3602{
3593 Event *event = 0; 3603 Event *event = 0;
3594 Todo *todo = 0; 3604 Todo *todo = 0;
3595 3605
3596 if (incidence == 0) { 3606 if (incidence == 0) {
3597 incidence = mViewManager->currentView()->selectedIncidences().first(); 3607 incidence = mViewManager->currentView()->selectedIncidences().first();
3598 if (incidence == 0) { 3608 if (incidence == 0) {
3599 incidence = mTodoList->selectedIncidences().first(); 3609 incidence = mTodoList->selectedIncidences().first();
3600 } 3610 }
3601 } 3611 }
3602 if ( incidence && incidence->typeID() == eventID ) { 3612 if ( incidence && incidence->typeID() == eventID ) {
3603 event = static_cast<Event *>(incidence); 3613 event = static_cast<Event *>(incidence);
3604 } else { 3614 } else {
3605 if ( incidence && incidence->typeID() == todoID ) { 3615 if ( incidence && incidence->typeID() == todoID ) {
3606 todo = static_cast<Todo *>(incidence); 3616 todo = static_cast<Todo *>(incidence);
3607 } 3617 }
3608 } 3618 }
3609 3619
3610 if (!event && !todo) { 3620 if (!event && !todo) {
3611 KMessageBox::sorry(this,i18n("No event selected.")); 3621 KMessageBox::sorry(this,i18n("No event selected."));
3612 return; 3622 return;
3613 } 3623 }
3614 3624
3615 PublishDialog *publishdlg = new PublishDialog(); 3625 PublishDialog *publishdlg = new PublishDialog();
3616 if (incidence->attendeeCount()>0) { 3626 if (incidence->attendeeCount()>0) {
3617 QPtrList<Attendee> attendees = incidence->attendees(); 3627 QPtrList<Attendee> attendees = incidence->attendees();
3618 attendees.first(); 3628 attendees.first();
3619 while ( attendees.current()!=0 ) { 3629 while ( attendees.current()!=0 ) {
3620 publishdlg->addAttendee(attendees.current()); 3630 publishdlg->addAttendee(attendees.current());
3621 attendees.next(); 3631 attendees.next();
3622 } 3632 }
3623 } 3633 }
3624 bool send = true; 3634 bool send = true;
3625 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3635 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3626 if ( publishdlg->exec() != QDialog::Accepted ) 3636 if ( publishdlg->exec() != QDialog::Accepted )
3627 send = false; 3637 send = false;
3628 } 3638 }
3629 if ( send ) { 3639 if ( send ) {
3630 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3640 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3631 if ( event ) { 3641 if ( event ) {
3632 Event *ev = new Event(*event); 3642 Event *ev = new Event(*event);
3633 ev->registerObserver(0); 3643 ev->registerObserver(0);
3634 ev->clearAttendees(); 3644 ev->clearAttendees();
3635 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3645 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3636 delete(ev); 3646 delete(ev);
3637 } 3647 }
3638 } else { 3648 } else {
3639 if ( todo ) { 3649 if ( todo ) {
3640 Todo *ev = new Todo(*todo); 3650 Todo *ev = new Todo(*todo);
3641 ev->registerObserver(0); 3651 ev->registerObserver(0);
3642 ev->clearAttendees(); 3652 ev->clearAttendees();
3643 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3653 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3644 delete(ev); 3654 delete(ev);
3645 } 3655 }
3646 } 3656 }
3647 } 3657 }
3648 } 3658 }
3649 delete publishdlg; 3659 delete publishdlg;
3650} 3660}
3651 3661
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index be18e8f..c89bbf7 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,653 +1,655 @@
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#include <qscrollbar.h>
33#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 35#include <qtopia/ir.h>
35#else 36#else
36#define Ir char 37#define Ir char
37#endif 38#endif
38#include <libkcal/calendar.h> 39#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 40#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
42#include <KDGanttMinimizeSplitter.h> 43#include <KDGanttMinimizeSplitter.h>
43 44
44#include <korganizer/calendarviewbase.h> 45#include <korganizer/calendarviewbase.h>
45 46
46#include <ksyncmanager.h> 47#include <ksyncmanager.h>
47//#include <koprefs.h> 48//#include <koprefs.h>
48 49
49class QWidgetStack; 50class QWidgetStack;
50class QSplitter; 51class QSplitter;
51class KopiCalendarFile; 52class KopiCalendarFile;
52class CalPrinter; 53class CalPrinter;
53class KOFilterView; 54class KOFilterView;
54class KOCalEditView; 55class KOCalEditView;
55class KOViewManager; 56class KOViewManager;
56class KODialogManager; 57class KODialogManager;
57class KOTodoView; 58class KOTodoView;
58class KDateNavigator; 59class KDateNavigator;
59class DateNavigatorContainer; 60class DateNavigatorContainer;
60class DateNavigator; 61class DateNavigator;
61class KOIncidenceEditor; 62class KOIncidenceEditor;
62class KDatePicker; 63class KDatePicker;
63class ResourceView; 64class ResourceView;
64class KOEventEditor; 65class KOEventEditor;
65class KOTodoEditor ; 66class KOTodoEditor ;
66class KOEventViewerDialog; 67class KOEventViewerDialog;
67class KOBeamPrefs; 68class KOBeamPrefs;
68class KSyncProfile; 69class KSyncProfile;
69class AlarmDialog; 70class AlarmDialog;
70class KCal::Attendee; 71class KCal::Attendee;
71 72
72namespace KCal { class FileStorage; } 73namespace KCal { class FileStorage; }
73 74
74using namespace KCal; 75using namespace KCal;
75 76
76/** 77/**
77 This is the main calendar widget. It provides the different vies on t he 78 This is the main calendar widget. It provides the different vies on t he
78 calendar data as well as the date navigator. It also handles synchronisation 79 calendar data as well as the date navigator. It also handles synchronisation
79 of the different views and controls the different dialogs like preferences, 80 of the different views and controls the different dialogs like preferences,
80 event editor, search dialog etc. 81 event editor, search dialog etc.
81 82
82 @short main calendar view widget 83 @short main calendar view widget
83 @author Cornelius Schumacher 84 @author Cornelius Schumacher
84*/ 85*/
85 86
86#include <qtextbrowser.h> 87#include <qtextbrowser.h>
87#include <qtextcodec.h> 88#include <qtextcodec.h>
88 89
89class MissedAlarmTextBrowser : public QTextBrowser { 90class MissedAlarmTextBrowser : public QTextBrowser {
90 Q_OBJECT 91 Q_OBJECT
91 public: 92 public:
92 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
93 ~MissedAlarmTextBrowser(); 94 ~MissedAlarmTextBrowser();
94 void setSource(const QString & n); 95 void setSource(const QString & n);
95 96
96 private: 97 private:
97 Incidence * getNextInc(QDateTime start ); 98 Incidence * getNextInc(QDateTime start );
98 QPtrList<Incidence> mAlarms; 99 QPtrList<Incidence> mAlarms;
99 signals: 100 signals:
100 void showIncidence( QString uid); 101 void showIncidence( QString uid);
101}; 102};
102 103
103 104
104class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
105{ 106{
106 Q_OBJECT 107 Q_OBJECT
107 public: 108 public:
108 /** 109 /**
109 Constructs a new calendar view widget. 110 Constructs a new calendar view widget.
110 111
111 @param calendar calendar document 112 @param calendar calendar document
112 @param parent parent window 113 @param parent parent window
113 @param name Qt internal widget object name 114 @param name Qt internal widget object name
114 */ 115 */
115 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 116 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
116 const char *name = 0 ); 117 const char *name = 0 );
117 CalendarView( Calendar *calendar, QWidget *parent = 0, 118 CalendarView( Calendar *calendar, QWidget *parent = 0,
118 const char *name = 0 ); 119 const char *name = 0 );
119 virtual ~CalendarView(); 120 virtual ~CalendarView();
120 121
121 Calendar *calendar() { return mCalendar; } 122 Calendar *calendar() { return mCalendar; }
122 123
123 KOViewManager *viewManager(); 124 KOViewManager *viewManager();
124 KODialogManager *dialogManager(); 125 KODialogManager *dialogManager();
125 126
126 QDate startDate(); 127 QDate startDate();
127 QDate endDate(); 128 QDate endDate();
128 129
129 QWidgetStack *viewStack(); 130 QWidgetStack *viewStack();
130 QWidget *leftFrame(); 131 QWidget *leftFrame();
131 132
132 DateNavigator *dateNavigator(); 133 DateNavigator *dateNavigator();
133 KDateNavigator *dateNavigatorWidget(); 134 KDateNavigator *dateNavigatorWidget();
134 135
135 void addView(KOrg::BaseView *); 136 void addView(KOrg::BaseView *);
136 void showView(KOrg::BaseView *); 137 void showView(KOrg::BaseView *);
137 KOEventViewerDialog* getEventViewerDialog(); 138 KOEventViewerDialog* getEventViewerDialog();
138 Incidence *currentSelection(); 139 Incidence *currentSelection();
139 140
140 signals: 141 signals:
141 void save (); 142 void save ();
142 void saveStopTimer (); 143 void saveStopTimer ();
143 void tempDisableBR(bool); 144 void tempDisableBR(bool);
144 /** This todo has been modified */ 145 /** This todo has been modified */
145 void todoModified(Todo *, int); 146 void todoModified(Todo *, int);
146 147
147 /** when change is made to options dialog, the topwidget will catch this 148 /** when change is made to options dialog, the topwidget will catch this
148 * and emit this signal which notifies all widgets which have registered 149 * and emit this signal which notifies all widgets which have registered
149 * for notification to update their settings. */ 150 * for notification to update their settings. */
150 void configChanged(); 151 void configChanged();
151 /** emitted when the topwidget is closing down, so that any attached 152 /** emitted when the topwidget is closing down, so that any attached
152 child windows can also close. */ 153 child windows can also close. */
153 void closingDown(); 154 void closingDown();
154 /** emitted right before we die */ 155 /** emitted right before we die */
155 void closed(QWidget *); 156 void closed(QWidget *);
156 157
157 /** Emitted when state of modified flag changes */ 158 /** Emitted when state of modified flag changes */
158 void modifiedChanged(bool); 159 void modifiedChanged(bool);
159 void signalmodified(); 160 void signalmodified();
160 161
161 /** Emitted when state of read-only flag changes */ 162 /** Emitted when state of read-only flag changes */
162 void readOnlyChanged(bool); 163 void readOnlyChanged(bool);
163 164
164 /** Emitted when the unit of navigation changes */ 165 /** Emitted when the unit of navigation changes */
165 void changeNavStringPrev(const QString &); 166 void changeNavStringPrev(const QString &);
166 void changeNavStringNext(const QString &); 167 void changeNavStringNext(const QString &);
167 168
168 /** Emitted when state of events selection has changed and user is organizer*/ 169 /** Emitted when state of events selection has changed and user is organizer*/
169 void organizerEventsSelected(bool); 170 void organizerEventsSelected(bool);
170 /** Emitted when state of events selection has changed and user is attendee*/ 171 /** Emitted when state of events selection has changed and user is attendee*/
171 void groupEventsSelected(bool); 172 void groupEventsSelected(bool);
172 /** 173 /**
173 Emitted when an incidence gets selected. If the selection is cleared the 174 Emitted when an incidence gets selected. If the selection is cleared the
174 signal is emitted with 0 as argument. 175 signal is emitted with 0 as argument.
175 */ 176 */
176 void incidenceSelected( Incidence * ); 177 void incidenceSelected( Incidence * );
177 /** Emitted, when a todoitem is selected or deselected. */ 178 /** Emitted, when a todoitem is selected or deselected. */
178 void todoSelected( bool ); 179 void todoSelected( bool );
179 180
180 /** 181 /**
181 Emitted, when clipboard content changes. Parameter indicates if paste 182 Emitted, when clipboard content changes. Parameter indicates if paste
182 is possible or not. 183 is possible or not.
183 */ 184 */
184 void pasteEnabled(bool); 185 void pasteEnabled(bool);
185 186
186 /** Emitted, when the number of incoming messages has changed. */ 187 /** Emitted, when the number of incoming messages has changed. */
187 void numIncomingChanged(int); 188 void numIncomingChanged(int);
188 189
189 /** Emitted, when the number of outgoing messages has changed. */ 190 /** Emitted, when the number of outgoing messages has changed. */
190 void numOutgoingChanged(int); 191 void numOutgoingChanged(int);
191 192
192 /** Send status message, which can e.g. be displayed in the status bar. */ 193 /** Send status message, which can e.g. be displayed in the status bar. */
193 void statusMessage(const QString &); 194 void statusMessage(const QString &);
194 195
195 void calendarViewExpanded( bool ); 196 void calendarViewExpanded( bool );
196 void updateSearchDialog(); 197 void updateSearchDialog();
197 void filtersUpdated(); 198 void filtersUpdated();
198 199
199 200
200 public slots: 201 public slots:
201 void checkAlarms(); 202 void checkAlarms();
202 void slotprintSelInc(); 203 void slotprintSelInc();
203 void showNextAlarms(); 204 void showNextAlarms();
204 void showOpenError(); 205 void showOpenError();
205 void watchSavedFile(); 206 void watchSavedFile();
206 void recheckTimerAlarm(); 207 void recheckTimerAlarm();
207 void checkNextTimerAlarm(); 208 void checkNextTimerAlarm();
208 void addAlarm(const QDateTime &qdt, const QString &noti ); 209 void addAlarm(const QDateTime &qdt, const QString &noti );
209 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 210 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
210 void removeAlarm(const QDateTime &qdt, const QString &noti ); 211 void removeAlarm(const QDateTime &qdt, const QString &noti );
211 212
212 /** options dialog made a changed to the configuration. we catch this 213 /** options dialog made a changed to the configuration. we catch this
213 * and notify all widgets which need to update their configuration. */ 214 * and notify all widgets which need to update their configuration. */
214 void updateConfig(); 215 void updateConfig();
215 216
216 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 217 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
217 const QStringList& anniversaryList, const QStringList& realNameList, 218 const QStringList& anniversaryList, const QStringList& realNameList,
218 const QStringList& emailList, const QStringList& assembledNameList, 219 const QStringList& emailList, const QStringList& assembledNameList,
219 const QStringList& uidList); 220 const QStringList& uidList);
220 221
221 /** 222 /**
222 Load calendar from file \a filename. If \a merge is true, load 223 Load calendar from file \a filename. If \a merge is true, load
223 calendar into existing one, if it is false, clear calendar, before 224 calendar into existing one, if it is false, clear calendar, before
224 loading. Return true, if calendar could be successfully loaded. 225 loading. Return true, if calendar could be successfully loaded.
225 */ 226 */
226 bool openCalendar(QString filename, bool merge=false); 227 bool openCalendar(QString filename, bool merge=false);
227 bool loadCalendars(); 228 bool loadCalendars();
228 bool saveCalendars(); 229 bool saveCalendars();
229 bool restoreCalendarSettings(); 230 bool restoreCalendarSettings();
230 bool addCalendar( KopiCalendarFile * ); 231 bool addCalendar( KopiCalendarFile * );
231 void addCalendarId( int id ); 232 void addCalendarId( int id );
232 bool syncCalendar(QString filename,int mode = 0 ); 233 bool syncCalendar(QString filename,int mode = 0 );
233 234
234 /** 235 /**
235 Save calendar data to file. Return true if calendar could be 236 Save calendar data to file. Return true if calendar could be
236 successfully saved. 237 successfully saved.
237 */ 238 */
238 bool saveCalendar(QString filename); 239 bool saveCalendar(QString filename);
239 240
240 /** 241 /**
241 Close calendar. Clear calendar data and reset views to display an empty 242 Close calendar. Clear calendar data and reset views to display an empty
242 calendar. 243 calendar.
243 */ 244 */
244 void closeCalendar(); 245 void closeCalendar();
245 246
246 /** Archive old events of calendar */ 247 /** Archive old events of calendar */
247 void archiveCalendar(); 248 void archiveCalendar();
248 249
249 void showIncidence(); 250 void showIncidence();
250 void editIncidence(); 251 void editIncidence();
251 void editIncidenceDescription(); 252 void editIncidenceDescription();
252 void deleteIncidence(); 253 void deleteIncidence();
253 void cloneIncidence(); 254 void cloneIncidence();
254 void moveIncidence(); 255 void moveIncidence();
255 void beamIncidence(); 256 void beamIncidence();
256 void toggleCancelIncidence(); 257 void toggleCancelIncidence();
257 258
258 /** create an editeventwin with supplied date/time, and if bool is true, 259 /** create an editeventwin with supplied date/time, and if bool is true,
259 * make the event take all day. */ 260 * make the event take all day. */
260 void newEvent(QDateTime, QDateTime, bool allDay ); 261 void newEvent(QDateTime, QDateTime, bool allDay );
261 void newEvent(QDateTime, QDateTime); 262 void newEvent(QDateTime, QDateTime);
262 void newEvent(QDateTime fh); 263 void newEvent(QDateTime fh);
263 void newEvent(QDate dt); 264 void newEvent(QDate dt);
264 /** create new event without having a date hint. Takes current date as 265 /** create new event without having a date hint. Takes current date as
265 default hint. */ 266 default hint. */
266 void newEvent(); 267 void newEvent();
267 void newFloatingEvent(); 268 void newFloatingEvent();
268 269
269 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 270 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
270 void showIncidence(Incidence *); 271 void showIncidence(Incidence *);
271 void showIncidence(QString uid); 272 void showIncidence(QString uid);
272 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 273 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
273 void editIncidence(Incidence *); 274 void editIncidence(Incidence *);
274 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 275 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
275 void deleteIncidence(Incidence *); 276 void deleteIncidence(Incidence *);
276 void cloneIncidence(Incidence *); 277 void cloneIncidence(Incidence *);
277 void cancelIncidence(Incidence *); 278 void cancelIncidence(Incidence *);
278 /** Create an editor for the supplied event. */ 279 /** Create an editor for the supplied event. */
279 void editEvent(Event *); 280 void editEvent(Event *);
280 /** Delete the supplied event. */ 281 /** Delete the supplied event. */
281 void deleteEvent(Event *); 282 void deleteEvent(Event *);
282 /** Delete the event with the given unique ID. Returns false, if event wasn't 283 /** Delete the event with the given unique ID. Returns false, if event wasn't
283 found. */ 284 found. */
284 bool deleteEvent(const QString &uid); 285 bool deleteEvent(const QString &uid);
285 /** Create a read-only viewer dialog for the supplied event. */ 286 /** Create a read-only viewer dialog for the supplied event. */
286 void showEvent(Event *); 287 void showEvent(Event *);
287 288
288 void editJournal(Journal *); 289 void editJournal(Journal *);
289 void showJournal(Journal *); 290 void showJournal(Journal *);
290 void deleteJournal(Journal *); 291 void deleteJournal(Journal *);
291 /** Create an editor dialog for a todo */ 292 /** Create an editor dialog for a todo */
292 void editTodo(Todo *); 293 void editTodo(Todo *);
293 /** Create a read-only viewer dialog for the supplied todo */ 294 /** Create a read-only viewer dialog for the supplied todo */
294 void showTodo(Todo *); 295 void showTodo(Todo *);
295 /** create new todo */ 296 /** create new todo */
296 void newTodo(); 297 void newTodo();
297 void newTodoDateTime(QDateTime, bool allday); 298 void newTodoDateTime(QDateTime, bool allday);
298 /** create new todo with a parent todo */ 299 /** create new todo with a parent todo */
299 void newSubTodo(); 300 void newSubTodo();
300 /** create new todo with a parent todo */ 301 /** create new todo with a parent todo */
301 void newSubTodo(Todo *); 302 void newSubTodo(Todo *);
302 /** Delete todo */ 303 /** Delete todo */
303 void deleteTodo(Todo *); 304 void deleteTodo(Todo *);
304 305
305 306
306 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 307 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
307 * emitted as result. */ 308 * emitted as result. */
308 void checkClipboard(); 309 void checkClipboard();
309 310
310 /** using the KConfig associated with the kapp variable, read in the 311 /** using the KConfig associated with the kapp variable, read in the
311 * settings from the config file. 312 * settings from the config file.
312 */ 313 */
313 void readSettings(); 314 void readSettings();
314 315
315 /** write current state to config file. */ 316 /** write current state to config file. */
316 void writeSettings(); 317 void writeSettings();
317 318
318 /** read settings for calendar filters */ 319 /** read settings for calendar filters */
319 void readFilterSettings(KConfig *config); 320 void readFilterSettings(KConfig *config);
320 321
321 /** write settings for calendar filters */ 322 /** write settings for calendar filters */
322 void writeFilterSettings(KConfig *config); 323 void writeFilterSettings(KConfig *config);
323 324
324 /** passes on the message that an event has changed to the currently 325 /** passes on the message that an event has changed to the currently
325 * activated view so that it can make appropriate display changes. */ 326 * activated view so that it can make appropriate display changes. */
326 void changeEventDisplay(Event *, int); 327 void changeEventDisplay(Event *, int);
327 void changeIncidenceDisplay(Incidence *, int); 328 void changeIncidenceDisplay(Incidence *, int);
328 void changeTodoDisplay(Todo *, int); 329 void changeTodoDisplay(Todo *, int);
329 330
330 void eventAdded(Event *); 331 void eventAdded(Event *);
331 void eventChanged(Event *); 332 void eventChanged(Event *);
332 void eventToBeDeleted(Event *); 333 void eventToBeDeleted(Event *);
333 void eventDeleted(); 334 void eventDeleted();
334 335
335 void todoAdded(Todo *); 336 void todoAdded(Todo *);
336 void todoChanged(Todo *); 337 void todoChanged(Todo *);
337 void todoToBeDeleted(Todo *); 338 void todoToBeDeleted(Todo *);
338 void todoDeleted(); 339 void todoDeleted();
339 340
340 void updateView(const QDate &start, const QDate &end); 341 void updateView(const QDate &start, const QDate &end);
341 void updateView(); 342 void updateView();
342 void clearAllViews(); 343 void clearAllViews();
343 344
344 /** Full update of visible todo views */ 345 /** Full update of visible todo views */
345 void updateTodoViews(); 346 void updateTodoViews();
346 347
347 void updateUnmanagedViews(); 348 void updateUnmanagedViews();
348 349
349 /** cut the current appointment to the clipboard */ 350 /** cut the current appointment to the clipboard */
350 void edit_cut(); 351 void edit_cut();
351 352
352 /** copy the current appointment(s) to the clipboard */ 353 /** copy the current appointment(s) to the clipboard */
353 void edit_copy(); 354 void edit_copy();
354 355
355 /** paste the current vobject(s) in the clipboard buffer into calendar */ 356 /** paste the current vobject(s) in the clipboard buffer into calendar */
356 void edit_paste(); 357 void edit_paste();
357 358
358 /** edit viewing and configuration options. */ 359 /** edit viewing and configuration options. */
359 void edit_options(); 360 void edit_options();
360 void edit_global_options(); 361 void edit_global_options();
361 /** 362 /**
362 Functions for printing, previewing a print, and setting up printing 363 Functions for printing, previewing a print, and setting up printing
363 parameters. 364 parameters.
364 */ 365 */
365 void print(); 366 void print();
366 void printSetup(); 367 void printSetup();
367 void printPreview(); 368 void printPreview();
368 369
369 /** Export as iCalendar file */ 370 /** Export as iCalendar file */
370 void exportICalendar(); 371 void exportICalendar();
371 372
372 /** Export as vCalendar file */ 373 /** Export as vCalendar file */
373 bool exportVCalendar( QString fn); 374 bool exportVCalendar( QString fn);
374 375
375 /** pop up a dialog to show an existing appointment. */ 376 /** pop up a dialog to show an existing appointment. */
376 void appointment_show(); 377 void appointment_show();
377 /** 378 /**
378 * pop up an Appointment Dialog to edit an existing appointment.Get 379 * pop up an Appointment Dialog to edit an existing appointment.Get
379 * information on the appointment from the list of unique IDs that is 380 * information on the appointment from the list of unique IDs that is
380 * currently in the View, called currIds. 381 * currently in the View, called currIds.
381 */ 382 */
382 void appointment_edit(); 383 void appointment_edit();
383 /** 384 /**
384 * pop up dialog confirming deletion of currently selected event in the 385 * pop up dialog confirming deletion of currently selected event in the
385 * View. 386 * View.
386 */ 387 */
387 void appointment_delete(); 388 void appointment_delete();
388 389
389 /** mails the currently selected event to a particular user as a vCalendar 390 /** mails the currently selected event to a particular user as a vCalendar
390 attachment. */ 391 attachment. */
391 void action_mail(); 392 void action_mail();
392 393
393 /* frees a subtodo from it's relation */ 394 /* frees a subtodo from it's relation */
394 void todo_unsub( Todo * ); 395 void todo_unsub( Todo * );
395 void todo_resub( Todo * parent, Todo * sub ); 396 void todo_resub( Todo * parent, Todo * sub );
396 397
397 /** Take ownership of selected event. */ 398 /** Take ownership of selected event. */
398 void takeOverEvent(); 399 void takeOverEvent();
399 400
400 /** Take ownership of all events in calendar. */ 401 /** Take ownership of all events in calendar. */
401 void takeOverCalendar(); 402 void takeOverCalendar();
402 403
403 /** query whether or not the calendar is "dirty". */ 404 /** query whether or not the calendar is "dirty". */
404 bool isModified(); 405 bool isModified();
405 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 406 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
406 void setModified(bool modified=true); 407 void setModified(bool modified=true);
407 408
408 /** query if the calendar is read-only. */ 409 /** query if the calendar is read-only. */
409 bool isReadOnly(); 410 bool isReadOnly();
410 /** set state of calendar to read-only */ 411 /** set state of calendar to read-only */
411 void setReadOnly(bool readOnly=true); 412 void setReadOnly(bool readOnly=true);
412 413
413 void eventUpdated(Incidence *); 414 void eventUpdated(Incidence *);
414 415
415 /* iTIP scheduling actions */ 416 /* iTIP scheduling actions */
416 void schedule_publish(Incidence *incidence = 0); 417 void schedule_publish(Incidence *incidence = 0);
417 void schedule_request(Incidence *incidence = 0); 418 void schedule_request(Incidence *incidence = 0);
418 void schedule_refresh(Incidence *incidence = 0); 419 void schedule_refresh(Incidence *incidence = 0);
419 void schedule_cancel(Incidence *incidence = 0); 420 void schedule_cancel(Incidence *incidence = 0);
420 void schedule_add(Incidence *incidence = 0); 421 void schedule_add(Incidence *incidence = 0);
421 void schedule_reply(Incidence *incidence = 0); 422 void schedule_reply(Incidence *incidence = 0);
422 void schedule_counter(Incidence *incidence = 0); 423 void schedule_counter(Incidence *incidence = 0);
423 void schedule_declinecounter(Incidence *incidence = 0); 424 void schedule_declinecounter(Incidence *incidence = 0);
424 void schedule_publish_freebusy(int daysToPublish = 30); 425 void schedule_publish_freebusy(int daysToPublish = 30);
425 426
426 void openAddressbook(); 427 void openAddressbook();
427 428
428 void editFilters(); 429 void editFilters();
429 void toggleFilerEnabled(); 430 void toggleFilerEnabled();
430 QPtrList<CalFilter> filters(); 431 QPtrList<CalFilter> filters();
431 void toggleFilter(); 432 void toggleFilter();
432 void showFilter(bool visible); 433 void showFilter(bool visible);
433 void updateFilter(); 434 void updateFilter();
434 void filterEdited(); 435 void filterEdited();
435 void selectFilter( int ); 436 void selectFilter( int );
436 KOFilterView *filterView(); 437 KOFilterView *filterView();
437 438
438 void showIntro(); 439 void showIntro();
439 440
440 /** Move the curdatepient view date to today */ 441 /** Move the curdatepient view date to today */
441 void goToday(); 442 void goToday();
442 443
443 /** Move to the next date(s) in the current view */ 444 /** Move to the next date(s) in the current view */
444 void goNext(); 445 void goNext();
445 446
446 /** Move to the previous date(s) in the current view */ 447 /** Move to the previous date(s) in the current view */
447 void goPrevious(); 448 void goPrevious();
448 /** Move to the next date(s) in the current view */ 449 /** Move to the next date(s) in the current view */
449 void goNextMonth(); 450 void goNextMonth();
450 451
451 /** Move to the previous date(s) in the current view */ 452 /** Move to the previous date(s) in the current view */
452 void goPreviousMonth(); 453 void goPreviousMonth();
453 454
454 void toggleExpand(); 455 void toggleExpand();
455 void toggleDateNavigatorWidget(); 456 void toggleDateNavigatorWidget();
456 void toggleAllDaySize(); 457 void toggleAllDaySize();
457 void dialogClosing(Incidence *); 458 void dialogClosing(Incidence *);
458 459
459 /** Look for new messages in the inbox */ 460 /** Look for new messages in the inbox */
460 void lookForIncomingMessages(); 461 void lookForIncomingMessages();
461 /** Look for new messages in the outbox */ 462 /** Look for new messages in the outbox */
462 void lookForOutgoingMessages(); 463 void lookForOutgoingMessages();
463 464
464 void processMainViewSelection( Incidence * ); 465 void processMainViewSelection( Incidence * );
465 void processTodoListSelection( Incidence * ); 466 void processTodoListSelection( Incidence * );
466 467
467 void processIncidenceSelection( Incidence * ); 468 void processIncidenceSelection( Incidence * );
468 469
469 void purgeCompleted(); 470 void purgeCompleted();
470 bool removeCompletedSubTodos( Todo* ); 471 bool removeCompletedSubTodos( Todo* );
471 void slotCalendarChanged(); 472 void slotCalendarChanged();
472 bool importBday(); 473 bool importBday();
473 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 474 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
474 bool importQtopia( const QString &categoriesFile, 475 bool importQtopia( const QString &categoriesFile,
475 const QString &datebookFile, 476 const QString &datebookFile,
476 const QString &tasklistFile ); 477 const QString &tasklistFile );
477 void syncExternal( int mode ); 478 void syncExternal( int mode );
478 void slotSelectPickerDate( QDate ) ; 479 void slotSelectPickerDate( QDate ) ;
479 void showDatePicker() ; 480 void showDatePicker() ;
480 void showDatePickerPopup() ; 481 void showDatePickerPopup() ;
481 void moveIncidence(Incidence *) ; 482 void moveIncidence(Incidence *) ;
482 void beamIncidence(Incidence *) ; 483 void beamIncidence(Incidence *) ;
483 void beamCalendar() ; 484 void beamCalendar() ;
484 void beamFilteredCalendar() ; 485 void beamFilteredCalendar() ;
485 void beamIncidenceList(QPtrList<Incidence>) ; 486 void beamIncidenceList(QPtrList<Incidence>) ;
486 void manageCategories(); 487 void manageCategories();
487 int addCategories(); 488 int addCategories();
488 void removeCategories(); 489 void removeCategories();
489 void setSyncDevice( QString ); 490 void setSyncDevice( QString );
490 void setSyncName( QString ); 491 void setSyncName( QString );
491 void showDay( QDate ); 492 void showDay( QDate );
492 void undo_delete(); 493 void undo_delete();
493 protected slots: 494 protected slots:
494 void resetFocus(); 495 void resetFocus();
496 void scrollBarValue(int);
495 void slotViewerClosed(); 497 void slotViewerClosed();
496 void timerAlarm(); 498 void timerAlarm();
497 void suspendAlarm(); 499 void suspendAlarm();
498 void beamDone( Ir *ir ); 500 void beamDone( Ir *ir );
499 /** Select a view or adapt the current view to display the specified dates. */ 501 /** Select a view or adapt the current view to display the specified dates. */
500 void showDates( const KCal::DateList & ); 502 void showDates( const KCal::DateList & );
501 void selectWeekNum ( int ); 503 void selectWeekNum ( int );
502 504
503 public: 505 public:
504 // show a standard warning 506 // show a standard warning
505 // returns KMsgBox::yesNoCancel() 507 // returns KMsgBox::yesNoCancel()
506 int msgCalModified(); 508 int msgCalModified();
507 virtual bool sync(KSyncManager* manager, QString filename, int mode); 509 virtual bool sync(KSyncManager* manager, QString filename, int mode);
508 510
509 virtual bool syncExternal(KSyncManager* manager, QString resource); 511 virtual bool syncExternal(KSyncManager* manager, QString resource);
510 virtual void removeSyncInfo( QString syncProfile); 512 virtual void removeSyncInfo( QString syncProfile);
511 void setSyncManager(KSyncManager* manager); 513 void setSyncManager(KSyncManager* manager);
512 void setLoadedFileVersion(QDateTime); 514 void setLoadedFileVersion(QDateTime);
513 bool checkFileVersion(QString fn); 515 bool checkFileVersion(QString fn);
514 bool checkAllFileVersions(); 516 bool checkAllFileVersions();
515 bool checkFileChanged(QString fn); 517 bool checkFileChanged(QString fn);
516 Event* getLastSyncEvent(); 518 Event* getLastSyncEvent();
517 /** Adapt navigation units correpsonding to step size of navigation of the 519 /** Adapt navigation units correpsonding to step size of navigation of the
518 * current view. 520 * current view.
519 */ 521 */
520 void adaptNavigationUnits(); 522 void adaptNavigationUnits();
521 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 523 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
522 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 524 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
523 //Attendee* getYourAttendee(Event *event); 525 //Attendee* getYourAttendee(Event *event);
524 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 526 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
527 void setScrollBarStep(int val );
528
525 protected: 529 protected:
526 void schedule(Scheduler::Method, Incidence *incidence = 0); 530 void schedule(Scheduler::Method, Incidence *incidence = 0);
527 531
528 // returns KMsgBox::OKCandel() 532 // returns KMsgBox::OKCandel()
529 int msgItemDelete(const QString name); 533 int msgItemDelete(const QString name);
530 void showEventEditor(); 534 void showEventEditor();
531 void showTodoEditor(); 535 void showTodoEditor();
532 void writeLocale();
533 Todo *selectedTodo(); 536 Todo *selectedTodo();
534
535 private: 537 private:
538 QScrollBar * mDateScrollBar;
536 QDateTime mNextAlarmDateTime; 539 QDateTime mNextAlarmDateTime;
537 bool mViewerCallerIsSearchDialog; 540 bool mViewerCallerIsSearchDialog;
538 bool mBlockShowDates; 541 bool mBlockShowDates;
539 KSyncManager* mSyncManager; 542 KSyncManager* mSyncManager;
540 AlarmDialog * mAlarmDialog; 543 AlarmDialog * mAlarmDialog;
541 QString mAlarmNotification; 544 QString mAlarmNotification;
542 QString mSuspendAlarmNotification; 545 QString mSuspendAlarmNotification;
543 QTimer* mSuspendTimer; 546 QTimer* mSuspendTimer;
544 QTimer* mAlarmTimer; 547 QTimer* mAlarmTimer;
545 QTimer* mRecheckAlarmTimer; 548 QTimer* mRecheckAlarmTimer;
546 void computeAlarm( QString ); 549 void computeAlarm( QString );
547 void startAlarm( QString, QString ); 550 void startAlarm( QString, QString );
548 void setSyncEventsReadOnly(); 551 void setSyncEventsReadOnly();
549 552
550 QDateTime loadedFileVersion; 553 QDateTime loadedFileVersion;
551 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 554 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
552 void checkExternalId( Incidence * inc ); 555 void checkExternalId( Incidence * inc );
553 int mGlobalSyncMode; 556 int mGlobalSyncMode;
554 QString mCurrentSyncDevice; 557 QString mCurrentSyncDevice;
555 QString mCurrentSyncName; 558 QString mCurrentSyncName;
556 KOBeamPrefs* beamDialog;
557 void init(); 559 void init();
558 int mDatePickerMode; 560 int mDatePickerMode;
559 bool mFlagEditDescription; 561 bool mFlagEditDescription;
560 QDateTime mLastCalendarSync; 562 QDateTime mLastCalendarSync;
561 void createPrinter(); 563 void createPrinter();
562 564
563 void calendarModified( bool, Calendar * ); 565 void calendarModified( bool, Calendar * );
564 566
565 CalPrinter *mCalPrinter; 567 CalPrinter *mCalPrinter;
566 568
567 QSplitter *mPanner; 569 QSplitter *mPanner;
568 QSplitter *mLeftSplitter; 570 QSplitter *mLeftSplitter;
569 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; 571 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
570 QWidgetStack *mRightFrame; 572 QWidgetStack *mRightFrame;
571 573
572 KDatePicker* mDatePicker; 574 KDatePicker* mDatePicker;
573 QVBox* mDateFrame; 575 QVBox* mDateFrame;
574 576
575 DateNavigatorContainer *mDateNavigator; // widget showing small month view. 577 DateNavigatorContainer *mDateNavigator; // widget showing small month view.
576 578
577 KOFilterView *mFilterView; 579 KOFilterView *mFilterView;
578 KOCalEditView *mCalEditView; 580 KOCalEditView *mCalEditView;
579 581
580 ResourceView *mResourceView; 582 ResourceView *mResourceView;
581 583
582 // calendar object for this viewing instance 584 // calendar object for this viewing instance
583 Calendar *mCalendar; 585 Calendar *mCalendar;
584 586
585 CalendarResourceManager *mResourceManager; 587 CalendarResourceManager *mResourceManager;
586 588
587 FileStorage *mStorage; 589 FileStorage *mStorage;
588 590
589 DateNavigator *mNavigator; 591 DateNavigator *mNavigator;
590 592
591 KOViewManager *mViewManager; 593 KOViewManager *mViewManager;
592 KODialogManager *mDialogManager; 594 KODialogManager *mDialogManager;
593 595
594 // Calendar filters 596 // Calendar filters
595 QPtrList<CalFilter> mFilters; 597 QPtrList<CalFilter> mFilters;
596 598
597 // various housekeeping variables. 599 // various housekeeping variables.
598 bool mModified; // flag indicating if calendar is modified 600 bool mModified; // flag indicating if calendar is modified
599 bool mReadOnly; // flag indicating if calendar is read-only 601 bool mReadOnly; // flag indicating if calendar is read-only
600 QDate mSaveSingleDate; 602 QDate mSaveSingleDate;
601 603
602 Incidence *mSelectedIncidence; 604 Incidence *mSelectedIncidence;
603 Incidence *mMoveIncidence; 605 Incidence *mMoveIncidence;
604 QDate mMoveIncidenceOldDate; 606 QDate mMoveIncidenceOldDate;
605 KOTodoView *mTodoList; 607 KOTodoView *mTodoList;
606 KOEventEditor * mEventEditor; 608 KOEventEditor * mEventEditor;
607 KOTodoEditor * mTodoEditor; 609 KOTodoEditor * mTodoEditor;
608 KOEventViewerDialog * mEventViewerDialog; 610 KOEventViewerDialog * mEventViewerDialog;
609 void keyPressEvent ( QKeyEvent *e) ; 611 void keyPressEvent ( QKeyEvent *e) ;
610 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 612 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
611}; 613};
612 614
613 615
614class CalendarViewVisitor : public Incidence::Visitor 616class CalendarViewVisitor : public Incidence::Visitor
615{ 617{
616 public: 618 public:
617 CalendarViewVisitor() : mView( 0 ) {} 619 CalendarViewVisitor() : mView( 0 ) {}
618 620
619 bool act( Incidence *incidence, CalendarView *view ) 621 bool act( Incidence *incidence, CalendarView *view )
620 { 622 {
621 mView = view; 623 mView = view;
622 return incidence->accept( *this ); 624 return incidence->accept( *this );
623 } 625 }
624 626
625 protected: 627 protected:
626 CalendarView *mView; 628 CalendarView *mView;
627}; 629};
628 630
629class ShowIncidenceVisitor : public CalendarViewVisitor 631class ShowIncidenceVisitor : public CalendarViewVisitor
630{ 632{
631 protected: 633 protected:
632 bool visit( Event *event ) { mView->showEvent( event ); return true; } 634 bool visit( Event *event ) { mView->showEvent( event ); return true; }
633 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 635 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
634 bool visit( Journal * j ) { mView->showJournal( j );return true; } 636 bool visit( Journal * j ) { mView->showJournal( j );return true; }
635}; 637};
636 638
637class EditIncidenceVisitor : public CalendarViewVisitor 639class EditIncidenceVisitor : public CalendarViewVisitor
638{ 640{
639 protected: 641 protected:
640 bool visit( Event *event ) { mView->editEvent( event ); return true; } 642 bool visit( Event *event ) { mView->editEvent( event ); return true; }
641 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 643 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
642 bool visit( Journal *j ) { mView->editJournal( j); return true; } 644 bool visit( Journal *j ) { mView->editJournal( j); return true; }
643}; 645};
644 646
645class DeleteIncidenceVisitor : public CalendarViewVisitor 647class DeleteIncidenceVisitor : public CalendarViewVisitor
646{ 648{
647 protected: 649 protected:
648 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 650 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
649 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 651 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
650 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 652 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
651}; 653};
652 654
653#endif 655#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 7b307f7..bd191d8 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,856 +1,866 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program 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 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 flagResetViewChangeDate = 0; 64 flagResetViewChangeDate = 0;
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") { 91 else if (view == "Month") {
92 if ( !KOPrefs::instance()->mMonthViewWeek ) 92 if ( !KOPrefs::instance()->mMonthViewWeek )
93 showMonthView(); 93 showMonthView();
94 else 94 else
95 showMonthViewWeek(); 95 showMonthViewWeek();
96 } 96 }
97 else if (view == "List") showListView(); 97 else if (view == "List") showListView();
98 else if (view == "Journal") showJournalView(); 98 else if (view == "Journal") showJournalView();
99 else if (view == "TimeSpan") showTimeSpanView(); 99 else if (view == "TimeSpan") showTimeSpanView();
100 else if (view == "Todo") showTodoView(); 100 else if (view == "Todo") showTodoView();
101 else { 101 else {
102 config->setGroup( "Views" ); 102 config->setGroup( "Views" );
103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
104 mCurrentAgendaView = dateCount; 104 mCurrentAgendaView = dateCount;
105 showAgendaView(); 105 showAgendaView();
106 mCurrentAgendaView = dateCount; 106 mCurrentAgendaView = dateCount;
107#ifdef DESKTOP_VERSION 107#ifdef DESKTOP_VERSION
108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
109#endif 109#endif
110 } 110 }
111} 111}
112 112
113 113
114void KOViewManager::showDateView( int view, QDate date) 114void KOViewManager::showDateView( int view, QDate date)
115{ 115{
116 static int lastMode = 0; 116 static int lastMode = 0;
117 static int lastCount = 0; 117 static int lastCount = 0;
118 static bool lastNDMode = false; 118 static bool lastNDMode = false;
119 static QDate lastDate; 119 static QDate lastDate;
120 //qDebug("date %d %s", view, date.toString().latin1()); 120 //qDebug("date %d %s", view, date.toString().latin1());
121 121
122 if (view != 9) 122 if (view != 9)
123 lastMode = 0; 123 lastMode = 0;
124 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 124 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
125 bool savemFlagShowNextxDays = mFlagShowNextxDays; 125 bool savemFlagShowNextxDays = mFlagShowNextxDays;
126 mFlagShowNextxDays = false; 126 mFlagShowNextxDays = false;
127 if ( view == 3 ) { 127 if ( view == 3 ) {
128 //mCurrentAgendaView = 1 ; 128 //mCurrentAgendaView = 1 ;
129 lastDate = mMainView->dateNavigator()->selectedDates().first(); 129 lastDate = mMainView->dateNavigator()->selectedDates().first();
130 lastCount = mMainView->dateNavigator()->selectedDates().count(); 130 lastCount = mMainView->dateNavigator()->selectedDates().count();
131 lastNDMode = savemFlagShowNextxDays; 131 lastNDMode = savemFlagShowNextxDays;
132 mMainView->dateNavigator()->selectDate( date ); 132 mMainView->dateNavigator()->selectDate( date );
133 lastMode = 1; 133 lastMode = 1;
134 mCurrentAgendaView = 1 ; 134 mCurrentAgendaView = 1 ;
135 } else if (view == 4 ) { 135 } else if (view == 4 ) {
136 mCurrentAgendaView = 7 ; 136 mCurrentAgendaView = 7 ;
137 mMainView->dateNavigator()->selectDates( date, 7 ); 137 mMainView->dateNavigator()->selectDates( date, 7 );
138 } else if (view == 5 ) { 138 } else if (view == 5 ) {
139 mCurrentAgendaView = 14 ; 139 mCurrentAgendaView = 14 ;
140 mMainView->dateNavigator()->selectDates( date, 14); 140 mMainView->dateNavigator()->selectDates( date, 14);
141 } else if (view == 6 ) { 141 } else if (view == 6 ) {
142 resetDateSilent( date,1); 142 resetDateSilent( date,1);
143 showMonthView(); 143 showMonthView();
144 } else if (view == 7 ) { 144 } else if (view == 7 ) {
145 mMainView->dateNavigator()->selectDate( date ); 145 mMainView->dateNavigator()->selectDate( date );
146 showJournalView(); 146 showJournalView();
147 } else if (view == 8 ) { 147 } else if (view == 8 ) {
148 globalFlagBlockAgenda = 1; 148 globalFlagBlockAgenda = 1;
149 if ( mCurrentAgendaView != 3 ) 149 if ( mCurrentAgendaView != 3 )
150 mCurrentAgendaView = -1; 150 mCurrentAgendaView = -1;
151 showAgendaView(KOPrefs::instance()->mFullViewMonth); 151 showAgendaView(KOPrefs::instance()->mFullViewMonth);
152 globalFlagBlockAgenda = 2; 152 globalFlagBlockAgenda = 2;
153 mMainView->dateNavigator()->selectDates( date , 153 mMainView->dateNavigator()->selectDates( date ,
154 KOPrefs::instance()->mNextXDays ); 154 KOPrefs::instance()->mNextXDays );
155 mFlagShowNextxDays = true; 155 mFlagShowNextxDays = true;
156 mCurrentAgendaView = 3 ; 156 mCurrentAgendaView = 3 ;
157 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 157 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
158 if ( lastMode ) { 158 if ( lastMode ) {
159 mCurrentAgendaView = lastCount ; 159 mCurrentAgendaView = lastCount ;
160 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 160 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
161 mFlagShowNextxDays = lastNDMode; 161 mFlagShowNextxDays = lastNDMode;
162 if ( mFlagShowNextxDays ) { 162 if ( mFlagShowNextxDays ) {
163 mCurrentAgendaView = 3 ; 163 mCurrentAgendaView = 3 ;
164 } 164 }
165 } else 165 } else
166 showWeekView(); 166 showWeekView();
167 } else if (view == 10) { 167 } else if (view == 10) {
168 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 168 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
169 } 169 }
170} 170}
171 171
172 172
173 173
174void KOViewManager::writeSettings(KConfig *config) 174void KOViewManager::writeSettings(KConfig *config)
175{ 175{
176 config->setGroup("General"); 176 config->setGroup("General");
177 177
178 QString view; 178 QString view;
179 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 179 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
180 else if (mCurrentView == mMonthView) view = "Month"; 180 else if (mCurrentView == mMonthView) view = "Month";
181 else if (mCurrentView == mListView) view = "List"; 181 else if (mCurrentView == mListView) view = "List";
182 else if (mCurrentView == mJournalView) view = "Journal"; 182 else if (mCurrentView == mJournalView) view = "Journal";
183 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 183 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
184 else if (mCurrentView == mTodoView) view = "Todo"; 184 else if (mCurrentView == mTodoView) view = "Todo";
185 else view = "Agenda"; 185 else view = "Agenda";
186 186
187 config->writeEntry("Current View",view); 187 config->writeEntry("Current View",view);
188 188
189 if (mAgendaView) { 189 if (mAgendaView) {
190 mAgendaView->writeSettings(config); 190 mAgendaView->writeSettings(config);
191 } 191 }
192 if (mTimeSpanView) { 192 if (mTimeSpanView) {
193 mTimeSpanView->writeSettings(config); 193 mTimeSpanView->writeSettings(config);
194 } 194 }
195 if (mListView) { 195 if (mListView) {
196 mListView->writeSettings(config); 196 mListView->writeSettings(config);
197 } 197 }
198 if (mTodoView) { 198 if (mTodoView) {
199 mTodoView->saveLayout(config,"Todo View"); 199 mTodoView->saveLayout(config,"Todo View");
200 } 200 }
201} 201}
202void KOViewManager::showNextView() 202void KOViewManager::showNextView()
203{ 203{
204 static int selecteddatescount = 0; 204 static int selecteddatescount = 0;
205 static QDate selecteddate = QDate ( 2000, 1, 1 ); 205 static QDate selecteddate = QDate ( 2000, 1, 1 );
206 static QDate baseCycleDate = QDate ( 2000, 1, 1 ); 206 static QDate baseCycleDate = QDate ( 2000, 1, 1 );
207 int newCount = mMainView->dateNavigator()->selectedDates().count(); 207 int newCount = mMainView->dateNavigator()->selectedDates().count();
208 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { 208 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) {
209 flagResetViewChangeDate = 1; 209 flagResetViewChangeDate = 1;
210 } 210 }
211 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) 211 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() )
212 flagResetViewChangeDate = 1; 212 flagResetViewChangeDate = 1;
213 if ( flagResetViewChangeDate > 0 ) { 213 if ( flagResetViewChangeDate > 0 ) {
214 baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); 214 baseCycleDate = mMainView->dateNavigator()->selectedDates().first();
215 //qDebug("newCycle "); 215 //qDebug("newCycle ");
216 } 216 }
217 if (mCurrentView == mWhatsNextView) goto NEXT_X; 217 if (mCurrentView == mWhatsNextView) goto NEXT_X;
218 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; 218 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL;
219 if (mCurrentView == mJournalView ) goto DAY_1; 219 if (mCurrentView == mJournalView ) goto DAY_1;
220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; 220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5;
221 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; 221 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7;
222 if (mCurrentView == mAgendaView ) goto DAY_6; 222 if (mCurrentView == mAgendaView ) goto DAY_6;
223 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; 223 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH;
224 if (mCurrentView == mMonthView ) goto LIST; 224 if (mCurrentView == mMonthView ) goto LIST;
225 if (mCurrentView == mListView ) goto TODO; 225 if (mCurrentView == mListView ) goto TODO;
226 // if (mCurrentView == mTodoView ) goto NEXT; 226 // if (mCurrentView == mTodoView ) goto NEXT;
227 NEXT: 227 NEXT:
228 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} 228 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;}
229 NEXT_X: 229 NEXT_X:
230 if ( KOPrefs::instance()->mShowIconNextDays ) { 230 if ( KOPrefs::instance()->mShowIconNextDays ) {
231 showNextXView(); 231 showNextXView();
232 goto ENTE ; 232 goto ENTE ;
233 } 233 }
234 JOURNAL: 234 JOURNAL:
235 if ( KOPrefs::instance()->mShowIconJournal ) { 235 if ( KOPrefs::instance()->mShowIconJournal ) {
236 resetDateSilent( baseCycleDate , 1 ); 236 resetDateSilent( baseCycleDate , 1 );
237 showJournalView() ;goto ENTE ;} 237 showJournalView() ;goto ENTE ;}
238 DAY_1: 238 DAY_1:
239 if ( KOPrefs::instance()->mShowIconDay1 ) { 239 if ( KOPrefs::instance()->mShowIconDay1 ) {
240 resetDateSilent( baseCycleDate , 2 ); 240 resetDateSilent( baseCycleDate , 2 );
241 showDayView() ;goto ENTE ;} 241 showDayView() ;goto ENTE ;}
242 DAY_5: 242 DAY_5:
243 if ( KOPrefs::instance()->mShowIconDay5 ) { 243 if ( KOPrefs::instance()->mShowIconDay5 ) {
244 resetDateSilent( baseCycleDate , 2 ); 244 resetDateSilent( baseCycleDate , 2 );
245 showWorkWeekView() ;goto ENTE ;} 245 showWorkWeekView() ;goto ENTE ;}
246 DAY_7: 246 DAY_7:
247 if ( KOPrefs::instance()->mShowIconDay7 ) { 247 if ( KOPrefs::instance()->mShowIconDay7 ) {
248 resetDateSilent( baseCycleDate , 2 ); 248 resetDateSilent( baseCycleDate , 2 );
249 showWeekView();goto ENTE ;} 249 showWeekView();goto ENTE ;}
250 DAY_6: 250 DAY_6:
251 if ( KOPrefs::instance()->mShowIconDay6 ) { 251 if ( KOPrefs::instance()->mShowIconDay6 ) {
252 resetDateSilent( baseCycleDate , 2 ); 252 resetDateSilent( baseCycleDate , 2 );
253 showMonthViewWeek();goto ENTE ;} 253 showMonthViewWeek();goto ENTE ;}
254 MONTH: 254 MONTH:
255 if ( KOPrefs::instance()->mShowIconMonth ) { 255 if ( KOPrefs::instance()->mShowIconMonth ) {
256 resetDateSilent( baseCycleDate , 2 ); 256 resetDateSilent( baseCycleDate , 2 );
257 showMonthView();goto ENTE ;} 257 showMonthView();goto ENTE ;}
258 LIST: 258 LIST:
259 if ( KOPrefs::instance()->mShowIconList ) { 259 if ( KOPrefs::instance()->mShowIconList ) {
260 resetDateSilent( baseCycleDate , 2 ); 260 resetDateSilent( baseCycleDate , 2 );
261 showListView() ;goto ENTE ;} 261 showListView() ;goto ENTE ;}
262 TODO: 262 TODO:
263 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 263 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
264 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} 264 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;}
265 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} 265 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;}
266 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} 266 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;}
267 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} 267 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;}
268 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} 268 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;}
269 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} 269 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;}
270 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} 270 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;}
271 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} 271 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;}
272 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} 272 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;}
273 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 273 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
274 ENTE: 274 ENTE:
275 flagResetViewChangeDate = 0; 275 flagResetViewChangeDate = 0;
276 selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); 276 selecteddatescount = mMainView->dateNavigator()->selectedDates().count();
277 selecteddate = mMainView->dateNavigator()->selectedDates().first(); 277 selecteddate = mMainView->dateNavigator()->selectedDates().first();
278 278
279} 279}
280void KOViewManager::resetDateSilent( QDate date , int days ) 280void KOViewManager::resetDateSilent( QDate date , int days )
281{ 281{
282 mMainView->dateNavigator()->blockSignals( true ); 282 mMainView->dateNavigator()->blockSignals( true );
283 mMainView->dateNavigator()->selectDates( date , days ); 283 mMainView->dateNavigator()->selectDates( date , days );
284 mMainView->dateNavigator()->blockSignals( false ); 284 mMainView->dateNavigator()->blockSignals( false );
285} 285}
286void KOViewManager::setDefaultCalendar(int) 286void KOViewManager::setDefaultCalendar(int)
287{ 287{
288 if ( mJournalView && mCurrentView == mJournalView ) 288 if ( mJournalView && mCurrentView == mJournalView )
289 mJournalView->updateView(); 289 mJournalView->updateView();
290} 290}
291 291
292void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 292void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
293{ 293{
294 if ( flagResetViewChangeDate < 10 ) 294 if ( flagResetViewChangeDate < 10 )
295 ++flagResetViewChangeDate; 295 ++flagResetViewChangeDate;
296 //mFlagShowNextxDays = false; 296 //mFlagShowNextxDays = false;
297 //if(view == mCurrentView) return; 297 //if(view == mCurrentView) return;
298 if ( view == 0 ) { 298 if ( view == 0 ) {
299 view = mCurrentView; 299 view = mCurrentView;
300 if ( view == 0 ) 300 if ( view == 0 )
301 return; 301 return;
302 } 302 }
303 bool callupdate = !(view == mCurrentView); 303 bool callupdate = !(view == mCurrentView);
304 bool full = fullScreen; 304 bool full = fullScreen;
305 if(view == mCurrentView && view != mWhatsNextView ) { 305 if(view == mCurrentView && view != mWhatsNextView ) {
306 if ( mCurrentAgendaView < 0 ) 306 if ( mCurrentAgendaView < 0 )
307 return; 307 return;
308 if ( view != mMonthView ) 308 if ( view != mMonthView )
309 full = mMainView->leftFrame()->isVisible(); 309 full = mMainView->leftFrame()->isVisible();
310 } else { 310 } else {
311 if ( view == mMonthView && mMonthView) 311 if ( view == mMonthView && mMonthView)
312 ;//mMonthView->skipResize = true ; 312 ;//mMonthView->skipResize = true ;
313 mCurrentView = view; 313 mCurrentView = view;
314 // bool full = fullScreen; 314 // bool full = fullScreen;
315 bool isFull = !mMainView->leftFrame()->isVisible(); 315 bool isFull = !mMainView->leftFrame()->isVisible();
316 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 316 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
317 full = true; 317 full = true;
318 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 318 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
319 full = false; 319 full = false;
320 } 320 }
321 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 321 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
322 //raiseCurrentView( full ); 322 //raiseCurrentView( full );
323 mMainView->processIncidenceSelection( 0 ); 323 mMainView->processIncidenceSelection( 0 );
324 //mMainView->updateView(); 324 //mMainView->updateView();
325 raiseCurrentView( full, callupdate ); 325 raiseCurrentView( full, callupdate );
326 mMainView->adaptNavigationUnits(); 326 mMainView->adaptNavigationUnits();
327 mMainView->updateUnmanagedViews(); 327 mMainView->updateUnmanagedViews();
328} 328}
329 329
330void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 330void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
331{ 331{
332 mCurrentAgendaView = 0; 332 mCurrentAgendaView = 0;
333 if ( fullScreen ) { 333 if ( fullScreen ) {
334 mMainView->leftFrame()->hide(); 334 mMainView->leftFrame()->hide();
335 } else { 335 } else {
336 mMainView->leftFrame()->show(); 336 mMainView->leftFrame()->show();
337 } 337 }
338 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 338 //if ( mCurrentView == mMonthView ) qApp->processEvents();
339 emit signalFullScreen( !fullScreen ); 339 emit signalFullScreen( !fullScreen );
340 if ( callUpdateView ) 340 if ( callUpdateView )
341 mMainView->updateView(); 341 mMainView->updateView();
342 342
343 if ( globalFlagBlockAgenda == 5 ) { 343 if ( globalFlagBlockAgenda == 5 ) {
344 globalFlagBlockAgenda = 4; 344 globalFlagBlockAgenda = 4;
345 globalFlagBlockAgendaItemPaint = 1; 345 globalFlagBlockAgendaItemPaint = 1;
346 } 346 }
347 mMainView->viewStack()->raiseWidget(mCurrentView); 347 mMainView->viewStack()->raiseWidget(mCurrentView);
348 if ( globalFlagBlockAgenda == 4 ) { 348 if ( globalFlagBlockAgenda == 4 ) {
349 if ( mCurrentView == mAgendaView ) { 349 if ( mCurrentView == mAgendaView ) {
350 //globalFlagBlockAgenda =1 ; 350 //globalFlagBlockAgenda =1 ;
351 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 351 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
352 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 352 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
353 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 353 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
354 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 354 mAgendaView->setStartHour( QTime::currentTime ().hour() );
355 qApp->processEvents(); 355 qApp->processEvents();
356 //qDebug("qApp->processEvents() "); 356 //qDebug("qApp->processEvents() ");
357 globalFlagBlockAgenda = 0; 357 globalFlagBlockAgenda = 0;
358 mAgendaView->repaintAgenda(); 358 mAgendaView->repaintAgenda();
359 359
360 } 360 }
361 globalFlagBlockAgenda = 0; 361 globalFlagBlockAgenda = 0;
362 } 362 }
363 emit signalAgendaView( mCurrentView == mAgendaView ); 363 emit signalAgendaView( mCurrentView == mAgendaView );
364 //qDebug("raiseCurrentView ende "); 364 //qDebug("raiseCurrentView ende ");
365 365
366} 366}
367 367
368void KOViewManager::clearAllViews() 368void KOViewManager::clearAllViews()
369{ 369{
370 370
371 if ( mTodoView ) mTodoView->clearList(); 371 if ( mTodoView ) mTodoView->clearList();
372 if ( mListView ) mListView->clearList(); 372 if ( mListView ) mListView->clearList();
373 373
374 if ( mAgendaView ) mAgendaView->clearList(); 374 if ( mAgendaView ) mAgendaView->clearList();
375 if ( mMonthView ) mMonthView->clearList(); 375 if ( mMonthView ) mMonthView->clearList();
376 if ( mWhatsNextView ) mWhatsNextView->clearList(); 376 if ( mWhatsNextView ) mWhatsNextView->clearList();
377 if ( mJournalView ) mJournalView->clearList(); 377 if ( mJournalView ) mJournalView->clearList();
378 378
379} 379}
380void KOViewManager::updateView() 380void KOViewManager::updateView()
381{ 381{
382 // qDebug("KOViewManager::updateView() "); 382 // qDebug("KOViewManager::updateView() ");
383 // if we are updating mTodoView, we get endless recursion 383 // if we are updating mTodoView, we get endless recursion
384 if ( mTodoView == mCurrentView ) 384 if ( mTodoView == mCurrentView )
385 return; 385 return;
386 if ( mCurrentView ) mCurrentView->updateView(); 386 if ( mCurrentView ) mCurrentView->updateView();
387 387
388} 388}
389 389
390void KOViewManager::updateView(const QDate &start, const QDate &end) 390void KOViewManager::updateView(const QDate &start, const QDate &end)
391{ 391{
392 // kdDebug() << "KOViewManager::updateView()" << endl; 392 // kdDebug() << "KOViewManager::updateView()" << endl;
393 393
394 if (mCurrentView) mCurrentView->showDates(start, end); 394 if (mCurrentView) mCurrentView->showDates(start, end);
395 395
396 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 396 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
397} 397}
398 398
399 399
400void KOViewManager::updateWNview() 400void KOViewManager::updateWNview()
401{ 401{
402 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 402 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
403 mWhatsNextView->updateView(); 403 mWhatsNextView->updateView();
404 if ( mCurrentView == mMonthView && mMonthView ) 404 if ( mCurrentView == mMonthView && mMonthView )
405 mMonthView->updateView(); 405 mMonthView->updateView();
406 406
407} 407}
408void KOViewManager::showWhatsNextView() 408void KOViewManager::showWhatsNextView()
409{ 409{
410 if (!mWhatsNextView) { 410 if (!mWhatsNextView) {
411 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 411 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
412 "KOViewManager::WhatsNextView"); 412 "KOViewManager::WhatsNextView");
413 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 413 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
414 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 414 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
415 addView(mWhatsNextView); 415 addView(mWhatsNextView);
416 connect(this, SIGNAL( printWNV() ), 416 connect(this, SIGNAL( printWNV() ),
417 mWhatsNextView, SLOT( printMe() ) ); 417 mWhatsNextView, SLOT( printMe() ) );
418 } 418 }
419 globalFlagBlockAgenda = 1; 419 globalFlagBlockAgenda = 1;
420 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 420 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
421 showView(mWhatsNextView, true ); 421 showView(mWhatsNextView, true );
422 //mWhatsNextView->updateView(); 422 //mWhatsNextView->updateView();
423 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 423 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
424} 424}
425 425
426void KOViewManager::slotprintWNV() 426void KOViewManager::slotprintWNV()
427{ 427{
428 if (!mWhatsNextView) 428 if (!mWhatsNextView)
429 showWhatsNextView(); 429 showWhatsNextView();
430 emit printWNV(); 430 emit printWNV();
431 431
432} 432}
433void KOViewManager::showListView() 433void KOViewManager::showListView()
434{ 434{
435 if (!mListView) { 435 if (!mListView) {
436 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 436 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
437 addView(mListView); 437 addView(mListView);
438 438
439 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 439 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
440 mMainView, SLOT(showIncidence(Incidence *))); 440 mMainView, SLOT(showIncidence(Incidence *)));
441 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 441 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
442 mMainView, SLOT(editIncidence(Incidence *))); 442 mMainView, SLOT(editIncidence(Incidence *)));
443 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 443 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
444 mMainView, SLOT(deleteIncidence(Incidence *))); 444 mMainView, SLOT(deleteIncidence(Incidence *)));
445 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 445 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
446 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 446 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
447 connect( mListView, SIGNAL( signalNewEvent() ), 447 connect( mListView, SIGNAL( signalNewEvent() ),
448 mMainView, SLOT( newEvent() ) ); 448 mMainView, SLOT( newEvent() ) );
449 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 449 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
450 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 450 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
451 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 451 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
452 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 452 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
453 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 453 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
454 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 454 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
455 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 455 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
456 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 456 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
457 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 457 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
458 } 458 }
459 // bool temp = mFlagShowNextxDays; 459 // bool temp = mFlagShowNextxDays;
460 //globalFlagBlockPainting = true; 460 //globalFlagBlockPainting = true;
461 globalFlagBlockAgenda = 1; 461 globalFlagBlockAgenda = 1;
462 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 462 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
463 mMainView->setBlockShowDates( true ); 463 mMainView->setBlockShowDates( true );
464 mMainView->dateNavigator()->selectMonth(); 464 mMainView->dateNavigator()->selectMonth();
465 mMainView->setBlockShowDates( false ); 465 mMainView->setBlockShowDates( false );
466 } 466 }
467 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 467 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
468 showView(mListView, KOPrefs::instance()->mFullViewTodo); 468 showView(mListView, KOPrefs::instance()->mFullViewTodo);
469 //mFlagShowNextxDays = temp; 469 //mFlagShowNextxDays = temp;
470 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 470 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
471 mMainView->setScrollBarStep( 7 );
471} 472}
472 473
473void KOViewManager::showAgendaView( bool fullScreen ) 474void KOViewManager::showAgendaView( bool fullScreen )
474{ 475{
475 476
476 mMainView->dialogManager()->hideSearchDialog(); 477 mMainView->dialogManager()->hideSearchDialog();
477 // qDebug("KOViewManager::showAgendaView "); 478 // qDebug("KOViewManager::showAgendaView ");
478 bool full; 479 bool full;
479 full = fullScreen; 480 full = fullScreen;
480 if (!mAgendaView) { 481 if (!mAgendaView) {
481 full = false; 482 full = false;
482 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 483 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
483 addView(mAgendaView); 484 addView(mAgendaView);
484#ifndef DESKTOP_VERSION 485#ifndef DESKTOP_VERSION
485 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 486 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
486#endif 487#endif
487 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 488 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
488 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 489 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
489 490
490 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 491 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
491 492
492 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 493 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
493 494
494 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 495 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
495 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 496 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
496 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 497 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
497 mMainView, SLOT(newEvent(QDateTime))); 498 mMainView, SLOT(newEvent(QDateTime)));
498 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 499 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
499 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 500 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
500 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 501 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
501 mMainView, SLOT(newEvent(QDate))); 502 mMainView, SLOT(newEvent(QDate)));
502 503
503 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 504 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
504 mMainView, SLOT(editIncidence(Incidence *))); 505 mMainView, SLOT(editIncidence(Incidence *)));
505 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 506 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
506 mMainView, SLOT(showIncidence(Incidence *))); 507 mMainView, SLOT(showIncidence(Incidence *)));
507 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 508 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
508 mMainView, SLOT(deleteIncidence(Incidence *))); 509 mMainView, SLOT(deleteIncidence(Incidence *)));
509 510
510 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 511 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
511 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 512 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
512 513
513 connect(mAgendaView, SIGNAL( toggleExpand() ), 514 connect(mAgendaView, SIGNAL( toggleExpand() ),
514 mMainView, SLOT( toggleExpand() ) ); 515 mMainView, SLOT( toggleExpand() ) );
515 516
516 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 517 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
517 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 518 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
518 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 519 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
519 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 520 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
520 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 521 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
521 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 522 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
522 SLOT( updateTodo( Todo *, int ) ) ); 523 SLOT( updateTodo( Todo *, int ) ) );
523 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 524 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
524 mMainView, SIGNAL( todoModified( Todo *, int ))); 525 mMainView, SIGNAL( todoModified( Todo *, int )));
525 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 526 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
526 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 527 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
527 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 528 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
528 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 529 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
529 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 530 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
530 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 531 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
531 mAgendaView->readSettings(); 532 mAgendaView->readSettings();
532 mAgendaView->updateConfig(); 533 mAgendaView->updateConfig();
533 } 534 }
534 535
535 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; 536 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
536 showView( mAgendaView, full); 537 showView( mAgendaView, full);
537 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; 538 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
539 mMainView->setScrollBarStep( 1 );
538} 540}
539 541
540void KOViewManager::showDayView() 542void KOViewManager::showDayView()
541{ 543{
542 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 544 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
543 mFlagShowNextxDays = false; 545 mFlagShowNextxDays = false;
544 globalFlagBlockLabel = 1; 546 globalFlagBlockLabel = 1;
545 globalFlagBlockAgenda = 1; 547 globalFlagBlockAgenda = 1;
546 if ( mCurrentAgendaView != 1 ) 548 if ( mCurrentAgendaView != 1 )
547 mCurrentAgendaView = -1; 549 mCurrentAgendaView = -1;
548 showAgendaView(); 550 showAgendaView();
549 qApp->processEvents(); 551 qApp->processEvents();
550 globalFlagBlockAgenda = 2; 552 globalFlagBlockAgenda = 2;
551 globalFlagBlockLabel = 0; 553 globalFlagBlockLabel = 0;
552 mMainView->dateNavigator()->selectDates( 1 ); 554 mMainView->dateNavigator()->selectDates( 1 );
553 mCurrentAgendaView = 1 ; 555 mCurrentAgendaView = 1 ;
556 mMainView->setScrollBarStep( 1 );
554 557
555} 558}
556 559
557void KOViewManager::showWorkWeekView() 560void KOViewManager::showWorkWeekView()
558{ 561{
559 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 562 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
560 mFlagShowNextxDays = false; 563 mFlagShowNextxDays = false;
561 globalFlagBlockAgenda = 1; 564 globalFlagBlockAgenda = 1;
562 globalFlagBlockLabel = 1; 565 globalFlagBlockLabel = 1;
563 if ( mCurrentAgendaView != 5 ) 566 if ( mCurrentAgendaView != 5 )
564 mCurrentAgendaView = -1; 567 mCurrentAgendaView = -1;
565 showAgendaView(); 568 showAgendaView();
566 qApp->processEvents(); 569 qApp->processEvents();
567 globalFlagBlockAgenda = 2; 570 globalFlagBlockAgenda = 2;
568 globalFlagBlockLabel = 0; 571 globalFlagBlockLabel = 0;
569 mMainView->dateNavigator()->selectWorkWeek(); 572 mMainView->dateNavigator()->selectWorkWeek();
570 mCurrentAgendaView = 5 ; 573 mCurrentAgendaView = 5 ;
574 mMainView->setScrollBarStep( 1 );
571 575
572} 576}
573 577
574void KOViewManager::showWeekView() 578void KOViewManager::showWeekView()
575{ 579{
576 580
577 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 581 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
578 mFlagShowNextxDays = false; 582 mFlagShowNextxDays = false;
579 globalFlagBlockAgenda = 1; 583 globalFlagBlockAgenda = 1;
580 globalFlagBlockLabel = 1; 584 globalFlagBlockLabel = 1;
581 if ( mCurrentAgendaView != 7 ) 585 if ( mCurrentAgendaView != 7 )
582 mCurrentAgendaView = -1; 586 mCurrentAgendaView = -1;
583 showAgendaView(); 587 showAgendaView();
584 qApp->processEvents(); 588 qApp->processEvents();
585 globalFlagBlockAgenda = 2; 589 globalFlagBlockAgenda = 2;
586 globalFlagBlockLabel = 0; 590 globalFlagBlockLabel = 0;
587 mMainView->dateNavigator()->selectWeek(); 591 mMainView->dateNavigator()->selectWeek();
588 mCurrentAgendaView = 7 ; 592 mCurrentAgendaView = 7 ;
593 mMainView->setScrollBarStep( 1 );
589} 594}
590 595
591void KOViewManager::showNextXView() 596void KOViewManager::showNextXView()
592{ 597{
593 598
594 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; 599 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
595 globalFlagBlockAgenda = 1; 600 globalFlagBlockAgenda = 1;
596 if ( mCurrentAgendaView != 3 ) 601 if ( mCurrentAgendaView != 3 )
597 mCurrentAgendaView = -1; 602 mCurrentAgendaView = -1;
598 showAgendaView(KOPrefs::instance()->mFullViewMonth); 603 showAgendaView(KOPrefs::instance()->mFullViewMonth);
599 globalFlagBlockAgenda = 2; 604 globalFlagBlockAgenda = 2;
600 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 605 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
601 KOPrefs::instance()->mNextXDays ); 606 KOPrefs::instance()->mNextXDays );
602 mFlagShowNextxDays = true; 607 mFlagShowNextxDays = true;
603 mCurrentAgendaView = 3 ; 608 mCurrentAgendaView = 3 ;
604 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; 609 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
610 mMainView->setScrollBarStep( KOPrefs::instance()->mNextXDays );
605} 611}
606bool KOViewManager::showsNextDays() 612bool KOViewManager::showsNextDays()
607{ 613{
608 return mFlagShowNextxDays; 614 return mFlagShowNextxDays;
609} 615}
610void KOViewManager::createMonthView() 616void KOViewManager::createMonthView()
611{ 617{
612if (!mMonthView) { 618if (!mMonthView) {
613 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 619 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
614 620
615 addView(mMonthView); 621 addView(mMonthView);
616 // mMonthView->show(); 622 // mMonthView->show();
617 // SIGNALS/SLOTS FOR MONTH VIEW 623 // SIGNALS/SLOTS FOR MONTH VIEW
618 624
619 connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate ))); 625 connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate )));
620 626
621 connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)), 627 connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)),
622 mMainView, SLOT(newTodoDateTime(QDateTime, bool))); 628 mMainView, SLOT(newTodoDateTime(QDateTime, bool)));
623 629
624 630
625 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 631 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
626 mMainView, SLOT(newEvent(QDateTime))); 632 mMainView, SLOT(newEvent(QDateTime)));
627 633
628 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 634 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
629 mMainView, SLOT(showIncidence(Incidence *))); 635 mMainView, SLOT(showIncidence(Incidence *)));
630 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 636 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
631 mMainView, SLOT(editIncidence(Incidence *))); 637 mMainView, SLOT(editIncidence(Incidence *)));
632 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 638 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
633 mMainView, SLOT(deleteIncidence(Incidence *))); 639 mMainView, SLOT(deleteIncidence(Incidence *)));
634 640
635 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 641 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
636 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 642 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
637 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 643 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
638 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 644 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
639 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 645 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
640 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 646 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
641 647
642 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 648 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
643 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 649 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
644 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 650 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
645 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 651 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
646 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 652 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
647 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 653 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
648 connect( mMonthView, SIGNAL( selectMonth() ), 654 connect( mMonthView, SIGNAL( selectMonth() ),
649 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); 655 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
650 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 656 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
651 mMainView, SLOT ( showDay( QDate ) ) ); 657 mMainView, SLOT ( showDay( QDate ) ) );
652 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 658 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
653 connect( mMonthView, SIGNAL(nextMonth() ), 659 connect( mMonthView, SIGNAL(nextMonth() ),
654 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 660 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
655 connect( mMonthView, SIGNAL(prevMonth() ), 661 connect( mMonthView, SIGNAL(prevMonth() ),
656 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 662 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
657 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 663 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
658 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 664 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
659 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 665 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
660 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 666 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
661 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 667 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
662 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 668 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
663 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 669 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
664 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 670 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
665 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), 671 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
666 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); 672 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
667 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), 673 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
668 mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); 674 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
669 675
670 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 676 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
671 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 677 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
672 678
673 679
674 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 680 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
675 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 681 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
676 682
677 } 683 }
678} 684}
679void KOViewManager::showMonthViewWeek() 685void KOViewManager::showMonthViewWeek()
680{ 686{
681 createMonthView(); 687 createMonthView();
682 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; 688 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
683 globalFlagBlockAgenda = 1; 689 globalFlagBlockAgenda = 1;
684 bool full = true; 690 bool full = true;
685 if ( mCurrentView == mMonthView) 691 if ( mCurrentView == mMonthView)
686 full = mMainView->leftFrame()->isVisible(); 692 full = mMainView->leftFrame()->isVisible();
687 if ( !KOPrefs::instance()->mMonthViewWeek ) { 693 if ( !KOPrefs::instance()->mMonthViewWeek ) {
688 mMonthView->switchView(); 694 mMonthView->switchView();
689 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 695 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
690 full = false; 696 full = false;
691 else 697 else
692 full = true; 698 full = true;
693 } 699 }
694 mMainView->dateNavigator()->selectWeek(); 700 mMainView->dateNavigator()->selectWeek();
695 showView(mMonthView, full ); 701 showView(mMonthView, full );
696 mMonthView->setKeyBFocus(); 702 mMonthView->setKeyBFocus();
697 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; 703 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
704 mMainView->setScrollBarStep( 7 );
698} 705}
699 706
700void KOViewManager::showMonth( const QDate & date ) 707void KOViewManager::showMonth( const QDate & date )
701{ 708{
702 mMainView->dateNavigator()->blockSignals( true ); 709 mMainView->dateNavigator()->blockSignals( true );
703 mMainView->dateNavigator()->selectDate( date ); 710 mMainView->dateNavigator()->selectDate( date );
704 mMainView->dateNavigator()->blockSignals( false ); 711 mMainView->dateNavigator()->blockSignals( false );
705 showMonthView(); 712 showMonthView();
706} 713}
707void KOViewManager::showMonthView() 714void KOViewManager::showMonthView()
708 { 715 {
709 716
710 createMonthView(); 717 createMonthView();
711 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; 718 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
712 globalFlagBlockAgenda = 1; 719 globalFlagBlockAgenda = 1;
713 //mFlagShowNextxDays = false; 720 //mFlagShowNextxDays = false;
714 bool full = true; 721 bool full = true;
715 if ( mCurrentView == mMonthView) 722 if ( mCurrentView == mMonthView)
716 full = mMainView->leftFrame()->isVisible(); 723 full = mMainView->leftFrame()->isVisible();
717 // if(mMonthView == mCurrentView) return; 724 // if(mMonthView == mCurrentView) return;
718 if ( KOPrefs::instance()->mMonthViewWeek ) { 725 if ( KOPrefs::instance()->mMonthViewWeek ) {
719 mMonthView->switchView(); 726 mMonthView->switchView();
720 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 727 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
721 full = false; 728 full = false;
722 else 729 else
723 full = true; 730 full = true;
724 } 731 }
725 mMainView->dateNavigator()->selectMonth(); 732 mMainView->dateNavigator()->selectMonth();
726 733
727 showView(mMonthView, full ); 734 showView(mMonthView, full );
728 mMonthView->setKeyBFocus(); 735 mMonthView->setKeyBFocus();
729 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; 736 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
737 mMainView->setScrollBarStep( 7 );
730 738
731} 739}
732 740
733void KOViewManager::showTodoView() 741void KOViewManager::showTodoView()
734{ 742{
735 //mFlagShowNextxDays = false; 743 //mFlagShowNextxDays = false;
736 if ( !mTodoView ) { 744 if ( !mTodoView ) {
737 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 745 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
738 "KOViewManager::TodoView" ); 746 "KOViewManager::TodoView" );
739 747
740 addView( mTodoView ); 748 addView( mTodoView );
741 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 749 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
742 750
743 // SIGNALS/SLOTS FOR TODO VIEW 751 // SIGNALS/SLOTS FOR TODO VIEW
744 connect( mTodoView, SIGNAL( newTodoSignal() ), 752 connect( mTodoView, SIGNAL( newTodoSignal() ),
745 mMainView, SLOT( newTodo() ) ); 753 mMainView, SLOT( newTodo() ) );
746 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 754 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
747 mMainView, SLOT( newSubTodo( Todo *) ) ); 755 mMainView, SLOT( newSubTodo( Todo *) ) );
748 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 756 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
749 mMainView, SLOT( showTodo( Todo * ) ) ); 757 mMainView, SLOT( showTodo( Todo * ) ) );
750 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 758 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
751 mMainView, SLOT( editTodo( Todo * ) ) ); 759 mMainView, SLOT( editTodo( Todo * ) ) );
752 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 760 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
753 mMainView, SLOT( deleteTodo( Todo * ) ) ); 761 mMainView, SLOT( deleteTodo( Todo * ) ) );
754 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 762 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
755 mMainView, SLOT( purgeCompleted() ) ); 763 mMainView, SLOT( purgeCompleted() ) );
756 764
757 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 765 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
758 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 766 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
759 767
760 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 768 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
761 SLOT( updateConfig() ) ); 769 SLOT( updateConfig() ) );
762 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 770 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
763 SLOT( updateTodo( Todo *, int ) ) ); 771 SLOT( updateTodo( Todo *, int ) ) );
764 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 772 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
765 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 773 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
766 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 774 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
767 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 775 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
768 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 776 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
769 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 777 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
770 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 778 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
771 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 779 mMainView, SLOT ( todo_unsub( Todo * ) ) );
772 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 780 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
773 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 781 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
774 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 782 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
775 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 783 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
776 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 784 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
777 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 785 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
778 KConfig *config = KOGlobals::config(); 786 KConfig *config = KOGlobals::config();
779 mTodoView->restoreLayout(config,"Todo View"); 787 mTodoView->restoreLayout(config,"Todo View");
780 mTodoView->setNavigator( mMainView->dateNavigator() ); 788 mTodoView->setNavigator( mMainView->dateNavigator() );
781 } 789 }
782 790
783 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 791 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
784 globalFlagBlockAgenda = 1; 792 globalFlagBlockAgenda = 1;
785 showView( mTodoView, true ); 793 showView( mTodoView, true );
786 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 794 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
795 mMainView->setScrollBarStep( 7 );
787 796
788} 797}
789 798
790void KOViewManager::showJournalView() 799void KOViewManager::showJournalView()
791{ 800{
792 //mFlagShowNextxDays = false; 801 //mFlagShowNextxDays = false;
793 if (!mJournalView) { 802 if (!mJournalView) {
794 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 803 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
795 "KOViewManager::JournalView"); 804 "KOViewManager::JournalView");
796 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 805 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
797 SLOT( updateConfig() ) ); 806 SLOT( updateConfig() ) );
798 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 807 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
799 addView(mJournalView); 808 addView(mJournalView);
800 } 809 }
801 810
802 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 811 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
803 showView(mJournalView); 812 showView(mJournalView);
804 mMainView->dateNavigator()->selectDates( 1 ); 813 mMainView->dateNavigator()->selectDates( 1 );
805 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 814 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
815 mMainView->setScrollBarStep( 1 );
806} 816}
807 817
808void KOViewManager::showTimeSpanView() 818void KOViewManager::showTimeSpanView()
809{ 819{
810 //mFlagShowNextxDays = false; 820 //mFlagShowNextxDays = false;
811 if (!mTimeSpanView) { 821 if (!mTimeSpanView) {
812 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 822 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
813 "KOViewManager::TimeSpanView"); 823 "KOViewManager::TimeSpanView");
814 addView(mTimeSpanView); 824 addView(mTimeSpanView);
815 825
816 mTimeSpanView->readSettings(); 826 mTimeSpanView->readSettings();
817 } 827 }
818 828
819 showView(mTimeSpanView); 829 showView(mTimeSpanView);
820} 830}
821 831
822Incidence *KOViewManager::currentSelection() 832Incidence *KOViewManager::currentSelection()
823{ 833{
824 if (!mCurrentView) return 0; 834 if (!mCurrentView) return 0;
825 if ( mCurrentView == mListView ) { 835 if ( mCurrentView == mListView ) {
826 if ( mListView->currentItem() ) 836 if ( mListView->currentItem() )
827 return mListView->currentItem(); 837 return mListView->currentItem();
828 } 838 }
829 return mCurrentView->selectedIncidences().first(); 839 return mCurrentView->selectedIncidences().first();
830} 840}
831 841
832QDate KOViewManager::currentSelectionDate() 842QDate KOViewManager::currentSelectionDate()
833{ 843{
834 QDate qd; 844 QDate qd;
835 if (mCurrentView) { 845 if (mCurrentView) {
836 DateList qvl = mCurrentView->selectedDates(); 846 DateList qvl = mCurrentView->selectedDates();
837 if (!qvl.isEmpty()) qd = qvl.first(); 847 if (!qvl.isEmpty()) qd = qvl.first();
838 } 848 }
839 return qd; 849 return qd;
840} 850}
841 851
842void KOViewManager::addView(KOrg::BaseView *view) 852void KOViewManager::addView(KOrg::BaseView *view)
843{ 853{
844#if QT_VERSION >= 0x030000 854#if QT_VERSION >= 0x030000
845 mMainView->viewStack()->addWidget( view ); 855 mMainView->viewStack()->addWidget( view );
846#else 856#else
847 mMainView->viewStack()->addWidget( view, 1 ); 857 mMainView->viewStack()->addWidget( view, 1 );
848#endif 858#endif
849} 859}
850 860
851void KOViewManager::setDocumentId( const QString &id ) 861void KOViewManager::setDocumentId( const QString &id )
852{ 862{
853 if (mTodoView) { 863 if (mTodoView) {
854 mTodoView->setDocumentId( id ); 864 mTodoView->setDocumentId( id );
855 } 865 }
856} 866}