summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-10-26 09:10:50 (UTC)
committer zautrix <zautrix>2005-10-26 09:10:50 (UTC)
commit15b9123c6c1f9096a4b1a7729c323433d408c8d7 (patch) (unidiff)
tree3d9a8a521df355641642172ab1200a0f75529910 /korganizer
parentf696b904526567d45cd01a5b607644f8aa3bfe6b (diff)
downloadkdepimpi-15b9123c6c1f9096a4b1a7729c323433d408c8d7.zip
kdepimpi-15b9123c6c1f9096a4b1a7729c323433d408c8d7.tar.gz
kdepimpi-15b9123c6c1f9096a4b1a7729c323433d408c8d7.tar.bz2
fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp42
-rw-r--r--korganizer/calendarview.h5
-rw-r--r--korganizer/koagendaview.cpp8
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/kotodoview.cpp6
-rw-r--r--korganizer/kotodoview.h1
-rw-r--r--korganizer/koviewmanager.cpp16
-rw-r--r--korganizer/koviewmanager.h7
8 files changed, 52 insertions, 34 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 28b17a5..31e103d 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,5176 +1,5176 @@
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 "koagenda.h" 107#include "koagenda.h"
108#include "kodialogmanager.h" 108#include "kodialogmanager.h"
109#include "outgoingdialog.h" 109#include "outgoingdialog.h"
110#include "incomingdialog.h" 110#include "incomingdialog.h"
111#include "datenavigatorcontainer.h" 111#include "datenavigatorcontainer.h"
112#include "statusdialog.h" 112#include "statusdialog.h"
113#include "kdatenavigator.h" 113#include "kdatenavigator.h"
114#include "kotodoview.h" 114#include "kotodoview.h"
115#include "datenavigator.h" 115#include "datenavigator.h"
116#include "resourceview.h" 116#include "resourceview.h"
117#include "navigatorbar.h" 117#include "navigatorbar.h"
118#include "searchdialog.h" 118#include "searchdialog.h"
119#include "mainwindow.h" 119#include "mainwindow.h"
120#include "categoryeditdialog.h" 120#include "categoryeditdialog.h"
121 121
122#include "calendarview.h" 122#include "calendarview.h"
123#ifndef DESKTOP_VERSION 123#ifndef DESKTOP_VERSION
124#include <qtopia/alarmserver.h> 124#include <qtopia/alarmserver.h>
125#endif 125#endif
126#ifndef _WIN32_ 126#ifndef _WIN32_
127#include <stdlib.h> 127#include <stdlib.h>
128#include <stdio.h> 128#include <stdio.h>
129#include <unistd.h> 129#include <unistd.h>
130#else 130#else
131#include <qprocess.h> 131#include <qprocess.h>
132#endif 132#endif
133 133
134#ifdef DESKTOP_VERSION 134#ifdef DESKTOP_VERSION
135#include <kabc/stdaddressbook.h> 135#include <kabc/stdaddressbook.h>
136#endif 136#endif
137using namespace KOrg; 137using namespace KOrg;
138using namespace KCal; 138using namespace KCal;
139extern int globalFlagBlockAgenda; 139extern int globalFlagBlockAgenda;
140extern int globalFlagBlockStartup; 140extern int globalFlagBlockStartup;
141 141
142 142
143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
144 144
145{ 145{
146 mAlarms = alarms; 146 mAlarms = alarms;
147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
148 QString mText = "<table width=\"100%\">\n"; 148 QString mText = "<table width=\"100%\">\n";
149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
150#ifdef DESKTOP_VERSION 150#ifdef DESKTOP_VERSION
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
152#else 152#else
153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
154#endif 154#endif
155 // mText += "<img src=\""; 155 // mText += "<img src=\"";
156 // mText += ipath; 156 // mText += ipath;
157 // mText += "\">"; 157 // mText += "\">";
158 //mEventDate = QDate::currentDate(); 158 //mEventDate = QDate::currentDate();
159#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
161#else 161#else
162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
163#endif 163#endif
164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
165 165
166 Incidence * inc = getNextInc( start ); 166 Incidence * inc = getNextInc( start );
167 int time = 0; 167 int time = 0;
168 //mText += "<table>"; 168 //mText += "<table>";
169 while ( inc ) { 169 while ( inc ) {
170 QDateTime dt ; 170 QDateTime dt ;
171 QString tempText = "<a "; 171 QString tempText = "<a ";
172 bool ok; 172 bool ok;
173 dt = inc->getNextOccurence( start, &ok ); 173 dt = inc->getNextOccurence( start, &ok );
174 if ( !ok ) continue; 174 if ( !ok ) continue;
175 if ( inc->typeID() == eventID ) { 175 if ( inc->typeID() == eventID ) {
176 tempText += "href=\"event:"; 176 tempText += "href=\"event:";
177 } else if ( inc->typeID() == todoID ) { 177 } else if ( inc->typeID() == todoID ) {
178 tempText += "href=\"todo:"; 178 tempText += "href=\"todo:";
179 } 179 }
180 tempText += inc->uid() + "\">"; 180 tempText += inc->uid() + "\">";
181 if ( inc->typeID() == todoID ) 181 if ( inc->typeID() == todoID )
182 tempText += i18n("Todo: "); 182 tempText += i18n("Todo: ");
183 if ( inc->summary().length() > 0 ) 183 if ( inc->summary().length() > 0 )
184 tempText += inc->summary(); 184 tempText += inc->summary();
185 else 185 else
186 tempText += i18n("-no summary-"); 186 tempText += i18n("-no summary-");
187 QString timestr; 187 QString timestr;
188 if (!inc->doesFloat()) 188 if (!inc->doesFloat())
189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
190 else 190 else
191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
192 if ( dt.date() < QDate::currentDate() && time == 0 ) { 192 if ( dt.date() < QDate::currentDate() && time == 0 ) {
193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
194 mText += "<table>"; 194 mText += "<table>";
195 time = 1; 195 time = 1;
196 } 196 }
197 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 197 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
198 if ( time > 0 ) 198 if ( time > 0 )
199 mText +="</table>"; 199 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
201 mText += "<table>"; 201 mText += "<table>";
202 time = 2; 202 time = 2;
203 203
204 } 204 }
205 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 205 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
206 if ( time > 0 ) 206 if ( time > 0 )
207 mText +="</table>"; 207 mText +="</table>";
208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
209 mText += "<table>"; 209 mText += "<table>";
210 time = 3; 210 time = 3;
211 } 211 }
212 mText +="<tr><td><b>"; 212 mText +="<tr><td><b>";
213 mText += timestr; 213 mText += timestr;
214 mText += "</b></td><td>"; 214 mText += "</b></td><td>";
215 mText += tempText; 215 mText += tempText;
216 mText += "</td></tr>\n"; 216 mText += "</td></tr>\n";
217 inc = getNextInc( start ); 217 inc = getNextInc( start );
218 } 218 }
219 mText +="</table>"; 219 mText +="</table>";
220 setText( mText ); 220 setText( mText );
221} 221}
222 222
223MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 223MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
224{ 224{
225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
226} 226}
227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
228{ 228{
229 QDateTime dt ; 229 QDateTime dt ;
230 Incidence * retInc; 230 Incidence * retInc;
231 Incidence * inc = mAlarms.first(); 231 Incidence * inc = mAlarms.first();
232 if ( inc == 0 ) 232 if ( inc == 0 )
233 return 0; 233 return 0;
234 bool ok; 234 bool ok;
235 dt = inc->getNextOccurence( start, &ok ); 235 dt = inc->getNextOccurence( start, &ok );
236 if ( ! ok ) return 0; 236 if ( ! ok ) return 0;
237 QDateTime dtn ; 237 QDateTime dtn ;
238 retInc = inc; 238 retInc = inc;
239 inc = mAlarms.next(); 239 inc = mAlarms.next();
240 while ( inc ) { 240 while ( inc ) {
241 dtn = inc->getNextOccurence( start, &ok ); 241 dtn = inc->getNextOccurence( start, &ok );
242 if ( ! ok ) return 0; 242 if ( ! ok ) return 0;
243 if ( dtn < dt ) { 243 if ( dtn < dt ) {
244 dt = dtn; 244 dt = dtn;
245 retInc = inc; 245 retInc = inc;
246 } 246 }
247 inc = mAlarms.next(); 247 inc = mAlarms.next();
248 } 248 }
249 mAlarms.remove( retInc ); 249 mAlarms.remove( retInc );
250 return retInc; 250 return retInc;
251 251
252} 252}
253void MissedAlarmTextBrowser::setSource(const QString & n) 253void MissedAlarmTextBrowser::setSource(const QString & n)
254{ 254{
255 if (n.startsWith("event:")) { 255 if (n.startsWith("event:")) {
256#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
257 emit showIncidence(n.mid(8)); 257 emit showIncidence(n.mid(8));
258#else 258#else
259 emit showIncidence(n.mid(6)); 259 emit showIncidence(n.mid(6));
260#endif 260#endif
261 return; 261 return;
262 } else if (n.startsWith("todo:")) { 262 } else if (n.startsWith("todo:")) {
263#ifdef DESKTOP_VERSION 263#ifdef DESKTOP_VERSION
264 emit showIncidence(n.mid(7)); 264 emit showIncidence(n.mid(7));
265#else 265#else
266 emit showIncidence(n.mid(5)); 266 emit showIncidence(n.mid(5));
267#endif 267#endif
268 return; 268 return;
269 } 269 }
270} 270}
271 271
272 272
273class KOBeamPrefs : public QDialog 273class KOBeamPrefs : public QDialog
274{ 274{
275 public: 275 public:
276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
277 QDialog( parent, name, true ) 277 QDialog( parent, name, true )
278 { 278 {
279 setCaption( i18n("Beam Options") ); 279 setCaption( i18n("Beam Options") );
280 QVBoxLayout* lay = new QVBoxLayout( this ); 280 QVBoxLayout* lay = new QVBoxLayout( this );
281 lay->setSpacing( 3 ); 281 lay->setSpacing( 3 );
282 lay->setMargin( 3 ); 282 lay->setMargin( 3 );
283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
284 lay->addWidget( format ); 284 lay->addWidget( format );
285 format->setExclusive ( true ) ; 285 format->setExclusive ( true ) ;
286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
287 lay->addWidget( time ); time->setExclusive ( true ) ; 287 lay->addWidget( time ); time->setExclusive ( true ) ;
288 vcal = new QRadioButton(" vCalendar ", format ); 288 vcal = new QRadioButton(" vCalendar ", format );
289 ical = new QRadioButton(" iCalendar ", format ); 289 ical = new QRadioButton(" iCalendar ", format );
290 vcal->setChecked( true ); 290 vcal->setChecked( true );
291 tz = new QRadioButton(i18n(" With timezone "), time ); 291 tz = new QRadioButton(i18n(" With timezone "), time );
292 local = new QRadioButton(i18n(" Local time "), time ); 292 local = new QRadioButton(i18n(" Local time "), time );
293 tz->setChecked( true ); 293 tz->setChecked( true );
294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
295 lay->addWidget( ok ); 295 lay->addWidget( ok );
296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
297 lay->addWidget( cancel ); 297 lay->addWidget( cancel );
298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
300 resize( 200, 200 ); 300 resize( 200, 200 );
301 } 301 }
302 302
303 bool beamVcal() { return vcal->isChecked(); } 303 bool beamVcal() { return vcal->isChecked(); }
304 bool beamLocal() { return local->isChecked(); } 304 bool beamLocal() { return local->isChecked(); }
305private: 305private:
306 QRadioButton* vcal, *ical, *local, *tz; 306 QRadioButton* vcal, *ical, *local, *tz;
307}; 307};
308class KOCatPrefs : public QDialog 308class KOCatPrefs : public QDialog
309{ 309{
310 public: 310 public:
311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
312 QDialog( parent, name, true ) 312 QDialog( parent, name, true )
313 { 313 {
314 setCaption( i18n("Manage new Categories") ); 314 setCaption( i18n("Manage new Categories") );
315 QVBoxLayout* lay = new QVBoxLayout( this ); 315 QVBoxLayout* lay = new QVBoxLayout( this );
316 lay->setSpacing( 3 ); 316 lay->setSpacing( 3 );
317 lay->setMargin( 3 ); 317 lay->setMargin( 3 );
318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
319 lay->addWidget( lab ); 319 lay->addWidget( lab );
320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
321 lay->addWidget( format ); 321 lay->addWidget( format );
322 format->setExclusive ( true ) ; 322 format->setExclusive ( true ) ;
323 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 323 addCatBut = new QRadioButton(i18n("Add to category list"), format );
324 new QRadioButton(i18n("Remove from Events/Todos"), format ); 324 new QRadioButton(i18n("Remove from Events/Todos"), format );
325 addCatBut->setChecked( true ); 325 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 327 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 329 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 332 resize( 200, 200 );
333 } 333 }
334 334
335 bool addCat() { return addCatBut->isChecked(); } 335 bool addCat() { return addCatBut->isChecked(); }
336private: 336private:
337 QRadioButton* addCatBut; 337 QRadioButton* addCatBut;
338}; 338};
339 339
340 340
341 341
342CalendarView::CalendarView( CalendarResources *calendar, 342CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 345 mCalendar( calendar ),
346 mResourceManager( calendar->resourceManager() ) 346 mResourceManager( calendar->resourceManager() )
347{ 347{
348 348
349 mEventEditor = 0; 349 mEventEditor = 0;
350 mTodoEditor = 0; 350 mTodoEditor = 0;
351 351
352 init(); 352 init();
353} 353}
354 354
355CalendarView::CalendarView( Calendar *calendar, 355CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 357 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 358 mCalendar( calendar ),
359 mResourceManager( 0 ) 359 mResourceManager( 0 )
360{ 360{
361 361
362 mEventEditor = 0; 362 mEventEditor = 0;
363 mTodoEditor = 0; 363 mTodoEditor = 0;
364 init(); 364 init();
365} 365}
366 366
367void CalendarView::init() 367void CalendarView::init()
368{ 368{
369 flag_blockConflict = false;
370 flag_blockScrollBar = false;
371 flag_checkFileFirsttime = true;
372 flag_clearallviewsEventDisplay = false;
373 flag_clearallviewsupdateView = false;
369 mNextAlarmDateTime = QDateTime::currentDateTime(); 374 mNextAlarmDateTime = QDateTime::currentDateTime();
370 setFocusPolicy (NoFocus ); 375 setFocusPolicy (NoFocus );
371 mViewerCallerIsSearchDialog = false; 376 mViewerCallerIsSearchDialog = false;
372 mBlockShowDates = false; 377 mBlockShowDates = false;
373 mConflictingEvent = 0; 378 mConflictingEvent = 0;
374 mDatePickerMode = 0; 379 mDatePickerMode = 0;
375 mCurrentSyncDevice = ""; 380 mCurrentSyncDevice = "";
376 mViewManager = new KOViewManager( this ); 381 mViewManager = new KOViewManager( this );
377 mDialogManager = new KODialogManager( this ); 382 mDialogManager = new KODialogManager( this );
378 mEventViewerDialog = 0; 383 mEventViewerDialog = 0;
379 mModified = false; 384 mModified = false;
380 mReadOnly = false; 385 mReadOnly = false;
381 mSelectedIncidence = 0; 386 mSelectedIncidence = 0;
382 mCalPrinter = 0; 387 mCalPrinter = 0;
383 mFilters.setAutoDelete(true); 388 mFilters.setAutoDelete(true);
384 389
385 mCalendar->registerObserver( this ); 390 mCalendar->registerObserver( this );
386 // TODO: Make sure that view is updated, when calendar is changed. 391 // TODO: Make sure that view is updated, when calendar is changed.
387 392
388 mStorage = new FileStorage( mCalendar ); 393 mStorage = new FileStorage( mCalendar );
389 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 394 mNavigator = new DateNavigator( this, "datevav", mViewManager );
390 395
391 QBoxLayout *topLayout = (QBoxLayout*)layout(); 396 QBoxLayout *topLayout = (QBoxLayout*)layout();
392#ifndef KORG_NOSPLITTER 397#ifndef KORG_NOSPLITTER
393 // create the main layout frames. 398 // create the main layout frames.
394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 399 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
395 topLayout->addWidget(mPanner); 400 topLayout->addWidget(mPanner);
396 401
397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 402 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
398 "CalendarView::LeftFrame"); 403 "CalendarView::LeftFrame");
399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 404 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
400 405
401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 406 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
402 "CalendarView::DateNavigator" ); 407 "CalendarView::DateNavigator" );
403 408
404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 409 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 410 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
406 mTodoList->setNavigator( mNavigator ); 411 mTodoList->setNavigator( mNavigator );
407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 412 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
408 413
409#ifdef KORG_NORESOURCEVIEW 414#ifdef KORG_NORESOURCEVIEW
410 mResourceView = 0; 415 mResourceView = 0;
411#else 416#else
412 if ( mResourceManager ) { 417 if ( mResourceManager ) {
413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 418 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
414 mResourceView->updateView(); 419 mResourceView->updateView();
415 connect( mResourceView, SIGNAL( resourcesChanged() ), 420 connect( mResourceView, SIGNAL( resourcesChanged() ),
416 SLOT( updateView() ) ); 421 SLOT( updateView() ) );
417 } else { 422 } else {
418 mResourceView = 0; 423 mResourceView = 0;
419 } 424 }
420#endif 425#endif
421 QWidget *rightBox = new QWidget( mPanner ); 426 QWidget *rightBox = new QWidget( mPanner );
422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 427 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
423 428
424 mRightFrame = new QWidgetStack( rightBox ); 429 mRightFrame = new QWidgetStack( rightBox );
425 rightLayout->addWidget( mRightFrame, 1 ); 430 rightLayout->addWidget( mRightFrame, 1 );
426 431
427 mLeftFrame = mLeftSplitter; 432 mLeftFrame = mLeftSplitter;
428#else 433#else
429 //QWidget *mainBox = new QWidget( this ); 434 //QWidget *mainBox = new QWidget( this );
430 //QWidget *leftFrame = new QWidget( mainBox ); 435 //QWidget *leftFrame = new QWidget( mainBox );
431 //QBoxLayout * mainBoxLayout; 436 //QBoxLayout * mainBoxLayout;
432 if ( KOPrefs::instance()->mVerticalScreen ) { 437 if ( KOPrefs::instance()->mVerticalScreen ) {
433 //mainBoxLayout = new QVBoxLayout(mainBox); 438 //mainBoxLayout = new QVBoxLayout(mainBox);
434 //leftFrameLayout = new QHBoxLayout(leftFrame ); 439 //leftFrameLayout = new QHBoxLayout(leftFrame );
435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 440 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 441 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 442 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 443 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
439 } else { 444 } else {
440 //mainBoxLayout = new QHBoxLayout(mainBox); 445 //mainBoxLayout = new QHBoxLayout(mainBox);
441 //leftFrameLayout = new QVBoxLayout(leftFrame ); 446 //leftFrameLayout = new QVBoxLayout(leftFrame );
442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 447 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 448 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 449 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 450 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
446 } 451 }
447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 452 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
448 //QBoxLayout * leftFrameLayout; 453 //QBoxLayout * leftFrameLayout;
449 topLayout->addWidget( mMainFrame ); 454 topLayout->addWidget( mMainFrame );
450#ifdef DESKTOP_VERSION 455#ifdef DESKTOP_VERSION
451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 456 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this );
452 topLayout->addWidget( mDateScrollBar ); 457 topLayout->addWidget( mDateScrollBar );
453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 458 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
454 if ( QApplication::desktop()->width() < 800 ) 459 if ( QApplication::desktop()->width() < 800 )
455 mDateScrollBar->hide(); 460 mDateScrollBar->hide();
456#endif 461#endif
457 //mainBoxLayout->addWidget (mLeftFrame); 462 //mainBoxLayout->addWidget (mLeftFrame);
458 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 463 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
459 "CalendarView::DateNavigator" ); 464 "CalendarView::DateNavigator" );
460#if 0 465#if 0
461 // FIXME 466 // FIXME
462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 467 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
463 "CalendarView::DateNavigator", QDate::currentDate()); 468 "CalendarView::DateNavigator", QDate::currentDate());
464#endif 469#endif
465 // mDateNavigator->blockSignals( true ); 470 // mDateNavigator->blockSignals( true );
466 //leftFrameLayout->addWidget( mDateNavigator ); 471 //leftFrameLayout->addWidget( mDateNavigator );
467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 472 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 473 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 474 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 475 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 476 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 477 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 478 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 479 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 480 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 481 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 482 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 483 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 484 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
480 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); 485 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) );
481 486
482 487
483 mTodoList->setNavigator( mNavigator ); 488 mTodoList->setNavigator( mNavigator );
484#if 0 489#if 0
485 if ( QApplication::desktop()->width() < 480 ) { 490 if ( QApplication::desktop()->width() < 480 ) {
486 leftFrameLayout->addWidget(mFilterView); 491 leftFrameLayout->addWidget(mFilterView);
487 leftFrameLayout->addWidget(mTodoList, 2 ); 492 leftFrameLayout->addWidget(mTodoList, 2 );
488 493
489 } else { 494 } else {
490 leftFrameLayout->addWidget(mTodoList,2 ); 495 leftFrameLayout->addWidget(mTodoList,2 );
491 leftFrameLayout->addWidget(mFilterView ); 496 leftFrameLayout->addWidget(mFilterView );
492 } 497 }
493#endif 498#endif
494 mFilterView->hide(); 499 mFilterView->hide();
495 mCalEditView->hide(); 500 mCalEditView->hide();
496 QWidget *rightBox = new QWidget( mMainFrame ); 501 QWidget *rightBox = new QWidget( mMainFrame );
497 //mainBoxLayout->addWidget ( rightBox, 10 ); 502 //mainBoxLayout->addWidget ( rightBox, 10 );
498 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 503 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
499 mRightFrame = new QWidgetStack( rightBox ); 504 mRightFrame = new QWidgetStack( rightBox );
500 rightLayout->addWidget( mRightFrame, 10 ); 505 rightLayout->addWidget( mRightFrame, 10 );
501 506
502 //mLeftFrame = (QWidget *)leftFrame; 507 //mLeftFrame = (QWidget *)leftFrame;
503 if ( KOPrefs::instance()->mVerticalScreen ) { 508 if ( KOPrefs::instance()->mVerticalScreen ) {
504 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 509 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
505 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 510 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
506 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 511 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
507 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 512 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
508 } else { 513 } else {
509 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 514 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
510 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 515 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
511 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 516 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
512 } 517 }
513 if ( !KOPrefs::instance()->mShowDateNavigator) 518 if ( !KOPrefs::instance()->mShowDateNavigator)
514 mDateNavigator->hide(); 519 mDateNavigator->hide();
515 //qDebug("Calendarview Size %d %d ", width(), height()); 520 //qDebug("Calendarview Size %d %d ", width(), height());
516#endif 521#endif
517 522
518 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 523 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
519 SLOT( showDates( const KCal::DateList & ) ) ); 524 SLOT( showDates( const KCal::DateList & ) ) );
520 525
521 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 526 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
522 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 527 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
523 528
524 529
525 530
526 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 531 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
527 mViewManager, SLOT( showMonth( const QDate & ) ) ); 532 mViewManager, SLOT( showMonth( const QDate & ) ) );
528 533
529 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 534 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
530 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 535 mNavigator, SLOT( selectWeek( const QDate & ) ) );
531 536
532 connect( mDateNavigator, SIGNAL( goPrevYear() ), 537 connect( mDateNavigator, SIGNAL( goPrevYear() ),
533 mNavigator, SLOT( selectPreviousYear() ) ); 538 mNavigator, SLOT( selectPreviousYear() ) );
534 connect( mDateNavigator, SIGNAL( goNextYear() ), 539 connect( mDateNavigator, SIGNAL( goNextYear() ),
535 mNavigator, SLOT( selectNextYear() ) ); 540 mNavigator, SLOT( selectNextYear() ) );
536 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 541 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
537 mNavigator, SLOT( selectPreviousMonth() ) ); 542 mNavigator, SLOT( selectPreviousMonth() ) );
538 connect( mDateNavigator, SIGNAL( goNextMonth() ), 543 connect( mDateNavigator, SIGNAL( goNextMonth() ),
539 mNavigator, SLOT( selectNextMonth() ) ); 544 mNavigator, SLOT( selectNextMonth() ) );
540 545
541 connect( mDateNavigator, SIGNAL( goPrevious() ), 546 connect( mDateNavigator, SIGNAL( goPrevious() ),
542 mNavigator, SLOT( selectPrevious() ) ); 547 mNavigator, SLOT( selectPrevious() ) );
543 connect( mDateNavigator, SIGNAL( goNext() ), 548 connect( mDateNavigator, SIGNAL( goNext() ),
544 mNavigator, SLOT( selectNext() ) ); 549 mNavigator, SLOT( selectNext() ) );
545 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 550 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
546 mNavigator, SLOT( slotMonthSelect( int ) ) ); 551 mNavigator, SLOT( slotMonthSelect( int ) ) );
547 552
548 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 553 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
549 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 554 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
550#if 0 555#if 0
551 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 556 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
552 SLOT( incidenceAdded( Incidence *) ) ); 557 SLOT( incidenceAdded( Incidence *) ) );
553#endif 558#endif
554 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 559 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
555 560
556 connect( this, SIGNAL( configChanged() ), 561 connect( this, SIGNAL( configChanged() ),
557 mDateNavigator, SLOT( updateConfig() ) ); 562 mDateNavigator, SLOT( updateConfig() ) );
558 563
559 connect( mTodoList, SIGNAL( newTodoSignal() ), 564 connect( mTodoList, SIGNAL( newTodoSignal() ),
560 SLOT( newTodo() ) ); 565 SLOT( newTodo() ) );
561 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 566 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
562 SLOT( newSubTodo( Todo * ) ) ); 567 SLOT( newSubTodo( Todo * ) ) );
563 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 568 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
564 SLOT( editTodo( Todo * ) ) ); 569 SLOT( editTodo( Todo * ) ) );
565 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 570 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
566 SLOT( showTodo( Todo *) ) ); 571 SLOT( showTodo( Todo *) ) );
567 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 572 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
568 SLOT( deleteTodo( Todo *) ) ); 573 SLOT( deleteTodo( Todo *) ) );
569 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 574 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
570 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 575 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
571 SLOT( purgeCompleted() ) ); 576 SLOT( purgeCompleted() ) );
572 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 577 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
573 SIGNAL( todoModified( Todo *, int ) ) ); 578 SIGNAL( todoModified( Todo *, int ) ) );
574 579
575 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 580 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
576 this, SLOT ( cloneIncidence( Incidence * ) ) ); 581 this, SLOT ( cloneIncidence( Incidence * ) ) );
577 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 582 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
578 this, SLOT (cancelIncidence( Incidence * ) ) ); 583 this, SLOT (cancelIncidence( Incidence * ) ) );
579 584
580 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 585 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
581 this, SLOT ( moveIncidence( Incidence * ) ) ); 586 this, SLOT ( moveIncidence( Incidence * ) ) );
582 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 587 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
583 this, SLOT ( beamIncidence( Incidence * ) ) ); 588 this, SLOT ( beamIncidence( Incidence * ) ) );
584 589
585 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 590 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
586 this, SLOT ( todo_unsub( Todo * ) ) ); 591 this, SLOT ( todo_unsub( Todo * ) ) );
587 592
588 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 593 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
589 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 594 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
590 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 595 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
591 SLOT( updateTodo( Todo *, int ) ) ); 596 SLOT( updateTodo( Todo *, int ) ) );
592 connect( this, SIGNAL( todoModified( Todo *, int )), this, 597 connect( this, SIGNAL( todoModified( Todo *, int )), this,
593 SLOT( changeTodoDisplay( Todo *, int ) ) ); 598 SLOT( changeTodoDisplay( Todo *, int ) ) );
594 599
595 600
596 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 601 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
597 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 602 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
598 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 603 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
599 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 604 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
600 605
601 606
602 607
603 608
604 609
605 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 610 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
606 SLOT(checkClipboard())); 611 SLOT(checkClipboard()));
607 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 612 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
608 SLOT( processTodoListSelection( Incidence * ) ) ); 613 SLOT( processTodoListSelection( Incidence * ) ) );
609 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 614 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
610 615
611 // kdDebug() << "CalendarView::CalendarView() done" << endl; 616 // kdDebug() << "CalendarView::CalendarView() done" << endl;
612 617
613 mDateFrame = new QVBox(0,0,WType_Popup); 618 mDateFrame = new QVBox(0,0,WType_Popup);
614 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 619 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
615 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 620 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
616 mDateFrame->setLineWidth(3); 621 mDateFrame->setLineWidth(3);
617 mDateFrame->hide(); 622 mDateFrame->hide();
618 mDateFrame->setCaption( i18n( "Pick a date to display")); 623 mDateFrame->setCaption( i18n( "Pick a date to display"));
619 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 624 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
620 625
621 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 626 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
622 627
623 mEventEditor = mDialogManager->getEventEditor(); 628 mEventEditor = mDialogManager->getEventEditor();
624 mTodoEditor = mDialogManager->getTodoEditor(); 629 mTodoEditor = mDialogManager->getTodoEditor();
625 630
626 mFlagEditDescription = false; 631 mFlagEditDescription = false;
627 632
628 mSuspendTimer = new QTimer( this ); 633 mSuspendTimer = new QTimer( this );
629 mAlarmTimer = new QTimer( this ); 634 mAlarmTimer = new QTimer( this );
630 mRecheckAlarmTimer = new QTimer( this ); 635 mRecheckAlarmTimer = new QTimer( this );
631 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 636 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
632 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 637 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
633 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 638 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
634 mAlarmDialog = new AlarmDialog( this ); 639 mAlarmDialog = new AlarmDialog( this );
635 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 640 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
636 mAlarmDialog->setServerNotification( false ); 641 mAlarmDialog->setServerNotification( false );
637 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 642 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
638 643
639 644
640#ifndef DESKTOP_VERSION 645#ifndef DESKTOP_VERSION
641//US listen for arriving address resultsets 646//US listen for arriving address resultsets
642 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 647 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
643 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 648 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
644#endif 649#endif
645 mDateNavigator->setCalendar( mCalendar ); 650 mDateNavigator->setCalendar( mCalendar );
646} 651}
647 652
648 653
649CalendarView::~CalendarView() 654CalendarView::~CalendarView()
650{ 655{
651 // kdDebug() << "~CalendarView()" << endl; 656 // kdDebug() << "~CalendarView()" << endl;
652 //qDebug("CalendarView::~CalendarView() "); 657 //qDebug("CalendarView::~CalendarView() ");
653 delete mDialogManager; 658 delete mDialogManager;
654 delete mViewManager; 659 delete mViewManager;
655 delete mStorage; 660 delete mStorage;
656 delete mDateFrame ; 661 delete mDateFrame ;
657 delete mEventViewerDialog; 662 delete mEventViewerDialog;
658 //kdDebug() << "~CalendarView() done" << endl; 663 //kdDebug() << "~CalendarView() done" << endl;
659} 664}
660 665
661 666
662void CalendarView::nextConflict( bool all, bool allday ) 667void CalendarView::nextConflict( bool all, bool allday )
663{ 668{
664 static bool block = false; 669 if ( flag_blockConflict ) return;
665 if ( block ) return; 670 flag_blockConflict = true;
666 block = true;
667 QPtrList<Event> testlist = mCalendar->events(); 671 QPtrList<Event> testlist = mCalendar->events();
668 Event * test = testlist.first(); 672 Event * test = testlist.first();
669 while ( test ) { 673 while ( test ) {
670 test->setTagged( false ); 674 test->setTagged( false );
671 test = testlist.next(); 675 test = testlist.next();
672 } 676 }
673 QTime st ( 0,0,0); 677 QTime st ( 0,0,0);
674 if ( mViewManager->currentView() == mViewManager->agendaView() ) 678 if ( mViewManager->currentView() == mViewManager->agendaView() )
675 st = mViewManager->agendaView()->agenda()->getEndTime(); 679 st = mViewManager->agendaView()->agenda()->getEndTime();
676 //qDebug("time %s ", st.toString().latin1()); 680 //qDebug("time %s ", st.toString().latin1());
677 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 681 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
678 QDateTime conflict; 682 QDateTime conflict;
679 QDateTime retVal; 683 QDateTime retVal;
680 bool found = false; 684 bool found = false;
681 Event * cE = 0; 685 Event * cE = 0;
682 Event * cE2 = 0; 686 Event * cE2 = 0;
683 QPtrList<Event> testlist2 = testlist; 687 QPtrList<Event> testlist2 = testlist;
684 test = testlist.first(); 688 test = testlist.first();
685 bool skip = false; 689 bool skip = false;
686 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 690 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
687 //QTime tm; 691 //QTime tm;
688 //tm.start(); 692 //tm.start();
689 while ( test ) { 693 while ( test ) {
690 qApp->processEvents(); 694 qApp->processEvents();
691 skip = false; 695 skip = false;
692 if ( !all ) skip = ( allday != test->doesFloat() ); 696 if ( !all ) skip = ( allday != test->doesFloat() );
693 if ( !skip ) { 697 if ( !skip ) {
694 if ( found ) 698 if ( found )
695 skip = !test->matchTime( &startDT, &conflict ); 699 skip = !test->matchTime( &startDT, &conflict );
696 else 700 else
697 skip = !test->matchTime( &startDT, 0 ); 701 skip = !test->matchTime( &startDT, 0 );
698 } 702 }
699 if ( !skip ) { 703 if ( !skip ) {
700 Event * test2 = testlist2.first(); 704 Event * test2 = testlist2.first();
701 while ( test2 ) { 705 while ( test2 ) {
702 skip = test2->isTagged(); 706 skip = test2->isTagged();
703 if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); 707 if ( !skip && !all ) skip = ( allday != test2->doesFloat() );
704 if ( !skip ) { 708 if ( !skip ) {
705 if ( found ) 709 if ( found )
706 skip = !test2->matchTime( &startDT, &conflict ); 710 skip = !test2->matchTime( &startDT, &conflict );
707 else 711 else
708 skip = !test2->matchTime( &startDT, 0 ); 712 skip = !test2->matchTime( &startDT, 0 );
709 } 713 }
710 if ( !skip ) { 714 if ( !skip ) {
711 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 715 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
712 //qDebug("overlap "); 716 //qDebug("overlap ");
713 if ( ! found ) { 717 if ( ! found ) {
714 if ( retVal >= startDT ) { 718 if ( retVal >= startDT ) {
715 conflict = retVal; 719 conflict = retVal;
716 cE = test; 720 cE = test;
717 cE2 = test2; 721 cE2 = test2;
718 found = true; 722 found = true;
719 } 723 }
720 } else { 724 } else {
721 if ( retVal >= startDT && retVal < conflict ) { 725 if ( retVal >= startDT && retVal < conflict ) {
722 conflict = retVal; 726 conflict = retVal;
723 cE = test; 727 cE = test;
724 cE2 = test2; 728 cE2 = test2;
725 } 729 }
726 } 730 }
727 } 731 }
728 } 732 }
729 test2 = testlist2.next(); 733 test2 = testlist2.next();
730 } 734 }
731 } 735 }
732 test->setTagged( true ); 736 test->setTagged( true );
733 test = testlist.next(); 737 test = testlist.next();
734 } 738 }
735 //qDebug("Search time : %d", tm.elapsed()); 739 //qDebug("Search time : %d", tm.elapsed());
736 if ( found ) { 740 if ( found ) {
737 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 741 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
738 mViewManager->showDayView(); 742 mViewManager->showDayView();
739 mNavigator->slotDaySelect( conflict.date() ); 743 mNavigator->slotDaySelect( conflict.date() );
740 int hour = conflict.time().hour(); 744 int hour = conflict.time().hour();
741 mViewManager->agendaView()->setStartHour( hour ); 745 mViewManager->agendaView()->setStartHour( hour );
742 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); 746 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
743 block = false; 747 flag_blockConflict = false;
744 return; 748 return;
745 } 749 }
746 750
747 topLevelWidget()->setCaption( i18n("No conflict found") ); 751 topLevelWidget()->setCaption( i18n("No conflict found") );
748 //qDebug("No conflict found "); 752 //qDebug("No conflict found ");
749 block = false; 753 flag_blockConflict = false;
750 return; 754 return;
751} 755}
752 756
753void CalendarView::conflictAll() 757void CalendarView::conflictAll()
754{ 758{
755 nextConflict ( true, true ); 759 nextConflict ( true, true );
756} 760}
757void CalendarView::conflictAllday() 761void CalendarView::conflictAllday()
758{ 762{
759 nextConflict ( false, true ); 763 nextConflict ( false, true );
760} 764}
761void CalendarView::conflictNotAll() 765void CalendarView::conflictNotAll()
762{ 766{
763 nextConflict ( false, false ); 767 nextConflict ( false, false );
764} 768}
765 769
766void CalendarView::setCalReadOnly( int id, bool readO ) 770void CalendarView::setCalReadOnly( int id, bool readO )
767{ 771{
768 if ( readO ) { 772 if ( readO ) {
769 emit save(); 773 emit save();
770 } 774 }
771 mCalendar->setReadOnly( id, readO ); 775 mCalendar->setReadOnly( id, readO );
772} 776}
773void CalendarView::setScrollBarStep(int val ) 777void CalendarView::setScrollBarStep(int val )
774{ 778{
775#ifdef DESKTOP_VERSION 779#ifdef DESKTOP_VERSION
776 mDateScrollBar->setLineStep ( val ); 780 mDateScrollBar->setLineStep ( val );
777#endif 781#endif
778} 782}
779void CalendarView::scrollBarValue(int val ) 783void CalendarView::scrollBarValue(int val )
780{ 784{
781#ifdef DESKTOP_VERSION 785#ifdef DESKTOP_VERSION
782 if ( QApplication::desktop()->width() < 800 ) return; 786 if ( QApplication::desktop()->width() < 800 ) return;
783 static bool block = false; 787 if ( flag_blockScrollBar ) return;
784 if ( block ) return; 788 flag_blockScrollBar = true;
785 block = true;
786 int count = mNavigator->selectedDates().count(); 789 int count = mNavigator->selectedDates().count();
787 int day = mNavigator->selectedDates().first().dayOfYear(); 790 int day = mNavigator->selectedDates().first().dayOfYear();
788 int stepdays = val; 791 int stepdays = val;
789 if ( mDateScrollBar->lineStep () <= count ) { 792 if ( mDateScrollBar->lineStep () <= count ) {
790 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 793 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
791 //qDebug("VAL %d ",val ); 794 //qDebug("VAL %d ",val );
792 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 795 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
793 stepdays = day+stepdays; 796 stepdays = day+stepdays;
794 if ( stepdays < 0 ) stepdays = 0; 797 if ( stepdays < 0 ) stepdays = 0;
795 } 798 }
796 if ( stepdays == day ) { 799 if ( stepdays == day ) {
797 block = false; 800 flag_blockScrollBar = false;
798 return; 801 return;
799 } 802 }
800 int year = mNavigator->selectedDates().first().year(); 803 int year = mNavigator->selectedDates().first().year();
801 QDate d ( year,1,1 ); 804 QDate d ( year,1,1 );
802 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 805 mNavigator->selectDates( d.addDays( stepdays-1) , count );
803 block = false; 806 flag_blockScrollBar = false;
804#endif 807#endif
805 808
806} 809}
807void CalendarView::updateView(const QDate &start, const QDate &end) 810void CalendarView::updateView(const QDate &start, const QDate &end)
808{ 811{
809#ifdef DESKTOP_VERSION 812#ifdef DESKTOP_VERSION
810 if ( ! mDateScrollBar->draggingSlider () ) { 813 if ( ! mDateScrollBar->draggingSlider () ) {
811 int dof = start.dayOfYear(); 814 int dof = start.dayOfYear();
812 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 815 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
813 if ( dof != mDateScrollBar->value() ) { 816 if ( dof != mDateScrollBar->value() ) {
814 mDateScrollBar->blockSignals( true ); 817 mDateScrollBar->blockSignals( true );
815 mDateScrollBar->setValue( start.dayOfYear()); 818 mDateScrollBar->setValue( start.dayOfYear());
816 mDateScrollBar->blockSignals( false ); 819 mDateScrollBar->blockSignals( false );
817 } 820 }
818 } 821 }
819#endif 822#endif
820 mTodoList->updateView(); 823 mTodoList->updateView();
821 mViewManager->updateView(start, end); 824 mViewManager->updateView(start, end);
822 //mDateNavigator->updateView(); 825 //mDateNavigator->updateView();
823} 826}
824 827
825 828
826 829
827void CalendarView::checkFiles() 830void CalendarView::checkFiles()
828{ 831{
829 QString message; 832 QString message;
830 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 833 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
831 KopiCalendarFile * cal = calendars.first(); 834 KopiCalendarFile * cal = calendars.first();
832 while ( cal ) { 835 while ( cal ) {
833 if ( cal->mErrorOnLoad ) { 836 if ( cal->mErrorOnLoad ) {
834 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 837 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
835 } 838 }
836 cal = calendars.next(); 839 cal = calendars.next();
837 } 840 }
838 if ( !message.isEmpty() ) { 841 if ( !message.isEmpty() ) {
839 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); 842 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0);
840 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); 843 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed"));
841 } 844 }
842 static bool firstTime = true; 845 if ( flag_checkFileFirsttime ) {
843 if ( firstTime ) { 846 flag_checkFileFirsttime = false;
844 firstTime = false;
845 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 847 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
846 } 848 }
847} 849}
848void CalendarView::checkAlarms() 850void CalendarView::checkAlarms()
849{ 851{
850 KConfig *config = KOGlobals::config(); 852 KConfig *config = KOGlobals::config();
851 config->setGroup( "AppRun" ); 853 config->setGroup( "AppRun" );
852 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 854 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
853 int daysto = dt.daysTo( QDate::currentDate() ); 855 int daysto = dt.daysTo( QDate::currentDate() );
854 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 856 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
855 dt = dt.addDays( days ); 857 dt = dt.addDays( days );
856 int secto = dt.secsTo( QDateTime::currentDateTime() ); 858 int secto = dt.secsTo( QDateTime::currentDateTime() );
857 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 859 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
858 //qDebug("KO: Reading program stop %d ", secs); 860 //qDebug("KO: Reading program stop %d ", secs);
859 //secs -= ( 3600 * 24*3 ); // debug only 861 //secs -= ( 3600 * 24*3 ); // debug only
860 QDateTime latest = dt.addSecs ( secs ); 862 QDateTime latest = dt.addSecs ( secs );
861 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 863 qDebug("KO: Last termination on %s ", latest.toString().latin1());
862 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 864 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
863 QPtrList<Incidence> el = mCalendar->rawIncidences(); 865 QPtrList<Incidence> el = mCalendar->rawIncidences();
864 QPtrList<Incidence> al; 866 QPtrList<Incidence> al;
865 Incidence* inL = el.first(); 867 Incidence* inL = el.first();
866 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 868 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
867 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 869 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
868 while ( inL ) { 870 while ( inL ) {
869 bool ok = false; 871 bool ok = false;
870 int offset = 0; 872 int offset = 0;
871 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 873 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
872 if ( ok ) { 874 if ( ok ) {
873 //qDebug("OK %s",next.toString().latin1()); 875 //qDebug("OK %s",next.toString().latin1());
874 if ( next < cur ) { 876 if ( next < cur ) {
875 al.append( inL ); 877 al.append( inL );
876 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 878 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
877 } 879 }
878 } 880 }
879 inL = el.next(); 881 inL = el.next();
880 } 882 }
881 if ( al.count() ) { 883 if ( al.count() ) {
882 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 884 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
883 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 885 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
884 QVBoxLayout* lay = new QVBoxLayout( dia ); 886 QVBoxLayout* lay = new QVBoxLayout( dia );
885 lay->setSpacing( 0 ); 887 lay->setSpacing( 0 );
886 lay->setMargin( 0 ); 888 lay->setMargin( 0 );
887 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 889 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
888 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 890 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
889 lay->addWidget( matb ); 891 lay->addWidget( matb );
890 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 892 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
891 int wid = 210; 893 int wid = 210;
892 int x = QApplication::desktop()->width() - wid - 7; 894 int x = QApplication::desktop()->width() - wid - 7;
893 int y = QApplication::desktop()->height() - wid - 70; 895 int y = QApplication::desktop()->height() - wid - 70;
894 dia->setGeometry ( x,y,wid,wid); 896 dia->setGeometry ( x,y,wid,wid);
895 } else { 897 } else {
896 int si = 220; 898 int si = 220;
897 if ( QApplication::desktop()->width() > 470 ) 899 if ( QApplication::desktop()->width() > 470 )
898 si = 400; 900 si = 400;
899 dia->resize(si,si/2); 901 dia->resize(si,si/2);
900 } 902 }
901 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 903 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
902 dia->show(); 904 dia->show();
903 905
904 } 906 }
905#if 0 907#if 0
906 // for creating timetracker test data 908 // for creating timetracker test data
907 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); 909 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc ");
908 Todo * nt; 910 Todo * nt;
909 mCalendar->close(); 911 mCalendar->close();
910 { 912 {
911 Todo * root1 = new Todo; 913 Todo * root1 = new Todo;
912 mCalendar->addTodo( root1 ); 914 mCalendar->addTodo( root1 );
913 root1->setSummary( "Project1"); 915 root1->setSummary( "Project1");
914 root1->setPriority( 1 ); 916 root1->setPriority( 1 );
915 root1->setCategories( QString( "Cat_Pro1") ); 917 root1->setCategories( QString( "Cat_Pro1") );
916 root1->setDescription( "This is a test description of a root Project" ); 918 root1->setDescription( "This is a test description of a root Project" );
917 root1->setPercentComplete( 20 ); 919 root1->setPercentComplete( 20 );
918 updateView(); 920 updateView();
919 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 921 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
920 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 922 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
921 923
922 nt = new Todo; 924 nt = new Todo;
923 mCalendar->addTodo( nt ); 925 mCalendar->addTodo( nt );
924 nt->setSummary( "Planning Project1"); 926 nt->setSummary( "Planning Project1");
925 nt->setPriority( 1 ); 927 nt->setPriority( 1 );
926 nt->setDescription( "This is a test description of Planning Project1" ); 928 nt->setDescription( "This is a test description of Planning Project1" );
927 nt->setPercentComplete( 20 ); 929 nt->setPercentComplete( 20 );
928 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") ); 930 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1") );
929 931
930 932
931 Todo * sub1 = nt; 933 Todo * sub1 = nt;
932 sub1->setRelatedTo( root1 ); 934 sub1->setRelatedTo( root1 );
933 935
934 nt = new Todo; 936 nt = new Todo;
935 mCalendar->addTodo( nt ); 937 mCalendar->addTodo( nt );
936 nt->setSummary( "Planning Project1: Lutz"); 938 nt->setSummary( "Planning Project1: Lutz");
937 nt->setPriority( 1 ); 939 nt->setPriority( 1 );
938 nt->setDescription( "This todo counts the actual work of a person on a project" ); 940 nt->setDescription( "This todo counts the actual work of a person on a project" );
939 nt->setPercentComplete( 20 ); 941 nt->setPercentComplete( 20 );
940 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") ); 942 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Lutz") );
941 Todo * workLutz11 = nt; 943 Todo * workLutz11 = nt;
942 workLutz11->setRelatedTo( sub1 ); 944 workLutz11->setRelatedTo( sub1 );
943 945
944 nt = new Todo; 946 nt = new Todo;
945 mCalendar->addTodo( nt ); 947 mCalendar->addTodo( nt );
946 nt->setSummary( "Planning Project1: Norbert"); 948 nt->setSummary( "Planning Project1: Norbert");
947 nt->setPriority( 1 ); 949 nt->setPriority( 1 );
948 nt->setDescription( "This todo counts the actual work of a person on a project" ); 950 nt->setDescription( "This todo counts the actual work of a person on a project" );
949 nt->setPercentComplete( 20 ); 951 nt->setPercentComplete( 20 );
950 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") ); 952 nt->setCategories( QString( "Cat_Pro1,Cat_Plan_Pro1,Cat_Work_Norbert") );
951 Todo * workNorbert11 = nt; 953 Todo * workNorbert11 = nt;
952 workNorbert11->setRelatedTo( sub1 ); 954 workNorbert11->setRelatedTo( sub1 );
953 955
954 nt = new Todo; 956 nt = new Todo;
955 mCalendar->addTodo( nt ); 957 mCalendar->addTodo( nt );
956 nt->setSummary( "Work on 1"); 958 nt->setSummary( "Work on 1");
957 nt->setPriority( 1 ); 959 nt->setPriority( 1 );
958 nt->setDescription( "This is a test description of Work Project_1" ); 960 nt->setDescription( "This is a test description of Work Project_1" );
959 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") ); 961 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1") );
960 nt->setPercentComplete( 20 ); 962 nt->setPercentComplete( 20 );
961 963
962 Todo * sub2 = nt; 964 Todo * sub2 = nt;
963 sub2->setRelatedTo( root1 ); 965 sub2->setRelatedTo( root1 );
964 966
965 967
966 nt = new Todo; 968 nt = new Todo;
967 mCalendar->addTodo( nt ); 969 mCalendar->addTodo( nt );
968 nt->setSummary( "Work on 1: Lutz"); 970 nt->setSummary( "Work on 1: Lutz");
969 nt->setPriority( 1 ); 971 nt->setPriority( 1 );
970 nt->setDescription( "This todo counts the actual work of a person on a project" ); 972 nt->setDescription( "This todo counts the actual work of a person on a project" );
971 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") ); 973 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Lutz") );
972 nt->setPercentComplete( 20 ); 974 nt->setPercentComplete( 20 );
973 Todo * workLutz12 = nt; 975 Todo * workLutz12 = nt;
974 workLutz12->setRelatedTo( sub2 ); 976 workLutz12->setRelatedTo( sub2 );
975 977
976 nt = new Todo; 978 nt = new Todo;
977 mCalendar->addTodo( nt ); 979 mCalendar->addTodo( nt );
978 nt->setSummary( "Work on 1: Norbert"); 980 nt->setSummary( "Work on 1: Norbert");
979 nt->setPriority( 1 ); 981 nt->setPriority( 1 );
980 nt->setDescription( "This todo counts the actual work of a person on a project" ); 982 nt->setDescription( "This todo counts the actual work of a person on a project" );
981 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") ); 983 nt->setCategories( QString( "Cat_Pro1,Cat_Work_Pro1,Cat_Work_Norbert") );
982 nt->setPercentComplete( 20 ); 984 nt->setPercentComplete( 20 );
983 Todo * workNorbert12 = nt; 985 Todo * workNorbert12 = nt;
984 workNorbert12->setRelatedTo( sub2 ); 986 workNorbert12->setRelatedTo( sub2 );
985 987
986 int secLenRunning = 7200; 988 int secLenRunning = 7200;
987 int secLenPausing = 3600 * 3; 989 int secLenPausing = 3600 * 3;
988 int dayInterval = 1; 990 int dayInterval = 1;
989 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval ); 991 //createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, dayInterval );
990 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 ); 992 createRunningDate4Todo( root1, start, end, secLenRunning*24, secLenPausing, 14 );
991 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1); 993 createRunningDate4Todo( sub1, start.addSecs( secLenRunning ), start.addDays( 10 ), secLenRunning*4, secLenPausing, 1);
992 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3); 994 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*4, secLenPausing, 3);
993 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0); 995 createRunningDate4Todo( workLutz11, start, start.addDays( 8 ), secLenRunning, secLenPausing, 0);
994 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1); 996 createRunningDate4Todo( workNorbert11, start, start.addDays( 8 ), secLenRunning*2, secLenPausing, 1);
995 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3); 997 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning*5, secLenPausing, 3);
996 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0); 998 createRunningDate4Todo( workNorbert12, start.addDays( 8 ), end, secLenRunning, secLenPausing*3, 0);
997 999
998 } 1000 }
999 1001
1000 { 1002 {
1001 Todo * root1 = new Todo; 1003 Todo * root1 = new Todo;
1002 mCalendar->addTodo( root1 ); 1004 mCalendar->addTodo( root1 );
1003 root1->setSummary( "Project2"); 1005 root1->setSummary( "Project2");
1004 root1->setPriority( 1 ); 1006 root1->setPriority( 1 );
1005 root1->setDescription( "This is a test description of a root Project 2" ); 1007 root1->setDescription( "This is a test description of a root Project 2" );
1006 root1->setPercentComplete( 20 ); 1008 root1->setPercentComplete( 20 );
1007 root1->setCategories( QString( "Cat_Pro2") ); 1009 root1->setCategories( QString( "Cat_Pro2") );
1008 updateView(); 1010 updateView();
1009 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) ); 1011 QDateTime start = QDateTime ( QDate( 2004,11,1), QTime ( 7,30,0) );
1010 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) ); 1012 QDateTime end = QDateTime ( QDate( 2005,8,5), QTime ( 0,0,0) );
1011 int secLenRunning = 7200; 1013 int secLenRunning = 7200;
1012 int secLenPausing = 3600 * 3; 1014 int secLenPausing = 3600 * 3;
1013 int dayInterval = 1; 1015 int dayInterval = 1;
1014 1016
1015 nt = new Todo; 1017 nt = new Todo;
1016 mCalendar->addTodo( nt ); 1018 mCalendar->addTodo( nt );
1017 nt->setSummary( "Planning Project2"); 1019 nt->setSummary( "Planning Project2");
1018 nt->setPriority( 1 ); 1020 nt->setPriority( 1 );
1019 nt->setDescription( "This is a test description of Planning_Project_2" ); 1021 nt->setDescription( "This is a test description of Planning_Project_2" );
1020 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") ); 1022 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2") );
1021 nt->setPercentComplete( 20 ); 1023 nt->setPercentComplete( 20 );
1022 1024
1023 1025
1024 Todo * sub1 = nt; 1026 Todo * sub1 = nt;
1025 sub1->setRelatedTo( root1 ); 1027 sub1->setRelatedTo( root1 );
1026 1028
1027 nt = new Todo; 1029 nt = new Todo;
1028 mCalendar->addTodo( nt ); 1030 mCalendar->addTodo( nt );
1029 nt->setSummary( "Planning Project2: Lutz"); 1031 nt->setSummary( "Planning Project2: Lutz");
1030 nt->setPriority( 1 ); 1032 nt->setPriority( 1 );
1031 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1033 nt->setDescription( "This todo counts the actual work of a person on a project" );
1032 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") ); 1034 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Lutz") );
1033 nt->setPercentComplete( 20 ); 1035 nt->setPercentComplete( 20 );
1034 Todo * workLutz11 = nt; 1036 Todo * workLutz11 = nt;
1035 workLutz11->setRelatedTo( sub1 ); 1037 workLutz11->setRelatedTo( sub1 );
1036 1038
1037 nt = new Todo; 1039 nt = new Todo;
1038 mCalendar->addTodo( nt ); 1040 mCalendar->addTodo( nt );
1039 nt->setSummary( "Planning Project2: Norbert"); 1041 nt->setSummary( "Planning Project2: Norbert");
1040 nt->setPriority( 1 ); 1042 nt->setPriority( 1 );
1041 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1043 nt->setDescription( "This todo counts the actual work of a person on a project" );
1042 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") ); 1044 nt->setCategories( QString( "Cat_Pro2,Cat_Plan_Pro2,Cat_Work_Norbert") );
1043 nt->setPercentComplete( 20 ); 1045 nt->setPercentComplete( 20 );
1044 Todo * workNorbert11 = nt; 1046 Todo * workNorbert11 = nt;
1045 workNorbert11->setRelatedTo( sub1 ); 1047 workNorbert11->setRelatedTo( sub1 );
1046 1048
1047 nt = new Todo; 1049 nt = new Todo;
1048 mCalendar->addTodo( nt ); 1050 mCalendar->addTodo( nt );
1049 nt->setSummary( "Work on 2"); 1051 nt->setSummary( "Work on 2");
1050 nt->setPriority( 1 ); 1052 nt->setPriority( 1 );
1051 nt->setDescription( "This is a test description of Work Project_2" ); 1053 nt->setDescription( "This is a test description of Work Project_2" );
1052 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") ); 1054 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2") );
1053 nt->setPercentComplete( 20 ); 1055 nt->setPercentComplete( 20 );
1054 1056
1055 Todo * sub2 = nt; 1057 Todo * sub2 = nt;
1056 sub2->setRelatedTo( root1 ); 1058 sub2->setRelatedTo( root1 );
1057 1059
1058 1060
1059 nt = new Todo; 1061 nt = new Todo;
1060 mCalendar->addTodo( nt ); 1062 mCalendar->addTodo( nt );
1061 nt->setSummary( "Work on 2: Lutz"); 1063 nt->setSummary( "Work on 2: Lutz");
1062 nt->setPriority( 1 ); 1064 nt->setPriority( 1 );
1063 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1065 nt->setDescription( "This todo counts the actual work of a person on a project" );
1064 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") ); 1066 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Lutz") );
1065 nt->setPercentComplete( 20 ); 1067 nt->setPercentComplete( 20 );
1066 Todo * workLutz12 = nt; 1068 Todo * workLutz12 = nt;
1067 workLutz12->setRelatedTo( sub2 ); 1069 workLutz12->setRelatedTo( sub2 );
1068 1070
1069 nt = new Todo; 1071 nt = new Todo;
1070 mCalendar->addTodo( nt ); 1072 mCalendar->addTodo( nt );
1071 nt->setSummary( "Work on 2: Norbert"); 1073 nt->setSummary( "Work on 2: Norbert");
1072 nt->setPriority( 1 ); 1074 nt->setPriority( 1 );
1073 nt->setDescription( "This todo counts the actual work of a person on a project" ); 1075 nt->setDescription( "This todo counts the actual work of a person on a project" );
1074 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") ); 1076 nt->setCategories( QString( "Cat_Pro2,Cat_Work_Pro2,Cat_Work_Norbert") );
1075 nt->setPercentComplete( 20 ); 1077 nt->setPercentComplete( 20 );
1076 Todo * workNorbert12 = nt; 1078 Todo * workNorbert12 = nt;
1077 workNorbert12->setRelatedTo( sub2 ); 1079 workNorbert12->setRelatedTo( sub2 );
1078 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 ); 1080 createRunningDate4Todo( root1, start, end, secLenRunning, secLenPausing, 10 );
1079 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2); 1081 createRunningDate4Todo( sub1, start.addSecs( secLenRunning*3 ), start.addDays( 20 ), secLenRunning*2, secLenPausing, 2);
1080 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7); 1082 createRunningDate4Todo( sub2, start.addDays( 8 ), end, secLenRunning*3, secLenPausing, 7);
1081 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0); 1083 createRunningDate4Todo( workLutz11, start, start.addDays( 18 ), secLenRunning/2, secLenPausing*5, 0);
1082 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1); 1084 createRunningDate4Todo( workNorbert11, start.addDays( 8 ), start.addDays( 18 ), secLenRunning*5, secLenPausing*5, 1);
1083 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0); 1085 createRunningDate4Todo( workLutz12, start.addDays( 8 ),end, secLenRunning, secLenPausing*8, 0);
1084 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0); 1086 createRunningDate4Todo( workNorbert12, start.addDays( 28 ), end, secLenRunning/8, secLenPausing*6, 0);
1085 } 1087 }
1086 updateView(); 1088 updateView();
1087#endif 1089#endif
1088 1090
1089} 1091}
1090void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ) 1092void CalendarView::createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval )
1091{ 1093{
1092 static int ccc = 0; 1094 static int ccc = 0;
1093 ++ccc; 1095 ++ccc;
1094 QDateTime t_start = start; 1096 QDateTime t_start = start;
1095 runT->setPriority( 5 ); 1097 runT->setPriority( 5 );
1096 runT->setPercentComplete( 0 ); 1098 runT->setPercentComplete( 0 );
1097 int count = 0; 1099 int count = 0;
1098 int prio = 5; 1100 int prio = 5;
1099 int complete = 0; 1101 int complete = 0;
1100 while ( t_start < end ) { 1102 while ( t_start < end ) {
1101 ++count; 1103 ++count;
1102 if ( count > ccc ) { 1104 if ( count > ccc ) {
1103 count = 0; 1105 count = 0;
1104 --prio; 1106 --prio;
1105 if ( prio == 0 ) prio = 5; 1107 if ( prio == 0 ) prio = 5;
1106 complete += 20; 1108 complete += 20;
1107 if ( complete > 100 ) complete = 0; 1109 if ( complete > 100 ) complete = 0;
1108 runT->setPriority( prio ); 1110 runT->setPriority( prio );
1109 runT->setPercentComplete( complete ); 1111 runT->setPercentComplete( complete );
1110 } 1112 }
1111 runT->setRunning( true ); 1113 runT->setRunning( true );
1112 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) ); 1114 runT->saveRunningInfo( "Additional tt comment: running on "+ t_start.toString(), t_start, t_start.addSecs( secLenRunning ) );
1113 if ( dayInterval ) 1115 if ( dayInterval )
1114 t_start = t_start.addDays( dayInterval ); 1116 t_start = t_start.addDays( dayInterval );
1115 else { 1117 else {
1116 t_start = t_start.addSecs( secLenRunning + secLenPausing ); 1118 t_start = t_start.addSecs( secLenRunning + secLenPausing );
1117 } 1119 }
1118 } 1120 }
1119} 1121}
1120 1122
1121void CalendarView::showDay( QDate d ) 1123void CalendarView::showDay( QDate d )
1122{ 1124{
1123 dateNavigator()->blockSignals( true ); 1125 dateNavigator()->blockSignals( true );
1124 dateNavigator()->selectDate( d ); 1126 dateNavigator()->selectDate( d );
1125 dateNavigator()->blockSignals( false ); 1127 dateNavigator()->blockSignals( false );
1126 mViewManager->showDayView(); 1128 mViewManager->showDayView();
1127 //dateNavigator()->selectDate( d ); 1129 //dateNavigator()->selectDate( d );
1128} 1130}
1129void CalendarView::timerAlarm() 1131void CalendarView::timerAlarm()
1130{ 1132{
1131 //qDebug("CalendarView::timerAlarm() "); 1133 //qDebug("CalendarView::timerAlarm() ");
1132 computeAlarm(mAlarmNotification ); 1134 computeAlarm(mAlarmNotification );
1133} 1135}
1134 1136
1135void CalendarView::suspendAlarm() 1137void CalendarView::suspendAlarm()
1136{ 1138{
1137 //qDebug(" CalendarView::suspendAlarm() "); 1139 //qDebug(" CalendarView::suspendAlarm() ");
1138 computeAlarm(mSuspendAlarmNotification ); 1140 computeAlarm(mSuspendAlarmNotification );
1139 1141
1140} 1142}
1141 1143
1142void CalendarView::startAlarm( QString mess , QString filename) 1144void CalendarView::startAlarm( QString mess , QString filename)
1143{ 1145{
1144 1146
1145 topLevelWidget()->showNormal(); 1147 topLevelWidget()->showNormal();
1146 topLevelWidget()->setActiveWindow(); 1148 topLevelWidget()->setActiveWindow();
1147 topLevelWidget()->raise(); 1149 topLevelWidget()->raise();
1148 1150
1149 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 1151 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
1150 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 1152 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
1151 1153
1152} 1154}
1153 1155
1154void CalendarView::checkNextTimerAlarm() 1156void CalendarView::checkNextTimerAlarm()
1155{ 1157{
1156 mCalendar->checkAlarmForIncidence( 0, true ); 1158 mCalendar->checkAlarmForIncidence( 0, true );
1157} 1159}
1158 1160
1159void CalendarView::computeAlarm( QString msg ) 1161void CalendarView::computeAlarm( QString msg )
1160{ 1162{
1161 1163
1162 QString mess = msg; 1164 QString mess = msg;
1163 QString mAlarmMessage = mess.mid( 9 ); 1165 QString mAlarmMessage = mess.mid( 9 );
1164 QString filename = MainWindow::resourcePath(); 1166 QString filename = MainWindow::resourcePath();
1165 filename += "koalarm.wav"; 1167 filename += "koalarm.wav";
1166 QString tempfilename; 1168 QString tempfilename;
1167 if ( mess.left( 13 ) == "suspend_alarm") { 1169 if ( mess.left( 13 ) == "suspend_alarm") {
1168 bool error = false; 1170 bool error = false;
1169 int len = mess.mid( 13 ).find("+++"); 1171 int len = mess.mid( 13 ).find("+++");
1170 if ( len < 2 ) 1172 if ( len < 2 )
1171 error = true; 1173 error = true;
1172 else { 1174 else {
1173 tempfilename = mess.mid( 13, len ); 1175 tempfilename = mess.mid( 13, len );
1174 if ( !QFile::exists( tempfilename ) ) 1176 if ( !QFile::exists( tempfilename ) )
1175 error = true; 1177 error = true;
1176 } 1178 }
1177 if ( ! error ) { 1179 if ( ! error ) {
1178 filename = tempfilename; 1180 filename = tempfilename;
1179 } 1181 }
1180 mAlarmMessage = mess.mid( 13+len+3 ); 1182 mAlarmMessage = mess.mid( 13+len+3 );
1181 //qDebug("suspend file %s ",tempfilename.latin1() ); 1183 //qDebug("suspend file %s ",tempfilename.latin1() );
1182 startAlarm( mAlarmMessage, filename); 1184 startAlarm( mAlarmMessage, filename);
1183 return; 1185 return;
1184 } 1186 }
1185 if ( mess.left( 11 ) == "timer_alarm") { 1187 if ( mess.left( 11 ) == "timer_alarm") {
1186 //mTimerTime = 0; 1188 //mTimerTime = 0;
1187 startAlarm( mess.mid( 11 ), filename ); 1189 startAlarm( mess.mid( 11 ), filename );
1188 return; 1190 return;
1189 } 1191 }
1190 if ( mess.left( 10 ) == "proc_alarm") { 1192 if ( mess.left( 10 ) == "proc_alarm") {
1191 bool error = false; 1193 bool error = false;
1192 int len = mess.mid( 10 ).find("+++"); 1194 int len = mess.mid( 10 ).find("+++");
1193 if ( len < 2 ) 1195 if ( len < 2 )
1194 error = true; 1196 error = true;
1195 else { 1197 else {
1196 tempfilename = mess.mid( 10, len ); 1198 tempfilename = mess.mid( 10, len );
1197 if ( !QFile::exists( tempfilename ) ) 1199 if ( !QFile::exists( tempfilename ) )
1198 error = true; 1200 error = true;
1199 } 1201 }
1200 if ( error ) { 1202 if ( error ) {
1201 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 1203 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
1202 mAlarmMessage += mess.mid( 10+len+3+9 ); 1204 mAlarmMessage += mess.mid( 10+len+3+9 );
1203 } else { 1205 } else {
1204 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 1206 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
1205 //qDebug("-----system command %s ",tempfilename.latin1() ); 1207 //qDebug("-----system command %s ",tempfilename.latin1() );
1206#ifndef _WIN32_ 1208#ifndef _WIN32_
1207 if ( vfork () == 0 ) { 1209 if ( vfork () == 0 ) {
1208 execl ( tempfilename.latin1(), 0 ); 1210 execl ( tempfilename.latin1(), 0 );
1209 return; 1211 return;
1210 } 1212 }
1211#else 1213#else
1212 QProcess* p = new QProcess(); 1214 QProcess* p = new QProcess();
1213 p->addArgument( tempfilename.latin1() ); 1215 p->addArgument( tempfilename.latin1() );
1214 p->start(); 1216 p->start();
1215 return; 1217 return;
1216#endif 1218#endif
1217 1219
1218 return; 1220 return;
1219 } 1221 }
1220 1222
1221 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 1223 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1222 } 1224 }
1223 if ( mess.left( 11 ) == "audio_alarm") { 1225 if ( mess.left( 11 ) == "audio_alarm") {
1224 bool error = false; 1226 bool error = false;
1225 int len = mess.mid( 11 ).find("+++"); 1227 int len = mess.mid( 11 ).find("+++");
1226 if ( len < 2 ) 1228 if ( len < 2 )
1227 error = true; 1229 error = true;
1228 else { 1230 else {
1229 tempfilename = mess.mid( 11, len ); 1231 tempfilename = mess.mid( 11, len );
1230 if ( !QFile::exists( tempfilename ) ) 1232 if ( !QFile::exists( tempfilename ) )
1231 error = true; 1233 error = true;
1232 } 1234 }
1233 if ( ! error ) { 1235 if ( ! error ) {
1234 filename = tempfilename; 1236 filename = tempfilename;
1235 } 1237 }
1236 mAlarmMessage = mess.mid( 11+len+3+9 ); 1238 mAlarmMessage = mess.mid( 11+len+3+9 );
1237 //qDebug("audio file command %s ",tempfilename.latin1() ); 1239 //qDebug("audio file command %s ",tempfilename.latin1() );
1238 } 1240 }
1239 if ( mess.left( 9 ) == "cal_alarm") { 1241 if ( mess.left( 9 ) == "cal_alarm") {
1240 mAlarmMessage = mess.mid( 9 ) ; 1242 mAlarmMessage = mess.mid( 9 ) ;
1241 } 1243 }
1242 1244
1243 startAlarm( mAlarmMessage, filename ); 1245 startAlarm( mAlarmMessage, filename );
1244 1246
1245 1247
1246} 1248}
1247 1249
1248void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1250void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1249{ 1251{
1250 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1252 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1251 1253
1252 mSuspendAlarmNotification = noti; 1254 mSuspendAlarmNotification = noti;
1253 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1255 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1254 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1256 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1255 mSuspendTimer->start( ms , true ); 1257 mSuspendTimer->start( ms , true );
1256#ifdef DESKTOP_VERSION 1258#ifdef DESKTOP_VERSION
1257 if ( QApplication::desktop()->width() < 1024 ) { 1259 if ( QApplication::desktop()->width() < 1024 ) {
1258 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1260 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1259 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); 1261 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() );
1260 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; 1262 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm";
1261 QFile file( fn ); 1263 QFile file( fn );
1262 if (!file.open( IO_WriteOnly ) ) { 1264 if (!file.open( IO_WriteOnly ) ) {
1263 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1265 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1264 } else { 1266 } else {
1265 QTextStream ts( &file ); 1267 QTextStream ts( &file );
1266 ts << mess; 1268 ts << mess;
1267 file.close(); 1269 file.close();
1268 } 1270 }
1269 } 1271 }
1270#endif 1272#endif
1271 1273
1272} 1274}
1273 1275
1274void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1276void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1275{ 1277{
1276 mNextAlarmDateTime = qdt; 1278 mNextAlarmDateTime = qdt;
1277 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1279 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1278 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1280 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1279#ifndef DESKTOP_VERSION 1281#ifndef DESKTOP_VERSION
1280 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1282 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1281#endif 1283#endif
1282 return; 1284 return;
1283 } 1285 }
1284#ifdef DESKTOP_VERSION 1286#ifdef DESKTOP_VERSION
1285 if ( QApplication::desktop()->width() < 1024 ) { 1287 if ( QApplication::desktop()->width() < 1024 ) {
1286 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1288 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1287 //qDebug("nextalarm = \n%s ",mess.latin1() ); 1289 //qDebug("nextalarm = \n%s ",mess.latin1() );
1288 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; 1290 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm";
1289 QFile file( fn ); 1291 QFile file( fn );
1290 if (!file.open( IO_WriteOnly ) ) { 1292 if (!file.open( IO_WriteOnly ) ) {
1291 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1293 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1292 } else { 1294 } else {
1293 QTextStream ts( &file ); 1295 QTextStream ts( &file );
1294 ts << mess; 1296 ts << mess;
1295 file.close(); 1297 file.close();
1296 } 1298 }
1297 } 1299 }
1298#endif 1300#endif
1299 int maxSec; 1301 int maxSec;
1300 //maxSec = 5; //testing only 1302 //maxSec = 5; //testing only
1301 maxSec = 86400+3600; // one day+1hour 1303 maxSec = 86400+3600; // one day+1hour
1302 mAlarmNotification = noti; 1304 mAlarmNotification = noti;
1303 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1305 int sec = QDateTime::currentDateTime().secsTo( qdt );
1304 if ( sec > maxSec ) { 1306 if ( sec > maxSec ) {
1305 mRecheckAlarmTimer->start( maxSec * 1000 ); 1307 mRecheckAlarmTimer->start( maxSec * 1000 );
1306 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1308 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1307 return; 1309 return;
1308 } else { 1310 } else {
1309 mRecheckAlarmTimer->stop(); 1311 mRecheckAlarmTimer->stop();
1310 } 1312 }
1311 //qDebug("Alarm timer started with secs: %d ", sec); 1313 //qDebug("Alarm timer started with secs: %d ", sec);
1312 mAlarmTimer->start( sec * 1000 , true ); 1314 mAlarmTimer->start( sec * 1000 , true );
1313 1315
1314} 1316}
1315// called by mRecheckAlarmTimer to get next alarm 1317// called by mRecheckAlarmTimer to get next alarm
1316// we need this, because a QTimer has only a max range of 25 days 1318// we need this, because a QTimer has only a max range of 25 days
1317void CalendarView::recheckTimerAlarm() 1319void CalendarView::recheckTimerAlarm()
1318{ 1320{
1319 mAlarmTimer->stop(); 1321 mAlarmTimer->stop();
1320 mRecheckAlarmTimer->stop(); 1322 mRecheckAlarmTimer->stop();
1321 mCalendar->checkAlarmForIncidence( 0, true ); 1323 mCalendar->checkAlarmForIncidence( 0, true );
1322} 1324}
1323#ifndef DESKTOP_VERSION 1325#ifndef DESKTOP_VERSION
1324void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1326void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1325#else 1327#else
1326void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1328void CalendarView::removeAlarm(const QDateTime &, const QString & )
1327#endif 1329#endif
1328{ 1330{
1329 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1331 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1330 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1332 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1331#ifndef DESKTOP_VERSION 1333#ifndef DESKTOP_VERSION
1332 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1334 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1333#endif 1335#endif
1334 return; 1336 return;
1335 } 1337 }
1336 mAlarmTimer->stop(); 1338 mAlarmTimer->stop();
1337} 1339}
1338void CalendarView::selectWeekNum ( int num ) 1340void CalendarView::selectWeekNum ( int num )
1339{ 1341{
1340 dateNavigator()->blockSignals( true ); 1342 dateNavigator()->blockSignals( true );
1341 dateNavigator()->selectWeek( num ); 1343 dateNavigator()->selectWeek( num );
1342 dateNavigator()->blockSignals( false ); 1344 dateNavigator()->blockSignals( false );
1343 mViewManager->showWeekView(); 1345 mViewManager->showWeekView();
1344} 1346}
1345KOViewManager *CalendarView::viewManager() 1347KOViewManager *CalendarView::viewManager()
1346{ 1348{
1347 return mViewManager; 1349 return mViewManager;
1348} 1350}
1349 1351
1350KODialogManager *CalendarView::dialogManager() 1352KODialogManager *CalendarView::dialogManager()
1351{ 1353{
1352 return mDialogManager; 1354 return mDialogManager;
1353} 1355}
1354 1356
1355QDate CalendarView::startDate() 1357QDate CalendarView::startDate()
1356{ 1358{
1357 DateList dates = mNavigator->selectedDates(); 1359 DateList dates = mNavigator->selectedDates();
1358 1360
1359 return dates.first(); 1361 return dates.first();
1360} 1362}
1361 1363
1362QDate CalendarView::endDate() 1364QDate CalendarView::endDate()
1363{ 1365{
1364 DateList dates = mNavigator->selectedDates(); 1366 DateList dates = mNavigator->selectedDates();
1365 1367
1366 return dates.last(); 1368 return dates.last();
1367} 1369}
1368 1370
1369 1371
1370void CalendarView::createPrinter() 1372void CalendarView::createPrinter()
1371{ 1373{
1372#ifndef KORG_NOPRINTER 1374#ifndef KORG_NOPRINTER
1373 if (!mCalPrinter) { 1375 if (!mCalPrinter) {
1374 mCalPrinter = new CalPrinter(this, mCalendar); 1376 mCalPrinter = new CalPrinter(this, mCalendar);
1375 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1377 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1376 } 1378 }
1377#endif 1379#endif
1378} 1380}
1379 1381
1380 1382
1381//KOPrefs::instance()->mWriteBackFile 1383//KOPrefs::instance()->mWriteBackFile
1382//KOPrefs::instance()->mWriteBackExistingOnly 1384//KOPrefs::instance()->mWriteBackExistingOnly
1383 1385
1384// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 1386// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
1385// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 1387// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
1386// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 1388// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
1387// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 1389// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
1388// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 1390// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
1389// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 1391// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
1390 1392
1391int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 1393int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
1392{ 1394{
1393 1395
1394 // 0 equal 1396 // 0 equal
1395 // 1 take local 1397 // 1 take local
1396 // 2 take remote 1398 // 2 take remote
1397 // 3 cancel 1399 // 3 cancel
1398 QDateTime lastSync = mLastCalendarSync; 1400 QDateTime lastSync = mLastCalendarSync;
1399 QDateTime localMod = local->lastModified(); 1401 QDateTime localMod = local->lastModified();
1400 QDateTime remoteMod = remote->lastModified(); 1402 QDateTime remoteMod = remote->lastModified();
1401 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1403 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1402 bool remCh, locCh; 1404 bool remCh, locCh;
1403 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 1405 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
1404 //if ( remCh ) 1406 //if ( remCh )
1405 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 1407 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
1406 locCh = ( localMod > mLastCalendarSync ); 1408 locCh = ( localMod > mLastCalendarSync );
1407 if ( !remCh && ! locCh ) { 1409 if ( !remCh && ! locCh ) {
1408 //qDebug("both not changed "); 1410 //qDebug("both not changed ");
1409 lastSync = localMod.addDays(1); 1411 lastSync = localMod.addDays(1);
1410 if ( mode <= SYNC_PREF_ASK ) 1412 if ( mode <= SYNC_PREF_ASK )
1411 return 0; 1413 return 0;
1412 } else { 1414 } else {
1413 if ( locCh ) { 1415 if ( locCh ) {
1414 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1416 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1415 lastSync = localMod.addDays( -1 ); 1417 lastSync = localMod.addDays( -1 );
1416 if ( !remCh ) 1418 if ( !remCh )
1417 remoteMod = ( lastSync.addDays( -1 ) ); 1419 remoteMod = ( lastSync.addDays( -1 ) );
1418 } else { 1420 } else {
1419 //qDebug(" not loc changed "); 1421 //qDebug(" not loc changed ");
1420 lastSync = localMod.addDays( 1 ); 1422 lastSync = localMod.addDays( 1 );
1421 if ( remCh ) 1423 if ( remCh )
1422 remoteMod =( lastSync.addDays( 1 ) ); 1424 remoteMod =( lastSync.addDays( 1 ) );
1423 1425
1424 } 1426 }
1425 } 1427 }
1426 full = true; 1428 full = true;
1427 if ( mode < SYNC_PREF_ASK ) 1429 if ( mode < SYNC_PREF_ASK )
1428 mode = SYNC_PREF_ASK; 1430 mode = SYNC_PREF_ASK;
1429 } else { 1431 } else {
1430 if ( localMod == remoteMod ) 1432 if ( localMod == remoteMod )
1431 // if ( local->revision() == remote->revision() ) 1433 // if ( local->revision() == remote->revision() )
1432 return 0; 1434 return 0;
1433 1435
1434 } 1436 }
1435 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1437 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1436 1438
1437 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1439 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1438 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1440 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1439 //full = true; //debug only 1441 //full = true; //debug only
1440 if ( full ) { 1442 if ( full ) {
1441 bool equ = false; 1443 bool equ = false;
1442 if ( local->typeID() == eventID ) { 1444 if ( local->typeID() == eventID ) {
1443 equ = (*((Event*) local) == *((Event*) remote)); 1445 equ = (*((Event*) local) == *((Event*) remote));
1444 } 1446 }
1445 else if ( local->typeID() == todoID ) 1447 else if ( local->typeID() == todoID )
1446 equ = (*((Todo*) local) == (*(Todo*) remote)); 1448 equ = (*((Todo*) local) == (*(Todo*) remote));
1447 else if ( local->typeID() == journalID ) 1449 else if ( local->typeID() == journalID )
1448 equ = (*((Journal*) local) == *((Journal*) remote)); 1450 equ = (*((Journal*) local) == *((Journal*) remote));
1449 if ( equ ) { 1451 if ( equ ) {
1450 //qDebug("equal "); 1452 //qDebug("equal ");
1451 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1453 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1452 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1454 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1453 } 1455 }
1454 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1456 if ( mode < SYNC_PREF_FORCE_LOCAL )
1455 return 0; 1457 return 0;
1456 1458
1457 }//else //debug only 1459 }//else //debug only
1458 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1460 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1459 } 1461 }
1460 int result; 1462 int result;
1461 bool localIsNew; 1463 bool localIsNew;
1462 //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() ); 1464 //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() );
1463 1465
1464 1466
1465 // ************************************************ 1467 // ************************************************
1466 // ************************************************ 1468 // ************************************************
1467 // ************************************************ 1469 // ************************************************
1468 // We may have that lastSync > remoteMod AND lastSync > localMod 1470 // We may have that lastSync > remoteMod AND lastSync > localMod
1469 // BUT remoteMod != localMod 1471 // BUT remoteMod != localMod
1470 1472
1471 1473
1472 if ( full && mode < SYNC_PREF_NEWEST ) 1474 if ( full && mode < SYNC_PREF_NEWEST )
1473 mode = SYNC_PREF_ASK; 1475 mode = SYNC_PREF_ASK;
1474 1476
1475 switch( mode ) { 1477 switch( mode ) {
1476 case SYNC_PREF_LOCAL: 1478 case SYNC_PREF_LOCAL:
1477 if ( lastSync > remoteMod ) 1479 if ( lastSync > remoteMod )
1478 return 1; 1480 return 1;
1479 if ( lastSync > localMod ) 1481 if ( lastSync > localMod )
1480 return 2; 1482 return 2;
1481 return 1; 1483 return 1;
1482 break; 1484 break;
1483 case SYNC_PREF_REMOTE: 1485 case SYNC_PREF_REMOTE:
1484 if ( lastSync > localMod ) 1486 if ( lastSync > localMod )
1485 return 2; 1487 return 2;
1486 if ( lastSync > remoteMod ) 1488 if ( lastSync > remoteMod )
1487 return 1; 1489 return 1;
1488 return 2; 1490 return 2;
1489 break; 1491 break;
1490 case SYNC_PREF_NEWEST: 1492 case SYNC_PREF_NEWEST:
1491 if ( localMod >= remoteMod ) 1493 if ( localMod >= remoteMod )
1492 return 1; 1494 return 1;
1493 else 1495 else
1494 return 2; 1496 return 2;
1495 break; 1497 break;
1496 case SYNC_PREF_ASK: 1498 case SYNC_PREF_ASK:
1497 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1499 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1498 if ( lastSync > remoteMod && lastSync > localMod) 1500 if ( lastSync > remoteMod && lastSync > localMod)
1499 return 0; 1501 return 0;
1500 if ( lastSync > remoteMod ) 1502 if ( lastSync > remoteMod )
1501 return 1; 1503 return 1;
1502 if ( lastSync > localMod ) 1504 if ( lastSync > localMod )
1503 return 2; 1505 return 2;
1504 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1506 qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1505 localIsNew = localMod >= remoteMod; 1507 localIsNew = localMod >= remoteMod;
1506 if ( localIsNew ) 1508 if ( localIsNew )
1507 getEventViewerDialog()->setColorMode( 1 ); 1509 getEventViewerDialog()->setColorMode( 1 );
1508 else 1510 else
1509 getEventViewerDialog()->setColorMode( 2 ); 1511 getEventViewerDialog()->setColorMode( 2 );
1510 getEventViewerDialog()->setIncidence(local); 1512 getEventViewerDialog()->setIncidence(local);
1511 if ( localIsNew ) 1513 if ( localIsNew )
1512 getEventViewerDialog()->setColorMode( 2 ); 1514 getEventViewerDialog()->setColorMode( 2 );
1513 else 1515 else
1514 getEventViewerDialog()->setColorMode( 1 ); 1516 getEventViewerDialog()->setColorMode( 1 );
1515 getEventViewerDialog()->addIncidence(remote); 1517 getEventViewerDialog()->addIncidence(remote);
1516 getEventViewerDialog()->setColorMode( 0 ); 1518 getEventViewerDialog()->setColorMode( 0 );
1517 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1519 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1518 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1520 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1519 getEventViewerDialog()->showMe(); 1521 getEventViewerDialog()->showMe();
1520 result = getEventViewerDialog()->executeS( localIsNew ); 1522 result = getEventViewerDialog()->executeS( localIsNew );
1521 return result; 1523 return result;
1522 1524
1523 break; 1525 break;
1524 case SYNC_PREF_FORCE_LOCAL: 1526 case SYNC_PREF_FORCE_LOCAL:
1525 return 1; 1527 return 1;
1526 break; 1528 break;
1527 case SYNC_PREF_FORCE_REMOTE: 1529 case SYNC_PREF_FORCE_REMOTE:
1528 return 2; 1530 return 2;
1529 break; 1531 break;
1530 1532
1531 default: 1533 default:
1532 // SYNC_PREF_TAKE_BOTH not implemented 1534 // SYNC_PREF_TAKE_BOTH not implemented
1533 break; 1535 break;
1534 } 1536 }
1535 return 0; 1537 return 0;
1536} 1538}
1537Event* CalendarView::getLastSyncEvent() 1539Event* CalendarView::getLastSyncEvent()
1538{ 1540{
1539 Event* lse; 1541 Event* lse;
1540 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1542 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1541 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1543 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1542 if (!lse) { 1544 if (!lse) {
1543 lse = new Event(); 1545 lse = new Event();
1544 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1546 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1545 QString sum = ""; 1547 QString sum = "";
1546 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1548 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1547 sum = "E: "; 1549 sum = "E: ";
1548 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1550 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1549 lse->setDtStart( mLastCalendarSync ); 1551 lse->setDtStart( mLastCalendarSync );
1550 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1552 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1551 lse->setCategories( i18n("SyncEvent") ); 1553 lse->setCategories( i18n("SyncEvent") );
1552 lse->setReadOnly( true ); 1554 lse->setReadOnly( true );
1553 mCalendar->addEvent( lse ); 1555 mCalendar->addEvent( lse );
1554 } 1556 }
1555 1557
1556 return lse; 1558 return lse;
1557 1559
1558} 1560}
1559 1561
1560// we check, if the to delete event has a id for a profile 1562// we check, if the to delete event has a id for a profile
1561// if yes, we set this id in the profile to delete 1563// if yes, we set this id in the profile to delete
1562void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1564void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1563{ 1565{
1564 if ( lastSync.count() == 0 ) { 1566 if ( lastSync.count() == 0 ) {
1565 //qDebug(" lastSync.count() == 0"); 1567 //qDebug(" lastSync.count() == 0");
1566 return; 1568 return;
1567 } 1569 }
1568 if ( toDelete->typeID() == journalID ) 1570 if ( toDelete->typeID() == journalID )
1569 return; 1571 return;
1570 1572
1571 Event* eve = lastSync.first(); 1573 Event* eve = lastSync.first();
1572 1574
1573 while ( eve ) { 1575 while ( eve ) {
1574 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1576 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1575 if ( !id.isEmpty() ) { 1577 if ( !id.isEmpty() ) {
1576 QString des = eve->description(); 1578 QString des = eve->description();
1577 QString pref = "e"; 1579 QString pref = "e";
1578 if ( toDelete->typeID() == todoID ) 1580 if ( toDelete->typeID() == todoID )
1579 pref = "t"; 1581 pref = "t";
1580 des += pref+ id + ","; 1582 des += pref+ id + ",";
1581 eve->setReadOnly( false ); 1583 eve->setReadOnly( false );
1582 eve->setDescription( des ); 1584 eve->setDescription( des );
1583 //qDebug("setdes %s ", des.latin1()); 1585 //qDebug("setdes %s ", des.latin1());
1584 eve->setReadOnly( true ); 1586 eve->setReadOnly( true );
1585 } 1587 }
1586 eve = lastSync.next(); 1588 eve = lastSync.next();
1587 } 1589 }
1588 1590
1589} 1591}
1590void CalendarView::checkExternalId( Incidence * inc ) 1592void CalendarView::checkExternalId( Incidence * inc )
1591{ 1593{
1592 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1594 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1593 checkExternSyncEvent( lastSync, inc ); 1595 checkExternSyncEvent( lastSync, inc );
1594 1596
1595} 1597}
1596bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1598bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1597{ 1599{
1598 bool syncOK = true; 1600 bool syncOK = true;
1599 int addedEvent = 0; 1601 int addedEvent = 0;
1600 int addedEventR = 0; 1602 int addedEventR = 0;
1601 int deletedEventR = 0; 1603 int deletedEventR = 0;
1602 int deletedEventL = 0; 1604 int deletedEventL = 0;
1603 int changedLocal = 0; 1605 int changedLocal = 0;
1604 int changedRemote = 0; 1606 int changedRemote = 0;
1605 int filteredIN = 0; 1607 int filteredIN = 0;
1606 int filteredOUT = 0; 1608 int filteredOUT = 0;
1607 //QPtrList<Event> el = local->rawEvents(); 1609 //QPtrList<Event> el = local->rawEvents();
1608 Event* eventR; 1610 Event* eventR;
1609 QString uid; 1611 QString uid;
1610 int take; 1612 int take;
1611 Event* eventRSync; 1613 Event* eventRSync;
1612 Event* eventLSync; 1614 Event* eventLSync;
1613 clearAllViews(); 1615 clearAllViews();
1614 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1616 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1615 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1617 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1616 bool fullDateRange = false; 1618 bool fullDateRange = false;
1617 local->resetTempSyncStat(); 1619 local->resetTempSyncStat();
1618 mLastCalendarSync = QDateTime::currentDateTime(); 1620 mLastCalendarSync = QDateTime::currentDateTime();
1619 if ( mSyncManager->syncWithDesktop() ) { 1621 if ( mSyncManager->syncWithDesktop() ) {
1620 remote->resetPilotStat(1); 1622 remote->resetPilotStat(1);
1621 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1623 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1622 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1624 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1623 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1625 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1624 } else { 1626 } else {
1625 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1627 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1626 } 1628 }
1627 } 1629 }
1628 QDateTime modifiedCalendar = mLastCalendarSync; 1630 QDateTime modifiedCalendar = mLastCalendarSync;
1629 eventLSync = getLastSyncEvent(); 1631 eventLSync = getLastSyncEvent();
1630 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1632 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1631 if ( eventR ) { 1633 if ( eventR ) {
1632 qDebug("last-syncEvent on remote found "); 1634 qDebug("last-syncEvent on remote found ");
1633 eventRSync = (Event*) eventR->clone(); 1635 eventRSync = (Event*) eventR->clone();
1634 remote->deleteEvent(eventR ); 1636 remote->deleteEvent(eventR );
1635 1637
1636 } else { 1638 } else {
1637 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1639 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1638 eventRSync = (Event*)eventLSync->clone(); 1640 eventRSync = (Event*)eventLSync->clone();
1639 } else { 1641 } else {
1640 fullDateRange = true; 1642 fullDateRange = true;
1641 eventRSync = new Event(); 1643 eventRSync = new Event();
1642 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1644 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1643 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1645 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1644 eventRSync->setDtStart( mLastCalendarSync ); 1646 eventRSync->setDtStart( mLastCalendarSync );
1645 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1647 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1646 eventRSync->setCategories( i18n("SyncEvent") ); 1648 eventRSync->setCategories( i18n("SyncEvent") );
1647 } 1649 }
1648 } 1650 }
1649 if ( eventLSync->dtStart() == mLastCalendarSync ) 1651 if ( eventLSync->dtStart() == mLastCalendarSync )
1650 fullDateRange = true; 1652 fullDateRange = true;
1651 1653
1652 if ( ! fullDateRange ) { 1654 if ( ! fullDateRange ) {
1653 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1655 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1654 1656
1655 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1657 qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1656 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1658 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1657 fullDateRange = true; 1659 fullDateRange = true;
1658 } 1660 }
1659 } 1661 }
1660 if ( mSyncManager->syncWithDesktop() ) { 1662 if ( mSyncManager->syncWithDesktop() ) {
1661 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1663 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1662 } 1664 }
1663 if ( fullDateRange ) 1665 if ( fullDateRange )
1664 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1666 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1665 else 1667 else
1666 mLastCalendarSync = eventLSync->dtStart(); 1668 mLastCalendarSync = eventLSync->dtStart();
1667 // for resyncing if own file has changed 1669 // for resyncing if own file has changed
1668 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1670 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1669 mLastCalendarSync = loadedFileVersion; 1671 mLastCalendarSync = loadedFileVersion;
1670 //qDebug("setting mLastCalendarSync "); 1672 //qDebug("setting mLastCalendarSync ");
1671 } 1673 }
1672 //qDebug("*************************** "); 1674 //qDebug("*************************** ");
1673 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1675 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1674 QPtrList<Incidence> er = remote->rawIncidences(); 1676 QPtrList<Incidence> er = remote->rawIncidences();
1675 Incidence* inR = er.first(); 1677 Incidence* inR = er.first();
1676 Incidence* inL; 1678 Incidence* inL;
1677 QProgressBar bar( er.count(),0 ); 1679 QProgressBar bar( er.count(),0 );
1678 bar.setCaption (i18n("Syncing - close to abort!") ); 1680 bar.setCaption (i18n("Syncing - close to abort!") );
1679 1681
1680 // ************** setting up filter ************* 1682 // ************** setting up filter *************
1681 CalFilter *filterIN = 0; 1683 CalFilter *filterIN = 0;
1682 CalFilter *filterOUT = 0; 1684 CalFilter *filterOUT = 0;
1683 CalFilter *filter = mFilters.first(); 1685 CalFilter *filter = mFilters.first();
1684 while(filter) { 1686 while(filter) {
1685 if ( filter->name() == mSyncManager->mFilterInCal ) 1687 if ( filter->name() == mSyncManager->mFilterInCal )
1686 filterIN = filter; 1688 filterIN = filter;
1687 if ( filter->name() == mSyncManager->mFilterOutCal ) 1689 if ( filter->name() == mSyncManager->mFilterOutCal )
1688 filterOUT = filter; 1690 filterOUT = filter;
1689 filter = mFilters.next(); 1691 filter = mFilters.next();
1690 } 1692 }
1691 int w = 300; 1693 int w = 300;
1692 if ( QApplication::desktop()->width() < 320 ) 1694 if ( QApplication::desktop()->width() < 320 )
1693 w = 220; 1695 w = 220;
1694 int h = bar.sizeHint().height() ; 1696 int h = bar.sizeHint().height() ;
1695 int dw = QApplication::desktop()->width(); 1697 int dw = QApplication::desktop()->width();
1696 int dh = QApplication::desktop()->height(); 1698 int dh = QApplication::desktop()->height();
1697 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1699 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1698 bar.show(); 1700 bar.show();
1699 int modulo = (er.count()/10)+1; 1701 int modulo = (er.count()/10)+1;
1700 int incCounter = 0; 1702 int incCounter = 0;
1701 while ( inR ) { 1703 while ( inR ) {
1702 if ( ! bar.isVisible() ) 1704 if ( ! bar.isVisible() )
1703 return false; 1705 return false;
1704 if ( incCounter % modulo == 0 ) 1706 if ( incCounter % modulo == 0 )
1705 bar.setProgress( incCounter ); 1707 bar.setProgress( incCounter );
1706 ++incCounter; 1708 ++incCounter;
1707 uid = inR->uid(); 1709 uid = inR->uid();
1708 bool skipIncidence = false; 1710 bool skipIncidence = false;
1709 if ( uid.left(15) == QString("last-syncEvent-") ) 1711 if ( uid.left(15) == QString("last-syncEvent-") )
1710 skipIncidence = true; 1712 skipIncidence = true;
1711 QString idS; 1713 QString idS;
1712 qApp->processEvents(); 1714 qApp->processEvents();
1713 if ( !skipIncidence ) { 1715 if ( !skipIncidence ) {
1714 inL = local->incidenceForUid( uid , false ); 1716 inL = local->incidenceForUid( uid , false );
1715 if ( inL ) { // maybe conflict - same uid in both calendars 1717 if ( inL ) { // maybe conflict - same uid in both calendars
1716 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1718 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1717 //qDebug("take %d %s ", take, inL->summary().latin1()); 1719 //qDebug("take %d %s ", take, inL->summary().latin1());
1718 if ( take == 3 ) 1720 if ( take == 3 )
1719 return false; 1721 return false;
1720 if ( take == 1 ) {// take local ********************** 1722 if ( take == 1 ) {// take local **********************
1721 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1723 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1722 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1724 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1723 else 1725 else
1724 idS = inR->IDStr(); 1726 idS = inR->IDStr();
1725 int calID = inR->calID(); 1727 int calID = inR->calID();
1726 remote->deleteIncidence( inR ); 1728 remote->deleteIncidence( inR );
1727 inR = inL->clone(); 1729 inR = inL->clone();
1728 inR->setCalID( calID ); 1730 inR->setCalID( calID );
1729 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1731 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1730 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1732 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1731 inR->setIDStr( idS ); 1733 inR->setIDStr( idS );
1732 remote->addIncidence( inR ); 1734 remote->addIncidence( inR );
1733 if ( mSyncManager->syncWithDesktop() ) 1735 if ( mSyncManager->syncWithDesktop() )
1734 inR->setPilotId( 2 ); 1736 inR->setPilotId( 2 );
1735 ++changedRemote; 1737 ++changedRemote;
1736 } else {// take remote ********************** 1738 } else {// take remote **********************
1737 if ( !inL->isReadOnly() ) { 1739 if ( !inL->isReadOnly() ) {
1738 idS = inL->IDStr(); 1740 idS = inL->IDStr();
1739 int pid = inL->pilotId(); 1741 int pid = inL->pilotId();
1740 int calID = inL->calID(); 1742 int calID = inL->calID();
1741 local->deleteIncidence( inL ); 1743 local->deleteIncidence( inL );
1742 inL = inR->clone(); 1744 inL = inR->clone();
1743 inL->setCalID( calID ); 1745 inL->setCalID( calID );
1744 if ( mSyncManager->syncWithDesktop() ) 1746 if ( mSyncManager->syncWithDesktop() )
1745 inL->setPilotId( pid ); 1747 inL->setPilotId( pid );
1746 inL->setIDStr( idS ); 1748 inL->setIDStr( idS );
1747 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1749 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1748 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1750 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1749 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1751 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1750 } 1752 }
1751 local->addIncidence( inL ); 1753 local->addIncidence( inL );
1752 ++changedLocal; 1754 ++changedLocal;
1753 } 1755 }
1754 } 1756 }
1755 } 1757 }
1756 } else { // no conflict ********** add or delete remote 1758 } else { // no conflict ********** add or delete remote
1757 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1759 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1758 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1760 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1759 QString des = eventLSync->description(); 1761 QString des = eventLSync->description();
1760 QString pref = "e"; 1762 QString pref = "e";
1761 if ( inR->typeID() == todoID ) 1763 if ( inR->typeID() == todoID )
1762 pref = "t"; 1764 pref = "t";
1763 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1765 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1764 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1766 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1765 //remote->deleteIncidence( inR ); 1767 //remote->deleteIncidence( inR );
1766 ++deletedEventR; 1768 ++deletedEventR;
1767 } else { 1769 } else {
1768 inR->setLastModified( modifiedCalendar ); 1770 inR->setLastModified( modifiedCalendar );
1769 inL = inR->clone(); 1771 inL = inR->clone();
1770 inL->setIDStr( ":" ); 1772 inL->setIDStr( ":" );
1771 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1773 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1772 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1774 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1773 1775
1774 inL->setCalID( 0 );// add to default cal 1776 inL->setCalID( 0 );// add to default cal
1775 local->addIncidence( inL ); 1777 local->addIncidence( inL );
1776 ++addedEvent; 1778 ++addedEvent;
1777 1779
1778 } 1780 }
1779 } else { 1781 } else {
1780 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1782 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1781 inR->setLastModified( modifiedCalendar ); 1783 inR->setLastModified( modifiedCalendar );
1782 inL = inR->clone(); 1784 inL = inR->clone();
1783 inL->setIDStr( ":" ); 1785 inL->setIDStr( ":" );
1784 inL->setCalID( 0 );// add to default cal 1786 inL->setCalID( 0 );// add to default cal
1785 local->addIncidence( inL ); 1787 local->addIncidence( inL );
1786 ++addedEvent; 1788 ++addedEvent;
1787 1789
1788 } else { 1790 } else {
1789 checkExternSyncEvent(eventRSyncSharp, inR); 1791 checkExternSyncEvent(eventRSyncSharp, inR);
1790 remote->deleteIncidence( inR ); 1792 remote->deleteIncidence( inR );
1791 ++deletedEventR; 1793 ++deletedEventR;
1792 } 1794 }
1793 } 1795 }
1794 } else { 1796 } else {
1795 ++filteredIN; 1797 ++filteredIN;
1796 } 1798 }
1797 } 1799 }
1798 } 1800 }
1799 inR = er.next(); 1801 inR = er.next();
1800 } 1802 }
1801 QPtrList<Incidence> el = local->rawIncidences(); 1803 QPtrList<Incidence> el = local->rawIncidences();
1802 inL = el.first(); 1804 inL = el.first();
1803 modulo = (el.count()/10)+1; 1805 modulo = (el.count()/10)+1;
1804 bar.setCaption (i18n("Add / remove events") ); 1806 bar.setCaption (i18n("Add / remove events") );
1805 bar.setTotalSteps ( el.count() ) ; 1807 bar.setTotalSteps ( el.count() ) ;
1806 bar.show(); 1808 bar.show();
1807 incCounter = 0; 1809 incCounter = 0;
1808 1810
1809 while ( inL ) { 1811 while ( inL ) {
1810 1812
1811 qApp->processEvents(); 1813 qApp->processEvents();
1812 if ( ! bar.isVisible() ) 1814 if ( ! bar.isVisible() )
1813 return false; 1815 return false;
1814 if ( incCounter % modulo == 0 ) 1816 if ( incCounter % modulo == 0 )
1815 bar.setProgress( incCounter ); 1817 bar.setProgress( incCounter );
1816 ++incCounter; 1818 ++incCounter;
1817 uid = inL->uid(); 1819 uid = inL->uid();
1818 bool skipIncidence = false; 1820 bool skipIncidence = false;
1819 if ( uid.left(15) == QString("last-syncEvent-") ) 1821 if ( uid.left(15) == QString("last-syncEvent-") )
1820 skipIncidence = true; 1822 skipIncidence = true;
1821 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1823 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1822 skipIncidence = true; 1824 skipIncidence = true;
1823 if ( !skipIncidence ) { 1825 if ( !skipIncidence ) {
1824 inR = remote->incidenceForUid( uid , true ); 1826 inR = remote->incidenceForUid( uid , true );
1825 if ( ! inR ) { 1827 if ( ! inR ) {
1826 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1828 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1827 // no conflict ********** add or delete local 1829 // no conflict ********** add or delete local
1828 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1830 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1829 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1831 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1830 checkExternSyncEvent(eventLSyncSharp, inL); 1832 checkExternSyncEvent(eventLSyncSharp, inL);
1831 local->deleteIncidence( inL ); 1833 local->deleteIncidence( inL );
1832 ++deletedEventL; 1834 ++deletedEventL;
1833 } else { 1835 } else {
1834 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1836 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1835 inL->removeID(mCurrentSyncDevice ); 1837 inL->removeID(mCurrentSyncDevice );
1836 ++addedEventR; 1838 ++addedEventR;
1837 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1839 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1838 inL->setLastModified( modifiedCalendar ); 1840 inL->setLastModified( modifiedCalendar );
1839 inR = inL->clone(); 1841 inR = inL->clone();
1840 inR->setIDStr( ":" ); 1842 inR->setIDStr( ":" );
1841 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1843 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1842 inR->setCalID( 0 );// add to default cal 1844 inR->setCalID( 0 );// add to default cal
1843 remote->addIncidence( inR ); 1845 remote->addIncidence( inR );
1844 } 1846 }
1845 } 1847 }
1846 } else { 1848 } else {
1847 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1849 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1848 checkExternSyncEvent(eventLSyncSharp, inL); 1850 checkExternSyncEvent(eventLSyncSharp, inL);
1849 local->deleteIncidence( inL ); 1851 local->deleteIncidence( inL );
1850 ++deletedEventL; 1852 ++deletedEventL;
1851 } else { 1853 } else {
1852 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1854 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1853 ++addedEventR; 1855 ++addedEventR;
1854 inL->setLastModified( modifiedCalendar ); 1856 inL->setLastModified( modifiedCalendar );
1855 inR = inL->clone(); 1857 inR = inL->clone();
1856 inR->setIDStr( ":" ); 1858 inR->setIDStr( ":" );
1857 inR->setCalID( 0 );// add to default cal 1859 inR->setCalID( 0 );// add to default cal
1858 remote->addIncidence( inR ); 1860 remote->addIncidence( inR );
1859 } 1861 }
1860 } 1862 }
1861 } 1863 }
1862 } else { 1864 } else {
1863 ++filteredOUT; 1865 ++filteredOUT;
1864 } 1866 }
1865 } 1867 }
1866 } 1868 }
1867 inL = el.next(); 1869 inL = el.next();
1868 } 1870 }
1869 int delFut = 0; 1871 int delFut = 0;
1870 int remRem = 0; 1872 int remRem = 0;
1871 if ( mSyncManager->mWriteBackInFuture ) { 1873 if ( mSyncManager->mWriteBackInFuture ) {
1872 er = remote->rawIncidences(); 1874 er = remote->rawIncidences();
1873 remRem = er.count(); 1875 remRem = er.count();
1874 inR = er.first(); 1876 inR = er.first();
1875 QDateTime dt; 1877 QDateTime dt;
1876 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1878 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1877 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1879 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1878 while ( inR ) { 1880 while ( inR ) {
1879 if ( inR->typeID() == todoID ) { 1881 if ( inR->typeID() == todoID ) {
1880 Todo * t = (Todo*)inR; 1882 Todo * t = (Todo*)inR;
1881 if ( t->hasDueDate() ) 1883 if ( t->hasDueDate() )
1882 dt = t->dtDue(); 1884 dt = t->dtDue();
1883 else 1885 else
1884 dt = cur.addSecs( 62 ); 1886 dt = cur.addSecs( 62 );
1885 } 1887 }
1886 else if (inR->typeID() == eventID ) { 1888 else if (inR->typeID() == eventID ) {
1887 bool ok; 1889 bool ok;
1888 dt = inR->getNextOccurence( cur, &ok ); 1890 dt = inR->getNextOccurence( cur, &ok );
1889 if ( !ok ) 1891 if ( !ok )
1890 dt = cur.addSecs( -62 ); 1892 dt = cur.addSecs( -62 );
1891 } 1893 }
1892 else 1894 else
1893 dt = inR->dtStart(); 1895 dt = inR->dtStart();
1894 if ( dt < cur || dt > end ) { 1896 if ( dt < cur || dt > end ) {
1895 remote->deleteIncidence( inR ); 1897 remote->deleteIncidence( inR );
1896 ++delFut; 1898 ++delFut;
1897 } 1899 }
1898 inR = er.next(); 1900 inR = er.next();
1899 } 1901 }
1900 } 1902 }
1901 bar.hide(); 1903 bar.hide();
1902 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1904 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1903 eventLSync->setReadOnly( false ); 1905 eventLSync->setReadOnly( false );
1904 eventLSync->setDtStart( mLastCalendarSync ); 1906 eventLSync->setDtStart( mLastCalendarSync );
1905 eventRSync->setDtStart( mLastCalendarSync ); 1907 eventRSync->setDtStart( mLastCalendarSync );
1906 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1908 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1907 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1909 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1908 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1910 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1909 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1911 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1910 eventLSync->setReadOnly( true ); 1912 eventLSync->setReadOnly( true );
1911 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1913 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1912 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1914 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1913 remote->addEvent( eventRSync ); 1915 remote->addEvent( eventRSync );
1914 else 1916 else
1915 delete eventRSync; 1917 delete eventRSync;
1916 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1918 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1917 QString mes; 1919 QString mes;
1918 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1920 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1919 QString delmess; 1921 QString delmess;
1920 if ( delFut ) { 1922 if ( delFut ) {
1921 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1923 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1922 mes += delmess; 1924 mes += delmess;
1923 } 1925 }
1924 mes = i18n("Local calendar changed!\n") +mes; 1926 mes = i18n("Local calendar changed!\n") +mes;
1925 mCalendar->checkAlarmForIncidence( 0, true ); 1927 mCalendar->checkAlarmForIncidence( 0, true );
1926 qDebug( mes ); 1928 qDebug( mes );
1927 if ( mSyncManager->mShowSyncSummary ) { 1929 if ( mSyncManager->mShowSyncSummary ) {
1928 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1930 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1929 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1931 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1930 qDebug("KO: WB cancelled "); 1932 qDebug("KO: WB cancelled ");
1931 mSyncManager->mWriteBackFile = false; 1933 mSyncManager->mWriteBackFile = false;
1932 return syncOK; 1934 return syncOK;
1933 } 1935 }
1934 } 1936 }
1935 return syncOK; 1937 return syncOK;
1936} 1938}
1937 1939
1938void CalendarView::setSyncDevice( QString s ) 1940void CalendarView::setSyncDevice( QString s )
1939{ 1941{
1940 mCurrentSyncDevice= s; 1942 mCurrentSyncDevice= s;
1941} 1943}
1942void CalendarView::setSyncName( QString s ) 1944void CalendarView::setSyncName( QString s )
1943{ 1945{
1944 mCurrentSyncName= s; 1946 mCurrentSyncName= s;
1945} 1947}
1946bool CalendarView::syncCalendar(QString filename, int mode) 1948bool CalendarView::syncCalendar(QString filename, int mode)
1947{ 1949{
1948 //qDebug("syncCalendar %s ", filename.latin1()); 1950 //qDebug("syncCalendar %s ", filename.latin1());
1949 mGlobalSyncMode = SYNC_MODE_NORMAL; 1951 mGlobalSyncMode = SYNC_MODE_NORMAL;
1950 CalendarLocal* calendar = new CalendarLocal(); 1952 CalendarLocal* calendar = new CalendarLocal();
1951 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1953 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1952 FileStorage* storage = new FileStorage( calendar ); 1954 FileStorage* storage = new FileStorage( calendar );
1953 bool syncOK = false; 1955 bool syncOK = false;
1954 storage->setFileName( filename ); 1956 storage->setFileName( filename );
1955 // qDebug("loading ... "); 1957 // qDebug("loading ... ");
1956 if ( storage->load() ) { 1958 if ( storage->load() ) {
1957 getEventViewerDialog()->setSyncMode( true ); 1959 getEventViewerDialog()->setSyncMode( true );
1958 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1960 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1959 getEventViewerDialog()->setSyncMode( false ); 1961 getEventViewerDialog()->setSyncMode( false );
1960 if ( syncOK ) { 1962 if ( syncOK ) {
1961 if ( mSyncManager->mWriteBackFile ) 1963 if ( mSyncManager->mWriteBackFile )
1962 { 1964 {
1963 storage->setSaveFormat( new ICalFormat() ); 1965 storage->setSaveFormat( new ICalFormat() );
1964 storage->save(); 1966 storage->save();
1965 } 1967 }
1966 } 1968 }
1967 setModified( true ); 1969 setModified( true );
1968 } 1970 }
1969 delete storage; 1971 delete storage;
1970 delete calendar; 1972 delete calendar;
1971 if ( syncOK ) 1973 if ( syncOK )
1972 updateView(); 1974 updateView();
1973 return syncOK; 1975 return syncOK;
1974} 1976}
1975 1977
1976void CalendarView::syncExternal( int mode ) 1978void CalendarView::syncExternal( int mode )
1977{ 1979{
1978 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1980 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1979 1981
1980 qApp->processEvents(); 1982 qApp->processEvents();
1981 CalendarLocal* calendar = new CalendarLocal(); 1983 CalendarLocal* calendar = new CalendarLocal();
1982 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1984 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1983 bool syncOK = false; 1985 bool syncOK = false;
1984 bool loadSuccess = false; 1986 bool loadSuccess = false;
1985 PhoneFormat* phoneFormat = 0; 1987 PhoneFormat* phoneFormat = 0;
1986 emit tempDisableBR(true); 1988 emit tempDisableBR(true);
1987#ifndef DESKTOP_VERSION 1989#ifndef DESKTOP_VERSION
1988 SharpFormat* sharpFormat = 0; 1990 SharpFormat* sharpFormat = 0;
1989 if ( mode == 0 ) { // sharp 1991 if ( mode == 0 ) { // sharp
1990 sharpFormat = new SharpFormat () ; 1992 sharpFormat = new SharpFormat () ;
1991 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1993 loadSuccess = sharpFormat->load( calendar, mCalendar );
1992 1994
1993 } else 1995 } else
1994#endif 1996#endif
1995 if ( mode == 1 ) { // phone 1997 if ( mode == 1 ) { // phone
1996 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1998 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1997 mSyncManager->mPhoneDevice, 1999 mSyncManager->mPhoneDevice,
1998 mSyncManager->mPhoneConnection, 2000 mSyncManager->mPhoneConnection,
1999 mSyncManager->mPhoneModel); 2001 mSyncManager->mPhoneModel);
2000 loadSuccess = phoneFormat->load( calendar,mCalendar); 2002 loadSuccess = phoneFormat->load( calendar,mCalendar);
2001 2003
2002 } else { 2004 } else {
2003 emit tempDisableBR(false); 2005 emit tempDisableBR(false);
2004 return; 2006 return;
2005 } 2007 }
2006 if ( loadSuccess ) { 2008 if ( loadSuccess ) {
2007 getEventViewerDialog()->setSyncMode( true ); 2009 getEventViewerDialog()->setSyncMode( true );
2008 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2010 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2009 getEventViewerDialog()->setSyncMode( false ); 2011 getEventViewerDialog()->setSyncMode( false );
2010 qApp->processEvents(); 2012 qApp->processEvents();
2011 if ( syncOK ) { 2013 if ( syncOK ) {
2012 if ( mSyncManager->mWriteBackFile ) 2014 if ( mSyncManager->mWriteBackFile )
2013 { 2015 {
2014 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 2016 QPtrList<Incidence> iL = mCalendar->rawIncidences();
2015 Incidence* inc = iL.first(); 2017 Incidence* inc = iL.first();
2016 if ( phoneFormat ) { 2018 if ( phoneFormat ) {
2017 while ( inc ) { 2019 while ( inc ) {
2018 inc->removeID(mCurrentSyncDevice); 2020 inc->removeID(mCurrentSyncDevice);
2019 inc = iL.next(); 2021 inc = iL.next();
2020 } 2022 }
2021 } 2023 }
2022#ifndef DESKTOP_VERSION 2024#ifndef DESKTOP_VERSION
2023 if ( sharpFormat ) 2025 if ( sharpFormat )
2024 sharpFormat->save(calendar); 2026 sharpFormat->save(calendar);
2025#endif 2027#endif
2026 if ( phoneFormat ) 2028 if ( phoneFormat )
2027 phoneFormat->save(calendar); 2029 phoneFormat->save(calendar);
2028 iL = calendar->rawIncidences(); 2030 iL = calendar->rawIncidences();
2029 inc = iL.first(); 2031 inc = iL.first();
2030 Incidence* loc; 2032 Incidence* loc;
2031 while ( inc ) { 2033 while ( inc ) {
2032 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 2034 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
2033 loc = mCalendar->incidence(inc->uid() ); 2035 loc = mCalendar->incidence(inc->uid() );
2034 if ( loc ) { 2036 if ( loc ) {
2035 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 2037 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
2036 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 2038 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
2037 } 2039 }
2038 } 2040 }
2039 inc = iL.next(); 2041 inc = iL.next();
2040 } 2042 }
2041 Incidence* lse = getLastSyncEvent(); 2043 Incidence* lse = getLastSyncEvent();
2042 if ( lse ) { 2044 if ( lse ) {
2043 lse->setReadOnly( false ); 2045 lse->setReadOnly( false );
2044 lse->setDescription( "" ); 2046 lse->setDescription( "" );
2045 lse->setReadOnly( true ); 2047 lse->setReadOnly( true );
2046 } 2048 }
2047 } 2049 }
2048 } else { 2050 } else {
2049 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 2051 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
2050 } 2052 }
2051 setModified( true ); 2053 setModified( true );
2052 } else { 2054 } else {
2053 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 2055 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
2054 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 2056 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
2055 question, i18n("Ok")) ; 2057 question, i18n("Ok")) ;
2056 2058
2057 } 2059 }
2058 delete calendar; 2060 delete calendar;
2059 updateView(); 2061 updateView();
2060 emit tempDisableBR(false); 2062 emit tempDisableBR(false);
2061 return ;//syncOK; 2063 return ;//syncOK;
2062 2064
2063} 2065}
2064 2066
2065bool CalendarView::importBday() 2067bool CalendarView::importBday()
2066{ 2068{
2067#ifndef KORG_NOKABC 2069#ifndef KORG_NOKABC
2068 2070
2069#ifdef DESKTOP_VERSION 2071#ifdef DESKTOP_VERSION
2070 int curCal = mCalendar->defaultCalendar(); 2072 int curCal = mCalendar->defaultCalendar();
2071 int bd = mCalEditView->getBirtdayID(); 2073 int bd = mCalEditView->getBirtdayID();
2072 if ( bd == 0 ) 2074 if ( bd == 0 )
2073 return false; 2075 return false;
2074 mCalendar->setDefaultCalendar( bd ); 2076 mCalendar->setDefaultCalendar( bd );
2075 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 2077 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
2076 KABC::AddressBook::Iterator it; 2078 KABC::AddressBook::Iterator it;
2077 int count = 0; 2079 int count = 0;
2078 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2080 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2079 ++count; 2081 ++count;
2080 } 2082 }
2081 QProgressBar bar(count,0 ); 2083 QProgressBar bar(count,0 );
2082 int w = 300; 2084 int w = 300;
2083 if ( QApplication::desktop()->width() < 320 ) 2085 if ( QApplication::desktop()->width() < 320 )
2084 w = 220; 2086 w = 220;
2085 int h = bar.sizeHint().height() ; 2087 int h = bar.sizeHint().height() ;
2086 int dw = QApplication::desktop()->width(); 2088 int dw = QApplication::desktop()->width();
2087 int dh = QApplication::desktop()->height(); 2089 int dh = QApplication::desktop()->height();
2088 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2090 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2089 bar.show(); 2091 bar.show();
2090 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 2092 bar.setCaption (i18n("Reading addressbook - close to abort!") );
2091 qApp->processEvents(); 2093 qApp->processEvents();
2092 count = 0; 2094 count = 0;
2093 int addCount = 0; 2095 int addCount = 0;
2094 KCal::Attendee* a = 0; 2096 KCal::Attendee* a = 0;
2095 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2097 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2096 if ( ! bar.isVisible() ) 2098 if ( ! bar.isVisible() )
2097 return false; 2099 return false;
2098 bar.setProgress( count++ ); 2100 bar.setProgress( count++ );
2099 qApp->processEvents(); 2101 qApp->processEvents();
2100 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 2102 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
2101 if ( (*it).birthday().date().isValid() ){ 2103 if ( (*it).birthday().date().isValid() ){
2102 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2104 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2103 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 2105 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
2104 ++addCount; 2106 ++addCount;
2105 } 2107 }
2106 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 2108 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
2107 if ( anni.isValid() ){ 2109 if ( anni.isValid() ){
2108 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2110 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2109 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 2111 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
2110 ++addCount; 2112 ++addCount;
2111 } 2113 }
2112 } 2114 }
2113 mCalendar->setDefaultCalendar( curCal ); 2115 mCalendar->setDefaultCalendar( curCal );
2114 updateView(); 2116 updateView();
2115 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2117 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2116#else //DESKTOP_VERSION 2118#else //DESKTOP_VERSION
2117 2119
2118 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 2120 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
2119 // the result should now arrive through method insertBirthdays 2121 // the result should now arrive through method insertBirthdays
2120 2122
2121#endif //DESKTOP_VERSION 2123#endif //DESKTOP_VERSION
2122 2124
2123#endif //KORG_NOKABC 2125#endif //KORG_NOKABC
2124 2126
2125 2127
2126 return true; 2128 return true;
2127} 2129}
2128 2130
2129// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 2131// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
2130void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 2132void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
2131 const QStringList& anniversaryList, const QStringList& realNameList, 2133 const QStringList& anniversaryList, const QStringList& realNameList,
2132 const QStringList& emailList, const QStringList& assembledNameList, 2134 const QStringList& emailList, const QStringList& assembledNameList,
2133 const QStringList& uidList) 2135 const QStringList& uidList)
2134{ 2136{
2135 2137
2136 //qDebug("KO::CalendarView::insertBirthdays"); 2138 //qDebug("KO::CalendarView::insertBirthdays");
2137 if (uid == this->name()) 2139 if (uid == this->name())
2138 { 2140 {
2139 int curCal = mCalendar->defaultCalendar(); 2141 int curCal = mCalendar->defaultCalendar();
2140 int bd = mCalEditView->getBirtdayID(); 2142 int bd = mCalEditView->getBirtdayID();
2141 if ( bd == 0 ) 2143 if ( bd == 0 )
2142 return; 2144 return;
2143 mCalendar->setDefaultCalendar( bd ); 2145 mCalendar->setDefaultCalendar( bd );
2144 2146
2145 2147
2146 int count = birthdayList.count(); 2148 int count = birthdayList.count();
2147 int addCount = 0; 2149 int addCount = 0;
2148 KCal::Attendee* a = 0; 2150 KCal::Attendee* a = 0;
2149 2151
2150 //qDebug("CalView 1 %i", count); 2152 //qDebug("CalView 1 %i", count);
2151 2153
2152 QProgressBar bar(count,0 ); 2154 QProgressBar bar(count,0 );
2153 int w = 300; 2155 int w = 300;
2154 if ( QApplication::desktop()->width() < 320 ) 2156 if ( QApplication::desktop()->width() < 320 )
2155 w = 220; 2157 w = 220;
2156 int h = bar.sizeHint().height() ; 2158 int h = bar.sizeHint().height() ;
2157 int dw = QApplication::desktop()->width(); 2159 int dw = QApplication::desktop()->width();
2158 int dh = QApplication::desktop()->height(); 2160 int dh = QApplication::desktop()->height();
2159 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2161 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2160 bar.show(); 2162 bar.show();
2161 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 2163 bar.setCaption (i18n("inserting birthdays - close to abort!") );
2162 qApp->processEvents(); 2164 qApp->processEvents();
2163 2165
2164 QDate birthday; 2166 QDate birthday;
2165 QDate anniversary; 2167 QDate anniversary;
2166 QString realName; 2168 QString realName;
2167 QString email; 2169 QString email;
2168 QString assembledName; 2170 QString assembledName;
2169 QString uid; 2171 QString uid;
2170 bool ok = true; 2172 bool ok = true;
2171 for ( int i = 0; i < count; i++) 2173 for ( int i = 0; i < count; i++)
2172 { 2174 {
2173 if ( ! bar.isVisible() ) 2175 if ( ! bar.isVisible() )
2174 return; 2176 return;
2175 bar.setProgress( i ); 2177 bar.setProgress( i );
2176 qApp->processEvents(); 2178 qApp->processEvents();
2177 2179
2178 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 2180 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
2179 if (!ok) { 2181 if (!ok) {
2180 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 2182 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
2181 } 2183 }
2182 2184
2183 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 2185 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
2184 if (!ok) { 2186 if (!ok) {
2185 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 2187 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
2186 } 2188 }
2187 realName = realNameList[i]; 2189 realName = realNameList[i];
2188 email = emailList[i]; 2190 email = emailList[i];
2189 assembledName = assembledNameList[i]; 2191 assembledName = assembledNameList[i];
2190 uid = uidList[i]; 2192 uid = uidList[i];
2191 //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() ); 2193 //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() );
2192 2194
2193 if ( birthday.isValid() ){ 2195 if ( birthday.isValid() ){
2194 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2196 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2195 KCal::Attendee::ReqParticipant,uid) ; 2197 KCal::Attendee::ReqParticipant,uid) ;
2196 if ( addAnniversary( birthday, assembledName, a, true ) ) 2198 if ( addAnniversary( birthday, assembledName, a, true ) )
2197 ++addCount; 2199 ++addCount;
2198 } 2200 }
2199 2201
2200 if ( anniversary.isValid() ){ 2202 if ( anniversary.isValid() ){
2201 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 2203 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
2202 KCal::Attendee::ReqParticipant,uid) ; 2204 KCal::Attendee::ReqParticipant,uid) ;
2203 if ( addAnniversary( anniversary, assembledName, a, false ) ) 2205 if ( addAnniversary( anniversary, assembledName, a, false ) )
2204 ++addCount; 2206 ++addCount;
2205 } 2207 }
2206 } 2208 }
2207 2209
2208 mCalendar->setDefaultCalendar( curCal ); 2210 mCalendar->setDefaultCalendar( curCal );
2209 updateView(); 2211 updateView();
2210 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 2212 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
2211 2213
2212 } 2214 }
2213 2215
2214} 2216}
2215 2217
2216 2218
2217 2219
2218bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 2220bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
2219{ 2221{
2220 //qDebug("addAnni "); 2222 //qDebug("addAnni ");
2221 Event * ev = new Event(); 2223 Event * ev = new Event();
2222 ev->setOrganizer(KOPrefs::instance()->email()); 2224 ev->setOrganizer(KOPrefs::instance()->email());
2223 if ( a ) { 2225 if ( a ) {
2224 ev->addAttendee( a ); 2226 ev->addAttendee( a );
2225 } 2227 }
2226 QString kind; 2228 QString kind;
2227 if ( birthday ) { 2229 if ( birthday ) {
2228 kind = i18n( "Birthday" ); 2230 kind = i18n( "Birthday" );
2229 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 2231 ev->setSummary( name + " (" + QString::number(date.year()) +")");
2230 } 2232 }
2231 else { 2233 else {
2232 kind = i18n( "Anniversary" ); 2234 kind = i18n( "Anniversary" );
2233 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 2235 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
2234 } 2236 }
2235 ev->setCategories( kind ); 2237 ev->setCategories( kind );
2236 ev->setDtStart( QDateTime(date) ); 2238 ev->setDtStart( QDateTime(date) );
2237 ev->setDtEnd( QDateTime(date) ); 2239 ev->setDtEnd( QDateTime(date) );
2238 ev->setFloats( true ); 2240 ev->setFloats( true );
2239 Recurrence * rec = ev->recurrence(); 2241 Recurrence * rec = ev->recurrence();
2240 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 2242 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
2241 rec->addYearlyNum( date.month() ); 2243 rec->addYearlyNum( date.month() );
2242 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 2244 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
2243 delete ev; 2245 delete ev;
2244 return false; 2246 return false;
2245 } 2247 }
2246 return true; 2248 return true;
2247 2249
2248} 2250}
2249bool CalendarView::importQtopia( const QString &categories, 2251bool CalendarView::importQtopia( const QString &categories,
2250 const QString &datebook, 2252 const QString &datebook,
2251 const QString &todolist ) 2253 const QString &todolist )
2252{ 2254{
2253 2255
2254 QtopiaFormat qtopiaFormat; 2256 QtopiaFormat qtopiaFormat;
2255 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2257 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2256 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 2258 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
2257 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 2259 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
2258 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 2260 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
2259 2261
2260 updateView(); 2262 updateView();
2261 return true; 2263 return true;
2262 2264
2263#if 0 2265#if 0
2264 mGlobalSyncMode = SYNC_MODE_QTOPIA; 2266 mGlobalSyncMode = SYNC_MODE_QTOPIA;
2265 mCurrentSyncDevice = "qtopia-XML"; 2267 mCurrentSyncDevice = "qtopia-XML";
2266 if ( mSyncManager->mAskForPreferences ) 2268 if ( mSyncManager->mAskForPreferences )
2267 edit_sync_options(); 2269 edit_sync_options();
2268 qApp->processEvents(); 2270 qApp->processEvents();
2269 CalendarLocal* calendar = new CalendarLocal(); 2271 CalendarLocal* calendar = new CalendarLocal();
2270 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2272 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2271 bool syncOK = false; 2273 bool syncOK = false;
2272 QtopiaFormat qtopiaFormat; 2274 QtopiaFormat qtopiaFormat;
2273 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 2275 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
2274 bool loadOk = true; 2276 bool loadOk = true;
2275 if ( !categories.isEmpty() ) 2277 if ( !categories.isEmpty() )
2276 loadOk = qtopiaFormat.load( calendar, categories ); 2278 loadOk = qtopiaFormat.load( calendar, categories );
2277 if ( loadOk && !datebook.isEmpty() ) 2279 if ( loadOk && !datebook.isEmpty() )
2278 loadOk = qtopiaFormat.load( calendar, datebook ); 2280 loadOk = qtopiaFormat.load( calendar, datebook );
2279 if ( loadOk && !todolist.isEmpty() ) 2281 if ( loadOk && !todolist.isEmpty() )
2280 loadOk = qtopiaFormat.load( calendar, todolist ); 2282 loadOk = qtopiaFormat.load( calendar, todolist );
2281 2283
2282 if ( loadOk ) { 2284 if ( loadOk ) {
2283 getEventViewerDialog()->setSyncMode( true ); 2285 getEventViewerDialog()->setSyncMode( true );
2284 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2286 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2285 getEventViewerDialog()->setSyncMode( false ); 2287 getEventViewerDialog()->setSyncMode( false );
2286 qApp->processEvents(); 2288 qApp->processEvents();
2287 if ( syncOK ) { 2289 if ( syncOK ) {
2288 if ( mSyncManager->mWriteBackFile ) 2290 if ( mSyncManager->mWriteBackFile )
2289 { 2291 {
2290 // write back XML file 2292 // write back XML file
2291 2293
2292 } 2294 }
2293 setModified( true ); 2295 setModified( true );
2294 } 2296 }
2295 } else { 2297 } else {
2296 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2298 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2297 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2299 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2298 question, i18n("Ok")) ; 2300 question, i18n("Ok")) ;
2299 } 2301 }
2300 delete calendar; 2302 delete calendar;
2301 updateView(); 2303 updateView();
2302 return syncOK; 2304 return syncOK;
2303 2305
2304 2306
2305#endif 2307#endif
2306 2308
2307} 2309}
2308 2310
2309void CalendarView::setSyncEventsReadOnly() 2311void CalendarView::setSyncEventsReadOnly()
2310{ 2312{
2311 mCalendar->setSyncEventsReadOnly(); 2313 mCalendar->setSyncEventsReadOnly();
2312} 2314}
2313 2315
2314bool CalendarView::loadCalendars() 2316bool CalendarView::loadCalendars()
2315{ 2317{
2316 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2318 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2317 KopiCalendarFile * cal = calendars.first(); 2319 KopiCalendarFile * cal = calendars.first();
2318 mCalendar->setDefaultCalendar( 1 ); 2320 mCalendar->setDefaultCalendar( 1 );
2319 openCalendar( MainWindow::defaultFileName(), false ); 2321 openCalendar( MainWindow::defaultFileName(), false );
2320 cal = calendars.next(); 2322 cal = calendars.next();
2321 while ( cal ) { 2323 while ( cal ) {
2322 addCalendar( cal ); 2324 addCalendar( cal );
2323 cal = calendars.next(); 2325 cal = calendars.next();
2324 } 2326 }
2325 restoreCalendarSettings(); 2327 restoreCalendarSettings();
2326 return true; 2328 return true;
2327} 2329}
2328bool CalendarView::restoreCalendarSettings() 2330bool CalendarView::restoreCalendarSettings()
2329{ 2331{
2330 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2332 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2331 KopiCalendarFile * cal = calendars.first(); 2333 KopiCalendarFile * cal = calendars.first();
2332 while ( cal ) { 2334 while ( cal ) {
2333 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2335 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2334 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2336 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2335 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2337 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2336 if ( cal->isStandard ) 2338 if ( cal->isStandard )
2337 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2339 mCalendar->setDefaultCalendar( cal->mCalNumber );
2338 cal = calendars.next(); 2340 cal = calendars.next();
2339 } 2341 }
2340 setSyncEventsReadOnly(); 2342 setSyncEventsReadOnly();
2341 mCalendar->reInitAlarmSettings(); 2343 mCalendar->reInitAlarmSettings();
2342 updateUnmanagedViews(); 2344 updateUnmanagedViews();
2343 updateView(); 2345 updateView();
2344 return true; 2346 return true;
2345} 2347}
2346void CalendarView::addCalendarId( int id ) 2348void CalendarView::addCalendarId( int id )
2347{ 2349{
2348 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2350 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2349 if ( cal ) 2351 if ( cal )
2350 addCalendar( cal ); 2352 addCalendar( cal );
2351} 2353}
2352bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2354bool CalendarView::addCalendar( KopiCalendarFile * cal )
2353{ 2355{
2354 cal->mErrorOnLoad = false; 2356 cal->mErrorOnLoad = false;
2355 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 2357 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
2356 cal->mLoadDt = QDateTime::currentDateTime(); 2358 cal->mLoadDt = QDateTime::currentDateTime();
2357 return true; 2359 return true;
2358 } 2360 }
2359 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() ); 2361 qDebug("KO: Error adding calendar file %s ",cal->mFileName.latin1() );
2360 cal->mErrorOnLoad = true; 2362 cal->mErrorOnLoad = true;
2361 return false; 2363 return false;
2362} 2364}
2363bool CalendarView::openCalendar(QString filename, bool merge) 2365bool CalendarView::openCalendar(QString filename, bool merge)
2364{ 2366{
2365 2367
2366 if (filename.isEmpty()) { 2368 if (filename.isEmpty()) {
2367 return false; 2369 return false;
2368 } 2370 }
2369 2371
2370 if (!QFile::exists(filename)) { 2372 if (!QFile::exists(filename)) {
2371 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 2373 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
2372 return false; 2374 return false;
2373 } 2375 }
2374 2376
2375 globalFlagBlockAgenda = 1; 2377 globalFlagBlockAgenda = 1;
2376 clearAllViews(); 2378 clearAllViews();
2377 if (!merge) { 2379 if (!merge) {
2378 mViewManager->setDocumentId( filename ); 2380 mViewManager->setDocumentId( filename );
2379 mCalendar->close(); 2381 mCalendar->close();
2380 } 2382 }
2381 mStorage->setFileName( filename ); 2383 mStorage->setFileName( filename );
2382 2384
2383 if ( mStorage->load() ) { 2385 if ( mStorage->load() ) {
2384 if ( merge ) ;//setModified( true ); 2386 if ( merge ) ;//setModified( true );
2385 else { 2387 else {
2386 //setModified( true ); 2388 //setModified( true );
2387 mViewManager->setDocumentId( filename ); 2389 mViewManager->setDocumentId( filename );
2388 mDialogManager->setDocumentId( filename ); 2390 mDialogManager->setDocumentId( filename );
2389 mTodoList->setDocumentId( filename ); 2391 mTodoList->setDocumentId( filename );
2390 } 2392 }
2391 globalFlagBlockAgenda = 2; 2393 globalFlagBlockAgenda = 2;
2392 // if ( getLastSyncEvent() ) 2394 // if ( getLastSyncEvent() )
2393 // getLastSyncEvent()->setReadOnly( true ); 2395 // getLastSyncEvent()->setReadOnly( true );
2394 mCalendar->reInitAlarmSettings(); 2396 mCalendar->reInitAlarmSettings();
2395 setSyncEventsReadOnly(); 2397 setSyncEventsReadOnly();
2396 //updateUnmanagedViews(); 2398 //updateUnmanagedViews();
2397 //updateView(); 2399 //updateView();
2398 if ( filename != MainWindow::defaultFileName() ) { 2400 if ( filename != MainWindow::defaultFileName() ) {
2399 saveCalendar( MainWindow::defaultFileName() ); 2401 saveCalendar( MainWindow::defaultFileName() );
2400 } else { 2402 } else {
2401 QFileInfo finf ( MainWindow::defaultFileName()); 2403 QFileInfo finf ( MainWindow::defaultFileName());
2402 if ( finf.exists() ) { 2404 if ( finf.exists() ) {
2403 setLoadedFileVersion( finf.lastModified () ); 2405 setLoadedFileVersion( finf.lastModified () );
2404 } 2406 }
2405 } 2407 }
2406 return true; 2408 return true;
2407 } else { 2409 } else {
2408 // while failing to load, the calendar object could 2410 // while failing to load, the calendar object could
2409 // have become partially populated. Clear it out. 2411 // have become partially populated. Clear it out.
2410 if ( !merge ) { 2412 if ( !merge ) {
2411 mCalendar->close(); 2413 mCalendar->close();
2412 mViewManager->setDocumentId( filename ); 2414 mViewManager->setDocumentId( filename );
2413 mDialogManager->setDocumentId( filename ); 2415 mDialogManager->setDocumentId( filename );
2414 mTodoList->setDocumentId( filename ); 2416 mTodoList->setDocumentId( filename );
2415 } 2417 }
2416 2418
2417 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 2419 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
2418 2420
2419 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 2421 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
2420 globalFlagBlockAgenda = 2; 2422 globalFlagBlockAgenda = 2;
2421 mCalendar->reInitAlarmSettings(); 2423 mCalendar->reInitAlarmSettings();
2422 setSyncEventsReadOnly(); 2424 setSyncEventsReadOnly();
2423 updateUnmanagedViews(); 2425 updateUnmanagedViews();
2424 updateView(); 2426 updateView();
2425 } 2427 }
2426 return false; 2428 return false;
2427} 2429}
2428void CalendarView::mergeFile( QString fn ) 2430void CalendarView::mergeFile( QString fn )
2429{ 2431{
2430 clearAllViews(); 2432 clearAllViews();
2431 mCalendar->mergeCalendarFile( fn ); 2433 mCalendar->mergeCalendarFile( fn );
2432 mCalendar->reInitAlarmSettings(); 2434 mCalendar->reInitAlarmSettings();
2433 setSyncEventsReadOnly(); 2435 setSyncEventsReadOnly();
2434 updateUnmanagedViews(); 2436 updateUnmanagedViews();
2435 updateView(); 2437 updateView();
2436} 2438}
2437void CalendarView::showOpenError() 2439void CalendarView::showOpenError()
2438{ 2440{
2439 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 2441 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
2440} 2442}
2441void CalendarView::setLoadedFileVersion(QDateTime dt) 2443void CalendarView::setLoadedFileVersion(QDateTime dt)
2442{ 2444{
2443 loadedFileVersion = dt; 2445 loadedFileVersion = dt;
2444} 2446}
2445bool CalendarView::checkFileChanged(QString fn) 2447bool CalendarView::checkFileChanged(QString fn)
2446{ 2448{
2447 QFileInfo finf ( fn ); 2449 QFileInfo finf ( fn );
2448 if ( !finf.exists() ) 2450 if ( !finf.exists() )
2449 return true; 2451 return true;
2450 QDateTime dt = finf.lastModified (); 2452 QDateTime dt = finf.lastModified ();
2451 if ( dt <= loadedFileVersion ) 2453 if ( dt <= loadedFileVersion )
2452 return false; 2454 return false;
2453 return true; 2455 return true;
2454 2456
2455} 2457}
2456void CalendarView::watchSavedFile() 2458void CalendarView::watchSavedFile()
2457{ 2459{
2458 QFileInfo finf ( MainWindow::defaultFileName()); 2460 QFileInfo finf ( MainWindow::defaultFileName());
2459 if ( !finf.exists() ) 2461 if ( !finf.exists() )
2460 return; 2462 return;
2461 QDateTime dt = finf.lastModified (); 2463 QDateTime dt = finf.lastModified ();
2462 if ( dt < loadedFileVersion ) { 2464 if ( dt < loadedFileVersion ) {
2463 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2465 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2464 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2466 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2465 return; 2467 return;
2466 } 2468 }
2467 loadedFileVersion = dt; 2469 loadedFileVersion = dt;
2468} 2470}
2469bool CalendarView::checkAllFileVersions() 2471bool CalendarView::checkAllFileVersions()
2470{ 2472{
2471 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2473 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2472 KopiCalendarFile * cal = calendars.first(); 2474 KopiCalendarFile * cal = calendars.first();
2473 mCalendar->setDefaultCalendar( 1 ); 2475 mCalendar->setDefaultCalendar( 1 );
2474 mCalendar->setDefaultCalendarEnabledOnly(); 2476 mCalendar->setDefaultCalendarEnabledOnly();
2475 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2477 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2476 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2478 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2477 restoreCalendarSettings(); 2479 restoreCalendarSettings();
2478 return false; 2480 return false;
2479 } 2481 }
2480 } 2482 }
2481 cal = calendars.next(); 2483 cal = calendars.next();
2482 QDateTime storeTemp = loadedFileVersion; 2484 QDateTime storeTemp = loadedFileVersion;
2483 while ( cal ) { 2485 while ( cal ) {
2484 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2486 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2485 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2487 mCalendar->setDefaultCalendar( cal->mCalNumber );
2486 mCalendar->setDefaultCalendarEnabledOnly(); 2488 mCalendar->setDefaultCalendarEnabledOnly();
2487 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2489 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2488 if ( !checkFileVersion(cal->mFileName )) { 2490 if ( !checkFileVersion(cal->mFileName )) {
2489 loadedFileVersion = storeTemp; 2491 loadedFileVersion = storeTemp;
2490 restoreCalendarSettings(); 2492 restoreCalendarSettings();
2491 return false; 2493 return false;
2492 } 2494 }
2493 } 2495 }
2494 cal = calendars.next(); 2496 cal = calendars.next();
2495 } 2497 }
2496 loadedFileVersion = storeTemp; 2498 loadedFileVersion = storeTemp;
2497 return true; 2499 return true;
2498} 2500}
2499bool CalendarView::checkFileVersion(QString fn) 2501bool CalendarView::checkFileVersion(QString fn)
2500{ 2502{
2501 QFileInfo finf ( fn ); 2503 QFileInfo finf ( fn );
2502 if ( !finf.exists() ) 2504 if ( !finf.exists() )
2503 return true; 2505 return true;
2504 QDateTime dt = finf.lastModified (); 2506 QDateTime dt = finf.lastModified ();
2505 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2507 //qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2506 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2508 //qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2507 if ( dt <= loadedFileVersion ) 2509 if ( dt <= loadedFileVersion )
2508 return true; 2510 return true;
2509 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2511 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2510 i18n("KO/Pi Warning"),i18n("Overwrite"), 2512 i18n("KO/Pi Warning"),i18n("Overwrite"),
2511 i18n("Sync+save")); 2513 i18n("Sync+save"));
2512 2514
2513 if ( km == KMessageBox::Cancel ) 2515 if ( km == KMessageBox::Cancel )
2514 return false; 2516 return false;
2515 if ( km == KMessageBox::Yes ) 2517 if ( km == KMessageBox::Yes )
2516 return true; 2518 return true;
2517 2519
2518 setSyncDevice("deleteaftersync" ); 2520 setSyncDevice("deleteaftersync" );
2519 mSyncManager->mAskForPreferences = true; 2521 mSyncManager->mAskForPreferences = true;
2520 mSyncManager->mSyncAlgoPrefs = 3; 2522 mSyncManager->mSyncAlgoPrefs = 3;
2521 mSyncManager->mWriteBackFile = false; 2523 mSyncManager->mWriteBackFile = false;
2522 mSyncManager->mWriteBackExistingOnly = false; 2524 mSyncManager->mWriteBackExistingOnly = false;
2523 mSyncManager->mShowSyncSummary = false; 2525 mSyncManager->mShowSyncSummary = false;
2524 syncCalendar( fn, 3 ); 2526 syncCalendar( fn, 3 );
2525 Event * e = getLastSyncEvent(); 2527 Event * e = getLastSyncEvent();
2526 if ( e ) 2528 if ( e )
2527 mCalendar->deleteEvent( e ); 2529 mCalendar->deleteEvent( e );
2528 return true; 2530 return true;
2529} 2531}
2530bool CalendarView::saveCalendars() 2532bool CalendarView::saveCalendars()
2531{ 2533{
2532 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2534 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2533 KopiCalendarFile * cal = calendars.first(); 2535 KopiCalendarFile * cal = calendars.first();
2534 mCalendar->setDefaultCalendar( 1 ); 2536 mCalendar->setDefaultCalendar( 1 );
2535 mCalendar->setDefaultCalendarEnabledOnly(); 2537 mCalendar->setDefaultCalendarEnabledOnly();
2536 QString saveError; 2538 QString saveError;
2537 if ( !saveCalendar( MainWindow::defaultFileName() ) ) 2539 if ( !saveCalendar( MainWindow::defaultFileName() ) )
2538 saveError = cal->mName +"\n"; 2540 saveError = cal->mName +"\n";
2539 cal = calendars.next(); 2541 cal = calendars.next();
2540 while ( cal ) { 2542 while ( cal ) {
2541 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2543 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2542 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2544 mCalendar->setDefaultCalendar( cal->mCalNumber );
2543 mCalendar->setDefaultCalendarEnabledOnly(); 2545 mCalendar->setDefaultCalendarEnabledOnly();
2544 if ( saveCalendar( cal->mFileName ) ) 2546 if ( saveCalendar( cal->mFileName ) )
2545 cal->mLoadDt = QDateTime::currentDateTime(); 2547 cal->mLoadDt = QDateTime::currentDateTime();
2546 else 2548 else
2547 saveError += cal->mName + "\n"; 2549 saveError += cal->mName + "\n";
2548 } 2550 }
2549 cal = calendars.next(); 2551 cal = calendars.next();
2550 } 2552 }
2551 restoreCalendarSettings(); 2553 restoreCalendarSettings();
2552 //saveError = "test error"; 2554 //saveError = "test error";
2553 if ( !saveError.isEmpty() ) { 2555 if ( !saveError.isEmpty() ) {
2554 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; 2556 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
2555 KMessageBox::error(this, saveError, i18n("Error saving data")); 2557 KMessageBox::error(this, saveError, i18n("Error saving data"));
2556 return false; 2558 return false;
2557 } 2559 }
2558 return true; 2560 return true;
2559} 2561}
2560bool CalendarView::saveCalendar( QString filename ) 2562bool CalendarView::saveCalendar( QString filename )
2561{ 2563{
2562 2564
2563 // Store back all unsaved data into calendar object 2565 // Store back all unsaved data into calendar object
2564 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2566 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2565 if ( mViewManager->currentView() ) 2567 if ( mViewManager->currentView() )
2566 mViewManager->currentView()->flushView(); 2568 mViewManager->currentView()->flushView();
2567 2569
2568 2570
2569 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2571 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2570 mStorage->setSaveFormat( new ICalFormat() ); 2572 mStorage->setSaveFormat( new ICalFormat() );
2571 mStorage->setFileName( filename ); 2573 mStorage->setFileName( filename );
2572 bool success; 2574 bool success;
2573 success = mStorage->save(); 2575 success = mStorage->save();
2574 if ( !success ) { 2576 if ( !success ) {
2575 return false; 2577 return false;
2576 } 2578 }
2577 if ( filename == MainWindow::defaultFileName() ) { 2579 if ( filename == MainWindow::defaultFileName() ) {
2578 setLoadedFileVersion( lfv ); 2580 setLoadedFileVersion( lfv );
2579 watchSavedFile(); 2581 watchSavedFile();
2580 } 2582 }
2581 return true; 2583 return true;
2582} 2584}
2583 2585
2584void CalendarView::closeCalendar() 2586void CalendarView::closeCalendar()
2585{ 2587{
2586 2588
2587 // child windows no longer valid 2589 // child windows no longer valid
2588 clearAllViews(); 2590 clearAllViews();
2589 emit closingDown(); 2591 emit closingDown();
2590 2592
2591 mCalendar->close(); 2593 mCalendar->close();
2592 setModified(false); 2594 setModified(false);
2593 updateView(); 2595 updateView();
2594} 2596}
2595 2597
2596void CalendarView::archiveCalendar() 2598void CalendarView::archiveCalendar()
2597{ 2599{
2598 mDialogManager->showArchiveDialog(); 2600 mDialogManager->showArchiveDialog();
2599} 2601}
2600 2602
2601 2603
2602void CalendarView::readSettings() 2604void CalendarView::readSettings()
2603{ 2605{
2604 2606
2605 2607
2606 // mViewManager->showAgendaView(); 2608 // mViewManager->showAgendaView();
2607 QString str; 2609 QString str;
2608 //qDebug("CalendarView::readSettings() "); 2610 //qDebug("CalendarView::readSettings() ");
2609 // read settings from the KConfig, supplying reasonable 2611 // read settings from the KConfig, supplying reasonable
2610 // defaults where none are to be found 2612 // defaults where none are to be found
2611 KConfig *config = KOGlobals::config(); 2613 KConfig *config = KOGlobals::config();
2612#ifndef KORG_NOSPLITTER 2614#ifndef KORG_NOSPLITTER
2613 config->setGroup("KOrganizer Geometry"); 2615 config->setGroup("KOrganizer Geometry");
2614 2616
2615 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2617 QValueList<int> sizes = config->readIntListEntry("Separator1");
2616 if (sizes.count() != 2) { 2618 if (sizes.count() != 2) {
2617 sizes << mDateNavigator->minimumSizeHint().width(); 2619 sizes << mDateNavigator->minimumSizeHint().width();
2618 sizes << 300; 2620 sizes << 300;
2619 } 2621 }
2620 mPanner->setSizes(sizes); 2622 mPanner->setSizes(sizes);
2621 2623
2622 sizes = config->readIntListEntry("Separator2"); 2624 sizes = config->readIntListEntry("Separator2");
2623 if ( ( mResourceView && sizes.count() == 4 ) || 2625 if ( ( mResourceView && sizes.count() == 4 ) ||
2624 ( !mResourceView && sizes.count() == 3 ) ) { 2626 ( !mResourceView && sizes.count() == 3 ) ) {
2625 mLeftSplitter->setSizes(sizes); 2627 mLeftSplitter->setSizes(sizes);
2626 } 2628 }
2627#endif 2629#endif
2628 globalFlagBlockAgenda = 1; 2630 globalFlagBlockAgenda = 1;
2629 mViewManager->showAgendaView(); 2631 mViewManager->showAgendaView();
2630 //mViewManager->readSettings( config ); 2632 //mViewManager->readSettings( config );
2631 mTodoList->restoreLayout(config,QString("Todo Layout")); 2633 mTodoList->restoreLayout(config,QString("Todo Layout"));
2632 readFilterSettings(config); 2634 readFilterSettings(config);
2633 2635
2634#ifdef DESKTOP_VERSION 2636#ifdef DESKTOP_VERSION
2635 config->setGroup("WidgetLayout"); 2637 config->setGroup("WidgetLayout");
2636 QStringList list; 2638 QStringList list;
2637 list = config->readListEntry("MainLayout"); 2639 list = config->readListEntry("MainLayout");
2638 int x,y,w,h; 2640 int x,y,w,h;
2639 if ( ! list.isEmpty() ) { 2641 if ( ! list.isEmpty() ) {
2640 x = list[0].toInt(); 2642 x = list[0].toInt();
2641 y = list[1].toInt(); 2643 y = list[1].toInt();
2642 w = list[2].toInt(); 2644 w = list[2].toInt();
2643 h = list[3].toInt(); 2645 h = list[3].toInt();
2644 KApplication::testCoords( &x,&y,&w,&h ); 2646 KApplication::testCoords( &x,&y,&w,&h );
2645 topLevelWidget()->setGeometry(x,y,w,h); 2647 topLevelWidget()->setGeometry(x,y,w,h);
2646 2648
2647 } else { 2649 } else {
2648 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2650 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2649 } 2651 }
2650 list = config->readListEntry("EditEventLayout"); 2652 list = config->readListEntry("EditEventLayout");
2651 if ( ! list.isEmpty() ) { 2653 if ( ! list.isEmpty() ) {
2652 x = list[0].toInt(); 2654 x = list[0].toInt();
2653 y = list[1].toInt(); 2655 y = list[1].toInt();
2654 w = list[2].toInt(); 2656 w = list[2].toInt();
2655 h = list[3].toInt(); 2657 h = list[3].toInt();
2656 KApplication::testCoords( &x,&y,&w,&h ); 2658 KApplication::testCoords( &x,&y,&w,&h );
2657 mEventEditor->setGeometry(x,y,w,h); 2659 mEventEditor->setGeometry(x,y,w,h);
2658 2660
2659 } 2661 }
2660 list = config->readListEntry("EditTodoLayout"); 2662 list = config->readListEntry("EditTodoLayout");
2661 if ( ! list.isEmpty() ) { 2663 if ( ! list.isEmpty() ) {
2662 x = list[0].toInt(); 2664 x = list[0].toInt();
2663 y = list[1].toInt(); 2665 y = list[1].toInt();
2664 w = list[2].toInt(); 2666 w = list[2].toInt();
2665 h = list[3].toInt(); 2667 h = list[3].toInt();
2666 KApplication::testCoords( &x,&y,&w,&h ); 2668 KApplication::testCoords( &x,&y,&w,&h );
2667 mTodoEditor->setGeometry(x,y,w,h); 2669 mTodoEditor->setGeometry(x,y,w,h);
2668 2670
2669 } 2671 }
2670 list = config->readListEntry("ViewerLayout"); 2672 list = config->readListEntry("ViewerLayout");
2671 if ( ! list.isEmpty() ) { 2673 if ( ! list.isEmpty() ) {
2672 x = list[0].toInt(); 2674 x = list[0].toInt();
2673 y = list[1].toInt(); 2675 y = list[1].toInt();
2674 w = list[2].toInt(); 2676 w = list[2].toInt();
2675 h = list[3].toInt(); 2677 h = list[3].toInt();
2676 KApplication::testCoords( &x,&y,&w,&h ); 2678 KApplication::testCoords( &x,&y,&w,&h );
2677 getEventViewerDialog()->setGeometry(x,y,w,h); 2679 getEventViewerDialog()->setGeometry(x,y,w,h);
2678 } 2680 }
2679#endif 2681#endif
2680 config->setGroup( "Views" ); 2682 config->setGroup( "Views" );
2681 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2683 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2682 2684
2683 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2685 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2684 2686
2685 int resetval = 0; 2687 int resetval = 0;
2686 int maxVal = 0; 2688 int maxVal = 0;
2687 if (sizes.count() != 3) { 2689 if (sizes.count() != 3) {
2688 if ( KOPrefs::instance()->mVerticalScreen ) { 2690 if ( KOPrefs::instance()->mVerticalScreen ) {
2689 resetval = mDateNavigator->sizeHint().width()+2; 2691 resetval = mDateNavigator->sizeHint().width()+2;
2690 } else { 2692 } else {
2691 resetval = mDateNavigator->sizeHint().height()+2; 2693 resetval = mDateNavigator->sizeHint().height()+2;
2692 } 2694 }
2693 } 2695 }
2694 if ( resetval ) { 2696 if ( resetval ) {
2695 sizes.clear(); 2697 sizes.clear();
2696 if ( KOPrefs::instance()->mVerticalScreen ) { 2698 if ( KOPrefs::instance()->mVerticalScreen ) {
2697 maxVal = QApplication::desktop()->width() -10; 2699 maxVal = QApplication::desktop()->width() -10;
2698 } else { 2700 } else {
2699 maxVal = QApplication::desktop()->height()-10; 2701 maxVal = QApplication::desktop()->height()-10;
2700 } 2702 }
2701 sizes << resetval; 2703 sizes << resetval;
2702 if ( maxVal < resetval + resetval) 2704 if ( maxVal < resetval + resetval)
2703 resetval = maxVal - resetval; 2705 resetval = maxVal - resetval;
2704 sizes << resetval; 2706 sizes << resetval;
2705 sizes << 100; 2707 sizes << 100;
2706 } 2708 }
2707 mLeftFrame->setSizes(sizes); 2709 mLeftFrame->setSizes(sizes);
2708 sizes = config->readIntListEntry("Main Splitter Frame"); 2710 sizes = config->readIntListEntry("Main Splitter Frame");
2709 resetval = 0; 2711 resetval = 0;
2710 maxVal = 0; 2712 maxVal = 0;
2711 if (sizes.count() != 2) { 2713 if (sizes.count() != 2) {
2712 if ( !KOPrefs::instance()->mVerticalScreen ) { 2714 if ( !KOPrefs::instance()->mVerticalScreen ) {
2713 resetval = mDateNavigator->sizeHint().width()+2; 2715 resetval = mDateNavigator->sizeHint().width()+2;
2714 } else { 2716 } else {
2715 resetval = mDateNavigator->sizeHint().height()+2; 2717 resetval = mDateNavigator->sizeHint().height()+2;
2716 } 2718 }
2717 } 2719 }
2718 if ( resetval ) { 2720 if ( resetval ) {
2719 sizes.clear(); 2721 sizes.clear();
2720 if ( !KOPrefs::instance()->mVerticalScreen ) { 2722 if ( !KOPrefs::instance()->mVerticalScreen ) {
2721 maxVal = QApplication::desktop()->width() -10; 2723 maxVal = QApplication::desktop()->width() -10;
2722 } else { 2724 } else {
2723 maxVal = QApplication::desktop()->height()-10; 2725 maxVal = QApplication::desktop()->height()-10;
2724 } 2726 }
2725 sizes << resetval; 2727 sizes << resetval;
2726 if ( maxVal < resetval + resetval) 2728 if ( maxVal < resetval + resetval)
2727 resetval = maxVal - resetval; 2729 resetval = maxVal - resetval;
2728 sizes << resetval; 2730 sizes << resetval;
2729 } 2731 }
2730 mMainFrame->setSizes(sizes); 2732 mMainFrame->setSizes(sizes);
2731 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2733 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2732 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2734 else if ( dateCount == 7 ) mNavigator->selectWeek();
2733 else mNavigator->selectDates( dateCount ); 2735 else mNavigator->selectDates( dateCount );
2734 // mViewManager->readSettings( config ); 2736 // mViewManager->readSettings( config );
2735 updateConfig(); 2737 updateConfig();
2736 globalFlagBlockAgenda = 2; 2738 globalFlagBlockAgenda = 2;
2737 mViewManager->readSettings( config ); 2739 mViewManager->readSettings( config );
2738 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2740 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2739} 2741}
2740 2742
2741void CalendarView::checkSuspendAlarm() 2743void CalendarView::checkSuspendAlarm()
2742{ 2744{
2743 if ( mSuspendTimer->isActive() ) { 2745 if ( mSuspendTimer->isActive() ) {
2744 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2746 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2745 } 2747 }
2746} 2748}
2747void CalendarView::writeSettings() 2749void CalendarView::writeSettings()
2748{ 2750{
2749 // kdDebug() << "CalendarView::writeSettings" << endl; 2751 // kdDebug() << "CalendarView::writeSettings" << endl;
2750 2752
2751 KConfig *config = KOGlobals::config(); 2753 KConfig *config = KOGlobals::config();
2752 2754
2753 mViewManager->writeSettings( config ); 2755 mViewManager->writeSettings( config );
2754 mTodoList->saveLayout(config,QString("Todo Layout")); 2756 mTodoList->saveLayout(config,QString("Todo Layout"));
2755 mDialogManager->writeSettings( config ); 2757 mDialogManager->writeSettings( config );
2756 //KOPrefs::instance()->usrWriteConfig(); 2758 //KOPrefs::instance()->usrWriteConfig();
2757 KOPrefs::instance()->writeConfig(); 2759 KOPrefs::instance()->writeConfig();
2758 2760
2759 writeFilterSettings(config); 2761 writeFilterSettings(config);
2760 config->setGroup( "AppRun" ); 2762 config->setGroup( "AppRun" );
2761 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2763 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2762 int days = dt.daysTo( QDate::currentDate() ); 2764 int days = dt.daysTo( QDate::currentDate() );
2763 dt = dt.addDays( days ); 2765 dt = dt.addDays( days );
2764 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2766 int secs = dt.secsTo( QDateTime::currentDateTime() );
2765 config->writeEntry( "LatestProgramStopDays", days ); 2767 config->writeEntry( "LatestProgramStopDays", days );
2766 config->writeEntry( "LatestProgramStopSecs", secs ); 2768 config->writeEntry( "LatestProgramStopSecs", secs );
2767 //qDebug("KO: Writing stop time: %d ", secs); 2769 //qDebug("KO: Writing stop time: %d ", secs);
2768 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2770 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2769 //QDateTime latest = dt.addSecs ( secs ); 2771 //QDateTime latest = dt.addSecs ( secs );
2770 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2772 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2771 config->setGroup( "Views" ); 2773 config->setGroup( "Views" );
2772 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2774 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2773 2775
2774#if 0 2776#if 0
2775 qDebug("********************* "); 2777 qDebug("********************* ");
2776 qDebug("Testcode secsto "); 2778 qDebug("Testcode secsto ");
2777 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2779 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2778 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2780 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2779 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2781 int secsto = dt_nodaylight.secsTo( dt_daylight );
2780 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2782 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2781 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2783 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2782 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2784 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2783 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2785 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2784 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2786 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2785 qDebug("********************* testcode end"); 2787 qDebug("********************* testcode end");
2786 2788
2787#endif 2789#endif
2788 2790
2789 QValueList<int> listINT = mLeftFrame->sizes(); 2791 QValueList<int> listINT = mLeftFrame->sizes();
2790 config->writeEntry("Left Splitter Frame",listINT); 2792 config->writeEntry("Left Splitter Frame",listINT);
2791 QValueList<int> listINT2 = mMainFrame->sizes(); 2793 QValueList<int> listINT2 = mMainFrame->sizes();
2792 config->writeEntry("Main Splitter Frame",listINT2); 2794 config->writeEntry("Main Splitter Frame",listINT2);
2793#ifdef DESKTOP_VERSION 2795#ifdef DESKTOP_VERSION
2794 config->setGroup("WidgetLayout"); 2796 config->setGroup("WidgetLayout");
2795 QStringList list ;//= config->readListEntry("MainLayout"); 2797 QStringList list ;//= config->readListEntry("MainLayout");
2796 int x,y,w,h; 2798 int x,y,w,h;
2797 QWidget* wid; 2799 QWidget* wid;
2798 wid = topLevelWidget(); 2800 wid = topLevelWidget();
2799 x = wid->geometry().x(); 2801 x = wid->geometry().x();
2800 y = wid->geometry().y(); 2802 y = wid->geometry().y();
2801 w = wid->width(); 2803 w = wid->width();
2802 h = wid->height(); 2804 h = wid->height();
2803 list.clear(); 2805 list.clear();
2804 list << QString::number( x ); 2806 list << QString::number( x );
2805 list << QString::number( y ); 2807 list << QString::number( y );
2806 list << QString::number( w ); 2808 list << QString::number( w );
2807 list << QString::number( h ); 2809 list << QString::number( h );
2808 config->writeEntry("MainLayout",list ); 2810 config->writeEntry("MainLayout",list );
2809 2811
2810 wid = mEventEditor; 2812 wid = mEventEditor;
2811 x = wid->geometry().x(); 2813 x = wid->geometry().x();
2812 y = wid->geometry().y(); 2814 y = wid->geometry().y();
2813 w = wid->width(); 2815 w = wid->width();
2814 h = wid->height(); 2816 h = wid->height();
2815 list.clear(); 2817 list.clear();
2816 list << QString::number( x ); 2818 list << QString::number( x );
2817 list << QString::number( y ); 2819 list << QString::number( y );
2818 list << QString::number( w ); 2820 list << QString::number( w );
2819 list << QString::number( h ); 2821 list << QString::number( h );
2820 config->writeEntry("EditEventLayout",list ); 2822 config->writeEntry("EditEventLayout",list );
2821 2823
2822 wid = mTodoEditor; 2824 wid = mTodoEditor;
2823 x = wid->geometry().x(); 2825 x = wid->geometry().x();
2824 y = wid->geometry().y(); 2826 y = wid->geometry().y();
2825 w = wid->width(); 2827 w = wid->width();
2826 h = wid->height(); 2828 h = wid->height();
2827 list.clear(); 2829 list.clear();
2828 list << QString::number( x ); 2830 list << QString::number( x );
2829 list << QString::number( y ); 2831 list << QString::number( y );
2830 list << QString::number( w ); 2832 list << QString::number( w );
2831 list << QString::number( h ); 2833 list << QString::number( h );
2832 config->writeEntry("EditTodoLayout",list ); 2834 config->writeEntry("EditTodoLayout",list );
2833 wid = getEventViewerDialog(); 2835 wid = getEventViewerDialog();
2834 x = wid->geometry().x(); 2836 x = wid->geometry().x();
2835 y = wid->geometry().y(); 2837 y = wid->geometry().y();
2836 w = wid->width(); 2838 w = wid->width();
2837 h = wid->height(); 2839 h = wid->height();
2838 list.clear(); 2840 list.clear();
2839 list << QString::number( x ); 2841 list << QString::number( x );
2840 list << QString::number( y ); 2842 list << QString::number( y );
2841 list << QString::number( w ); 2843 list << QString::number( w );
2842 list << QString::number( h ); 2844 list << QString::number( h );
2843 config->writeEntry("ViewerLayout",list ); 2845 config->writeEntry("ViewerLayout",list );
2844 wid = mDialogManager->getSearchDialog(); 2846 wid = mDialogManager->getSearchDialog();
2845 if ( wid ) { 2847 if ( wid ) {
2846 x = wid->geometry().x(); 2848 x = wid->geometry().x();
2847 y = wid->geometry().y(); 2849 y = wid->geometry().y();
2848 w = wid->width(); 2850 w = wid->width();
2849 h = wid->height(); 2851 h = wid->height();
2850 list.clear(); 2852 list.clear();
2851 list << QString::number( x ); 2853 list << QString::number( x );
2852 list << QString::number( y ); 2854 list << QString::number( y );
2853 list << QString::number( w ); 2855 list << QString::number( w );
2854 list << QString::number( h ); 2856 list << QString::number( h );
2855 config->writeEntry("SearchLayout",list ); 2857 config->writeEntry("SearchLayout",list );
2856 } 2858 }
2857#endif 2859#endif
2858 2860
2859 2861
2860 config->sync(); 2862 config->sync();
2861} 2863}
2862 2864
2863void CalendarView::readFilterSettings(KConfig *config) 2865void CalendarView::readFilterSettings(KConfig *config)
2864{ 2866{
2865 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2867 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2866 2868
2867 mFilters.clear(); 2869 mFilters.clear();
2868 2870
2869 config->setGroup("General"); 2871 config->setGroup("General");
2870 QStringList filterList = config->readListEntry("CalendarFilters"); 2872 QStringList filterList = config->readListEntry("CalendarFilters");
2871 2873
2872 QStringList::ConstIterator it = filterList.begin(); 2874 QStringList::ConstIterator it = filterList.begin();
2873 QStringList::ConstIterator end = filterList.end(); 2875 QStringList::ConstIterator end = filterList.end();
2874 while(it != end) { 2876 while(it != end) {
2875 // kdDebug() << " filter: " << (*it) << endl; 2877 // kdDebug() << " filter: " << (*it) << endl;
2876 2878
2877 CalFilter *filter; 2879 CalFilter *filter;
2878 filter = new CalFilter(*it); 2880 filter = new CalFilter(*it);
2879 config->setGroup("Filter_" + (*it).utf8()); 2881 config->setGroup("Filter_" + (*it).utf8());
2880 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2882 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2881 filter->setCriteria(config->readNumEntry("Criteria",0)); 2883 filter->setCriteria(config->readNumEntry("Criteria",0));
2882 filter->setCategoryList(config->readListEntry("CategoryList")); 2884 filter->setCategoryList(config->readListEntry("CategoryList"));
2883 mFilters.append(filter); 2885 mFilters.append(filter);
2884 2886
2885 ++it; 2887 ++it;
2886 } 2888 }
2887 2889
2888 if (mFilters.count() == 0) { 2890 if (mFilters.count() == 0) {
2889 CalFilter *filter = new CalFilter(i18n("Default")); 2891 CalFilter *filter = new CalFilter(i18n("Default"));
2890 mFilters.append(filter); 2892 mFilters.append(filter);
2891 } 2893 }
2892 mFilterView->updateFilters(); 2894 mFilterView->updateFilters();
2893 config->setGroup("FilterView"); 2895 config->setGroup("FilterView");
2894 2896
2895 mFilterView->blockSignals(true); 2897 mFilterView->blockSignals(true);
2896 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2898 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2897 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2899 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2898 mFilterView->blockSignals(false); 2900 mFilterView->blockSignals(false);
2899 // We do it manually to avoid it being done twice by the above calls 2901 // We do it manually to avoid it being done twice by the above calls
2900 updateFilter(); 2902 updateFilter();
2901} 2903}
2902 2904
2903void CalendarView::writeFilterSettings(KConfig *config) 2905void CalendarView::writeFilterSettings(KConfig *config)
2904{ 2906{
2905 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2907 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2906 2908
2907 QStringList filterList; 2909 QStringList filterList;
2908 2910
2909 CalFilter *filter = mFilters.first(); 2911 CalFilter *filter = mFilters.first();
2910 while(filter) { 2912 while(filter) {
2911 // kdDebug() << " fn: " << filter->name() << endl; 2913 // kdDebug() << " fn: " << filter->name() << endl;
2912 filterList << filter->name(); 2914 filterList << filter->name();
2913 config->setGroup("Filter_" + filter->name().utf8()); 2915 config->setGroup("Filter_" + filter->name().utf8());
2914 config->writeEntry("Criteria",filter->criteria()); 2916 config->writeEntry("Criteria",filter->criteria());
2915 config->writeEntry("CategoryList",filter->categoryList()); 2917 config->writeEntry("CategoryList",filter->categoryList());
2916 filter = mFilters.next(); 2918 filter = mFilters.next();
2917 } 2919 }
2918 config->setGroup("General"); 2920 config->setGroup("General");
2919 config->writeEntry("CalendarFilters",filterList); 2921 config->writeEntry("CalendarFilters",filterList);
2920 2922
2921 config->setGroup("FilterView"); 2923 config->setGroup("FilterView");
2922 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2924 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2923 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2925 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2924} 2926}
2925 2927
2926 2928
2927void CalendarView::goToday() 2929void CalendarView::goToday()
2928{ 2930{
2929 if ( mViewManager->currentView()->isMonthView() ) 2931 if ( mViewManager->currentView()->isMonthView() )
2930 mNavigator->selectTodayMonth(); 2932 mNavigator->selectTodayMonth();
2931 else 2933 else
2932 mNavigator->selectToday(); 2934 mNavigator->selectToday();
2933} 2935}
2934 2936
2935void CalendarView::goNext() 2937void CalendarView::goNext()
2936{ 2938{
2937 mNavigator->selectNext(); 2939 mNavigator->selectNext();
2938} 2940}
2939 2941
2940void CalendarView::goPrevious() 2942void CalendarView::goPrevious()
2941{ 2943{
2942 mNavigator->selectPrevious(); 2944 mNavigator->selectPrevious();
2943} 2945}
2944void CalendarView::goNextMonth() 2946void CalendarView::goNextMonth()
2945{ 2947{
2946 mNavigator->selectNextMonth(); 2948 mNavigator->selectNextMonth();
2947} 2949}
2948 2950
2949void CalendarView::goPreviousMonth() 2951void CalendarView::goPreviousMonth()
2950{ 2952{
2951 mNavigator->selectPreviousMonth(); 2953 mNavigator->selectPreviousMonth();
2952} 2954}
2953 2955
2954void CalendarView::updateConfig() 2956void CalendarView::updateConfig()
2955{ 2957{
2956 if ( KOPrefs::instance()->mUseAppColors ) 2958 if ( KOPrefs::instance()->mUseAppColors )
2957 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2959 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2958 emit configChanged(); 2960 emit configChanged();
2959 mTodoList->updateConfig(); 2961 mTodoList->updateConfig();
2960 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2962 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2961 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2963 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2962 // To make the "fill window" configurations work 2964 // To make the "fill window" configurations work
2963 //mViewManager->raiseCurrentView(); 2965 //mViewManager->raiseCurrentView();
2964} 2966}
2965 2967
2966 2968
2967void CalendarView::eventChanged(Event *event) 2969void CalendarView::eventChanged(Event *event)
2968{ 2970{
2969 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2971 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2970 //updateUnmanagedViews(); 2972 //updateUnmanagedViews();
2971} 2973}
2972 2974
2973void CalendarView::eventAdded(Event *event) 2975void CalendarView::eventAdded(Event *event)
2974{ 2976{
2975 changeEventDisplay(event,KOGlobals::EVENTADDED); 2977 changeEventDisplay(event,KOGlobals::EVENTADDED);
2976} 2978}
2977 2979
2978void CalendarView::eventToBeDeleted(Event *) 2980void CalendarView::eventToBeDeleted(Event *)
2979{ 2981{
2980 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2982 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2981} 2983}
2982 2984
2983void CalendarView::eventDeleted() 2985void CalendarView::eventDeleted()
2984{ 2986{
2985 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2987 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2986} 2988}
2987void CalendarView::changeTodoDisplay(Todo *which, int action) 2989void CalendarView::changeTodoDisplay(Todo *which, int action)
2988{ 2990{
2989 changeIncidenceDisplay((Incidence *)which, action); 2991 changeIncidenceDisplay((Incidence *)which, action);
2990 mDateNavigator->updateView(); //LR 2992 mDateNavigator->updateView(); //LR
2991 //mDialogManager->updateSearchDialog(); 2993 //mDialogManager->updateSearchDialog();
2992 2994
2993 if (which) { 2995 if (which) {
2994 mViewManager->updateWNview(); 2996 mViewManager->updateWNview();
2995 //mTodoList->updateView(); 2997 //mTodoList->updateView();
2996 } 2998 }
2997 2999
2998} 3000}
2999 3001
3000void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 3002void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
3001{ 3003{
3002 updateUnmanagedViews(); 3004 updateUnmanagedViews();
3003 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 3005 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
3004 if ( action == KOGlobals::EVENTDELETED ) { //delete 3006 if ( action == KOGlobals::EVENTDELETED ) { //delete
3005 mCalendar->checkAlarmForIncidence( 0, true ); 3007 mCalendar->checkAlarmForIncidence( 0, true );
3006 if ( mEventViewerDialog ) 3008 if ( mEventViewerDialog )
3007 mEventViewerDialog->hide(); 3009 mEventViewerDialog->hide();
3008 } 3010 }
3009 else 3011 else
3010 mCalendar->checkAlarmForIncidence( which , false ); 3012 mCalendar->checkAlarmForIncidence( which , false );
3011} 3013}
3012 3014
3013// most of the changeEventDisplays() right now just call the view's 3015// most of the changeEventDisplays() right now just call the view's
3014// total update mode, but they SHOULD be recoded to be more refresh-efficient. 3016// total update mode, but they SHOULD be recoded to be more refresh-efficient.
3015void CalendarView::changeEventDisplay(Event *which, int action) 3017void CalendarView::changeEventDisplay(Event *which, int action)
3016{ 3018{
3017 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 3019 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
3018 changeIncidenceDisplay((Incidence *)which, action); 3020 changeIncidenceDisplay((Incidence *)which, action);
3019 static bool clearallviews = false;
3020 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 3021 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
3021 if ( clearallviews ) { 3022 if ( flag_clearallviewsEventDisplay ) {
3022 clearAllViews(); 3023 clearAllViews();
3023 clearallviews = false; 3024 flag_clearallviewsEventDisplay = false;
3024 } 3025 }
3025 return; 3026 return;
3026 } 3027 }
3027 clearallviews = true; 3028 flag_clearallviewsEventDisplay = true;
3028 mDateNavigator->updateView(); 3029 mDateNavigator->updateView();
3029 //mDialogManager->updateSearchDialog(); 3030 //mDialogManager->updateSearchDialog();
3030 if (which) { 3031 if (which) {
3031 // If there is an event view visible update the display 3032 // If there is an event view visible update the display
3032 mViewManager->currentView()->changeEventDisplay(which,action); 3033 mViewManager->currentView()->changeEventDisplay(which,action);
3033 // TODO: check, if update needed 3034 // TODO: check, if update needed
3034 // if (which->getTodoStatus()) { 3035 // if (which->getTodoStatus()) {
3035 mTodoList->updateView(); 3036 mTodoList->updateView();
3036 if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) { 3037 if ( action != KOGlobals::EVENTDELETED && KOPrefs::instance()->mDetectConflicts ) {
3037 mConflictingEvent = which ; 3038 mConflictingEvent = which ;
3038 int time = 1000; 3039 int time = 1000;
3039#ifdef DESKTOP_VERSION 3040#ifdef DESKTOP_VERSION
3040 time = 500; 3041 time = 500;
3041#endif 3042#endif
3042 bool checkC = false; 3043 bool checkC = false;
3043 if ( mConflictingEvent->doesFloat() ) { 3044 if ( mConflictingEvent->doesFloat() ) {
3044 checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay 3045 checkC = KOPrefs::instance()->mCheckConflictsAllDayAllDay
3045 || KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3046 || KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3046 } else { 3047 } else {
3047 checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay 3048 checkC = KOPrefs::instance()->mCheckConflictsNonADAllDay
3048 || KOPrefs::instance()->mCheckConflictsNonADNonAD; 3049 || KOPrefs::instance()->mCheckConflictsNonADNonAD;
3049 } 3050 }
3050 if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent ) 3051 if ( !KOPrefs::instance()->mIncludeFree && mConflictingEvent->transparency() == KCal::Event::Transparent )
3051 checkC = false; 3052 checkC = false;
3052 if ( checkC ) 3053 if ( checkC )
3053 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) ); 3054 QTimer::singleShot( time, this, SLOT ( checkConflictForEvent() ) );
3054 } 3055 }
3055 // } 3056 // }
3056 } else { 3057 } else {
3057 mViewManager->currentView()->updateView(); 3058 mViewManager->currentView()->updateView();
3058 } 3059 }
3059} 3060}
3060void CalendarView::checkConflictForEvent() 3061void CalendarView::checkConflictForEvent()
3061{ 3062{
3062 3063
3063 if (!KOPrefs::instance()->mConfirm) 3064 if (!KOPrefs::instance()->mConfirm)
3064 return; 3065 return;
3065 if ( ! mConflictingEvent ) return; 3066 if ( ! mConflictingEvent ) return;
3066 Event * conflictingEvent = mConflictingEvent; 3067 Event * conflictingEvent = mConflictingEvent;
3067 mConflictingEvent = 0; 3068 mConflictingEvent = 0;
3068 QDateTime current = QDateTime::currentDateTime(); 3069 QDateTime current = QDateTime::currentDateTime();
3069 if ( ! conflictingEvent->matchTime( &current, 0 ) ) { 3070 if ( ! conflictingEvent->matchTime( &current, 0 ) ) {
3070 return; 3071 return;
3071 } 3072 }
3072 CalFilter *filterIN = 0; 3073 CalFilter *filterIN = 0;
3073 CalFilter *filterALL = 0; 3074 CalFilter *filterALL = 0;
3074 CalFilter *filter = mFilters.first(); 3075 CalFilter *filter = mFilters.first();
3075 while(filter) { 3076 while(filter) {
3076 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) 3077 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem)
3077 filterIN = filter; 3078 filterIN = filter;
3078 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) 3079 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem )
3079 filterALL = filter; 3080 filterALL = filter;
3080 filter = mFilters.next(); 3081 filter = mFilters.next();
3081 } 3082 }
3082 if ( filterIN ) { 3083 if ( filterIN ) {
3083 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { 3084 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) {
3084 return; 3085 return;
3085 } 3086 }
3086 } 3087 }
3087 QPtrList<Event> testlist = mCalendar->events(); 3088 QPtrList<Event> testlist = mCalendar->events();
3088 Event * test = testlist.first(); 3089 Event * test = testlist.first();
3089 QDateTime conflict; 3090 QDateTime conflict;
3090 QDateTime retVal; 3091 QDateTime retVal;
3091 bool found = false; 3092 bool found = false;
3092 Event * cE = 0; 3093 Event * cE = 0;
3093 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; 3094 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay;
3094 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3095 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3095 if ( !conflictingEvent->doesFloat() ) { 3096 if ( !conflictingEvent->doesFloat() ) {
3096 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; 3097 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay;
3097 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; 3098 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD;
3098 } 3099 }
3099 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 3100 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
3100 while ( test ) { 3101 while ( test ) {
3101 qApp->processEvents(); 3102 qApp->processEvents();
3102 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); 3103 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad );
3103 3104
3104 if ( !skip ) { 3105 if ( !skip ) {
3105 if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) 3106 if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent )
3106 skip = true; 3107 skip = true;
3107 } 3108 }
3108 if ( !skip ) { 3109 if ( !skip ) {
3109 if ( filterALL ) { 3110 if ( filterALL ) {
3110 if ( !filterALL->filterCalendarItem( test ) ) { 3111 if ( !filterALL->filterCalendarItem( test ) ) {
3111 skip = true; 3112 skip = true;
3112 } 3113 }
3113 } 3114 }
3114 if ( !skip ) { 3115 if ( !skip ) {
3115 if ( found ) 3116 if ( found )
3116 skip = !test->matchTime( &current, &conflict ); 3117 skip = !test->matchTime( &current, &conflict );
3117 else 3118 else
3118 skip = !test->matchTime( &current, 0 ); 3119 skip = !test->matchTime( &current, 0 );
3119 if ( !skip ) { 3120 if ( !skip ) {
3120 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) { 3121 if ( conflictingEvent->isOverlapping ( test, &retVal, &current ) ) {
3121 if ( ! found ) { 3122 if ( ! found ) {
3122 conflict = retVal; 3123 conflict = retVal;
3123 cE = test; 3124 cE = test;
3124 } else { 3125 } else {
3125 if ( retVal < conflict ) { 3126 if ( retVal < conflict ) {
3126 conflict = retVal; 3127 conflict = retVal;
3127 cE = test; 3128 cE = test;
3128 } 3129 }
3129 } 3130 }
3130 found = true; 3131 found = true;
3131 } 3132 }
3132 } 3133 }
3133 } 3134 }
3134 } 3135 }
3135 test = testlist.next(); 3136 test = testlist.next();
3136 } 3137 }
3137 topLevelWidget()->setCaption( i18n("KO/Pi") ); 3138 topLevelWidget()->setCaption( i18n("KO/Pi") );
3138 if ( found ) { 3139 if ( found ) {
3139 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; 3140 QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( conflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ;
3140 qApp->processEvents(); 3141 qApp->processEvents();
3141 int km = KMessageBox::warningContinueCancel(this,mess, 3142 int km = KMessageBox::warningContinueCancel(this,mess,
3142 i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!")); 3143 i18n("KO/Pi Conflict detected"),i18n("Show date"),i18n("No problem!"));
3143 if ( km != KMessageBox::Continue ) { 3144 if ( km != KMessageBox::Continue ) {
3144 return; 3145 return;
3145 } 3146 }
3146 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 3147 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
3147 mViewManager->showDayView(); 3148 mViewManager->showDayView();
3148 mNavigator->slotDaySelect( conflict.date() ); 3149 mNavigator->slotDaySelect( conflict.date() );
3149 int hour = conflict.time().hour(); 3150 int hour = conflict.time().hour();
3150 mViewManager->agendaView()->setStartHour( hour ); 3151 mViewManager->agendaView()->setStartHour( hour );
3151 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); 3152 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( conflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) );
3152 } else 3153 } else
3153 topLevelWidget()->setCaption( i18n("No conflict found") ); 3154 topLevelWidget()->setCaption( i18n("No conflict found") );
3154 return; 3155 return;
3155 3156
3156} 3157}
3157 3158
3158void CalendarView::updateTodoViews() 3159void CalendarView::updateTodoViews()
3159{ 3160{
3160 mTodoList->updateView(); 3161 mTodoList->updateView();
3161 mViewManager->currentView()->updateView(); 3162 mViewManager->currentView()->updateView();
3162 3163
3163} 3164}
3164 3165
3165 3166
3166 3167
3167void CalendarView::clearAllViews() 3168void CalendarView::clearAllViews()
3168{ 3169{
3169 mTodoList->clearList(); 3170 mTodoList->clearList();
3170 mViewManager->clearAllViews(); 3171 mViewManager->clearAllViews();
3171 SearchDialog * sd = mDialogManager->getSearchDialog(); 3172 SearchDialog * sd = mDialogManager->getSearchDialog();
3172 if ( sd ) { 3173 if ( sd ) {
3173 KOListView* kol = sd->listview(); 3174 KOListView* kol = sd->listview();
3174 if ( kol ) 3175 if ( kol )
3175 kol->clearList(); 3176 kol->clearList();
3176 } 3177 }
3177} 3178}
3178void CalendarView::updateView() 3179void CalendarView::updateView()
3179{ 3180{
3180 static bool clearallviews = false;
3181 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 3181 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
3182 if ( clearallviews ) { 3182 if ( flag_clearallviewsupdateView ) {
3183 clearAllViews(); 3183 clearAllViews();
3184 clearallviews = false; 3184 flag_clearallviewsupdateView = false;
3185 } 3185 }
3186 return; 3186 return;
3187 } 3187 }
3188 clearallviews = true; 3188 flag_clearallviewsupdateView = true;
3189 DateList tmpList = mNavigator->selectedDates(); 3189 DateList tmpList = mNavigator->selectedDates();
3190 3190
3191 if ( KOPrefs::instance()->mHideNonStartedTodos ) 3191 if ( KOPrefs::instance()->mHideNonStartedTodos )
3192 mTodoList->updateView(); 3192 mTodoList->updateView();
3193 // We assume that the navigator only selects consecutive days. 3193 // We assume that the navigator only selects consecutive days.
3194 updateView( tmpList.first(), tmpList.last() ); 3194 updateView( tmpList.first(), tmpList.last() );
3195} 3195}
3196 3196
3197void CalendarView::updateUnmanagedViews() 3197void CalendarView::updateUnmanagedViews()
3198{ 3198{
3199 mDateNavigator->updateDayMatrix(); 3199 mDateNavigator->updateDayMatrix();
3200} 3200}
3201 3201
3202int CalendarView::msgItemDelete(const QString name) 3202int CalendarView::msgItemDelete(const QString name)
3203{ 3203{
3204 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 3204 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
3205 i18n("This item will be\npermanently deleted."), 3205 i18n("This item will be\npermanently deleted."),
3206 i18n("KO/Pi Confirmation"),i18n("Delete")); 3206 i18n("KO/Pi Confirmation"),i18n("Delete"));
3207} 3207}
3208 3208
3209 3209
3210void CalendarView::edit_cut() 3210void CalendarView::edit_cut()
3211{ 3211{
3212 Event *anEvent=0; 3212 Event *anEvent=0;
3213 3213
3214 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3214 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3215 3215
3216 if (mViewManager->currentView()->isEventView()) { 3216 if (mViewManager->currentView()->isEventView()) {
3217 if ( incidence && incidence->typeID() == eventID ) { 3217 if ( incidence && incidence->typeID() == eventID ) {
3218 anEvent = static_cast<Event *>(incidence); 3218 anEvent = static_cast<Event *>(incidence);
3219 } 3219 }
3220 } 3220 }
3221 3221
3222 if (!anEvent) { 3222 if (!anEvent) {
3223 KNotifyClient::beep(); 3223 KNotifyClient::beep();
3224 return; 3224 return;
3225 } 3225 }
3226 DndFactory factory( mCalendar ); 3226 DndFactory factory( mCalendar );
3227 factory.cutIncidence(anEvent); 3227 factory.cutIncidence(anEvent);
3228 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3228 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3229} 3229}
3230 3230
3231void CalendarView::edit_copy() 3231void CalendarView::edit_copy()
3232{ 3232{
3233 Event *anEvent=0; 3233 Event *anEvent=0;
3234 3234
3235 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3235 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3236 3236
3237 if (mViewManager->currentView()->isEventView()) { 3237 if (mViewManager->currentView()->isEventView()) {
3238 if ( incidence && incidence->typeID() == eventID ) { 3238 if ( incidence && incidence->typeID() == eventID ) {
3239 anEvent = static_cast<Event *>(incidence); 3239 anEvent = static_cast<Event *>(incidence);
3240 } 3240 }
3241 } 3241 }
3242 3242
3243 if (!anEvent) { 3243 if (!anEvent) {
3244 KNotifyClient::beep(); 3244 KNotifyClient::beep();
3245 return; 3245 return;
3246 } 3246 }
3247 DndFactory factory( mCalendar ); 3247 DndFactory factory( mCalendar );
3248 factory.copyIncidence(anEvent); 3248 factory.copyIncidence(anEvent);
3249} 3249}
3250 3250
3251void CalendarView::edit_paste() 3251void CalendarView::edit_paste()
3252{ 3252{
3253 QDate date = mNavigator->selectedDates().first(); 3253 QDate date = mNavigator->selectedDates().first();
3254 3254
3255 DndFactory factory( mCalendar ); 3255 DndFactory factory( mCalendar );
3256 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 3256 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
3257 3257
3258 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 3258 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
3259} 3259}
3260void CalendarView::edit_global_options() 3260void CalendarView::edit_global_options()
3261{ 3261{
3262 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 3262 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
3263 emit save(); 3263 emit save();
3264 emit saveStopTimer(); 3264 emit saveStopTimer();
3265 mDialogManager->showGlobalOptionsDialog(); 3265 mDialogManager->showGlobalOptionsDialog();
3266 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 3266 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
3267 emit saveStopTimer(); 3267 emit saveStopTimer();
3268 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!"), 3268 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!"),
3269 i18n("Timezone settings"),i18n("Reload"))) { 3269 i18n("Timezone settings"),i18n("Reload"))) {
3270 qDebug("KO: TZ reload cancelled "); 3270 qDebug("KO: TZ reload cancelled ");
3271 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3271 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3272 return; 3272 return;
3273 } 3273 }
3274 qDebug("KO: Timezone change "); 3274 qDebug("KO: Timezone change ");
3275 loadCalendars(); 3275 loadCalendars();
3276 setModified(true); 3276 setModified(true);
3277 } 3277 }
3278 else 3278 else
3279 qDebug("KO: No tz change "); 3279 qDebug("KO: No tz change ");
3280} 3280}
3281void CalendarView::edit_options() 3281void CalendarView::edit_options()
3282{ 3282{
3283 mDialogManager->showOptionsDialog(); 3283 mDialogManager->showOptionsDialog();
3284} 3284}
3285 3285
3286 3286
3287void CalendarView::slotSelectPickerDate( QDate d) 3287void CalendarView::slotSelectPickerDate( QDate d)
3288{ 3288{
3289 mDateFrame->hide(); 3289 mDateFrame->hide();
3290 if ( mDatePickerMode == 1 ) { 3290 if ( mDatePickerMode == 1 ) {
3291 mNavigator->slotDaySelect( d ); 3291 mNavigator->slotDaySelect( d );
3292 } else if ( mDatePickerMode == 2 ) { 3292 } else if ( mDatePickerMode == 2 ) {
3293 if ( mMoveIncidence->typeID() == todoID ) { 3293 if ( mMoveIncidence->typeID() == todoID ) {
3294 Todo * to = (Todo *) mMoveIncidence; 3294 Todo * to = (Todo *) mMoveIncidence;
3295 QTime tim; 3295 QTime tim;
3296 int len = 0; 3296 int len = 0;
3297 if ( to->hasStartDate() && to->hasDueDate() ) 3297 if ( to->hasStartDate() && to->hasDueDate() )
3298 len = to->dtStart().secsTo( to->dtDue()); 3298 len = to->dtStart().secsTo( to->dtDue());
3299 if ( to->hasDueDate() ) 3299 if ( to->hasDueDate() )
3300 tim = to->dtDue().time(); 3300 tim = to->dtDue().time();
3301 else { 3301 else {
3302 tim = QTime ( 0,0,0 ); 3302 tim = QTime ( 0,0,0 );
3303 to->setFloats( true ); 3303 to->setFloats( true );
3304 to->setHasDueDate( true ); 3304 to->setHasDueDate( true );
3305 } 3305 }
3306 QDateTime dt ( d,tim ); 3306 QDateTime dt ( d,tim );
3307 to->setDtDue( dt ); 3307 to->setDtDue( dt );
3308 3308
3309 if ( to->hasStartDate() ) { 3309 if ( to->hasStartDate() ) {
3310 if ( len>0 ) 3310 if ( len>0 )
3311 to->setDtStart(to->dtDue().addSecs( -len )); 3311 to->setDtStart(to->dtDue().addSecs( -len ));
3312 else 3312 else
3313 if (to->dtStart() > to->dtDue() ) 3313 if (to->dtStart() > to->dtDue() )
3314 to->setDtStart(to->dtDue().addDays( -3 )); 3314 to->setDtStart(to->dtDue().addDays( -3 ));
3315 } 3315 }
3316 3316
3317 todoChanged( to ); 3317 todoChanged( to );
3318 } else if ( mMoveIncidence->typeID() == eventID ) { 3318 } else if ( mMoveIncidence->typeID() == eventID ) {
3319 if ( mMoveIncidence->doesRecur() ) { 3319 if ( mMoveIncidence->doesRecur() ) {
3320#if 0 3320#if 0
3321 // PENDING implement this 3321 // PENDING implement this
3322 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 3322 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
3323 mCalendar()->addIncidence( newInc ); 3323 mCalendar()->addIncidence( newInc );
3324 if ( mMoveIncidence->typeID() == todoID ) 3324 if ( mMoveIncidence->typeID() == todoID )
3325 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 3325 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
3326 else 3326 else
3327 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 3327 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
3328 mMoveIncidence = newInc; 3328 mMoveIncidence = newInc;
3329 3329
3330#endif 3330#endif
3331 } 3331 }
3332 QTime tim = mMoveIncidence->dtStart().time(); 3332 QTime tim = mMoveIncidence->dtStart().time();
3333 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 3333 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
3334 QDateTime dt ( d,tim ); 3334 QDateTime dt ( d,tim );
3335 mMoveIncidence->setDtStart( dt ); 3335 mMoveIncidence->setDtStart( dt );
3336 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 3336 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
3337 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 3337 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
3338 } else if ( mMoveIncidence->typeID() == journalID ) { 3338 } else if ( mMoveIncidence->typeID() == journalID ) {
3339 QTime tim = mMoveIncidence->dtStart().time(); 3339 QTime tim = mMoveIncidence->dtStart().time();
3340 QDateTime dt ( d,tim ); 3340 QDateTime dt ( d,tim );
3341 mMoveIncidence->setDtStart( dt ); 3341 mMoveIncidence->setDtStart( dt );
3342 updateView(); 3342 updateView();
3343 } 3343 }
3344 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 3344 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
3345 } 3345 }
3346} 3346}
3347 3347
3348void CalendarView::removeCategories() 3348void CalendarView::removeCategories()
3349{ 3349{
3350 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3350 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3351 QStringList catList = KOPrefs::instance()->mCustomCategories; 3351 QStringList catList = KOPrefs::instance()->mCustomCategories;
3352 QStringList catIncList; 3352 QStringList catIncList;
3353 QStringList newCatList; 3353 QStringList newCatList;
3354 Incidence* inc = incList.first(); 3354 Incidence* inc = incList.first();
3355 uint i; 3355 uint i;
3356 while ( inc ) { 3356 while ( inc ) {
3357 newCatList.clear(); 3357 newCatList.clear();
3358 catIncList = inc->categories() ; 3358 catIncList = inc->categories() ;
3359 for( i = 0; i< catIncList.count(); ++i ) { 3359 for( i = 0; i< catIncList.count(); ++i ) {
3360 if ( catList.contains (catIncList[i])) 3360 if ( catList.contains (catIncList[i]))
3361 newCatList.append( catIncList[i] ); 3361 newCatList.append( catIncList[i] );
3362 } 3362 }
3363 newCatList.sort(); 3363 newCatList.sort();
3364 inc->setCategories( newCatList.join(",") ); 3364 inc->setCategories( newCatList.join(",") );
3365 inc = incList.next(); 3365 inc = incList.next();
3366 } 3366 }
3367} 3367}
3368 3368
3369int CalendarView::addCategories() 3369int CalendarView::addCategories()
3370{ 3370{
3371 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3371 QPtrList<Incidence> incList = mCalendar->rawIncidences();
3372 QStringList catList = KOPrefs::instance()->mCustomCategories; 3372 QStringList catList = KOPrefs::instance()->mCustomCategories;
3373 QStringList catIncList; 3373 QStringList catIncList;
3374 Incidence* inc = incList.first(); 3374 Incidence* inc = incList.first();
3375 uint i; 3375 uint i;
3376 int count = 0; 3376 int count = 0;
3377 while ( inc ) { 3377 while ( inc ) {
3378 catIncList = inc->categories() ; 3378 catIncList = inc->categories() ;
3379 for( i = 0; i< catIncList.count(); ++i ) { 3379 for( i = 0; i< catIncList.count(); ++i ) {
3380 if ( !catList.contains (catIncList[i])) { 3380 if ( !catList.contains (catIncList[i])) {
3381 catList.append( catIncList[i] ); 3381 catList.append( catIncList[i] );
3382 //qDebug("add cat %s ", catIncList[i].latin1()); 3382 //qDebug("add cat %s ", catIncList[i].latin1());
3383 ++count; 3383 ++count;
3384 } 3384 }
3385 } 3385 }
3386 inc = incList.next(); 3386 inc = incList.next();
3387 } 3387 }
3388 catList.sort(); 3388 catList.sort();
3389 KOPrefs::instance()->mCustomCategories = catList; 3389 KOPrefs::instance()->mCustomCategories = catList;
3390 return count; 3390 return count;
3391} 3391}
3392 3392
3393void CalendarView::editCategories() 3393void CalendarView::editCategories()
3394{ 3394{
3395 qDebug("CalendarView::editCategories() "); 3395 qDebug("CalendarView::editCategories() ");
3396 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 3396 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
3397 ced.exec(); 3397 ced.exec();
3398} 3398}
3399void CalendarView::manageCategories() 3399void CalendarView::manageCategories()
3400{ 3400{
3401 KOCatPrefs* cp = new KOCatPrefs(); 3401 KOCatPrefs* cp = new KOCatPrefs();
3402 cp->show(); 3402 cp->show();
3403 int w =cp->sizeHint().width() ; 3403 int w =cp->sizeHint().width() ;
3404 int h = cp->sizeHint().height() ; 3404 int h = cp->sizeHint().height() ;
3405 int dw = QApplication::desktop()->width(); 3405 int dw = QApplication::desktop()->width();
3406 int dh = QApplication::desktop()->height(); 3406 int dh = QApplication::desktop()->height();
3407 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 3407 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
3408 if ( !cp->exec() ) { 3408 if ( !cp->exec() ) {
3409 delete cp; 3409 delete cp;
3410 return; 3410 return;
3411 } 3411 }
3412 int count = 0; 3412 int count = 0;
3413 if ( cp->addCat() ) { 3413 if ( cp->addCat() ) {
3414 count = addCategories(); 3414 count = addCategories();
3415 if ( count ) { 3415 if ( count ) {
3416 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 3416 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
3417 writeSettings(); 3417 writeSettings();
3418 } else 3418 } else
3419 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 3419 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
3420 } else { 3420 } else {
3421 removeCategories(); 3421 removeCategories();
3422 updateView(); 3422 updateView();
3423 } 3423 }
3424 delete cp; 3424 delete cp;
3425} 3425}
3426 3426
3427void CalendarView::beamIncidence(Incidence * Inc) 3427void CalendarView::beamIncidence(Incidence * Inc)
3428{ 3428{
3429 QPtrList<Incidence> delSel ; 3429 QPtrList<Incidence> delSel ;
3430 delSel.append(Inc); 3430 delSel.append(Inc);
3431 beamIncidenceList( delSel ); 3431 beamIncidenceList( delSel );
3432} 3432}
3433void CalendarView::beamCalendar() 3433void CalendarView::beamCalendar()
3434{ 3434{
3435 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 3435 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
3436 //qDebug("beamCalendar() "); 3436 //qDebug("beamCalendar() ");
3437 beamIncidenceList( delSel ); 3437 beamIncidenceList( delSel );
3438} 3438}
3439void CalendarView::beamFilteredCalendar() 3439void CalendarView::beamFilteredCalendar()
3440{ 3440{
3441 QPtrList<Incidence> delSel = mCalendar->incidences(); 3441 QPtrList<Incidence> delSel = mCalendar->incidences();
3442 //qDebug("beamFilteredCalendar() "); 3442 //qDebug("beamFilteredCalendar() ");
3443 beamIncidenceList( delSel ); 3443 beamIncidenceList( delSel );
3444} 3444}
3445void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 3445void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
3446{ 3446{
3447 3447
3448 KOBeamPrefs beamDialog; 3448 KOBeamPrefs beamDialog;
3449 if ( beamDialog.exec () == QDialog::Rejected ) 3449 if ( beamDialog.exec () == QDialog::Rejected )
3450 return; 3450 return;
3451#ifdef DESKTOP_VERSION 3451#ifdef DESKTOP_VERSION
3452 QString fn = locateLocal( "tmp", "kopibeamfile" ); 3452 QString fn = locateLocal( "tmp", "kopibeamfile" );
3453#else 3453#else
3454 QString fn = "/tmp/kopibeamfile"; 3454 QString fn = "/tmp/kopibeamfile";
3455#endif 3455#endif
3456 QString mes; 3456 QString mes;
3457 bool createbup = true; 3457 bool createbup = true;
3458 if ( createbup ) { 3458 if ( createbup ) {
3459 QString description = "\n"; 3459 QString description = "\n";
3460 CalendarLocal* cal = new CalendarLocal(); 3460 CalendarLocal* cal = new CalendarLocal();
3461 if ( beamDialog.beamLocal() ) 3461 if ( beamDialog.beamLocal() )
3462 cal->setLocalTime(); 3462 cal->setLocalTime();
3463 else 3463 else
3464 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3464 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3465 Incidence *incidence = delSel.first(); 3465 Incidence *incidence = delSel.first();
3466 bool addText = false; 3466 bool addText = false;
3467 if ( delSel.count() < 10 ) 3467 if ( delSel.count() < 10 )
3468 addText = true; 3468 addText = true;
3469 else { 3469 else {
3470 description.sprintf(i18n(" %d items?"),delSel.count() ); 3470 description.sprintf(i18n(" %d items?"),delSel.count() );
3471 } 3471 }
3472 while ( incidence ) { 3472 while ( incidence ) {
3473 Incidence *in = incidence->clone(); 3473 Incidence *in = incidence->clone();
3474 if ( ! in->summary().isEmpty() ) { 3474 if ( ! in->summary().isEmpty() ) {
3475 in->setDescription(""); 3475 in->setDescription("");
3476 } else { 3476 } else {
3477 in->setSummary( in->description().left(20)); 3477 in->setSummary( in->description().left(20));
3478 in->setDescription(""); 3478 in->setDescription("");
3479 } 3479 }
3480 if ( addText ) 3480 if ( addText )
3481 description += in->summary() + "\n"; 3481 description += in->summary() + "\n";
3482 cal->addIncidence( in ); 3482 cal->addIncidence( in );
3483 incidence = delSel.next(); 3483 incidence = delSel.next();
3484 } 3484 }
3485 if ( beamDialog.beamVcal() ) { 3485 if ( beamDialog.beamVcal() ) {
3486 fn += ".vcs"; 3486 fn += ".vcs";
3487 FileStorage storage( cal, fn, new VCalFormat ); 3487 FileStorage storage( cal, fn, new VCalFormat );
3488 storage.save(); 3488 storage.save();
3489 } else { 3489 } else {
3490 fn += ".ics"; 3490 fn += ".ics";
3491 FileStorage storage( cal, fn, new ICalFormat( ) ); 3491 FileStorage storage( cal, fn, new ICalFormat( ) );
3492 storage.save(); 3492 storage.save();
3493 } 3493 }
3494 delete cal; 3494 delete cal;
3495 mes = i18n("KO/Pi: Ready for beaming"); 3495 mes = i18n("KO/Pi: Ready for beaming");
3496 topLevelWidget()->setCaption(mes); 3496 topLevelWidget()->setCaption(mes);
3497 KApplication::convert2latin1( fn ); 3497 KApplication::convert2latin1( fn );
3498#ifndef DESKTOP_VERSION 3498#ifndef DESKTOP_VERSION
3499 Ir *ir = new Ir( this ); 3499 Ir *ir = new Ir( this );
3500 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 3500 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
3501 ir->send( fn, description, "text/x-vCalendar" ); 3501 ir->send( fn, description, "text/x-vCalendar" );
3502#endif 3502#endif
3503 } 3503 }
3504} 3504}
3505 3505
3506#ifndef DESKTOP_VERSION 3506#ifndef DESKTOP_VERSION
3507void CalendarView::beamDone( Ir *ir ) 3507void CalendarView::beamDone( Ir *ir )
3508{ 3508{
3509 delete ir; 3509 delete ir;
3510 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 3510 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
3511 topLevelWidget()->raise(); 3511 topLevelWidget()->raise();
3512} 3512}
3513#else 3513#else
3514void CalendarView::beamDone( Ir *){;} 3514void CalendarView::beamDone( Ir *){;}
3515#endif 3515#endif
3516void CalendarView::moveIncidence(Incidence * inc ) 3516void CalendarView::moveIncidence(Incidence * inc )
3517{ 3517{
3518 if ( !inc ) return; 3518 if ( !inc ) return;
3519 showDatePickerPopup(); 3519 showDatePickerPopup();
3520 mDatePickerMode = 2; 3520 mDatePickerMode = 2;
3521 mMoveIncidence = inc ; 3521 mMoveIncidence = inc ;
3522 QDate da; 3522 QDate da;
3523 if ( mMoveIncidence->typeID() == todoID ) { 3523 if ( mMoveIncidence->typeID() == todoID ) {
3524 Todo * to = (Todo *) mMoveIncidence; 3524 Todo * to = (Todo *) mMoveIncidence;
3525 if ( to->hasDueDate() ) 3525 if ( to->hasDueDate() )
3526 da = to->dtDue().date(); 3526 da = to->dtDue().date();
3527 else 3527 else
3528 da = QDate::currentDate(); 3528 da = QDate::currentDate();
3529 } else { 3529 } else {
3530 da = mMoveIncidence->dtStart().date(); 3530 da = mMoveIncidence->dtStart().date();
3531 } 3531 }
3532 //PENDING set date for recurring incidence to date of recurrence 3532 //PENDING set date for recurring incidence to date of recurrence
3533 //mMoveIncidenceOldDate; 3533 //mMoveIncidenceOldDate;
3534 mDatePicker->setDate( da ); 3534 mDatePicker->setDate( da );
3535} 3535}
3536void CalendarView::showDatePickerPopup() 3536void CalendarView::showDatePickerPopup()
3537{ 3537{
3538 if ( mDateFrame->isVisible() ) 3538 if ( mDateFrame->isVisible() )
3539 mDateFrame->hide(); 3539 mDateFrame->hide();
3540 else { 3540 else {
3541 int offX = 0, offY = 0; 3541 int offX = 0, offY = 0;
3542#ifdef DESKTOP_VERSION 3542#ifdef DESKTOP_VERSION
3543 int w =mDatePicker->sizeHint().width() ; 3543 int w =mDatePicker->sizeHint().width() ;
3544 int h = mDatePicker->sizeHint().height() ; 3544 int h = mDatePicker->sizeHint().height() ;
3545 int dw = topLevelWidget()->width(); 3545 int dw = topLevelWidget()->width();
3546 int dh = topLevelWidget()->height(); 3546 int dh = topLevelWidget()->height();
3547 offX = topLevelWidget()->x(); 3547 offX = topLevelWidget()->x();
3548 offY = topLevelWidget()->y(); 3548 offY = topLevelWidget()->y();
3549#else 3549#else
3550 int w =mDatePicker->sizeHint().width() ; 3550 int w =mDatePicker->sizeHint().width() ;
3551 int h = mDatePicker->sizeHint().height() ; 3551 int h = mDatePicker->sizeHint().height() ;
3552 int dw = QApplication::desktop()->width(); 3552 int dw = QApplication::desktop()->width();
3553 int dh = QApplication::desktop()->height(); 3553 int dh = QApplication::desktop()->height();
3554#endif 3554#endif
3555 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 3555 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
3556 mDateFrame->show(); 3556 mDateFrame->show();
3557 } 3557 }
3558} 3558}
3559void CalendarView::showDatePicker( ) 3559void CalendarView::showDatePicker( )
3560{ 3560{
3561 showDatePickerPopup(); 3561 showDatePickerPopup();
3562 mDatePickerMode = 1; 3562 mDatePickerMode = 1;
3563 mDatePicker->setDate( mNavigator->selectedDates().first() ); 3563 mDatePicker->setDate( mNavigator->selectedDates().first() );
3564} 3564}
3565 3565
3566void CalendarView::showEventEditor() 3566void CalendarView::showEventEditor()
3567{ 3567{
3568#ifdef DESKTOP_VERSION 3568#ifdef DESKTOP_VERSION
3569 int x,y,w,h; 3569 int x,y,w,h;
3570 x = mEventEditor->geometry().x(); 3570 x = mEventEditor->geometry().x();
3571 y = mEventEditor->geometry().y(); 3571 y = mEventEditor->geometry().y();
3572 w = mEventEditor->width(); 3572 w = mEventEditor->width();
3573 h = mEventEditor->height(); 3573 h = mEventEditor->height();
3574 mEventEditor->show(); 3574 mEventEditor->show();
3575 mEventEditor->setGeometry(x,y,w,h); 3575 mEventEditor->setGeometry(x,y,w,h);
3576#else 3576#else
3577 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 3577 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
3578 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3578 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3579 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 3579 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
3580 qApp->processEvents(); 3580 qApp->processEvents();
3581 delete mEventEditor; 3581 delete mEventEditor;
3582 mEventEditor = mDialogManager->getEventEditor(); 3582 mEventEditor = mDialogManager->getEventEditor();
3583 topLevelWidget()->setCaption( i18n("") ); 3583 topLevelWidget()->setCaption( i18n("") );
3584 } 3584 }
3585 mEventEditor->showMaximized(); 3585 mEventEditor->showMaximized();
3586#endif 3586#endif
3587} 3587}
3588void CalendarView::showTodoEditor() 3588void CalendarView::showTodoEditor()
3589{ 3589{
3590#ifdef DESKTOP_VERSION 3590#ifdef DESKTOP_VERSION
3591 int x,y,w,h; 3591 int x,y,w,h;
3592 x = mTodoEditor->geometry().x(); 3592 x = mTodoEditor->geometry().x();
3593 y = mTodoEditor->geometry().y(); 3593 y = mTodoEditor->geometry().y();
3594 w = mTodoEditor->width(); 3594 w = mTodoEditor->width();
3595 h = mTodoEditor->height(); 3595 h = mTodoEditor->height();
3596 mTodoEditor->show(); 3596 mTodoEditor->show();
3597 mTodoEditor->setGeometry(x,y,w,h); 3597 mTodoEditor->setGeometry(x,y,w,h);
3598#else 3598#else
3599 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3599 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3600 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3600 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3601 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3601 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3602 qApp->processEvents(); 3602 qApp->processEvents();
3603 delete mTodoEditor; 3603 delete mTodoEditor;
3604 mTodoEditor = mDialogManager->getTodoEditor(); 3604 mTodoEditor = mDialogManager->getTodoEditor();
3605 topLevelWidget()->setCaption( i18n("") ); 3605 topLevelWidget()->setCaption( i18n("") );
3606 } 3606 }
3607 mTodoEditor->showMaximized(); 3607 mTodoEditor->showMaximized();
3608#endif 3608#endif
3609} 3609}
3610 3610
3611void CalendarView::cloneIncidence() 3611void CalendarView::cloneIncidence()
3612{ 3612{
3613 Incidence *incidence = currentSelection(); 3613 Incidence *incidence = currentSelection();
3614 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3614 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3615 if ( incidence ) { 3615 if ( incidence ) {
3616 cloneIncidence(incidence); 3616 cloneIncidence(incidence);
3617 } 3617 }
3618} 3618}
3619void CalendarView::moveIncidence() 3619void CalendarView::moveIncidence()
3620{ 3620{
3621 Incidence *incidence = currentSelection(); 3621 Incidence *incidence = currentSelection();
3622 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3622 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3623 if ( incidence ) { 3623 if ( incidence ) {
3624 moveIncidence(incidence); 3624 moveIncidence(incidence);
3625 } 3625 }
3626} 3626}
3627void CalendarView::beamIncidence() 3627void CalendarView::beamIncidence()
3628{ 3628{
3629 Incidence *incidence = currentSelection(); 3629 Incidence *incidence = currentSelection();
3630 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3630 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3631 if ( incidence ) { 3631 if ( incidence ) {
3632 beamIncidence(incidence); 3632 beamIncidence(incidence);
3633 } 3633 }
3634} 3634}
3635void CalendarView::toggleCancelIncidence() 3635void CalendarView::toggleCancelIncidence()
3636{ 3636{
3637 Incidence *incidence = currentSelection(); 3637 Incidence *incidence = currentSelection();
3638 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3638 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3639 if ( incidence ) { 3639 if ( incidence ) {
3640 cancelIncidence(incidence); 3640 cancelIncidence(incidence);
3641 } 3641 }
3642} 3642}
3643 3643
3644 3644
3645void CalendarView::cancelIncidence(Incidence * inc ) 3645void CalendarView::cancelIncidence(Incidence * inc )
3646{ 3646{
3647 inc->setCancelled( ! inc->cancelled() ); 3647 inc->setCancelled( ! inc->cancelled() );
3648 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3648 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3649 updateView(); 3649 updateView();
3650} 3650}
3651void CalendarView::cloneIncidence(Incidence * orgInc ) 3651void CalendarView::cloneIncidence(Incidence * orgInc )
3652{ 3652{
3653 Incidence * newInc = orgInc->clone(); 3653 Incidence * newInc = orgInc->clone();
3654 newInc->recreate(); 3654 newInc->recreate();
3655 3655
3656 if ( newInc->typeID() == todoID ) { 3656 if ( newInc->typeID() == todoID ) {
3657 Todo* t = (Todo*) newInc; 3657 Todo* t = (Todo*) newInc;
3658 bool cloneSub = false; 3658 bool cloneSub = false;
3659 if ( orgInc->relations().count() ) { 3659 if ( orgInc->relations().count() ) {
3660 int result = KMessageBox::warningYesNoCancel(this, 3660 int result = KMessageBox::warningYesNoCancel(this,
3661 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), 3661 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ),
3662 i18n("Todo has subtodos"), 3662 i18n("Todo has subtodos"),
3663 i18n("Yes"), 3663 i18n("Yes"),
3664 i18n("No")); 3664 i18n("No"));
3665 3665
3666 if ( result == KMessageBox::Cancel ) { 3666 if ( result == KMessageBox::Cancel ) {
3667 delete t; 3667 delete t;
3668 return; 3668 return;
3669 } 3669 }
3670 if (result == KMessageBox::Yes) cloneSub = true; 3670 if (result == KMessageBox::Yes) cloneSub = true;
3671 } 3671 }
3672 showTodoEditor(); 3672 showTodoEditor();
3673 mTodoEditor->editTodo( t ); 3673 mTodoEditor->editTodo( t );
3674 if ( mTodoEditor->exec() ) { 3674 if ( mTodoEditor->exec() ) {
3675 if ( cloneSub ) { 3675 if ( cloneSub ) {
3676 orgInc->cloneRelations( t ); 3676 orgInc->cloneRelations( t );
3677 mCalendar->addIncidenceBranch( t ); 3677 mCalendar->addIncidenceBranch( t );
3678 updateView(); 3678 updateView();
3679 3679
3680 } else { 3680 } else {
3681 mCalendar->addTodo( t ); 3681 mCalendar->addTodo( t );
3682 updateView(); 3682 updateView();
3683 } 3683 }
3684 } else { 3684 } else {
3685 delete t; 3685 delete t;
3686 } 3686 }
3687 } 3687 }
3688 else if ( newInc->typeID() == eventID ) { 3688 else if ( newInc->typeID() == eventID ) {
3689 Event* e = (Event*) newInc; 3689 Event* e = (Event*) newInc;
3690 showEventEditor(); 3690 showEventEditor();
3691 mEventEditor->editEvent( e ); 3691 mEventEditor->editEvent( e );
3692 if ( mEventEditor->exec() ) { 3692 if ( mEventEditor->exec() ) {
3693 mCalendar->addEvent( e ); 3693 mCalendar->addEvent( e );
3694 updateView(); 3694 updateView();
3695 } else { 3695 } else {
3696 delete e; 3696 delete e;
3697 } 3697 }
3698 } else if ( newInc->typeID() == journalID ) { 3698 } else if ( newInc->typeID() == journalID ) {
3699 mCalendar->addJournal( (Journal*) newInc ); 3699 mCalendar->addJournal( (Journal*) newInc );
3700 editJournal( (Journal*) newInc ); 3700 editJournal( (Journal*) newInc );
3701 } 3701 }
3702 setActiveWindow(); 3702 setActiveWindow();
3703} 3703}
3704 3704
3705void CalendarView::newEvent() 3705void CalendarView::newEvent()
3706{ 3706{
3707 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3707 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3708 KOAgendaView *aView = mViewManager->agendaView(); 3708 KOAgendaView *aView = mViewManager->agendaView();
3709 if (aView) { 3709 if (aView) {
3710 if (aView->selectionStart().isValid()) { 3710 if (aView->selectionStart().isValid()) {
3711 if (aView->selectedIsAllDay()) { 3711 if (aView->selectedIsAllDay()) {
3712 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3712 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3713 } else { 3713 } else {
3714 newEvent(aView->selectionStart(),aView->selectionEnd()); 3714 newEvent(aView->selectionStart(),aView->selectionEnd());
3715 } 3715 }
3716 return; 3716 return;
3717 } 3717 }
3718 } 3718 }
3719 3719
3720 QDate date = mNavigator->selectedDates().first(); 3720 QDate date = mNavigator->selectedDates().first();
3721#if 0 3721#if 0
3722 QDateTime current = QDateTime::currentDateTime(); 3722 QDateTime current = QDateTime::currentDateTime();
3723 if ( date <= current.date() ) { 3723 if ( date <= current.date() ) {
3724 int hour = current.time().hour() +1; 3724 int hour = current.time().hour() +1;
3725 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3725 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3726 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3726 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3727 } else 3727 } else
3728#endif 3728#endif
3729 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3729 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3730 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3730 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3731 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3731 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3732} 3732}
3733 3733
3734void CalendarView::newEvent(QDateTime fh) 3734void CalendarView::newEvent(QDateTime fh)
3735{ 3735{
3736 newEvent(fh, 3736 newEvent(fh,
3737 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3737 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3738} 3738}
3739 3739
3740void CalendarView::newEvent(QDate dt) 3740void CalendarView::newEvent(QDate dt)
3741{ 3741{
3742 newEvent(QDateTime(dt, QTime(0,0,0)), 3742 newEvent(QDateTime(dt, QTime(0,0,0)),
3743 QDateTime(dt, QTime(0,0,0)), true); 3743 QDateTime(dt, QTime(0,0,0)), true);
3744} 3744}
3745void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3745void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3746{ 3746{
3747 newEvent(fromHint, toHint, false); 3747 newEvent(fromHint, toHint, false);
3748} 3748}
3749void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3749void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3750{ 3750{
3751 3751
3752 showEventEditor(); 3752 showEventEditor();
3753 mEventEditor->newEvent(fromHint,toHint,allDay); 3753 mEventEditor->newEvent(fromHint,toHint,allDay);
3754 if ( mFilterView->filtersEnabled() ) { 3754 if ( mFilterView->filtersEnabled() ) {
3755 CalFilter *filter = mFilterView->selectedFilter(); 3755 CalFilter *filter = mFilterView->selectedFilter();
3756 if (filter && filter->showCategories()) { 3756 if (filter && filter->showCategories()) {
3757 mEventEditor->setCategories(filter->categoryList().join(",") ); 3757 mEventEditor->setCategories(filter->categoryList().join(",") );
3758 } 3758 }
3759 if ( filter ) 3759 if ( filter )
3760 mEventEditor->setSecrecy( filter->getSecrecy() ); 3760 mEventEditor->setSecrecy( filter->getSecrecy() );
3761 } 3761 }
3762 mEventEditor->exec(); 3762 mEventEditor->exec();
3763 setActiveWindow(); 3763 setActiveWindow();
3764} 3764}
3765void CalendarView::todoAdded(Todo * t) 3765void CalendarView::todoAdded(Todo * t)
3766{ 3766{
3767 3767
3768 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3768 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3769 updateTodoViews(); 3769 updateTodoViews();
3770} 3770}
3771void CalendarView::todoChanged(Todo * t) 3771void CalendarView::todoChanged(Todo * t)
3772{ 3772{
3773 emit todoModified( t, 4 ); 3773 emit todoModified( t, 4 );
3774 // updateTodoViews(); 3774 // updateTodoViews();
3775} 3775}
3776void CalendarView::todoToBeDeleted(Todo *) 3776void CalendarView::todoToBeDeleted(Todo *)
3777{ 3777{
3778 //qDebug("todoToBeDeleted(Todo *) "); 3778 //qDebug("todoToBeDeleted(Todo *) ");
3779 updateTodoViews(); 3779 updateTodoViews();
3780} 3780}
3781void CalendarView::todoDeleted() 3781void CalendarView::todoDeleted()
3782{ 3782{
3783 //qDebug(" todoDeleted()"); 3783 //qDebug(" todoDeleted()");
3784 updateTodoViews(); 3784 updateTodoViews();
3785} 3785}
3786 3786
3787 3787
3788void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3788void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3789{ 3789{
3790 showTodoEditor(); 3790 showTodoEditor();
3791 mTodoEditor->newTodo(dt,0,allday); 3791 mTodoEditor->newTodo(dt,0,allday);
3792 if ( mFilterView->filtersEnabled() ) { 3792 if ( mFilterView->filtersEnabled() ) {
3793 CalFilter *filter = mFilterView->selectedFilter(); 3793 CalFilter *filter = mFilterView->selectedFilter();
3794 if (filter && filter->showCategories()) { 3794 if (filter && filter->showCategories()) {
3795 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3795 mTodoEditor->setCategories(filter->categoryList().join(",") );
3796 } 3796 }
3797 if ( filter ) 3797 if ( filter )
3798 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3798 mTodoEditor->setSecrecy( filter->getSecrecy() );
3799 } 3799 }
3800 mTodoEditor->exec(); 3800 mTodoEditor->exec();
3801 setActiveWindow(); 3801 setActiveWindow();
3802} 3802}
3803 3803
3804void CalendarView::newTodo() 3804void CalendarView::newTodo()
3805{ 3805{
3806 newTodoDateTime( QDateTime(),true ); 3806 newTodoDateTime( QDateTime(),true );
3807} 3807}
3808 3808
3809void CalendarView::newSubTodo() 3809void CalendarView::newSubTodo()
3810{ 3810{
3811 Todo *todo = selectedTodo(); 3811 Todo *todo = selectedTodo();
3812 if ( todo ) newSubTodo( todo ); 3812 if ( todo ) newSubTodo( todo );
3813} 3813}
3814 3814
3815void CalendarView::newSubTodo(Todo *parentEvent) 3815void CalendarView::newSubTodo(Todo *parentEvent)
3816{ 3816{
3817 3817
3818 showTodoEditor(); 3818 showTodoEditor();
3819 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3819 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3820 mTodoEditor->exec(); 3820 mTodoEditor->exec();
3821 setActiveWindow(); 3821 setActiveWindow();
3822} 3822}
3823 3823
3824void CalendarView::newFloatingEvent() 3824void CalendarView::newFloatingEvent()
3825{ 3825{
3826 DateList tmpList = mNavigator->selectedDates(); 3826 DateList tmpList = mNavigator->selectedDates();
3827 QDate date = tmpList.first(); 3827 QDate date = tmpList.first();
3828 3828
3829 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3829 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3830 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3830 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3831} 3831}
3832 3832
3833 3833
3834void CalendarView::editEvent( Event *event ) 3834void CalendarView::editEvent( Event *event )
3835{ 3835{
3836 3836
3837 if ( !event ) return; 3837 if ( !event ) return;
3838 if ( event->isReadOnly() ) { 3838 if ( event->isReadOnly() ) {
3839 showEvent( event ); 3839 showEvent( event );
3840 return; 3840 return;
3841 } 3841 }
3842 showEventEditor(); 3842 showEventEditor();
3843 mEventEditor->editEvent( event , mFlagEditDescription); 3843 mEventEditor->editEvent( event , mFlagEditDescription);
3844 mEventEditor->exec(); 3844 mEventEditor->exec();
3845 setActiveWindow(); 3845 setActiveWindow();
3846 3846
3847} 3847}
3848void CalendarView::editJournal( Journal *jour ) 3848void CalendarView::editJournal( Journal *jour )
3849{ 3849{
3850 if ( !jour ) return; 3850 if ( !jour ) return;
3851 mDialogManager->hideSearchDialog(); 3851 mDialogManager->hideSearchDialog();
3852 mViewManager->showJournalView(); 3852 mViewManager->showJournalView();
3853 mNavigator->slotDaySelect( jour->dtStart().date() ); 3853 mNavigator->slotDaySelect( jour->dtStart().date() );
3854} 3854}
3855void CalendarView::editTodo( Todo *todo ) 3855void CalendarView::editTodo( Todo *todo )
3856{ 3856{
3857 if ( !todo ) return; 3857 if ( !todo ) return;
3858 3858
3859 if ( todo->isReadOnly() ) { 3859 if ( todo->isReadOnly() ) {
3860 showTodo( todo ); 3860 showTodo( todo );
3861 return; 3861 return;
3862 } 3862 }
3863 showTodoEditor(); 3863 showTodoEditor();
3864 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3864 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3865 mTodoEditor->exec(); 3865 mTodoEditor->exec();
3866 setActiveWindow(); 3866 setActiveWindow();
3867 3867
3868} 3868}
3869 3869
3870KOEventViewerDialog* CalendarView::getEventViewerDialog() 3870KOEventViewerDialog* CalendarView::getEventViewerDialog()
3871{ 3871{
3872 if ( !mEventViewerDialog ) { 3872 if ( !mEventViewerDialog ) {
3873 mEventViewerDialog = new KOEventViewerDialog(0); 3873 mEventViewerDialog = new KOEventViewerDialog(0);
3874 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3874 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3875 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3875 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3876 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3876 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3877 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3877 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3878 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3878 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3879 viewManager(), SLOT( showAgendaView( bool ) ) ); 3879 viewManager(), SLOT( showAgendaView( bool ) ) );
3880 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3880 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3881 this, SLOT( slotViewerClosed() ) ); 3881 this, SLOT( slotViewerClosed() ) );
3882 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3882 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3883 this, SLOT( todoChanged(Todo *) ) ); 3883 this, SLOT( todoChanged(Todo *) ) );
3884 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 3884 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
3885 mEventViewerDialog->resize( 640, 480 ); 3885 mEventViewerDialog->resize( 640, 480 );
3886 3886
3887 } 3887 }
3888 return mEventViewerDialog; 3888 return mEventViewerDialog;
3889} 3889}
3890void CalendarView::showEvent(Event *event) 3890void CalendarView::showEvent(Event *event)
3891{ 3891{
3892 getEventViewerDialog()->setEvent(event); 3892 getEventViewerDialog()->setEvent(event);
3893 getEventViewerDialog()->showMe(); 3893 getEventViewerDialog()->showMe();
3894} 3894}
3895 3895
3896void CalendarView::showTodo(Todo *event) 3896void CalendarView::showTodo(Todo *event)
3897{ 3897{
3898 getEventViewerDialog()->setTodo(event); 3898 getEventViewerDialog()->setTodo(event);
3899 getEventViewerDialog()->showMe(); 3899 getEventViewerDialog()->showMe();
3900} 3900}
3901void CalendarView::showJournal( Journal *jour ) 3901void CalendarView::showJournal( Journal *jour )
3902{ 3902{
3903 getEventViewerDialog()->setJournal(jour); 3903 getEventViewerDialog()->setJournal(jour);
3904 getEventViewerDialog()->showMe(); 3904 getEventViewerDialog()->showMe();
3905 3905
3906} 3906}
3907// void CalendarView::todoModified (Todo *event, int changed) 3907// void CalendarView::todoModified (Todo *event, int changed)
3908// { 3908// {
3909// // if (mDialogList.find (event) != mDialogList.end ()) { 3909// // if (mDialogList.find (event) != mDialogList.end ()) {
3910// // kdDebug() << "Todo modified and open" << endl; 3910// // kdDebug() << "Todo modified and open" << endl;
3911// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3911// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3912// // temp->modified (changed); 3912// // temp->modified (changed);
3913 3913
3914// // } 3914// // }
3915 3915
3916// mViewManager->updateView(); 3916// mViewManager->updateView();
3917// } 3917// }
3918 3918
3919void CalendarView::appointment_show() 3919void CalendarView::appointment_show()
3920{ 3920{
3921 Event *anEvent = 0; 3921 Event *anEvent = 0;
3922 3922
3923 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3923 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3924 3924
3925 if (mViewManager->currentView()->isEventView()) { 3925 if (mViewManager->currentView()->isEventView()) {
3926 if ( incidence && incidence->typeID() == eventID ) { 3926 if ( incidence && incidence->typeID() == eventID ) {
3927 anEvent = static_cast<Event *>(incidence); 3927 anEvent = static_cast<Event *>(incidence);
3928 } 3928 }
3929 } 3929 }
3930 3930
3931 if (!anEvent) { 3931 if (!anEvent) {
3932 KNotifyClient::beep(); 3932 KNotifyClient::beep();
3933 return; 3933 return;
3934 } 3934 }
3935 3935
3936 showEvent(anEvent); 3936 showEvent(anEvent);
3937} 3937}
3938 3938
3939void CalendarView::appointment_edit() 3939void CalendarView::appointment_edit()
3940{ 3940{
3941 Event *anEvent = 0; 3941 Event *anEvent = 0;
3942 3942
3943 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3943 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3944 3944
3945 if (mViewManager->currentView()->isEventView()) { 3945 if (mViewManager->currentView()->isEventView()) {
3946 if ( incidence && incidence->typeID() == eventID ) { 3946 if ( incidence && incidence->typeID() == eventID ) {
3947 anEvent = static_cast<Event *>(incidence); 3947 anEvent = static_cast<Event *>(incidence);
3948 } 3948 }
3949 } 3949 }
3950 3950
3951 if (!anEvent) { 3951 if (!anEvent) {
3952 KNotifyClient::beep(); 3952 KNotifyClient::beep();
3953 return; 3953 return;
3954 } 3954 }
3955 3955
3956 editEvent(anEvent); 3956 editEvent(anEvent);
3957} 3957}
3958 3958
3959void CalendarView::appointment_delete() 3959void CalendarView::appointment_delete()
3960{ 3960{
3961 Event *anEvent = 0; 3961 Event *anEvent = 0;
3962 3962
3963 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3963 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3964 3964
3965 if (mViewManager->currentView()->isEventView()) { 3965 if (mViewManager->currentView()->isEventView()) {
3966 if ( incidence && incidence->typeID() == eventID ) { 3966 if ( incidence && incidence->typeID() == eventID ) {
3967 anEvent = static_cast<Event *>(incidence); 3967 anEvent = static_cast<Event *>(incidence);
3968 } 3968 }
3969 } 3969 }
3970 3970
3971 if (!anEvent) { 3971 if (!anEvent) {
3972 KNotifyClient::beep(); 3972 KNotifyClient::beep();
3973 return; 3973 return;
3974 } 3974 }
3975 3975
3976 deleteEvent(anEvent); 3976 deleteEvent(anEvent);
3977} 3977}
3978 3978
3979void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3979void CalendarView::todo_resub( Todo * parent, Todo * sub )
3980{ 3980{
3981 if (!sub) return; 3981 if (!sub) return;
3982 if ( sub->relatedTo() == parent ) 3982 if ( sub->relatedTo() == parent )
3983 return; 3983 return;
3984 sub->setRelatedTo(parent); 3984 sub->setRelatedTo(parent);
3985 sub->updated(); 3985 sub->updated();
3986 setModified(true); 3986 setModified(true);
3987 updateView(); 3987 updateView();
3988} 3988}
3989void CalendarView::todo_unsub(Todo *anTodo ) 3989void CalendarView::todo_unsub(Todo *anTodo )
3990{ 3990{
3991 todo_resub( 0, anTodo ); 3991 todo_resub( 0, anTodo );
3992} 3992}
3993 3993
3994void CalendarView::deleteTodo(Todo *todo) 3994void CalendarView::deleteTodo(Todo *todo)
3995{ 3995{
3996 if (!todo) { 3996 if (!todo) {
3997 KNotifyClient::beep(); 3997 KNotifyClient::beep();
3998 return; 3998 return;
3999 } 3999 }
4000 if (KOPrefs::instance()->mConfirm) { 4000 if (KOPrefs::instance()->mConfirm) {
4001 QString text = KGlobal::formatMessage ( todo->summary(),0 ); 4001 QString text = KGlobal::formatMessage ( todo->summary(),0 );
4002 if (!todo->relations().isEmpty()) { 4002 if (!todo->relations().isEmpty()) {
4003 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 4003 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
4004 4004
4005 } 4005 }
4006 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { 4006 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) {
4007 case KMessageBox::Continue: // OK 4007 case KMessageBox::Continue: // OK
4008 bool deleteT = false; 4008 bool deleteT = false;
4009 if (!todo->relations().isEmpty()) { 4009 if (!todo->relations().isEmpty()) {
4010 deleteT = removeCompletedSubTodos( todo ); 4010 deleteT = removeCompletedSubTodos( todo );
4011 } 4011 }
4012 // deleteT == true: todo already deleted in removeCompletedSubTodos 4012 // deleteT == true: todo already deleted in removeCompletedSubTodos
4013 if ( !deleteT ) { 4013 if ( !deleteT ) {
4014 checkExternalId( todo ); 4014 checkExternalId( todo );
4015 calendar()->deleteTodo(todo); 4015 calendar()->deleteTodo(todo);
4016 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 4016 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
4017 } 4017 }
4018 updateView(); 4018 updateView();
4019 break; 4019 break;
4020 } // switch 4020 } // switch
4021 } else { 4021 } else {
4022 checkExternalId( todo ); 4022 checkExternalId( todo );
4023 mCalendar->deleteTodo(todo); 4023 mCalendar->deleteTodo(todo);
4024 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 4024 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
4025 updateView(); 4025 updateView();
4026 } 4026 }
4027 4027
4028 emit updateSearchDialog(); 4028 emit updateSearchDialog();
4029} 4029}
4030void CalendarView::deleteJournal(Journal *jour) 4030void CalendarView::deleteJournal(Journal *jour)
4031{ 4031{
4032 if (!jour) { 4032 if (!jour) {
4033 KNotifyClient::beep(); 4033 KNotifyClient::beep();
4034 return; 4034 return;
4035 } 4035 }
4036 if (KOPrefs::instance()->mConfirm) { 4036 if (KOPrefs::instance()->mConfirm) {
4037 4037
4038 QString des; 4038 QString des;
4039 if ( !jour->summary().isEmpty() ) { 4039 if ( !jour->summary().isEmpty() ) {
4040 des = jour->summary(); 4040 des = jour->summary();
4041 } else { 4041 } else {
4042 des = jour->description().left(30); 4042 des = jour->description().left(30);
4043 des = des.simplifyWhiteSpace (); 4043 des = des.simplifyWhiteSpace ();
4044 des.replace (QRegExp ("\\n"),"" ); 4044 des.replace (QRegExp ("\\n"),"" );
4045 des.replace (QRegExp ("\\r"),"" ); 4045 des.replace (QRegExp ("\\r"),"" );
4046 } 4046 }
4047 switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { 4047 switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) {
4048 case KMessageBox::Continue: // OK 4048 case KMessageBox::Continue: // OK
4049 calendar()->deleteJournal(jour); 4049 calendar()->deleteJournal(jour);
4050 updateView(); 4050 updateView();
4051 break; 4051 break;
4052 } // switch 4052 } // switch
4053 } else { 4053 } else {
4054 calendar()->deleteJournal(jour);; 4054 calendar()->deleteJournal(jour);;
4055 updateView(); 4055 updateView();
4056 } 4056 }
4057 emit updateSearchDialog(); 4057 emit updateSearchDialog();
4058} 4058}
4059 4059
4060void CalendarView::deleteEvent(Event *anEvent) 4060void CalendarView::deleteEvent(Event *anEvent)
4061{ 4061{
4062 if (!anEvent) { 4062 if (!anEvent) {
4063 KNotifyClient::beep(); 4063 KNotifyClient::beep();
4064 return; 4064 return;
4065 } 4065 }
4066 4066
4067 if (anEvent->doesRecur()) { 4067 if (anEvent->doesRecur()) {
4068 QDate itemDate = mViewManager->currentSelectionDate(); 4068 QDate itemDate = mViewManager->currentSelectionDate();
4069 int km; 4069 int km;
4070 if (!itemDate.isValid()) { 4070 if (!itemDate.isValid()) {
4071 //kdDebug() << "Date Not Valid" << endl; 4071 //kdDebug() << "Date Not Valid" << endl;
4072 if (KOPrefs::instance()->mConfirm) { 4072 if (KOPrefs::instance()->mConfirm) {
4073 km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 4073 km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
4074 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 4074 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
4075 i18n("KO/Pi Confirmation"),i18n("Delete All")); 4075 i18n("KO/Pi Confirmation"),i18n("Delete All"));
4076 if ( km == KMessageBox::Continue ) 4076 if ( km == KMessageBox::Continue )
4077 km = KMessageBox::No; // No = all below 4077 km = KMessageBox::No; // No = all below
4078 } else 4078 } else
4079 km = KMessageBox::No; 4079 km = KMessageBox::No;
4080 } else { 4080 } else {
4081 km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 4081 km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
4082 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 4082 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
4083 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 4083 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
4084 i18n("KO/Pi Confirmation"),i18n("Current"), 4084 i18n("KO/Pi Confirmation"),i18n("Current"),
4085 i18n("All")); 4085 i18n("All"));
4086 } 4086 }
4087 switch(km) { 4087 switch(km) {
4088 4088
4089 case KMessageBox::No: // Continue // all 4089 case KMessageBox::No: // Continue // all
4090 //qDebug("KMessageBox::No "); 4090 //qDebug("KMessageBox::No ");
4091 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 4091 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
4092 schedule(Scheduler::Cancel,anEvent); 4092 schedule(Scheduler::Cancel,anEvent);
4093 4093
4094 checkExternalId( anEvent); 4094 checkExternalId( anEvent);
4095 mCalendar->deleteEvent(anEvent); 4095 mCalendar->deleteEvent(anEvent);
4096 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 4096 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
4097 break; 4097 break;
4098 4098
4099 // Disabled because it does not work 4099 // Disabled because it does not work
4100 //#if 0 4100 //#if 0
4101 case KMessageBox::Yes: // just this one 4101 case KMessageBox::Yes: // just this one
4102 //QDate qd = mNavigator->selectedDates().first(); 4102 //QDate qd = mNavigator->selectedDates().first();
4103 //if (!qd.isValid()) { 4103 //if (!qd.isValid()) {
4104 // kdDebug() << "no date selected, or invalid date" << endl; 4104 // kdDebug() << "no date selected, or invalid date" << endl;
4105 // KNotifyClient::beep(); 4105 // KNotifyClient::beep();
4106 // return; 4106 // return;
4107 //} 4107 //}
4108 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 4108 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
4109 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 4109 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
4110 anEvent->addExDate(itemDate); 4110 anEvent->addExDate(itemDate);
4111 int duration = anEvent->recurrence()->duration(); 4111 int duration = anEvent->recurrence()->duration();
4112 if ( duration > 0 ) { 4112 if ( duration > 0 ) {
4113 anEvent->recurrence()->setDuration( duration - 1 ); 4113 anEvent->recurrence()->setDuration( duration - 1 );
4114 } 4114 }
4115 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 4115 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
4116 } 4116 }
4117 break; 4117 break;
4118 //#endif 4118 //#endif
4119 } // switch 4119 } // switch
4120 } else { 4120 } else {
4121 if (KOPrefs::instance()->mConfirm) { 4121 if (KOPrefs::instance()->mConfirm) {
4122 switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + 4122 switch (KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) +
4123 i18n("\nAre you sure you want\nto delete this event?"), 4123 i18n("\nAre you sure you want\nto delete this event?"),
4124 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 4124 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
4125 case KMessageBox::Continue: // OK 4125 case KMessageBox::Continue: // OK
4126 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 4126 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
4127 schedule(Scheduler::Cancel,anEvent); 4127 schedule(Scheduler::Cancel,anEvent);
4128 checkExternalId( anEvent); 4128 checkExternalId( anEvent);
4129 mCalendar->deleteEvent(anEvent); 4129 mCalendar->deleteEvent(anEvent);
4130 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 4130 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
4131 break; 4131 break;
4132 } // switch 4132 } // switch
4133 } else { 4133 } else {
4134 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 4134 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
4135 schedule(Scheduler::Cancel,anEvent); 4135 schedule(Scheduler::Cancel,anEvent);
4136 checkExternalId( anEvent); 4136 checkExternalId( anEvent);
4137 mCalendar->deleteEvent(anEvent); 4137 mCalendar->deleteEvent(anEvent);
4138 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 4138 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
4139 } 4139 }
4140 } // if-else 4140 } // if-else
4141 emit updateSearchDialog(); 4141 emit updateSearchDialog();
4142} 4142}
4143 4143
4144bool CalendarView::deleteEvent(const QString &uid) 4144bool CalendarView::deleteEvent(const QString &uid)
4145{ 4145{
4146 Event *ev = mCalendar->event(uid); 4146 Event *ev = mCalendar->event(uid);
4147 if (ev) { 4147 if (ev) {
4148 deleteEvent(ev); 4148 deleteEvent(ev);
4149 return true; 4149 return true;
4150 } else { 4150 } else {
4151 return false; 4151 return false;
4152 } 4152 }
4153} 4153}
4154 4154
4155/*****************************************************************************/ 4155/*****************************************************************************/
4156 4156
4157void CalendarView::action_mail() 4157void CalendarView::action_mail()
4158{ 4158{
4159#ifndef KORG_NOMAIL 4159#ifndef KORG_NOMAIL
4160 KOMailClient mailClient; 4160 KOMailClient mailClient;
4161 4161
4162 Incidence *incidence = currentSelection(); 4162 Incidence *incidence = currentSelection();
4163 4163
4164 if (!incidence) { 4164 if (!incidence) {
4165 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 4165 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
4166 return; 4166 return;
4167 } 4167 }
4168 if(incidence->attendeeCount() == 0 ) { 4168 if(incidence->attendeeCount() == 0 ) {
4169 KMessageBox::sorry(this, 4169 KMessageBox::sorry(this,
4170 i18n("Can't generate mail:\nNo attendees defined.\n")); 4170 i18n("Can't generate mail:\nNo attendees defined.\n"));
4171 return; 4171 return;
4172 } 4172 }
4173 4173
4174 CalendarLocal cal_tmp; 4174 CalendarLocal cal_tmp;
4175 Event *event = 0; 4175 Event *event = 0;
4176 Event *ev = 0; 4176 Event *ev = 0;
4177 if ( incidence && incidence->typeID() == eventID ) { 4177 if ( incidence && incidence->typeID() == eventID ) {
4178 event = static_cast<Event *>(incidence); 4178 event = static_cast<Event *>(incidence);
4179 ev = new Event(*event); 4179 ev = new Event(*event);
4180 cal_tmp.addEvent(ev); 4180 cal_tmp.addEvent(ev);
4181 } 4181 }
4182 ICalFormat mForm(); 4182 ICalFormat mForm();
4183 QString attachment = mForm.toString( &cal_tmp ); 4183 QString attachment = mForm.toString( &cal_tmp );
4184 if (ev) delete(ev); 4184 if (ev) delete(ev);
4185 4185
4186 mailClient.mailAttendees(currentSelection(), attachment); 4186 mailClient.mailAttendees(currentSelection(), attachment);
4187 4187
4188#endif 4188#endif
4189 4189
4190#if 0 4190#if 0
4191 Event *anEvent = 0; 4191 Event *anEvent = 0;
4192 if (mViewManager->currentView()->isEventView()) { 4192 if (mViewManager->currentView()->isEventView()) {
4193 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 4193 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
4194 } 4194 }
4195 4195
4196 if (!anEvent) { 4196 if (!anEvent) {
4197 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 4197 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
4198 return; 4198 return;
4199 } 4199 }
4200 if(anEvent->attendeeCount() == 0 ) { 4200 if(anEvent->attendeeCount() == 0 ) {
4201 KMessageBox::sorry(this, 4201 KMessageBox::sorry(this,
4202 i18n("Can't generate mail:\nNo attendees defined.\n")); 4202 i18n("Can't generate mail:\nNo attendees defined.\n"));
4203 return; 4203 return;
4204 } 4204 }
4205 4205
4206 mailobject.emailEvent(anEvent); 4206 mailobject.emailEvent(anEvent);
4207#endif 4207#endif
4208} 4208}
4209 4209
4210 4210
4211void CalendarView::schedule_publish(Incidence *incidence) 4211void CalendarView::schedule_publish(Incidence *incidence)
4212{ 4212{
4213 Event *event = 0; 4213 Event *event = 0;
4214 Todo *todo = 0; 4214 Todo *todo = 0;
4215 4215
4216 if (incidence == 0) { 4216 if (incidence == 0) {
4217 incidence = mViewManager->currentView()->selectedIncidences().first(); 4217 incidence = mViewManager->currentView()->selectedIncidences().first();
4218 if (incidence == 0) { 4218 if (incidence == 0) {
4219 incidence = mTodoList->selectedIncidences().first(); 4219 incidence = mTodoList->selectedIncidences().first();
4220 } 4220 }
4221 } 4221 }
4222 if ( incidence && incidence->typeID() == eventID ) { 4222 if ( incidence && incidence->typeID() == eventID ) {
4223 event = static_cast<Event *>(incidence); 4223 event = static_cast<Event *>(incidence);
4224 } else { 4224 } else {
4225 if ( incidence && incidence->typeID() == todoID ) { 4225 if ( incidence && incidence->typeID() == todoID ) {
4226 todo = static_cast<Todo *>(incidence); 4226 todo = static_cast<Todo *>(incidence);
4227 } 4227 }
4228 } 4228 }
4229 4229
4230 if (!event && !todo) { 4230 if (!event && !todo) {
4231 KMessageBox::sorry(this,i18n("No event selected.")); 4231 KMessageBox::sorry(this,i18n("No event selected."));
4232 return; 4232 return;
4233 } 4233 }
4234 4234
4235 PublishDialog *publishdlg = new PublishDialog(); 4235 PublishDialog *publishdlg = new PublishDialog();
4236 if (incidence->attendeeCount()>0) { 4236 if (incidence->attendeeCount()>0) {
4237 QPtrList<Attendee> attendees = incidence->attendees(); 4237 QPtrList<Attendee> attendees = incidence->attendees();
4238 attendees.first(); 4238 attendees.first();
4239 while ( attendees.current()!=0 ) { 4239 while ( attendees.current()!=0 ) {
4240 publishdlg->addAttendee(attendees.current()); 4240 publishdlg->addAttendee(attendees.current());
4241 attendees.next(); 4241 attendees.next();
4242 } 4242 }
4243 } 4243 }
4244 bool send = true; 4244 bool send = true;
4245 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 4245 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
4246 if ( publishdlg->exec() != QDialog::Accepted ) 4246 if ( publishdlg->exec() != QDialog::Accepted )
4247 send = false; 4247 send = false;
4248 } 4248 }
4249 if ( send ) { 4249 if ( send ) {
4250 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4250 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4251 if ( event ) { 4251 if ( event ) {
4252 Event *ev = new Event(*event); 4252 Event *ev = new Event(*event);
4253 ev->registerObserver(0); 4253 ev->registerObserver(0);
4254 ev->clearAttendees(); 4254 ev->clearAttendees();
4255 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 4255 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
4256 delete(ev); 4256 delete(ev);
4257 } 4257 }
4258 } else { 4258 } else {
4259 if ( todo ) { 4259 if ( todo ) {
4260 Todo *ev = new Todo(*todo); 4260 Todo *ev = new Todo(*todo);
4261 ev->registerObserver(0); 4261 ev->registerObserver(0);
4262 ev->clearAttendees(); 4262 ev->clearAttendees();
4263 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 4263 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
4264 delete(ev); 4264 delete(ev);
4265 } 4265 }
4266 } 4266 }
4267 } 4267 }
4268 } 4268 }
4269 delete publishdlg; 4269 delete publishdlg;
4270} 4270}
4271 4271
4272void CalendarView::schedule_request(Incidence *incidence) 4272void CalendarView::schedule_request(Incidence *incidence)
4273{ 4273{
4274 schedule(Scheduler::Request,incidence); 4274 schedule(Scheduler::Request,incidence);
4275} 4275}
4276 4276
4277void CalendarView::schedule_refresh(Incidence *incidence) 4277void CalendarView::schedule_refresh(Incidence *incidence)
4278{ 4278{
4279 schedule(Scheduler::Refresh,incidence); 4279 schedule(Scheduler::Refresh,incidence);
4280} 4280}
4281 4281
4282void CalendarView::schedule_cancel(Incidence *incidence) 4282void CalendarView::schedule_cancel(Incidence *incidence)
4283{ 4283{
4284 schedule(Scheduler::Cancel,incidence); 4284 schedule(Scheduler::Cancel,incidence);
4285} 4285}
4286 4286
4287void CalendarView::schedule_add(Incidence *incidence) 4287void CalendarView::schedule_add(Incidence *incidence)
4288{ 4288{
4289 schedule(Scheduler::Add,incidence); 4289 schedule(Scheduler::Add,incidence);
4290} 4290}
4291 4291
4292void CalendarView::schedule_reply(Incidence *incidence) 4292void CalendarView::schedule_reply(Incidence *incidence)
4293{ 4293{
4294 schedule(Scheduler::Reply,incidence); 4294 schedule(Scheduler::Reply,incidence);
4295} 4295}
4296 4296
4297void CalendarView::schedule_counter(Incidence *incidence) 4297void CalendarView::schedule_counter(Incidence *incidence)
4298{ 4298{
4299 schedule(Scheduler::Counter,incidence); 4299 schedule(Scheduler::Counter,incidence);
4300} 4300}
4301 4301
4302void CalendarView::schedule_declinecounter(Incidence *incidence) 4302void CalendarView::schedule_declinecounter(Incidence *incidence)
4303{ 4303{
4304 schedule(Scheduler::Declinecounter,incidence); 4304 schedule(Scheduler::Declinecounter,incidence);
4305} 4305}
4306 4306
4307void CalendarView::schedule_publish_freebusy(int daysToPublish) 4307void CalendarView::schedule_publish_freebusy(int daysToPublish)
4308{ 4308{
4309 QDateTime start = QDateTime::currentDateTime(); 4309 QDateTime start = QDateTime::currentDateTime();
4310 QDateTime end = start.addDays(daysToPublish); 4310 QDateTime end = start.addDays(daysToPublish);
4311 4311
4312 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 4312 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
4313 freebusy->setOrganizer(KOPrefs::instance()->email()); 4313 freebusy->setOrganizer(KOPrefs::instance()->email());
4314 4314
4315 4315
4316 PublishDialog *publishdlg = new PublishDialog(); 4316 PublishDialog *publishdlg = new PublishDialog();
4317 if ( publishdlg->exec() == QDialog::Accepted ) { 4317 if ( publishdlg->exec() == QDialog::Accepted ) {
4318 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4318 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4319 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 4319 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
4320 delete(freebusy); 4320 delete(freebusy);
4321 } 4321 }
4322 } 4322 }
4323 delete publishdlg; 4323 delete publishdlg;
4324} 4324}
4325 4325
4326void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 4326void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
4327{ 4327{
4328 Event *event = 0; 4328 Event *event = 0;
4329 Todo *todo = 0; 4329 Todo *todo = 0;
4330 4330
4331 if (incidence == 0) { 4331 if (incidence == 0) {
4332 incidence = mViewManager->currentView()->selectedIncidences().first(); 4332 incidence = mViewManager->currentView()->selectedIncidences().first();
4333 if (incidence == 0) { 4333 if (incidence == 0) {
4334 incidence = mTodoList->selectedIncidences().first(); 4334 incidence = mTodoList->selectedIncidences().first();
4335 } 4335 }
4336 } 4336 }
4337 if ( incidence && incidence->typeID() == eventID ) { 4337 if ( incidence && incidence->typeID() == eventID ) {
4338 event = static_cast<Event *>(incidence); 4338 event = static_cast<Event *>(incidence);
4339 } 4339 }
4340 if ( incidence && incidence->typeID() == todoID ) { 4340 if ( incidence && incidence->typeID() == todoID ) {
4341 todo = static_cast<Todo *>(incidence); 4341 todo = static_cast<Todo *>(incidence);
4342 } 4342 }
4343 4343
4344 if (!event && !todo) { 4344 if (!event && !todo) {
4345 KMessageBox::sorry(this,i18n("No event selected.")); 4345 KMessageBox::sorry(this,i18n("No event selected."));
4346 return; 4346 return;
4347 } 4347 }
4348 4348
4349 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 4349 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
4350 KMessageBox::sorry(this,i18n("The event has no attendees.")); 4350 KMessageBox::sorry(this,i18n("The event has no attendees."));
4351 return; 4351 return;
4352 } 4352 }
4353 4353
4354 Event *ev = 0; 4354 Event *ev = 0;
4355 if (event) ev = new Event(*event); 4355 if (event) ev = new Event(*event);
4356 Todo *to = 0; 4356 Todo *to = 0;
4357 if (todo) to = new Todo(*todo); 4357 if (todo) to = new Todo(*todo);
4358 4358
4359 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 4359 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
4360 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 4360 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
4361 if (!me) { 4361 if (!me) {
4362 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 4362 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
4363 return; 4363 return;
4364 } 4364 }
4365 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 4365 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
4366 StatusDialog *statdlg = new StatusDialog(this); 4366 StatusDialog *statdlg = new StatusDialog(this);
4367 if (!statdlg->exec()==QDialog::Accepted) return; 4367 if (!statdlg->exec()==QDialog::Accepted) return;
4368 me->setStatus( statdlg->status() ); 4368 me->setStatus( statdlg->status() );
4369 delete(statdlg); 4369 delete(statdlg);
4370 } 4370 }
4371 Attendee *menew = new Attendee(*me); 4371 Attendee *menew = new Attendee(*me);
4372 if (ev) { 4372 if (ev) {
4373 ev->clearAttendees(); 4373 ev->clearAttendees();
4374 ev->addAttendee(menew,false); 4374 ev->addAttendee(menew,false);
4375 } else { 4375 } else {
4376 if (to) { 4376 if (to) {
4377 todo->clearAttendees(); 4377 todo->clearAttendees();
4378 todo->addAttendee(menew,false); 4378 todo->addAttendee(menew,false);
4379 } 4379 }
4380 } 4380 }
4381 } 4381 }
4382 4382
4383 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4383 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4384 if (ev) { 4384 if (ev) {
4385 if ( !dlg->addMessage(ev,method) ) delete(ev); 4385 if ( !dlg->addMessage(ev,method) ) delete(ev);
4386 } else { 4386 } else {
4387 if (to) { 4387 if (to) {
4388 if ( !dlg->addMessage(to,method) ) delete(to); 4388 if ( !dlg->addMessage(to,method) ) delete(to);
4389 } 4389 }
4390 } 4390 }
4391} 4391}
4392 4392
4393void CalendarView::openAddressbook() 4393void CalendarView::openAddressbook()
4394{ 4394{
4395 KRun::runCommand("kaddressbook"); 4395 KRun::runCommand("kaddressbook");
4396} 4396}
4397 4397
4398void CalendarView::setModified(bool modified) 4398void CalendarView::setModified(bool modified)
4399{ 4399{
4400 //qDebug("CalendarView::setModified %d ", modified); 4400 //qDebug("CalendarView::setModified %d ", modified);
4401 if ( modified ) 4401 if ( modified )
4402 emit signalmodified(); 4402 emit signalmodified();
4403 mModified = modified; 4403 mModified = modified;
4404 if ( mModified ) 4404 if ( mModified )
4405 emit modifiedChanged(mModified); 4405 emit modifiedChanged(mModified);
4406 4406
4407} 4407}
4408 4408
4409bool CalendarView::isReadOnly() 4409bool CalendarView::isReadOnly()
4410{ 4410{
4411 return mReadOnly; 4411 return mReadOnly;
4412} 4412}
4413 4413
4414void CalendarView::setReadOnly(bool readOnly) 4414void CalendarView::setReadOnly(bool readOnly)
4415{ 4415{
4416 if (mReadOnly != readOnly) { 4416 if (mReadOnly != readOnly) {
4417 mReadOnly = readOnly; 4417 mReadOnly = readOnly;
4418 emit readOnlyChanged(mReadOnly); 4418 emit readOnlyChanged(mReadOnly);
4419 } 4419 }
4420} 4420}
4421 4421
4422bool CalendarView::isModified() 4422bool CalendarView::isModified()
4423{ 4423{
4424 return mModified; 4424 return mModified;
4425} 4425}
4426void CalendarView::slotprintSelInc() 4426void CalendarView::slotprintSelInc()
4427{ 4427{
4428 if ( currentSelection() == 0 ) { 4428 if ( currentSelection() == 0 ) {
4429 KMessageBox::sorry(this,i18n("There is nothing selected!")); 4429 KMessageBox::sorry(this,i18n("There is nothing selected!"));
4430 return; 4430 return;
4431 } 4431 }
4432 showIncidence(); 4432 showIncidence();
4433 getEventViewerDialog()->print(); 4433 getEventViewerDialog()->print();
4434 4434
4435} 4435}
4436void CalendarView::printSetup() 4436void CalendarView::printSetup()
4437{ 4437{
4438#ifndef KORG_NOPRINTER 4438#ifndef KORG_NOPRINTER
4439 createPrinter(); 4439 createPrinter();
4440 4440
4441 mCalPrinter->setupPrinter(); 4441 mCalPrinter->setupPrinter();
4442#endif 4442#endif
4443} 4443}
4444 4444
4445void CalendarView::print() 4445void CalendarView::print()
4446{ 4446{
4447#ifndef KORG_NOPRINTER 4447#ifndef KORG_NOPRINTER
4448 createPrinter(); 4448 createPrinter();
4449 4449
4450 DateList tmpDateList = mNavigator->selectedDates(); 4450 DateList tmpDateList = mNavigator->selectedDates();
4451 mCalPrinter->print(CalPrinter::Month, 4451 mCalPrinter->print(CalPrinter::Month,
4452 tmpDateList.first(), tmpDateList.last()); 4452 tmpDateList.first(), tmpDateList.last());
4453#endif 4453#endif
4454} 4454}
4455 4455
4456void CalendarView::printPreview() 4456void CalendarView::printPreview()
4457{ 4457{
4458#ifndef KORG_NOPRINTER 4458#ifndef KORG_NOPRINTER
4459 kdDebug() << "CalendarView::printPreview()" << endl; 4459 kdDebug() << "CalendarView::printPreview()" << endl;
4460 4460
4461 createPrinter(); 4461 createPrinter();
4462 4462
4463 DateList tmpDateList = mNavigator->selectedDates(); 4463 DateList tmpDateList = mNavigator->selectedDates();
4464 4464
4465 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 4465 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
4466 tmpDateList.last()); 4466 tmpDateList.last());
4467#endif 4467#endif
4468} 4468}
4469bool CalendarView::exportICalendar( QString filename ) 4469bool CalendarView::exportICalendar( QString filename )
4470{ 4470{
4471 // Force correct extension 4471 // Force correct extension
4472 if (filename.right(4) != ".ics") filename += ".ics"; 4472 if (filename.right(4) != ".ics") filename += ".ics";
4473 4473
4474 FileStorage storage( mCalendar, filename, new ICalFormat() ); 4474 FileStorage storage( mCalendar, filename, new ICalFormat() );
4475 return storage.save(); 4475 return storage.save();
4476} 4476}
4477 4477
4478bool CalendarView::exportICalendar() 4478bool CalendarView::exportICalendar()
4479{ 4479{
4480 return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) ); 4480 return exportICalendar( KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this) );
4481} 4481}
4482 4482
4483bool CalendarView::exportVCalendar( QString filename ) 4483bool CalendarView::exportVCalendar( QString filename )
4484{ 4484{
4485 if (mCalendar->journals().count() > 0) { 4485 if (mCalendar->journals().count() > 0) {
4486 int result = KMessageBox::warningContinueCancel(this, 4486 int result = KMessageBox::warningContinueCancel(this,
4487 i18n("The journal entries can not be\nexported to a vCalendar file."), 4487 i18n("The journal entries can not be\nexported to a vCalendar file."),
4488 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 4488 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
4489 true); 4489 true);
4490 if (result != KMessageBox::Continue) return false; 4490 if (result != KMessageBox::Continue) return false;
4491 } 4491 }
4492 4492
4493 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 4493 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
4494 4494
4495 // Force correct extension 4495 // Force correct extension
4496 if (filename.right(4) != ".vcs") filename += ".vcs"; 4496 if (filename.right(4) != ".vcs") filename += ".vcs";
4497 4497
4498 FileStorage storage( mCalendar, filename, new VCalFormat ); 4498 FileStorage storage( mCalendar, filename, new VCalFormat );
4499 return storage.save(); 4499 return storage.save();
4500 4500
4501} 4501}
4502 4502
4503void CalendarView::eventUpdated(Incidence *) 4503void CalendarView::eventUpdated(Incidence *)
4504{ 4504{
4505 setModified(); 4505 setModified();
4506 // Don't call updateView here. The code, which has caused the update of the 4506 // Don't call updateView here. The code, which has caused the update of the
4507 // event is responsible for updating the view. 4507 // event is responsible for updating the view.
4508 // updateView(); 4508 // updateView();
4509} 4509}
4510 4510
4511void CalendarView::adaptNavigationUnits() 4511void CalendarView::adaptNavigationUnits()
4512{ 4512{
4513 if (mViewManager->currentView()->isEventView()) { 4513 if (mViewManager->currentView()->isEventView()) {
4514 int days = mViewManager->currentView()->currentDateCount(); 4514 int days = mViewManager->currentView()->currentDateCount();
4515 if (days == 1) { 4515 if (days == 1) {
4516 emit changeNavStringPrev(i18n("&Previous Day")); 4516 emit changeNavStringPrev(i18n("&Previous Day"));
4517 emit changeNavStringNext(i18n("&Next Day")); 4517 emit changeNavStringNext(i18n("&Next Day"));
4518 } else { 4518 } else {
4519 emit changeNavStringPrev(i18n("&Previous Week")); 4519 emit changeNavStringPrev(i18n("&Previous Week"));
4520 emit changeNavStringNext(i18n("&Next Week")); 4520 emit changeNavStringNext(i18n("&Next Week"));
4521 } 4521 }
4522 } 4522 }
4523} 4523}
4524 4524
4525void CalendarView::processMainViewSelection( Incidence *incidence ) 4525void CalendarView::processMainViewSelection( Incidence *incidence )
4526{ 4526{
4527 if ( incidence ) mTodoList->clearSelection(); 4527 if ( incidence ) mTodoList->clearSelection();
4528 processIncidenceSelection( incidence ); 4528 processIncidenceSelection( incidence );
4529} 4529}
4530 4530
4531void CalendarView::processTodoListSelection( Incidence *incidence ) 4531void CalendarView::processTodoListSelection( Incidence *incidence )
4532{ 4532{
4533 if ( incidence && mViewManager->currentView() ) { 4533 if ( incidence && mViewManager->currentView() ) {
4534 mViewManager->currentView()->clearSelection(); 4534 mViewManager->currentView()->clearSelection();
4535 } 4535 }
4536 processIncidenceSelection( incidence ); 4536 processIncidenceSelection( incidence );
4537} 4537}
4538 4538
4539void CalendarView::processIncidenceSelection( Incidence *incidence ) 4539void CalendarView::processIncidenceSelection( Incidence *incidence )
4540{ 4540{
4541 emit incidenceSelected( incidence ); 4541 emit incidenceSelected( incidence );
4542 if ( incidence == mSelectedIncidence ) return; 4542 if ( incidence == mSelectedIncidence ) return;
4543 mSelectedIncidence = incidence; 4543 mSelectedIncidence = incidence;
4544 4544
4545 if ( incidence && incidence->typeID() == eventID ) { 4545 if ( incidence && incidence->typeID() == eventID ) {
4546 Event *event = static_cast<Event *>( incidence ); 4546 Event *event = static_cast<Event *>( incidence );
4547 if ( event->organizer() == KOPrefs::instance()->email() ) { 4547 if ( event->organizer() == KOPrefs::instance()->email() ) {
4548 emit organizerEventsSelected( true ); 4548 emit organizerEventsSelected( true );
4549 } else { 4549 } else {
4550 emit organizerEventsSelected(false); 4550 emit organizerEventsSelected(false);
4551 } 4551 }
4552 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4552 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4553 KOPrefs::instance()->email() ) ) { 4553 KOPrefs::instance()->email() ) ) {
4554 emit groupEventsSelected( true ); 4554 emit groupEventsSelected( true );
4555 } else { 4555 } else {
4556 emit groupEventsSelected(false); 4556 emit groupEventsSelected(false);
4557 } 4557 }
4558 return; 4558 return;
4559 } else { 4559 } else {
4560 if ( incidence && incidence->typeID() == todoID ) { 4560 if ( incidence && incidence->typeID() == todoID ) {
4561 emit todoSelected( true ); 4561 emit todoSelected( true );
4562 Todo *event = static_cast<Todo *>( incidence ); 4562 Todo *event = static_cast<Todo *>( incidence );
4563 if ( event->organizer() == KOPrefs::instance()->email() ) { 4563 if ( event->organizer() == KOPrefs::instance()->email() ) {
4564 emit organizerEventsSelected( true ); 4564 emit organizerEventsSelected( true );
4565 } else { 4565 } else {
4566 emit organizerEventsSelected(false); 4566 emit organizerEventsSelected(false);
4567 } 4567 }
4568 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 4568 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
4569 KOPrefs::instance()->email() ) ) { 4569 KOPrefs::instance()->email() ) ) {
4570 emit groupEventsSelected( true ); 4570 emit groupEventsSelected( true );
4571 } else { 4571 } else {
4572 emit groupEventsSelected(false); 4572 emit groupEventsSelected(false);
4573 } 4573 }
4574 return; 4574 return;
4575 } else { 4575 } else {
4576 emit todoSelected( false ); 4576 emit todoSelected( false );
4577 emit organizerEventsSelected(false); 4577 emit organizerEventsSelected(false);
4578 emit groupEventsSelected(false); 4578 emit groupEventsSelected(false);
4579 } 4579 }
4580 return; 4580 return;
4581 } 4581 }
4582 4582
4583 /* if ( incidence && incidence->typeID() == todoID ) { 4583 /* if ( incidence && incidence->typeID() == todoID ) {
4584 emit todoSelected( true ); 4584 emit todoSelected( true );
4585 } else { 4585 } else {
4586 emit todoSelected( false ); 4586 emit todoSelected( false );
4587 }*/ 4587 }*/
4588} 4588}
4589 4589
4590 4590
4591void CalendarView::checkClipboard() 4591void CalendarView::checkClipboard()
4592{ 4592{
4593#ifndef KORG_NODND 4593#ifndef KORG_NODND
4594 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 4594 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
4595 emit pasteEnabled(true); 4595 emit pasteEnabled(true);
4596 } else { 4596 } else {
4597 emit pasteEnabled(false); 4597 emit pasteEnabled(false);
4598 } 4598 }
4599#endif 4599#endif
4600} 4600}
4601 4601
4602void CalendarView::showDates(const DateList &selectedDates) 4602void CalendarView::showDates(const DateList &selectedDates)
4603{ 4603{
4604 // kdDebug() << "CalendarView::selectDates()" << endl; 4604 // kdDebug() << "CalendarView::selectDates()" << endl;
4605 4605
4606 4606
4607 if ( !mBlockShowDates ) { 4607 if ( !mBlockShowDates ) {
4608 if ( mViewManager->currentView() ) { 4608 if ( mViewManager->currentView() ) {
4609 updateView( selectedDates.first(), selectedDates.last() ); 4609 updateView( selectedDates.first(), selectedDates.last() );
4610 } else { 4610 } else {
4611 mViewManager->showAgendaView(); 4611 mViewManager->showAgendaView();
4612 } 4612 }
4613 } 4613 }
4614 4614
4615 QDate date = selectedDates.first(); 4615 QDate date = selectedDates.first();
4616 if ( ! date.isValid() ) { 4616 if ( ! date.isValid() ) {
4617 topLevelWidget()->setCaption(""); 4617 topLevelWidget()->setCaption("");
4618 return; 4618 return;
4619 } 4619 }
4620 4620
4621 QString selDates; 4621 QString selDates;
4622 selDates = KGlobal::locale()->formatDate( date, true); 4622 selDates = KGlobal::locale()->formatDate( date, true);
4623 if (selectedDates.first() < selectedDates.last() ) 4623 if (selectedDates.first() < selectedDates.last() )
4624 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 4624 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
4625 else { 4625 else {
4626 QString addString; 4626 QString addString;
4627 if ( date == QDateTime::currentDateTime().date() ) 4627 if ( date == QDateTime::currentDateTime().date() )
4628 addString = i18n("Today"); 4628 addString = i18n("Today");
4629 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 4629 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
4630 addString = i18n("Tomorrow"); 4630 addString = i18n("Tomorrow");
4631 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 4631 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
4632 addString = i18n("Yesterday"); 4632 addString = i18n("Yesterday");
4633 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 4633 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
4634 addString = i18n("Day before yesterday"); 4634 addString = i18n("Day before yesterday");
4635 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 4635 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
4636 addString = i18n("Day after tomorrow"); 4636 addString = i18n("Day after tomorrow");
4637 if ( !addString.isEmpty() ) { 4637 if ( !addString.isEmpty() ) {
4638 topLevelWidget()->setCaption( addString+", " + selDates ); 4638 topLevelWidget()->setCaption( addString+", " + selDates );
4639 return; 4639 return;
4640 } 4640 }
4641 } 4641 }
4642 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 4642 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
4643 4643
4644} 4644}
4645 4645
4646QPtrList<CalFilter> CalendarView::filters() 4646QPtrList<CalFilter> CalendarView::filters()
4647{ 4647{
4648 return mFilters; 4648 return mFilters;
4649 4649
4650} 4650}
4651void CalendarView::editFilters() 4651void CalendarView::editFilters()
4652{ 4652{
4653 // kdDebug() << "CalendarView::editFilters()" << endl; 4653 // kdDebug() << "CalendarView::editFilters()" << endl;
4654 4654
4655 CalFilter *filter = mFilters.first(); 4655 CalFilter *filter = mFilters.first();
4656 while(filter) { 4656 while(filter) {
4657 filter = mFilters.next(); 4657 filter = mFilters.next();
4658 } 4658 }
4659 4659
4660 mDialogManager->showFilterEditDialog(&mFilters); 4660 mDialogManager->showFilterEditDialog(&mFilters);
4661 updateFilter(); 4661 updateFilter();
4662} 4662}
4663void CalendarView::toggleFilter() 4663void CalendarView::toggleFilter()
4664{ 4664{
4665 if ( mLeftFrame->isHidden() ) { 4665 if ( mLeftFrame->isHidden() ) {
4666 toggleExpand(); 4666 toggleExpand();
4667 showFilter( true ); 4667 showFilter( true );
4668 } else 4668 } else
4669 showFilter(! mCalEditView->isVisible()); 4669 showFilter(! mCalEditView->isVisible());
4670} 4670}
4671 4671
4672KOFilterView *CalendarView::filterView() 4672KOFilterView *CalendarView::filterView()
4673{ 4673{
4674 return mFilterView; 4674 return mFilterView;
4675} 4675}
4676void CalendarView::selectFilter( int fil ) 4676void CalendarView::selectFilter( int fil )
4677{ 4677{
4678 mFilterView->setSelectedFilter( fil ); 4678 mFilterView->setSelectedFilter( fil );
4679 updateUnmanagedViews(); 4679 updateUnmanagedViews();
4680} 4680}
4681void CalendarView::showFilter(bool visible) 4681void CalendarView::showFilter(bool visible)
4682{ 4682{
4683#if 1 4683#if 1
4684 if (visible) { 4684 if (visible) {
4685 mCalEditView->readConfig(); 4685 mCalEditView->readConfig();
4686 mCalEditView->show(); 4686 mCalEditView->show();
4687 QValueList<int> sizes; 4687 QValueList<int> sizes;
4688 sizes = mLeftFrame->sizes(); 4688 sizes = mLeftFrame->sizes();
4689 if ( sizes.count() == 4 && sizes[3] < 20 ) { 4689 if ( sizes.count() == 4 && sizes[3] < 20 ) {
4690 sizes.clear(); 4690 sizes.clear();
4691 sizes << 100; 4691 sizes << 100;
4692 sizes << 0; 4692 sizes << 0;
4693 sizes << 0; 4693 sizes << 0;
4694 sizes << 100; 4694 sizes << 100;
4695 mLeftFrame->setSizes(sizes); 4695 mLeftFrame->setSizes(sizes);
4696 } 4696 }
4697#if 0 4697#if 0
4698 sizes = mLeftFrame->sizes(); 4698 sizes = mLeftFrame->sizes();
4699 int ccc = 0; 4699 int ccc = 0;
4700 while ( ccc < sizes.count()) { 4700 while ( ccc < sizes.count()) {
4701 qDebug("size %d %d ", ccc, sizes[ccc]); 4701 qDebug("size %d %d ", ccc, sizes[ccc]);
4702 ++ccc; 4702 ++ccc;
4703 } 4703 }
4704#endif 4704#endif
4705 4705
4706 } 4706 }
4707 else { 4707 else {
4708 mCalEditView->hide(); 4708 mCalEditView->hide();
4709 } 4709 }
4710#else 4710#else
4711 if (visible) mFilterView->show(); 4711 if (visible) mFilterView->show();
4712 else mFilterView->hide(); 4712 else mFilterView->hide();
4713#endif 4713#endif
4714} 4714}
4715void CalendarView::toggleFilerEnabled( ) 4715void CalendarView::toggleFilerEnabled( )
4716{ 4716{
4717 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 4717 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
4718 if ( !mFilterView->filtersEnabled() ) 4718 if ( !mFilterView->filtersEnabled() )
4719 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 4719 topLevelWidget()->setCaption( i18n("Filter disabled ") );
4720 updateUnmanagedViews(); 4720 updateUnmanagedViews();
4721 4721
4722} 4722}
4723void CalendarView::updateFilter() 4723void CalendarView::updateFilter()
4724{ 4724{
4725 CalFilter *filter = mFilterView->selectedFilter(); 4725 CalFilter *filter = mFilterView->selectedFilter();
4726 if (filter) { 4726 if (filter) {
4727 QString mess; 4727 QString mess;
4728 if (mFilterView->filtersEnabled()) { 4728 if (mFilterView->filtersEnabled()) {
4729 mess = i18n("Filter selected: ")+filter->name(); 4729 mess = i18n("Filter selected: ")+filter->name();
4730 filter->setEnabled(true); 4730 filter->setEnabled(true);
4731 } 4731 }
4732 else filter->setEnabled(false); 4732 else filter->setEnabled(false);
4733 mCalendar->setFilter(filter); 4733 mCalendar->setFilter(filter);
4734 updateView(); 4734 updateView();
4735 if ( !mess.isEmpty() ) 4735 if ( !mess.isEmpty() )
4736 topLevelWidget()->setCaption( mess ); 4736 topLevelWidget()->setCaption( mess );
4737 4737
4738 } 4738 }
4739 emit filtersUpdated(); 4739 emit filtersUpdated();
4740} 4740}
4741 4741
4742void CalendarView::filterEdited() 4742void CalendarView::filterEdited()
4743{ 4743{
4744 mFilterView->updateFilters(); 4744 mFilterView->updateFilters();
4745 updateFilter(); 4745 updateFilter();
4746 writeSettings(); 4746 writeSettings();
4747} 4747}
4748 4748
4749 4749
4750void CalendarView::takeOverEvent() 4750void CalendarView::takeOverEvent()
4751{ 4751{
4752 Incidence *incidence = currentSelection(); 4752 Incidence *incidence = currentSelection();
4753 4753
4754 if (!incidence) return; 4754 if (!incidence) return;
4755 4755
4756 incidence->setOrganizer(KOPrefs::instance()->email()); 4756 incidence->setOrganizer(KOPrefs::instance()->email());
4757 incidence->recreate(); 4757 incidence->recreate();
4758 incidence->setReadOnly(false); 4758 incidence->setReadOnly(false);
4759 4759
4760 updateView(); 4760 updateView();
4761} 4761}
4762 4762
4763void CalendarView::takeOverCalendar() 4763void CalendarView::takeOverCalendar()
4764{ 4764{
4765 // TODO: Create Calendar::allIncidences() function and use it here 4765 // TODO: Create Calendar::allIncidences() function and use it here
4766 4766
4767 clearAllViews(); 4767 clearAllViews();
4768 QPtrList<Event> events = mCalendar->events(); 4768 QPtrList<Event> events = mCalendar->events();
4769 for(uint i=0; i<events.count(); ++i) { 4769 for(uint i=0; i<events.count(); ++i) {
4770 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4770 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4771 events.at(i)->recreate(); 4771 events.at(i)->recreate();
4772 events.at(i)->setReadOnly(false); 4772 events.at(i)->setReadOnly(false);
4773 } 4773 }
4774 4774
4775 QPtrList<Todo> todos = mCalendar->todos(); 4775 QPtrList<Todo> todos = mCalendar->todos();
4776 for(uint i=0; i<todos.count(); ++i) { 4776 for(uint i=0; i<todos.count(); ++i) {
4777 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4777 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4778 todos.at(i)->recreate(); 4778 todos.at(i)->recreate();
4779 todos.at(i)->setReadOnly(false); 4779 todos.at(i)->setReadOnly(false);
4780 } 4780 }
4781 4781
4782 QPtrList<Journal> journals = mCalendar->journals(); 4782 QPtrList<Journal> journals = mCalendar->journals();
4783 for(uint i=0; i<journals.count(); ++i) { 4783 for(uint i=0; i<journals.count(); ++i) {
4784 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4784 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4785 journals.at(i)->recreate(); 4785 journals.at(i)->recreate();
4786 journals.at(i)->setReadOnly(false); 4786 journals.at(i)->setReadOnly(false);
4787 } 4787 }
4788 4788
4789 updateView(); 4789 updateView();
4790} 4790}
4791 4791
4792void CalendarView::showIntro() 4792void CalendarView::showIntro()
4793{ 4793{
4794 kdDebug() << "To be implemented." << endl; 4794 kdDebug() << "To be implemented." << endl;
4795} 4795}
4796 4796
4797QWidgetStack *CalendarView::viewStack() 4797QWidgetStack *CalendarView::viewStack()
4798{ 4798{
4799 return mRightFrame; 4799 return mRightFrame;
4800} 4800}
4801 4801
4802QWidget *CalendarView::leftFrame() 4802QWidget *CalendarView::leftFrame()
4803{ 4803{
4804 return ( QWidget *)mLeftFrame; 4804 return ( QWidget *)mLeftFrame;
4805} 4805}
4806 4806
4807DateNavigator *CalendarView::dateNavigator() 4807DateNavigator *CalendarView::dateNavigator()
4808{ 4808{
4809 return mNavigator; 4809 return mNavigator;
4810} 4810}
4811 4811
4812KDateNavigator* CalendarView::dateNavigatorWidget() 4812KDateNavigator* CalendarView::dateNavigatorWidget()
4813{ 4813{
4814 return mDateNavigator->navigatorView(); 4814 return mDateNavigator->navigatorView();
4815} 4815}
4816void CalendarView::toggleDateNavigatorWidget() 4816void CalendarView::toggleDateNavigatorWidget()
4817{ 4817{
4818 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4818 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4819 4819
4820 if (!KOPrefs::instance()->mShowDateNavigator ) 4820 if (!KOPrefs::instance()->mShowDateNavigator )
4821 mDateNavigator->hide(); 4821 mDateNavigator->hide();
4822 else 4822 else
4823 mDateNavigator->show(); 4823 mDateNavigator->show();
4824} 4824}
4825void CalendarView::addView(KOrg::BaseView *view) 4825void CalendarView::addView(KOrg::BaseView *view)
4826{ 4826{
4827 mViewManager->addView(view); 4827 mViewManager->addView(view);
4828} 4828}
4829 4829
4830void CalendarView::showView(KOrg::BaseView *view) 4830void CalendarView::showView(KOrg::BaseView *view)
4831{ 4831{
4832 mViewManager->showView(view, mLeftFrame->isVisible()); 4832 mViewManager->showView(view, mLeftFrame->isVisible());
4833} 4833}
4834 4834
4835Incidence *CalendarView::currentSelection() 4835Incidence *CalendarView::currentSelection()
4836{ 4836{
4837 return mViewManager->currentSelection(); 4837 return mViewManager->currentSelection();
4838} 4838}
4839void CalendarView::toggleAllDaySize() 4839void CalendarView::toggleAllDaySize()
4840{ 4840{
4841 /* 4841 /*
4842 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4842 if ( KOPrefs::instance()->mAllDaySize > 47 )
4843 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4843 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4844 else 4844 else
4845 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4845 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4846 */ 4846 */
4847 viewManager()->agendaView()->toggleAllDay(); 4847 viewManager()->agendaView()->toggleAllDay();
4848} 4848}
4849void CalendarView::toggleExpand() 4849void CalendarView::toggleExpand()
4850{ 4850{
4851 // if ( mLeftFrame->isHidden() ) { 4851 // if ( mLeftFrame->isHidden() ) {
4852 // mLeftFrame->show(); 4852 // mLeftFrame->show();
4853 // emit calendarViewExpanded( false ); 4853 // emit calendarViewExpanded( false );
4854 // } else { 4854 // } else {
4855 // mLeftFrame->hide(); 4855 // mLeftFrame->hide();
4856 // emit calendarViewExpanded( true ); 4856 // emit calendarViewExpanded( true );
4857 // } 4857 // }
4858 //qDebug(" CalendarView::toggleExpand()"); 4858 //qDebug(" CalendarView::toggleExpand()");
4859 globalFlagBlockAgenda = 1; 4859 globalFlagBlockAgenda = 1;
4860 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4860 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4861 globalFlagBlockAgenda = 5; 4861 globalFlagBlockAgenda = 5;
4862 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4862 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4863 //mViewManager->showView( 0, true ); 4863 //mViewManager->showView( 0, true );
4864} 4864}
4865 4865
4866void CalendarView::calendarModified( bool modified, Calendar * ) 4866void CalendarView::calendarModified( bool modified, Calendar * )
4867{ 4867{
4868 setModified( modified ); 4868 setModified( modified );
4869} 4869}
4870 4870
4871Todo *CalendarView::selectedTodo() 4871Todo *CalendarView::selectedTodo()
4872{ 4872{
4873 Incidence *incidence = currentSelection(); 4873 Incidence *incidence = currentSelection();
4874 if ( incidence && incidence->typeID() == todoID ) { 4874 if ( incidence && incidence->typeID() == todoID ) {
4875 return static_cast<Todo *>( incidence ); 4875 return static_cast<Todo *>( incidence );
4876 } 4876 }
4877 4877
4878 incidence = mTodoList->selectedIncidences().first(); 4878 incidence = mTodoList->selectedIncidences().first();
4879 if ( incidence && incidence->typeID() == todoID ) { 4879 if ( incidence && incidence->typeID() == todoID ) {
4880 return static_cast<Todo *>( incidence ); 4880 return static_cast<Todo *>( incidence );
4881 } 4881 }
4882 4882
4883 return 0; 4883 return 0;
4884} 4884}
4885 4885
4886void CalendarView::showIncidence() 4886void CalendarView::showIncidence()
4887{ 4887{
4888 mViewerCallerIsSearchDialog = false; 4888 mViewerCallerIsSearchDialog = false;
4889 Incidence *incidence = currentSelection(); 4889 Incidence *incidence = currentSelection();
4890 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4890 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4891 if ( incidence ) { 4891 if ( incidence ) {
4892 ShowIncidenceVisitor v; 4892 ShowIncidenceVisitor v;
4893 v.act( incidence, this ); 4893 v.act( incidence, this );
4894 } 4894 }
4895} 4895}
4896void CalendarView::editIncidenceDescription() 4896void CalendarView::editIncidenceDescription()
4897{ 4897{
4898 mFlagEditDescription = true; 4898 mFlagEditDescription = true;
4899 editIncidence(); 4899 editIncidence();
4900 mFlagEditDescription = false; 4900 mFlagEditDescription = false;
4901} 4901}
4902void CalendarView::editIncidence() 4902void CalendarView::editIncidence()
4903{ 4903{
4904 // qDebug("editIncidence() "); 4904 // qDebug("editIncidence() ");
4905 Incidence *incidence = currentSelection(); 4905 Incidence *incidence = currentSelection();
4906 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4906 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4907 if ( incidence ) { 4907 if ( incidence ) {
4908 EditIncidenceVisitor v; 4908 EditIncidenceVisitor v;
4909 v.act( incidence, this ); 4909 v.act( incidence, this );
4910 } 4910 }
4911} 4911}
4912 4912
4913void CalendarView::deleteIncidence() 4913void CalendarView::deleteIncidence()
4914{ 4914{
4915 Incidence *incidence = currentSelection(); 4915 Incidence *incidence = currentSelection();
4916 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4916 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4917 if ( incidence ) { 4917 if ( incidence ) {
4918 deleteIncidence(incidence); 4918 deleteIncidence(incidence);
4919 } 4919 }
4920} 4920}
4921void CalendarView::showIncidence(QString uid) 4921void CalendarView::showIncidence(QString uid)
4922{ 4922{
4923 Incidence *inc = mCalendar->incidence( uid ); 4923 Incidence *inc = mCalendar->incidence( uid );
4924 if ( inc ) 4924 if ( inc )
4925 showIncidence( inc ); 4925 showIncidence( inc );
4926} 4926}
4927void CalendarView::showIncidence(Incidence *incidence) 4927void CalendarView::showIncidence(Incidence *incidence)
4928{ 4928{
4929 mViewerCallerIsSearchDialog = false; 4929 mViewerCallerIsSearchDialog = false;
4930 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4930 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4931 if ( sender() && mDialogManager->getSearchDialog() ) { 4931 if ( sender() && mDialogManager->getSearchDialog() ) {
4932 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4932 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4933 mViewerCallerIsSearchDialog = true; 4933 mViewerCallerIsSearchDialog = true;
4934 } 4934 }
4935 } 4935 }
4936 if ( incidence ) { 4936 if ( incidence ) {
4937 ShowIncidenceVisitor v; 4937 ShowIncidenceVisitor v;
4938 v.act( incidence, this ); 4938 v.act( incidence, this );
4939 } 4939 }
4940} 4940}
4941 4941
4942void CalendarView::editIncidence(Incidence *incidence) 4942void CalendarView::editIncidence(Incidence *incidence)
4943{ 4943{
4944 if ( incidence ) { 4944 if ( incidence ) {
4945 4945
4946 EditIncidenceVisitor v; 4946 EditIncidenceVisitor v;
4947 v.act( incidence, this ); 4947 v.act( incidence, this );
4948 4948
4949 } 4949 }
4950} 4950}
4951 4951
4952void CalendarView::deleteIncidence(Incidence *incidence) 4952void CalendarView::deleteIncidence(Incidence *incidence)
4953{ 4953{
4954 //qDebug(" CalendarView::deleteIncidence "); 4954 //qDebug(" CalendarView::deleteIncidence ");
4955 if ( incidence == 0 ) { 4955 if ( incidence == 0 ) {
4956 updateView(); 4956 updateView();
4957 emit updateSearchDialog(); 4957 emit updateSearchDialog();
4958 return; 4958 return;
4959 } 4959 }
4960 if ( incidence ) { 4960 if ( incidence ) {
4961 DeleteIncidenceVisitor v; 4961 DeleteIncidenceVisitor v;
4962 v.act( incidence, this ); 4962 v.act( incidence, this );
4963 } 4963 }
4964} 4964}
4965 4965
4966 4966
4967void CalendarView::lookForOutgoingMessages() 4967void CalendarView::lookForOutgoingMessages()
4968{ 4968{
4969 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4969 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4970 ogd->loadMessages(); 4970 ogd->loadMessages();
4971} 4971}
4972 4972
4973void CalendarView::lookForIncomingMessages() 4973void CalendarView::lookForIncomingMessages()
4974{ 4974{
4975 IncomingDialog *icd = mDialogManager->incomingDialog(); 4975 IncomingDialog *icd = mDialogManager->incomingDialog();
4976 icd->retrieve(); 4976 icd->retrieve();
4977} 4977}
4978 4978
4979bool CalendarView::removeCompletedSubTodos( Todo* t ) 4979bool CalendarView::removeCompletedSubTodos( Todo* t )
4980{ 4980{
4981 bool deleteTodo = true; 4981 bool deleteTodo = true;
4982 QPtrList<Incidence> subTodos; 4982 QPtrList<Incidence> subTodos;
4983 Incidence *aTodo; 4983 Incidence *aTodo;
4984 subTodos = t->relations(); 4984 subTodos = t->relations();
4985 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4985 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4986 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4986 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4987 deleteTodo = false; 4987 deleteTodo = false;
4988 } 4988 }
4989 if ( deleteTodo ) { 4989 if ( deleteTodo ) {
4990 if ( t->isCompleted() && !t->doesRecur()) { 4990 if ( t->isCompleted() && !t->doesRecur()) {
4991 checkExternalId( t ); 4991 checkExternalId( t );
4992 mCalendar->deleteTodo( t ); 4992 mCalendar->deleteTodo( t );
4993 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4993 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4994 } 4994 }
4995 else 4995 else
4996 deleteTodo = false; 4996 deleteTodo = false;
4997 } 4997 }
4998 return deleteTodo; 4998 return deleteTodo;
4999 4999
5000} 5000}
5001void CalendarView::purgeCompleted() 5001void CalendarView::purgeCompleted()
5002{ 5002{
5003 int result = KMessageBox::warningContinueCancel(this, 5003 int result = KMessageBox::warningContinueCancel(this,
5004 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 5004 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
5005 5005
5006 if (result == KMessageBox::Continue) { 5006 if (result == KMessageBox::Continue) {
5007 5007
5008 QPtrList<Todo> todoCal; 5008 QPtrList<Todo> todoCal;
5009 QPtrList<Todo> rootTodos; 5009 QPtrList<Todo> rootTodos;
5010 //QPtrList<Incidence> rel; 5010 //QPtrList<Incidence> rel;
5011 Todo *aTodo; 5011 Todo *aTodo;
5012 todoCal = calendar()->todos(); 5012 todoCal = calendar()->todos();
5013 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 5013 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
5014 if ( !aTodo->relatedTo() ) 5014 if ( !aTodo->relatedTo() )
5015 rootTodos.append( aTodo ); 5015 rootTodos.append( aTodo );
5016 } 5016 }
5017 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 5017 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
5018 removeCompletedSubTodos( aTodo ); 5018 removeCompletedSubTodos( aTodo );
5019 } 5019 }
5020 5020
5021 updateView(); 5021 updateView();
5022 } 5022 }
5023} 5023}
5024 5024
5025void CalendarView::slotCalendarChanged() 5025void CalendarView::slotCalendarChanged()
5026{ 5026{
5027 ; 5027 ;
5028} 5028}
5029 5029
5030void CalendarView::keyPressEvent ( QKeyEvent *e) 5030void CalendarView::keyPressEvent ( QKeyEvent *e)
5031{ 5031{
5032 //qDebug("CalendarView::keyPressEvent "); 5032 //qDebug("CalendarView::keyPressEvent ");
5033 e->ignore(); 5033 e->ignore();
5034} 5034}
5035 5035
5036 5036
5037bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 5037bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
5038{ 5038{
5039 5039
5040 if ( manager != mSyncManager) 5040 if ( manager != mSyncManager)
5041 qDebug("KO: Internal error-1. SyncManager mismatch "); 5041 qDebug("KO: Internal error-1. SyncManager mismatch ");
5042 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 5042 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
5043 qDebug("KO: SyncKDE request detected!"); 5043 qDebug("KO: SyncKDE request detected!");
5044 } 5044 }
5045 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5045 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5046 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5046 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5047 return syncCalendar( filename, mode ); 5047 return syncCalendar( filename, mode );
5048} 5048}
5049bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 5049bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
5050{ 5050{
5051 //mSyncManager = manager; 5051 //mSyncManager = manager;
5052 if ( manager != mSyncManager) 5052 if ( manager != mSyncManager)
5053 qDebug("KO: Internal error-2. SyncManager mismatch "); 5053 qDebug("KO: Internal error-2. SyncManager mismatch ");
5054 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 5054 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
5055 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 5055 mCurrentSyncName = mSyncManager->getCurrentSyncName();
5056 if ( resource == "sharp" ) 5056 if ( resource == "sharp" )
5057 syncExternal( 0 ); 5057 syncExternal( 0 );
5058 if ( resource == "phone" ) 5058 if ( resource == "phone" )
5059 syncExternal( 1 ); 5059 syncExternal( 1 );
5060 // pending setmodified 5060 // pending setmodified
5061 return true; 5061 return true;
5062} 5062}
5063void CalendarView::setSyncManager(KSyncManager* manager) 5063void CalendarView::setSyncManager(KSyncManager* manager)
5064{ 5064{
5065 mSyncManager = manager; 5065 mSyncManager = manager;
5066} 5066}
5067 5067
5068void CalendarView::removeSyncInfo( QString syncProfile) 5068void CalendarView::removeSyncInfo( QString syncProfile)
5069{ 5069{
5070 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 5070 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
5071 mCalendar->removeSyncInfo( syncProfile ); 5071 mCalendar->removeSyncInfo( syncProfile );
5072 5072
5073} 5073}
5074 5074
5075void CalendarView::undo_delete() 5075void CalendarView::undo_delete()
5076{ 5076{
5077 //qDebug("undo_delete() "); 5077 //qDebug("undo_delete() ");
5078 Incidence* undo = mCalendar->undoIncidence(); 5078 Incidence* undo = mCalendar->undoIncidence();
5079 if ( !undo ) { 5079 if ( !undo ) {
5080 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 5080 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
5081 i18n("KO/Pi")); 5081 i18n("KO/Pi"));
5082 return; 5082 return;
5083 } 5083 }
5084 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + 5084 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) +
5085 i18n("\nAre you sure you want\nto restore this?"), 5085 i18n("\nAre you sure you want\nto restore this?"),
5086 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 5086 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
5087 mCalendar->undoDeleteIncidence(); 5087 mCalendar->undoDeleteIncidence();
5088 updateView(); 5088 updateView();
5089 } 5089 }
5090} 5090}
5091 5091
5092void CalendarView::slotViewerClosed() 5092void CalendarView::slotViewerClosed()
5093{ 5093{
5094 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 5094 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
5095} 5095}
5096 5096
5097void CalendarView::resetFocus() 5097void CalendarView::resetFocus()
5098{ 5098{
5099 if ( mViewerCallerIsSearchDialog ) { 5099 if ( mViewerCallerIsSearchDialog ) {
5100 if ( mDialogManager->getSearchDialog()->isVisible() ){ 5100 if ( mDialogManager->getSearchDialog()->isVisible() ){
5101 mDialogManager->getSearchDialog()->raise(); 5101 mDialogManager->getSearchDialog()->raise();
5102 mDialogManager->getSearchDialog()->setActiveWindow(); 5102 mDialogManager->getSearchDialog()->setActiveWindow();
5103 mDialogManager->getSearchDialog()->listview()->resetFocus(); 5103 mDialogManager->getSearchDialog()->listview()->resetFocus();
5104 } else 5104 } else
5105 mViewerCallerIsSearchDialog = false; 5105 mViewerCallerIsSearchDialog = false;
5106 } 5106 }
5107 if ( !mViewerCallerIsSearchDialog ) { 5107 if ( !mViewerCallerIsSearchDialog ) {
5108 //mViewManager->currentView()->setFocus(); 5108 //mViewManager->currentView()->setFocus();
5109 //qDebug("sssssssssssssssset focus "); 5109 //qDebug("sssssssssssssssset focus ");
5110 topLevelWidget()->raise(); 5110 topLevelWidget()->raise();
5111 setActiveWindow(); 5111 setActiveWindow();
5112 //setFocus(); 5112 //setFocus();
5113 } 5113 }
5114 mViewerCallerIsSearchDialog = false; 5114 mViewerCallerIsSearchDialog = false;
5115} 5115}
5116 5116
5117void CalendarView::showNextAlarms() 5117void CalendarView::showNextAlarms()
5118{ 5118{
5119 QString message; 5119 QString message;
5120 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 5120 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
5121 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 5121 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
5122 QString sum = mCalendar->nextSummary(); 5122 QString sum = mCalendar->nextSummary();
5123 QDateTime nextA = mNextAlarmDateTime; 5123 QDateTime nextA = mNextAlarmDateTime;
5124 QDateTime cur = QDateTime::currentDateTime(); 5124 QDateTime cur = QDateTime::currentDateTime();
5125 int secs = cur.secsTo( nextA ); 5125 int secs = cur.secsTo( nextA );
5126 int min = secs /60; 5126 int min = secs /60;
5127 int hours = min /60; 5127 int hours = min /60;
5128 min = min % 60; 5128 min = min % 60;
5129 int days = hours /24; 5129 int days = hours /24;
5130 hours = hours % 24; 5130 hours = hours % 24;
5131 5131
5132 //message = i18n("The next alarm is in:\n"); 5132 //message = i18n("The next alarm is in:\n");
5133 if ( days > 1 ) 5133 if ( days > 1 )
5134 message += i18n("%1 days\n").arg( days ); 5134 message += i18n("%1 days\n").arg( days );
5135 else if ( days == 1 ) 5135 else if ( days == 1 )
5136 message += i18n("1 day\n"); 5136 message += i18n("1 day\n");
5137 if ( hours > 1 ) 5137 if ( hours > 1 )
5138 message += i18n("%1 hours\n").arg( hours ); 5138 message += i18n("%1 hours\n").arg( hours );
5139 else if ( hours == 1 ) 5139 else if ( hours == 1 )
5140 message += i18n("1 hour\n"); 5140 message += i18n("1 hour\n");
5141 if ( min > 1 ) 5141 if ( min > 1 )
5142 message += i18n("%1 minutes\n").arg( min ); 5142 message += i18n("%1 minutes\n").arg( min );
5143 else if ( min == 1 ) 5143 else if ( min == 1 )
5144 message += i18n("1 minute\n"); 5144 message += i18n("1 minute\n");
5145 if ( message.isEmpty() ) 5145 if ( message.isEmpty() )
5146 message = i18n("The next alarm is in\nless than one minute!"); 5146 message = i18n("The next alarm is in\nless than one minute!");
5147 else 5147 else
5148 message = i18n("The next alarm is in:\n") + message; 5148 message = i18n("The next alarm is in:\n") + message;
5149 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 5149 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
5150 } else { 5150 } else {
5151 message = i18n("There is no next alarm."); 5151 message = i18n("There is no next alarm.");
5152 5152
5153 } 5153 }
5154#ifdef DESKTOP_VERSION 5154#ifdef DESKTOP_VERSION
5155 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 5155 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
5156 message += i18n("\nThe internal alarm notification is disabled!\n"); 5156 message += i18n("\nThe internal alarm notification is disabled!\n");
5157 message += i18n("Enable it in the settings menu, TAB alarm."); 5157 message += i18n("Enable it in the settings menu, TAB alarm.");
5158 } 5158 }
5159 5159
5160#endif 5160#endif
5161 KMessageBox::information( this, message); 5161 KMessageBox::information( this, message);
5162} 5162}
5163 5163
5164void CalendarView::displayCalendarInfo( int id ) 5164void CalendarView::displayCalendarInfo( int id )
5165{ 5165{
5166 int e, t,j; 5166 int e, t,j;
5167 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id ); 5167 KopiCalendarFile * kkf = KOPrefs::instance()->getCalendar( id );
5168 QString name = kkf->mName; 5168 QString name = kkf->mName;
5169 mCalendar->getIncidenceCount( id, e, t, j ); 5169 mCalendar->getIncidenceCount( id, e, t, j );
5170 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 ); 5170 QString file = KGlobal::formatMessage ( kkf->mFileName ,0 );
5171 QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file); 5171 QString mess = i18n("The calendar <b>%1</b> is displaying file <b>%2</b>").arg(name).arg(file);
5172 mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j ); 5172 mess += i18n("<br>The calendar contains<br><b>%1 events<br>%2 todos<br>%3 journals</b>").arg( e ).arg( t ).arg( j );
5173 KMessageBox::information( this, mess ); 5173 KMessageBox::information( this, mess );
5174 5174
5175 5175
5176} 5176}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 0924f07..80f7ed4 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,670 +1,675 @@
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#include <qscrollbar.h>
34#ifndef DESKTOP_VERSION 34#ifndef DESKTOP_VERSION
35#include <qtopia/ir.h> 35#include <qtopia/ir.h>
36#else 36#else
37#define Ir char 37#define Ir char
38#endif 38#endif
39#include <libkcal/calendar.h> 39#include <libkcal/calendar.h>
40#include <libkcal/scheduler.h> 40#include <libkcal/scheduler.h>
41#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
43#include <KDGanttMinimizeSplitter.h> 43#include <KDGanttMinimizeSplitter.h>
44 44
45#include <korganizer/calendarviewbase.h> 45#include <korganizer/calendarviewbase.h>
46 46
47#include <ksyncmanager.h> 47#include <ksyncmanager.h>
48//#include <koprefs.h> 48//#include <koprefs.h>
49 49
50class QWidgetStack; 50class QWidgetStack;
51class QSplitter; 51class QSplitter;
52class KopiCalendarFile; 52class KopiCalendarFile;
53class CalPrinter; 53class CalPrinter;
54class KOFilterView; 54class KOFilterView;
55class KOCalEditView; 55class KOCalEditView;
56class KOViewManager; 56class KOViewManager;
57class KODialogManager; 57class KODialogManager;
58class KOTodoView; 58class KOTodoView;
59class KDateNavigator; 59class KDateNavigator;
60class DateNavigatorContainer; 60class DateNavigatorContainer;
61class DateNavigator; 61class DateNavigator;
62class KOIncidenceEditor; 62class KOIncidenceEditor;
63class KDatePicker; 63class KDatePicker;
64class ResourceView; 64class ResourceView;
65class KOEventEditor; 65class KOEventEditor;
66class KOTodoEditor ; 66class KOTodoEditor ;
67class KOEventViewerDialog; 67class KOEventViewerDialog;
68class KOBeamPrefs; 68class KOBeamPrefs;
69class KSyncProfile; 69class KSyncProfile;
70class AlarmDialog; 70class AlarmDialog;
71class KCal::Attendee; 71class KCal::Attendee;
72 72
73namespace KCal { class FileStorage; } 73namespace KCal { class FileStorage; }
74 74
75using namespace KCal; 75using namespace KCal;
76 76
77/** 77/**
78 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
79 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
80 of the different views and controls the different dialogs like preferences, 80 of the different views and controls the different dialogs like preferences,
81 event editor, search dialog etc. 81 event editor, search dialog etc.
82 82
83 @short main calendar view widget 83 @short main calendar view widget
84 @author Cornelius Schumacher 84 @author Cornelius Schumacher
85*/ 85*/
86 86
87#include <qtextbrowser.h> 87#include <qtextbrowser.h>
88#include <qtextcodec.h> 88#include <qtextcodec.h>
89 89
90class MissedAlarmTextBrowser : public QTextBrowser { 90class MissedAlarmTextBrowser : public QTextBrowser {
91 Q_OBJECT 91 Q_OBJECT
92 public: 92 public:
93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 93 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
94 ~MissedAlarmTextBrowser(); 94 ~MissedAlarmTextBrowser();
95 void setSource(const QString & n); 95 void setSource(const QString & n);
96 96
97 private: 97 private:
98 Incidence * getNextInc(QDateTime start ); 98 Incidence * getNextInc(QDateTime start );
99 QPtrList<Incidence> mAlarms; 99 QPtrList<Incidence> mAlarms;
100 signals: 100 signals:
101 void showIncidence( QString uid); 101 void showIncidence( QString uid);
102}; 102};
103 103
104 104
105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 105class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
106{ 106{
107 Q_OBJECT 107 Q_OBJECT
108 public: 108 public:
109 /** 109 /**
110 Constructs a new calendar view widget. 110 Constructs a new calendar view widget.
111 111
112 @param calendar calendar document 112 @param calendar calendar document
113 @param parent parent window 113 @param parent parent window
114 @param name Qt internal widget object name 114 @param name Qt internal widget object name
115 */ 115 */
116 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 116 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
117 const char *name = 0 ); 117 const char *name = 0 );
118 CalendarView( Calendar *calendar, QWidget *parent = 0, 118 CalendarView( Calendar *calendar, QWidget *parent = 0,
119 const char *name = 0 ); 119 const char *name = 0 );
120 virtual ~CalendarView(); 120 virtual ~CalendarView();
121 121
122 Calendar *calendar() { return mCalendar; } 122 Calendar *calendar() { return mCalendar; }
123 123
124 KOViewManager *viewManager(); 124 KOViewManager *viewManager();
125 KODialogManager *dialogManager(); 125 KODialogManager *dialogManager();
126 126
127 QDate startDate(); 127 QDate startDate();
128 QDate endDate(); 128 QDate endDate();
129 129
130 QWidgetStack *viewStack(); 130 QWidgetStack *viewStack();
131 QWidget *leftFrame(); 131 QWidget *leftFrame();
132 132
133 DateNavigator *dateNavigator(); 133 DateNavigator *dateNavigator();
134 KDateNavigator *dateNavigatorWidget(); 134 KDateNavigator *dateNavigatorWidget();
135 135
136 void addView(KOrg::BaseView *); 136 void addView(KOrg::BaseView *);
137 void showView(KOrg::BaseView *); 137 void showView(KOrg::BaseView *);
138 KOEventViewerDialog* getEventViewerDialog(); 138 KOEventViewerDialog* getEventViewerDialog();
139 Incidence *currentSelection(); 139 Incidence *currentSelection();
140 void checkSuspendAlarm(); 140 void checkSuspendAlarm();
141 void mergeFile( QString fn ); 141 void mergeFile( QString fn );
142 142
143 signals: 143 signals:
144 void save (); 144 void save ();
145 void saveStopTimer (); 145 void saveStopTimer ();
146 void tempDisableBR(bool); 146 void tempDisableBR(bool);
147 /** This todo has been modified */ 147 /** This todo has been modified */
148 void todoModified(Todo *, int); 148 void todoModified(Todo *, int);
149 149
150 /** when change is made to options dialog, the topwidget will catch this 150 /** when change is made to options dialog, the topwidget will catch this
151 * and emit this signal which notifies all widgets which have registered 151 * and emit this signal which notifies all widgets which have registered
152 * for notification to update their settings. */ 152 * for notification to update their settings. */
153 void configChanged(); 153 void configChanged();
154 /** emitted when the topwidget is closing down, so that any attached 154 /** emitted when the topwidget is closing down, so that any attached
155 child windows can also close. */ 155 child windows can also close. */
156 void closingDown(); 156 void closingDown();
157 /** emitted right before we die */ 157 /** emitted right before we die */
158 void closed(QWidget *); 158 void closed(QWidget *);
159 159
160 /** Emitted when state of modified flag changes */ 160 /** Emitted when state of modified flag changes */
161 void modifiedChanged(bool); 161 void modifiedChanged(bool);
162 void signalmodified(); 162 void signalmodified();
163 163
164 /** Emitted when state of read-only flag changes */ 164 /** Emitted when state of read-only flag changes */
165 void readOnlyChanged(bool); 165 void readOnlyChanged(bool);
166 166
167 /** Emitted when the unit of navigation changes */ 167 /** Emitted when the unit of navigation changes */
168 void changeNavStringPrev(const QString &); 168 void changeNavStringPrev(const QString &);
169 void changeNavStringNext(const QString &); 169 void changeNavStringNext(const QString &);
170 170
171 /** Emitted when state of events selection has changed and user is organizer*/ 171 /** Emitted when state of events selection has changed and user is organizer*/
172 void organizerEventsSelected(bool); 172 void organizerEventsSelected(bool);
173 /** Emitted when state of events selection has changed and user is attendee*/ 173 /** Emitted when state of events selection has changed and user is attendee*/
174 void groupEventsSelected(bool); 174 void groupEventsSelected(bool);
175 /** 175 /**
176 Emitted when an incidence gets selected. If the selection is cleared the 176 Emitted when an incidence gets selected. If the selection is cleared the
177 signal is emitted with 0 as argument. 177 signal is emitted with 0 as argument.
178 */ 178 */
179 void incidenceSelected( Incidence * ); 179 void incidenceSelected( Incidence * );
180 /** Emitted, when a todoitem is selected or deselected. */ 180 /** Emitted, when a todoitem is selected or deselected. */
181 void todoSelected( bool ); 181 void todoSelected( bool );
182 182
183 /** 183 /**
184 Emitted, when clipboard content changes. Parameter indicates if paste 184 Emitted, when clipboard content changes. Parameter indicates if paste
185 is possible or not. 185 is possible or not.
186 */ 186 */
187 void pasteEnabled(bool); 187 void pasteEnabled(bool);
188 188
189 /** Emitted, when the number of incoming messages has changed. */ 189 /** Emitted, when the number of incoming messages has changed. */
190 void numIncomingChanged(int); 190 void numIncomingChanged(int);
191 191
192 /** Emitted, when the number of outgoing messages has changed. */ 192 /** Emitted, when the number of outgoing messages has changed. */
193 void numOutgoingChanged(int); 193 void numOutgoingChanged(int);
194 194
195 /** Send status message, which can e.g. be displayed in the status bar. */ 195 /** Send status message, which can e.g. be displayed in the status bar. */
196 void statusMessage(const QString &); 196 void statusMessage(const QString &);
197 197
198 void calendarViewExpanded( bool ); 198 void calendarViewExpanded( bool );
199 void updateSearchDialog(); 199 void updateSearchDialog();
200 void filtersUpdated(); 200 void filtersUpdated();
201 201
202 202
203 public slots: 203 public slots:
204 void displayCalendarInfo( int id ); 204 void displayCalendarInfo( int id );
205 void nextConflict( bool all, bool allday ); 205 void nextConflict( bool all, bool allday );
206 void conflictAll(); 206 void conflictAll();
207 void conflictAllday(); 207 void conflictAllday();
208 void conflictNotAll(); 208 void conflictNotAll();
209 void setCalReadOnly( int id, bool readO ); 209 void setCalReadOnly( int id, bool readO );
210 void checkAlarms(); 210 void checkAlarms();
211 void checkFiles(); 211 void checkFiles();
212 void slotprintSelInc(); 212 void slotprintSelInc();
213 void showNextAlarms(); 213 void showNextAlarms();
214 void showOpenError(); 214 void showOpenError();
215 void watchSavedFile(); 215 void watchSavedFile();
216 void recheckTimerAlarm(); 216 void recheckTimerAlarm();
217 void checkNextTimerAlarm(); 217 void checkNextTimerAlarm();
218 void addAlarm(const QDateTime &qdt, const QString &noti ); 218 void addAlarm(const QDateTime &qdt, const QString &noti );
219 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 219 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
220 void removeAlarm(const QDateTime &qdt, const QString &noti ); 220 void removeAlarm(const QDateTime &qdt, const QString &noti );
221 221
222 /** options dialog made a changed to the configuration. we catch this 222 /** options dialog made a changed to the configuration. we catch this
223 * and notify all widgets which need to update their configuration. */ 223 * and notify all widgets which need to update their configuration. */
224 void updateConfig(); 224 void updateConfig();
225 225
226 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 226 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
227 const QStringList& anniversaryList, const QStringList& realNameList, 227 const QStringList& anniversaryList, const QStringList& realNameList,
228 const QStringList& emailList, const QStringList& assembledNameList, 228 const QStringList& emailList, const QStringList& assembledNameList,
229 const QStringList& uidList); 229 const QStringList& uidList);
230 230
231 /** 231 /**
232 Load calendar from file \a filename. If \a merge is true, load 232 Load calendar from file \a filename. If \a merge is true, load
233 calendar into existing one, if it is false, clear calendar, before 233 calendar into existing one, if it is false, clear calendar, before
234 loading. Return true, if calendar could be successfully loaded. 234 loading. Return true, if calendar could be successfully loaded.
235 */ 235 */
236 bool openCalendar(QString filename, bool merge=false); 236 bool openCalendar(QString filename, bool merge=false);
237 bool loadCalendars(); 237 bool loadCalendars();
238 bool saveCalendars(); 238 bool saveCalendars();
239 bool restoreCalendarSettings(); 239 bool restoreCalendarSettings();
240 bool addCalendar( KopiCalendarFile * ); 240 bool addCalendar( KopiCalendarFile * );
241 void addCalendarId( int id ); 241 void addCalendarId( int id );
242 bool syncCalendar(QString filename,int mode = 0 ); 242 bool syncCalendar(QString filename,int mode = 0 );
243 243
244 /** 244 /**
245 Save calendar data to file. Return true if calendar could be 245 Save calendar data to file. Return true if calendar could be
246 successfully saved. 246 successfully saved.
247 */ 247 */
248 bool saveCalendar(QString filename); 248 bool saveCalendar(QString filename);
249 249
250 /** 250 /**
251 Close calendar. Clear calendar data and reset views to display an empty 251 Close calendar. Clear calendar data and reset views to display an empty
252 calendar. 252 calendar.
253 */ 253 */
254 void closeCalendar(); 254 void closeCalendar();
255 255
256 /** Archive old events of calendar */ 256 /** Archive old events of calendar */
257 void archiveCalendar(); 257 void archiveCalendar();
258 258
259 void showIncidence(); 259 void showIncidence();
260 void editIncidence(); 260 void editIncidence();
261 void editIncidenceDescription(); 261 void editIncidenceDescription();
262 void deleteIncidence(); 262 void deleteIncidence();
263 void cloneIncidence(); 263 void cloneIncidence();
264 void moveIncidence(); 264 void moveIncidence();
265 void beamIncidence(); 265 void beamIncidence();
266 void toggleCancelIncidence(); 266 void toggleCancelIncidence();
267 267
268 /** create an editeventwin with supplied date/time, and if bool is true, 268 /** create an editeventwin with supplied date/time, and if bool is true,
269 * make the event take all day. */ 269 * make the event take all day. */
270 void newEvent(QDateTime, QDateTime, bool allDay ); 270 void newEvent(QDateTime, QDateTime, bool allDay );
271 void newEvent(QDateTime, QDateTime); 271 void newEvent(QDateTime, QDateTime);
272 void newEvent(QDateTime fh); 272 void newEvent(QDateTime fh);
273 void newEvent(QDate dt); 273 void newEvent(QDate dt);
274 /** create new event without having a date hint. Takes current date as 274 /** create new event without having a date hint. Takes current date as
275 default hint. */ 275 default hint. */
276 void newEvent(); 276 void newEvent();
277 void newFloatingEvent(); 277 void newFloatingEvent();
278 278
279 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 279 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
280 void showIncidence(Incidence *); 280 void showIncidence(Incidence *);
281 void showIncidence(QString uid); 281 void showIncidence(QString uid);
282 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 282 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
283 void editIncidence(Incidence *); 283 void editIncidence(Incidence *);
284 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 284 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
285 void deleteIncidence(Incidence *); 285 void deleteIncidence(Incidence *);
286 void cloneIncidence(Incidence *); 286 void cloneIncidence(Incidence *);
287 void cancelIncidence(Incidence *); 287 void cancelIncidence(Incidence *);
288 /** Create an editor for the supplied event. */ 288 /** Create an editor for the supplied event. */
289 void editEvent(Event *); 289 void editEvent(Event *);
290 /** Delete the supplied event. */ 290 /** Delete the supplied event. */
291 void deleteEvent(Event *); 291 void deleteEvent(Event *);
292 /** Delete the event with the given unique ID. Returns false, if event wasn't 292 /** Delete the event with the given unique ID. Returns false, if event wasn't
293 found. */ 293 found. */
294 bool deleteEvent(const QString &uid); 294 bool deleteEvent(const QString &uid);
295 /** Create a read-only viewer dialog for the supplied event. */ 295 /** Create a read-only viewer dialog for the supplied event. */
296 void showEvent(Event *); 296 void showEvent(Event *);
297 297
298 void editJournal(Journal *); 298 void editJournal(Journal *);
299 void showJournal(Journal *); 299 void showJournal(Journal *);
300 void deleteJournal(Journal *); 300 void deleteJournal(Journal *);
301 /** Create an editor dialog for a todo */ 301 /** Create an editor dialog for a todo */
302 void editTodo(Todo *); 302 void editTodo(Todo *);
303 /** Create a read-only viewer dialog for the supplied todo */ 303 /** Create a read-only viewer dialog for the supplied todo */
304 void showTodo(Todo *); 304 void showTodo(Todo *);
305 /** create new todo */ 305 /** create new todo */
306 void newTodo(); 306 void newTodo();
307 void newTodoDateTime(QDateTime, bool allday); 307 void newTodoDateTime(QDateTime, bool allday);
308 /** create new todo with a parent todo */ 308 /** create new todo with a parent todo */
309 void newSubTodo(); 309 void newSubTodo();
310 /** create new todo with a parent todo */ 310 /** create new todo with a parent todo */
311 void newSubTodo(Todo *); 311 void newSubTodo(Todo *);
312 /** Delete todo */ 312 /** Delete todo */
313 void deleteTodo(Todo *); 313 void deleteTodo(Todo *);
314 314
315 315
316 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 316 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
317 * emitted as result. */ 317 * emitted as result. */
318 void checkClipboard(); 318 void checkClipboard();
319 319
320 /** using the KConfig associated with the kapp variable, read in the 320 /** using the KConfig associated with the kapp variable, read in the
321 * settings from the config file. 321 * settings from the config file.
322 */ 322 */
323 void readSettings(); 323 void readSettings();
324 324
325 /** write current state to config file. */ 325 /** write current state to config file. */
326 void writeSettings(); 326 void writeSettings();
327 327
328 /** read settings for calendar filters */ 328 /** read settings for calendar filters */
329 void readFilterSettings(KConfig *config); 329 void readFilterSettings(KConfig *config);
330 330
331 /** write settings for calendar filters */ 331 /** write settings for calendar filters */
332 void writeFilterSettings(KConfig *config); 332 void writeFilterSettings(KConfig *config);
333 333
334 /** passes on the message that an event has changed to the currently 334 /** passes on the message that an event has changed to the currently
335 * activated view so that it can make appropriate display changes. */ 335 * activated view so that it can make appropriate display changes. */
336 void changeEventDisplay(Event *, int); 336 void changeEventDisplay(Event *, int);
337 void changeIncidenceDisplay(Incidence *, int); 337 void changeIncidenceDisplay(Incidence *, int);
338 void changeTodoDisplay(Todo *, int); 338 void changeTodoDisplay(Todo *, int);
339 339
340 void eventAdded(Event *); 340 void eventAdded(Event *);
341 void eventChanged(Event *); 341 void eventChanged(Event *);
342 void eventToBeDeleted(Event *); 342 void eventToBeDeleted(Event *);
343 void eventDeleted(); 343 void eventDeleted();
344 344
345 void todoAdded(Todo *); 345 void todoAdded(Todo *);
346 void todoChanged(Todo *); 346 void todoChanged(Todo *);
347 void todoToBeDeleted(Todo *); 347 void todoToBeDeleted(Todo *);
348 void todoDeleted(); 348 void todoDeleted();
349 349
350 void updateView(const QDate &start, const QDate &end); 350 void updateView(const QDate &start, const QDate &end);
351 void updateView(); 351 void updateView();
352 void clearAllViews(); 352 void clearAllViews();
353 353
354 /** Full update of visible todo views */ 354 /** Full update of visible todo views */
355 void updateTodoViews(); 355 void updateTodoViews();
356 356
357 void updateUnmanagedViews(); 357 void updateUnmanagedViews();
358 358
359 /** cut the current appointment to the clipboard */ 359 /** cut the current appointment to the clipboard */
360 void edit_cut(); 360 void edit_cut();
361 361
362 /** copy the current appointment(s) to the clipboard */ 362 /** copy the current appointment(s) to the clipboard */
363 void edit_copy(); 363 void edit_copy();
364 364
365 /** paste the current vobject(s) in the clipboard buffer into calendar */ 365 /** paste the current vobject(s) in the clipboard buffer into calendar */
366 void edit_paste(); 366 void edit_paste();
367 367
368 /** edit viewing and configuration options. */ 368 /** edit viewing and configuration options. */
369 void edit_options(); 369 void edit_options();
370 void edit_global_options(); 370 void edit_global_options();
371 /** 371 /**
372 Functions for printing, previewing a print, and setting up printing 372 Functions for printing, previewing a print, and setting up printing
373 parameters. 373 parameters.
374 */ 374 */
375 void print(); 375 void print();
376 void printSetup(); 376 void printSetup();
377 void printPreview(); 377 void printPreview();
378 378
379 /** Export as iCalendar file */ 379 /** Export as iCalendar file */
380 bool exportICalendar(); 380 bool exportICalendar();
381 bool exportICalendar( QString fn ); 381 bool exportICalendar( QString fn );
382 382
383 /** Export as vCalendar file */ 383 /** Export as vCalendar file */
384 bool exportVCalendar( QString fn); 384 bool exportVCalendar( QString fn);
385 385
386 /** pop up a dialog to show an existing appointment. */ 386 /** pop up a dialog to show an existing appointment. */
387 void appointment_show(); 387 void appointment_show();
388 /** 388 /**
389 * pop up an Appointment Dialog to edit an existing appointment.Get 389 * pop up an Appointment Dialog to edit an existing appointment.Get
390 * information on the appointment from the list of unique IDs that is 390 * information on the appointment from the list of unique IDs that is
391 * currently in the View, called currIds. 391 * currently in the View, called currIds.
392 */ 392 */
393 void appointment_edit(); 393 void appointment_edit();
394 /** 394 /**
395 * pop up dialog confirming deletion of currently selected event in the 395 * pop up dialog confirming deletion of currently selected event in the
396 * View. 396 * View.
397 */ 397 */
398 void appointment_delete(); 398 void appointment_delete();
399 399
400 /** mails the currently selected event to a particular user as a vCalendar 400 /** mails the currently selected event to a particular user as a vCalendar
401 attachment. */ 401 attachment. */
402 void action_mail(); 402 void action_mail();
403 403
404 /* frees a subtodo from it's relation */ 404 /* frees a subtodo from it's relation */
405 void todo_unsub( Todo * ); 405 void todo_unsub( Todo * );
406 void todo_resub( Todo * parent, Todo * sub ); 406 void todo_resub( Todo * parent, Todo * sub );
407 407
408 /** Take ownership of selected event. */ 408 /** Take ownership of selected event. */
409 void takeOverEvent(); 409 void takeOverEvent();
410 410
411 /** Take ownership of all events in calendar. */ 411 /** Take ownership of all events in calendar. */
412 void takeOverCalendar(); 412 void takeOverCalendar();
413 413
414 /** query whether or not the calendar is "dirty". */ 414 /** query whether or not the calendar is "dirty". */
415 bool isModified(); 415 bool isModified();
416 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 416 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
417 void setModified(bool modified=true); 417 void setModified(bool modified=true);
418 418
419 /** query if the calendar is read-only. */ 419 /** query if the calendar is read-only. */
420 bool isReadOnly(); 420 bool isReadOnly();
421 /** set state of calendar to read-only */ 421 /** set state of calendar to read-only */
422 void setReadOnly(bool readOnly=true); 422 void setReadOnly(bool readOnly=true);
423 423
424 void eventUpdated(Incidence *); 424 void eventUpdated(Incidence *);
425 425
426 /* iTIP scheduling actions */ 426 /* iTIP scheduling actions */
427 void schedule_publish(Incidence *incidence = 0); 427 void schedule_publish(Incidence *incidence = 0);
428 void schedule_request(Incidence *incidence = 0); 428 void schedule_request(Incidence *incidence = 0);
429 void schedule_refresh(Incidence *incidence = 0); 429 void schedule_refresh(Incidence *incidence = 0);
430 void schedule_cancel(Incidence *incidence = 0); 430 void schedule_cancel(Incidence *incidence = 0);
431 void schedule_add(Incidence *incidence = 0); 431 void schedule_add(Incidence *incidence = 0);
432 void schedule_reply(Incidence *incidence = 0); 432 void schedule_reply(Incidence *incidence = 0);
433 void schedule_counter(Incidence *incidence = 0); 433 void schedule_counter(Incidence *incidence = 0);
434 void schedule_declinecounter(Incidence *incidence = 0); 434 void schedule_declinecounter(Incidence *incidence = 0);
435 void schedule_publish_freebusy(int daysToPublish = 30); 435 void schedule_publish_freebusy(int daysToPublish = 30);
436 436
437 void openAddressbook(); 437 void openAddressbook();
438 438
439 void editFilters(); 439 void editFilters();
440 void toggleFilerEnabled(); 440 void toggleFilerEnabled();
441 QPtrList<CalFilter> filters(); 441 QPtrList<CalFilter> filters();
442 void toggleFilter(); 442 void toggleFilter();
443 void showFilter(bool visible); 443 void showFilter(bool visible);
444 void updateFilter(); 444 void updateFilter();
445 void filterEdited(); 445 void filterEdited();
446 void selectFilter( int ); 446 void selectFilter( int );
447 KOFilterView *filterView(); 447 KOFilterView *filterView();
448 448
449 void showIntro(); 449 void showIntro();
450 450
451 /** Move the curdatepient view date to today */ 451 /** Move the curdatepient view date to today */
452 void goToday(); 452 void goToday();
453 453
454 /** Move to the next date(s) in the current view */ 454 /** Move to the next date(s) in the current view */
455 void goNext(); 455 void goNext();
456 456
457 /** Move to the previous date(s) in the current view */ 457 /** Move to the previous date(s) in the current view */
458 void goPrevious(); 458 void goPrevious();
459 /** Move to the next date(s) in the current view */ 459 /** Move to the next date(s) in the current view */
460 void goNextMonth(); 460 void goNextMonth();
461 461
462 /** Move to the previous date(s) in the current view */ 462 /** Move to the previous date(s) in the current view */
463 void goPreviousMonth(); 463 void goPreviousMonth();
464 464
465 void toggleExpand(); 465 void toggleExpand();
466 void toggleDateNavigatorWidget(); 466 void toggleDateNavigatorWidget();
467 void toggleAllDaySize(); 467 void toggleAllDaySize();
468 468
469 /** Look for new messages in the inbox */ 469 /** Look for new messages in the inbox */
470 void lookForIncomingMessages(); 470 void lookForIncomingMessages();
471 /** Look for new messages in the outbox */ 471 /** Look for new messages in the outbox */
472 void lookForOutgoingMessages(); 472 void lookForOutgoingMessages();
473 473
474 void processMainViewSelection( Incidence * ); 474 void processMainViewSelection( Incidence * );
475 void processTodoListSelection( Incidence * ); 475 void processTodoListSelection( Incidence * );
476 476
477 void processIncidenceSelection( Incidence * ); 477 void processIncidenceSelection( Incidence * );
478 478
479 void purgeCompleted(); 479 void purgeCompleted();
480 bool removeCompletedSubTodos( Todo* ); 480 bool removeCompletedSubTodos( Todo* );
481 void slotCalendarChanged(); 481 void slotCalendarChanged();
482 bool importBday(); 482 bool importBday();
483 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 483 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
484 bool importQtopia( const QString &categoriesFile, 484 bool importQtopia( const QString &categoriesFile,
485 const QString &datebookFile, 485 const QString &datebookFile,
486 const QString &tasklistFile ); 486 const QString &tasklistFile );
487 void syncExternal( int mode ); 487 void syncExternal( int mode );
488 void slotSelectPickerDate( QDate ) ; 488 void slotSelectPickerDate( QDate ) ;
489 void showDatePicker() ; 489 void showDatePicker() ;
490 void showDatePickerPopup() ; 490 void showDatePickerPopup() ;
491 void moveIncidence(Incidence *) ; 491 void moveIncidence(Incidence *) ;
492 void beamIncidence(Incidence *) ; 492 void beamIncidence(Incidence *) ;
493 void beamCalendar() ; 493 void beamCalendar() ;
494 void beamFilteredCalendar() ; 494 void beamFilteredCalendar() ;
495 void beamIncidenceList(QPtrList<Incidence>) ; 495 void beamIncidenceList(QPtrList<Incidence>) ;
496 void manageCategories(); 496 void manageCategories();
497 void editCategories(); 497 void editCategories();
498 int addCategories(); 498 int addCategories();
499 void removeCategories(); 499 void removeCategories();
500 void setSyncDevice( QString ); 500 void setSyncDevice( QString );
501 void setSyncName( QString ); 501 void setSyncName( QString );
502 void showDay( QDate ); 502 void showDay( QDate );
503 void undo_delete(); 503 void undo_delete();
504 protected slots: 504 protected slots:
505 void resetFocus(); 505 void resetFocus();
506 void scrollBarValue(int); 506 void scrollBarValue(int);
507 void slotViewerClosed(); 507 void slotViewerClosed();
508 void timerAlarm(); 508 void timerAlarm();
509 void suspendAlarm(); 509 void suspendAlarm();
510 void beamDone( Ir *ir ); 510 void beamDone( Ir *ir );
511 /** Select a view or adapt the current view to display the specified dates. */ 511 /** Select a view or adapt the current view to display the specified dates. */
512 void showDates( const KCal::DateList & ); 512 void showDates( const KCal::DateList & );
513 void selectWeekNum ( int ); 513 void selectWeekNum ( int );
514 void checkConflictForEvent(); 514 void checkConflictForEvent();
515 515
516 public: 516 public:
517 void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval ); 517 void createRunningDate4Todo( Todo * runT, QDateTime start , QDateTime end, int secLenRunning, int secLenPausing,int dayInterval );
518 // show a standard warning 518 // show a standard warning
519 // returns KMsgBox::yesNoCancel() 519 // returns KMsgBox::yesNoCancel()
520 int msgCalModified(); 520 int msgCalModified();
521 virtual bool sync(KSyncManager* manager, QString filename, int mode); 521 virtual bool sync(KSyncManager* manager, QString filename, int mode);
522 522
523 virtual bool syncExternal(KSyncManager* manager, QString resource); 523 virtual bool syncExternal(KSyncManager* manager, QString resource);
524 virtual void removeSyncInfo( QString syncProfile); 524 virtual void removeSyncInfo( QString syncProfile);
525 void setSyncManager(KSyncManager* manager); 525 void setSyncManager(KSyncManager* manager);
526 void setLoadedFileVersion(QDateTime); 526 void setLoadedFileVersion(QDateTime);
527 bool checkFileVersion(QString fn); 527 bool checkFileVersion(QString fn);
528 bool checkAllFileVersions(); 528 bool checkAllFileVersions();
529 bool checkFileChanged(QString fn); 529 bool checkFileChanged(QString fn);
530 Event* getLastSyncEvent(); 530 Event* getLastSyncEvent();
531 /** Adapt navigation units correpsonding to step size of navigation of the 531 /** Adapt navigation units correpsonding to step size of navigation of the
532 * current view. 532 * current view.
533 */ 533 */
534 void adaptNavigationUnits(); 534 void adaptNavigationUnits();
535 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 535 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
536 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 536 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
537 //Attendee* getYourAttendee(Event *event); 537 //Attendee* getYourAttendee(Event *event);
538 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 538 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
539 void setScrollBarStep(int val ); 539 void setScrollBarStep(int val );
540 540
541 protected: 541 protected:
542 Event *mConflictingEvent; 542 Event *mConflictingEvent;
543 void schedule(Scheduler::Method, Incidence *incidence = 0); 543 void schedule(Scheduler::Method, Incidence *incidence = 0);
544 544
545 // returns KMsgBox::OKCandel() 545 // returns KMsgBox::OKCandel()
546 int msgItemDelete(const QString name); 546 int msgItemDelete(const QString name);
547 void showEventEditor(); 547 void showEventEditor();
548 void showTodoEditor(); 548 void showTodoEditor();
549 Todo *selectedTodo(); 549 Todo *selectedTodo();
550 private: 550 private:
551#ifdef DESKTOP_VERSION 551#ifdef DESKTOP_VERSION
552 QScrollBar * mDateScrollBar; 552 QScrollBar * mDateScrollBar;
553#endif 553#endif
554 bool flag_blockConflict;
555 bool flag_blockScrollBar;
556 bool flag_checkFileFirsttime;
557 bool flag_clearallviewsEventDisplay;
558 bool flag_clearallviewsupdateView;
554 QDateTime mNextAlarmDateTime; 559 QDateTime mNextAlarmDateTime;
555 bool mViewerCallerIsSearchDialog; 560 bool mViewerCallerIsSearchDialog;
556 bool mBlockShowDates; 561 bool mBlockShowDates;
557 KSyncManager* mSyncManager; 562 KSyncManager* mSyncManager;
558 AlarmDialog * mAlarmDialog; 563 AlarmDialog * mAlarmDialog;
559 QString mAlarmNotification; 564 QString mAlarmNotification;
560 QString mSuspendAlarmNotification; 565 QString mSuspendAlarmNotification;
561 QTimer* mSuspendTimer; 566 QTimer* mSuspendTimer;
562 QTimer* mAlarmTimer; 567 QTimer* mAlarmTimer;
563 QTimer* mRecheckAlarmTimer; 568 QTimer* mRecheckAlarmTimer;
564 void computeAlarm( QString ); 569 void computeAlarm( QString );
565 void startAlarm( QString, QString ); 570 void startAlarm( QString, QString );
566 void setSyncEventsReadOnly(); 571 void setSyncEventsReadOnly();
567 572
568 QDateTime loadedFileVersion; 573 QDateTime loadedFileVersion;
569 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 574 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
570 void checkExternalId( Incidence * inc ); 575 void checkExternalId( Incidence * inc );
571 int mGlobalSyncMode; 576 int mGlobalSyncMode;
572 QString mCurrentSyncDevice; 577 QString mCurrentSyncDevice;
573 QString mCurrentSyncName; 578 QString mCurrentSyncName;
574 void init(); 579 void init();
575 int mDatePickerMode; 580 int mDatePickerMode;
576 bool mFlagEditDescription; 581 bool mFlagEditDescription;
577 QDateTime mLastCalendarSync; 582 QDateTime mLastCalendarSync;
578 void createPrinter(); 583 void createPrinter();
579 584
580 void calendarModified( bool, Calendar * ); 585 void calendarModified( bool, Calendar * );
581 586
582 CalPrinter *mCalPrinter; 587 CalPrinter *mCalPrinter;
583 588
584 QSplitter *mPanner; 589 QSplitter *mPanner;
585 QSplitter *mLeftSplitter; 590 QSplitter *mLeftSplitter;
586 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; 591 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
587 QWidgetStack *mRightFrame; 592 QWidgetStack *mRightFrame;
588 593
589 KDatePicker* mDatePicker; 594 KDatePicker* mDatePicker;
590 QVBox* mDateFrame; 595 QVBox* mDateFrame;
591 596
592 DateNavigatorContainer *mDateNavigator; // widget showing small month view. 597 DateNavigatorContainer *mDateNavigator; // widget showing small month view.
593 598
594 KOFilterView *mFilterView; 599 KOFilterView *mFilterView;
595 KOCalEditView *mCalEditView; 600 KOCalEditView *mCalEditView;
596 601
597 ResourceView *mResourceView; 602 ResourceView *mResourceView;
598 603
599 // calendar object for this viewing instance 604 // calendar object for this viewing instance
600 Calendar *mCalendar; 605 Calendar *mCalendar;
601 606
602 CalendarResourceManager *mResourceManager; 607 CalendarResourceManager *mResourceManager;
603 608
604 FileStorage *mStorage; 609 FileStorage *mStorage;
605 610
606 DateNavigator *mNavigator; 611 DateNavigator *mNavigator;
607 612
608 KOViewManager *mViewManager; 613 KOViewManager *mViewManager;
609 KODialogManager *mDialogManager; 614 KODialogManager *mDialogManager;
610 615
611 // Calendar filters 616 // Calendar filters
612 QPtrList<CalFilter> mFilters; 617 QPtrList<CalFilter> mFilters;
613 618
614 // various housekeeping variables. 619 // various housekeeping variables.
615 bool mModified; // flag indicating if calendar is modified 620 bool mModified; // flag indicating if calendar is modified
616 bool mReadOnly; // flag indicating if calendar is read-only 621 bool mReadOnly; // flag indicating if calendar is read-only
617 QDate mSaveSingleDate; 622 QDate mSaveSingleDate;
618 623
619 Incidence *mSelectedIncidence; 624 Incidence *mSelectedIncidence;
620 Incidence *mMoveIncidence; 625 Incidence *mMoveIncidence;
621 QDate mMoveIncidenceOldDate; 626 QDate mMoveIncidenceOldDate;
622 KOTodoView *mTodoList; 627 KOTodoView *mTodoList;
623 KOEventEditor * mEventEditor; 628 KOEventEditor * mEventEditor;
624 KOTodoEditor * mTodoEditor; 629 KOTodoEditor * mTodoEditor;
625 KOEventViewerDialog * mEventViewerDialog; 630 KOEventViewerDialog * mEventViewerDialog;
626 void keyPressEvent ( QKeyEvent *e) ; 631 void keyPressEvent ( QKeyEvent *e) ;
627 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 632 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
628}; 633};
629 634
630 635
631class CalendarViewVisitor : public Incidence::Visitor 636class CalendarViewVisitor : public Incidence::Visitor
632{ 637{
633 public: 638 public:
634 CalendarViewVisitor() : mView( 0 ) {} 639 CalendarViewVisitor() : mView( 0 ) {}
635 640
636 bool act( Incidence *incidence, CalendarView *view ) 641 bool act( Incidence *incidence, CalendarView *view )
637 { 642 {
638 mView = view; 643 mView = view;
639 return incidence->accept( *this ); 644 return incidence->accept( *this );
640 } 645 }
641 646
642 protected: 647 protected:
643 CalendarView *mView; 648 CalendarView *mView;
644}; 649};
645 650
646class ShowIncidenceVisitor : public CalendarViewVisitor 651class ShowIncidenceVisitor : public CalendarViewVisitor
647{ 652{
648 protected: 653 protected:
649 bool visit( Event *event ) { mView->showEvent( event ); return true; } 654 bool visit( Event *event ) { mView->showEvent( event ); return true; }
650 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 655 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
651 bool visit( Journal * j ) { mView->showJournal( j );return true; } 656 bool visit( Journal * j ) { mView->showJournal( j );return true; }
652}; 657};
653 658
654class EditIncidenceVisitor : public CalendarViewVisitor 659class EditIncidenceVisitor : public CalendarViewVisitor
655{ 660{
656 protected: 661 protected:
657 bool visit( Event *event ) { mView->editEvent( event ); return true; } 662 bool visit( Event *event ) { mView->editEvent( event ); return true; }
658 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 663 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
659 bool visit( Journal *j ) { mView->editJournal( j); return true; } 664 bool visit( Journal *j ) { mView->editJournal( j); return true; }
660}; 665};
661 666
662class DeleteIncidenceVisitor : public CalendarViewVisitor 667class DeleteIncidenceVisitor : public CalendarViewVisitor
663{ 668{
664 protected: 669 protected:
665 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 670 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
666 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 671 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
667 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 672 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
668}; 673};
669 674
670#endif 675#endif
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index c1b149f..6e65a03 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1692 +1,1692 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79#define IDLETIMEOUT 45 79#define IDLETIMEOUT 45
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = font(); 123 QFont nFont = font();
124 p->setFont( font()); 124 p->setFont( font());
125 125
126 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
127 suffix = "00"; 127 suffix = "00";
128 } else 128 } else
129 if (cell > 11) suffix = "pm"; 129 if (cell > 11) suffix = "pm";
130 130
131 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
132 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
133 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
134 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
135 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
136 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
137 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
138 break; 138 break;
139 -- pointS; 139 -- pointS;
140 } 140 }
141 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
142 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
143 } 143 }
144 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
145 QFont sFont = nFont; 145 QFont sFont = nFont;
146 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
147 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
148 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
149 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
150 int startW = mMiniWidth - frameWidth()-2 ; 150 int startW = mMiniWidth - frameWidth()-2 ;
151 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
152 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline 153 //testline
154 //p->drawLine(0,0,0,contentsHeight()); 154 //p->drawLine(0,0,0,contentsHeight());
155 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
156 p->drawLine(startW-tw2+1 ,y,cw+2,y); 156 p->drawLine(startW-tw2+1 ,y,cw+2,y);
157 hour.setNum(cell); 157 hour.setNum(cell);
158 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
159 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
160 if (cell == 12) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
161 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
162 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
163 } 163 }
164 164
165 // center and draw the time label 165 // center and draw the time label
166 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
167 int offset = startW - timeWidth - tw2 -1 ; 167 int offset = startW - timeWidth - tw2 -1 ;
168 p->setFont( nFont ); 168 p->setFont( nFont );
169 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
170 p->setFont( sFont ); 170 p->setFont( sFont );
171 offset = startW - tw2; 171 offset = startW - tw2;
172 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
173 173
174 // increment indices 174 // increment indices
175 y += mCellHeight; 175 y += mCellHeight;
176 cell++; 176 cell++;
177 } 177 }
178 178
179 179
180 180
181 181
182} 182}
183 183
184/** 184/**
185 Calculates the minimum width. 185 Calculates the minimum width.
186*/ 186*/
187int TimeLabels::minimumWidth() const 187int TimeLabels::minimumWidth() const
188{ 188{
189 return mMiniWidth; 189 return mMiniWidth;
190} 190}
191 191
192/** updates widget's internal state */ 192/** updates widget's internal state */
193void TimeLabels::updateConfig() 193void TimeLabels::updateConfig()
194{ 194{
195 mRedrawNeeded = true; 195 mRedrawNeeded = true;
196 // set the font 196 // set the font
197 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
198 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
199 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
200 QString test = "20"; 200 QString test = "20";
201 if (KGlobal::locale()->use12Clock()) 201 if (KGlobal::locale()->use12Clock())
202 test = "12"; 202 test = "12";
203 mMiniWidth = fontMetrics().width(test); 203 mMiniWidth = fontMetrics().width(test);
204 if (KGlobal::locale()->use12Clock()) 204 if (KGlobal::locale()->use12Clock())
205 test = "pm"; 205 test = "pm";
206 else { 206 else {
207 test = "00"; 207 test = "00";
208 } 208 }
209 QFont sFont = font(); 209 QFont sFont = font();
210 sFont.setPointSize( sFont.pointSize()/2 ); 210 sFont.setPointSize( sFont.pointSize()/2 );
211 QFontMetrics fmS( sFont ); 211 QFontMetrics fmS( sFont );
212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; 212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 // update geometry restrictions based on new settings 213 // update geometry restrictions based on new settings
214 setFixedWidth( mMiniWidth ); 214 setFixedWidth( mMiniWidth );
215 215
216 // update HourSize 216 // update HourSize
217 mCellHeight = KOPrefs::instance()->mHourSize*4; 217 mCellHeight = KOPrefs::instance()->mHourSize*4;
218 resizeContents(mMiniWidth,mRows * mCellHeight+1); 218 resizeContents(mMiniWidth,mRows * mCellHeight+1);
219} 219}
220 220
221/** update time label positions */ 221/** update time label positions */
222void TimeLabels::positionChanged() 222void TimeLabels::positionChanged()
223{ 223{
224 int adjustment = mAgenda->contentsY(); 224 int adjustment = mAgenda->contentsY();
225 setContentsPos(0, adjustment); 225 setContentsPos(0, adjustment);
226} 226}
227 227
228/** */ 228/** */
229void TimeLabels::setAgenda(KOAgenda* agenda) 229void TimeLabels::setAgenda(KOAgenda* agenda)
230{ 230{
231 mAgenda = agenda; 231 mAgenda = agenda;
232} 232}
233 233
234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
235{ 235{
236 mMouseDownY = e->pos().y(); 236 mMouseDownY = e->pos().y();
237 mOrgCap = topLevelWidget()->caption(); 237 mOrgCap = topLevelWidget()->caption();
238} 238}
239 239
240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
241{ 241{
242 int diff = mMouseDownY - e->pos().y(); 242 int diff = mMouseDownY - e->pos().y();
243 if ( diff < 10 && diff > -10 ) 243 if ( diff < 10 && diff > -10 )
244 return; 244 return;
245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
246 if ( tSize < 4 ) 246 if ( tSize < 4 )
247 tSize = 4; 247 tSize = 4;
248 if ( tSize > 22 ) 248 if ( tSize > 22 )
249 tSize = 22; 249 tSize = 22;
250 tSize = (tSize-2)/2; 250 tSize = (tSize-2)/2;
251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
252 252
253} 253}
254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
255{ 255{
256 topLevelWidget()->setCaption( mOrgCap ); 256 topLevelWidget()->setCaption( mOrgCap );
257 int diff = mMouseDownY - e->pos().y(); 257 int diff = mMouseDownY - e->pos().y();
258 if ( diff < 10 && diff > -10 ) 258 if ( diff < 10 && diff > -10 )
259 return; 259 return;
260 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 260 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
261 if ( tSize < 4 ) 261 if ( tSize < 4 )
262 tSize = 4; 262 tSize = 4;
263 if ( tSize > 22 ) 263 if ( tSize > 22 )
264 tSize = 22; 264 tSize = 22;
265 tSize = (tSize/2)*2; 265 tSize = (tSize/2)*2;
266 if ( tSize == KOPrefs::instance()->mHourSize ) 266 if ( tSize == KOPrefs::instance()->mHourSize )
267 return; 267 return;
268 KOPrefs::instance()->mHourSize = tSize; 268 KOPrefs::instance()->mHourSize = tSize;
269 emit scaleChanged(); 269 emit scaleChanged();
270} 270}
271 271
272/** This is called in response to repaint() */ 272/** This is called in response to repaint() */
273void TimeLabels::paintEvent(QPaintEvent*) 273void TimeLabels::paintEvent(QPaintEvent*)
274{ 274{
275 275
276 // kdDebug() << "paintevent..." << endl; 276 // kdDebug() << "paintevent..." << endl;
277 // this is another hack! 277 // this is another hack!
278 // QPainter painter(this); 278 // QPainter painter(this);
279 //QString c 279 //QString c
280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
281} 281}
282 282
283//////////////////////////////////////////////////////////////////////////// 283////////////////////////////////////////////////////////////////////////////
284 284
285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
286 : QFrame(parent,name) 286 : QFrame(parent,name)
287{ 287{
288 mColumns = 1; 288 mColumns = 1;
289 mTopBox = 0; 289 mTopBox = 0;
290 mLocation = loc; 290 mLocation = loc;
291 mTopLayout = 0; 291 mTopLayout = 0;
292 mPaintWidget = 0; 292 mPaintWidget = 0;
293 mXOffset = 0; 293 mXOffset = 0;
294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
295 else mPixmap = SmallIcon("1downarrow"); 295 else mPixmap = SmallIcon("1downarrow");
296 mEnabled.resize(mColumns); 296 mEnabled.resize(mColumns);
297 mEnabled.fill( false ); 297 mEnabled.fill( false );
298 setMinimumHeight(mPixmap.height()); 298 setMinimumHeight(mPixmap.height());
299} 299}
300 300
301EventIndicator::~EventIndicator() 301EventIndicator::~EventIndicator()
302{ 302{
303} 303}
304 304
305void EventIndicator::drawContents(QPainter *p) 305void EventIndicator::drawContents(QPainter *p)
306{ 306{
307 307
308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
309 KDGanttSplitterHandle* han = 0; 309 KDGanttSplitterHandle* han = 0;
310 if ( mPaintWidget ) 310 if ( mPaintWidget )
311 han = mPaintWidget->firstHandle(); 311 han = mPaintWidget->firstHandle();
312 if ( ! han ) { 312 if ( ! han ) {
313 int i; 313 int i;
314 for(i=0;i<mColumns;++i) { 314 for(i=0;i<mColumns;++i) {
315 if (mEnabled[i]) { 315 if (mEnabled[i]) {
316 int cellWidth = contentsRect().right()/mColumns; 316 int cellWidth = contentsRect().right()/mColumns;
317 int xOffset = KOGlobals::self()->reverseLayout() ? 317 int xOffset = KOGlobals::self()->reverseLayout() ?
318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
319 i*cellWidth + (cellWidth -mPixmap.width()) /2; 319 i*cellWidth + (cellWidth -mPixmap.width()) /2;
320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
321 } 321 }
322 } 322 }
323 } else { 323 } else {
324 han->repaint(); 324 han->repaint();
325 //mPaintWidget->setBackgroundColor( red ); 325 //mPaintWidget->setBackgroundColor( red );
326 326
327 QPainter pa( han ); 327 QPainter pa( han );
328 int i; 328 int i;
329 bool setColor = false; 329 bool setColor = false;
330 for(i=0;i<mColumns;++i) { 330 for(i=0;i<mColumns;++i) {
331 if (mEnabled[i]) { 331 if (mEnabled[i]) {
332 setColor = true; 332 setColor = true;
333 333
334 int cellWidth = contentsRect().right()/mColumns; 334 int cellWidth = contentsRect().right()/mColumns;
335 int xOffset = KOGlobals::self()->reverseLayout() ? 335 int xOffset = KOGlobals::self()->reverseLayout() ?
336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
337 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 337 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
339 //qDebug("222draw pix %d ",xOffset ); 339 //qDebug("222draw pix %d ",xOffset );
340 340
341 } 341 }
342 342
343 } 343 }
344 pa.end(); 344 pa.end();
345 345
346 } 346 }
347} 347}
348 348
349void EventIndicator::setXOffset( int x ) 349void EventIndicator::setXOffset( int x )
350{ 350{
351 mXOffset = x; 351 mXOffset = x;
352} 352}
353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
354{ 354{
355 mPaintWidget = w; 355 mPaintWidget = w;
356 setMaximumHeight(0); 356 setMaximumHeight(0);
357 setMinimumHeight(0); 357 setMinimumHeight(0);
358} 358}
359void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
360{ 360{
361 mColumns = columns; 361 mColumns = columns;
362 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
363 363
364 update(); 364 update();
365} 365}
366 366
367void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
368{ 368{
369 mEnabled[column] = enable; 369 mEnabled[column] = enable;
370} 370}
371 371
372 372
373//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
376 376
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
379{ 379{
380 flag_blockfillAgenda = false;
380 mBlockUpdating = true; 381 mBlockUpdating = true;
381 mStartHour = 8; 382 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 383 mSelectedDates.append(QDate::currentDate());
383 384
384 mLayoutDayLabels = 0; 385 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 386 mDayLabelsFrame = 0;
386 mDayLabels = 0; 387 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 388 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 389 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 390 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 391 expandPix = SmallIcon( "1updownarrow" );
391 } else { 392 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 393 expandPix = SmallIcon("1leftrightarrow" );
393 } 394 }
394 395
395 QBoxLayout *topLayout = new QVBoxLayout(this); 396 QBoxLayout *topLayout = new QVBoxLayout(this);
396 397
397 // Create day name labels for agenda columns 398 // Create day name labels for agenda columns
398 // Create agenda splitter 399 // Create agenda splitter
399 400
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 403 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 404 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 405 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 406 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 407 agendaFrame->setFocusPolicy(NoFocus);
407 408
408 // Create all-day agenda widget 409 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 410 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 411
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 412 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 413 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 414 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 415 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 416 if ( heibut > widebut )
416 widebut = heibut ; 417 widebut = heibut ;
417 418
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 420 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 421 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 423 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 425 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 426 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 427
427 // Create event context menu for all day agenda 428 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 429 //mAllDayAgendaPopup = eventPopup();
429 430
430 // Create agenda frame 431 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 432 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 433 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 434
434 // create event indicator bars 435 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 436 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 437#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 439#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 440 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 441 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 442 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 443 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 444 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 445 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 446
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 447 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 448 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 449 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 450 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 451 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 452
452 // Create time labels 453 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 454 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 455 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 456 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 457 this,SLOT(updateConfig()));
457 458
458 // Create agenda 459 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 460 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 461 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 462 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 463 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 464 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 465 mAllAgendaPopup = eventPopup();
465 466
466#if 0 467#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 468 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 469 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 470 SLOT(popupAlarm()),true);
470 471
471#endif 472#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 473 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 474 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 475
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 476 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 477 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 478
478 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), 479 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
479 this,SLOT(categoryChanged(Incidence *))); 480 this,SLOT(categoryChanged(Incidence *)));
480 481
481 482
482 mAgenda->setPopup( mAllAgendaPopup ); 483 mAgenda->setPopup( mAllAgendaPopup );
483 mAllDayAgenda->setPopup( mAllAgendaPopup ); 484 mAllDayAgenda->setPopup( mAllAgendaPopup );
484 // make connections between dependent widgets 485 // make connections between dependent widgets
485 mTimeLabels->setAgenda(mAgenda); 486 mTimeLabels->setAgenda(mAgenda);
486 487
487 // Update widgets to reflect user preferences 488 // Update widgets to reflect user preferences
488 // updateConfig(); 489 // updateConfig();
489 490
490 // createDayLabels(); 491 // createDayLabels();
491 492
492 // these blank widgets make the All Day Event box line up with the agenda 493 // these blank widgets make the All Day Event box line up with the agenda
493 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 494 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
494 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 495 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
495 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 496 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
496 497
497 // Scrolling 498 // Scrolling
498 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 499 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
499 mTimeLabels, SLOT(positionChanged())); 500 mTimeLabels, SLOT(positionChanged()));
500 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 501 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
501 SLOT(setContentsPos(int))); 502 SLOT(setContentsPos(int)));
502 503
503 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 504 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
504 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 505 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
505 506
506 // Create/Show/Edit/Delete Event 507 // Create/Show/Edit/Delete Event
507 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 508 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
508 SLOT(newEvent(int,int))); 509 SLOT(newEvent(int,int)));
509 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 510 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
510 SLOT(newTodo(int,int))); 511 SLOT(newTodo(int,int)));
511 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 512 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
512 SLOT(newEvent(int,int,int,int))); 513 SLOT(newEvent(int,int,int,int)));
513 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 514 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
514 SLOT(newEventAllDay(int,int))); 515 SLOT(newEventAllDay(int,int)));
515 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 516 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
516 SLOT(newTodoAllDay(int,int))); 517 SLOT(newTodoAllDay(int,int)));
517 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 518 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
518 SLOT(newEventAllDay(int,int))); 519 SLOT(newEventAllDay(int,int)));
519 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 520 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
520 SLOT(newTimeSpanSelected(int,int,int,int))); 521 SLOT(newTimeSpanSelected(int,int,int,int)));
521 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 522 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
522 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 523 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
523 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 524 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
524 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 525 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
525 526
526 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 527 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
527 SIGNAL(editIncidenceSignal(Incidence *))); 528 SIGNAL(editIncidenceSignal(Incidence *)));
528 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 529 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
529 SIGNAL(editIncidenceSignal(Incidence *))); 530 SIGNAL(editIncidenceSignal(Incidence *)));
530 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 531 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
531 SIGNAL(showIncidenceSignal(Incidence *))); 532 SIGNAL(showIncidenceSignal(Incidence *)));
532 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 533 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
533 SIGNAL(showIncidenceSignal(Incidence *))); 534 SIGNAL(showIncidenceSignal(Incidence *)));
534 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 535 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
535 SIGNAL(deleteIncidenceSignal(Incidence *))); 536 SIGNAL(deleteIncidenceSignal(Incidence *)));
536 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 537 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
537 SIGNAL(deleteIncidenceSignal(Incidence *))); 538 SIGNAL(deleteIncidenceSignal(Incidence *)));
538 539
539 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 540 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
540 SLOT(updateEventDates(KOAgendaItem *, int ))); 541 SLOT(updateEventDates(KOAgendaItem *, int )));
541 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 542 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
542 SLOT(updateEventDates(KOAgendaItem *, int))); 543 SLOT(updateEventDates(KOAgendaItem *, int)));
543 544
544 // event indicator update 545 // event indicator update
545 connect(mAgenda,SIGNAL(lowerYChanged(int)), 546 connect(mAgenda,SIGNAL(lowerYChanged(int)),
546 SLOT(updateEventIndicatorTop(int))); 547 SLOT(updateEventIndicatorTop(int)));
547 connect(mAgenda,SIGNAL(upperYChanged(int)), 548 connect(mAgenda,SIGNAL(upperYChanged(int)),
548 SLOT(updateEventIndicatorBottom(int))); 549 SLOT(updateEventIndicatorBottom(int)));
549 // drag signals 550 // drag signals
550 /* 551 /*
551 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 552 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
552 SLOT(startDrag(Event *))); 553 SLOT(startDrag(Event *)));
553 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 554 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
554 SLOT(startDrag(Event *))); 555 SLOT(startDrag(Event *)));
555 */ 556 */
556 // synchronize selections 557 // synchronize selections
557 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 558 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
558 mAllDayAgenda, SLOT( deselectItem() ) ); 559 mAllDayAgenda, SLOT( deselectItem() ) );
559 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 560 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
560 mAgenda, SLOT( deselectItem() ) ); 561 mAgenda, SLOT( deselectItem() ) );
561 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 562 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
562 SIGNAL( incidenceSelected( Incidence * ) ) ); 563 SIGNAL( incidenceSelected( Incidence * ) ) );
563 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 564 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
564 SIGNAL( incidenceSelected( Incidence * ) ) ); 565 SIGNAL( incidenceSelected( Incidence * ) ) );
565 connect( mAgenda, SIGNAL( resizedSignal() ), 566 connect( mAgenda, SIGNAL( resizedSignal() ),
566 SLOT( updateConfig( ) ) ); 567 SLOT( updateConfig( ) ) );
567 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 568 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
568 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 569 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
569 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 570 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
570 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 571 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
571 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 572 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
572 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 573 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
573 574
574 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 575 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
575 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 576 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
576#ifndef DESKTOP_VERSION 577#ifndef DESKTOP_VERSION
577 connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) ); 578 connect( mAllDayAgenda, SIGNAL( updateViewSignal() ),this, SLOT( fillAgenda()) );
578 connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) ); 579 connect( mAgenda, SIGNAL( updateViewSignal() ), this, SLOT( fillAgenda()) );
579 connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) ); 580 connect( mAllDayAgenda, SIGNAL( sendPing() ),this, SLOT( startIdleTimeout()) );
580 connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) ); 581 connect( mAgenda, SIGNAL( sendPing() ), this, SLOT( startIdleTimeout()) );
581 mIdleTimer = new QTimer ( this );; 582 mIdleTimer = new QTimer ( this );;
582 connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout())); 583 connect(mIdleTimer,SIGNAL(timeout()),SLOT(slotIdleTimeout()));
583#endif 584#endif
584} 585}
585void KOAgendaView::startIdleTimeout() 586void KOAgendaView::startIdleTimeout()
586{ 587{
587#ifndef DESKTOP_VERSION 588#ifndef DESKTOP_VERSION
588 mIdleStart = QDateTime::currentDateTime(); 589 mIdleStart = QDateTime::currentDateTime();
589 mIdleTimer->start( IDLETIMEOUT * 1000 ); 590 mIdleTimer->start( IDLETIMEOUT * 1000 );
590#endif 591#endif
591} 592}
592void KOAgendaView::slotIdleTimeout() 593void KOAgendaView::slotIdleTimeout()
593{ 594{
594#ifndef DESKTOP_VERSION 595#ifndef DESKTOP_VERSION
595 //qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) ); 596 //qDebug("SECS TO %d ",mIdleStart.secsTo( QDateTime::currentDateTime() ) );
596 int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() ); 597 int secsfromstart = mIdleStart.secsTo( QDateTime::currentDateTime() );
597 mIdleTimer->stop(); 598 mIdleTimer->stop();
598 bool isActice = topLevelWidget()->isActiveWindow(); 599 bool isActice = topLevelWidget()->isActiveWindow();
599 //qDebug("KO: Active Window %d %d", isActice, isVisible()); 600 //qDebug("KO: Active Window %d %d", isActice, isVisible());
600 // we do nothing if we wake up from a suspend 601 // we do nothing if we wake up from a suspend
601 if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) { 602 if ( secsfromstart > IDLETIMEOUT + 30 && isActice ) {
602 qDebug("KO: Wakeup from suspend "); 603 qDebug("KO: Wakeup from suspend ");
603 startIdleTimeout(); 604 startIdleTimeout();
604 return; 605 return;
605 } 606 }
606 qDebug("KO: Downsizing Pixmaps %s",QDateTime::currentDateTime().toString().latin1()); 607 qDebug("KO: Downsizing Pixmaps %s",QDateTime::currentDateTime().toString().latin1());
607 mAgenda->shrinkPixmap(); 608 mAgenda->shrinkPixmap();
608 mAllDayAgenda->shrinkPixmap(); 609 mAllDayAgenda->shrinkPixmap();
609 KOAgendaItem::paintPix()->resize( 20,20); 610 KOAgendaItem::paintPix()->resize( 20,20);
610 KOAgendaItem::paintPixAllday()->resize( 20,20); 611 KOAgendaItem::paintPixAllday()->resize( 20,20);
611#endif 612#endif
612 613
613} 614}
614void KOAgendaView::toggleAllDay() 615void KOAgendaView::toggleAllDay()
615{ 616{
616 if ( mSplitterAgenda->firstHandle() ) 617 if ( mSplitterAgenda->firstHandle() )
617 mSplitterAgenda->firstHandle()->toggle(); 618 mSplitterAgenda->firstHandle()->toggle();
618} 619}
619void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 620void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
620{ 621{
621 calendar()->addIncidence( inc ); 622 calendar()->addIncidence( inc );
622 623
623 if ( incOld ) { 624 if ( incOld ) {
624 if ( incOld->typeID() == todoID ) 625 if ( incOld->typeID() == todoID )
625 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 626 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
626 else 627 else
627 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 628 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
628 } 629 }
629 630
630} 631}
631void KOAgendaView::categoryChanged(Incidence * inc) 632void KOAgendaView::categoryChanged(Incidence * inc)
632{ 633{
633 mAgenda->categoryChanged( inc ); 634 mAgenda->categoryChanged( inc );
634 mAllDayAgenda->categoryChanged( inc ); 635 mAllDayAgenda->categoryChanged( inc );
635} 636}
636KOAgendaView::~KOAgendaView() 637KOAgendaView::~KOAgendaView()
637{ 638{
638 delete mAllAgendaPopup; 639 delete mAllAgendaPopup;
639 //delete mAllDayAgendaPopup; 640 //delete mAllDayAgendaPopup;
640 delete KOAgendaItem::paintPix(); 641 delete KOAgendaItem::paintPix();
641 delete KOAgendaItem::paintPixAllday(); 642 delete KOAgendaItem::paintPixAllday();
642} 643}
643void KOAgendaView::resizeEvent( QResizeEvent* e ) 644void KOAgendaView::resizeEvent( QResizeEvent* e )
644{ 645{
645 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 646 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
646 bool uc = false; 647 bool uc = false;
647 int ow = e->oldSize().width(); 648 int ow = e->oldSize().width();
648 int oh = e->oldSize().height(); 649 int oh = e->oldSize().height();
649 int w = e->size().width(); 650 int w = e->size().width();
650 int h = e->size().height(); 651 int h = e->size().height();
651 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 652 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
652 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 653 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
653 uc = true; 654 uc = true;
654 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 655 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
655 } 656 }
656 mUpcomingWidth = e->size().width() ; 657 mUpcomingWidth = e->size().width() ;
657 if ( mBlockUpdating || uc ) { 658 if ( mBlockUpdating || uc ) {
658 mBlockUpdating = false; 659 mBlockUpdating = false;
659 //mAgenda->setMinimumSize(800 , 600 ); 660 //mAgenda->setMinimumSize(800 , 600 );
660 //qDebug("mAgenda->resize+++++++++++++++ "); 661 //qDebug("mAgenda->resize+++++++++++++++ ");
661 updateConfig(); 662 updateConfig();
662 //qDebug("KOAgendaView::Updating now possible "); 663 //qDebug("KOAgendaView::Updating now possible ");
663 } else 664 } else
664 createDayLabels(); 665 createDayLabels();
665 //qDebug("resizeEvent end "); 666 //qDebug("resizeEvent end ");
666 667
667} 668}
668void KOAgendaView::slotDaylabelClicked( int num ) 669void KOAgendaView::slotDaylabelClicked( int num )
669{ 670{
670 671
671 QDate firstDate = mSelectedDates.first(); 672 QDate firstDate = mSelectedDates.first();
672 if ( num == -1 ) 673 if ( num == -1 )
673 emit showDateView( 6, firstDate ); 674 emit showDateView( 6, firstDate );
674 else if (num >= 0 ) { 675 else if (num >= 0 ) {
675 if ( mSelectedDates.count() == 1) 676 if ( mSelectedDates.count() == 1)
676 emit showDateView( 9, firstDate.addDays( num ) ); 677 emit showDateView( 9, firstDate.addDays( num ) );
677 else 678 else
678 emit showDateView( 3, firstDate.addDays( num ) ); 679 emit showDateView( 3, firstDate.addDays( num ) );
679 } 680 }
680 else 681 else
681 showDateView( 10, firstDate.addDays(1) ); 682 showDateView( 10, firstDate.addDays(1) );
682} 683}
683 684
684KOAgendaButton* KOAgendaView::getNewDaylabel() 685KOAgendaButton* KOAgendaView::getNewDaylabel()
685{ 686{
686 687
687 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 688 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
688 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 689 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
689 mDayLabelsList.append( dayLabel ); 690 mDayLabelsList.append( dayLabel );
690 mLayoutDayLabels->addWidget(dayLabel); 691 mLayoutDayLabels->addWidget(dayLabel);
691 return dayLabel ; 692 return dayLabel ;
692} 693}
693 694
694void KOAgendaView::createDayLabels() 695void KOAgendaView::createDayLabels()
695{ 696{
696 697
697 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 698 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
698 // qDebug(" KOAgendaView::createDayLabels() blocked "); 699 // qDebug(" KOAgendaView::createDayLabels() blocked ");
699 return; 700 return;
700 701
701 } 702 }
702 int newHight; 703 int newHight;
703 if ( !mSelectedDates.count()) 704 if ( !mSelectedDates.count())
704 return; 705 return;
705 706
706 // ### Before deleting and recreating we could check if mSelectedDates changed... 707 // ### Before deleting and recreating we could check if mSelectedDates changed...
707 // It would remove some flickering and gain speed (since this is called by 708 // It would remove some flickering and gain speed (since this is called by
708 // each updateView() call) 709 // each updateView() call)
709 710
710 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 711 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
711 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 712 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
712 if ( maxWid < 20 ) 713 if ( maxWid < 20 )
713 maxWid = 20; 714 maxWid = 20;
714 715
715 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 716 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
716 QFontMetrics fm ( dlf ); 717 QFontMetrics fm ( dlf );
717 dlf.setBold( true ); 718 dlf.setBold( true );
718 int selCount = mSelectedDates.count(); 719 int selCount = mSelectedDates.count();
719 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 720 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
720 if ( widModulo < 0 || widModulo > selCount ) 721 if ( widModulo < 0 || widModulo > selCount )
721 widModulo = 0; 722 widModulo = 0;
722 QString dayTest = "Mon 20"; 723 QString dayTest = "Mon 20";
723 //QString dayTest = "Mon 20"; 724 //QString dayTest = "Mon 20";
724 int wid = fm.width( dayTest ); 725 int wid = fm.width( dayTest );
725 //maxWid -= ( selCount * 3 ); //working for QLabels 726 //maxWid -= ( selCount * 3 ); //working for QLabels
726 if ( QApplication::desktop()->width() <= 320 ) 727 if ( QApplication::desktop()->width() <= 320 )
727 maxWid -= ( selCount * 3 ); //working for QPushButton 728 maxWid -= ( selCount * 3 ); //working for QPushButton
728 else 729 else
729 maxWid -= ( selCount * 4 ); //working for QPushButton 730 maxWid -= ( selCount * 4 ); //working for QPushButton
730 if ( maxWid < 0 ) 731 if ( maxWid < 0 )
731 maxWid = 20; 732 maxWid = 20;
732 int needWid = wid * selCount; 733 int needWid = wid * selCount;
733 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 734 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
734 //if ( needWid > maxWid ) 735 //if ( needWid > maxWid )
735 // qDebug("DAYLABELS TOOOOOOO BIG "); 736 // qDebug("DAYLABELS TOOOOOOO BIG ");
736 while ( needWid > maxWid ) { 737 while ( needWid > maxWid ) {
737 dayTest = dayTest.left( dayTest.length() - 1 ); 738 dayTest = dayTest.left( dayTest.length() - 1 );
738 wid = fm.width( dayTest ); 739 wid = fm.width( dayTest );
739 needWid = wid * selCount; 740 needWid = wid * selCount;
740 } 741 }
741 int maxLen = dayTest.length(); 742 int maxLen = dayTest.length();
742 int fontPoint = dlf.pointSize(); 743 int fontPoint = dlf.pointSize();
743 if ( maxLen < 2 ) { 744 if ( maxLen < 2 ) {
744 int fontPoint = dlf.pointSize(); 745 int fontPoint = dlf.pointSize();
745 while ( fontPoint > 4 ) { 746 while ( fontPoint > 4 ) {
746 --fontPoint; 747 --fontPoint;
747 dlf.setPointSize( fontPoint ); 748 dlf.setPointSize( fontPoint );
748 QFontMetrics f( dlf ); 749 QFontMetrics f( dlf );
749 wid = f.width( "30" ); 750 wid = f.width( "30" );
750 needWid = wid * selCount; 751 needWid = wid * selCount;
751 if ( needWid < maxWid ) 752 if ( needWid < maxWid )
752 break; 753 break;
753 } 754 }
754 maxLen = 2; 755 maxLen = 2;
755 } 756 }
756 //qDebug("Max len %d ", dayTest.length() ); 757 //qDebug("Max len %d ", dayTest.length() );
757 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() ) 758 if ( !KOPrefs::instance()->mTimeLabelsFont.bold() )
758 dlf.setBold( false ); 759 dlf.setBold( false );
759 QFontMetrics tempF( dlf ); 760 QFontMetrics tempF( dlf );
760 newHight = tempF.height(); 761 newHight = tempF.height();
761 mDayLabels->setFont( dlf ); 762 mDayLabels->setFont( dlf );
762 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 763 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
763 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 764 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
764 //mLayoutDayLabels->addSpacing( 2 ); 765 //mLayoutDayLabels->addSpacing( 2 );
765 // QFont lFont = dlf; 766 // QFont lFont = dlf;
766 bool appendLabels = false; 767 bool appendLabels = false;
767 KOAgendaButton *dayLabel; 768 KOAgendaButton *dayLabel;
768 dayLabel = mDayLabelsList.first(); 769 dayLabel = mDayLabelsList.first();
769 if ( !dayLabel ) { 770 if ( !dayLabel ) {
770 appendLabels = true; 771 appendLabels = true;
771 dayLabel = getNewDaylabel(); 772 dayLabel = getNewDaylabel();
772 } 773 }
773 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 774 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
774 dayLabel->setFont( dlf ); 775 dayLabel->setFont( dlf );
775 dayLabel->setNum( -1 ); 776 dayLabel->setNum( -1 );
776 //dayLabel->setAlignment(QLabel::AlignHCenter); 777 //dayLabel->setAlignment(QLabel::AlignHCenter);
777 778
778 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 779 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
779 dayLabel->show(); 780 dayLabel->show();
780 DateList::ConstIterator dit; 781 DateList::ConstIterator dit;
781 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 782 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
782 int counter = -1; 783 int counter = -1;
783 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 784 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
784 ++counter; 785 ++counter;
785 QDate date = *dit; 786 QDate date = *dit;
786 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 787 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
787 if ( ! appendLabels ) { 788 if ( ! appendLabels ) {
788 dayLabel = mDayLabelsList.next(); 789 dayLabel = mDayLabelsList.next();
789 if ( !dayLabel ) 790 if ( !dayLabel )
790 appendLabels = true; 791 appendLabels = true;
791 } 792 }
792 if ( appendLabels ) { 793 if ( appendLabels ) {
793 dayLabel = getNewDaylabel(); 794 dayLabel = getNewDaylabel();
794 } 795 }
795 dayLabel->setMinimumWidth( 1 ); 796 dayLabel->setMinimumWidth( 1 );
796 dayLabel->setMaximumWidth( 10240 ); 797 dayLabel->setMaximumWidth( 10240 );
797 dayLabel->setFont( dlf ); 798 dayLabel->setFont( dlf );
798 dayLabel->show(); 799 dayLabel->show();
799 dayLabel->setAutoRepeat( false ); 800 dayLabel->setAutoRepeat( false );
800 dayLabel->setNum( counter ); 801 dayLabel->setNum( counter );
801 QString str; 802 QString str;
802 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 803 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
803 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 804 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
804 switch ( maxLen ) { 805 switch ( maxLen ) {
805 case 2: 806 case 2:
806 str = QString::number( date.day() ); 807 str = QString::number( date.day() );
807 break; 808 break;
808 809
809 case 3: 810 case 3:
810 str = dayName.left( 1 ) +QString::number( date.day()); 811 str = dayName.left( 1 ) +QString::number( date.day());
811 812
812 break; 813 break;
813 case 4: 814 case 4:
814 str = dayName.left( 1 ) + " " +QString::number( date.day()); 815 str = dayName.left( 1 ) + " " +QString::number( date.day());
815 816
816 break; 817 break;
817 case 5: 818 case 5:
818 str = dayName.left( 2 ) + " " +QString::number( date.day()); 819 str = dayName.left( 2 ) + " " +QString::number( date.day());
819 820
820 break; 821 break;
821 case 6: 822 case 6:
822 str = dayName.left( 3 ) + " " +QString::number( date.day()); 823 str = dayName.left( 3 ) + " " +QString::number( date.day());
823 break; 824 break;
824 825
825 default: 826 default:
826 break; 827 break;
827 } 828 }
828 if ( oneday ) { 829 if ( oneday ) {
829 QString addString; 830 QString addString;
830 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 831 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
831 addString = i18n("Today"); 832 addString = i18n("Today");
832 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 833 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
833 addString = i18n("Tomorrow"); 834 addString = i18n("Tomorrow");
834 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 835 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
835 addString = i18n("Yesterday"); 836 addString = i18n("Yesterday");
836 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 837 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
837 addString = i18n("Day before yesterday"); 838 addString = i18n("Day before yesterday");
838 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 839 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
839 addString = i18n("Day after tomorrow"); 840 addString = i18n("Day after tomorrow");
840 if ( !addString.isEmpty() ) { 841 if ( !addString.isEmpty() ) {
841 if ( QApplication::desktop()->width() < 640 ) 842 if ( QApplication::desktop()->width() < 640 )
842 str = addString+", " + str; 843 str = addString+", " + str;
843 else 844 else
844 str = addString+", "+ KGlobal::locale()->formatDate( date, false); 845 str = addString+", "+ KGlobal::locale()->formatDate( date, false);
845 } else { 846 } else {
846 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 847 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
847 } 848 }
848 } 849 }
849 dayLabel->setText(str); 850 dayLabel->setText(str);
850 //dayLabel->setAlignment(QLabel::AlignHCenter); 851 //dayLabel->setAlignment(QLabel::AlignHCenter);
851 if (date == QDate::currentDate()) { 852 if (date == QDate::currentDate()) {
852 QFont bFont = dlf; 853 QFont bFont = dlf;
853 bFont.setBold( true ); 854 bFont.setBold( true );
854 dayLabel->setFont(bFont); 855 dayLabel->setFont(bFont);
855 } 856 }
856 //dayLayout->addWidget(dayLabel); 857 //dayLayout->addWidget(dayLabel);
857 858
858#ifndef KORG_NOPLUGINS 859#ifndef KORG_NOPLUGINS
859 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 860 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
860 CalendarDecoration *it; 861 CalendarDecoration *it;
861 for(it = cds.first(); it; it = cds.next()) { 862 for(it = cds.first(); it; it = cds.next()) {
862 QString text = it->shortText( date ); 863 QString text = it->shortText( date );
863 if ( !text.isEmpty() ) { 864 if ( !text.isEmpty() ) {
864 QLabel *label = new QLabel(text,mDayLabels); 865 QLabel *label = new QLabel(text,mDayLabels);
865 label->setAlignment(AlignCenter); 866 label->setAlignment(AlignCenter);
866 dayLayout->addWidget(label); 867 dayLayout->addWidget(label);
867 } 868 }
868 } 869 }
869 870
870 for(it = cds.first(); it; it = cds.next()) { 871 for(it = cds.first(); it; it = cds.next()) {
871 QWidget *wid = it->smallWidget(mDayLabels,date); 872 QWidget *wid = it->smallWidget(mDayLabels,date);
872 if ( wid ) { 873 if ( wid ) {
873 // wid->setHeight(20); 874 // wid->setHeight(20);
874 dayLayout->addWidget(wid); 875 dayLayout->addWidget(wid);
875 } 876 }
876 } 877 }
877#endif 878#endif
878 } 879 }
879 if ( ! appendLabels ) { 880 if ( ! appendLabels ) {
880 dayLabel = mDayLabelsList.next(); 881 dayLabel = mDayLabelsList.next();
881 if ( !dayLabel ) 882 if ( !dayLabel )
882 appendLabels = true; 883 appendLabels = true;
883 } 884 }
884 if ( appendLabels ) { 885 if ( appendLabels ) {
885 dayLabel = getNewDaylabel(); 886 dayLabel = getNewDaylabel();
886 } 887 }
887 //dayLabel->hide();//test only 888 //dayLabel->hide();//test only
888 889
889 dayLabel->setText(">"); 890 dayLabel->setText(">");
890 dayLabel->setFont( dlf ); 891 dayLabel->setFont( dlf );
891 dayLabel->setAutoRepeat( true ); 892 dayLabel->setAutoRepeat( true );
892 dayLabel->show(); 893 dayLabel->show();
893 dayLabel->setNum( -2 ); 894 dayLabel->setNum( -2 );
894 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 895 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
895 896
896 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 897 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
897 if ( !appendLabels ) { 898 if ( !appendLabels ) {
898 dayLabel = mDayLabelsList.next(); 899 dayLabel = mDayLabelsList.next();
899 while ( dayLabel ) { 900 while ( dayLabel ) {
900 //qDebug("!dayLabel %d",dayLabel ); 901 //qDebug("!dayLabel %d",dayLabel );
901 dayLabel->hide(); 902 dayLabel->hide();
902 dayLabel = mDayLabelsList.next(); 903 dayLabel = mDayLabelsList.next();
903 } 904 }
904 } 905 }
905 906
906 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 907 mDayLabelsFrame->setFixedHeight( newHight + 4 );
907} 908}
908 909
909int KOAgendaView::maxDatesHint() 910int KOAgendaView::maxDatesHint()
910{ 911{
911 // Not sure about the max number of events, so return 0 for now. 912 // Not sure about the max number of events, so return 0 for now.
912 return 0; 913 return 0;
913} 914}
914 915
915int KOAgendaView::currentDateCount() 916int KOAgendaView::currentDateCount()
916{ 917{
917 return mSelectedDates.count(); 918 return mSelectedDates.count();
918} 919}
919 920
920QPtrList<Incidence> KOAgendaView::selectedIncidences() 921QPtrList<Incidence> KOAgendaView::selectedIncidences()
921{ 922{
922 QPtrList<Incidence> selected; 923 QPtrList<Incidence> selected;
923 Incidence *incidence; 924 Incidence *incidence;
924 925
925 incidence = mAgenda->selectedIncidence(); 926 incidence = mAgenda->selectedIncidence();
926 if (incidence) selected.append(incidence); 927 if (incidence) selected.append(incidence);
927 928
928 incidence = mAllDayAgenda->selectedIncidence(); 929 incidence = mAllDayAgenda->selectedIncidence();
929 if (incidence) selected.append(incidence); 930 if (incidence) selected.append(incidence);
930 931
931 return selected; 932 return selected;
932} 933}
933 934
934DateList KOAgendaView::selectedDates() 935DateList KOAgendaView::selectedDates()
935{ 936{
936 DateList selected; 937 DateList selected;
937 QDate qd; 938 QDate qd;
938 939
939 qd = mAgenda->selectedIncidenceDate(); 940 qd = mAgenda->selectedIncidenceDate();
940 if (qd.isValid()) selected.append(qd); 941 if (qd.isValid()) selected.append(qd);
941 942
942 qd = mAllDayAgenda->selectedIncidenceDate(); 943 qd = mAllDayAgenda->selectedIncidenceDate();
943 if (qd.isValid()) selected.append(qd); 944 if (qd.isValid()) selected.append(qd);
944 945
945 return selected; 946 return selected;
946} 947}
947 948
948 949
949void KOAgendaView::updateView() 950void KOAgendaView::updateView()
950{ 951{
951 if ( mBlockUpdating ) 952 if ( mBlockUpdating )
952 return; 953 return;
953 // kdDebug() << "KOAgendaView::updateView()" << endl; 954 // kdDebug() << "KOAgendaView::updateView()" << endl;
954 fillAgenda(); 955 fillAgenda();
955 956
956} 957}
957 958
958 959
959/* 960/*
960 Update configuration settings for the agenda view. This method is not 961 Update configuration settings for the agenda view. This method is not
961 complete. 962 complete.
962*/ 963*/
963void KOAgendaView::updateConfig() 964void KOAgendaView::updateConfig()
964{ 965{
965 if ( mBlockUpdating ) 966 if ( mBlockUpdating )
966 return; 967 return;
967 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 968 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
968 int old = KOPrefs::instance()->mHourSize; 969 int old = KOPrefs::instance()->mHourSize;
969 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 970 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
970 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 971 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
971 } 972 }
972 973
973 974
974 // update config for children 975 // update config for children
975 mTimeLabels->updateConfig(); 976 mTimeLabels->updateConfig();
976 mAgenda->storePosition(); 977 mAgenda->storePosition();
977 mAgenda->updateConfig(); 978 mAgenda->updateConfig();
978 mAllDayAgenda->updateConfig(); 979 mAllDayAgenda->updateConfig();
979 // widget synchronization 980 // widget synchronization
980 //TODO: find a better way, maybe signal/slot 981 //TODO: find a better way, maybe signal/slot
981 mTimeLabels->positionChanged(); 982 mTimeLabels->positionChanged();
982 983
983 // for some reason, this needs to be called explicitly 984 // for some reason, this needs to be called explicitly
984 mTimeLabels->repaint(); 985 mTimeLabels->repaint();
985 986
986 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 987 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
987 988
988 // ToolTips displaying summary of events 989 // ToolTips displaying summary of events
989 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 990 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
990 ->mEnableToolTips); 991 ->mEnableToolTips);
991 992
992 //setHolidayMasks(); 993 //setHolidayMasks();
993 994
994 //createDayLabels(); called by via updateView(); 995 //createDayLabels(); called by via updateView();
995 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 996 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
996 updateView(); 997 updateView();
997 mAgenda->restorePosition(); 998 mAgenda->restorePosition();
998} 999}
999 1000
1000 1001
1001void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 1002void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
1002{ 1003{
1003 1004
1004 1005
1005 int xxx = item->cellX(); 1006 int xxx = item->cellX();
1006 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); 1007 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() );
1007 if ( xxx >= 0 && xxx < mMinY.count() && !item->isAllDay() ) { 1008 if ( xxx >= 0 && xxx < mMinY.count() && !item->isAllDay() ) {
1008 if ( mMinY.at(xxx) > item->cellYTop() ) 1009 if ( mMinY.at(xxx) > item->cellYTop() )
1009 mMinY.at(xxx) = item->cellYTop(); 1010 mMinY.at(xxx) = item->cellYTop();
1010 if ( mMaxY.at(xxx) < item->cellYBottom() ) 1011 if ( mMaxY.at(xxx) < item->cellYBottom() )
1011 mMaxY.at(xxx) = item->cellYBottom(); 1012 mMaxY.at(xxx) = item->cellYBottom();
1012 } 1013 }
1013 QDateTime startDt,endDt; 1014 QDateTime startDt,endDt;
1014 QDate startDate; 1015 QDate startDate;
1015 int lenInSecs; 1016 int lenInSecs;
1016 // if ( type == KOAgenda::RESIZETOP ) 1017 // if ( type == KOAgenda::RESIZETOP )
1017 // qDebug("RESIZETOP "); 1018 // qDebug("RESIZETOP ");
1018 // if ( type == KOAgenda::RESIZEBOTTOM ) 1019 // if ( type == KOAgenda::RESIZEBOTTOM )
1019 // qDebug("RESIZEBOTTOM "); 1020 // qDebug("RESIZEBOTTOM ");
1020 // if ( type == KOAgenda::MOVE ) 1021 // if ( type == KOAgenda::MOVE )
1021 // qDebug("MOVE "); 1022 // qDebug("MOVE ");
1022 if ( item->incidence()->typeID() == eventID ) { 1023 if ( item->incidence()->typeID() == eventID ) {
1023 startDt =item->incidence()->dtStart(); 1024 startDt =item->incidence()->dtStart();
1024 endDt = item->incidence()->dtEnd(); 1025 endDt = item->incidence()->dtEnd();
1025 lenInSecs = startDt.secsTo( endDt ); 1026 lenInSecs = startDt.secsTo( endDt );
1026 } 1027 }
1027 1028
1028 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 1029 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
1029 1030
1030 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { 1031 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) {
1031 startDate = mSelectedDates[item->mLastMoveXPos]; 1032 startDate = mSelectedDates[item->mLastMoveXPos];
1032 } else { 1033 } else {
1033 if (item->cellX() < 0) { 1034 if (item->cellX() < 0) {
1034 startDate = (mSelectedDates.first()).addDays(item->cellX()); 1035 startDate = (mSelectedDates.first()).addDays(item->cellX());
1035 } else { 1036 } else {
1036 startDate = mSelectedDates[item->cellX()]; 1037 startDate = mSelectedDates[item->cellX()];
1037 } 1038 }
1038 } 1039 }
1039 startDt.setDate(startDate); 1040 startDt.setDate(startDate);
1040 1041
1041 if (item->incidence()->doesFloat()) { 1042 if (item->incidence()->doesFloat()) {
1042 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 1043 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
1043 } else { 1044 } else {
1044 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 1045 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
1045 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 1046 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
1046 if ( item->incidence()->typeID() == eventID ) { 1047 if ( item->incidence()->typeID() == eventID ) {
1047 if ( type == KOAgenda::MOVE ) { 1048 if ( type == KOAgenda::MOVE ) {
1048 endDt = startDt.addSecs(lenInSecs); 1049 endDt = startDt.addSecs(lenInSecs);
1049 1050
1050 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 1051 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
1051 if (item->lastMultiItem()) { 1052 if (item->lastMultiItem()) {
1052 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1053 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1053 endDt.setDate(startDate. 1054 endDt.setDate(startDate.
1054 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1055 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1055 } else { 1056 } else {
1056 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1057 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1057 endDt.setDate(startDate); 1058 endDt.setDate(startDate);
1058 } 1059 }
1059 } 1060 }
1060 } else { 1061 } else {
1061 // todo 1062 // todo
1062 if (item->lastMultiItem()) { 1063 if (item->lastMultiItem()) {
1063 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1064 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1064 endDt.setDate(startDate. 1065 endDt.setDate(startDate.
1065 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1066 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1066 } else { 1067 } else {
1067 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1068 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1068 if ( item->cellYBottom() > 0 ) 1069 if ( item->cellYBottom() > 0 )
1069 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1070 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1070 else 1071 else
1071 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1072 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1072 endDt.setDate(startDate); 1073 endDt.setDate(startDate);
1073 } 1074 }
1074 } 1075 }
1075 } 1076 }
1076 if ( item->incidence()->typeID() == eventID ) { 1077 if ( item->incidence()->typeID() == eventID ) {
1077 item->incidence()->setDtStart(startDt); 1078 item->incidence()->setDtStart(startDt);
1078 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1079 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1079 } else if ( item->incidence()->typeID() == todoID ) { 1080 } else if ( item->incidence()->typeID() == todoID ) {
1080 Todo* to = static_cast<Todo*>(item->incidence()); 1081 Todo* to = static_cast<Todo*>(item->incidence());
1081 1082
1082 to->setDtDue(endDt); 1083 to->setDtDue(endDt);
1083 if ( to->hasStartDate() ) { 1084 if ( to->hasStartDate() ) {
1084 if (to->dtStart() >= to->dtDue() ) 1085 if (to->dtStart() >= to->dtDue() )
1085 to->setDtStart(to->dtDue().addDays( -2 )); 1086 to->setDtStart(to->dtDue().addDays( -2 ));
1086 } 1087 }
1087 1088
1088 } 1089 }
1089 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1090 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1090 item->incidence()->setRevision(item->incidence()->revision()+1); 1091 item->incidence()->setRevision(item->incidence()->revision()+1);
1091 item->setItemDate(startDt.date()); 1092 item->setItemDate(startDt.date());
1092 //item->updateItem(); 1093 //item->updateItem();
1093 if ( item->incidence()->typeID() == todoID ) { 1094 if ( item->incidence()->typeID() == todoID ) {
1094 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1095 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1095 1096
1096 } 1097 }
1097 else 1098 else
1098 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1099 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1099 item->updateItem(); 1100 item->updateItem();
1100} 1101}
1101 1102
1102void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1103void KOAgendaView::showDates( const QDate &start, const QDate &end )
1103{ 1104{
1104 // kdDebug() << "KOAgendaView::selectDates" << endl; 1105 // kdDebug() << "KOAgendaView::selectDates" << endl;
1105 1106
1106 mSelectedDates.clear(); 1107 mSelectedDates.clear();
1107 // qDebug("KOAgendaView::showDates "); 1108 // qDebug("KOAgendaView::showDates ");
1108 QDate d = start; 1109 QDate d = start;
1109 while (d <= end) { 1110 while (d <= end) {
1110 mSelectedDates.append(d); 1111 mSelectedDates.append(d);
1111 d = d.addDays( 1 ); 1112 d = d.addDays( 1 );
1112 } 1113 }
1113 1114
1114 // and update the view 1115 // and update the view
1115 fillAgenda(); 1116 fillAgenda();
1116} 1117}
1117 1118
1118 1119
1119void KOAgendaView::showEvents(QPtrList<Event>) 1120void KOAgendaView::showEvents(QPtrList<Event>)
1120{ 1121{
1121 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1122 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1122} 1123}
1123 1124
1124void KOAgendaView::changeEventDisplay(Event *, int) 1125void KOAgendaView::changeEventDisplay(Event *, int)
1125{ 1126{
1126 // qDebug("KOAgendaView::changeEventDisplay "); 1127 // qDebug("KOAgendaView::changeEventDisplay ");
1127 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1128 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1128 // this should be re-written to be MUCH smarter. Right now we 1129 // this should be re-written to be MUCH smarter. Right now we
1129 // are just playing dumb. 1130 // are just playing dumb.
1130 fillAgenda(); 1131 fillAgenda();
1131} 1132}
1132 1133
1133void KOAgendaView::fillAgenda(const QDate &) 1134void KOAgendaView::fillAgenda(const QDate &)
1134{ 1135{
1135 // qDebug("KOAgendaView::fillAgenda "); 1136 // qDebug("KOAgendaView::fillAgenda ");
1136 fillAgenda(); 1137 fillAgenda();
1137} 1138}
1138 1139
1139void KOAgendaView::fillAgenda() 1140void KOAgendaView::fillAgenda()
1140{ 1141{
1141 if ( globalFlagBlockStartup ) 1142 if ( globalFlagBlockStartup )
1142 return; 1143 return;
1143 if ( globalFlagBlockAgenda == 1 ) 1144 if ( globalFlagBlockAgenda == 1 )
1144 return; 1145 return;
1145 static bool onlyOne = false; 1146 if ( flag_blockfillAgenda )
1146 if ( onlyOne )
1147 return; 1147 return;
1148 onlyOne = true; 1148 flag_blockfillAgenda = true;
1149 //if ( globalFlagBlockAgenda == 2 ) 1149 //if ( globalFlagBlockAgenda == 2 )
1150 //globalFlagBlockAgenda = 0; 1150 //globalFlagBlockAgenda = 0;
1151 // globalFlagBlockPainting = false; 1151 // globalFlagBlockPainting = false;
1152 if ( globalFlagBlockAgenda == 0 ) 1152 if ( globalFlagBlockAgenda == 0 )
1153 globalFlagBlockAgenda = 1; 1153 globalFlagBlockAgenda = 1;
1154 // clearView(); 1154 // clearView();
1155 //qDebug("fillAgenda()++++ "); 1155 //qDebug("fillAgenda()++++ ");
1156 globalFlagBlockAgendaItemPaint = 1; 1156 globalFlagBlockAgendaItemPaint = 1;
1157 1157
1158 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1158 mAllDayAgenda->changeColumns(mSelectedDates.count());
1159 mAgenda->changeColumns(mSelectedDates.count()); 1159 mAgenda->changeColumns(mSelectedDates.count());
1160 qApp->processEvents(); 1160 qApp->processEvents();
1161 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1161 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1162 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1162 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1163 setHolidayMasks(); 1163 setHolidayMasks();
1164 1164
1165 mMinY.resize(mSelectedDates.count()); 1165 mMinY.resize(mSelectedDates.count());
1166 mMaxY.resize(mSelectedDates.count()); 1166 mMaxY.resize(mSelectedDates.count());
1167 1167
1168 QPtrList<Event> dayEvents; 1168 QPtrList<Event> dayEvents;
1169 1169
1170 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1170 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1171 // Therefore, gtodoset all of them. 1171 // Therefore, gtodoset all of them.
1172 QPtrList<Todo> todos = calendar()->todos(); 1172 QPtrList<Todo> todos = calendar()->todos();
1173 1173
1174 mAgenda->setDateList(mSelectedDates); 1174 mAgenda->setDateList(mSelectedDates);
1175 1175
1176 QDate today = QDate::currentDate(); 1176 QDate today = QDate::currentDate();
1177 1177
1178 DateList::ConstIterator dit; 1178 DateList::ConstIterator dit;
1179 int curCol = 0; 1179 int curCol = 0;
1180 int maxCol = mSelectedDates.count()-1; 1180 int maxCol = mSelectedDates.count()-1;
1181 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1181 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1182 QDate currentDate = *dit; 1182 QDate currentDate = *dit;
1183 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1183 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1184 // << endl; 1184 // << endl;
1185 1185
1186 dayEvents = calendar()->events(currentDate,false); 1186 dayEvents = calendar()->events(currentDate,false);
1187 1187
1188 // Default values, which can never be reached 1188 // Default values, which can never be reached
1189 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1189 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1190 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1190 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1191 1191
1192 unsigned int numEvent; 1192 unsigned int numEvent;
1193 //qDebug("+++++NUMEVENT %d", dayEvents.count()); 1193 //qDebug("+++++NUMEVENT %d", dayEvents.count());
1194 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1194 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1195 Event *event = dayEvents.at(numEvent); 1195 Event *event = dayEvents.at(numEvent);
1196 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1196 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1197 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1197 if ( event->uid().left(15) == QString("last-syncEvent-") )
1198 continue; 1198 continue;
1199 // kdDebug() << " Event: " << event->summary() << endl; 1199 // kdDebug() << " Event: " << event->summary() << endl;
1200 1200
1201 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1201 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1202 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1202 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1203 1203
1204 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1204 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1205 1205
1206 if (event->doesFloat()) { 1206 if (event->doesFloat()) {
1207 if (event->doesRecur()) { 1207 if (event->doesRecur()) {
1208 if (event->isMultiDay() ) { 1208 if (event->isMultiDay() ) {
1209 endX = endX - beginX;// endX is now number of days 1209 endX = endX - beginX;// endX is now number of days
1210 if ( event->recursOn( currentDate ) ) { 1210 if ( event->recursOn( currentDate ) ) {
1211 endX += curCol; 1211 endX += curCol;
1212 beginX = curCol; 1212 beginX = curCol;
1213 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1213 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1214 } else { 1214 } else {
1215 //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1()); 1215 //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1());
1216 if ( curCol == maxCol && maxCol+1 < endX ) { 1216 if ( curCol == maxCol && maxCol+1 < endX ) {
1217 int i; 1217 int i;
1218 for ( i = 1; i< endX; ++i ) { 1218 for ( i = 1; i< endX; ++i ) {
1219 if ( event->recursOn( currentDate.addDays( -i ) ) ) 1219 if ( event->recursOn( currentDate.addDays( -i ) ) )
1220 break; 1220 break;
1221 } 1221 }
1222 if ( i > maxCol ) { 1222 if ( i > maxCol ) {
1223 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1223 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1224 //qDebug("BINGO "); 1224 //qDebug("BINGO ");
1225 } 1225 }
1226 1226
1227 } else { 1227 } else {
1228 QDate dateit = currentDate.addDays( -endX ); 1228 QDate dateit = currentDate.addDays( -endX );
1229 if ( event->recursOn( dateit ) ) { 1229 if ( event->recursOn( dateit ) ) {
1230 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1230 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1231 if ( curCol-endX < 0 ) { 1231 if ( curCol-endX < 0 ) {
1232 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1232 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1233 } 1233 }
1234 } 1234 }
1235 } 1235 }
1236 } 1236 }
1237 } else { 1237 } else {
1238 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1238 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1239 } 1239 }
1240 } else { 1240 } else {
1241 if (beginX <= 0 && curCol == 0) { 1241 if (beginX <= 0 && curCol == 0) {
1242 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1242 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1243 } else if (beginX == curCol) { 1243 } else if (beginX == curCol) {
1244 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1244 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1245 } 1245 }
1246 } 1246 }
1247 } else if (event->isMultiDay()) { 1247 } else if (event->isMultiDay()) {
1248 if ( event->doesRecur () ) { 1248 if ( event->doesRecur () ) {
1249 QDate dateit = currentDate; 1249 QDate dateit = currentDate;
1250 int count = 0; 1250 int count = 0;
1251 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1251 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1252 while (! event->recursOn( dateit ) && count <= max ) { 1252 while (! event->recursOn( dateit ) && count <= max ) {
1253 ++count; 1253 ++count;
1254 dateit = dateit.addDays( -1 ); 1254 dateit = dateit.addDays( -1 );
1255 } 1255 }
1256 bool ok; 1256 bool ok;
1257 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1257 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1258 if ( ok ) 1258 if ( ok )
1259 { 1259 {
1260 int secs = event->dtStart().secsTo( event->dtEnd() ); 1260 int secs = event->dtStart().secsTo( event->dtEnd() );
1261 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1261 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1262 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1262 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1263 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1263 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1264 1264
1265 } 1265 }
1266 } 1266 }
1267 int startY = mAgenda->timeToY(event->dtStart().time()); 1267 int startY = mAgenda->timeToY(event->dtStart().time());
1268 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1268 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1269 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1269 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1270 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1270 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1271 //qDebug("insert!!! "); 1271 //qDebug("insert!!! ");
1272 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1272 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1273 } 1273 }
1274 if (beginX == curCol) { 1274 if (beginX == curCol) {
1275 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1275 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1276 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1276 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1277 } else if (endX == curCol) { 1277 } else if (endX == curCol) {
1278 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1278 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1279 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1279 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1280 } else { 1280 } else {
1281 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1281 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1282 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1282 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1283 } 1283 }
1284 } else { 1284 } else {
1285 int startY = mAgenda->timeToY(event->dtStart().time()); 1285 int startY = mAgenda->timeToY(event->dtStart().time());
1286 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1286 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1287 if (endY < startY) endY = startY; 1287 if (endY < startY) endY = startY;
1288 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1288 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1289 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1289 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1290 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1290 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1291 } 1291 }
1292 } 1292 }
1293 // ---------- [display Todos -------------- 1293 // ---------- [display Todos --------------
1294 unsigned int numTodo; 1294 unsigned int numTodo;
1295 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1295 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1296 Todo *todo = todos.at(numTodo); 1296 Todo *todo = todos.at(numTodo);
1297 1297
1298 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1298 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1299 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1299 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1300 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1300 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1301 // Already completed items can be displayed on their original due date 1301 // Already completed items can be displayed on their original due date
1302 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1302 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1303 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1303 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1304 bool fillIn = false; 1304 bool fillIn = false;
1305 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1305 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1306 fillIn = true; 1306 fillIn = true;
1307 if ( ! fillIn && !todo->hasCompletedDate() ) 1307 if ( ! fillIn && !todo->hasCompletedDate() )
1308 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1308 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1309 if ( fillIn ) { 1309 if ( fillIn ) {
1310 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1310 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1311 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1311 if ( KOPrefs::instance()->mShowTodoInAgenda )
1312 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1312 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1313 } 1313 }
1314 else { 1314 else {
1315 QDateTime dt; 1315 QDateTime dt;
1316 if ( todo->hasCompletedDate() ) 1316 if ( todo->hasCompletedDate() )
1317 dt = todo->completed(); 1317 dt = todo->completed();
1318 else 1318 else
1319 dt = todo->dtDue();; 1319 dt = todo->dtDue();;
1320 1320
1321 1321
1322 int endY = mAgenda->timeToY(dt.time()) - 1; 1322 int endY = mAgenda->timeToY(dt.time()) - 1;
1323 int hi = (18/KOPrefs::instance()->mHourSize); 1323 int hi = (18/KOPrefs::instance()->mHourSize);
1324 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1324 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1325 int startY = endY -hi; 1325 int startY = endY -hi;
1326 1326
1327 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1327 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1328 1328
1329 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1329 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1330 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1330 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1331 } 1331 }
1332 } 1332 }
1333 } 1333 }
1334 // ---------- display Todos] -------------- 1334 // ---------- display Todos] --------------
1335 1335
1336 ++curCol; 1336 ++curCol;
1337 } 1337 }
1338 mAgenda->hideUnused(); 1338 mAgenda->hideUnused();
1339 mAllDayAgenda->hideUnused(); 1339 mAllDayAgenda->hideUnused();
1340 mAgenda->checkScrollBoundaries(); 1340 mAgenda->checkScrollBoundaries();
1341 deleteSelectedDateTime(); 1341 deleteSelectedDateTime();
1342 createDayLabels(); 1342 createDayLabels();
1343 emit incidenceSelected( 0 ); 1343 emit incidenceSelected( 0 );
1344 1344
1345 if ( globalFlagBlockAgenda == 2 ) { 1345 if ( globalFlagBlockAgenda == 2 ) {
1346 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1346 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1347 setStartHour( KOPrefs::instance()->mDayBegins ); 1347 setStartHour( KOPrefs::instance()->mDayBegins );
1348 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1348 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1349 setStartHour( QTime::currentTime ().hour() ); 1349 setStartHour( QTime::currentTime ().hour() );
1350 } 1350 }
1351 qApp->processEvents(); 1351 qApp->processEvents();
1352 globalFlagBlockAgenda = 0; 1352 globalFlagBlockAgenda = 0;
1353 mAllDayAgenda->drawContentsToPainter(); 1353 mAllDayAgenda->drawContentsToPainter();
1354 mAgenda->drawContentsToPainter(); 1354 mAgenda->drawContentsToPainter();
1355 repaintAgenda(); 1355 repaintAgenda();
1356 startIdleTimeout(); 1356 startIdleTimeout();
1357 onlyOne = false; 1357 flag_blockfillAgenda = false;
1358} 1358}
1359void KOAgendaView::repaintAgenda() 1359void KOAgendaView::repaintAgenda()
1360{ 1360{
1361 mAgenda->viewport()->repaint( false ); 1361 mAgenda->viewport()->repaint( false );
1362 mAllDayAgenda->viewport()->repaint( false ); 1362 mAllDayAgenda->viewport()->repaint( false );
1363 mAgenda->finishUpdate(); 1363 mAgenda->finishUpdate();
1364 mAllDayAgenda->finishUpdate(); 1364 mAllDayAgenda->finishUpdate();
1365} 1365}
1366 1366
1367 1367
1368void KOAgendaView::clearView() 1368void KOAgendaView::clearView()
1369{ 1369{
1370 mAllDayAgenda->clear(); 1370 mAllDayAgenda->clear();
1371 mAgenda->clear(); 1371 mAgenda->clear();
1372} 1372}
1373void KOAgendaView::clearList() 1373void KOAgendaView::clearList()
1374{ 1374{
1375 clearView(); 1375 clearView();
1376 mAllDayAgenda->hideUnused(); 1376 mAllDayAgenda->hideUnused();
1377 mAgenda->hideUnused(); 1377 mAgenda->hideUnused();
1378} 1378}
1379 1379
1380void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1380void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1381 const QDate &td) 1381 const QDate &td)
1382{ 1382{
1383#ifndef KORG_NOPRINTER 1383#ifndef KORG_NOPRINTER
1384 if (fd == td) 1384 if (fd == td)
1385 calPrinter->preview(CalPrinter::Day, fd, td); 1385 calPrinter->preview(CalPrinter::Day, fd, td);
1386 else 1386 else
1387 calPrinter->preview(CalPrinter::Week, fd, td); 1387 calPrinter->preview(CalPrinter::Week, fd, td);
1388#endif 1388#endif
1389} 1389}
1390 1390
1391// void KOAgendaView::updateMovedTodo() 1391// void KOAgendaView::updateMovedTodo()
1392// { 1392// {
1393// // updateConfig(); 1393// // updateConfig();
1394// // emit updateTodoViews(); 1394// // emit updateTodoViews();
1395// } 1395// }
1396 1396
1397void KOAgendaView::slotShowDateView( int mode , int d ) 1397void KOAgendaView::slotShowDateView( int mode , int d )
1398{ 1398{
1399 if ( d >= mSelectedDates.count() ) { 1399 if ( d >= mSelectedDates.count() ) {
1400 qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() ); 1400 qDebug("KOAgendaView::slotShowDateView datecounterror %d %d ", d, mSelectedDates.count() );
1401 1401
1402 } else { 1402 } else {
1403 QDate day = mSelectedDates[d]; 1403 QDate day = mSelectedDates[d];
1404 emit showDateView(mode , day ); 1404 emit showDateView(mode , day );
1405 } 1405 }
1406 1406
1407} 1407}
1408void KOAgendaView::newEvent(int gx, int gy) 1408void KOAgendaView::newEvent(int gx, int gy)
1409{ 1409{
1410 if (!mSelectedDates.count()) return; 1410 if (!mSelectedDates.count()) return;
1411 1411
1412 QDate day = mSelectedDates[gx]; 1412 QDate day = mSelectedDates[gx];
1413 1413
1414 QTime time = mAgenda->gyToTime(gy); 1414 QTime time = mAgenda->gyToTime(gy);
1415 QDateTime dt(day,time); 1415 QDateTime dt(day,time);
1416 // if ( dt < QDateTime::currentDateTime () ) 1416 // if ( dt < QDateTime::currentDateTime () )
1417 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1417 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1418 emit newEventSignal(dt); 1418 emit newEventSignal(dt);
1419} 1419}
1420 1420
1421void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1421void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1422{ 1422{
1423 if (!mSelectedDates.count()) return; 1423 if (!mSelectedDates.count()) return;
1424 1424
1425 QDate dayStart = mSelectedDates[gxStart]; 1425 QDate dayStart = mSelectedDates[gxStart];
1426 QDate dayEnd = mSelectedDates[gxEnd]; 1426 QDate dayEnd = mSelectedDates[gxEnd];
1427 1427
1428 QTime timeStart = mAgenda->gyToTime(gyStart); 1428 QTime timeStart = mAgenda->gyToTime(gyStart);
1429 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1429 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1430 1430
1431 QDateTime dtStart(dayStart,timeStart); 1431 QDateTime dtStart(dayStart,timeStart);
1432 QDateTime dtEnd(dayEnd,timeEnd); 1432 QDateTime dtEnd(dayEnd,timeEnd);
1433 1433
1434 emit newEventSignal(dtStart,dtEnd); 1434 emit newEventSignal(dtStart,dtEnd);
1435} 1435}
1436 1436
1437void KOAgendaView::newEventAllDay(int gx, int ) 1437void KOAgendaView::newEventAllDay(int gx, int )
1438{ 1438{
1439 if (!mSelectedDates.count()) return; 1439 if (!mSelectedDates.count()) return;
1440 1440
1441 QDate day = mSelectedDates[gx]; 1441 QDate day = mSelectedDates[gx];
1442 1442
1443 emit newEventSignal(day); 1443 emit newEventSignal(day);
1444} 1444}
1445void KOAgendaView::newTodoAllDay(int gx, int ) 1445void KOAgendaView::newTodoAllDay(int gx, int )
1446{ 1446{
1447 if (!mSelectedDates.count()) return; 1447 if (!mSelectedDates.count()) return;
1448 1448
1449 QDateTime day (mSelectedDates[gx] ); 1449 QDateTime day (mSelectedDates[gx] );
1450 emit newTodoSignal(day, true); 1450 emit newTodoSignal(day, true);
1451} 1451}
1452void KOAgendaView::newTodo(int gx, int gy ) 1452void KOAgendaView::newTodo(int gx, int gy )
1453{ 1453{
1454 if (!mSelectedDates.count()) return; 1454 if (!mSelectedDates.count()) return;
1455 QDate dayStart = mSelectedDates[gx]; 1455 QDate dayStart = mSelectedDates[gx];
1456 QTime timeStart = mAgenda->gyToTime(gy); 1456 QTime timeStart = mAgenda->gyToTime(gy);
1457 QDateTime dt (dayStart,timeStart); 1457 QDateTime dt (dayStart,timeStart);
1458 emit newTodoSignal( dt, false ); 1458 emit newTodoSignal( dt, false );
1459} 1459}
1460 1460
1461void KOAgendaView::updateEventIndicatorTop(int newY) 1461void KOAgendaView::updateEventIndicatorTop(int newY)
1462{ 1462{
1463 uint i; 1463 uint i;
1464 for(i=0;i<mMinY.size();++i) { 1464 for(i=0;i<mMinY.size();++i) {
1465 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1465 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1466 else mEventIndicatorTop->enableColumn(i,false); 1466 else mEventIndicatorTop->enableColumn(i,false);
1467 } 1467 }
1468 1468
1469 mEventIndicatorTop->update(); 1469 mEventIndicatorTop->update();
1470} 1470}
1471 1471
1472void KOAgendaView::updateEventIndicatorBottom(int newY) 1472void KOAgendaView::updateEventIndicatorBottom(int newY)
1473{ 1473{
1474 uint i; 1474 uint i;
1475 for(i=0;i<mMaxY.size();++i) { 1475 for(i=0;i<mMaxY.size();++i) {
1476 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1476 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1477 else mEventIndicatorBottom->enableColumn(i,false); 1477 else mEventIndicatorBottom->enableColumn(i,false);
1478 } 1478 }
1479 1479
1480 mEventIndicatorBottom->update(); 1480 mEventIndicatorBottom->update();
1481} 1481}
1482 1482
1483void KOAgendaView::startDrag(Event *event) 1483void KOAgendaView::startDrag(Event *event)
1484{ 1484{
1485#ifndef KORG_NODND 1485#ifndef KORG_NODND
1486 DndFactory factory( calendar() ); 1486 DndFactory factory( calendar() );
1487 ICalDrag *vd = factory.createDrag(event,this); 1487 ICalDrag *vd = factory.createDrag(event,this);
1488 if (vd->drag()) { 1488 if (vd->drag()) {
1489 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1489 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1490 } 1490 }
1491#endif 1491#endif
1492} 1492}
1493 1493
1494void KOAgendaView::readSettings() 1494void KOAgendaView::readSettings()
1495{ 1495{
1496 readSettings(KOGlobals::config()); 1496 readSettings(KOGlobals::config());
1497} 1497}
1498 1498
1499void KOAgendaView::readSettings(KConfig *config) 1499void KOAgendaView::readSettings(KConfig *config)
1500{ 1500{
1501 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1501 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1502 1502
1503 config->setGroup("Views"); 1503 config->setGroup("Views");
1504 1504
1505 //#ifndef KORG_NOSPLITTER 1505 //#ifndef KORG_NOSPLITTER
1506 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1506 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1507 if (sizes.count() == 2) { 1507 if (sizes.count() == 2) {
1508 if ( sizes[0] < 20 ) { 1508 if ( sizes[0] < 20 ) {
1509 sizes[1] = sizes[1] +20 - sizes[0]; 1509 sizes[1] = sizes[1] +20 - sizes[0];
1510 sizes[0] = 20; 1510 sizes[0] = 20;
1511 } 1511 }
1512 mSplitterAgenda->setSizes(sizes); 1512 mSplitterAgenda->setSizes(sizes);
1513 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1513 // qDebug("read %d %d ",sizes[0],sizes[1] );
1514 } 1514 }
1515 //#endif 1515 //#endif
1516 1516
1517 // updateConfig(); 1517 // updateConfig();
1518} 1518}
1519 1519
1520void KOAgendaView::writeSettings(KConfig *config) 1520void KOAgendaView::writeSettings(KConfig *config)
1521{ 1521{
1522 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1522 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1523 1523
1524 config->setGroup("Views"); 1524 config->setGroup("Views");
1525 1525
1526 //#ifndef KORG_NOSPLITTER 1526 //#ifndef KORG_NOSPLITTER
1527 QValueList<int> list = mSplitterAgenda->sizes(); 1527 QValueList<int> list = mSplitterAgenda->sizes();
1528 config->writeEntry("Separator AgendaView",list); 1528 config->writeEntry("Separator AgendaView",list);
1529 //qDebug("write %d %d ", list[0],list[1] ); 1529 //qDebug("write %d %d ", list[0],list[1] );
1530 //#endif 1530 //#endif
1531} 1531}
1532 1532
1533void KOAgendaView::setHolidayMasks() 1533void KOAgendaView::setHolidayMasks()
1534{ 1534{
1535 mHolidayMask.resize(mSelectedDates.count()); 1535 mHolidayMask.resize(mSelectedDates.count());
1536 1536
1537 uint i; 1537 uint i;
1538 for(i=0;i<mSelectedDates.count();++i) { 1538 for(i=0;i<mSelectedDates.count();++i) {
1539 QDate date = mSelectedDates[i]; 1539 QDate date = mSelectedDates[i];
1540 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1540 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1541 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1541 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1542 bool showHoliday = false; 1542 bool showHoliday = false;
1543 if ( KOPrefs::instance()->mExcludeHolidays ) { 1543 if ( KOPrefs::instance()->mExcludeHolidays ) {
1544 QPtrList<Event> events = calendar()->events( date, true ); 1544 QPtrList<Event> events = calendar()->events( date, true );
1545 Event *event; 1545 Event *event;
1546 for( event = events.first(); event; event = events.next() ) { 1546 for( event = events.first(); event; event = events.next() ) {
1547 if ( event->isHoliday()) { 1547 if ( event->isHoliday()) {
1548 showHoliday = true; 1548 showHoliday = true;
1549 break; 1549 break;
1550 } 1550 }
1551 } 1551 }
1552 1552
1553 } 1553 }
1554 1554
1555#ifndef KORG_NOPLUGINS 1555#ifndef KORG_NOPLUGINS
1556 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1556 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1557 !KOCore::self()->holiday(date).isEmpty(); 1557 !KOCore::self()->holiday(date).isEmpty();
1558#endif 1558#endif
1559 bool showDay = showSaturday || showSunday || showHoliday; 1559 bool showDay = showSaturday || showSunday || showHoliday;
1560 1560
1561 if (showDay) { 1561 if (showDay) {
1562 mHolidayMask.at(i) = true; 1562 mHolidayMask.at(i) = true;
1563 } else { 1563 } else {
1564 mHolidayMask.at(i) = false; 1564 mHolidayMask.at(i) = false;
1565 } 1565 }
1566 } 1566 }
1567 1567
1568 mAgenda->setHolidayMask(&mHolidayMask); 1568 mAgenda->setHolidayMask(&mHolidayMask);
1569 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1569 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1570} 1570}
1571 1571
1572void KOAgendaView::setContentsPos(int y) 1572void KOAgendaView::setContentsPos(int y)
1573{ 1573{
1574 mAgenda->setContentsPos(0,y); 1574 mAgenda->setContentsPos(0,y);
1575} 1575}
1576 1576
1577void KOAgendaView::clearSelection() 1577void KOAgendaView::clearSelection()
1578{ 1578{
1579 mAgenda->deselectItem(); 1579 mAgenda->deselectItem();
1580 mAllDayAgenda->deselectItem(); 1580 mAllDayAgenda->deselectItem();
1581} 1581}
1582 1582
1583void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1583void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1584 int gxEnd, int gyEnd) 1584 int gxEnd, int gyEnd)
1585{ 1585{
1586 mTimeSpanInAllDay = true; 1586 mTimeSpanInAllDay = true;
1587 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1587 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1588} 1588}
1589 1589
1590 1590
1591 1591
1592 1592
1593void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1593void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1594 int gxEnd, int gyEnd) 1594 int gxEnd, int gyEnd)
1595{ 1595{
1596 if (!mSelectedDates.count()) return; 1596 if (!mSelectedDates.count()) return;
1597 1597
1598 QDate dayStart = mSelectedDates[gxStart]; 1598 QDate dayStart = mSelectedDates[gxStart];
1599 QDate dayEnd = mSelectedDates[gxEnd]; 1599 QDate dayEnd = mSelectedDates[gxEnd];
1600 1600
1601 QTime timeStart = mAgenda->gyToTime(gyStart); 1601 QTime timeStart = mAgenda->gyToTime(gyStart);
1602 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1602 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1603 1603
1604 QDateTime dtStart(dayStart,timeStart); 1604 QDateTime dtStart(dayStart,timeStart);
1605 QDateTime dtEnd(dayEnd,timeEnd); 1605 QDateTime dtEnd(dayEnd,timeEnd);
1606 1606
1607 mTimeSpanBegin = dtStart; 1607 mTimeSpanBegin = dtStart;
1608 mTimeSpanEnd = dtEnd; 1608 mTimeSpanEnd = dtEnd;
1609 1609
1610} 1610}
1611 1611
1612void KOAgendaView::deleteSelectedDateTime() 1612void KOAgendaView::deleteSelectedDateTime()
1613{ 1613{
1614 mTimeSpanBegin.setDate(QDate()); 1614 mTimeSpanBegin.setDate(QDate());
1615 mTimeSpanEnd.setDate(QDate()); 1615 mTimeSpanEnd.setDate(QDate());
1616 mTimeSpanInAllDay = false; 1616 mTimeSpanInAllDay = false;
1617} 1617}
1618 1618
1619void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1619void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1620{ 1620{
1621 e->ignore(); 1621 e->ignore();
1622} 1622}
1623 1623
1624void KOAgendaView::scrollOneHourUp() 1624void KOAgendaView::scrollOneHourUp()
1625{ 1625{
1626 1626
1627 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1627 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1628} 1628}
1629void KOAgendaView::scrollOneHourDown() 1629void KOAgendaView::scrollOneHourDown()
1630{ 1630{
1631 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1631 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1632} 1632}
1633 1633
1634void KOAgendaView::setStartHour( int h ) 1634void KOAgendaView::setStartHour( int h )
1635{ 1635{
1636 mAgenda->setStartHour( h ); 1636 mAgenda->setStartHour( h );
1637 1637
1638} 1638}
1639void KOAgendaView::setInitStartHour() 1639void KOAgendaView::setInitStartHour()
1640{ 1640{
1641 1641
1642 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1642 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1643 setStartHour( QTime::currentTime ().hour() ); 1643 setStartHour( QTime::currentTime ().hour() );
1644 else 1644 else
1645 setStartHour( KOPrefs::instance()->mDayBegins ); 1645 setStartHour( KOPrefs::instance()->mDayBegins );
1646 1646
1647} 1647}
1648 1648
1649 1649
1650void KOAgendaView::updateTodo( Todo * t, int ) 1650void KOAgendaView::updateTodo( Todo * t, int )
1651{ 1651{
1652 if ( !isVisible() ) 1652 if ( !isVisible() )
1653 return; 1653 return;
1654 bool remove = false; 1654 bool remove = false;
1655 bool removeAD = false; 1655 bool removeAD = false;
1656 QDate da; 1656 QDate da;
1657 if ( t->hasCompletedDate() ) 1657 if ( t->hasCompletedDate() )
1658 da = t->completed().date(); 1658 da = t->completed().date();
1659 else 1659 else
1660 da = t->dtDue().date(); 1660 da = t->dtDue().date();
1661 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1661 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1662 remove = true; 1662 remove = true;
1663 removeAD = true; 1663 removeAD = true;
1664 } 1664 }
1665 else { 1665 else {
1666 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1666 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1667 if ( overdue && 1667 if ( overdue &&
1668 QDate::currentDate() >= mSelectedDates.first() && 1668 QDate::currentDate() >= mSelectedDates.first() &&
1669 QDate::currentDate() <= mSelectedDates.last()) { 1669 QDate::currentDate() <= mSelectedDates.last()) {
1670 removeAD = false; 1670 removeAD = false;
1671 remove = true; 1671 remove = true;
1672 } 1672 }
1673 else { 1673 else {
1674 1674
1675 if ( da < mSelectedDates.first() || 1675 if ( da < mSelectedDates.first() ||
1676 da > mSelectedDates.last() ) { 1676 da > mSelectedDates.last() ) {
1677 remove = true; 1677 remove = true;
1678 removeAD = true; 1678 removeAD = true;
1679 } else { 1679 } else {
1680 remove = t->doesFloat() && !t->hasCompletedDate(); 1680 remove = t->doesFloat() && !t->hasCompletedDate();
1681 removeAD = !remove; 1681 removeAD = !remove;
1682 } 1682 }
1683 } 1683 }
1684 } 1684 }
1685 int days = mSelectedDates.first().daysTo( da ); 1685 int days = mSelectedDates.first().daysTo( da );
1686 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1686 //qDebug("daysto %d %d %d", days, remove,removeAD );
1687 mAgenda->updateTodo( t , days, remove); 1687 mAgenda->updateTodo( t , days, remove);
1688 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1688 if ( KOPrefs::instance()->mShowTodoInAgenda )
1689 mAllDayAgenda->updateTodo( t , days, removeAD); 1689 mAllDayAgenda->updateTodo( t , days, removeAD);
1690 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1690 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1691 1691
1692} 1692}
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 4b7ef5b..5e68146 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,298 +1,299 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qksplitter.h> 31#include <qksplitter.h>
32#else 32#else
33#include <qsplitter.h> 33#include <qsplitter.h>
34#endif 34#endif
35#include <qmemarray.h> 35#include <qmemarray.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48 48
49class KOAgendaButton : public QPushButton 49class KOAgendaButton : public QPushButton
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 QPixmap myPix; 104 QPixmap myPix;
105 bool mRedrawNeeded; 105 bool mRedrawNeeded;
106 int mMiniWidth; 106 int mMiniWidth;
107 int mMouseDownY; 107 int mMouseDownY;
108 QString mOrgCap; 108 QString mOrgCap;
109 int mRows; 109 int mRows;
110 int mCellHeight; 110 int mCellHeight;
111 111
112 /** */ 112 /** */
113 KOAgenda* mAgenda; 113 KOAgenda* mAgenda;
114}; 114};
115 115
116class EventIndicator : public QFrame { 116class EventIndicator : public QFrame {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
121 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
122 122
123 void changeColumns(int columns); 123 void changeColumns(int columns);
124 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
125 void setXOffset( int ); 125 void setXOffset( int );
126 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
127 127
128 protected: 128 protected:
129 void drawContents(QPainter *); 129 void drawContents(QPainter *);
130 130
131 private: 131 private:
132 int mXOffset; 132 int mXOffset;
133 KDGanttMinimizeSplitter* mPaintWidget; 133 KDGanttMinimizeSplitter* mPaintWidget;
134 int mColumns; 134 int mColumns;
135 QHBox *mTopBox; 135 QHBox *mTopBox;
136 QBoxLayout *mTopLayout; 136 QBoxLayout *mTopLayout;
137 Location mLocation; 137 Location mLocation;
138 QPixmap mPixmap; 138 QPixmap mPixmap;
139 QMemArray<bool> mEnabled; 139 QMemArray<bool> mEnabled;
140}; 140};
141 141
142/** 142/**
143 KOAgendaView is the agenda-like view used to display events in an one or 143 KOAgendaView is the agenda-like view used to display events in an one or
144 multi-day view. 144 multi-day view.
145*/ 145*/
146class KOAgendaView : public KOEventView { 146class KOAgendaView : public KOEventView {
147 Q_OBJECT 147 Q_OBJECT
148 public: 148 public:
149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
150 virtual ~KOAgendaView(); 150 virtual ~KOAgendaView();
151 void setStartHour( int ); 151 void setStartHour( int );
152 void toggleAllDay(); 152 void toggleAllDay();
153 153
154 154
155 /** Returns maximum number of days supported by the koagendaview */ 155 /** Returns maximum number of days supported by the koagendaview */
156 virtual int maxDatesHint(); 156 virtual int maxDatesHint();
157 157
158 /** Returns number of currently shown dates. */ 158 /** Returns number of currently shown dates. */
159 virtual int currentDateCount(); 159 virtual int currentDateCount();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual QPtrList<Incidence> selectedIncidences(); 162 virtual QPtrList<Incidence> selectedIncidences();
163 163
164 /** returns the currently selected events */ 164 /** returns the currently selected events */
165 virtual DateList selectedDates(); 165 virtual DateList selectedDates();
166 166
167 /** Remove all events from view */ 167 /** Remove all events from view */
168 void clearView(); 168 void clearView();
169 void clearList(); 169 void clearList();
170 KOAgenda *agenda() { return mAgenda;} 170 KOAgenda *agenda() { return mAgenda;}
171 virtual void printPreview(CalPrinter *calPrinter, 171 virtual void printPreview(CalPrinter *calPrinter,
172 const QDate &, const QDate &); 172 const QDate &, const QDate &);
173 173
174 /** start-datetime of selection */ 174 /** start-datetime of selection */
175 QDateTime selectionStart() {return mTimeSpanBegin;} 175 QDateTime selectionStart() {return mTimeSpanBegin;}
176 /** end-datetime of selection */ 176 /** end-datetime of selection */
177 QDateTime selectionEnd() {return mTimeSpanEnd;} 177 QDateTime selectionEnd() {return mTimeSpanEnd;}
178 /** returns true if selection is for whole day */ 178 /** returns true if selection is for whole day */
179 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 179 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
180 /** make selected start/end invalid */ 180 /** make selected start/end invalid */
181 void deleteSelectedDateTime(); 181 void deleteSelectedDateTime();
182 void repaintAgenda(); 182 void repaintAgenda();
183 public slots: 183 public slots:
184 void setInitStartHour(); 184 void setInitStartHour();
185 virtual void updateView(); 185 virtual void updateView();
186 virtual void updateConfig(); 186 virtual void updateConfig();
187 virtual void showDates(const QDate &start, const QDate &end); 187 virtual void showDates(const QDate &start, const QDate &end);
188 virtual void showEvents(QPtrList<Event> eventList); 188 virtual void showEvents(QPtrList<Event> eventList);
189 189
190 void updateTodo( Todo *, int ); 190 void updateTodo( Todo *, int );
191 void changeEventDisplay(Event *, int); 191 void changeEventDisplay(Event *, int);
192 192
193 void clearSelection(); 193 void clearSelection();
194 194
195 void newTodo(int gx,int gy); 195 void newTodo(int gx,int gy);
196 void newEvent(int gx,int gy); 196 void newEvent(int gx,int gy);
197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
198 void newEventAllDay(int gx, int gy); 198 void newEventAllDay(int gx, int gy);
199 void newTodoAllDay(int gx, int gy); 199 void newTodoAllDay(int gx, int gy);
200 200
201 void startDrag(Event *); 201 void startDrag(Event *);
202 202
203 void readSettings(); 203 void readSettings();
204 void readSettings(KConfig *); 204 void readSettings(KConfig *);
205 void writeSettings(KConfig *); 205 void writeSettings(KConfig *);
206 206
207 void setContentsPos(int y); 207 void setContentsPos(int y);
208 208
209 void scrollOneHourUp(); 209 void scrollOneHourUp();
210 void scrollOneHourDown(); 210 void scrollOneHourDown();
211 void addToCalSlot(Incidence *, Incidence *); 211 void addToCalSlot(Incidence *, Incidence *);
212 void slotShowDateView( int, int ); 212 void slotShowDateView( int, int );
213 void fillAgenda(); 213 void fillAgenda();
214 void startIdleTimeout(); 214 void startIdleTimeout();
215 215
216 signals: 216 signals:
217 void showDateView( int, QDate ); 217 void showDateView( int, QDate );
218 void newTodoSignal( QDateTime ,bool ); 218 void newTodoSignal( QDateTime ,bool );
219 void toggleExpand(); 219 void toggleExpand();
220 void selectWeekNum( int ); 220 void selectWeekNum( int );
221 void todoMoved( Todo *, int ); 221 void todoMoved( Todo *, int );
222 void incidenceChanged(Incidence * , int ); 222 void incidenceChanged(Incidence * , int );
223 // void cloneIncidenceSignal(Incidence *); 223 // void cloneIncidenceSignal(Incidence *);
224 224
225 protected: 225 protected:
226 KOAgendaButton* getNewDaylabel(); 226 KOAgendaButton* getNewDaylabel();
227 bool mBlockUpdating; 227 bool mBlockUpdating;
228 int mUpcomingWidth; 228 int mUpcomingWidth;
229 /** Fill agenda beginning with date startDate */ 229 /** Fill agenda beginning with date startDate */
230 void fillAgenda(const QDate &startDate); 230 void fillAgenda(const QDate &startDate);
231 void resizeEvent( QResizeEvent* e ); 231 void resizeEvent( QResizeEvent* e );
232 /** Fill agenda using the current set value for the start date */ 232 /** Fill agenda using the current set value for the start date */
233 233
234 /** Create labels for the selected dates. */ 234 /** Create labels for the selected dates. */
235 void createDayLabels(); 235 void createDayLabels();
236 236
237 /** 237 /**
238 Set the masks on the agenda widgets indicating, which days are holidays. 238 Set the masks on the agenda widgets indicating, which days are holidays.
239 */ 239 */
240 void setHolidayMasks(); 240 void setHolidayMasks();
241 241
242 protected slots: 242 protected slots:
243 void slotIdleTimeout(); 243 void slotIdleTimeout();
244 void categoryChanged( Incidence * ); 244 void categoryChanged( Incidence * );
245 void slotDaylabelClicked( int ); 245 void slotDaylabelClicked( int );
246 /** Update event belonging to agenda item */ 246 /** Update event belonging to agenda item */
247 void updateEventDates(KOAgendaItem *item, int mode = -1); 247 void updateEventDates(KOAgendaItem *item, int mode = -1);
248 //void updateMovedTodo(); 248 //void updateMovedTodo();
249 249
250 void updateEventIndicatorTop(int newY); 250 void updateEventIndicatorTop(int newY);
251 void updateEventIndicatorBottom(int newY); 251 void updateEventIndicatorBottom(int newY);
252 252
253 /** Updates data for selected timespan */ 253 /** Updates data for selected timespan */
254 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 254 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
255 /** Updates data for selected timespan for all day event*/ 255 /** Updates data for selected timespan for all day event*/
256 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 256 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
257 257
258 private: 258 private:
259 bool flag_blockfillAgenda;
259 QTimer* mIdleTimer; 260 QTimer* mIdleTimer;
260 QDateTime mIdleStart; 261 QDateTime mIdleStart;
261 // view widgets 262 // view widgets
262 QFrame *mDayLabels; 263 QFrame *mDayLabels;
263 QHBox *mDayLabelsFrame; 264 QHBox *mDayLabelsFrame;
264 QBoxLayout *mLayoutDayLabels; 265 QBoxLayout *mLayoutDayLabels;
265 QFrame *mAllDayFrame; 266 QFrame *mAllDayFrame;
266 KOAgenda *mAllDayAgenda; 267 KOAgenda *mAllDayAgenda;
267 KOAgenda *mAgenda; 268 KOAgenda *mAgenda;
268 TimeLabels *mTimeLabels; 269 TimeLabels *mTimeLabels;
269 QWidget *mDummyAllDayLeft; 270 QWidget *mDummyAllDayLeft;
270 271
271 KDGanttMinimizeSplitter* mSplitterAgenda; 272 KDGanttMinimizeSplitter* mSplitterAgenda;
272 QPushButton *mExpandButton; 273 QPushButton *mExpandButton;
273 274
274 DateList mSelectedDates; // List of dates to be displayed 275 DateList mSelectedDates; // List of dates to be displayed
275 int mViewType; 276 int mViewType;
276 277
277 bool mWeekStartsMonday; 278 bool mWeekStartsMonday;
278 int mStartHour; 279 int mStartHour;
279 280
280 KOEventPopupMenu *mAllAgendaPopup; 281 KOEventPopupMenu *mAllAgendaPopup;
281 //KOEventPopupMenu *mAllDayAgendaPopup; 282 //KOEventPopupMenu *mAllDayAgendaPopup;
282 283
283 EventIndicator *mEventIndicatorTop; 284 EventIndicator *mEventIndicatorTop;
284 EventIndicator *mEventIndicatorBottom; 285 EventIndicator *mEventIndicatorBottom;
285 286
286 QMemArray<int> mMinY; 287 QMemArray<int> mMinY;
287 QMemArray<int> mMaxY; 288 QMemArray<int> mMaxY;
288 289
289 QMemArray<bool> mHolidayMask; 290 QMemArray<bool> mHolidayMask;
290 291
291 QPtrList<KOAgendaButton> mDayLabelsList; 292 QPtrList<KOAgendaButton> mDayLabelsList;
292 QDateTime mTimeSpanBegin; 293 QDateTime mTimeSpanBegin;
293 QDateTime mTimeSpanEnd; 294 QDateTime mTimeSpanEnd;
294 bool mTimeSpanInAllDay; 295 bool mTimeSpanInAllDay;
295 void keyPressEvent ( QKeyEvent * e ); 296 void keyPressEvent ( QKeyEvent * e );
296}; 297};
297 298
298#endif // KOAGENDAVIEW_H 299#endif // KOAGENDAVIEW_H
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index a12c43e..d79a9b9 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1764 +1,1766 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31 31
32#include <qinputdialog.h> 32#include <qinputdialog.h>
33 33
34#include <qvbox.h> 34#include <qvbox.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include "koprefs.h" 36#include "koprefs.h"
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kdateedit.h> 39#include <kdateedit.h>
40#include "ktimeedit.h" 40#include "ktimeedit.h"
41#include <kiconloader.h> 41#include <kiconloader.h>
42#include <kmessagebox.h> 42#include <kmessagebox.h>
43 43
44#include <libkcal/icaldrag.h> 44#include <libkcal/icaldrag.h>
45#include <libkcal/vcaldrag.h> 45#include <libkcal/vcaldrag.h>
46#include <libkcal/calfilter.h> 46#include <libkcal/calfilter.h>
47#include <libkcal/dndfactory.h> 47#include <libkcal/dndfactory.h>
48#include <libkcal/calendarresources.h> 48#include <libkcal/calendarresources.h>
49#include <libkcal/resourcecalendar.h> 49#include <libkcal/resourcecalendar.h>
50#include <kresources/resourceselectdialog.h> 50#include <kresources/resourceselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57#ifndef KORG_NOPRINTER 57#ifndef KORG_NOPRINTER
58#include "calprinter.h" 58#include "calprinter.h"
59#endif 59#endif
60#include "docprefs.h" 60#include "docprefs.h"
61 61
62#include "kotodoview.h" 62#include "kotodoview.h"
63using namespace KOrg; 63using namespace KOrg;
64 64
65 65
66KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) : 66KOStartTodoPrefs::KOStartTodoPrefs( QString sum, QWidget *parent, const char *name ) :
67 QDialog( parent, name, true ) 67 QDialog( parent, name, true )
68{ 68{
69 mStopAll = true; 69 mStopAll = true;
70 setCaption( i18n("Start todo") ); 70 setCaption( i18n("Start todo") );
71 QVBoxLayout* lay = new QVBoxLayout( this ); 71 QVBoxLayout* lay = new QVBoxLayout( this );
72 lay->setSpacing( 3 ); 72 lay->setSpacing( 3 );
73 lay->setMargin( 3 ); 73 lay->setMargin( 3 );
74 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this ); 74 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( sum ), this );
75 lay->addWidget( lab ); 75 lay->addWidget( lab );
76 lab->setAlignment( AlignCenter ); 76 lab->setAlignment( AlignCenter );
77 77
78 QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this ); 78 QPushButton * ok = new QPushButton( i18n("Start this todo\nand stop all running"), this );
79 lay->addWidget( ok ); 79 lay->addWidget( ok );
80 ok->setDefault( true ); 80 ok->setDefault( true );
81 QPushButton * start = new QPushButton( i18n("Start todo"), this ); 81 QPushButton * start = new QPushButton( i18n("Start todo"), this );
82 lay->addWidget( start ); 82 lay->addWidget( start );
83 QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this ); 83 QPushButton * cancel = new QPushButton( i18n("Cancel - do not start"), this );
84 lay->addWidget( cancel ); 84 lay->addWidget( cancel );
85 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 85 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
86 connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) ); 86 connect ( start,SIGNAL(clicked() ),this , SLOT ( doStop() ) );
87 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 87 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
88 resize( sizeHint() ); 88 resize( sizeHint() );
89 89
90} 90}
91void KOStartTodoPrefs::doStop() 91void KOStartTodoPrefs::doStop()
92{ 92{
93 mStopAll = false; 93 mStopAll = false;
94 accept(); 94 accept();
95} 95}
96KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) : 96KOStopTodoPrefs::KOStopTodoPrefs( Todo* todo, QWidget *parent, const char *name ) :
97 QDialog( parent, name, true ) 97 QDialog( parent, name, true )
98{ 98{
99 mTodo = todo; 99 mTodo = todo;
100 setCaption( i18n("Stop todo") ); 100 setCaption( i18n("Stop todo") );
101 QVBoxLayout* lay = new QVBoxLayout( this ); 101 QVBoxLayout* lay = new QVBoxLayout( this );
102 lay->setSpacing( 3 ); 102 lay->setSpacing( 3 );
103 lay->setMargin( 3 ); 103 lay->setMargin( 3 );
104 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this ); 104 QLabel * lab = new QLabel( i18n("<b>%1\n</b>").arg( todo->summary() ), this );
105 lay->addWidget( lab ); 105 lay->addWidget( lab );
106 lab->setAlignment( AlignHCenter ); 106 lab->setAlignment( AlignHCenter );
107 lab = new QLabel( i18n("Additional Comment:"), this ); 107 lab = new QLabel( i18n("Additional Comment:"), this );
108 lay->addWidget( lab ); 108 lay->addWidget( lab );
109 mComment = new QLineEdit( this ); 109 mComment = new QLineEdit( this );
110 lay->addWidget( mComment ); 110 lay->addWidget( mComment );
111 QHBox * start = new QHBox ( this ); 111 QHBox * start = new QHBox ( this );
112 lay->addWidget( start ); 112 lay->addWidget( start );
113 lab = new QLabel( i18n("Start:"), start ); 113 lab = new QLabel( i18n("Start:"), start );
114 QHBox * end = new QHBox ( this ); 114 QHBox * end = new QHBox ( this );
115 lay->addWidget( end ); 115 lay->addWidget( end );
116 lab = new QLabel( i18n("End:"), end ); 116 lab = new QLabel( i18n("End:"), end );
117 sde = new KDateEdit( start ); 117 sde = new KDateEdit( start );
118 ste = new KOTimeEdit( start ); 118 ste = new KOTimeEdit( start );
119 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) ); 119 connect ( sde,SIGNAL(setTimeTo( QTime ) ),ste , SLOT ( setTime(QTime ) ) );
120 ede = new KDateEdit( end ); 120 ede = new KDateEdit( end );
121 ete = new KOTimeEdit(end ); 121 ete = new KOTimeEdit(end );
122 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) ); 122 connect ( ede,SIGNAL(setTimeTo( QTime ) ),ete , SLOT ( setTime(QTime ) ) );
123 sde->setDate( mTodo->runStart().date() ); 123 sde->setDate( mTodo->runStart().date() );
124 ste->setTime( mTodo->runStart().time() ); 124 ste->setTime( mTodo->runStart().time() );
125 mStop = QDateTime::currentDateTime(); 125 mStop = QDateTime::currentDateTime();
126 ede->setDate( mStop.date()); 126 ede->setDate( mStop.date());
127 ete->setTime( mStop.time() ); 127 ete->setTime( mStop.time() );
128 QPushButton * ok = new QPushButton( i18n("Stop and save"), this ); 128 QPushButton * ok = new QPushButton( i18n("Stop and save"), this );
129 lay->addWidget( ok ); 129 lay->addWidget( ok );
130 ok->setDefault( true ); 130 ok->setDefault( true );
131 QPushButton * cancel = new QPushButton( i18n("Continue running"), this ); 131 QPushButton * cancel = new QPushButton( i18n("Continue running"), this );
132 lay->addWidget( cancel ); 132 lay->addWidget( cancel );
133 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 133 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
134 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 134 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
135 ok = new QPushButton( i18n("Stop - do not save"), this ); 135 ok = new QPushButton( i18n("Stop - do not save"), this );
136 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) ); 136 connect ( ok,SIGNAL(clicked() ),this , SLOT ( doNotSave() ) );
137 lay->addWidget( ok ); 137 lay->addWidget( ok );
138 if (QApplication::desktop()->width() < 320 ) 138 if (QApplication::desktop()->width() < 320 )
139 resize( 240, sizeHint().height() ); 139 resize( 240, sizeHint().height() );
140 else 140 else
141 resize( 320, sizeHint().height() ); 141 resize( 320, sizeHint().height() );
142 142
143} 143}
144 144
145void KOStopTodoPrefs::accept() 145void KOStopTodoPrefs::accept()
146{ 146{
147 QDateTime start = QDateTime( sde->date(), ste->getTime() ); 147 QDateTime start = QDateTime( sde->date(), ste->getTime() );
148 QDateTime stop = QDateTime( ede->date(), ete->getTime() ); 148 QDateTime stop = QDateTime( ede->date(), ete->getTime() );
149 if ( start > stop ) { 149 if ( start > stop ) {
150 KMessageBox::sorry(this, 150 KMessageBox::sorry(this,
151 i18n("The start time is\nafter the end time!"), 151 i18n("The start time is\nafter the end time!"),
152 i18n("Time mismatch!")); 152 i18n("Time mismatch!"));
153 return; 153 return;
154 } 154 }
155 // restoring the seconds 155 // restoring the seconds
156 if ( start == QDateTime( mTodo->runStart().date(), 156 if ( start == QDateTime( mTodo->runStart().date(),
157 QTime(mTodo->runStart().time().hour() , mTodo->runStart().time().minute() ) ) ) 157 QTime(mTodo->runStart().time().hour() , mTodo->runStart().time().minute() ) ) )
158 start = mTodo->runStart(); 158 start = mTodo->runStart();
159 if ( stop == QDateTime( mStop.date(), 159 if ( stop == QDateTime( mStop.date(),
160 QTime( mStop.time().hour() , mStop.time().minute() ) ) ) 160 QTime( mStop.time().hour() , mStop.time().minute() ) ) )
161 stop = mStop; 161 stop = mStop;
162 162
163 mTodo->saveRunningInfo( mComment->text(), start, stop ); 163 mTodo->saveRunningInfo( mComment->text(), start, stop );
164 QDialog::accept(); 164 QDialog::accept();
165} 165}
166void KOStopTodoPrefs::doNotSave() 166void KOStopTodoPrefs::doNotSave()
167{ 167{
168 int result = KMessageBox::warningContinueCancel(this, 168 int result = KMessageBox::warningContinueCancel(this,
169 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") ); 169 i18n("Do you really want to set\nthe state to stopped\nwithout saving the data?"),mTodo->summary(),i18n("Yes, stop todo") );
170 if (result != KMessageBox::Continue) return; 170 if (result != KMessageBox::Continue) return;
171 mTodo->stopRunning(); 171 mTodo->stopRunning();
172 QDialog::accept(); 172 QDialog::accept();
173} 173}
174 174
175 175
176class KOTodoViewWhatsThis :public QWhatsThis 176class KOTodoViewWhatsThis :public QWhatsThis
177{ 177{
178public: 178public:
179 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 179 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
180 180
181protected: 181protected:
182 virtual QString text( const QPoint& p) 182 virtual QString text( const QPoint& p)
183 { 183 {
184 return _view->getWhatsThisText(p) ; 184 return _view->getWhatsThisText(p) ;
185 } 185 }
186private: 186private:
187 QWidget* _wid; 187 QWidget* _wid;
188 KOTodoView * _view; 188 KOTodoView * _view;
189}; 189};
190 190
191KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 191KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
192 const char *name) : 192 const char *name) :
193 KListView(parent,name) 193 KListView(parent,name)
194{ 194{
195 mName = QString ( name ); 195 mName = QString ( name );
196 mCalendar = calendar; 196 mCalendar = calendar;
197#ifndef DESKTOP_VERSION 197#ifndef DESKTOP_VERSION
198 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 198 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
199#endif 199#endif
200 mOldCurrent = 0; 200 mOldCurrent = 0;
201 mMousePressed = false; 201 mMousePressed = false;
202 202
203 setAcceptDrops(true); 203 setAcceptDrops(true);
204 viewport()->setAcceptDrops(true); 204 viewport()->setAcceptDrops(true);
205 int size = 16; 205 int size = 16;
206 if (qApp->desktop()->width() < 300 ) 206 if (qApp->desktop()->width() < 300 )
207 size = 12; 207 size = 12;
208 setTreeStepSize( size + 6 ); 208 setTreeStepSize( size + 6 );
209 209
210} 210}
211 211
212void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 212void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
213{ 213{
214#ifndef KORG_NODND 214#ifndef KORG_NODND
215// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 215// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
216 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 216 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
217 !QTextDrag::canDecode( e ) ) { 217 !QTextDrag::canDecode( e ) ) {
218 e->ignore(); 218 e->ignore();
219 return; 219 return;
220 } 220 }
221 221
222 mOldCurrent = currentItem(); 222 mOldCurrent = currentItem();
223#endif 223#endif
224} 224}
225 225
226 226
227void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 227void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
228{ 228{
229#ifndef KORG_NODND 229#ifndef KORG_NODND
230// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 230// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
231 231
232 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 232 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
233 !QTextDrag::canDecode( e ) ) { 233 !QTextDrag::canDecode( e ) ) {
234 e->ignore(); 234 e->ignore();
235 return; 235 return;
236 } 236 }
237 237
238 e->accept(); 238 e->accept();
239#endif 239#endif
240} 240}
241 241
242void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 242void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
243{ 243{
244#ifndef KORG_NODND 244#ifndef KORG_NODND
245// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 245// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
246 246
247 setCurrentItem(mOldCurrent); 247 setCurrentItem(mOldCurrent);
248 setSelected(mOldCurrent,true); 248 setSelected(mOldCurrent,true);
249#endif 249#endif
250} 250}
251 251
252void KOTodoListView::contentsDropEvent(QDropEvent *e) 252void KOTodoListView::contentsDropEvent(QDropEvent *e)
253{ 253{
254#ifndef KORG_NODND 254#ifndef KORG_NODND
255// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 255// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
256 256
257 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 257 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
258 !QTextDrag::canDecode( e ) ) { 258 !QTextDrag::canDecode( e ) ) {
259 e->ignore(); 259 e->ignore();
260 return; 260 return;
261 } 261 }
262 262
263 DndFactory factory( mCalendar ); 263 DndFactory factory( mCalendar );
264 Todo *todo = factory.createDropTodo(e); 264 Todo *todo = factory.createDropTodo(e);
265 265
266 if (todo) { 266 if (todo) {
267 e->acceptAction(); 267 e->acceptAction();
268 268
269 KOTodoViewItem *destination = 269 KOTodoViewItem *destination =
270 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 270 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
271 Todo *destinationEvent = 0; 271 Todo *destinationEvent = 0;
272 if (destination) destinationEvent = destination->todo(); 272 if (destination) destinationEvent = destination->todo();
273 273
274 Todo *existingTodo = mCalendar->todo(todo->uid()); 274 Todo *existingTodo = mCalendar->todo(todo->uid());
275 275
276 if(existingTodo) { 276 if(existingTodo) {
277 Incidence *to = destinationEvent; 277 Incidence *to = destinationEvent;
278 while(to) { 278 while(to) {
279 if (to->uid() == todo->uid()) { 279 if (to->uid() == todo->uid()) {
280 KMessageBox::sorry(this, 280 KMessageBox::sorry(this,
281 i18n("Cannot move Todo to itself\nor a child of itself"), 281 i18n("Cannot move Todo to itself\nor a child of itself"),
282 i18n("Drop Todo")); 282 i18n("Drop Todo"));
283 delete todo; 283 delete todo;
284 return; 284 return;
285 } 285 }
286 to = to->relatedTo(); 286 to = to->relatedTo();
287 } 287 }
288 internalDrop = true; 288 internalDrop = true;
289 if ( destinationEvent ) 289 if ( destinationEvent )
290 reparentTodoSignal( destinationEvent, existingTodo ); 290 reparentTodoSignal( destinationEvent, existingTodo );
291 else 291 else
292 unparentTodoSignal(existingTodo); 292 unparentTodoSignal(existingTodo);
293 delete todo; 293 delete todo;
294 } else { 294 } else {
295 mCalendar->addTodo(todo); 295 mCalendar->addTodo(todo);
296 emit todoDropped(todo, KOGlobals::EVENTADDED); 296 emit todoDropped(todo, KOGlobals::EVENTADDED);
297 if ( destinationEvent ) 297 if ( destinationEvent )
298 reparentTodoSignal( destinationEvent, todo ); 298 reparentTodoSignal( destinationEvent, todo );
299 } 299 }
300 } 300 }
301 else { 301 else {
302 QString text; 302 QString text;
303 if (QTextDrag::decode(e,text)) { 303 if (QTextDrag::decode(e,text)) {
304 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 304 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
305 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 305 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
306 qDebug("Dropped : " + text); 306 qDebug("Dropped : " + text);
307 QStringList emails = QStringList::split(",",text); 307 QStringList emails = QStringList::split(",",text);
308 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 308 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
309 int pos = (*it).find("<"); 309 int pos = (*it).find("<");
310 QString name = (*it).left(pos); 310 QString name = (*it).left(pos);
311 QString email = (*it).mid(pos); 311 QString email = (*it).mid(pos);
312 if (!email.isEmpty() && todoi) { 312 if (!email.isEmpty() && todoi) {
313 todoi->todo()->addAttendee(new Attendee(name,email)); 313 todoi->todo()->addAttendee(new Attendee(name,email));
314 } 314 }
315 } 315 }
316 } 316 }
317 else { 317 else {
318 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 318 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
319 e->ignore(); 319 e->ignore();
320 } 320 }
321 } 321 }
322#endif 322#endif
323} 323}
324void KOTodoListView::wheelEvent (QWheelEvent *e) 324void KOTodoListView::wheelEvent (QWheelEvent *e)
325{ 325{
326 QListView::wheelEvent (e); 326 QListView::wheelEvent (e);
327} 327}
328 328
329void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 329void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
330{ 330{
331 331
332 QPoint p(contentsToViewport(e->pos())); 332 QPoint p(contentsToViewport(e->pos()));
333 QListViewItem *i = itemAt(p); 333 QListViewItem *i = itemAt(p);
334 bool rootClicked = true; 334 bool rootClicked = true;
335 if (i) { 335 if (i) {
336 // if the user clicked into the root decoration of the item, don't 336 // if the user clicked into the root decoration of the item, don't
337 // try to start a drag! 337 // try to start a drag!
338 int X = p.x(); 338 int X = p.x();
339 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 339 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
340 if (X > header()->sectionPos(0) + 340 if (X > header()->sectionPos(0) +
341 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 341 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
342 itemMargin() +i->height()|| 342 itemMargin() +i->height()||
343 X < header()->sectionPos(0)) { 343 X < header()->sectionPos(0)) {
344 rootClicked = false; 344 rootClicked = false;
345 } 345 }
346 } else { 346 } else {
347 rootClicked = false; 347 rootClicked = false;
348 } 348 }
349#ifndef KORG_NODND 349#ifndef KORG_NODND
350 mMousePressed = false; 350 mMousePressed = false;
351 if (! rootClicked && !( e->button() == RightButton) ) { 351 if (! rootClicked && !( e->button() == RightButton) ) {
352 mPressPos = e->pos(); 352 mPressPos = e->pos();
353 mMousePressed = true; 353 mMousePressed = true;
354 } else { 354 } else {
355 mMousePressed = false; 355 mMousePressed = false;
356 } 356 }
357#endif 357#endif
358 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 358 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
359#ifndef DESKTOP_VERSION 359#ifndef DESKTOP_VERSION
360 if (!( e->button() == RightButton && rootClicked) ) 360 if (!( e->button() == RightButton && rootClicked) )
361 QListView::contentsMousePressEvent(e); 361 QListView::contentsMousePressEvent(e);
362#else 362#else
363 QListView::contentsMousePressEvent(e); 363 QListView::contentsMousePressEvent(e);
364#endif 364#endif
365} 365}
366void KOTodoListView::paintEvent(QPaintEvent* e) 366void KOTodoListView::paintEvent(QPaintEvent* e)
367{ 367{
368 emit paintNeeded(); 368 emit paintNeeded();
369 QListView::paintEvent( e); 369 QListView::paintEvent( e);
370} 370}
371void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 371void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
372{ 372{
373 373
374#ifndef KORG_NODND 374#ifndef KORG_NODND
375 //QListView::contentsMouseMoveEvent(e); 375 //QListView::contentsMouseMoveEvent(e);
376 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 376 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
377 QApplication::startDragDistance()*3) { 377 QApplication::startDragDistance()*3) {
378 mMousePressed = false; 378 mMousePressed = false;
379 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 379 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
380 if (item) { 380 if (item) {
381 DndFactory factory( mCalendar ); 381 DndFactory factory( mCalendar );
382 ICalDrag *vd = factory.createDrag( 382 ICalDrag *vd = factory.createDrag(
383 ((KOTodoViewItem *)item)->todo(),viewport()); 383 ((KOTodoViewItem *)item)->todo(),viewport());
384 internalDrop = false; 384 internalDrop = false;
385 // we cannot do any senseful here, because the DnD is still broken in Qt 385 // we cannot do any senseful here, because the DnD is still broken in Qt
386 if (vd->drag()) { 386 if (vd->drag()) {
387 if ( !internalDrop ) { 387 if ( !internalDrop ) {
388 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 388 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
389 qDebug("Dnd: External move: Delete drag source "); 389 qDebug("Dnd: External move: Delete drag source ");
390 } else 390 } else
391 qDebug("Dnd: Internal move "); 391 qDebug("Dnd: Internal move ");
392 392
393 } else { 393 } else {
394 if ( !internalDrop ) { 394 if ( !internalDrop ) {
395 qDebug("Dnd: External Copy"); 395 qDebug("Dnd: External Copy");
396 } else 396 } else
397 qDebug("DnD: Internal copy: Copy pending"); 397 qDebug("DnD: Internal copy: Copy pending");
398 } 398 }
399 } 399 }
400 } 400 }
401#endif 401#endif
402} 402}
403void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 403void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
404{ 404{
405 if ( !e->isAutoRepeat() ) { 405 if ( !e->isAutoRepeat() ) {
406 mFlagKeyPressed = false; 406 mFlagKeyPressed = false;
407 } 407 }
408} 408}
409 409
410 410
411void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 411void KOTodoListView::keyPressEvent ( QKeyEvent * e )
412{ 412{
413 qApp->processEvents(); 413 qApp->processEvents();
414 if ( !isVisible() ) { 414 if ( !isVisible() ) {
415 e->ignore(); 415 e->ignore();
416 return; 416 return;
417 } 417 }
418 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 418 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
419 e->ignore(); 419 e->ignore();
420 // qDebug(" ignore %d",e->isAutoRepeat() ); 420 // qDebug(" ignore %d",e->isAutoRepeat() );
421 return; 421 return;
422 } 422 }
423 if (! e->isAutoRepeat() ) 423 if (! e->isAutoRepeat() )
424 mFlagKeyPressed = true; 424 mFlagKeyPressed = true;
425 QListViewItem* cn; 425 QListViewItem* cn;
426 if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") { 426 if ( (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && mName != "todolistsmall") {
427 cn = currentItem(); 427 cn = currentItem();
428 if ( cn ) { 428 if ( cn ) {
429 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 429 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
430 if ( ci ){ 430 if ( ci ){
431 if ( e->state() == ShiftButton ) 431 if ( e->state() == ShiftButton )
432 ci->setOn( false ); 432 ci->setOn( false );
433 else 433 else
434 ci->setOn( true ); 434 ci->setOn( true );
435 cn = cn->itemBelow(); 435 cn = cn->itemBelow();
436 if ( cn ) { 436 if ( cn ) {
437 setCurrentItem ( cn ); 437 setCurrentItem ( cn );
438 ensureItemVisible ( cn ); 438 ensureItemVisible ( cn );
439 } 439 }
440 440
441 } 441 }
442 } 442 }
443 443
444 e->accept(); 444 e->accept();
445 return; 445 return;
446 } 446 }
447 447
448 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 448 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
449 switch ( e->key() ) { 449 switch ( e->key() ) {
450 case Qt::Key_Down: 450 case Qt::Key_Down:
451 case Qt::Key_Up: 451 case Qt::Key_Up:
452 QListView::keyPressEvent ( e ); 452 QListView::keyPressEvent ( e );
453 e->accept(); 453 e->accept();
454 break; 454 break;
455 case Qt::Key_Left: 455 case Qt::Key_Left:
456 case Qt::Key_Right: 456 case Qt::Key_Right:
457 QListView::keyPressEvent ( e ); 457 QListView::keyPressEvent ( e );
458 e->accept(); 458 e->accept();
459 return; 459 return;
460 break; 460 break;
461 default: 461 default:
462 e->ignore(); 462 e->ignore();
463 break; 463 break;
464 } 464 }
465 return; 465 return;
466 } 466 }
467 e->ignore(); 467 e->ignore();
468} 468}
469void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 469void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
470{ 470{
471 QListView::contentsMouseReleaseEvent(e); 471 QListView::contentsMouseReleaseEvent(e);
472 mMousePressed = false; 472 mMousePressed = false;
473} 473}
474 474
475void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 475void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
476{ 476{
477 if (!e) return; 477 if (!e) return;
478 478
479 QPoint vp = contentsToViewport(e->pos()); 479 QPoint vp = contentsToViewport(e->pos());
480 480
481 QListViewItem *item = itemAt(vp); 481 QListViewItem *item = itemAt(vp);
482 482
483 emit double_Clicked(item); 483 emit double_Clicked(item);
484 if (!item) return; 484 if (!item) return;
485 485
486 emit doubleClicked(item,vp,0); 486 emit doubleClicked(item,vp,0);
487} 487}
488 488
489///////////////////////////////////////////////////////////////////////////// 489/////////////////////////////////////////////////////////////////////////////
490 490
491KOQuickTodo::KOQuickTodo(QWidget *parent) : 491KOQuickTodo::KOQuickTodo(QWidget *parent) :
492 QLineEdit(parent) 492 QLineEdit(parent)
493{ 493{
494 setText(i18n("Click to add new Todo")); 494 setText(i18n("Click to add new Todo"));
495 setFocusPolicy ( QWidget::ClickFocus ); 495 setFocusPolicy ( QWidget::ClickFocus );
496} 496}
497 497
498void KOQuickTodo::focusInEvent(QFocusEvent *ev) 498void KOQuickTodo::focusInEvent(QFocusEvent *ev)
499{ 499{
500 if ( text()==i18n("Click to add new Todo") ) 500 if ( text()==i18n("Click to add new Todo") )
501 setText(""); 501 setText("");
502 QLineEdit::focusInEvent(ev); 502 QLineEdit::focusInEvent(ev);
503} 503}
504 504
505void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 505void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
506{ 506{
507 setText(i18n("Click to add new Todo")); 507 setText(i18n("Click to add new Todo"));
508 QLineEdit::focusOutEvent(ev); 508 QLineEdit::focusOutEvent(ev);
509} 509}
510 510
511///////////////////////////////////////////////////////////////////////////// 511/////////////////////////////////////////////////////////////////////////////
512 512
513KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 513KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
514 KOrg::BaseView(calendar,parent,name) 514 KOrg::BaseView(calendar,parent,name)
515{ 515{
516 516 mIsActiveWindow = false;
517 mCurItem = 0; 517 mCurItem = 0;
518 mCurItemRootParent = 0; 518 mCurItemRootParent = 0;
519 mCurItemParent = 0; 519 mCurItemParent = 0;
520 mCurItemAbove = 0; 520 mCurItemAbove = 0;
521 mActiveItem = 0; 521 mActiveItem = 0;
522 mCategoryPopupMenu = 0; 522 mCategoryPopupMenu = 0;
523 mPendingUpdateBeforeRepaint = false; 523 mPendingUpdateBeforeRepaint = false;
524 isFlatDisplay = false; 524 isFlatDisplay = false;
525 mNavigator = 0; 525 mNavigator = 0;
526 QBoxLayout *topLayout = new QVBoxLayout(this); 526 QBoxLayout *topLayout = new QVBoxLayout(this);
527 mName = QString ( name ); 527 mName = QString ( name );
528 mBlockUpdate = false; 528 mBlockUpdate = false;
529 mQuickBar = new QWidget( this ); 529 mQuickBar = new QWidget( this );
530 topLayout->addWidget(mQuickBar); 530 topLayout->addWidget(mQuickBar);
531 531
532 mQuickAdd = new KOQuickTodo(mQuickBar); 532 mQuickAdd = new KOQuickTodo(mQuickBar);
533 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); 533 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar);
534 quickLayout->addWidget( mQuickAdd ); 534 quickLayout->addWidget( mQuickAdd );
535 mNewSubBut = new QPushButton( "sub",mQuickBar ); 535 mNewSubBut = new QPushButton( "sub",mQuickBar );
536 QPushButton * s_done = new QPushButton( "D",mQuickBar ); 536 QPushButton * s_done = new QPushButton( "D",mQuickBar );
537 QPushButton * s_run = new QPushButton( "R",mQuickBar ); 537 QPushButton * s_run = new QPushButton( "R",mQuickBar );
538 QPushButton * allopen = new QPushButton( "O",mQuickBar ); 538 QPushButton * allopen = new QPushButton( "O",mQuickBar );
539 QPushButton * allclose = new QPushButton( "C",mQuickBar ); 539 QPushButton * allclose = new QPushButton( "C",mQuickBar );
540 QPushButton * flat = new QPushButton( "F",mQuickBar ); 540 QPushButton * flat = new QPushButton( "F",mQuickBar );
541 541
542 int fixwid = mQuickAdd->sizeHint().height(); 542 int fixwid = mQuickAdd->sizeHint().height();
543 int fixhei = fixwid; 543 int fixhei = fixwid;
544 if ( QApplication::desktop()->width() > 800 ) 544 if ( QApplication::desktop()->width() > 800 )
545 fixwid = (fixwid*3)/2; 545 fixwid = (fixwid*3)/2;
546 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); 546 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat()));
547 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); 547 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen()));
548 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); 548 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose()));
549 s_done->setPixmap( SmallIcon("greenhook16")); 549 s_done->setPixmap( SmallIcon("greenhook16"));
550 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); 550 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted()));
551 s_run->setPixmap( SmallIcon("ko16old")); 551 s_run->setPixmap( SmallIcon("ko16old"));
552 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); 552 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning()));
553 553
554 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); 554 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo()));
555 555
556 mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() ); 556 mNewSubBut->setFixedWidth(mNewSubBut->sizeHint().width() );
557 mNewSubBut->setEnabled( false ); 557 mNewSubBut->setEnabled( false );
558 flat->setFixedWidth( fixwid ); 558 flat->setFixedWidth( fixwid );
559 s_done->setFixedWidth( fixwid ); 559 s_done->setFixedWidth( fixwid );
560 allopen->setFixedWidth( fixwid ); 560 allopen->setFixedWidth( fixwid );
561 allclose->setFixedWidth( fixwid ); 561 allclose->setFixedWidth( fixwid );
562 s_run->setFixedWidth( fixwid ); 562 s_run->setFixedWidth( fixwid );
563 563
564 flat->setFixedHeight(fixhei ); 564 flat->setFixedHeight(fixhei );
565 s_done->setFixedHeight(fixhei ); 565 s_done->setFixedHeight(fixhei );
566 allopen->setFixedHeight(fixhei ); 566 allopen->setFixedHeight(fixhei );
567 allclose->setFixedHeight(fixhei ); 567 allclose->setFixedHeight(fixhei );
568 s_run->setFixedHeight(fixhei ); 568 s_run->setFixedHeight(fixhei );
569 mNewSubBut->setFixedHeight(fixhei ); 569 mNewSubBut->setFixedHeight(fixhei );
570 570
571 flat->setFocusPolicy( NoFocus ); 571 flat->setFocusPolicy( NoFocus );
572 s_done->setFocusPolicy( NoFocus ); 572 s_done->setFocusPolicy( NoFocus );
573 allopen->setFocusPolicy( NoFocus ); 573 allopen->setFocusPolicy( NoFocus );
574 allclose->setFocusPolicy( NoFocus ); 574 allclose->setFocusPolicy( NoFocus );
575 s_run->setFocusPolicy( NoFocus ); 575 s_run->setFocusPolicy( NoFocus );
576 mNewSubBut->setFocusPolicy( NoFocus ); 576 mNewSubBut->setFocusPolicy( NoFocus );
577 577
578 QWhatsThis::add( flat, i18n("Click this button to display all todos in a <b>flat</b> hierarchy" ) ); 578 QWhatsThis::add( flat, i18n("Click this button to display all todos in a <b>flat</b> hierarchy" ) );
579 QWhatsThis::add( allopen, i18n("Click this button to display all todos <b>openend</b>" ) ); 579 QWhatsThis::add( allopen, i18n("Click this button to display all todos <b>openend</b>" ) );
580 QWhatsThis::add( allclose, i18n("Click this button to display all todos <b>closed</b>" ) ); 580 QWhatsThis::add( allclose, i18n("Click this button to display all todos <b>closed</b>" ) );
581 QWhatsThis::add( s_run, i18n("Click this button to toggle show/hide <b>running</b> todos" ) ); 581 QWhatsThis::add( s_run, i18n("Click this button to toggle show/hide <b>running</b> todos" ) );
582 QWhatsThis::add( mNewSubBut, i18n("Click this button to add a new subtodo to the currently selected todo" ) ); 582 QWhatsThis::add( mNewSubBut, i18n("Click this button to add a new subtodo to the currently selected todo" ) );
583 QWhatsThis::add( s_done, i18n("Click this button to toggle show/hide <b>completed</b> todos" ) ); 583 QWhatsThis::add( s_done, i18n("Click this button to toggle show/hide <b>completed</b> todos" ) );
584 584
585 quickLayout->addWidget( mNewSubBut ); 585 quickLayout->addWidget( mNewSubBut );
586 quickLayout->addWidget( s_done ); 586 quickLayout->addWidget( s_done );
587 quickLayout->addWidget( s_run ); 587 quickLayout->addWidget( s_run );
588 quickLayout->addWidget( allopen ); 588 quickLayout->addWidget( allopen );
589 quickLayout->addWidget( allclose ); 589 quickLayout->addWidget( allclose );
590 quickLayout->addWidget( flat ); 590 quickLayout->addWidget( flat );
591 591
592 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); 592 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide();
593 593
594 mTodoListView = new KOTodoListView(calendar,this, name ); 594 mTodoListView = new KOTodoListView(calendar,this, name );
595 topLayout->addWidget(mTodoListView); 595 topLayout->addWidget(mTodoListView);
596 //mTodoListView->header()->setMaximumHeight(30); 596 //mTodoListView->header()->setMaximumHeight(30);
597 mTodoListView->setRootIsDecorated(true); 597 mTodoListView->setRootIsDecorated(true);
598 mTodoListView->setAllColumnsShowFocus(true); 598 mTodoListView->setAllColumnsShowFocus(true);
599 599
600 mTodoListView->setShowSortIndicator(true); 600 mTodoListView->setShowSortIndicator(true);
601 601
602 mTodoListView->addColumn(i18n("Todo")); 602 mTodoListView->addColumn(i18n("Todo"));
603 mTodoListView->addColumn(i18n("Prio")); 603 mTodoListView->addColumn(i18n("Prio"));
604 mTodoListView->setColumnAlignment(1,AlignHCenter); 604 mTodoListView->setColumnAlignment(1,AlignHCenter);
605 mTodoListView->addColumn(i18n("Complete")); 605 mTodoListView->addColumn(i18n("Complete"));
606 mTodoListView->setColumnAlignment(2,AlignCenter); 606 mTodoListView->setColumnAlignment(2,AlignCenter);
607 607
608 mTodoListView->addColumn(i18n("Due Date")); 608 mTodoListView->addColumn(i18n("Due Date"));
609 mTodoListView->setColumnAlignment(3,AlignLeft); 609 mTodoListView->setColumnAlignment(3,AlignLeft);
610 mTodoListView->addColumn(i18n("Due Time")); 610 mTodoListView->addColumn(i18n("Due Time"));
611 mTodoListView->setColumnAlignment(4,AlignHCenter); 611 mTodoListView->setColumnAlignment(4,AlignHCenter);
612 612
613 mTodoListView->addColumn(i18n("Start Date")); 613 mTodoListView->addColumn(i18n("Start Date"));
614 mTodoListView->setColumnAlignment(5,AlignLeft); 614 mTodoListView->setColumnAlignment(5,AlignLeft);
615 mTodoListView->addColumn(i18n("Start Time")); 615 mTodoListView->addColumn(i18n("Start Time"));
616 mTodoListView->setColumnAlignment(6,AlignHCenter); 616 mTodoListView->setColumnAlignment(6,AlignHCenter);
617 617
618 //mTodoListView->addColumn(i18n("Cancelled")); 618 //mTodoListView->addColumn(i18n("Cancelled"));
619 mTodoListView->addColumn(i18n("Categories")); 619 mTodoListView->addColumn(i18n("Categories"));
620 mTodoListView->addColumn(i18n("Calendar")); 620 mTodoListView->addColumn(i18n("Calendar"));
621 mTodoListView->addColumn(i18n("Last Modified")); 621 mTodoListView->addColumn(i18n("Last Modified"));
622 mTodoListView->addColumn(i18n("Created")); 622 mTodoListView->addColumn(i18n("Created"));
623 mTodoListView->addColumn(i18n("Last Modified Sub")); 623 mTodoListView->addColumn(i18n("Last Modified Sub"));
624#if 0 624#if 0
625 mTodoListView->addColumn(i18n("Sort Id")); 625 mTodoListView->addColumn(i18n("Sort Id"));
626 mTodoListView->setColumnAlignment(4,AlignHCenter); 626 mTodoListView->setColumnAlignment(4,AlignHCenter);
627#endif 627#endif
628 628
629 mTodoListView->setMinimumHeight( 60 ); 629 mTodoListView->setMinimumHeight( 60 );
630 mTodoListView->setItemsRenameable( true ); 630 mTodoListView->setItemsRenameable( true );
631 mTodoListView->setRenameable( 0 ); 631 mTodoListView->setRenameable( 0 );
632 mTodoListView->setColumnWidth( 0, 120 ); 632 mTodoListView->setColumnWidth( 0, 120 );
633 int iii = 0; 633 int iii = 0;
634 for ( iii = 0; iii< 12 ; ++iii ) 634 for ( iii = 0; iii< 12 ; ++iii )
635 mTodoListView->setColumnWidthMode( iii, QListView::Manual ); 635 mTodoListView->setColumnWidthMode( iii, QListView::Manual );
636 636
637 637
638 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 638 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
639 639
640 mPriorityPopupMenu = new QPopupMenu(this); 640 mPriorityPopupMenu = new QPopupMenu(this);
641 for (int i = 1; i <= 5; i++) { 641 for (int i = 1; i <= 5; i++) {
642 QString label = QString ("%1").arg (i); 642 QString label = QString ("%1").arg (i);
643 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 643 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
644 } 644 }
645 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 645 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
646 646
647 mPercentageCompletedPopupMenu = new QPopupMenu(this); 647 mPercentageCompletedPopupMenu = new QPopupMenu(this);
648 for (int i = 0; i <= 100; i+=20) { 648 for (int i = 0; i <= 100; i+=20) {
649 QString label = QString ("%1 %").arg (i); 649 QString label = QString ("%1 %").arg (i);
650 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 650 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
651 } 651 }
652 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 652 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
653 653
654 654
655 mCategoryPopupMenu = new QPopupMenu (this); 655 mCategoryPopupMenu = new QPopupMenu (this);
656 mCategoryPopupMenu->setCheckable (true); 656 mCategoryPopupMenu->setCheckable (true);
657 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 657 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
658 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); 658 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ()));
659 659
660 mCalPopupMenu = new QPopupMenu (this); 660 mCalPopupMenu = new QPopupMenu (this);
661 mCalPopupMenu->setCheckable (true); 661 mCalPopupMenu->setCheckable (true);
662 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); 662 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int)));
663 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); 663 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ()));
664 664
665 665
666 666
667 667
668 mItemPopupMenu = new QPopupMenu(this); 668 mItemPopupMenu = new QPopupMenu(this);
669 mItemPopupMenu->insertItem(i18n("Show"), this, 669 mItemPopupMenu->insertItem(i18n("Show"), this,
670 SLOT (showTodo())); 670 SLOT (showTodo()));
671 mItemPopupMenu->insertItem(i18n("Edit..."), this, 671 mItemPopupMenu->insertItem(i18n("Edit..."), this,
672 SLOT (editTodo())); 672 SLOT (editTodo()));
673 mItemPopupMenu->insertItem( i18n("Delete..."), this, 673 mItemPopupMenu->insertItem( i18n("Delete..."), this,
674 SLOT (deleteTodo())); 674 SLOT (deleteTodo()));
675 mItemPopupMenu->insertItem( i18n("Clone..."), this, 675 mItemPopupMenu->insertItem( i18n("Clone..."), this,
676 SLOT (cloneTodo())); 676 SLOT (cloneTodo()));
677 mItemPopupMenu->insertItem( i18n("Move..."), this, 677 mItemPopupMenu->insertItem( i18n("Move..."), this,
678 SLOT (moveTodo())); 678 SLOT (moveTodo()));
679#ifndef DESKTOP_VERSION 679#ifndef DESKTOP_VERSION
680 mItemPopupMenu->insertItem( i18n("Beam..."), this, 680 mItemPopupMenu->insertItem( i18n("Beam..."), this,
681 SLOT (beamTodo())); 681 SLOT (beamTodo()));
682#endif 682#endif
683 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 683 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
684 SLOT (cancelTodo())); 684 SLOT (cancelTodo()));
685 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); 685 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu);
686 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); 686 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu);
687 mItemPopupMenu->insertSeparator(); 687 mItemPopupMenu->insertSeparator();
688 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 688 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
689 SLOT (toggleRunningItem())); 689 SLOT (toggleRunningItem()));
690 mItemPopupMenu->insertSeparator(); 690 mItemPopupMenu->insertSeparator();
691 /* 691 /*
692 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 692 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
693 SLOT (newTodo())); 693 SLOT (newTodo()));
694 */ 694 */
695 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 695 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
696 SLOT (newSubTodo())); 696 SLOT (newSubTodo()));
697 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 697 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
698 SLOT (unparentTodo()),0,21); 698 SLOT (unparentTodo()),0,21);
699 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 699 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
700 SLOT (reparentTodo()),0,22); 700 SLOT (reparentTodo()),0,22);
701 mItemPopupMenu->insertSeparator(); 701 mItemPopupMenu->insertSeparator();
702#if 0 702#if 0
703 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), 703 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."),
704 this, SLOT( purgeCompleted() ) ); 704 this, SLOT( purgeCompleted() ) );
705 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 705 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
706 this, SLOT( toggleCompleted() ),0, 33 ); 706 this, SLOT( toggleCompleted() ),0, 33 );
707 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 707 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
708 this, SLOT( toggleQuickTodo() ),0, 34 ); 708 this, SLOT( toggleQuickTodo() ),0, 34 );
709 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 709 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
710 this, SLOT( toggleRunning() ),0, 35 ); 710 this, SLOT( toggleRunning() ),0, 35 );
711 711
712#endif 712#endif
713 mPopupMenu = new QPopupMenu(this); 713 mPopupMenu = new QPopupMenu(this);
714 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 714 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
715 SLOT (newTodo()),0,1); 715 SLOT (newTodo()),0,1);
716 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), 716 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."),
717 this, SLOT(purgeCompleted()),0,2); 717 this, SLOT(purgeCompleted()),0,2);
718 mPopupMenu->insertItem(i18n("Show Completed"), 718 mPopupMenu->insertItem(i18n("Show Completed"),
719 this, SLOT( toggleCompleted() ),0,3 ); 719 this, SLOT( toggleCompleted() ),0,3 );
720 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 720 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
721 this, SLOT( toggleRunning() ),0,5 ); 721 this, SLOT( toggleRunning() ),0,5 );
722 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 722 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
723 this, SLOT( setAllOpen() ),0,6 ); 723 this, SLOT( setAllOpen() ),0,6 );
724 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 724 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
725 this, SLOT( setAllClose() ),0,7 ); 725 this, SLOT( setAllClose() ),0,7 );
726 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 726 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
727 this, SLOT( setAllFlat() ),0,8 ); 727 this, SLOT( setAllFlat() ),0,8 );
728 mPopupMenu->insertSeparator(); 728 mPopupMenu->insertSeparator();
729 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 729 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
730 this, SLOT( toggleQuickTodo() ),0,4 ); 730 this, SLOT( toggleQuickTodo() ),0,4 );
731 mDocPrefs = new DocPrefs( name ); 731 mDocPrefs = new DocPrefs( name );
732 732
733 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 733 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
734 mPopupMenu->setCheckable( true ); 734 mPopupMenu->setCheckable( true );
735 mItemPopupMenu->setCheckable( true ); 735 mItemPopupMenu->setCheckable( true );
736 736
737 737
738 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 738 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
739 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 739 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
740 740
741 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 741 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
742 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 742 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
743 743
744 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 744 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
745 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 745 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
746 746
747 747
748 // Double clicking conflicts with opening/closing the subtree 748 // Double clicking conflicts with opening/closing the subtree
749 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 749 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
750 SLOT( editItem( QListViewItem *) ) ); 750 SLOT( editItem( QListViewItem *) ) );
751 /* 751 /*
752 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 752 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
753 const QPoint &,int ) ), 753 const QPoint &,int ) ),
754 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 754 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
755 */ 755 */
756 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 756 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
757 const QPoint &,int ) ), 757 const QPoint &,int ) ),
758 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 758 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
759 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 759 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
760 SLOT( itemClicked( QListViewItem * ) ) ); 760 SLOT( itemClicked( QListViewItem * ) ) );
761 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 761 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
762 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 762 SLOT( itemDoubleClicked( QListViewItem * ) ) );
763 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 763 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
764 SLOT( updateView() ) ); 764 SLOT( updateView() ) );
765 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 765 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
766 SLOT( todoModified(Todo *, int) ) ); 766 SLOT( todoModified(Todo *, int) ) );
767 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 767 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
768 SLOT( itemStateChanged( QListViewItem * ) ) ); 768 SLOT( itemStateChanged( QListViewItem * ) ) );
769 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 769 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
770 SLOT( itemStateChanged( QListViewItem * ) ) ); 770 SLOT( itemStateChanged( QListViewItem * ) ) );
771 connect( mTodoListView, SIGNAL( paintNeeded() ), 771 connect( mTodoListView, SIGNAL( paintNeeded() ),
772 SLOT( paintNeeded()) ); 772 SLOT( paintNeeded()) );
773 773
774#if 0 774#if 0
775 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 775 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
776 SLOT(selectionChanged(QListViewItem *))); 776 SLOT(selectionChanged(QListViewItem *)));
777 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 777 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
778 SLOT(selectionChanged(QListViewItem *))); 778 SLOT(selectionChanged(QListViewItem *)));
779 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 779 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
780 SLOT(selectionChanged(QListViewItem *))); 780 SLOT(selectionChanged(QListViewItem *)));
781#endif 781#endif
782 782
783 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 783 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
784 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 784 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
785 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 785 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
786 786
787 connect( mTodoListView, SIGNAL(selectionChanged() ), 787 connect( mTodoListView, SIGNAL(selectionChanged() ),
788 SLOT( processSelectionChange() ) ); 788 SLOT( processSelectionChange() ) );
789 connect( mQuickAdd, SIGNAL( returnPressed () ), 789 connect( mQuickAdd, SIGNAL( returnPressed () ),
790 SLOT( addQuickTodo() ) ); 790 SLOT( addQuickTodo() ) );
791 791
792} 792}
793 793
794KOTodoView::~KOTodoView() 794KOTodoView::~KOTodoView()
795{ 795{
796 796
797#if QT_VERSION >= 0x030000 797#if QT_VERSION >= 0x030000
798 798
799#else 799#else
800 delete mKOTodoViewWhatsThis; 800 delete mKOTodoViewWhatsThis;
801#endif 801#endif
802 802
803 delete mDocPrefs; 803 delete mDocPrefs;
804} 804}
805QString KOTodoView::getWhatsThisText(QPoint p) 805QString KOTodoView::getWhatsThisText(QPoint p)
806{ 806{
807 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 807 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
808 if ( item ) 808 if ( item )
809 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 809 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
810 KOPrefs::instance()->mWTshowDetails, 810 KOPrefs::instance()->mWTshowDetails,
811 KOPrefs::instance()->mWTshowCreated, 811 KOPrefs::instance()->mWTshowCreated,
812 KOPrefs::instance()->mWTshowChanged); 812 KOPrefs::instance()->mWTshowChanged);
813 return i18n("That is the todo view" ); 813 return i18n("That is the todo view" );
814 814
815} 815}
816 816
817void KOTodoView::jumpToDate () 817void KOTodoView::jumpToDate ()
818{ 818{
819 // if (mActiveItem) { 819 // if (mActiveItem) {
820// mActiveItem->todo()); 820// mActiveItem->todo());
821// if ( mActiveItem->todo()->hasDueDate() ) 821// if ( mActiveItem->todo()->hasDueDate() )
822// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 822// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
823} 823}
824void KOTodoView::paintNeeded() 824void KOTodoView::paintNeeded()
825{ 825{
826 if ( mPendingUpdateBeforeRepaint ) { 826 if ( mPendingUpdateBeforeRepaint ) {
827 updateView(); 827 updateView();
828 mPendingUpdateBeforeRepaint = false; 828 mPendingUpdateBeforeRepaint = false;
829 } 829 }
830} 830}
831void KOTodoView::paintEvent(QPaintEvent * pevent) 831void KOTodoView::paintEvent(QPaintEvent * pevent)
832{ 832{
833 if ( mPendingUpdateBeforeRepaint ) { 833 if ( mPendingUpdateBeforeRepaint ) {
834 updateView(); 834 updateView();
835 mPendingUpdateBeforeRepaint = false; 835 mPendingUpdateBeforeRepaint = false;
836 } 836 }
837 KOrg::BaseView::paintEvent( pevent); 837 KOrg::BaseView::paintEvent( pevent);
838} 838}
839 839
840void KOTodoView::clearList( bool saveCurrentItem ) // default true 840void KOTodoView::clearList( bool saveCurrentItem ) // default true
841{ 841{
842 if ( mTodoListView->childCount() ) { 842 if ( mTodoListView->childCount() ) {
843 if ( saveCurrentItem ) 843 if ( saveCurrentItem )
844 storeCurrentItem(); 844 storeCurrentItem();
845 mTodoListView->clear(); 845 mTodoListView->clear();
846 mTodoMap.clear(); 846 mTodoMap.clear();
847 } 847 }
848} 848}
849void KOTodoView::updateView() 849void KOTodoView::updateView()
850{ 850{
851 mActiveItem = 0; 851 mActiveItem = 0;
852 pendingSubtodo = 0; 852 pendingSubtodo = 0;
853 if ( mBlockUpdate ) { 853 if ( mBlockUpdate ) {
854 return; 854 return;
855 } 855 }
856 if ( !isVisible() ) { 856 if ( !isVisible() ) {
857 clearList (); 857 clearList ();
858 mPendingUpdateBeforeRepaint = true; 858 mPendingUpdateBeforeRepaint = true;
859 return; 859 return;
860 } 860 }
861 //qDebug("KOTodoView::updateView() %x", this); 861 //qDebug("KOTodoView::updateView() %x", this);
862 if ( isFlatDisplay ) { 862 if ( isFlatDisplay ) {
863 displayAllFlat(); 863 displayAllFlat();
864 return; 864 return;
865 } 865 }
866 //qDebug("update "); 866 //qDebug("update ");
867// kdDebug() << "KOTodoView::updateView()" << endl; 867// kdDebug() << "KOTodoView::updateView()" << endl;
868 QFont fo = KOPrefs::instance()->mTodoViewFont; 868 QFont fo = KOPrefs::instance()->mTodoViewFont;
869 869
870 clearList (); 870 clearList ();
871 871
872 if ( mName == "todolistsmall" ) { 872 if ( mName == "todolistsmall" ) {
873 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 873 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
874 int ps = fo.pointSize() -2; 874 int ps = fo.pointSize() -2;
875 if ( ps > 12 ) 875 if ( ps > 12 )
876 ps -= 2; 876 ps -= 2;
877 fo.setPointSize( ps ); 877 fo.setPointSize( ps );
878 } 878 }
879 } 879 }
880 880
881 mTodoListView->setFont( fo ); 881 mTodoListView->setFont( fo );
882 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 882 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
883 //mTodoListView->header()->setMaximumHeight(fm.height()); 883 //mTodoListView->header()->setMaximumHeight(fm.height());
884 QPtrList<Todo> todoList = calendar()->todos(); 884 QPtrList<Todo> todoList = calendar()->todos();
885 885
886/* 886/*
887 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 887 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
888 Event *t; 888 Event *t;
889 for(t = todoList.first(); t; t = todoList.next()) { 889 for(t = todoList.first(); t; t = todoList.next()) {
890 kdDebug() << " " << t->getSummary() << endl; 890 kdDebug() << " " << t->getSummary() << endl;
891 891
892 if (t->getRelatedTo()) { 892 if (t->getRelatedTo()) {
893 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 893 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
894 } 894 }
895 895
896 QPtrList<Event> l = t->getRelations(); 896 QPtrList<Event> l = t->getRelations();
897 Event *c; 897 Event *c;
898 for(c=l.first();c;c=l.next()) { 898 for(c=l.first();c;c=l.next()) {
899 kdDebug() << " - relation: " << c->getSummary() << endl; 899 kdDebug() << " - relation: " << c->getSummary() << endl;
900 } 900 }
901 } 901 }
902*/ 902*/
903 903
904 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 904 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
905 // specific order of events. That means that we have to generate parent items 905 // specific order of events. That means that we have to generate parent items
906 // recursively for proper hierarchical display of Todos. 906 // recursively for proper hierarchical display of Todos.
907 Todo *todo; 907 Todo *todo;
908 todo = todoList.first();// todo; todo = todoList.next()) { 908 todo = todoList.first();// todo; todo = todoList.next()) {
909 while ( todo ) { 909 while ( todo ) {
910 bool next = true; 910 bool next = true;
911 // qDebug("todo %s ", todo->summary().latin1()); 911 // qDebug("todo %s ", todo->summary().latin1());
912 Incidence *incidence = todo->relatedTo(); 912 Incidence *incidence = todo->relatedTo();
913 while ( incidence ) { 913 while ( incidence ) {
914 if ( incidence->typeID() == todoID ) { 914 if ( incidence->typeID() == todoID ) {
915 //qDebug("related %s ",incidence->summary().latin1() ); 915 //qDebug("related %s ",incidence->summary().latin1() );
916 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { 916 if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) {
917 //qDebug("related not found "); 917 //qDebug("related not found ");
918 todoList.remove( ); 918 todoList.remove( );
919 todo = todoList.current(); 919 todo = todoList.current();
920 next = false; 920 next = false;
921 incidence = 0; 921 incidence = 0;
922 922
923 } else { 923 } else {
924 //qDebug("related found "); 924 //qDebug("related found ");
925 incidence = incidence->relatedTo(); 925 incidence = incidence->relatedTo();
926 } 926 }
927 } else 927 } else
928 incidence = 0; 928 incidence = 0;
929 } 929 }
930 if ( next ) 930 if ( next )
931 todo = todoList.next(); 931 todo = todoList.next();
932 } 932 }
933 933
934 for(todo = todoList.first(); todo; todo = todoList.next()) { 934 for(todo = todoList.first(); todo; todo = todoList.next()) {
935 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 935 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
936 { 936 {
937 insertTodoItem(todo); 937 insertTodoItem(todo);
938 } 938 }
939 } 939 }
940 // Restore opened/closed state 940 // Restore opened/closed state
941 mTodoListView->blockSignals( true ); 941 mTodoListView->blockSignals( true );
942 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 942 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
943 mTodoListView->blockSignals( false ); 943 mTodoListView->blockSignals( false );
944 resetCurrentItem(); 944 resetCurrentItem();
945} 945}
946 946
947void KOTodoView::storeCurrentItem() 947void KOTodoView::storeCurrentItem()
948{ 948{
949 mCurItem = 0; 949 mCurItem = 0;
950 mCurItemRootParent = 0; 950 mCurItemRootParent = 0;
951 mCurItemParent = 0; 951 mCurItemParent = 0;
952 mCurItemAbove = 0; 952 mCurItemAbove = 0;
953 mIsActiveWindow = topLevelWidget()->isActiveWindow();
953 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 954 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
954 if (mActiveItem) { 955 if (mActiveItem) {
955 mCurItem = mActiveItem->todo(); 956 mCurItem = mActiveItem->todo();
956 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 957 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
957 if ( activeItemAbove ) 958 if ( activeItemAbove )
958 mCurItemAbove = activeItemAbove->todo(); 959 mCurItemAbove = activeItemAbove->todo();
959 mCurItemRootParent = mCurItem; 960 mCurItemRootParent = mCurItem;
960 mCurItemParent = mCurItemRootParent->relatedTo(); 961 mCurItemParent = mCurItemRootParent->relatedTo();
961 while ( mCurItemRootParent->relatedTo() != 0 ) 962 while ( mCurItemRootParent->relatedTo() != 0 )
962 mCurItemRootParent = mCurItemRootParent->relatedTo(); 963 mCurItemRootParent = mCurItemRootParent->relatedTo();
963 } 964 }
964 mActiveItem = 0; 965 mActiveItem = 0;
965} 966}
966 967
967void KOTodoView::resetCurrentItem() 968void KOTodoView::resetCurrentItem()
968{ 969{
969 //mTodoListView->setFocus(); 970 //mTodoListView->setFocus();
970 KOTodoViewItem* foundItem = 0; 971 KOTodoViewItem* foundItem = 0;
971 KOTodoViewItem* foundItemRoot = 0; 972 KOTodoViewItem* foundItemRoot = 0;
972 KOTodoViewItem* foundItemParent = 0; 973 KOTodoViewItem* foundItemParent = 0;
973 KOTodoViewItem* foundItemAbove = 0; 974 KOTodoViewItem* foundItemAbove = 0;
974 if ( mTodoListView->firstChild () ) { 975 if ( mTodoListView->firstChild () ) {
975 if ( mCurItem ) { 976 if ( mCurItem ) {
976 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 977 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
977 while ( item ) { 978 while ( item ) {
978 if ( item->todo() == mCurItem ) { 979 if ( item->todo() == mCurItem ) {
979 foundItem = item; 980 foundItem = item;
980 break; 981 break;
981 } else if ( item->todo() == mCurItemAbove ) { 982 } else if ( item->todo() == mCurItemAbove ) {
982 foundItemAbove = item; 983 foundItemAbove = item;
983 984
984 } 985 }
985 if ( item->todo() == mCurItemRootParent ) { 986 if ( item->todo() == mCurItemRootParent ) {
986 foundItemRoot = item; 987 foundItemRoot = item;
987 } 988 }
988 if ( item->todo() == mCurItemParent ) { 989 if ( item->todo() == mCurItemParent ) {
989 foundItemParent = item; 990 foundItemParent = item;
990 } 991 }
991 item = (KOTodoViewItem*)item->itemBelow(); 992 item = (KOTodoViewItem*)item->itemBelow();
992 } 993 }
993 if ( ! foundItem ) { 994 if ( ! foundItem ) {
994 if ( foundItemParent ) { 995 if ( foundItemParent ) {
995 foundItem = foundItemParent; 996 foundItem = foundItemParent;
996 } else { 997 } else {
997 if ( foundItemRoot ) 998 if ( foundItemRoot )
998 foundItem = foundItemRoot; 999 foundItem = foundItemRoot;
999 else 1000 else
1000 foundItem = foundItemAbove; 1001 foundItem = foundItemAbove;
1001 } 1002 }
1002 } 1003 }
1003 } 1004 }
1004 if ( foundItem ) { 1005 if ( foundItem ) {
1005 mTodoListView->setSelected ( foundItem, true ); 1006 mTodoListView->setSelected ( foundItem, true );
1006 mTodoListView->setCurrentItem( foundItem ); 1007 mTodoListView->setCurrentItem( foundItem );
1007 mTodoListView->ensureItemVisible( foundItem ); 1008 mTodoListView->ensureItemVisible( foundItem );
1008 } else { 1009 } else {
1009 if ( mTodoListView->firstChild () ) { 1010 if ( mTodoListView->firstChild () ) {
1010 mTodoListView->setSelected ( mTodoListView->firstChild (), true ); 1011 mTodoListView->setSelected ( mTodoListView->firstChild (), true );
1011 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 1012 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
1012 } 1013 }
1013 } 1014 }
1014 } 1015 }
1015 processSelectionChange(); 1016 processSelectionChange();
1016 if ( mName != "todolistsmall" ) 1017 if ( mName != "todolistsmall" )
1017 QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); 1018 QTimer::singleShot( 100, this, SLOT ( resetFocusToList() ));
1018} 1019}
1019void KOTodoView::resetFocusToList() 1020void KOTodoView::resetFocusToList()
1020{ 1021{
1021 topLevelWidget()->setActiveWindow(); 1022 if ( mIsActiveWindow )
1023 topLevelWidget()->setActiveWindow();
1022 mTodoListView->setFocus(); 1024 mTodoListView->setFocus();
1023} 1025}
1024//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 1026//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
1025bool KOTodoView::checkTodo( Todo * todo ) 1027bool KOTodoView::checkTodo( Todo * todo )
1026{ 1028{
1027 1029
1028 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 1030 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
1029 return false; 1031 return false;
1030 if ( !todo->isCompleted() ) { 1032 if ( !todo->isCompleted() ) {
1031 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 1033 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
1032 return true; 1034 return true;
1033 } 1035 }
1034 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 1036 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
1035 if ( todo->hasStartDate() ) 1037 if ( todo->hasStartDate() )
1036 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 1038 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
1037 return false; 1039 return false;
1038 if ( todo->hasDueDate() ) 1040 if ( todo->hasDueDate() )
1039 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 1041 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
1040 return false; 1042 return false;
1041 } 1043 }
1042 return true; 1044 return true;
1043} 1045}
1044 1046
1045void KOTodoView::restoreItemState( QListViewItem *item ) 1047void KOTodoView::restoreItemState( QListViewItem *item )
1046{ 1048{
1047 pendingSubtodo = 0; 1049 pendingSubtodo = 0;
1048 while( item ) { 1050 while( item ) {
1049 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1051 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1050 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 1052 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
1051 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 1053 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
1052 item = item->nextSibling(); 1054 item = item->nextSibling();
1053 } 1055 }
1054} 1056}
1055 1057
1056 1058
1057QMap<Todo *,KOTodoViewItem *>::ConstIterator 1059QMap<Todo *,KOTodoViewItem *>::ConstIterator
1058KOTodoView::insertTodoItem(Todo *todo) 1060KOTodoView::insertTodoItem(Todo *todo)
1059{ 1061{
1060 1062
1061 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 1063 // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
1062 // TODO: Check, if dynmaic cast is necessary 1064 // TODO: Check, if dynmaic cast is necessary
1063 1065
1064 pendingSubtodo = 0; 1066 pendingSubtodo = 0;
1065 Incidence *incidence = todo->relatedTo(); 1067 Incidence *incidence = todo->relatedTo();
1066 while ( incidence && !incidence->calEnabled() ) 1068 while ( incidence && !incidence->calEnabled() )
1067 incidence = incidence->relatedTo(); 1069 incidence = incidence->relatedTo();
1068 if (incidence && incidence->typeID() == todoID ) { 1070 if (incidence && incidence->typeID() == todoID ) {
1069 Todo *relatedTodo = static_cast<Todo *>(incidence); 1071 Todo *relatedTodo = static_cast<Todo *>(incidence);
1070 1072
1071 // kdDebug() << " has Related" << endl; 1073 // kdDebug() << " has Related" << endl;
1072 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1074 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1073 itemIterator = mTodoMap.find(relatedTodo); 1075 itemIterator = mTodoMap.find(relatedTodo);
1074 if (itemIterator == mTodoMap.end()) { 1076 if (itemIterator == mTodoMap.end()) {
1075 // kdDebug() << " related not yet in list" << endl; 1077 // kdDebug() << " related not yet in list" << endl;
1076 itemIterator = insertTodoItem (relatedTodo); 1078 itemIterator = insertTodoItem (relatedTodo);
1077 } 1079 }
1078 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 1080 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
1079 // and one into the map. Sure finding is more easy but why? -zecke 1081 // and one into the map. Sure finding is more easy but why? -zecke
1080 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 1082 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
1081 return mTodoMap.insert(todo,todoItem); 1083 return mTodoMap.insert(todo,todoItem);
1082 } else { 1084 } else {
1083 // kdDebug() << " no Related" << endl; 1085 // kdDebug() << " no Related" << endl;
1084 // see above -zecke 1086 // see above -zecke
1085 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1087 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1086 return mTodoMap.insert(todo,todoItem); 1088 return mTodoMap.insert(todo,todoItem);
1087 } 1089 }
1088} 1090}
1089 1091
1090 1092
1091void KOTodoView::updateConfig() 1093void KOTodoView::updateConfig()
1092{ 1094{
1093 updateView(); 1095 updateView();
1094 mTodoListView->repaintContents(); 1096 mTodoListView->repaintContents();
1095} 1097}
1096 1098
1097QPtrList<Incidence> KOTodoView::selectedIncidences() 1099QPtrList<Incidence> KOTodoView::selectedIncidences()
1098{ 1100{
1099 QPtrList<Incidence> selected; 1101 QPtrList<Incidence> selected;
1100 1102
1101 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 1103 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
1102// if (!item) item = mActiveItem; 1104// if (!item) item = mActiveItem;
1103 if (item) selected.append(item->todo()); 1105 if (item) selected.append(item->todo());
1104 1106
1105 return selected; 1107 return selected;
1106} 1108}
1107 1109
1108QPtrList<Todo> KOTodoView::selectedTodos() 1110QPtrList<Todo> KOTodoView::selectedTodos()
1109{ 1111{
1110 QPtrList<Todo> selected; 1112 QPtrList<Todo> selected;
1111 1113
1112 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 1114 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
1113// if (!item) item = mActiveItem; 1115// if (!item) item = mActiveItem;
1114 if (item) selected.append(item->todo()); 1116 if (item) selected.append(item->todo());
1115 1117
1116 return selected; 1118 return selected;
1117} 1119}
1118 1120
1119void KOTodoView::changeEventDisplay(Event *, int) 1121void KOTodoView::changeEventDisplay(Event *, int)
1120{ 1122{
1121 updateView(); 1123 updateView();
1122} 1124}
1123 1125
1124void KOTodoView::showDates(const QDate &, const QDate &) 1126void KOTodoView::showDates(const QDate &, const QDate &)
1125{ 1127{
1126} 1128}
1127 1129
1128void KOTodoView::showEvents(QPtrList<Event>) 1130void KOTodoView::showEvents(QPtrList<Event>)
1129{ 1131{
1130 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 1132 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
1131} 1133}
1132 1134
1133void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1135void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1134 const QDate &td) 1136 const QDate &td)
1135{ 1137{
1136#ifndef KORG_NOPRINTER 1138#ifndef KORG_NOPRINTER
1137 calPrinter->preview(CalPrinter::Todolist, fd, td); 1139 calPrinter->preview(CalPrinter::Todolist, fd, td);
1138#endif 1140#endif
1139} 1141}
1140 1142
1141void KOTodoView::editItem(QListViewItem *item ) 1143void KOTodoView::editItem(QListViewItem *item )
1142{ 1144{
1143 if ( item ) 1145 if ( item )
1144 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 1146 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
1145} 1147}
1146 1148
1147void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 1149void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
1148{ 1150{
1149 if ( item ) 1151 if ( item )
1150 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 1152 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
1151} 1153}
1152 1154
1153void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 1155void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
1154{ 1156{
1155 pendingSubtodo = 0; 1157 pendingSubtodo = 0;
1156 mActiveItem = (KOTodoViewItem *)item; 1158 mActiveItem = (KOTodoViewItem *)item;
1157 if (item) { 1159 if (item) {
1158 switch (column){ 1160 switch (column){
1159 case 1: 1161 case 1:
1160 mPriorityPopupMenu->popup(QCursor::pos ()); break; 1162 mPriorityPopupMenu->popup(QCursor::pos ()); break;
1161 case 2: 1163 case 2:
1162 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 1164 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
1163 case 3: 1165 case 3:
1164 moveTodo(); 1166 moveTodo();
1165 break; 1167 break;
1166 case 7: 1168 case 7:
1167 mCategoryPopupMenu->popup(QCursor::pos ()); break; 1169 mCategoryPopupMenu->popup(QCursor::pos ()); break;
1168 case 8: 1170 case 8:
1169 mCalPopupMenu->popup(QCursor::pos ()); break; 1171 mCalPopupMenu->popup(QCursor::pos ()); break;
1170 default: 1172 default:
1171 mItemPopupMenu->popup(QCursor::pos()); 1173 mItemPopupMenu->popup(QCursor::pos());
1172 } 1174 }
1173 } else mPopupMenu->popup(QCursor::pos()); 1175 } else mPopupMenu->popup(QCursor::pos());
1174} 1176}
1175void KOTodoView::newTodo() 1177void KOTodoView::newTodo()
1176{ 1178{
1177 emit newTodoSignal(); 1179 emit newTodoSignal();
1178} 1180}
1179 1181
1180void KOTodoView::newSubTodo() 1182void KOTodoView::newSubTodo()
1181{ 1183{
1182 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1184 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1183 if (mActiveItem) { 1185 if (mActiveItem) {
1184 if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { 1186 if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) {
1185 addQuickTodoPar( mActiveItem->todo()); 1187 addQuickTodoPar( mActiveItem->todo());
1186 } else 1188 } else
1187 emit newSubTodoSignal(mActiveItem->todo()); 1189 emit newSubTodoSignal(mActiveItem->todo());
1188 } 1190 }
1189} 1191}
1190void KOTodoView::unparentTodo() 1192void KOTodoView::unparentTodo()
1191{ 1193{
1192 if (mActiveItem) { 1194 if (mActiveItem) {
1193 emit unparentTodoSignal(mActiveItem->todo()); 1195 emit unparentTodoSignal(mActiveItem->todo());
1194 } 1196 }
1195} 1197}
1196 1198
1197void KOTodoView::reparentTodo() 1199void KOTodoView::reparentTodo()
1198{ 1200{
1199 if (mActiveItem) { 1201 if (mActiveItem) {
1200 topLevelWidget()->setCaption(i18n("Click on new parent item")); 1202 topLevelWidget()->setCaption(i18n("Click on new parent item"));
1201 pendingSubtodo = mActiveItem; 1203 pendingSubtodo = mActiveItem;
1202 } 1204 }
1203} 1205}
1204void KOTodoView::editTodo() 1206void KOTodoView::editTodo()
1205{ 1207{
1206 if (mActiveItem) { 1208 if (mActiveItem) {
1207 emit editTodoSignal(mActiveItem->todo()); 1209 emit editTodoSignal(mActiveItem->todo());
1208 } 1210 }
1209} 1211}
1210void KOTodoView::cloneTodo() 1212void KOTodoView::cloneTodo()
1211{ 1213{
1212 if (mActiveItem) { 1214 if (mActiveItem) {
1213 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 1215 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
1214 } 1216 }
1215} 1217}
1216void KOTodoView::cancelTodo() 1218void KOTodoView::cancelTodo()
1217{ 1219{
1218 if (mActiveItem) { 1220 if (mActiveItem) {
1219 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 1221 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
1220 } 1222 }
1221} 1223}
1222void KOTodoView::moveTodo() 1224void KOTodoView::moveTodo()
1223{ 1225{
1224 if (mActiveItem) { 1226 if (mActiveItem) {
1225 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 1227 emit moveTodoSignal((Incidence*)mActiveItem->todo());
1226 } 1228 }
1227} 1229}
1228void KOTodoView::beamTodo() 1230void KOTodoView::beamTodo()
1229{ 1231{
1230 if (mActiveItem) { 1232 if (mActiveItem) {
1231 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 1233 emit beamTodoSignal((Incidence*)mActiveItem->todo());
1232 } 1234 }
1233} 1235}
1234 1236
1235 1237
1236void KOTodoView::showTodo() 1238void KOTodoView::showTodo()
1237{ 1239{
1238 if (mActiveItem) { 1240 if (mActiveItem) {
1239 emit showTodoSignal(mActiveItem->todo()); 1241 emit showTodoSignal(mActiveItem->todo());
1240 } 1242 }
1241} 1243}
1242 1244
1243void KOTodoView::deleteTodo() 1245void KOTodoView::deleteTodo()
1244{ 1246{
1245 if (mActiveItem) { 1247 if (mActiveItem) {
1246 emit deleteTodoSignal(mActiveItem->todo()); 1248 emit deleteTodoSignal(mActiveItem->todo());
1247 } 1249 }
1248} 1250}
1249 1251
1250void KOTodoView::setNewPriority(int index) 1252void KOTodoView::setNewPriority(int index)
1251{ 1253{
1252 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1254 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1253 mActiveItem->todo()->setPriority(mPriority[index]); 1255 mActiveItem->todo()->setPriority(mPriority[index]);
1254 mActiveItem->construct(); 1256 mActiveItem->construct();
1255 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1257 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1256 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1258 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1257 } 1259 }
1258 processSelectionChange(); 1260 processSelectionChange();
1259} 1261}
1260 1262
1261void KOTodoView::setNewPercentage(int index) 1263void KOTodoView::setNewPercentage(int index)
1262{ 1264{
1263 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1265 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1264 1266
1265 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1267 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1266 mActiveItem->setOn( true ); 1268 mActiveItem->setOn( true );
1267 processSelectionChange(); 1269 processSelectionChange();
1268 return; 1270 return;
1269 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1271 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1270 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1272 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1271 if ( par && par->isOn() ) 1273 if ( par && par->isOn() )
1272 par->setOn( false ); 1274 par->setOn( false );
1273 } 1275 }
1274 if (mPercentage[index] == 100) { 1276 if (mPercentage[index] == 100) {
1275 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1277 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1276 } else { 1278 } else {
1277 mActiveItem->todo()->setCompleted(false); 1279 mActiveItem->todo()->setCompleted(false);
1278 } 1280 }
1279 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1281 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1280 mActiveItem->construct(); 1282 mActiveItem->construct();
1281 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1283 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1282 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1284 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1283 } 1285 }
1284 processSelectionChange(); 1286 processSelectionChange();
1285} 1287}
1286 1288
1287void KOTodoView::fillCategories () 1289void KOTodoView::fillCategories ()
1288{ 1290{
1289 mCategoryPopupMenu->clear(); 1291 mCategoryPopupMenu->clear();
1290 if ( ! mActiveItem ) return; 1292 if ( ! mActiveItem ) return;
1291 QStringList checkedCategories = mActiveItem->todo()->categories (); 1293 QStringList checkedCategories = mActiveItem->todo()->categories ();
1292 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1294 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1293 it != KOPrefs::instance()->mCustomCategories.end (); 1295 it != KOPrefs::instance()->mCustomCategories.end ();
1294 ++it) { 1296 ++it) {
1295 int index = mCategoryPopupMenu->insertItem (*it); 1297 int index = mCategoryPopupMenu->insertItem (*it);
1296 mCategory[index] = *it; 1298 mCategory[index] = *it;
1297 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); 1299 if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true);
1298 } 1300 }
1299} 1301}
1300void KOTodoView::fillCal () 1302void KOTodoView::fillCal ()
1301{ 1303{
1302 mCalPopupMenu->clear(); 1304 mCalPopupMenu->clear();
1303 if (!mActiveItem) return; 1305 if (!mActiveItem) return;
1304 bool readO = mActiveItem->todo()->isReadOnly(); 1306 bool readO = mActiveItem->todo()->isReadOnly();
1305 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); 1307 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
1306 while ( kkf ) { 1308 while ( kkf ) {
1307 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); 1309 int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber);
1308 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) 1310 if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO )
1309 mCalPopupMenu->setItemEnabled( index, false ); 1311 mCalPopupMenu->setItemEnabled( index, false );
1310 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); 1312 mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID());
1311 kkf = KOPrefs::instance()->mCalendars.next(); 1313 kkf = KOPrefs::instance()->mCalendars.next();
1312 } 1314 }
1313} 1315}
1314void KOTodoView::changedCal (int index ) 1316void KOTodoView::changedCal (int index )
1315{ 1317{
1316 if (!mActiveItem) return; 1318 if (!mActiveItem) return;
1317 mActiveItem->todo()->setCalID( index ); 1319 mActiveItem->todo()->setCalID( index );
1318 mActiveItem->construct(); 1320 mActiveItem->construct();
1319} 1321}
1320void KOTodoView::changedCategories(int index) 1322void KOTodoView::changedCategories(int index)
1321{ 1323{
1322 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1324 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1323 QStringList categories = mActiveItem->todo()->categories (); 1325 QStringList categories = mActiveItem->todo()->categories ();
1324 QString colcat = categories.first(); 1326 QString colcat = categories.first();
1325 if (categories.find (mCategory[index]) != categories.end ()) 1327 if (categories.find (mCategory[index]) != categories.end ())
1326 categories.remove (mCategory[index]); 1328 categories.remove (mCategory[index]);
1327 else 1329 else
1328 categories.insert (categories.end(), mCategory[index]); 1330 categories.insert (categories.end(), mCategory[index]);
1329 categories.sort (); 1331 categories.sort ();
1330 if ( !colcat.isEmpty() ) { 1332 if ( !colcat.isEmpty() ) {
1331 if ( categories.find ( colcat ) != categories.end () ) { 1333 if ( categories.find ( colcat ) != categories.end () ) {
1332 categories.remove( colcat ); 1334 categories.remove( colcat );
1333 categories.prepend( colcat ); 1335 categories.prepend( colcat );
1334 } 1336 }
1335 } 1337 }
1336 mActiveItem->todo()->setCategories (categories); 1338 mActiveItem->todo()->setCategories (categories);
1337 mActiveItem->construct(); 1339 mActiveItem->construct();
1338 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1340 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1339 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1341 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1340 } 1342 }
1341} 1343}
1342void KOTodoView::itemDoubleClicked(QListViewItem *item) 1344void KOTodoView::itemDoubleClicked(QListViewItem *item)
1343{ 1345{
1344 if ( pendingSubtodo != 0 ) { 1346 if ( pendingSubtodo != 0 ) {
1345 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1347 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1346 } 1348 }
1347 pendingSubtodo = 0; 1349 pendingSubtodo = 0;
1348 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1350 //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1349 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); 1351 int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() );
1350 //qDebug("ROW %d ", row); 1352 //qDebug("ROW %d ", row);
1351 if (!item) { 1353 if (!item) {
1352 newTodo(); 1354 newTodo();
1353 return; 1355 return;
1354 } else { 1356 } else {
1355 if ( row == 1 ) { 1357 if ( row == 1 ) {
1356 mActiveItem = (KOTodoViewItem *) item; 1358 mActiveItem = (KOTodoViewItem *) item;
1357 newSubTodo(); 1359 newSubTodo();
1358 return; 1360 return;
1359 } 1361 }
1360 if ( row == 5 || row == 6 || row == 2) { 1362 if ( row == 5 || row == 6 || row == 2) {
1361 mActiveItem = (KOTodoViewItem *) item; 1363 mActiveItem = (KOTodoViewItem *) item;
1362 Todo * t = mActiveItem->todo(); 1364 Todo * t = mActiveItem->todo();
1363 if ( t->isRunning() ) { 1365 if ( t->isRunning() ) {
1364 if ( t->runTime() < 15) { 1366 if ( t->runTime() < 15) {
1365 t->stopRunning(); 1367 t->stopRunning();
1366 mActiveItem->construct(); 1368 mActiveItem->construct();
1367 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); 1369 topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!"));
1368 return; 1370 return;
1369 } 1371 }
1370 else 1372 else
1371 toggleRunningItem(); 1373 toggleRunningItem();
1372 return; 1374 return;
1373 } else { 1375 } else {
1374 t->setRunning( true ); 1376 t->setRunning( true );
1375 mActiveItem->construct(); 1377 mActiveItem->construct();
1376 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); 1378 topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!"));
1377 return; 1379 return;
1378 } 1380 }
1379 } 1381 }
1380 } 1382 }
1381 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1383 if ( KOPrefs::instance()->mEditOnDoubleClick )
1382 editItem( item ); 1384 editItem( item );
1383 else 1385 else
1384 showItem( item , QPoint(), 0 ); 1386 showItem( item , QPoint(), 0 );
1385} 1387}
1386void KOTodoView::toggleRunningItem() 1388void KOTodoView::toggleRunningItem()
1387{ 1389{
1388 // qDebug("KOTodoView::toggleRunning() "); 1390 // qDebug("KOTodoView::toggleRunning() ");
1389 if ( ! mActiveItem ) 1391 if ( ! mActiveItem )
1390 return; 1392 return;
1391 Todo * t = mActiveItem->todo(); 1393 Todo * t = mActiveItem->todo();
1392 if ( t->isRunning() ) { 1394 if ( t->isRunning() ) {
1393 KOStopTodoPrefs tp ( t, this ); 1395 KOStopTodoPrefs tp ( t, this );
1394 if (QApplication::desktop()->width() <= 800 ){ 1396 if (QApplication::desktop()->width() <= 800 ){
1395 int wid = tp.width(); 1397 int wid = tp.width();
1396 int hei = tp.height(); 1398 int hei = tp.height();
1397 int xx = (QApplication::desktop()->width()-wid)/2; 1399 int xx = (QApplication::desktop()->width()-wid)/2;
1398 int yy = (QApplication::desktop()->height()-hei)/2; 1400 int yy = (QApplication::desktop()->height()-hei)/2;
1399 tp.setGeometry( xx,yy,wid,hei ); 1401 tp.setGeometry( xx,yy,wid,hei );
1400 } 1402 }
1401 tp.exec(); 1403 tp.exec();
1402 updateTodo ( t, KOGlobals::EVENTEDITED ); 1404 updateTodo ( t, KOGlobals::EVENTEDITED );
1403 } else { 1405 } else {
1404 KOStartTodoPrefs tp ( t->summary(), this ); 1406 KOStartTodoPrefs tp ( t->summary(), this );
1405 if (QApplication::desktop()->width() <= 800 ){ 1407 if (QApplication::desktop()->width() <= 800 ){
1406 int wid = tp.width(); 1408 int wid = tp.width();
1407 int hei = tp.height(); 1409 int hei = tp.height();
1408 int xx = (QApplication::desktop()->width()-wid)/2; 1410 int xx = (QApplication::desktop()->width()-wid)/2;
1409 int yy = (QApplication::desktop()->height()-hei)/2; 1411 int yy = (QApplication::desktop()->height()-hei)/2;
1410 tp.setGeometry( xx,yy,wid,hei ); 1412 tp.setGeometry( xx,yy,wid,hei );
1411 } 1413 }
1412 if ( !tp.exec() ) return; 1414 if ( !tp.exec() ) return;
1413 if ( tp.stopAll() ) { 1415 if ( tp.stopAll() ) {
1414 mCalendar->stopAllTodos(); 1416 mCalendar->stopAllTodos();
1415 t->setRunning( true ); 1417 t->setRunning( true );
1416 updateView(); 1418 updateView();
1417 } else { 1419 } else {
1418 t->setRunning( true ); 1420 t->setRunning( true );
1419 updateTodo ( t, KOGlobals::EVENTEDITED ); 1421 updateTodo ( t, KOGlobals::EVENTEDITED );
1420 } 1422 }
1421 } 1423 }
1422} 1424}
1423 1425
1424void KOTodoView::itemClicked(QListViewItem *item) 1426void KOTodoView::itemClicked(QListViewItem *item)
1425{ 1427{
1426 //qDebug("KOTodoView::itemClicked %d", item); 1428 //qDebug("KOTodoView::itemClicked %d", item);
1427 if (!item) { 1429 if (!item) {
1428 if ( pendingSubtodo != 0 ) { 1430 if ( pendingSubtodo != 0 ) {
1429 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1431 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1430 } 1432 }
1431 pendingSubtodo = 0; 1433 pendingSubtodo = 0;
1432 return; 1434 return;
1433 } 1435 }
1434 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1436 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1435 if ( pendingSubtodo != 0 ) { 1437 if ( pendingSubtodo != 0 ) {
1436 bool allowReparent = true; 1438 bool allowReparent = true;
1437 QListViewItem *par = item; 1439 QListViewItem *par = item;
1438 while ( par ) { 1440 while ( par ) {
1439 if ( par == pendingSubtodo ) { 1441 if ( par == pendingSubtodo ) {
1440 allowReparent = false; 1442 allowReparent = false;
1441 break; 1443 break;
1442 } 1444 }
1443 par = par->parent(); 1445 par = par->parent();
1444 } 1446 }
1445 if ( !allowReparent ) { 1447 if ( !allowReparent ) {
1446 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1448 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1447 pendingSubtodo = 0; 1449 pendingSubtodo = 0;
1448 } else { 1450 } else {
1449 Todo* newParent = todoItem->todo(); 1451 Todo* newParent = todoItem->todo();
1450 Todo* newSub = pendingSubtodo->todo(); 1452 Todo* newSub = pendingSubtodo->todo();
1451 pendingSubtodo = 0; 1453 pendingSubtodo = 0;
1452 emit reparentTodoSignal( newParent,newSub ); 1454 emit reparentTodoSignal( newParent,newSub );
1453 return; 1455 return;
1454 } 1456 }
1455 } 1457 }
1456 1458
1457} 1459}
1458 1460
1459void KOTodoView::setDocumentId( const QString &id ) 1461void KOTodoView::setDocumentId( const QString &id )
1460{ 1462{
1461 1463
1462 mDocPrefs->setDoc( id ); 1464 mDocPrefs->setDoc( id );
1463} 1465}
1464 1466
1465void KOTodoView::itemStateChanged( QListViewItem *item ) 1467void KOTodoView::itemStateChanged( QListViewItem *item )
1466{ 1468{
1467 if (!item) return; 1469 if (!item) return;
1468 1470
1469 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1471 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1470 1472
1471// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1473// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1472 1474
1473 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1475 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1474} 1476}
1475 1477
1476void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1478void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1477{ 1479{
1478 mTodoListView->saveLayout(config,group); 1480 mTodoListView->saveLayout(config,group);
1479} 1481}
1480 1482
1481void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1483void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1482{ 1484{
1483 mTodoListView->restoreLayout(config,group); 1485 mTodoListView->restoreLayout(config,group);
1484} 1486}
1485 1487
1486void KOTodoView::processSelectionChange() 1488void KOTodoView::processSelectionChange()
1487{ 1489{
1488// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1490// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1489 1491
1490 KOTodoViewItem *item = 1492 KOTodoViewItem *item =
1491 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1493 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1492 1494
1493 if ( !item ) { 1495 if ( !item ) {
1494 emit incidenceSelected( 0 ); 1496 emit incidenceSelected( 0 );
1495 mNewSubBut->setEnabled( false ); 1497 mNewSubBut->setEnabled( false );
1496 } else { 1498 } else {
1497 emit incidenceSelected( item->todo() ); 1499 emit incidenceSelected( item->todo() );
1498 mNewSubBut->setEnabled( true ); 1500 mNewSubBut->setEnabled( true );
1499 } 1501 }
1500} 1502}
1501 1503
1502void KOTodoView::modified(bool b) 1504void KOTodoView::modified(bool b)
1503{ 1505{
1504 emit isModified(b); 1506 emit isModified(b);
1505} 1507}
1506void KOTodoView::setTodoModified( Todo* todo ) 1508void KOTodoView::setTodoModified( Todo* todo )
1507{ 1509{
1508 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1510 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1509} 1511}
1510void KOTodoView::clearSelection() 1512void KOTodoView::clearSelection()
1511{ 1513{
1512 mTodoListView->selectAll( false ); 1514 mTodoListView->selectAll( false );
1513} 1515}
1514void KOTodoView::setAllOpen() 1516void KOTodoView::setAllOpen()
1515{ 1517{
1516 if ( isFlatDisplay ) { 1518 if ( isFlatDisplay ) {
1517 isFlatDisplay = false; 1519 isFlatDisplay = false;
1518 mPopupMenu->setItemChecked( 8,false ); 1520 mPopupMenu->setItemChecked( 8,false );
1519 updateView(); 1521 updateView();
1520 } else { 1522 } else {
1521 storeCurrentItem(); 1523 storeCurrentItem();
1522 } 1524 }
1523 setOpen(mTodoListView->firstChild(), true); 1525 setOpen(mTodoListView->firstChild(), true);
1524 resetCurrentItem(); 1526 resetCurrentItem();
1525} 1527}
1526void KOTodoView::setAllClose() 1528void KOTodoView::setAllClose()
1527{ 1529{
1528 if ( isFlatDisplay ) { 1530 if ( isFlatDisplay ) {
1529 isFlatDisplay = false; 1531 isFlatDisplay = false;
1530 mPopupMenu->setItemChecked( 8,false ); 1532 mPopupMenu->setItemChecked( 8,false );
1531 updateView(); 1533 updateView();
1532 } else { 1534 } else {
1533 storeCurrentItem(); 1535 storeCurrentItem();
1534 } 1536 }
1535 setOpen(mTodoListView->firstChild(), false); 1537 setOpen(mTodoListView->firstChild(), false);
1536 resetCurrentItem(); 1538 resetCurrentItem();
1537} 1539}
1538void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1540void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1539{ 1541{
1540 1542
1541 while ( item ) { 1543 while ( item ) {
1542 setOpen( item->firstChild(), setOpenI ); 1544 setOpen( item->firstChild(), setOpenI );
1543 item->setOpen( setOpenI ); 1545 item->setOpen( setOpenI );
1544 item = item->nextSibling(); 1546 item = item->nextSibling();
1545 } 1547 }
1546} 1548}
1547 1549
1548void KOTodoView::displayAllFlat() 1550void KOTodoView::displayAllFlat()
1549{ 1551{
1550 1552
1551 mActiveItem = 0; 1553 mActiveItem = 0;
1552 pendingSubtodo = 0; 1554 pendingSubtodo = 0;
1553 if ( mBlockUpdate ) { 1555 if ( mBlockUpdate ) {
1554 return; 1556 return;
1555 } 1557 }
1556 clearList (); 1558 clearList ();
1557 mPopupMenu->setItemChecked( 8,true ); 1559 mPopupMenu->setItemChecked( 8,true );
1558 isFlatDisplay = true; 1560 isFlatDisplay = true;
1559 QPtrList<Todo> todoList = calendar()->todos(); 1561 QPtrList<Todo> todoList = calendar()->todos();
1560 Todo *todo; 1562 Todo *todo;
1561 for(todo = todoList.first(); todo; todo = todoList.next()) { 1563 for(todo = todoList.first(); todo; todo = todoList.next()) {
1562 if ( checkTodo( todo ) ) { 1564 if ( checkTodo( todo ) ) {
1563 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1565 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1564 mTodoMap.insert(todo,todoItem); 1566 mTodoMap.insert(todo,todoItem);
1565 } 1567 }
1566 } 1568 }
1567 resetCurrentItem(); 1569 resetCurrentItem();
1568} 1570}
1569 1571
1570void KOTodoView::setAllFlat() 1572void KOTodoView::setAllFlat()
1571{ 1573{
1572 if ( isFlatDisplay ) { 1574 if ( isFlatDisplay ) {
1573 isFlatDisplay = false; 1575 isFlatDisplay = false;
1574 mPopupMenu->setItemChecked( 8,false ); 1576 mPopupMenu->setItemChecked( 8,false );
1575 updateView(); 1577 updateView();
1576 return; 1578 return;
1577 } 1579 }
1578 displayAllFlat(); 1580 displayAllFlat();
1579} 1581}
1580 1582
1581void KOTodoView::purgeCompleted() 1583void KOTodoView::purgeCompleted()
1582{ 1584{
1583 emit purgeCompletedSignal(); 1585 emit purgeCompletedSignal();
1584 1586
1585} 1587}
1586void KOTodoView::toggleQuickTodo() 1588void KOTodoView::toggleQuickTodo()
1587{ 1589{
1588 if ( mQuickBar->isVisible() ) { 1590 if ( mQuickBar->isVisible() ) {
1589 mQuickBar->hide(); 1591 mQuickBar->hide();
1590 KOPrefs::instance()->mEnableQuickTodo = false; 1592 KOPrefs::instance()->mEnableQuickTodo = false;
1591 } 1593 }
1592 else { 1594 else {
1593 mQuickBar->show(); 1595 mQuickBar->show();
1594 KOPrefs::instance()->mEnableQuickTodo = true; 1596 KOPrefs::instance()->mEnableQuickTodo = true;
1595 } 1597 }
1596 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1598 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1597 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1599 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1598} 1600}
1599 1601
1600void KOTodoView::toggleRunning() 1602void KOTodoView::toggleRunning()
1601{ 1603{
1602 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1604 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1603 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1605 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1604 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1606 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1605 updateView(); 1607 updateView();
1606 if ( KOPrefs::instance()->mHideNonStartedTodos ) 1608 if ( KOPrefs::instance()->mHideNonStartedTodos )
1607 topLevelWidget()->setCaption(i18n("Hide not Running")); 1609 topLevelWidget()->setCaption(i18n("Hide not Running"));
1608 else 1610 else
1609 topLevelWidget()->setCaption(i18n("Show not Running")); 1611 topLevelWidget()->setCaption(i18n("Show not Running"));
1610} 1612}
1611 1613
1612void KOTodoView::toggleCompleted() 1614void KOTodoView::toggleCompleted()
1613{ 1615{
1614 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1616 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1615 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1617 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1616 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1618 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1617 updateView(); 1619 updateView();
1618 if ( KOPrefs::instance()->mShowCompletedTodo ) 1620 if ( KOPrefs::instance()->mShowCompletedTodo )
1619 topLevelWidget()->setCaption(i18n("Show Completed")); 1621 topLevelWidget()->setCaption(i18n("Show Completed"));
1620 else 1622 else
1621 topLevelWidget()->setCaption(i18n("Hide Completed")); 1623 topLevelWidget()->setCaption(i18n("Hide Completed"));
1622} 1624}
1623 1625
1624void KOTodoView::addQuickTodo() 1626void KOTodoView::addQuickTodo()
1625{ 1627{
1626 addQuickTodoPar( 0 ); 1628 addQuickTodoPar( 0 );
1627} 1629}
1628void KOTodoView::addQuickTodoPar( Todo * parentTodo) 1630void KOTodoView::addQuickTodoPar( Todo * parentTodo)
1629{ 1631{
1630 Todo *todo = new Todo(); 1632 Todo *todo = new Todo();
1631 todo->setSummary(mQuickAdd->text()); 1633 todo->setSummary(mQuickAdd->text());
1632 todo->setOrganizer(KOPrefs::instance()->email()); 1634 todo->setOrganizer(KOPrefs::instance()->email());
1633 if ( parentTodo ) { 1635 if ( parentTodo ) {
1634 todo->setRelatedTo(parentTodo); 1636 todo->setRelatedTo(parentTodo);
1635 1637
1636 todo->setCategories (parentTodo->categoriesStr ()); 1638 todo->setCategories (parentTodo->categoriesStr ());
1637 todo->setSecrecy (parentTodo->secrecy ()); 1639 todo->setSecrecy (parentTodo->secrecy ());
1638 if ( parentTodo->priority() < 3 ) 1640 if ( parentTodo->priority() < 3 )
1639 todo->setPriority( parentTodo->priority() ); 1641 todo->setPriority( parentTodo->priority() );
1640 todo->setCalID( parentTodo->calID() ); 1642 todo->setCalID( parentTodo->calID() );
1641 } else { 1643 } else {
1642 CalFilter * cf = mCalendar->filter(); 1644 CalFilter * cf = mCalendar->filter();
1643 if ( cf ) { 1645 if ( cf ) {
1644 if ( cf->isEnabled()&& cf->showCategories()) { 1646 if ( cf->isEnabled()&& cf->showCategories()) {
1645 todo->setCategories(cf->categoryList()); 1647 todo->setCategories(cf->categoryList());
1646 } 1648 }
1647 if ( cf->isEnabled() ) 1649 if ( cf->isEnabled() )
1648 todo->setSecrecy( cf->getSecrecy()); 1650 todo->setSecrecy( cf->getSecrecy());
1649 } 1651 }
1650 } 1652 }
1651 mCalendar->addTodo(todo); 1653 mCalendar->addTodo(todo);
1652 mQuickAdd->setText(""); 1654 mQuickAdd->setText("");
1653 todoModified (todo, KOGlobals::EVENTADDED ); 1655 todoModified (todo, KOGlobals::EVENTADDED );
1654 updateView(); 1656 updateView();
1655 1657
1656} 1658}
1657void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1659void KOTodoView::keyPressEvent ( QKeyEvent * e )
1658{ 1660{
1659 // e->ignore(); 1661 // e->ignore();
1660 //return; 1662 //return;
1661 if ( !isVisible() ) { 1663 if ( !isVisible() ) {
1662 e->ignore(); 1664 e->ignore();
1663 return; 1665 return;
1664 } 1666 }
1665 switch ( e->key() ) { 1667 switch ( e->key() ) {
1666 case Qt::Key_Down: 1668 case Qt::Key_Down:
1667 case Qt::Key_Up: 1669 case Qt::Key_Up:
1668 // KOrg::BaseView::keyPressEvent ( e ); 1670 // KOrg::BaseView::keyPressEvent ( e );
1669 e->ignore(); 1671 e->ignore();
1670 break; 1672 break;
1671 1673
1672 case Qt::Key_Q: 1674 case Qt::Key_Q:
1673 1675
1674 1676
1675 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { 1677 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) {
1676 e->ignore(); 1678 e->ignore();
1677 break; 1679 break;
1678 } 1680 }
1679 toggleQuickTodo(); 1681 toggleQuickTodo();
1680 break; 1682 break;
1681 case Qt::Key_U: 1683 case Qt::Key_U:
1682 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1684 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1683 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1685 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1684 unparentTodo(); 1686 unparentTodo();
1685 e->accept(); 1687 e->accept();
1686 } else 1688 } else
1687 e->ignore(); 1689 e->ignore();
1688 break; 1690 break;
1689 case Qt::Key_S: 1691 case Qt::Key_S:
1690 if ( e->state() == Qt::ControlButton ) { 1692 if ( e->state() == Qt::ControlButton ) {
1691 e->ignore(); 1693 e->ignore();
1692 break; 1694 break;
1693 } 1695 }
1694 if ( e->state() == Qt::ShiftButton ) { 1696 if ( e->state() == Qt::ShiftButton ) {
1695 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1697 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1696 reparentTodo(); 1698 reparentTodo();
1697 e->accept(); 1699 e->accept();
1698 } else 1700 } else
1699 e->ignore(); 1701 e->ignore();
1700 break; 1702 break;
1701 case Qt::Key_P: 1703 case Qt::Key_P:
1702 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1704 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1703 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1705 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1704 if ( pendingSubtodo ) 1706 if ( pendingSubtodo )
1705 itemClicked(mActiveItem); 1707 itemClicked(mActiveItem);
1706 e->accept(); 1708 e->accept();
1707 } else 1709 } else
1708 e->ignore(); 1710 e->ignore();
1709 break; 1711 break;
1710 case Qt::Key_Escape: 1712 case Qt::Key_Escape:
1711 if ( pendingSubtodo ) { 1713 if ( pendingSubtodo ) {
1712 itemClicked(0); 1714 itemClicked(0);
1713 e->accept(); 1715 e->accept();
1714 } else 1716 } else
1715 e->ignore(); 1717 e->ignore();
1716 break; 1718 break;
1717 default: 1719 default:
1718 e->ignore(); 1720 e->ignore();
1719 } 1721 }
1720 1722
1721 if ( true ) { 1723 if ( true ) {
1722 if ( e->key() == Qt::Key_I ) { 1724 if ( e->key() == Qt::Key_I ) {
1723 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1725 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1724 if ( cn ) { 1726 if ( cn ) {
1725 mActiveItem = cn; 1727 mActiveItem = cn;
1726 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1728 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1727 if ( ci ){ 1729 if ( ci ){
1728 showTodo(); 1730 showTodo();
1729 cn = (KOTodoViewItem*)cn->itemBelow(); 1731 cn = (KOTodoViewItem*)cn->itemBelow();
1730 if ( cn ) { 1732 if ( cn ) {
1731 mTodoListView->setCurrentItem ( cn ); 1733 mTodoListView->setCurrentItem ( cn );
1732 mTodoListView->ensureItemVisible ( cn ); 1734 mTodoListView->ensureItemVisible ( cn );
1733 } 1735 }
1734 1736
1735 } 1737 }
1736 } 1738 }
1737 e->accept(); 1739 e->accept();
1738 } 1740 }
1739 } 1741 }
1740} 1742}
1741 1743
1742void KOTodoView::updateTodo( Todo * t, int type ) 1744void KOTodoView::updateTodo( Todo * t, int type )
1743{ 1745{
1744 if ( mBlockUpdate ) 1746 if ( mBlockUpdate )
1745 return; 1747 return;
1746 1748
1747 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1749 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1748 itemIterator = mTodoMap.find(t); 1750 itemIterator = mTodoMap.find(t);
1749 if (itemIterator != mTodoMap.end()) { 1751 if (itemIterator != mTodoMap.end()) {
1750 (*itemIterator)->construct(); 1752 (*itemIterator)->construct();
1751 } else { 1753 } else {
1752 if ( type == KOGlobals::EVENTADDED ) { 1754 if ( type == KOGlobals::EVENTADDED ) {
1753 insertTodoItem( t ); 1755 insertTodoItem( t );
1754 } 1756 }
1755 } 1757 }
1756 1758
1757} 1759}
1758 1760
1759void KOTodoView::todoModified(Todo * t , int p ) 1761void KOTodoView::todoModified(Todo * t , int p )
1760{ 1762{
1761 mBlockUpdate = true; 1763 mBlockUpdate = true;
1762 emit todoModifiedSignal ( t, p ); 1764 emit todoModifiedSignal ( t, p );
1763 mBlockUpdate = false; 1765 mBlockUpdate = false;
1764} 1766}
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index ecd0ad9..161ecb0 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -1,309 +1,310 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOTODOVIEW_H 23#ifndef KOTODOVIEW_H
24#define KOTODOVIEW_H 24#define KOTODOVIEW_H
25 25
26#include <qfont.h> 26#include <qfont.h>
27#include <qfontmetrics.h> 27#include <qfontmetrics.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30#include <qstrlist.h> 30#include <qstrlist.h>
31#include <qlistbox.h> 31#include <qlistbox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qdialog.h> 35#include <qdialog.h>
36#include <qlabel.h> 36#include <qlabel.h>
37#include <qlistview.h> 37#include <qlistview.h>
38#include <klistview.h> 38#include <klistview.h>
39 39
40#include <libkcal/calendar.h> 40#include <libkcal/calendar.h>
41#include <libkcal/todo.h> 41#include <libkcal/todo.h>
42 42
43#include <korganizer/baseview.h> 43#include <korganizer/baseview.h>
44 44
45#include "kotodoviewitem.h" 45#include "kotodoviewitem.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "koglobals.h" 47#include "koglobals.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49 49
50class QDragEnterEvent; 50class QDragEnterEvent;
51class QDragMoveEvent; 51class QDragMoveEvent;
52class QDragLeaveEvent; 52class QDragLeaveEvent;
53class QDropEvent; 53class QDropEvent;
54class KOTodoViewWhatsThis; 54class KOTodoViewWhatsThis;
55class KDateEdit; 55class KDateEdit;
56class KOTimeEdit; 56class KOTimeEdit;
57 57
58class DocPrefs; 58class DocPrefs;
59 59
60 60
61class KOStopTodoPrefs : public QDialog 61class KOStopTodoPrefs : public QDialog
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64 public: 64 public:
65 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ; 65 KOStopTodoPrefs( Todo* todo, QWidget *parent=0, const char *name=0 ) ;
66 66
67 67
68private slots: 68private slots:
69 void doNotSave(); 69 void doNotSave();
70 void accept(); 70 void accept();
71private: 71private:
72 Todo* mTodo; 72 Todo* mTodo;
73 QLineEdit* mComment; 73 QLineEdit* mComment;
74 QDateTime mStop; 74 QDateTime mStop;
75 KDateEdit *sde, *ede; 75 KDateEdit *sde, *ede;
76 KOTimeEdit *ste, *ete; 76 KOTimeEdit *ste, *ete;
77 77
78}; 78};
79 79
80class KOStartTodoPrefs : public QDialog 80class KOStartTodoPrefs : public QDialog
81{ 81{
82 Q_OBJECT 82 Q_OBJECT
83 public: 83 public:
84 KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ; 84 KOStartTodoPrefs( QString sum, QWidget *parent=0, const char *name=0 ) ;
85 85
86 bool stopAll() { return mStopAll; } 86 bool stopAll() { return mStopAll; }
87private slots: 87private slots:
88 void doStop(); 88 void doStop();
89private: 89private:
90 bool mStopAll; 90 bool mStopAll;
91 91
92}; 92};
93 93
94class KOTodoListView : public KListView 94class KOTodoListView : public KListView
95{ 95{
96 Q_OBJECT 96 Q_OBJECT
97 public: 97 public:
98 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 98 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
99 virtual ~KOTodoListView() {} 99 virtual ~KOTodoListView() {}
100 100
101 signals: 101 signals:
102 void paintNeeded(); 102 void paintNeeded();
103 void todoDropped(Todo *, int); 103 void todoDropped(Todo *, int);
104 void double_Clicked(QListViewItem *item); 104 void double_Clicked(QListViewItem *item);
105 void reparentTodoSignal( Todo *,Todo * ); 105 void reparentTodoSignal( Todo *,Todo * );
106 void unparentTodoSignal(Todo *); 106 void unparentTodoSignal(Todo *);
107 void deleteTodo( Todo * ); 107 void deleteTodo( Todo * );
108 protected: 108 protected:
109 void wheelEvent (QWheelEvent *e); 109 void wheelEvent (QWheelEvent *e);
110 void contentsDragEnterEvent(QDragEnterEvent *); 110 void contentsDragEnterEvent(QDragEnterEvent *);
111 void contentsDragMoveEvent(QDragMoveEvent *); 111 void contentsDragMoveEvent(QDragMoveEvent *);
112 void contentsDragLeaveEvent(QDragLeaveEvent *); 112 void contentsDragLeaveEvent(QDragLeaveEvent *);
113 void contentsDropEvent(QDropEvent *); 113 void contentsDropEvent(QDropEvent *);
114 114
115 void contentsMousePressEvent(QMouseEvent *); 115 void contentsMousePressEvent(QMouseEvent *);
116 void contentsMouseMoveEvent(QMouseEvent *); 116 void contentsMouseMoveEvent(QMouseEvent *);
117 void contentsMouseReleaseEvent(QMouseEvent *); 117 void contentsMouseReleaseEvent(QMouseEvent *);
118 void contentsMouseDoubleClickEvent(QMouseEvent *); 118 void contentsMouseDoubleClickEvent(QMouseEvent *);
119 119
120 private: 120 private:
121 void paintEvent(QPaintEvent * pevent); 121 void paintEvent(QPaintEvent * pevent);
122 bool internalDrop; 122 bool internalDrop;
123 QString mName; 123 QString mName;
124 Calendar *mCalendar; 124 Calendar *mCalendar;
125 QPoint mPressPos; 125 QPoint mPressPos;
126 bool mMousePressed; 126 bool mMousePressed;
127 QListViewItem *mOldCurrent; 127 QListViewItem *mOldCurrent;
128 bool mFlagKeyPressed; 128 bool mFlagKeyPressed;
129 void keyPressEvent ( QKeyEvent * ) ; 129 void keyPressEvent ( QKeyEvent * ) ;
130 void keyReleaseEvent ( QKeyEvent * ) ; 130 void keyReleaseEvent ( QKeyEvent * ) ;
131}; 131};
132 132
133 133
134/** 134/**
135 This is the line-edit on top of the todoview for fast addition of new todos 135 This is the line-edit on top of the todoview for fast addition of new todos
136*/ 136*/
137class KOQuickTodo : public QLineEdit 137class KOQuickTodo : public QLineEdit
138{ 138{
139 public: 139 public:
140 KOQuickTodo(QWidget *parent=0); 140 KOQuickTodo(QWidget *parent=0);
141 protected: 141 protected:
142 void focusInEvent(QFocusEvent *ev); 142 void focusInEvent(QFocusEvent *ev);
143 void focusOutEvent(QFocusEvent *ev); 143 void focusOutEvent(QFocusEvent *ev);
144}; 144};
145 145
146 146
147/** 147/**
148 This class provides a multi-column list view of todo events. 148 This class provides a multi-column list view of todo events.
149 149
150 @short multi-column list view of todo events. 150 @short multi-column list view of todo events.
151 @author Cornelius Schumacher <schumacher@kde.org> 151 @author Cornelius Schumacher <schumacher@kde.org>
152*/ 152*/
153class KOTodoView : public KOrg::BaseView 153class KOTodoView : public KOrg::BaseView
154{ 154{
155 Q_OBJECT 155 Q_OBJECT
156 public: 156 public:
157 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); 157 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 );
158 ~KOTodoView(); 158 ~KOTodoView();
159 159
160 QPtrList<Incidence> selectedIncidences(); 160 QPtrList<Incidence> selectedIncidences();
161 QPtrList<Todo> selectedTodos(); 161 QPtrList<Todo> selectedTodos();
162 162
163 DateList selectedDates() 163 DateList selectedDates()
164 {DateList q; 164 {DateList q;
165 return q;} 165 return q;}
166 166
167 /** Return number of shown dates. TodoView does not show dates, */ 167 /** Return number of shown dates. TodoView does not show dates, */
168 int currentDateCount() { return 0; } 168 int currentDateCount() { return 0; }
169 169
170 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); 170 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td);
171 171
172 void setDocumentId( const QString & ); 172 void setDocumentId( const QString & );
173 173
174 void saveLayout(KConfig *config, const QString &group) const; 174 void saveLayout(KConfig *config, const QString &group) const;
175 void restoreLayout(KConfig *config, const QString &group); 175 void restoreLayout(KConfig *config, const QString &group);
176 void setNavigator( DateNavigator* nav ) {mNavigator = nav;} 176 void setNavigator( DateNavigator* nav ) {mNavigator = nav;}
177 QString getWhatsThisText(QPoint p); 177 QString getWhatsThisText(QPoint p);
178 void clearList( bool saveCurrentItem = true ); 178 void clearList( bool saveCurrentItem = true );
179 179
180 public slots: 180 public slots:
181 void updateView(); 181 void updateView();
182 void updateConfig(); 182 void updateConfig();
183 183
184 void changeEventDisplay(Event *, int); 184 void changeEventDisplay(Event *, int);
185 185
186 void showDates(const QDate &start, const QDate &end); 186 void showDates(const QDate &start, const QDate &end);
187 void showEvents(QPtrList<Event> eventList); 187 void showEvents(QPtrList<Event> eventList);
188 188
189 void clearSelection(); 189 void clearSelection();
190 void jumpToDate (); 190 void jumpToDate ();
191 191
192 void editItem(QListViewItem *item); 192 void editItem(QListViewItem *item);
193 void showItem(QListViewItem *item,const QPoint &,int); 193 void showItem(QListViewItem *item,const QPoint &,int);
194 void popupMenu(QListViewItem *item,const QPoint &,int); 194 void popupMenu(QListViewItem *item,const QPoint &,int);
195 void newTodo(); 195 void newTodo();
196 void newSubTodo(); 196 void newSubTodo();
197 void unparentTodo(); 197 void unparentTodo();
198 void reparentTodo(); 198 void reparentTodo();
199 void showTodo(); 199 void showTodo();
200 void editTodo(); 200 void editTodo();
201 void cloneTodo(); 201 void cloneTodo();
202 void cancelTodo(); 202 void cancelTodo();
203 void moveTodo(); 203 void moveTodo();
204 void beamTodo(); 204 void beamTodo();
205 void deleteTodo(); 205 void deleteTodo();
206 206
207 void setNewPriority(int); 207 void setNewPriority(int);
208 void setNewPercentage(int); 208 void setNewPercentage(int);
209 void changedCategories(int); 209 void changedCategories(int);
210 210
211 void setAllOpen(); 211 void setAllOpen();
212 void setAllClose(); 212 void setAllClose();
213 void setAllFlat(); 213 void setAllFlat();
214 void displayAllFlat(); 214 void displayAllFlat();
215 215
216 void purgeCompleted(); 216 void purgeCompleted();
217 void toggleCompleted(); 217 void toggleCompleted();
218 void toggleRunning(); 218 void toggleRunning();
219 void toggleQuickTodo(); 219 void toggleQuickTodo();
220 void updateTodo( Todo *, int ); 220 void updateTodo( Todo *, int );
221 221
222 void itemClicked(QListViewItem *); 222 void itemClicked(QListViewItem *);
223 void itemStateChanged(QListViewItem *); 223 void itemStateChanged(QListViewItem *);
224 void modified(bool); 224 void modified(bool);
225 void itemDoubleClicked(QListViewItem *item); 225 void itemDoubleClicked(QListViewItem *item);
226 void resetFocusToList(); 226 void resetFocusToList();
227 void fillCategories (); 227 void fillCategories ();
228 void fillCal (); 228 void fillCal ();
229 void changedCal (int); 229 void changedCal (int);
230 230
231 signals: 231 signals:
232 void newTodoSignal(); 232 void newTodoSignal();
233 void newSubTodoSignal(Todo *); 233 void newSubTodoSignal(Todo *);
234 void unparentTodoSignal(Todo *); 234 void unparentTodoSignal(Todo *);
235 void reparentTodoSignal( Todo *,Todo * ); 235 void reparentTodoSignal( Todo *,Todo * );
236 void showTodoSignal(Todo *); 236 void showTodoSignal(Todo *);
237 237
238 void editTodoSignal(Todo *); 238 void editTodoSignal(Todo *);
239 void deleteTodoSignal(Todo *); 239 void deleteTodoSignal(Todo *);
240 void todoModifiedSignal (Todo *, int); 240 void todoModifiedSignal (Todo *, int);
241 241
242 void isModified(bool); 242 void isModified(bool);
243 void cloneTodoSignal( Incidence * ); 243 void cloneTodoSignal( Incidence * );
244 void cancelTodoSignal( Incidence * ); 244 void cancelTodoSignal( Incidence * );
245 void moveTodoSignal( Incidence * ); 245 void moveTodoSignal( Incidence * );
246 void beamTodoSignal( Incidence * ); 246 void beamTodoSignal( Incidence * );
247 void purgeCompletedSignal(); 247 void purgeCompletedSignal();
248 248
249 protected slots: 249 protected slots:
250 void toggleRunningItem(); 250 void toggleRunningItem();
251 void paintNeeded(); 251 void paintNeeded();
252 void processSelectionChange(); 252 void processSelectionChange();
253 void addQuickTodo(); 253 void addQuickTodo();
254 void setTodoModified( Todo* ); 254 void setTodoModified( Todo* );
255 void todoModified(Todo *, int ); 255 void todoModified(Todo *, int );
256 256
257 private: 257 private:
258 bool mIsActiveWindow;
258 void addQuickTodoPar( Todo * parentTodo); 259 void addQuickTodoPar( Todo * parentTodo);
259 /* 260 /*
260 * the TodoEditor approach is rather unscaling in the long 261 * the TodoEditor approach is rather unscaling in the long
261 * run. 262 * run.
262 * Korganizer keeps it in memory and we need to update 263 * Korganizer keeps it in memory and we need to update
263 * 1. make KOTodoViewItem a QObject again? 264 * 1. make KOTodoViewItem a QObject again?
264 * 2. add a public method for setting one todo modified? 265 * 2. add a public method for setting one todo modified?
265 * 3. add a private method for setting a todo modified + friend here? 266 * 3. add a private method for setting a todo modified + friend here?
266 * -- zecke 2002-07-08 267 * -- zecke 2002-07-08
267 */ 268 */
268 KOTodoViewWhatsThis* mKOTodoViewWhatsThis; 269 KOTodoViewWhatsThis* mKOTodoViewWhatsThis;
269 friend class KOTodoListView; 270 friend class KOTodoListView;
270 void paintEvent(QPaintEvent * pevent); 271 void paintEvent(QPaintEvent * pevent);
271 bool mPendingUpdateBeforeRepaint; 272 bool mPendingUpdateBeforeRepaint;
272 friend class KOTodoViewItem; 273 friend class KOTodoViewItem;
273 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); 274 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
274 void restoreItemState( QListViewItem * ); 275 void restoreItemState( QListViewItem * );
275 276
276 bool checkTodo( Todo * ); 277 bool checkTodo( Todo * );
277 bool isFlatDisplay; 278 bool isFlatDisplay;
278 void setOpen( QListViewItem*, bool setOpen); 279 void setOpen( QListViewItem*, bool setOpen);
279 KOTodoListView *mTodoListView; 280 KOTodoListView *mTodoListView;
280 QPopupMenu *mItemPopupMenu; 281 QPopupMenu *mItemPopupMenu;
281 QPopupMenu *mPopupMenu; 282 QPopupMenu *mPopupMenu;
282 QPopupMenu *mPriorityPopupMenu; 283 QPopupMenu *mPriorityPopupMenu;
283 QPopupMenu *mPercentageCompletedPopupMenu; 284 QPopupMenu *mPercentageCompletedPopupMenu;
284 QPopupMenu *mCategoryPopupMenu; 285 QPopupMenu *mCategoryPopupMenu;
285 QPopupMenu *mCalPopupMenu; 286 QPopupMenu *mCalPopupMenu;
286 287
287 QMap<int, int> mPercentage; 288 QMap<int, int> mPercentage;
288 QMap<int, int> mPriority; 289 QMap<int, int> mPriority;
289 QMap<int, QString> mCategory; 290 QMap<int, QString> mCategory;
290 KOTodoViewItem *mActiveItem; 291 KOTodoViewItem *mActiveItem;
291 292
292 QMap<Todo *,KOTodoViewItem *> mTodoMap; 293 QMap<Todo *,KOTodoViewItem *> mTodoMap;
293 QString mName; 294 QString mName;
294 QWidget* mQuickBar; 295 QWidget* mQuickBar;
295 296
296 DocPrefs *mDocPrefs; 297 DocPrefs *mDocPrefs;
297 QString mCurrentDoc; 298 QString mCurrentDoc;
298 KOQuickTodo *mQuickAdd; 299 KOQuickTodo *mQuickAdd;
299 bool mBlockUpdate; 300 bool mBlockUpdate;
300 void keyPressEvent ( QKeyEvent * ) ; 301 void keyPressEvent ( QKeyEvent * ) ;
301 KOTodoViewItem * pendingSubtodo; 302 KOTodoViewItem * pendingSubtodo;
302 DateNavigator* mNavigator; 303 DateNavigator* mNavigator;
303 void storeCurrentItem(); 304 void storeCurrentItem();
304 void resetCurrentItem(); 305 void resetCurrentItem();
305 Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove; 306 Incidence * mCurItem, *mCurItemRootParent, *mCurItemParent,*mCurItemAbove;
306 QPushButton * mNewSubBut; 307 QPushButton * mNewSubBut;
307}; 308};
308 309
309#endif 310#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index ba3bc05..4057ae0 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,865 +1,867 @@
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
64 lastMode = 0;
65 lastCount = 0;
66 lastNDMode = false;
67 selecteddatescount = 0;
68 selecteddate = QDate ( 2000, 1, 1 );
69 baseCycleDate = QDate ( 2000, 1, 1 );
63 mCurrentView = 0; 70 mCurrentView = 0;
64 flagResetViewChangeDate = 0; 71 flagResetViewChangeDate = 0;
65 mWhatsNextView = 0; 72 mWhatsNextView = 0;
66 mTodoView = 0; 73 mTodoView = 0;
67 mAgendaView = 0; 74 mAgendaView = 0;
68 mMonthView = 0; 75 mMonthView = 0;
69 mListView = 0; 76 mListView = 0;
70 mJournalView = 0; 77 mJournalView = 0;
71 mTimeSpanView = 0; 78 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 79 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 80 mFlagShowNextxDays = false;
74} 81}
75 82
76KOViewManager::~KOViewManager() 83KOViewManager::~KOViewManager()
77{ 84{
78} 85}
79 86
80 87
81KOrg::BaseView *KOViewManager::currentView() 88KOrg::BaseView *KOViewManager::currentView()
82{ 89{
83 return mCurrentView; 90 return mCurrentView;
84} 91}
85 92
86void KOViewManager::readSettings(KConfig *config) 93void KOViewManager::readSettings(KConfig *config)
87{ 94{
88 config->setGroup("General"); 95 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 96 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 97 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") { 98 else if (view == "Month") {
92 if ( !KOPrefs::instance()->mMonthViewWeek ) 99 if ( !KOPrefs::instance()->mMonthViewWeek )
93 showMonthView(); 100 showMonthView();
94 else 101 else
95 showMonthViewWeek(); 102 showMonthViewWeek();
96 } 103 }
97 else if (view == "List") showListView(); 104 else if (view == "List") showListView();
98 else if (view == "Journal") showJournalView(); 105 else if (view == "Journal") showJournalView();
99 else if (view == "TimeSpan") showTimeSpanView(); 106 else if (view == "TimeSpan") showTimeSpanView();
100 else if (view == "Todo") showTodoView(); 107 else if (view == "Todo") showTodoView();
101 else { 108 else {
102 config->setGroup( "Views" ); 109 config->setGroup( "Views" );
103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 110 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
104 mCurrentAgendaView = dateCount; 111 mCurrentAgendaView = dateCount;
105 showAgendaView(); 112 showAgendaView();
106 mCurrentAgendaView = dateCount; 113 mCurrentAgendaView = dateCount;
107#ifdef DESKTOP_VERSION 114#ifdef DESKTOP_VERSION
108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 115 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
109#endif 116#endif
110 } 117 }
111} 118}
112 119
113 120
114void KOViewManager::showDateView( int view, QDate date) 121void KOViewManager::showDateView( int view, QDate date)
115{ 122{
116 static int lastMode = 0; 123
117 static int lastCount = 0;
118 static bool lastNDMode = false;
119 static QDate lastDate;
120 //qDebug("date %d %s", view, date.toString().latin1()); 124 //qDebug("date %d %s", view, date.toString().latin1());
121 125
122 if (view != 9) 126 if (view != 9)
123 lastMode = 0; 127 lastMode = 0;
124 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 128 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
125 bool savemFlagShowNextxDays = mFlagShowNextxDays; 129 bool savemFlagShowNextxDays = mFlagShowNextxDays;
126 mFlagShowNextxDays = false; 130 mFlagShowNextxDays = false;
127 if ( view == 3 ) { 131 if ( view == 3 ) {
128 //mCurrentAgendaView = 1 ; 132 //mCurrentAgendaView = 1 ;
129 lastDate = mMainView->dateNavigator()->selectedDates().first(); 133 lastDate = mMainView->dateNavigator()->selectedDates().first();
130 lastCount = mMainView->dateNavigator()->selectedDates().count(); 134 lastCount = mMainView->dateNavigator()->selectedDates().count();
131 lastNDMode = savemFlagShowNextxDays; 135 lastNDMode = savemFlagShowNextxDays;
132 mMainView->dateNavigator()->selectDate( date ); 136 mMainView->dateNavigator()->selectDate( date );
133 lastMode = 1; 137 lastMode = 1;
134 mCurrentAgendaView = 1 ; 138 mCurrentAgendaView = 1 ;
135 } else if (view == 4 ) { 139 } else if (view == 4 ) {
136 mCurrentAgendaView = 7 ; 140 mCurrentAgendaView = 7 ;
137 mMainView->dateNavigator()->selectDates( date, 7 ); 141 mMainView->dateNavigator()->selectDates( date, 7 );
138 } else if (view == 5 ) { 142 } else if (view == 5 ) {
139 mCurrentAgendaView = 14 ; 143 mCurrentAgendaView = 14 ;
140 mMainView->dateNavigator()->selectDates( date, 14); 144 mMainView->dateNavigator()->selectDates( date, 14);
141 } else if (view == 6 ) { 145 } else if (view == 6 ) {
142 resetDateSilent( date,1); 146 resetDateSilent( date,1);
143 showMonthView(); 147 showMonthView();
144 } else if (view == 7 ) { 148 } else if (view == 7 ) {
145 mMainView->dateNavigator()->selectDate( date ); 149 mMainView->dateNavigator()->selectDate( date );
146 showJournalView(); 150 showJournalView();
147 } else if (view == 8 ) { 151 } else if (view == 8 ) {
148 globalFlagBlockAgenda = 1; 152 globalFlagBlockAgenda = 1;
149 if ( mCurrentAgendaView != 3 ) 153 if ( mCurrentAgendaView != 3 )
150 mCurrentAgendaView = -1; 154 mCurrentAgendaView = -1;
151 showAgendaView(KOPrefs::instance()->mFullViewMonth); 155 showAgendaView(KOPrefs::instance()->mFullViewMonth);
152 globalFlagBlockAgenda = 2; 156 globalFlagBlockAgenda = 2;
153 mMainView->dateNavigator()->selectDates( date , 157 mMainView->dateNavigator()->selectDates( date ,
154 KOPrefs::instance()->mNextXDays ); 158 KOPrefs::instance()->mNextXDays );
155 mFlagShowNextxDays = true; 159 mFlagShowNextxDays = true;
156 mCurrentAgendaView = 3 ; 160 mCurrentAgendaView = 3 ;
157 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 161 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
158 if ( lastMode ) { 162 if ( lastMode ) {
159 mCurrentAgendaView = lastCount ; 163 mCurrentAgendaView = lastCount ;
160 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 164 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
161 mFlagShowNextxDays = lastNDMode; 165 mFlagShowNextxDays = lastNDMode;
162 if ( mFlagShowNextxDays ) { 166 if ( mFlagShowNextxDays ) {
163 mCurrentAgendaView = 3 ; 167 mCurrentAgendaView = 3 ;
164 } 168 }
165 } else 169 } else
166 showWeekView(); 170 showWeekView();
167 } else if (view == 10) { 171 } else if (view == 10) {
168 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 172 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
169 } 173 }
170} 174}
171 175
172 176
173 177
174void KOViewManager::writeSettings(KConfig *config) 178void KOViewManager::writeSettings(KConfig *config)
175{ 179{
176 config->setGroup("General"); 180 config->setGroup("General");
177 181
178 QString view; 182 QString view;
179 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 183 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
180 else if (mCurrentView == mMonthView) view = "Month"; 184 else if (mCurrentView == mMonthView) view = "Month";
181 else if (mCurrentView == mListView) view = "List"; 185 else if (mCurrentView == mListView) view = "List";
182 else if (mCurrentView == mJournalView) view = "Journal"; 186 else if (mCurrentView == mJournalView) view = "Journal";
183 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 187 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
184 else if (mCurrentView == mTodoView) view = "Todo"; 188 else if (mCurrentView == mTodoView) view = "Todo";
185 else view = "Agenda"; 189 else view = "Agenda";
186 190
187 config->writeEntry("Current View",view); 191 config->writeEntry("Current View",view);
188 192
189 if (mAgendaView) { 193 if (mAgendaView) {
190 mAgendaView->writeSettings(config); 194 mAgendaView->writeSettings(config);
191 } 195 }
192 if (mTimeSpanView) { 196 if (mTimeSpanView) {
193 mTimeSpanView->writeSettings(config); 197 mTimeSpanView->writeSettings(config);
194 } 198 }
195 if (mListView) { 199 if (mListView) {
196 mListView->writeSettings(config); 200 mListView->writeSettings(config);
197 } 201 }
198 if (mTodoView) { 202 if (mTodoView) {
199 mTodoView->saveLayout(config,"Todo View"); 203 mTodoView->saveLayout(config,"Todo View");
200 } 204 }
201} 205}
202void KOViewManager::showNextView() 206void KOViewManager::showNextView()
203{ 207{
204 static int selecteddatescount = 0; 208
205 static QDate selecteddate = QDate ( 2000, 1, 1 );
206 static QDate baseCycleDate = QDate ( 2000, 1, 1 );
207 int newCount = mMainView->dateNavigator()->selectedDates().count(); 209 int newCount = mMainView->dateNavigator()->selectedDates().count();
208 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { 210 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) {
209 flagResetViewChangeDate = 1; 211 flagResetViewChangeDate = 1;
210 } 212 }
211 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) 213 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() )
212 flagResetViewChangeDate = 1; 214 flagResetViewChangeDate = 1;
213 if ( flagResetViewChangeDate > 0 ) { 215 if ( flagResetViewChangeDate > 0 ) {
214 baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); 216 baseCycleDate = mMainView->dateNavigator()->selectedDates().first();
215 //qDebug("newCycle "); 217 //qDebug("newCycle ");
216 } 218 }
217 if (mCurrentView == mWhatsNextView) goto NEXT_X; 219 if (mCurrentView == mWhatsNextView) goto NEXT_X;
218 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; 220 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL;
219 if (mCurrentView == mJournalView ) goto DAY_1; 221 if (mCurrentView == mJournalView ) goto DAY_1;
220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; 222 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5;
221 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; 223 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7;
222 if (mCurrentView == mAgendaView ) goto DAY_6; 224 if (mCurrentView == mAgendaView ) goto DAY_6;
223 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; 225 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH;
224 if (mCurrentView == mMonthView ) goto LIST; 226 if (mCurrentView == mMonthView ) goto LIST;
225 if (mCurrentView == mListView ) goto TODO; 227 if (mCurrentView == mListView ) goto TODO;
226 // if (mCurrentView == mTodoView ) goto NEXT; 228 // if (mCurrentView == mTodoView ) goto NEXT;
227 NEXT: 229 NEXT:
228 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} 230 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;}
229 NEXT_X: 231 NEXT_X:
230 if ( KOPrefs::instance()->mShowIconNextDays ) { 232 if ( KOPrefs::instance()->mShowIconNextDays ) {
231 showNextXView(); 233 showNextXView();
232 goto ENTE ; 234 goto ENTE ;
233 } 235 }
234 JOURNAL: 236 JOURNAL:
235 if ( KOPrefs::instance()->mShowIconJournal ) { 237 if ( KOPrefs::instance()->mShowIconJournal ) {
236 resetDateSilent( baseCycleDate , 1 ); 238 resetDateSilent( baseCycleDate , 1 );
237 showJournalView() ;goto ENTE ;} 239 showJournalView() ;goto ENTE ;}
238 DAY_1: 240 DAY_1:
239 if ( KOPrefs::instance()->mShowIconDay1 ) { 241 if ( KOPrefs::instance()->mShowIconDay1 ) {
240 resetDateSilent( baseCycleDate , 2 ); 242 resetDateSilent( baseCycleDate , 2 );
241 showDayView() ;goto ENTE ;} 243 showDayView() ;goto ENTE ;}
242 DAY_5: 244 DAY_5:
243 if ( KOPrefs::instance()->mShowIconDay5 ) { 245 if ( KOPrefs::instance()->mShowIconDay5 ) {
244 resetDateSilent( baseCycleDate , 2 ); 246 resetDateSilent( baseCycleDate , 2 );
245 showWorkWeekView() ;goto ENTE ;} 247 showWorkWeekView() ;goto ENTE ;}
246 DAY_7: 248 DAY_7:
247 if ( KOPrefs::instance()->mShowIconDay7 ) { 249 if ( KOPrefs::instance()->mShowIconDay7 ) {
248 resetDateSilent( baseCycleDate , 2 ); 250 resetDateSilent( baseCycleDate , 2 );
249 showWeekView();goto ENTE ;} 251 showWeekView();goto ENTE ;}
250 DAY_6: 252 DAY_6:
251 if ( KOPrefs::instance()->mShowIconDay6 ) { 253 if ( KOPrefs::instance()->mShowIconDay6 ) {
252 resetDateSilent( baseCycleDate , 2 ); 254 resetDateSilent( baseCycleDate , 2 );
253 showMonthViewWeek();goto ENTE ;} 255 showMonthViewWeek();goto ENTE ;}
254 MONTH: 256 MONTH:
255 if ( KOPrefs::instance()->mShowIconMonth ) { 257 if ( KOPrefs::instance()->mShowIconMonth ) {
256 resetDateSilent( baseCycleDate , 2 ); 258 resetDateSilent( baseCycleDate , 2 );
257 showMonthView();goto ENTE ;} 259 showMonthView();goto ENTE ;}
258 LIST: 260 LIST:
259 if ( KOPrefs::instance()->mShowIconList ) { 261 if ( KOPrefs::instance()->mShowIconList ) {
260 resetDateSilent( baseCycleDate , 2 ); 262 resetDateSilent( baseCycleDate , 2 );
261 showListView() ;goto ENTE ;} 263 showListView() ;goto ENTE ;}
262 TODO: 264 TODO:
263 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 265 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
264 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} 266 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;}
265 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} 267 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;}
266 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} 268 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;}
267 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} 269 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;}
268 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} 270 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;}
269 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} 271 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;}
270 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} 272 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;}
271 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} 273 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;}
272 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} 274 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;}
273 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 275 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
274 ENTE: 276 ENTE:
275 flagResetViewChangeDate = 0; 277 flagResetViewChangeDate = 0;
276 selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); 278 selecteddatescount = mMainView->dateNavigator()->selectedDates().count();
277 selecteddate = mMainView->dateNavigator()->selectedDates().first(); 279 selecteddate = mMainView->dateNavigator()->selectedDates().first();
278 280
279} 281}
280void KOViewManager::resetDateSilent( QDate date , int days ) 282void KOViewManager::resetDateSilent( QDate date , int days )
281{ 283{
282 mMainView->dateNavigator()->blockSignals( true ); 284 mMainView->dateNavigator()->blockSignals( true );
283 mMainView->dateNavigator()->selectDates( date , days ); 285 mMainView->dateNavigator()->selectDates( date , days );
284 mMainView->dateNavigator()->blockSignals( false ); 286 mMainView->dateNavigator()->blockSignals( false );
285} 287}
286void KOViewManager::setDefaultCalendar(int) 288void KOViewManager::setDefaultCalendar(int)
287{ 289{
288 if ( mJournalView && mCurrentView == mJournalView ) 290 if ( mJournalView && mCurrentView == mJournalView )
289 mJournalView->updateView(); 291 mJournalView->updateView();
290} 292}
291 293
292void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 294void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
293{ 295{
294 if ( flagResetViewChangeDate < 10 ) 296 if ( flagResetViewChangeDate < 10 )
295 ++flagResetViewChangeDate; 297 ++flagResetViewChangeDate;
296 //mFlagShowNextxDays = false; 298 //mFlagShowNextxDays = false;
297 //if(view == mCurrentView) return; 299 //if(view == mCurrentView) return;
298 if ( view == 0 ) { 300 if ( view == 0 ) {
299 view = mCurrentView; 301 view = mCurrentView;
300 if ( view == 0 ) 302 if ( view == 0 )
301 return; 303 return;
302 } 304 }
303 bool callupdate = !(view == mCurrentView); 305 bool callupdate = !(view == mCurrentView);
304 bool full = fullScreen; 306 bool full = fullScreen;
305 if(view == mCurrentView && view != mWhatsNextView ) { 307 if(view == mCurrentView && view != mWhatsNextView ) {
306 if ( mCurrentAgendaView < 0 ) 308 if ( mCurrentAgendaView < 0 )
307 return; 309 return;
308 if ( view != mMonthView ) 310 if ( view != mMonthView )
309 full = mMainView->leftFrame()->isVisible(); 311 full = mMainView->leftFrame()->isVisible();
310 } else { 312 } else {
311 if ( view == mMonthView && mMonthView) 313 if ( view == mMonthView && mMonthView)
312 ;//mMonthView->skipResize = true ; 314 ;//mMonthView->skipResize = true ;
313 mCurrentView = view; 315 mCurrentView = view;
314 // bool full = fullScreen; 316 // bool full = fullScreen;
315 bool isFull = !mMainView->leftFrame()->isVisible(); 317 bool isFull = !mMainView->leftFrame()->isVisible();
316 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 318 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
317 full = true; 319 full = true;
318 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 320 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
319 full = false; 321 full = false;
320 } 322 }
321 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 323 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
322 //raiseCurrentView( full ); 324 //raiseCurrentView( full );
323 mMainView->processIncidenceSelection( 0 ); 325 mMainView->processIncidenceSelection( 0 );
324 //mMainView->updateView(); 326 //mMainView->updateView();
325 raiseCurrentView( full, callupdate ); 327 raiseCurrentView( full, callupdate );
326 mMainView->adaptNavigationUnits(); 328 mMainView->adaptNavigationUnits();
327 mMainView->updateUnmanagedViews(); 329 mMainView->updateUnmanagedViews();
328} 330}
329 331
330void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 332void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
331{ 333{
332 mCurrentAgendaView = 0; 334 mCurrentAgendaView = 0;
333 if ( fullScreen ) { 335 if ( fullScreen ) {
334 mMainView->leftFrame()->hide(); 336 mMainView->leftFrame()->hide();
335 } else { 337 } else {
336 mMainView->leftFrame()->show(); 338 mMainView->leftFrame()->show();
337 } 339 }
338 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 340 //if ( mCurrentView == mMonthView ) qApp->processEvents();
339 emit signalFullScreen( !fullScreen ); 341 emit signalFullScreen( !fullScreen );
340 if ( callUpdateView ) 342 if ( callUpdateView )
341 mMainView->updateView(); 343 mMainView->updateView();
342 344
343 if ( globalFlagBlockAgenda == 5 ) { 345 if ( globalFlagBlockAgenda == 5 ) {
344 globalFlagBlockAgenda = 4; 346 globalFlagBlockAgenda = 4;
345 globalFlagBlockAgendaItemPaint = 1; 347 globalFlagBlockAgendaItemPaint = 1;
346 } 348 }
347 mMainView->viewStack()->raiseWidget(mCurrentView); 349 mMainView->viewStack()->raiseWidget(mCurrentView);
348 if ( globalFlagBlockAgenda == 4 ) { 350 if ( globalFlagBlockAgenda == 4 ) {
349 if ( mCurrentView == mAgendaView ) { 351 if ( mCurrentView == mAgendaView ) {
350 //globalFlagBlockAgenda =1 ; 352 //globalFlagBlockAgenda =1 ;
351 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 353 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
352 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 354 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
353 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 355 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
354 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 356 mAgendaView->setStartHour( QTime::currentTime ().hour() );
355 qApp->processEvents(); 357 qApp->processEvents();
356 //qDebug("qApp->processEvents() "); 358 //qDebug("qApp->processEvents() ");
357 globalFlagBlockAgenda = 0; 359 globalFlagBlockAgenda = 0;
358 mAgendaView->repaintAgenda(); 360 mAgendaView->repaintAgenda();
359 361
360 } 362 }
361 globalFlagBlockAgenda = 0; 363 globalFlagBlockAgenda = 0;
362 } 364 }
363 emit signalAgendaView( mCurrentView == mAgendaView ); 365 emit signalAgendaView( mCurrentView == mAgendaView );
364 //qDebug("raiseCurrentView ende "); 366 //qDebug("raiseCurrentView ende ");
365 367
366} 368}
367 369
368void KOViewManager::clearAllViews() 370void KOViewManager::clearAllViews()
369{ 371{
370 372
371 if ( mTodoView ) mTodoView->clearList(); 373 if ( mTodoView ) mTodoView->clearList();
372 if ( mListView ) mListView->clearList(); 374 if ( mListView ) mListView->clearList();
373 375
374 if ( mAgendaView ) mAgendaView->clearList(); 376 if ( mAgendaView ) mAgendaView->clearList();
375 if ( mMonthView ) mMonthView->clearList(); 377 if ( mMonthView ) mMonthView->clearList();
376 if ( mWhatsNextView ) mWhatsNextView->clearList(); 378 if ( mWhatsNextView ) mWhatsNextView->clearList();
377 if ( mJournalView ) mJournalView->clearList(); 379 if ( mJournalView ) mJournalView->clearList();
378 380
379} 381}
380void KOViewManager::updateView() 382void KOViewManager::updateView()
381{ 383{
382 // qDebug("KOViewManager::updateView() "); 384 // qDebug("KOViewManager::updateView() ");
383 // if we are updating mTodoView, we get endless recursion 385 // if we are updating mTodoView, we get endless recursion
384 if ( mTodoView == mCurrentView ) 386 if ( mTodoView == mCurrentView )
385 return; 387 return;
386 if ( mCurrentView ) mCurrentView->updateView(); 388 if ( mCurrentView ) mCurrentView->updateView();
387 389
388} 390}
389 391
390void KOViewManager::updateView(const QDate &start, const QDate &end) 392void KOViewManager::updateView(const QDate &start, const QDate &end)
391{ 393{
392 // kdDebug() << "KOViewManager::updateView()" << endl; 394 // kdDebug() << "KOViewManager::updateView()" << endl;
393 395
394 if (mCurrentView) mCurrentView->showDates(start, end); 396 if (mCurrentView) mCurrentView->showDates(start, end);
395 397
396 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 398 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
397} 399}
398 400
399 401
400void KOViewManager::updateWNview() 402void KOViewManager::updateWNview()
401{ 403{
402 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 404 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
403 mWhatsNextView->updateView(); 405 mWhatsNextView->updateView();
404 if ( mCurrentView == mMonthView && mMonthView ) 406 if ( mCurrentView == mMonthView && mMonthView )
405 mMonthView->updateView(); 407 mMonthView->updateView();
406 408
407} 409}
408void KOViewManager::showWhatsNextView() 410void KOViewManager::showWhatsNextView()
409{ 411{
410 if (!mWhatsNextView) { 412 if (!mWhatsNextView) {
411 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 413 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
412 "KOViewManager::WhatsNextView"); 414 "KOViewManager::WhatsNextView");
413 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 415 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
414 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 416 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
415 addView(mWhatsNextView); 417 addView(mWhatsNextView);
416 connect(this, SIGNAL( printWNV() ), 418 connect(this, SIGNAL( printWNV() ),
417 mWhatsNextView, SLOT( printMe() ) ); 419 mWhatsNextView, SLOT( printMe() ) );
418 } 420 }
419 globalFlagBlockAgenda = 1; 421 globalFlagBlockAgenda = 1;
420 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 422 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
421 showView(mWhatsNextView, true ); 423 showView(mWhatsNextView, true );
422 //mWhatsNextView->updateView(); 424 //mWhatsNextView->updateView();
423 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 425 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
424} 426}
425 427
426void KOViewManager::slotprintWNV() 428void KOViewManager::slotprintWNV()
427{ 429{
428 if (!mWhatsNextView) 430 if (!mWhatsNextView)
429 showWhatsNextView(); 431 showWhatsNextView();
430 emit printWNV(); 432 emit printWNV();
431 433
432} 434}
433void KOViewManager::showListView() 435void KOViewManager::showListView()
434{ 436{
435 if (!mListView) { 437 if (!mListView) {
436 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 438 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
437 addView(mListView); 439 addView(mListView);
438 440
439 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 441 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
440 mMainView, SLOT(showIncidence(Incidence *))); 442 mMainView, SLOT(showIncidence(Incidence *)));
441 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 443 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
442 mMainView, SLOT(editIncidence(Incidence *))); 444 mMainView, SLOT(editIncidence(Incidence *)));
443 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 445 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
444 mMainView, SLOT(deleteIncidence(Incidence *))); 446 mMainView, SLOT(deleteIncidence(Incidence *)));
445 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 447 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
446 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 448 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
447 connect( mListView, SIGNAL( signalNewEvent() ), 449 connect( mListView, SIGNAL( signalNewEvent() ),
448 mMainView, SLOT( newEvent() ) ); 450 mMainView, SLOT( newEvent() ) );
449 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 451 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
450 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 452 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
451 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 453 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
452 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 454 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
453 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 455 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
454 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 456 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
455 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 457 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
456 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 458 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
457 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 459 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
458 connect( mListView, SIGNAL( beamIncidenceList( QPtrList<Incidence> ) ), 460 connect( mListView, SIGNAL( beamIncidenceList( QPtrList<Incidence> ) ),
459 mMainView, SLOT ( beamIncidenceList( QPtrList<Incidence> ) ) ); 461 mMainView, SLOT ( beamIncidenceList( QPtrList<Incidence> ) ) );
460 } 462 }
461 // bool temp = mFlagShowNextxDays; 463 // bool temp = mFlagShowNextxDays;
462 //globalFlagBlockPainting = true; 464 //globalFlagBlockPainting = true;
463 globalFlagBlockAgenda = 1; 465 globalFlagBlockAgenda = 1;
464 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 466 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
465 mMainView->setBlockShowDates( true ); 467 mMainView->setBlockShowDates( true );
466 mMainView->dateNavigator()->selectMonth(); 468 mMainView->dateNavigator()->selectMonth();
467 mMainView->setBlockShowDates( false ); 469 mMainView->setBlockShowDates( false );
468 } 470 }
469 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 471 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
470 showView(mListView, KOPrefs::instance()->mFullViewTodo); 472 showView(mListView, KOPrefs::instance()->mFullViewTodo);
471 //mFlagShowNextxDays = temp; 473 //mFlagShowNextxDays = temp;
472 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 474 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
473 mMainView->setScrollBarStep( 7 ); 475 mMainView->setScrollBarStep( 7 );
474} 476}
475 477
476void KOViewManager::showAgendaView( bool fullScreen ) 478void KOViewManager::showAgendaView( bool fullScreen )
477{ 479{
478 480
479 mMainView->dialogManager()->hideSearchDialog(); 481 mMainView->dialogManager()->hideSearchDialog();
480 // qDebug("KOViewManager::showAgendaView "); 482 // qDebug("KOViewManager::showAgendaView ");
481 bool full; 483 bool full;
482 full = fullScreen; 484 full = fullScreen;
483 if (!mAgendaView) { 485 if (!mAgendaView) {
484 full = false; 486 full = false;
485 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 487 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
486 addView(mAgendaView); 488 addView(mAgendaView);
487#ifndef DESKTOP_VERSION 489#ifndef DESKTOP_VERSION
488 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 490 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
489#endif 491#endif
490 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 492 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
491 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 493 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
492 494
493 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 495 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
494 496
495 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 497 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
496 498
497 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 499 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
498 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 500 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
499 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 501 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
500 mMainView, SLOT(newEvent(QDateTime))); 502 mMainView, SLOT(newEvent(QDateTime)));
501 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 503 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
502 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 504 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
503 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 505 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
504 mMainView, SLOT(newEvent(QDate))); 506 mMainView, SLOT(newEvent(QDate)));
505 507
506 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 508 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
507 mMainView, SLOT(editIncidence(Incidence *))); 509 mMainView, SLOT(editIncidence(Incidence *)));
508 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 510 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
509 mMainView, SLOT(showIncidence(Incidence *))); 511 mMainView, SLOT(showIncidence(Incidence *)));
510 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 512 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
511 mMainView, SLOT(deleteIncidence(Incidence *))); 513 mMainView, SLOT(deleteIncidence(Incidence *)));
512 514
513 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 515 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
514 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 516 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
515 517
516 connect(mAgendaView, SIGNAL( toggleExpand() ), 518 connect(mAgendaView, SIGNAL( toggleExpand() ),
517 mMainView, SLOT( toggleExpand() ) ); 519 mMainView, SLOT( toggleExpand() ) );
518 520
519 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 521 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
520 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 522 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
521 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 523 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
522 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 524 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
523 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 525 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
524 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 526 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
525 SLOT( updateTodo( Todo *, int ) ) ); 527 SLOT( updateTodo( Todo *, int ) ) );
526 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 528 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
527 mMainView, SIGNAL( todoModified( Todo *, int ))); 529 mMainView, SIGNAL( todoModified( Todo *, int )));
528 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 530 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
529 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 531 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
530 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 532 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
531 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 533 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
532 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 534 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
533 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 535 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
534 mAgendaView->readSettings(); 536 mAgendaView->readSettings();
535 mAgendaView->updateConfig(); 537 mAgendaView->updateConfig();
536 } 538 }
537 539
538 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; 540 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
539 showView( mAgendaView, full); 541 showView( mAgendaView, full);
540 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; 542 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
541 mMainView->setScrollBarStep( 1 ); 543 mMainView->setScrollBarStep( 1 );
542} 544}
543 545
544void KOViewManager::showDayView() 546void KOViewManager::showDayView()
545{ 547{
546 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 548 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
547 mFlagShowNextxDays = false; 549 mFlagShowNextxDays = false;
548 globalFlagBlockLabel = 1; 550 globalFlagBlockLabel = 1;
549 globalFlagBlockAgenda = 1; 551 globalFlagBlockAgenda = 1;
550 if ( mCurrentAgendaView != 1 ) 552 if ( mCurrentAgendaView != 1 )
551 mCurrentAgendaView = -1; 553 mCurrentAgendaView = -1;
552 showAgendaView(); 554 showAgendaView();
553 qApp->processEvents(); 555 qApp->processEvents();
554 globalFlagBlockAgenda = 2; 556 globalFlagBlockAgenda = 2;
555 globalFlagBlockLabel = 0; 557 globalFlagBlockLabel = 0;
556 mMainView->dateNavigator()->selectDates( 1 ); 558 mMainView->dateNavigator()->selectDates( 1 );
557 mCurrentAgendaView = 1 ; 559 mCurrentAgendaView = 1 ;
558 560
559} 561}
560 562
561void KOViewManager::showWorkWeekView() 563void KOViewManager::showWorkWeekView()
562{ 564{
563 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 565 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
564 mFlagShowNextxDays = false; 566 mFlagShowNextxDays = false;
565 globalFlagBlockAgenda = 1; 567 globalFlagBlockAgenda = 1;
566 globalFlagBlockLabel = 1; 568 globalFlagBlockLabel = 1;
567 if ( mCurrentAgendaView != 5 ) 569 if ( mCurrentAgendaView != 5 )
568 mCurrentAgendaView = -1; 570 mCurrentAgendaView = -1;
569 showAgendaView(); 571 showAgendaView();
570 qApp->processEvents(); 572 qApp->processEvents();
571 globalFlagBlockAgenda = 2; 573 globalFlagBlockAgenda = 2;
572 globalFlagBlockLabel = 0; 574 globalFlagBlockLabel = 0;
573 mMainView->dateNavigator()->selectWorkWeek(); 575 mMainView->dateNavigator()->selectWorkWeek();
574 mCurrentAgendaView = 5 ; 576 mCurrentAgendaView = 5 ;
575 577
576} 578}
577 579
578void KOViewManager::showWeekView() 580void KOViewManager::showWeekView()
579{ 581{
580 582
581 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 583 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
582 mFlagShowNextxDays = false; 584 mFlagShowNextxDays = false;
583 globalFlagBlockAgenda = 1; 585 globalFlagBlockAgenda = 1;
584 globalFlagBlockLabel = 1; 586 globalFlagBlockLabel = 1;
585 if ( mCurrentAgendaView != 7 ) 587 if ( mCurrentAgendaView != 7 )
586 mCurrentAgendaView = -1; 588 mCurrentAgendaView = -1;
587 showAgendaView(); 589 showAgendaView();
588 qApp->processEvents(); 590 qApp->processEvents();
589 globalFlagBlockAgenda = 2; 591 globalFlagBlockAgenda = 2;
590 globalFlagBlockLabel = 0; 592 globalFlagBlockLabel = 0;
591 mMainView->dateNavigator()->selectWeek(); 593 mMainView->dateNavigator()->selectWeek();
592 mCurrentAgendaView = 7 ; 594 mCurrentAgendaView = 7 ;
593} 595}
594 596
595void KOViewManager::showNextXView() 597void KOViewManager::showNextXView()
596{ 598{
597 599
598 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; 600 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
599 globalFlagBlockAgenda = 1; 601 globalFlagBlockAgenda = 1;
600 if ( mCurrentAgendaView != 3 ) 602 if ( mCurrentAgendaView != 3 )
601 mCurrentAgendaView = -1; 603 mCurrentAgendaView = -1;
602 showAgendaView(KOPrefs::instance()->mFullViewMonth); 604 showAgendaView(KOPrefs::instance()->mFullViewMonth);
603 globalFlagBlockAgenda = 2; 605 globalFlagBlockAgenda = 2;
604 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 606 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
605 KOPrefs::instance()->mNextXDays ); 607 KOPrefs::instance()->mNextXDays );
606 mFlagShowNextxDays = true; 608 mFlagShowNextxDays = true;
607 mCurrentAgendaView = 3 ; 609 mCurrentAgendaView = 3 ;
608 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; 610 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
609 mMainView->setScrollBarStep( KOPrefs::instance()->mNextXDays ); 611 mMainView->setScrollBarStep( KOPrefs::instance()->mNextXDays );
610} 612}
611bool KOViewManager::showsNextDays() 613bool KOViewManager::showsNextDays()
612{ 614{
613 return mFlagShowNextxDays; 615 return mFlagShowNextxDays;
614} 616}
615void KOViewManager::createMonthView() 617void KOViewManager::createMonthView()
616{ 618{
617if (!mMonthView) { 619if (!mMonthView) {
618 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 620 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
619 621
620 addView(mMonthView); 622 addView(mMonthView);
621 // mMonthView->show(); 623 // mMonthView->show();
622 // SIGNALS/SLOTS FOR MONTH VIEW 624 // SIGNALS/SLOTS FOR MONTH VIEW
623 625
624 connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate ))); 626 connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate )));
625 627
626 connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)), 628 connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)),
627 mMainView, SLOT(newTodoDateTime(QDateTime, bool))); 629 mMainView, SLOT(newTodoDateTime(QDateTime, bool)));
628 630
629 631
630 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 632 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
631 mMainView, SLOT(newEvent(QDateTime))); 633 mMainView, SLOT(newEvent(QDateTime)));
632 634
633 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 635 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
634 mMainView, SLOT(showIncidence(Incidence *))); 636 mMainView, SLOT(showIncidence(Incidence *)));
635 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 637 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
636 mMainView, SLOT(editIncidence(Incidence *))); 638 mMainView, SLOT(editIncidence(Incidence *)));
637 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 639 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
638 mMainView, SLOT(deleteIncidence(Incidence *))); 640 mMainView, SLOT(deleteIncidence(Incidence *)));
639 641
640 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 642 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
641 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 643 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
642 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 644 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
643 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 645 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
644 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 646 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
645 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 647 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
646 648
647 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 649 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
648 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 650 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
649 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 651 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
650 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 652 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
651 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 653 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
652 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 654 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
653 connect( mMonthView, SIGNAL( selectMonth() ), 655 connect( mMonthView, SIGNAL( selectMonth() ),
654 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); 656 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
655 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 657 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
656 mMainView, SLOT ( showDay( QDate ) ) ); 658 mMainView, SLOT ( showDay( QDate ) ) );
657 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 659 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
658 connect( mMonthView, SIGNAL(nextMonth() ), 660 connect( mMonthView, SIGNAL(nextMonth() ),
659 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 661 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
660 connect( mMonthView, SIGNAL(prevMonth() ), 662 connect( mMonthView, SIGNAL(prevMonth() ),
661 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 663 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
662 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 664 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
663 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 665 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
664 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 666 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
665 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 667 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
666 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 668 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
667 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 669 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
668 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 670 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
669 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 671 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
670 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), 672 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
671 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); 673 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
672 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), 674 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
673 mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); 675 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
674 676
675 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 677 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
676 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 678 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
677 679
678 680
679 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 681 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
680 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 682 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
681 683
682 } 684 }
683} 685}
684void KOViewManager::showMonthViewWeek() 686void KOViewManager::showMonthViewWeek()
685{ 687{
686 createMonthView(); 688 createMonthView();
687 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; 689 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
688 globalFlagBlockAgenda = 1; 690 globalFlagBlockAgenda = 1;
689 bool full = true; 691 bool full = true;
690 if ( mCurrentView == mMonthView) 692 if ( mCurrentView == mMonthView)
691 full = mMainView->leftFrame()->isVisible(); 693 full = mMainView->leftFrame()->isVisible();
692 if ( !KOPrefs::instance()->mMonthViewWeek ) { 694 if ( !KOPrefs::instance()->mMonthViewWeek ) {
693 mMonthView->switchView(); 695 mMonthView->switchView();
694 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 696 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
695 full = false; 697 full = false;
696 else 698 else
697 full = true; 699 full = true;
698 } 700 }
699 mMainView->dateNavigator()->selectWeek(); 701 mMainView->dateNavigator()->selectWeek();
700 showView(mMonthView, full ); 702 showView(mMonthView, full );
701 mMonthView->setKeyBFocus(); 703 mMonthView->setKeyBFocus();
702 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; 704 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
703 mMainView->setScrollBarStep( 7 ); 705 mMainView->setScrollBarStep( 7 );
704} 706}
705 707
706void KOViewManager::showMonth( const QDate & date ) 708void KOViewManager::showMonth( const QDate & date )
707{ 709{
708 mMainView->dateNavigator()->blockSignals( true ); 710 mMainView->dateNavigator()->blockSignals( true );
709 mMainView->dateNavigator()->selectDate( date ); 711 mMainView->dateNavigator()->selectDate( date );
710 mMainView->dateNavigator()->blockSignals( false ); 712 mMainView->dateNavigator()->blockSignals( false );
711 showMonthView(); 713 showMonthView();
712} 714}
713void KOViewManager::showMonthView() 715void KOViewManager::showMonthView()
714 { 716 {
715 717
716 createMonthView(); 718 createMonthView();
717 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; 719 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
718 globalFlagBlockAgenda = 1; 720 globalFlagBlockAgenda = 1;
719 //mFlagShowNextxDays = false; 721 //mFlagShowNextxDays = false;
720 bool full = true; 722 bool full = true;
721 if ( mCurrentView == mMonthView) 723 if ( mCurrentView == mMonthView)
722 full = mMainView->leftFrame()->isVisible(); 724 full = mMainView->leftFrame()->isVisible();
723 // if(mMonthView == mCurrentView) return; 725 // if(mMonthView == mCurrentView) return;
724 if ( KOPrefs::instance()->mMonthViewWeek ) { 726 if ( KOPrefs::instance()->mMonthViewWeek ) {
725 mMonthView->switchView(); 727 mMonthView->switchView();
726 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 728 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
727 full = false; 729 full = false;
728 else 730 else
729 full = true; 731 full = true;
730 } 732 }
731 mMainView->dateNavigator()->selectMonth(); 733 mMainView->dateNavigator()->selectMonth();
732 734
733 showView(mMonthView, full ); 735 showView(mMonthView, full );
734 mMonthView->setKeyBFocus(); 736 mMonthView->setKeyBFocus();
735 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; 737 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
736 mMainView->setScrollBarStep( 7 ); 738 mMainView->setScrollBarStep( 7 );
737 739
738} 740}
739 741
740void KOViewManager::showTodoView() 742void KOViewManager::showTodoView()
741{ 743{
742 //mFlagShowNextxDays = false; 744 //mFlagShowNextxDays = false;
743 if ( !mTodoView ) { 745 if ( !mTodoView ) {
744 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 746 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
745 "KOViewManager::TodoView" ); 747 "KOViewManager::TodoView" );
746 748
747 addView( mTodoView ); 749 addView( mTodoView );
748 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 750 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
749 751
750 // SIGNALS/SLOTS FOR TODO VIEW 752 // SIGNALS/SLOTS FOR TODO VIEW
751 connect( mTodoView, SIGNAL( newTodoSignal() ), 753 connect( mTodoView, SIGNAL( newTodoSignal() ),
752 mMainView, SLOT( newTodo() ) ); 754 mMainView, SLOT( newTodo() ) );
753 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 755 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
754 mMainView, SLOT( newSubTodo( Todo *) ) ); 756 mMainView, SLOT( newSubTodo( Todo *) ) );
755 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 757 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
756 mMainView, SLOT( showTodo( Todo * ) ) ); 758 mMainView, SLOT( showTodo( Todo * ) ) );
757 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 759 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
758 mMainView, SLOT( editTodo( Todo * ) ) ); 760 mMainView, SLOT( editTodo( Todo * ) ) );
759 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 761 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
760 mMainView, SLOT( deleteTodo( Todo * ) ) ); 762 mMainView, SLOT( deleteTodo( Todo * ) ) );
761 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 763 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
762 mMainView, SLOT( purgeCompleted() ) ); 764 mMainView, SLOT( purgeCompleted() ) );
763 765
764 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 766 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
765 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 767 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
766 768
767 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 769 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
768 SLOT( updateConfig() ) ); 770 SLOT( updateConfig() ) );
769 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 771 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
770 SLOT( updateTodo( Todo *, int ) ) ); 772 SLOT( updateTodo( Todo *, int ) ) );
771 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 773 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
772 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 774 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
773 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 775 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
774 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 776 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
775 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 777 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
776 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 778 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
777 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 779 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
778 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 780 mMainView, SLOT ( todo_unsub( Todo * ) ) );
779 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 781 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
780 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 782 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
781 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 783 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
782 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 784 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
783 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 785 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
784 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 786 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
785 KConfig *config = KOGlobals::config(); 787 KConfig *config = KOGlobals::config();
786 mTodoView->restoreLayout(config,"Todo View"); 788 mTodoView->restoreLayout(config,"Todo View");
787 mTodoView->setNavigator( mMainView->dateNavigator() ); 789 mTodoView->setNavigator( mMainView->dateNavigator() );
788 } 790 }
789 791
790 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 792 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
791 globalFlagBlockAgenda = 1; 793 globalFlagBlockAgenda = 1;
792 showView( mTodoView, true ); 794 showView( mTodoView, true );
793 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 795 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
794 mMainView->setScrollBarStep( 7 ); 796 mMainView->setScrollBarStep( 7 );
795 797
796} 798}
797 799
798void KOViewManager::showJournalView() 800void KOViewManager::showJournalView()
799{ 801{
800 //mFlagShowNextxDays = false; 802 //mFlagShowNextxDays = false;
801 if (!mJournalView) { 803 if (!mJournalView) {
802 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 804 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
803 "KOViewManager::JournalView"); 805 "KOViewManager::JournalView");
804 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 806 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
805 SLOT( updateConfig() ) ); 807 SLOT( updateConfig() ) );
806 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 808 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
807 addView(mJournalView); 809 addView(mJournalView);
808 } 810 }
809 811
810 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 812 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
811 showView(mJournalView); 813 showView(mJournalView);
812 mMainView->dateNavigator()->selectDates( 1 ); 814 mMainView->dateNavigator()->selectDates( 1 );
813 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 815 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
814 mMainView->setScrollBarStep( 1 ); 816 mMainView->setScrollBarStep( 1 );
815} 817}
816 818
817void KOViewManager::showTimeSpanView() 819void KOViewManager::showTimeSpanView()
818{ 820{
819 //mFlagShowNextxDays = false; 821 //mFlagShowNextxDays = false;
820 if (!mTimeSpanView) { 822 if (!mTimeSpanView) {
821 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 823 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
822 "KOViewManager::TimeSpanView"); 824 "KOViewManager::TimeSpanView");
823 addView(mTimeSpanView); 825 addView(mTimeSpanView);
824 826
825 mTimeSpanView->readSettings(); 827 mTimeSpanView->readSettings();
826 } 828 }
827 829
828 showView(mTimeSpanView); 830 showView(mTimeSpanView);
829} 831}
830 832
831Incidence *KOViewManager::currentSelection() 833Incidence *KOViewManager::currentSelection()
832{ 834{
833 if (!mCurrentView) return 0; 835 if (!mCurrentView) return 0;
834 if ( mCurrentView == mListView ) { 836 if ( mCurrentView == mListView ) {
835 if ( mListView->currentItem() ) 837 if ( mListView->currentItem() )
836 return mListView->currentItem(); 838 return mListView->currentItem();
837 } 839 }
838 return mCurrentView->selectedIncidences().first(); 840 return mCurrentView->selectedIncidences().first();
839} 841}
840 842
841QDate KOViewManager::currentSelectionDate() 843QDate KOViewManager::currentSelectionDate()
842{ 844{
843 QDate qd; 845 QDate qd;
844 if (mCurrentView) { 846 if (mCurrentView) {
845 DateList qvl = mCurrentView->selectedDates(); 847 DateList qvl = mCurrentView->selectedDates();
846 if (!qvl.isEmpty()) qd = qvl.first(); 848 if (!qvl.isEmpty()) qd = qvl.first();
847 } 849 }
848 return qd; 850 return qd;
849} 851}
850 852
851void KOViewManager::addView(KOrg::BaseView *view) 853void KOViewManager::addView(KOrg::BaseView *view)
852{ 854{
853#if QT_VERSION >= 0x030000 855#if QT_VERSION >= 0x030000
854 mMainView->viewStack()->addWidget( view ); 856 mMainView->viewStack()->addWidget( view );
855#else 857#else
856 mMainView->viewStack()->addWidget( view, 1 ); 858 mMainView->viewStack()->addWidget( view, 1 );
857#endif 859#endif
858} 860}
859 861
860void KOViewManager::setDocumentId( const QString &id ) 862void KOViewManager::setDocumentId( const QString &id )
861{ 863{
862 if (mTodoView) { 864 if (mTodoView) {
863 mTodoView->setDocumentId( id ); 865 mTodoView->setDocumentId( id );
864 } 866 }
865} 867}
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h
index 2e6aaed..2aa46d0 100644
--- a/korganizer/koviewmanager.h
+++ b/korganizer/koviewmanager.h
@@ -1,129 +1,136 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 3 Copyright (c) 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 KOVIEWMANAGER_H 24#ifndef KOVIEWMANAGER_H
25#define KOVIEWMANAGER_H 25#define KOVIEWMANAGER_H
26 26
27#include <qobject.h> 27#include <qobject.h>
28 28
29#include <korganizer/baseview.h> 29#include <korganizer/baseview.h>
30 30
31class CalendarView; 31class CalendarView;
32 32
33class KOListView; 33class KOListView;
34class KOAgendaView; 34class KOAgendaView;
35class KOMonthView; 35class KOMonthView;
36class KOTimeSpanView; 36class KOTimeSpanView;
37class KOTodoView; 37class KOTodoView;
38class KOWhatsNextView; 38class KOWhatsNextView;
39class KOJournalView; 39class KOJournalView;
40 40
41using namespace KCal; 41using namespace KCal;
42 42
43/** 43/**
44 This class manages the views of the calendar. It owns the objects and handles 44 This class manages the views of the calendar. It owns the objects and handles
45 creation and selection. 45 creation and selection.
46*/ 46*/
47class KOViewManager : public QObject 47class KOViewManager : public QObject
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 KOViewManager( CalendarView * ); 51 KOViewManager( CalendarView * );
52 virtual ~KOViewManager(); 52 virtual ~KOViewManager();
53 53
54 /** changes the view to be the currently selected view */ 54 /** changes the view to be the currently selected view */
55 void showView(KOrg::BaseView *, bool fullScreen = false ); 55 void showView(KOrg::BaseView *, bool fullScreen = false );
56 void updateWNview(); 56 void updateWNview();
57 void readSettings(KConfig *config); 57 void readSettings(KConfig *config);
58 void writeSettings(KConfig *config); 58 void writeSettings(KConfig *config);
59 bool showsNextDays(); 59 bool showsNextDays();
60 /** Read which view was shown last from config file */ 60 /** Read which view was shown last from config file */
61 void readCurrentView(KConfig *); 61 void readCurrentView(KConfig *);
62 /** Write which view is currently shown to config file */ 62 /** Write which view is currently shown to config file */
63 void writeCurrentView(KConfig *); 63 void writeCurrentView(KConfig *);
64 64
65 KOrg::BaseView *currentView(); 65 KOrg::BaseView *currentView();
66 66
67 void setDocumentId( const QString & ); 67 void setDocumentId( const QString & );
68 68
69 void updateView( const QDate &start, const QDate &end ); 69 void updateView( const QDate &start, const QDate &end );
70 void clearAllViews(); 70 void clearAllViews();
71 71
72 void raiseCurrentView( bool fullScreen = false , bool updateView = false); 72 void raiseCurrentView( bool fullScreen = false , bool updateView = false);
73 73
74 void addView(KOrg::BaseView *); 74 void addView(KOrg::BaseView *);
75 75
76 Incidence *currentSelection(); 76 Incidence *currentSelection();
77 QDate currentSelectionDate(); 77 QDate currentSelectionDate();
78 78
79 KOAgendaView *agendaView() const { return mAgendaView; } 79 KOAgendaView *agendaView() const { return mAgendaView; }
80 KOJournalView *journalView() const { return mJournalView; } 80 KOJournalView *journalView() const { return mJournalView; }
81 81
82 signals: 82 signals:
83 void printWNV(); 83 void printWNV();
84 void signalFullScreen( bool ); 84 void signalFullScreen( bool );
85 void signalAgendaView( bool ); 85 void signalAgendaView( bool );
86 public slots: 86 public slots:
87 void setDefaultCalendar(int); 87 void setDefaultCalendar(int);
88 void slotprintWNV(); 88 void slotprintWNV();
89 void showNextView(); 89 void showNextView();
90 void showMonth( const QDate & ); 90 void showMonth( const QDate & );
91 void showDateView( int, QDate ); 91 void showDateView( int, QDate );
92 void updateView(); 92 void updateView();
93 void showWhatsNextView(); 93 void showWhatsNextView();
94 void showListView(); 94 void showListView();
95 void showAgendaView( bool fullScreen = false ); 95 void showAgendaView( bool fullScreen = false );
96 void showDayView(); 96 void showDayView();
97 void showWorkWeekView(); 97 void showWorkWeekView();
98 void showWeekView(); 98 void showWeekView();
99 void showNextXView(); 99 void showNextXView();
100 void showMonthView(); 100 void showMonthView();
101 void showMonthViewWeek(); 101 void showMonthViewWeek();
102 void showTodoView(); 102 void showTodoView();
103 void showJournalView(); 103 void showJournalView();
104 void showTimeSpanView(); 104 void showTimeSpanView();
105 105
106 private: 106 private:
107 int lastMode;
108 int lastCount;
109 bool lastNDMode;
110 QDate lastDate;
111 int selecteddatescount;
112 QDate selecteddate;
113 QDate baseCycleDate;
107 void resetDateSilent( QDate date , int days ); 114 void resetDateSilent( QDate date , int days );
108 int flagResetViewChangeDate; 115 int flagResetViewChangeDate;
109 QDate currentViewChangeDate; 116 QDate currentViewChangeDate;
110 void createMonthView(); 117 void createMonthView();
111 CalendarView *mMainView; 118 CalendarView *mMainView;
112 119
113 int mCurrentAgendaView; 120 int mCurrentAgendaView;
114 KOAgendaView *mAgendaView; 121 KOAgendaView *mAgendaView;
115 KOListView *mListView; 122 KOListView *mListView;
116 KOMonthView *mMonthView; 123 KOMonthView *mMonthView;
117 KOTodoView *mTodoView; 124 KOTodoView *mTodoView;
118 KOWhatsNextView *mWhatsNextView; 125 KOWhatsNextView *mWhatsNextView;
119 KOJournalView *mJournalView; 126 KOJournalView *mJournalView;
120 KOTimeSpanView *mTimeSpanView; 127 KOTimeSpanView *mTimeSpanView;
121 128
122 KOrg::BaseView *mCurrentView; // currently active event view 129 KOrg::BaseView *mCurrentView; // currently active event view
123 130
124 int mAgendaViewMode; 131 int mAgendaViewMode;
125 bool mFlagShowNextxDays; 132 bool mFlagShowNextxDays;
126 133
127}; 134};
128 135
129#endif 136#endif