summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp9
-rw-r--r--korganizer/koagendaview.cpp2
-rw-r--r--korganizer/kolistview.cpp68
-rw-r--r--korganizer/kolistview.h5
-rw-r--r--korganizer/koprefs.cpp4
-rw-r--r--korganizer/koprefs.h1
6 files changed, 73 insertions, 16 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 377a66f..2012e92 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4524 +1,4517 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preton.brown@yale.edu) 8 Preston Brown (preton.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
142 142
143{ 143{
144 mAlarms = alarms; 144 mAlarms = alarms;
145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
146 QString mText = "<table width=\"100%\">\n"; 146 QString mText = "<table width=\"100%\">\n";
147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
148#ifdef DESKTOP_VERSION 148#ifdef DESKTOP_VERSION
149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
150#else 150#else
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
152#endif 152#endif
153 // mText += "<img src=\""; 153 // mText += "<img src=\"";
154 // mText += ipath; 154 // mText += ipath;
155 // mText += "\">"; 155 // mText += "\">";
156 //mEventDate = QDate::currentDate(); 156 //mEventDate = QDate::currentDate();
157#ifdef DESKTOP_VERSION 157#ifdef DESKTOP_VERSION
158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
159#else 159#else
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
161#endif 161#endif
162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
163 163
164 Incidence * inc = getNextInc( start ); 164 Incidence * inc = getNextInc( start );
165 int time = 0; 165 int time = 0;
166 //mText += "<table>"; 166 //mText += "<table>";
167 while ( inc ) { 167 while ( inc ) {
168 QDateTime dt ; 168 QDateTime dt ;
169 QString tempText = "<a "; 169 QString tempText = "<a ";
170 bool ok; 170 bool ok;
171 dt = inc->getNextOccurence( start, &ok ); 171 dt = inc->getNextOccurence( start, &ok );
172 if ( !ok ) continue; 172 if ( !ok ) continue;
173 if ( inc->typeID() == eventID ) { 173 if ( inc->typeID() == eventID ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->typeID() == todoID ) { 175 } else if ( inc->typeID() == todoID ) {
176 tempText += "href=\"todo:"; 176 tempText += "href=\"todo:";
177 } 177 }
178 tempText += inc->uid() + "\">"; 178 tempText += inc->uid() + "\">";
179 if ( inc->typeID() == todoID ) 179 if ( inc->typeID() == todoID )
180 tempText += i18n("Todo: "); 180 tempText += i18n("Todo: ");
181 if ( inc->summary().length() > 0 ) 181 if ( inc->summary().length() > 0 )
182 tempText += inc->summary(); 182 tempText += inc->summary();
183 else 183 else
184 tempText += i18n("-no summary-"); 184 tempText += i18n("-no summary-");
185 QString timestr; 185 QString timestr;
186 if (!inc->doesFloat()) 186 if (!inc->doesFloat())
187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
188 else 188 else
189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
190 if ( dt.date() < QDate::currentDate() && time == 0 ) { 190 if ( dt.date() < QDate::currentDate() && time == 0 ) {
191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
192 mText += "<table>"; 192 mText += "<table>";
193 time = 1; 193 time = 1;
194 } 194 }
195 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 195 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
196 if ( time > 0 ) 196 if ( time > 0 )
197 mText +="</table>"; 197 mText +="</table>";
198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
199 mText += "<table>"; 199 mText += "<table>";
200 time = 2; 200 time = 2;
201 201
202 } 202 }
203 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 203 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
204 if ( time > 0 ) 204 if ( time > 0 )
205 mText +="</table>"; 205 mText +="</table>";
206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
207 mText += "<table>"; 207 mText += "<table>";
208 time = 3; 208 time = 3;
209 } 209 }
210 mText +="<tr><td><b>"; 210 mText +="<tr><td><b>";
211 mText += timestr; 211 mText += timestr;
212 mText += "</b></td><td>"; 212 mText += "</b></td><td>";
213 mText += tempText; 213 mText += tempText;
214 mText += "</td></tr>\n"; 214 mText += "</td></tr>\n";
215 inc = getNextInc( start ); 215 inc = getNextInc( start );
216 } 216 }
217 mText +="</table>"; 217 mText +="</table>";
218 setText( mText ); 218 setText( mText );
219} 219}
220 220
221MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 221MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
222{ 222{
223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
224} 224}
225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
226{ 226{
227 QDateTime dt ; 227 QDateTime dt ;
228 Incidence * retInc; 228 Incidence * retInc;
229 Incidence * inc = mAlarms.first(); 229 Incidence * inc = mAlarms.first();
230 if ( inc == 0 ) 230 if ( inc == 0 )
231 return 0; 231 return 0;
232 bool ok; 232 bool ok;
233 dt = inc->getNextOccurence( start, &ok ); 233 dt = inc->getNextOccurence( start, &ok );
234 if ( ! ok ) return 0; 234 if ( ! ok ) return 0;
235 QDateTime dtn ; 235 QDateTime dtn ;
236 retInc = inc; 236 retInc = inc;
237 inc = mAlarms.next(); 237 inc = mAlarms.next();
238 while ( inc ) { 238 while ( inc ) {
239 dtn = inc->getNextOccurence( start, &ok ); 239 dtn = inc->getNextOccurence( start, &ok );
240 if ( ! ok ) return 0; 240 if ( ! ok ) return 0;
241 if ( dtn < dt ) { 241 if ( dtn < dt ) {
242 dt = dtn; 242 dt = dtn;
243 retInc = inc; 243 retInc = inc;
244 } 244 }
245 inc = mAlarms.next(); 245 inc = mAlarms.next();
246 } 246 }
247 mAlarms.remove( retInc ); 247 mAlarms.remove( retInc );
248 return retInc; 248 return retInc;
249 249
250} 250}
251void MissedAlarmTextBrowser::setSource(const QString & n) 251void MissedAlarmTextBrowser::setSource(const QString & n)
252{ 252{
253 if (n.startsWith("event:")) { 253 if (n.startsWith("event:")) {
254#ifdef DESKTOP_VERSION 254#ifdef DESKTOP_VERSION
255 emit showIncidence(n.mid(8)); 255 emit showIncidence(n.mid(8));
256#else 256#else
257 emit showIncidence(n.mid(6)); 257 emit showIncidence(n.mid(6));
258#endif 258#endif
259 return; 259 return;
260 } else if (n.startsWith("todo:")) { 260 } else if (n.startsWith("todo:")) {
261#ifdef DESKTOP_VERSION 261#ifdef DESKTOP_VERSION
262 emit showIncidence(n.mid(7)); 262 emit showIncidence(n.mid(7));
263#else 263#else
264 emit showIncidence(n.mid(5)); 264 emit showIncidence(n.mid(5));
265#endif 265#endif
266 return; 266 return;
267 } 267 }
268} 268}
269 269
270 270
271class KOBeamPrefs : public QDialog 271class KOBeamPrefs : public QDialog
272{ 272{
273 public: 273 public:
274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
275 QDialog( parent, name, true ) 275 QDialog( parent, name, true )
276 { 276 {
277 setCaption( i18n("Beam Options") ); 277 setCaption( i18n("Beam Options") );
278 QVBoxLayout* lay = new QVBoxLayout( this ); 278 QVBoxLayout* lay = new QVBoxLayout( this );
279 lay->setSpacing( 3 ); 279 lay->setSpacing( 3 );
280 lay->setMargin( 3 ); 280 lay->setMargin( 3 );
281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
282 lay->addWidget( format ); 282 lay->addWidget( format );
283 format->setExclusive ( true ) ; 283 format->setExclusive ( true ) ;
284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
285 lay->addWidget( time ); time->setExclusive ( true ) ; 285 lay->addWidget( time ); time->setExclusive ( true ) ;
286 vcal = new QRadioButton(" vCalendar ", format ); 286 vcal = new QRadioButton(" vCalendar ", format );
287 ical = new QRadioButton(" iCalendar ", format ); 287 ical = new QRadioButton(" iCalendar ", format );
288 vcal->setChecked( true ); 288 vcal->setChecked( true );
289 tz = new QRadioButton(i18n(" With timezone "), time ); 289 tz = new QRadioButton(i18n(" With timezone "), time );
290 local = new QRadioButton(i18n(" Local time "), time ); 290 local = new QRadioButton(i18n(" Local time "), time );
291 tz->setChecked( true ); 291 tz->setChecked( true );
292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
293 lay->addWidget( ok ); 293 lay->addWidget( ok );
294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
295 lay->addWidget( cancel ); 295 lay->addWidget( cancel );
296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
298 resize( 200, 200 ); 298 resize( 200, 200 );
299 } 299 }
300 300
301 bool beamVcal() { return vcal->isChecked(); } 301 bool beamVcal() { return vcal->isChecked(); }
302 bool beamLocal() { return local->isChecked(); } 302 bool beamLocal() { return local->isChecked(); }
303private: 303private:
304 QRadioButton* vcal, *ical, *local, *tz; 304 QRadioButton* vcal, *ical, *local, *tz;
305}; 305};
306class KOCatPrefs : public QDialog 306class KOCatPrefs : public QDialog
307{ 307{
308 public: 308 public:
309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
310 QDialog( parent, name, true ) 310 QDialog( parent, name, true )
311 { 311 {
312 setCaption( i18n("Manage new Categories") ); 312 setCaption( i18n("Manage new Categories") );
313 QVBoxLayout* lay = new QVBoxLayout( this ); 313 QVBoxLayout* lay = new QVBoxLayout( this );
314 lay->setSpacing( 3 ); 314 lay->setSpacing( 3 );
315 lay->setMargin( 3 ); 315 lay->setMargin( 3 );
316 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 316 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
317 lay->addWidget( lab ); 317 lay->addWidget( lab );
318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
319 lay->addWidget( format ); 319 lay->addWidget( format );
320 format->setExclusive ( true ) ; 320 format->setExclusive ( true ) ;
321 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 321 addCatBut = new QRadioButton(i18n("Add to category list"), format );
322 new QRadioButton(i18n("Remove from Events/Todos"), format ); 322 new QRadioButton(i18n("Remove from Events/Todos"), format );
323 addCatBut->setChecked( true ); 323 addCatBut->setChecked( true );
324 QPushButton * ok = new QPushButton( i18n("OK"), this ); 324 QPushButton * ok = new QPushButton( i18n("OK"), this );
325 lay->addWidget( ok ); 325 lay->addWidget( ok );
326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
327 lay->addWidget( cancel ); 327 lay->addWidget( cancel );
328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
330 resize( 200, 200 ); 330 resize( 200, 200 );
331 } 331 }
332 332
333 bool addCat() { return addCatBut->isChecked(); } 333 bool addCat() { return addCatBut->isChecked(); }
334private: 334private:
335 QRadioButton* addCatBut; 335 QRadioButton* addCatBut;
336}; 336};
337 337
338 338
339 339
340CalendarView::CalendarView( CalendarResources *calendar, 340CalendarView::CalendarView( CalendarResources *calendar,
341 QWidget *parent, const char *name ) 341 QWidget *parent, const char *name )
342 : CalendarViewBase( parent, name ), 342 : CalendarViewBase( parent, name ),
343 mCalendar( calendar ), 343 mCalendar( calendar ),
344 mResourceManager( calendar->resourceManager() ) 344 mResourceManager( calendar->resourceManager() )
345{ 345{
346 346
347 mEventEditor = 0; 347 mEventEditor = 0;
348 mTodoEditor = 0; 348 mTodoEditor = 0;
349 349
350 init(); 350 init();
351} 351}
352 352
353CalendarView::CalendarView( Calendar *calendar, 353CalendarView::CalendarView( Calendar *calendar,
354 QWidget *parent, const char *name ) 354 QWidget *parent, const char *name )
355 : CalendarViewBase( parent, name ), 355 : CalendarViewBase( parent, name ),
356 mCalendar( calendar ), 356 mCalendar( calendar ),
357 mResourceManager( 0 ) 357 mResourceManager( 0 )
358{ 358{
359 359
360 mEventEditor = 0; 360 mEventEditor = 0;
361 mTodoEditor = 0; 361 mTodoEditor = 0;
362 init(); 362 init();
363} 363}
364 364
365void CalendarView::init() 365void CalendarView::init()
366{ 366{
367 mNextAlarmDateTime = QDateTime::currentDateTime(); 367 mNextAlarmDateTime = QDateTime::currentDateTime();
368 setFocusPolicy ( NoFocus ); 368 setFocusPolicy ( NoFocus );
369 mViewerCallerIsSearchDialog = false; 369 mViewerCallerIsSearchDialog = false;
370 mBlockShowDates = false; 370 mBlockShowDates = false;
371 beamDialog = new KOBeamPrefs(); 371 beamDialog = new KOBeamPrefs();
372 mDatePickerMode = 0; 372 mDatePickerMode = 0;
373 mCurrentSyncDevice = ""; 373 mCurrentSyncDevice = "";
374 writeLocale(); 374 writeLocale();
375 mViewManager = new KOViewManager( this ); 375 mViewManager = new KOViewManager( this );
376 mDialogManager = new KODialogManager( this ); 376 mDialogManager = new KODialogManager( this );
377 mEventViewerDialog = 0; 377 mEventViewerDialog = 0;
378 mModified = false; 378 mModified = false;
379 mReadOnly = false; 379 mReadOnly = false;
380 mSelectedIncidence = 0; 380 mSelectedIncidence = 0;
381 mCalPrinter = 0; 381 mCalPrinter = 0;
382 mFilters.setAutoDelete(true); 382 mFilters.setAutoDelete(true);
383 383
384 mCalendar->registerObserver( this ); 384 mCalendar->registerObserver( this );
385 // TODO: Make sure that view is updated, when calendar is changed. 385 // TODO: Make sure that view is updated, when calendar is changed.
386 386
387 mStorage = new FileStorage( mCalendar ); 387 mStorage = new FileStorage( mCalendar );
388 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 388 mNavigator = new DateNavigator( this, "datevav", mViewManager );
389 389
390 QBoxLayout *topLayout = (QBoxLayout*)layout(); 390 QBoxLayout *topLayout = (QBoxLayout*)layout();
391#ifndef KORG_NOSPLITTER 391#ifndef KORG_NOSPLITTER
392 // create the main layout frames. 392 // create the main layout frames.
393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
394 topLayout->addWidget(mPanner); 394 topLayout->addWidget(mPanner);
395 395
396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
397 "CalendarView::LeftFrame"); 397 "CalendarView::LeftFrame");
398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
399 399
400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
401 "CalendarView::DateNavigator" ); 401 "CalendarView::DateNavigator" );
402 402
403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
405 mTodoList->setNavigator( mNavigator ); 405 mTodoList->setNavigator( mNavigator );
406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
407 407
408#ifdef KORG_NORESOURCEVIEW 408#ifdef KORG_NORESOURCEVIEW
409 mResourceView = 0; 409 mResourceView = 0;
410#else 410#else
411 if ( mResourceManager ) { 411 if ( mResourceManager ) {
412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
413 mResourceView->updateView(); 413 mResourceView->updateView();
414 connect( mResourceView, SIGNAL( resourcesChanged() ), 414 connect( mResourceView, SIGNAL( resourcesChanged() ),
415 SLOT( updateView() ) ); 415 SLOT( updateView() ) );
416 } else { 416 } else {
417 mResourceView = 0; 417 mResourceView = 0;
418 } 418 }
419#endif 419#endif
420 QWidget *rightBox = new QWidget( mPanner ); 420 QWidget *rightBox = new QWidget( mPanner );
421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
422 422
423 mRightFrame = new QWidgetStack( rightBox ); 423 mRightFrame = new QWidgetStack( rightBox );
424 rightLayout->addWidget( mRightFrame, 1 ); 424 rightLayout->addWidget( mRightFrame, 1 );
425 425
426 mLeftFrame = mLeftSplitter; 426 mLeftFrame = mLeftSplitter;
427#else 427#else
428 //QWidget *mainBox = new QWidget( this ); 428 //QWidget *mainBox = new QWidget( this );
429 //QWidget *leftFrame = new QWidget( mainBox ); 429 //QWidget *leftFrame = new QWidget( mainBox );
430 //QBoxLayout * mainBoxLayout; 430 //QBoxLayout * mainBoxLayout;
431 if ( KOPrefs::instance()->mVerticalScreen ) { 431 if ( KOPrefs::instance()->mVerticalScreen ) {
432 //mainBoxLayout = new QVBoxLayout(mainBox); 432 //mainBoxLayout = new QVBoxLayout(mainBox);
433 //leftFrameLayout = new QHBoxLayout(leftFrame ); 433 //leftFrameLayout = new QHBoxLayout(leftFrame );
434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
438 } else { 438 } else {
439 //mainBoxLayout = new QHBoxLayout(mainBox); 439 //mainBoxLayout = new QHBoxLayout(mainBox);
440 //leftFrameLayout = new QVBoxLayout(leftFrame ); 440 //leftFrameLayout = new QVBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
445 } 445 }
446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
447 //QBoxLayout * leftFrameLayout; 447 //QBoxLayout * leftFrameLayout;
448 topLayout->addWidget( mMainFrame ); 448 topLayout->addWidget( mMainFrame );
449 //mainBoxLayout->addWidget (mLeftFrame); 449 //mainBoxLayout->addWidget (mLeftFrame);
450 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 450 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
451 "CalendarView::DateNavigator" ); 451 "CalendarView::DateNavigator" );
452#if 0 452#if 0
453 // FIXME 453 // FIXME
454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
455 "CalendarView::DateNavigator", QDate::currentDate()); 455 "CalendarView::DateNavigator", QDate::currentDate());
456#endif 456#endif
457 // mDateNavigator->blockSignals( true ); 457 // mDateNavigator->blockSignals( true );
458 //leftFrameLayout->addWidget( mDateNavigator ); 458 //leftFrameLayout->addWidget( mDateNavigator );
459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
462 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 462 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
463 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 463 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
464 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); 464 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
465 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 465 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
466 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 466 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
467 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 467 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
468 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 468 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
469 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 469 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
470 mTodoList->setNavigator( mNavigator ); 470 mTodoList->setNavigator( mNavigator );
471#if 0 471#if 0
472 if ( QApplication::desktop()->width() < 480 ) { 472 if ( QApplication::desktop()->width() < 480 ) {
473 leftFrameLayout->addWidget(mFilterView); 473 leftFrameLayout->addWidget(mFilterView);
474 leftFrameLayout->addWidget(mTodoList, 2 ); 474 leftFrameLayout->addWidget(mTodoList, 2 );
475 475
476 } else { 476 } else {
477 leftFrameLayout->addWidget(mTodoList,2 ); 477 leftFrameLayout->addWidget(mTodoList,2 );
478 leftFrameLayout->addWidget(mFilterView ); 478 leftFrameLayout->addWidget(mFilterView );
479 } 479 }
480#endif 480#endif
481 mFilterView->hide(); 481 mFilterView->hide();
482 mCalEditView->hide(); 482 mCalEditView->hide();
483 QWidget *rightBox = new QWidget( mMainFrame ); 483 QWidget *rightBox = new QWidget( mMainFrame );
484 //mainBoxLayout->addWidget ( rightBox, 10 ); 484 //mainBoxLayout->addWidget ( rightBox, 10 );
485 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 485 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
486 mRightFrame = new QWidgetStack( rightBox ); 486 mRightFrame = new QWidgetStack( rightBox );
487 rightLayout->addWidget( mRightFrame, 10 ); 487 rightLayout->addWidget( mRightFrame, 10 );
488 488
489 //mLeftFrame = (QWidget *)leftFrame; 489 //mLeftFrame = (QWidget *)leftFrame;
490 if ( KOPrefs::instance()->mVerticalScreen ) { 490 if ( KOPrefs::instance()->mVerticalScreen ) {
491 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 491 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
492 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 492 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
493 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 493 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
494 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 494 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
495 } else { 495 } else {
496 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 496 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
497 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 497 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
498 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 498 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
499 } 499 }
500 if ( !KOPrefs::instance()->mShowDateNavigator) 500 if ( !KOPrefs::instance()->mShowDateNavigator)
501 mDateNavigator->hide(); 501 mDateNavigator->hide();
502 //qDebug("Calendarview Size %d %d ", width(), height()); 502 //qDebug("Calendarview Size %d %d ", width(), height());
503#endif 503#endif
504 504
505 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 505 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
506 SLOT( showDates( const KCal::DateList & ) ) ); 506 SLOT( showDates( const KCal::DateList & ) ) );
507 507
508 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 508 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
509 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 509 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
510 510
511 511
512 512
513 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 513 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
514 mViewManager, SLOT( showMonth( const QDate & ) ) ); 514 mViewManager, SLOT( showMonth( const QDate & ) ) );
515 515
516 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 516 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
517 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 517 mNavigator, SLOT( selectWeek( const QDate & ) ) );
518 518
519 connect( mDateNavigator, SIGNAL( goPrevYear() ), 519 connect( mDateNavigator, SIGNAL( goPrevYear() ),
520 mNavigator, SLOT( selectPreviousYear() ) ); 520 mNavigator, SLOT( selectPreviousYear() ) );
521 connect( mDateNavigator, SIGNAL( goNextYear() ), 521 connect( mDateNavigator, SIGNAL( goNextYear() ),
522 mNavigator, SLOT( selectNextYear() ) ); 522 mNavigator, SLOT( selectNextYear() ) );
523 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 523 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
524 mNavigator, SLOT( selectPreviousMonth() ) ); 524 mNavigator, SLOT( selectPreviousMonth() ) );
525 connect( mDateNavigator, SIGNAL( goNextMonth() ), 525 connect( mDateNavigator, SIGNAL( goNextMonth() ),
526 mNavigator, SLOT( selectNextMonth() ) ); 526 mNavigator, SLOT( selectNextMonth() ) );
527 527
528 connect( mDateNavigator, SIGNAL( goPrevious() ), 528 connect( mDateNavigator, SIGNAL( goPrevious() ),
529 mNavigator, SLOT( selectPrevious() ) ); 529 mNavigator, SLOT( selectPrevious() ) );
530 connect( mDateNavigator, SIGNAL( goNext() ), 530 connect( mDateNavigator, SIGNAL( goNext() ),
531 mNavigator, SLOT( selectNext() ) ); 531 mNavigator, SLOT( selectNext() ) );
532 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 532 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
533 mNavigator, SLOT( slotMonthSelect( int ) ) ); 533 mNavigator, SLOT( slotMonthSelect( int ) ) );
534 534
535 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 535 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
536 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 536 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
537#if 0 537#if 0
538 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 538 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
539 SLOT( incidenceAdded( Incidence *) ) ); 539 SLOT( incidenceAdded( Incidence *) ) );
540#endif 540#endif
541 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 541 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
542 542
543 connect( this, SIGNAL( configChanged() ), 543 connect( this, SIGNAL( configChanged() ),
544 mDateNavigator, SLOT( updateConfig() ) ); 544 mDateNavigator, SLOT( updateConfig() ) );
545 545
546 connect( mTodoList, SIGNAL( newTodoSignal() ), 546 connect( mTodoList, SIGNAL( newTodoSignal() ),
547 SLOT( newTodo() ) ); 547 SLOT( newTodo() ) );
548 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 548 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
549 SLOT( newSubTodo( Todo * ) ) ); 549 SLOT( newSubTodo( Todo * ) ) );
550 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 550 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
551 SLOT( editTodo( Todo * ) ) ); 551 SLOT( editTodo( Todo * ) ) );
552 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 552 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
553 SLOT( showTodo( Todo *) ) ); 553 SLOT( showTodo( Todo *) ) );
554 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 554 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
555 SLOT( deleteTodo( Todo *) ) ); 555 SLOT( deleteTodo( Todo *) ) );
556 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 556 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
557 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 557 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
558 SLOT( purgeCompleted() ) ); 558 SLOT( purgeCompleted() ) );
559 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 559 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
560 SIGNAL( todoModified( Todo *, int ) ) ); 560 SIGNAL( todoModified( Todo *, int ) ) );
561 561
562 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 562 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
563 this, SLOT ( cloneIncidence( Incidence * ) ) ); 563 this, SLOT ( cloneIncidence( Incidence * ) ) );
564 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 564 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
565 this, SLOT (cancelIncidence( Incidence * ) ) ); 565 this, SLOT (cancelIncidence( Incidence * ) ) );
566 566
567 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 567 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
568 this, SLOT ( moveIncidence( Incidence * ) ) ); 568 this, SLOT ( moveIncidence( Incidence * ) ) );
569 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 569 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
570 this, SLOT ( beamIncidence( Incidence * ) ) ); 570 this, SLOT ( beamIncidence( Incidence * ) ) );
571 571
572 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 572 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
573 this, SLOT ( todo_unsub( Todo * ) ) ); 573 this, SLOT ( todo_unsub( Todo * ) ) );
574 574
575 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 575 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
576 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 576 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
577 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 577 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
578 SLOT( updateTodo( Todo *, int ) ) ); 578 SLOT( updateTodo( Todo *, int ) ) );
579 connect( this, SIGNAL( todoModified( Todo *, int )), this, 579 connect( this, SIGNAL( todoModified( Todo *, int )), this,
580 SLOT( changeTodoDisplay( Todo *, int ) ) ); 580 SLOT( changeTodoDisplay( Todo *, int ) ) );
581 581
582 582
583 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 583 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
584 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 584 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
585 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 585 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
586 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 586 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
587 587
588 588
589 589
590 590
591 591
592 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 592 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
593 SLOT(checkClipboard())); 593 SLOT(checkClipboard()));
594 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 594 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
595 SLOT( processTodoListSelection( Incidence * ) ) ); 595 SLOT( processTodoListSelection( Incidence * ) ) );
596 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 596 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
597 597
598 // kdDebug() << "CalendarView::CalendarView() done" << endl; 598 // kdDebug() << "CalendarView::CalendarView() done" << endl;
599 599
600 mDateFrame = new QVBox(0,0,WType_Popup); 600 mDateFrame = new QVBox(0,0,WType_Popup);
601 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 601 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
602 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 602 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
603 mDateFrame->setLineWidth(3); 603 mDateFrame->setLineWidth(3);
604 mDateFrame->hide(); 604 mDateFrame->hide();
605 mDateFrame->setCaption( i18n( "Pick a date to display")); 605 mDateFrame->setCaption( i18n( "Pick a date to display"));
606 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 606 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
607 607
608 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 608 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
609 609
610 mEventEditor = mDialogManager->getEventEditor(); 610 mEventEditor = mDialogManager->getEventEditor();
611 mTodoEditor = mDialogManager->getTodoEditor(); 611 mTodoEditor = mDialogManager->getTodoEditor();
612 612
613 mFlagEditDescription = false; 613 mFlagEditDescription = false;
614 614
615 mSuspendTimer = new QTimer( this ); 615 mSuspendTimer = new QTimer( this );
616 mAlarmTimer = new QTimer( this ); 616 mAlarmTimer = new QTimer( this );
617 mRecheckAlarmTimer = new QTimer( this ); 617 mRecheckAlarmTimer = new QTimer( this );
618 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 618 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
619 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 619 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
620 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 620 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
621 mAlarmDialog = new AlarmDialog( this ); 621 mAlarmDialog = new AlarmDialog( this );
622 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 622 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
623 mAlarmDialog->setServerNotification( false ); 623 mAlarmDialog->setServerNotification( false );
624 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 624 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
625 625
626 626
627#ifndef DESKTOP_VERSION 627#ifndef DESKTOP_VERSION
628//US listen for arriving address resultsets 628//US listen for arriving address resultsets
629 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 629 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
630 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 630 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
631#endif 631#endif
632 mDateNavigator->setCalendar( mCalendar ); 632 mDateNavigator->setCalendar( mCalendar );
633} 633}
634 634
635 635
636CalendarView::~CalendarView() 636CalendarView::~CalendarView()
637{ 637{
638 // kdDebug() << "~CalendarView()" << endl; 638 // kdDebug() << "~CalendarView()" << endl;
639 //qDebug("CalendarView::~CalendarView() "); 639 //qDebug("CalendarView::~CalendarView() ");
640 delete mDialogManager; 640 delete mDialogManager;
641 delete mViewManager; 641 delete mViewManager;
642 delete mStorage; 642 delete mStorage;
643 delete mDateFrame ; 643 delete mDateFrame ;
644 delete beamDialog; 644 delete beamDialog;
645 delete mEventViewerDialog; 645 delete mEventViewerDialog;
646 //kdDebug() << "~CalendarView() done" << endl; 646 //kdDebug() << "~CalendarView() done" << endl;
647} 647}
648void CalendarView::checkAlarms() 648void CalendarView::checkAlarms()
649{ 649{
650 KConfig *config = KOGlobals::config(); 650 KConfig *config = KOGlobals::config();
651 config->setGroup( "AppRun" ); 651 config->setGroup( "AppRun" );
652 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 652 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
653 int daysto = dt.daysTo( QDate::currentDate() ); 653 int daysto = dt.daysTo( QDate::currentDate() );
654 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 654 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
655 dt = dt.addDays( days ); 655 dt = dt.addDays( days );
656 int secto = dt.secsTo( QDateTime::currentDateTime() ); 656 int secto = dt.secsTo( QDateTime::currentDateTime() );
657 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 657 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
658 //qDebug("KO: Reading program stop %d ", secs); 658 //qDebug("KO: Reading program stop %d ", secs);
659 //secs -= ( 3600 * 24*3 ); // debug only 659 //secs -= ( 3600 * 24*3 ); // debug only
660 QDateTime latest = dt.addSecs ( secs ); 660 QDateTime latest = dt.addSecs ( secs );
661 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 661 qDebug("KO: Last termination on %s ", latest.toString().latin1());
662 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 662 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
663 QPtrList<Incidence> el = mCalendar->rawIncidences(); 663 QPtrList<Incidence> el = mCalendar->rawIncidences();
664 QPtrList<Incidence> al; 664 QPtrList<Incidence> al;
665 Incidence* inL = el.first(); 665 Incidence* inL = el.first();
666 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 666 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
667 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 667 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
668 while ( inL ) { 668 while ( inL ) {
669 bool ok = false; 669 bool ok = false;
670 int offset = 0; 670 int offset = 0;
671 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 671 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
672 if ( ok ) { 672 if ( ok ) {
673 //qDebug("OK %s",next.toString().latin1()); 673 //qDebug("OK %s",next.toString().latin1());
674 if ( next < cur ) { 674 if ( next < cur ) {
675 al.append( inL ); 675 al.append( inL );
676 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 676 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
677 } 677 }
678 } 678 }
679 inL = el.next(); 679 inL = el.next();
680 } 680 }
681 if ( al.count() ) { 681 if ( al.count() ) {
682 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 682 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
683 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 683 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
684 QVBoxLayout* lay = new QVBoxLayout( dia ); 684 QVBoxLayout* lay = new QVBoxLayout( dia );
685 lay->setSpacing( 0 ); 685 lay->setSpacing( 0 );
686 lay->setMargin( 0 ); 686 lay->setMargin( 0 );
687 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 687 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
688 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 688 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
689 lay->addWidget( matb ); 689 lay->addWidget( matb );
690 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 690 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
691 int wid = 210; 691 int wid = 210;
692 int x = QApplication::desktop()->width() - wid - 7; 692 int x = QApplication::desktop()->width() - wid - 7;
693 int y = QApplication::desktop()->height() - wid - 70; 693 int y = QApplication::desktop()->height() - wid - 70;
694 dia->setGeometry ( x,y,wid,wid); 694 dia->setGeometry ( x,y,wid,wid);
695 } else { 695 } else {
696 int si = 220; 696 int si = 220;
697 if ( QApplication::desktop()->width() > 470 ) 697 if ( QApplication::desktop()->width() > 470 )
698 si = 400; 698 si = 400;
699 dia->resize(si,si/2); 699 dia->resize(si,si/2);
700 } 700 }
701 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 701 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
702 dia->show(); 702 dia->show();
703 703
704 } 704 }
705} 705}
706void CalendarView::showDay( QDate d ) 706void CalendarView::showDay( QDate d )
707{ 707{
708 dateNavigator()->blockSignals( true ); 708 dateNavigator()->blockSignals( true );
709 dateNavigator()->selectDate( d ); 709 dateNavigator()->selectDate( d );
710 dateNavigator()->blockSignals( false ); 710 dateNavigator()->blockSignals( false );
711 mViewManager->showDayView(); 711 mViewManager->showDayView();
712 //dateNavigator()->selectDate( d ); 712 //dateNavigator()->selectDate( d );
713} 713}
714void CalendarView::timerAlarm() 714void CalendarView::timerAlarm()
715{ 715{
716 //qDebug("CalendarView::timerAlarm() "); 716 //qDebug("CalendarView::timerAlarm() ");
717 computeAlarm(mAlarmNotification ); 717 computeAlarm(mAlarmNotification );
718} 718}
719 719
720void CalendarView::suspendAlarm() 720void CalendarView::suspendAlarm()
721{ 721{
722 //qDebug(" CalendarView::suspendAlarm() "); 722 //qDebug(" CalendarView::suspendAlarm() ");
723 computeAlarm(mSuspendAlarmNotification ); 723 computeAlarm(mSuspendAlarmNotification );
724 724
725} 725}
726 726
727void CalendarView::startAlarm( QString mess , QString filename) 727void CalendarView::startAlarm( QString mess , QString filename)
728{ 728{
729 729
730 topLevelWidget()->showNormal(); 730 topLevelWidget()->showNormal();
731 topLevelWidget()->setActiveWindow(); 731 topLevelWidget()->setActiveWindow();
732 topLevelWidget()->raise(); 732 topLevelWidget()->raise();
733 733
734 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 734 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
735 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 735 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
736 736
737} 737}
738 738
739void CalendarView::checkNextTimerAlarm() 739void CalendarView::checkNextTimerAlarm()
740{ 740{
741 mCalendar->checkAlarmForIncidence( 0, true ); 741 mCalendar->checkAlarmForIncidence( 0, true );
742} 742}
743 743
744void CalendarView::computeAlarm( QString msg ) 744void CalendarView::computeAlarm( QString msg )
745{ 745{
746 746
747 QString mess = msg; 747 QString mess = msg;
748 QString mAlarmMessage = mess.mid( 9 ); 748 QString mAlarmMessage = mess.mid( 9 );
749 QString filename = MainWindow::resourcePath(); 749 QString filename = MainWindow::resourcePath();
750 filename += "koalarm.wav"; 750 filename += "koalarm.wav";
751 QString tempfilename; 751 QString tempfilename;
752 if ( mess.left( 13 ) == "suspend_alarm") { 752 if ( mess.left( 13 ) == "suspend_alarm") {
753 bool error = false; 753 bool error = false;
754 int len = mess.mid( 13 ).find("+++"); 754 int len = mess.mid( 13 ).find("+++");
755 if ( len < 2 ) 755 if ( len < 2 )
756 error = true; 756 error = true;
757 else { 757 else {
758 tempfilename = mess.mid( 13, len ); 758 tempfilename = mess.mid( 13, len );
759 if ( !QFile::exists( tempfilename ) ) 759 if ( !QFile::exists( tempfilename ) )
760 error = true; 760 error = true;
761 } 761 }
762 if ( ! error ) { 762 if ( ! error ) {
763 filename = tempfilename; 763 filename = tempfilename;
764 } 764 }
765 mAlarmMessage = mess.mid( 13+len+3 ); 765 mAlarmMessage = mess.mid( 13+len+3 );
766 //qDebug("suspend file %s ",tempfilename.latin1() ); 766 //qDebug("suspend file %s ",tempfilename.latin1() );
767 startAlarm( mAlarmMessage, filename); 767 startAlarm( mAlarmMessage, filename);
768 return; 768 return;
769 } 769 }
770 if ( mess.left( 11 ) == "timer_alarm") { 770 if ( mess.left( 11 ) == "timer_alarm") {
771 //mTimerTime = 0; 771 //mTimerTime = 0;
772 startAlarm( mess.mid( 11 ), filename ); 772 startAlarm( mess.mid( 11 ), filename );
773 return; 773 return;
774 } 774 }
775 if ( mess.left( 10 ) == "proc_alarm") { 775 if ( mess.left( 10 ) == "proc_alarm") {
776 bool error = false; 776 bool error = false;
777 int len = mess.mid( 10 ).find("+++"); 777 int len = mess.mid( 10 ).find("+++");
778 if ( len < 2 ) 778 if ( len < 2 )
779 error = true; 779 error = true;
780 else { 780 else {
781 tempfilename = mess.mid( 10, len ); 781 tempfilename = mess.mid( 10, len );
782 if ( !QFile::exists( tempfilename ) ) 782 if ( !QFile::exists( tempfilename ) )
783 error = true; 783 error = true;
784 } 784 }
785 if ( error ) { 785 if ( error ) {
786 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 786 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
787 mAlarmMessage += mess.mid( 10+len+3+9 ); 787 mAlarmMessage += mess.mid( 10+len+3+9 );
788 } else { 788 } else {
789 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 789 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
790 //qDebug("-----system command %s ",tempfilename.latin1() ); 790 //qDebug("-----system command %s ",tempfilename.latin1() );
791#ifndef _WIN32_ 791#ifndef _WIN32_
792 if ( vfork () == 0 ) { 792 if ( vfork () == 0 ) {
793 execl ( tempfilename.latin1(), 0 ); 793 execl ( tempfilename.latin1(), 0 );
794 return; 794 return;
795 } 795 }
796#else 796#else
797 QProcess* p = new QProcess(); 797 QProcess* p = new QProcess();
798 p->addArgument( tempfilename.latin1() ); 798 p->addArgument( tempfilename.latin1() );
799 p->start(); 799 p->start();
800 return; 800 return;
801#endif 801#endif
802 802
803 return; 803 return;
804 } 804 }
805 805
806 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 806 //qDebug("+++++++system command %s ",tempfilename.latin1() );
807 } 807 }
808 if ( mess.left( 11 ) == "audio_alarm") { 808 if ( mess.left( 11 ) == "audio_alarm") {
809 bool error = false; 809 bool error = false;
810 int len = mess.mid( 11 ).find("+++"); 810 int len = mess.mid( 11 ).find("+++");
811 if ( len < 2 ) 811 if ( len < 2 )
812 error = true; 812 error = true;
813 else { 813 else {
814 tempfilename = mess.mid( 11, len ); 814 tempfilename = mess.mid( 11, len );
815 if ( !QFile::exists( tempfilename ) ) 815 if ( !QFile::exists( tempfilename ) )
816 error = true; 816 error = true;
817 } 817 }
818 if ( ! error ) { 818 if ( ! error ) {
819 filename = tempfilename; 819 filename = tempfilename;
820 } 820 }
821 mAlarmMessage = mess.mid( 11+len+3+9 ); 821 mAlarmMessage = mess.mid( 11+len+3+9 );
822 //qDebug("audio file command %s ",tempfilename.latin1() ); 822 //qDebug("audio file command %s ",tempfilename.latin1() );
823 } 823 }
824 if ( mess.left( 9 ) == "cal_alarm") { 824 if ( mess.left( 9 ) == "cal_alarm") {
825 mAlarmMessage = mess.mid( 9 ) ; 825 mAlarmMessage = mess.mid( 9 ) ;
826 } 826 }
827 827
828 startAlarm( mAlarmMessage, filename ); 828 startAlarm( mAlarmMessage, filename );
829 829
830 830
831} 831}
832 832
833void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 833void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
834{ 834{
835 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 835 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
836 836
837 mSuspendAlarmNotification = noti; 837 mSuspendAlarmNotification = noti;
838 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 838 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
839 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 839 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
840 mSuspendTimer->start( ms , true ); 840 mSuspendTimer->start( ms , true );
841 841
842} 842}
843 843
844void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 844void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
845{ 845{
846 mNextAlarmDateTime = qdt; 846 mNextAlarmDateTime = qdt;
847 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 847 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
848 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 848 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
849#ifndef DESKTOP_VERSION 849#ifndef DESKTOP_VERSION
850 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 850 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
851#endif 851#endif
852 return; 852 return;
853 } 853 }
854 int maxSec; 854 int maxSec;
855 //maxSec = 5; //testing only 855 //maxSec = 5; //testing only
856 maxSec = 86400+3600; // one day+1hour 856 maxSec = 86400+3600; // one day+1hour
857 mAlarmNotification = noti; 857 mAlarmNotification = noti;
858 int sec = QDateTime::currentDateTime().secsTo( qdt ); 858 int sec = QDateTime::currentDateTime().secsTo( qdt );
859 if ( sec > maxSec ) { 859 if ( sec > maxSec ) {
860 mRecheckAlarmTimer->start( maxSec * 1000 ); 860 mRecheckAlarmTimer->start( maxSec * 1000 );
861 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 861 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
862 return; 862 return;
863 } else { 863 } else {
864 mRecheckAlarmTimer->stop(); 864 mRecheckAlarmTimer->stop();
865 } 865 }
866 //qDebug("Alarm timer started with secs: %d ", sec); 866 //qDebug("Alarm timer started with secs: %d ", sec);
867 mAlarmTimer->start( sec *1000 , true ); 867 mAlarmTimer->start( sec *1000 , true );
868 868
869} 869}
870// called by mRecheckAlarmTimer to get next alarm 870// called by mRecheckAlarmTimer to get next alarm
871// we need this, because a QTimer has only a max range of 25 days 871// we need this, because a QTimer has only a max range of 25 days
872void CalendarView::recheckTimerAlarm() 872void CalendarView::recheckTimerAlarm()
873{ 873{
874 mAlarmTimer->stop(); 874 mAlarmTimer->stop();
875 mRecheckAlarmTimer->stop(); 875 mRecheckAlarmTimer->stop();
876 mCalendar->checkAlarmForIncidence( 0, true ); 876 mCalendar->checkAlarmForIncidence( 0, true );
877} 877}
878void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 878void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
879{ 879{
880 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 880 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
881 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 881 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
882#ifndef DESKTOP_VERSION 882#ifndef DESKTOP_VERSION
883 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 883 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
884#endif 884#endif
885 return; 885 return;
886 } 886 }
887 mAlarmTimer->stop(); 887 mAlarmTimer->stop();
888} 888}
889void CalendarView::selectWeekNum ( int num ) 889void CalendarView::selectWeekNum ( int num )
890{ 890{
891 dateNavigator()->blockSignals( true ); 891 dateNavigator()->blockSignals( true );
892 dateNavigator()->selectWeek( num ); 892 dateNavigator()->selectWeek( num );
893 dateNavigator()->blockSignals( false ); 893 dateNavigator()->blockSignals( false );
894 mViewManager->showWeekView(); 894 mViewManager->showWeekView();
895} 895}
896KOViewManager *CalendarView::viewManager() 896KOViewManager *CalendarView::viewManager()
897{ 897{
898 return mViewManager; 898 return mViewManager;
899} 899}
900 900
901KODialogManager *CalendarView::dialogManager() 901KODialogManager *CalendarView::dialogManager()
902{ 902{
903 return mDialogManager; 903 return mDialogManager;
904} 904}
905 905
906QDate CalendarView::startDate() 906QDate CalendarView::startDate()
907{ 907{
908 DateList dates = mNavigator->selectedDates(); 908 DateList dates = mNavigator->selectedDates();
909 909
910 return dates.first(); 910 return dates.first();
911} 911}
912 912
913QDate CalendarView::endDate() 913QDate CalendarView::endDate()
914{ 914{
915 DateList dates = mNavigator->selectedDates(); 915 DateList dates = mNavigator->selectedDates();
916 916
917 return dates.last(); 917 return dates.last();
918} 918}
919 919
920 920
921void CalendarView::createPrinter() 921void CalendarView::createPrinter()
922{ 922{
923#ifndef KORG_NOPRINTER 923#ifndef KORG_NOPRINTER
924 if (!mCalPrinter) { 924 if (!mCalPrinter) {
925 mCalPrinter = new CalPrinter(this, mCalendar); 925 mCalPrinter = new CalPrinter(this, mCalendar);
926 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 926 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
927 } 927 }
928#endif 928#endif
929} 929}
930 930
931 931
932//KOPrefs::instance()->mWriteBackFile 932//KOPrefs::instance()->mWriteBackFile
933//KOPrefs::instance()->mWriteBackExistingOnly 933//KOPrefs::instance()->mWriteBackExistingOnly
934 934
935// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 935// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
936// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 936// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
937// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 937// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
938// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 938// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
939// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 939// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
940// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 940// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
941 941
942int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 942int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
943{ 943{
944 944
945 // 0 equal 945 // 0 equal
946 // 1 take local 946 // 1 take local
947 // 2 take remote 947 // 2 take remote
948 // 3 cancel 948 // 3 cancel
949 QDateTime lastSync = mLastCalendarSync; 949 QDateTime lastSync = mLastCalendarSync;
950 QDateTime localMod = local->lastModified(); 950 QDateTime localMod = local->lastModified();
951 QDateTime remoteMod = remote->lastModified(); 951 QDateTime remoteMod = remote->lastModified();
952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 952 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
953 bool remCh, locCh; 953 bool remCh, locCh;
954 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 954 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
955 //if ( remCh ) 955 //if ( remCh )
956 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 956 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
957 locCh = ( localMod > mLastCalendarSync ); 957 locCh = ( localMod > mLastCalendarSync );
958 if ( !remCh && ! locCh ) { 958 if ( !remCh && ! locCh ) {
959 //qDebug("both not changed "); 959 //qDebug("both not changed ");
960 lastSync = localMod.addDays(1); 960 lastSync = localMod.addDays(1);
961 if ( mode <= SYNC_PREF_ASK ) 961 if ( mode <= SYNC_PREF_ASK )
962 return 0; 962 return 0;
963 } else { 963 } else {
964 if ( locCh ) { 964 if ( locCh ) {
965 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 965 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
966 lastSync = localMod.addDays( -1 ); 966 lastSync = localMod.addDays( -1 );
967 if ( !remCh ) 967 if ( !remCh )
968 remoteMod = ( lastSync.addDays( -1 ) ); 968 remoteMod = ( lastSync.addDays( -1 ) );
969 } else { 969 } else {
970 //qDebug(" not loc changed "); 970 //qDebug(" not loc changed ");
971 lastSync = localMod.addDays( 1 ); 971 lastSync = localMod.addDays( 1 );
972 if ( remCh ) 972 if ( remCh )
973 remoteMod =( lastSync.addDays( 1 ) ); 973 remoteMod =( lastSync.addDays( 1 ) );
974 974
975 } 975 }
976 } 976 }
977 full = true; 977 full = true;
978 if ( mode < SYNC_PREF_ASK ) 978 if ( mode < SYNC_PREF_ASK )
979 mode = SYNC_PREF_ASK; 979 mode = SYNC_PREF_ASK;
980 } else { 980 } else {
981 if ( localMod == remoteMod ) 981 if ( localMod == remoteMod )
982 // if ( local->revision() == remote->revision() ) 982 // if ( local->revision() == remote->revision() )
983 return 0; 983 return 0;
984 984
985 } 985 }
986 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 986 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
987 987
988 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 988 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
989 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 989 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
990 //full = true; //debug only 990 //full = true; //debug only
991 if ( full ) { 991 if ( full ) {
992 bool equ = false; 992 bool equ = false;
993 if ( local->typeID() == eventID ) { 993 if ( local->typeID() == eventID ) {
994 equ = (*((Event*) local) == *((Event*) remote)); 994 equ = (*((Event*) local) == *((Event*) remote));
995 } 995 }
996 else if ( local->typeID() == todoID ) 996 else if ( local->typeID() == todoID )
997 equ = (*((Todo*) local) == (*(Todo*) remote)); 997 equ = (*((Todo*) local) == (*(Todo*) remote));
998 else if ( local->typeID() == journalID ) 998 else if ( local->typeID() == journalID )
999 equ = (*((Journal*) local) == *((Journal*) remote)); 999 equ = (*((Journal*) local) == *((Journal*) remote));
1000 if ( equ ) { 1000 if ( equ ) {
1001 //qDebug("equal "); 1001 //qDebug("equal ");
1002 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1002 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1003 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1003 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1004 } 1004 }
1005 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1005 if ( mode < SYNC_PREF_FORCE_LOCAL )
1006 return 0; 1006 return 0;
1007 1007
1008 }//else //debug only 1008 }//else //debug only
1009 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1009 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1010 } 1010 }
1011 int result; 1011 int result;
1012 bool localIsNew; 1012 bool localIsNew;
1013 //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() ); 1013 //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() );
1014 1014
1015 1015
1016 // ************************************************ 1016 // ************************************************
1017 // ************************************************ 1017 // ************************************************
1018 // ************************************************ 1018 // ************************************************
1019 // We may have that lastSync > remoteMod AND lastSync > localMod 1019 // We may have that lastSync > remoteMod AND lastSync > localMod
1020 // BUT remoteMod != localMod 1020 // BUT remoteMod != localMod
1021 1021
1022 1022
1023 if ( full && mode < SYNC_PREF_NEWEST ) 1023 if ( full && mode < SYNC_PREF_NEWEST )
1024 mode = SYNC_PREF_ASK; 1024 mode = SYNC_PREF_ASK;
1025 1025
1026 switch( mode ) { 1026 switch( mode ) {
1027 case SYNC_PREF_LOCAL: 1027 case SYNC_PREF_LOCAL:
1028 if ( lastSync > remoteMod ) 1028 if ( lastSync > remoteMod )
1029 return 1; 1029 return 1;
1030 if ( lastSync > localMod ) 1030 if ( lastSync > localMod )
1031 return 2; 1031 return 2;
1032 return 1; 1032 return 1;
1033 break; 1033 break;
1034 case SYNC_PREF_REMOTE: 1034 case SYNC_PREF_REMOTE:
1035 if ( lastSync > localMod ) 1035 if ( lastSync > localMod )
1036 return 2; 1036 return 2;
1037 if ( lastSync > remoteMod ) 1037 if ( lastSync > remoteMod )
1038 return 1; 1038 return 1;
1039 return 2; 1039 return 2;
1040 break; 1040 break;
1041 case SYNC_PREF_NEWEST: 1041 case SYNC_PREF_NEWEST:
1042 if ( localMod >= remoteMod ) 1042 if ( localMod >= remoteMod )
1043 return 1; 1043 return 1;
1044 else 1044 else
1045 return 2; 1045 return 2;
1046 break; 1046 break;
1047 case SYNC_PREF_ASK: 1047 case SYNC_PREF_ASK:
1048 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1048 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1049 if ( lastSync > remoteMod && lastSync > localMod) 1049 if ( lastSync > remoteMod && lastSync > localMod)
1050 return 0; 1050 return 0;
1051 if ( lastSync > remoteMod ) 1051 if ( lastSync > remoteMod )
1052 return 1; 1052 return 1;
1053 if ( lastSync > localMod ) 1053 if ( lastSync > localMod )
1054 return 2; 1054 return 2;
1055 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1055 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1056 localIsNew = localMod >= remoteMod; 1056 localIsNew = localMod >= remoteMod;
1057 if ( localIsNew ) 1057 if ( localIsNew )
1058 getEventViewerDialog()->setColorMode( 1 ); 1058 getEventViewerDialog()->setColorMode( 1 );
1059 else 1059 else
1060 getEventViewerDialog()->setColorMode( 2 ); 1060 getEventViewerDialog()->setColorMode( 2 );
1061 getEventViewerDialog()->setIncidence(local); 1061 getEventViewerDialog()->setIncidence(local);
1062 if ( localIsNew ) 1062 if ( localIsNew )
1063 getEventViewerDialog()->setColorMode( 2 ); 1063 getEventViewerDialog()->setColorMode( 2 );
1064 else 1064 else
1065 getEventViewerDialog()->setColorMode( 1 ); 1065 getEventViewerDialog()->setColorMode( 1 );
1066 getEventViewerDialog()->addIncidence(remote); 1066 getEventViewerDialog()->addIncidence(remote);
1067 getEventViewerDialog()->setColorMode( 0 ); 1067 getEventViewerDialog()->setColorMode( 0 );
1068 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1068 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1069 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1069 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1070 getEventViewerDialog()->showMe(); 1070 getEventViewerDialog()->showMe();
1071 result = getEventViewerDialog()->executeS( localIsNew ); 1071 result = getEventViewerDialog()->executeS( localIsNew );
1072 return result; 1072 return result;
1073 1073
1074 break; 1074 break;
1075 case SYNC_PREF_FORCE_LOCAL: 1075 case SYNC_PREF_FORCE_LOCAL:
1076 return 1; 1076 return 1;
1077 break; 1077 break;
1078 case SYNC_PREF_FORCE_REMOTE: 1078 case SYNC_PREF_FORCE_REMOTE:
1079 return 2; 1079 return 2;
1080 break; 1080 break;
1081 1081
1082 default: 1082 default:
1083 // SYNC_PREF_TAKE_BOTH not implemented 1083 // SYNC_PREF_TAKE_BOTH not implemented
1084 break; 1084 break;
1085 } 1085 }
1086 return 0; 1086 return 0;
1087} 1087}
1088Event* CalendarView::getLastSyncEvent() 1088Event* CalendarView::getLastSyncEvent()
1089{ 1089{
1090 Event* lse; 1090 Event* lse;
1091 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1091 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1092 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1092 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1093 if (!lse) { 1093 if (!lse) {
1094 lse = new Event(); 1094 lse = new Event();
1095 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1095 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1096 QString sum = ""; 1096 QString sum = "";
1097 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1097 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1098 sum = "E: "; 1098 sum = "E: ";
1099 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1099 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1100 lse->setDtStart( mLastCalendarSync ); 1100 lse->setDtStart( mLastCalendarSync );
1101 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1101 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1102 lse->setCategories( i18n("SyncEvent") ); 1102 lse->setCategories( i18n("SyncEvent") );
1103 lse->setReadOnly( true ); 1103 lse->setReadOnly( true );
1104 mCalendar->addEvent( lse ); 1104 mCalendar->addEvent( lse );
1105 } 1105 }
1106 1106
1107 return lse; 1107 return lse;
1108 1108
1109} 1109}
1110 1110
1111// we check, if the to delete event has a id for a profile 1111// we check, if the to delete event has a id for a profile
1112// if yes, we set this id in the profile to delete 1112// if yes, we set this id in the profile to delete
1113void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1113void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1114{ 1114{
1115 if ( lastSync.count() == 0 ) { 1115 if ( lastSync.count() == 0 ) {
1116 //qDebug(" lastSync.count() == 0"); 1116 //qDebug(" lastSync.count() == 0");
1117 return; 1117 return;
1118 } 1118 }
1119 if ( toDelete->typeID() == journalID ) 1119 if ( toDelete->typeID() == journalID )
1120 return; 1120 return;
1121 1121
1122 Event* eve = lastSync.first(); 1122 Event* eve = lastSync.first();
1123 1123
1124 while ( eve ) { 1124 while ( eve ) {
1125 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1125 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1126 if ( !id.isEmpty() ) { 1126 if ( !id.isEmpty() ) {
1127 QString des = eve->description(); 1127 QString des = eve->description();
1128 QString pref = "e"; 1128 QString pref = "e";
1129 if ( toDelete->typeID() == todoID ) 1129 if ( toDelete->typeID() == todoID )
1130 pref = "t"; 1130 pref = "t";
1131 des += pref+ id + ","; 1131 des += pref+ id + ",";
1132 eve->setReadOnly( false ); 1132 eve->setReadOnly( false );
1133 eve->setDescription( des ); 1133 eve->setDescription( des );
1134 //qDebug("setdes %s ", des.latin1()); 1134 //qDebug("setdes %s ", des.latin1());
1135 eve->setReadOnly( true ); 1135 eve->setReadOnly( true );
1136 } 1136 }
1137 eve = lastSync.next(); 1137 eve = lastSync.next();
1138 } 1138 }
1139 1139
1140} 1140}
1141void CalendarView::checkExternalId( Incidence * inc ) 1141void CalendarView::checkExternalId( Incidence * inc )
1142{ 1142{
1143 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1143 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1144 checkExternSyncEvent( lastSync, inc ); 1144 checkExternSyncEvent( lastSync, inc );
1145 1145
1146} 1146}
1147bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1147bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1148{ 1148{
1149 bool syncOK = true; 1149 bool syncOK = true;
1150 int addedEvent = 0; 1150 int addedEvent = 0;
1151 int addedEventR = 0; 1151 int addedEventR = 0;
1152 int deletedEventR = 0; 1152 int deletedEventR = 0;
1153 int deletedEventL = 0; 1153 int deletedEventL = 0;
1154 int changedLocal = 0; 1154 int changedLocal = 0;
1155 int changedRemote = 0; 1155 int changedRemote = 0;
1156 int filteredIN = 0; 1156 int filteredIN = 0;
1157 int filteredOUT = 0; 1157 int filteredOUT = 0;
1158 //QPtrList<Event> el = local->rawEvents(); 1158 //QPtrList<Event> el = local->rawEvents();
1159 Event* eventR; 1159 Event* eventR;
1160 QString uid; 1160 QString uid;
1161 int take; 1161 int take;
1162 Event* eventL; 1162 Event* eventL;
1163 Event* eventRSync; 1163 Event* eventRSync;
1164 Event* eventLSync; 1164 Event* eventLSync;
1165 clearAllViews(); 1165 clearAllViews();
1166 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1166 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1167 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1167 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1168 bool fullDateRange = false; 1168 bool fullDateRange = false;
1169 local->resetTempSyncStat(); 1169 local->resetTempSyncStat();
1170 mLastCalendarSync = QDateTime::currentDateTime(); 1170 mLastCalendarSync = QDateTime::currentDateTime();
1171 if ( mSyncManager->syncWithDesktop() ) { 1171 if ( mSyncManager->syncWithDesktop() ) {
1172 remote->resetPilotStat(1); 1172 remote->resetPilotStat(1);
1173 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1173 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1174 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1174 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1175 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1175 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1176 } else { 1176 } else {
1177 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1177 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1178 } 1178 }
1179 } 1179 }
1180 QDateTime modifiedCalendar = mLastCalendarSync; 1180 QDateTime modifiedCalendar = mLastCalendarSync;
1181 eventLSync = getLastSyncEvent(); 1181 eventLSync = getLastSyncEvent();
1182 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1182 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1183 if ( eventR ) { 1183 if ( eventR ) {
1184 eventRSync = (Event*) eventR->clone(); 1184 eventRSync = (Event*) eventR->clone();
1185 remote->deleteEvent(eventR ); 1185 remote->deleteEvent(eventR );
1186 1186
1187 } else { 1187 } else {
1188 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1188 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1189 eventRSync = (Event*)eventLSync->clone(); 1189 eventRSync = (Event*)eventLSync->clone();
1190 } else { 1190 } else {
1191 fullDateRange = true; 1191 fullDateRange = true;
1192 eventRSync = new Event(); 1192 eventRSync = new Event();
1193 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1193 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1194 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1194 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1195 eventRSync->setDtStart( mLastCalendarSync ); 1195 eventRSync->setDtStart( mLastCalendarSync );
1196 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1196 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1197 eventRSync->setCategories( i18n("SyncEvent") ); 1197 eventRSync->setCategories( i18n("SyncEvent") );
1198 } 1198 }
1199 } 1199 }
1200 if ( eventLSync->dtStart() == mLastCalendarSync ) 1200 if ( eventLSync->dtStart() == mLastCalendarSync )
1201 fullDateRange = true; 1201 fullDateRange = true;
1202 1202
1203 if ( ! fullDateRange ) { 1203 if ( ! fullDateRange ) {
1204 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1204 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1205 1205
1206 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1206 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1207 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1207 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1208 fullDateRange = true; 1208 fullDateRange = true;
1209 } 1209 }
1210 } 1210 }
1211 if ( mSyncManager->syncWithDesktop() ) { 1211 if ( mSyncManager->syncWithDesktop() ) {
1212 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1212 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1213 } 1213 }
1214 if ( fullDateRange ) 1214 if ( fullDateRange )
1215 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1215 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1216 else 1216 else
1217 mLastCalendarSync = eventLSync->dtStart(); 1217 mLastCalendarSync = eventLSync->dtStart();
1218 // for resyncing if own file has changed 1218 // for resyncing if own file has changed
1219 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1219 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1220 mLastCalendarSync = loadedFileVersion; 1220 mLastCalendarSync = loadedFileVersion;
1221 //qDebug("setting mLastCalendarSync "); 1221 //qDebug("setting mLastCalendarSync ");
1222 } 1222 }
1223 //qDebug("*************************** "); 1223 //qDebug("*************************** ");
1224 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1224 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1225 QPtrList<Incidence> er = remote->rawIncidences(); 1225 QPtrList<Incidence> er = remote->rawIncidences();
1226 Incidence* inR = er.first(); 1226 Incidence* inR = er.first();
1227 Incidence* inL; 1227 Incidence* inL;
1228 QProgressBar bar( er.count(),0 ); 1228 QProgressBar bar( er.count(),0 );
1229 bar.setCaption (i18n("Syncing - close to abort!") ); 1229 bar.setCaption (i18n("Syncing - close to abort!") );
1230 1230
1231 // ************** setting up filter ************* 1231 // ************** setting up filter *************
1232 CalFilter *filterIN = 0; 1232 CalFilter *filterIN = 0;
1233 CalFilter *filterOUT = 0; 1233 CalFilter *filterOUT = 0;
1234 CalFilter *filter = mFilters.first(); 1234 CalFilter *filter = mFilters.first();
1235 while(filter) { 1235 while(filter) {
1236 if ( filter->name() == mSyncManager->mFilterInCal ) 1236 if ( filter->name() == mSyncManager->mFilterInCal )
1237 filterIN = filter; 1237 filterIN = filter;
1238 if ( filter->name() == mSyncManager->mFilterOutCal ) 1238 if ( filter->name() == mSyncManager->mFilterOutCal )
1239 filterOUT = filter; 1239 filterOUT = filter;
1240 filter = mFilters.next(); 1240 filter = mFilters.next();
1241 } 1241 }
1242 int w = 300; 1242 int w = 300;
1243 if ( QApplication::desktop()->width() < 320 ) 1243 if ( QApplication::desktop()->width() < 320 )
1244 w = 220; 1244 w = 220;
1245 int h = bar.sizeHint().height() ; 1245 int h = bar.sizeHint().height() ;
1246 int dw = QApplication::desktop()->width(); 1246 int dw = QApplication::desktop()->width();
1247 int dh = QApplication::desktop()->height(); 1247 int dh = QApplication::desktop()->height();
1248 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1248 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1249 bar.show(); 1249 bar.show();
1250 int modulo = (er.count()/10)+1; 1250 int modulo = (er.count()/10)+1;
1251 int incCounter = 0; 1251 int incCounter = 0;
1252 while ( inR ) { 1252 while ( inR ) {
1253 if ( ! bar.isVisible() ) 1253 if ( ! bar.isVisible() )
1254 return false; 1254 return false;
1255 if ( incCounter % modulo == 0 ) 1255 if ( incCounter % modulo == 0 )
1256 bar.setProgress( incCounter ); 1256 bar.setProgress( incCounter );
1257 ++incCounter; 1257 ++incCounter;
1258 uid = inR->uid(); 1258 uid = inR->uid();
1259 bool skipIncidence = false; 1259 bool skipIncidence = false;
1260 if ( uid.left(15) == QString("last-syncEvent-") ) 1260 if ( uid.left(15) == QString("last-syncEvent-") )
1261 skipIncidence = true; 1261 skipIncidence = true;
1262 QString idS; 1262 QString idS;
1263 qApp->processEvents(); 1263 qApp->processEvents();
1264 if ( !skipIncidence ) { 1264 if ( !skipIncidence ) {
1265 inL = local->incidence( uid ); 1265 inL = local->incidence( uid );
1266 if ( inL ) { // maybe conflict - same uid in both calendars 1266 if ( inL ) { // maybe conflict - same uid in both calendars
1267 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1267 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1268 //qDebug("take %d %s ", take, inL->summary().latin1()); 1268 //qDebug("take %d %s ", take, inL->summary().latin1());
1269 if ( take == 3 ) 1269 if ( take == 3 )
1270 return false; 1270 return false;
1271 if ( take == 1 ) {// take local ********************** 1271 if ( take == 1 ) {// take local **********************
1272 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1272 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1273 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1273 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1274 else 1274 else
1275 idS = inR->IDStr(); 1275 idS = inR->IDStr();
1276 remote->deleteIncidence( inR ); 1276 remote->deleteIncidence( inR );
1277 inR = inL->clone(); 1277 inR = inL->clone();
1278 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1278 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1279 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1279 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1280 inR->setIDStr( idS ); 1280 inR->setIDStr( idS );
1281 remote->addIncidence( inR ); 1281 remote->addIncidence( inR );
1282 if ( mSyncManager->syncWithDesktop() ) 1282 if ( mSyncManager->syncWithDesktop() )
1283 inR->setPilotId( 2 ); 1283 inR->setPilotId( 2 );
1284 ++changedRemote; 1284 ++changedRemote;
1285 } else {// take remote ********************** 1285 } else {// take remote **********************
1286 idS = inL->IDStr(); 1286 idS = inL->IDStr();
1287 int pid = inL->pilotId(); 1287 int pid = inL->pilotId();
1288 local->deleteIncidence( inL ); 1288 local->deleteIncidence( inL );
1289 inL = inR->clone(); 1289 inL = inR->clone();
1290 if ( mSyncManager->syncWithDesktop() ) 1290 if ( mSyncManager->syncWithDesktop() )
1291 inL->setPilotId( pid ); 1291 inL->setPilotId( pid );
1292 inL->setIDStr( idS ); 1292 inL->setIDStr( idS );
1293 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1293 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1294 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1294 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1295 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1295 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1296 } 1296 }
1297 local->addIncidence( inL ); 1297 local->addIncidence( inL );
1298 ++changedLocal; 1298 ++changedLocal;
1299 } 1299 }
1300 } 1300 }
1301 } else { // no conflict ********** add or delete remote 1301 } else { // no conflict ********** add or delete remote
1302 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1302 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1303 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1303 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1304 QString des = eventLSync->description(); 1304 QString des = eventLSync->description();
1305 QString pref = "e"; 1305 QString pref = "e";
1306 if ( inR->typeID() == todoID ) 1306 if ( inR->typeID() == todoID )
1307 pref = "t"; 1307 pref = "t";
1308 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1308 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1309 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1309 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1310 //remote->deleteIncidence( inR ); 1310 //remote->deleteIncidence( inR );
1311 ++deletedEventR; 1311 ++deletedEventR;
1312 } else { 1312 } else {
1313 inR->setLastModified( modifiedCalendar ); 1313 inR->setLastModified( modifiedCalendar );
1314 inL = inR->clone(); 1314 inL = inR->clone();
1315 inL->setIDStr( ":" ); 1315 inL->setIDStr( ":" );
1316 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1316 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1317 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1317 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1318 local->addIncidence( inL ); 1318 local->addIncidence( inL );
1319 ++addedEvent; 1319 ++addedEvent;
1320 1320
1321 } 1321 }
1322 } else { 1322 } else {
1323 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1323 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1324 inR->setLastModified( modifiedCalendar ); 1324 inR->setLastModified( modifiedCalendar );
1325 inL = inR->clone(); 1325 inL = inR->clone();
1326 inL->setIDStr( ":" ); 1326 inL->setIDStr( ":" );
1327 local->addIncidence( inL ); 1327 local->addIncidence( inL );
1328 ++addedEvent; 1328 ++addedEvent;
1329 1329
1330 } else { 1330 } else {
1331 checkExternSyncEvent(eventRSyncSharp, inR); 1331 checkExternSyncEvent(eventRSyncSharp, inR);
1332 remote->deleteIncidence( inR ); 1332 remote->deleteIncidence( inR );
1333 ++deletedEventR; 1333 ++deletedEventR;
1334 } 1334 }
1335 } 1335 }
1336 } else { 1336 } else {
1337 ++filteredIN; 1337 ++filteredIN;
1338 } 1338 }
1339 } 1339 }
1340 } 1340 }
1341 inR = er.next(); 1341 inR = er.next();
1342 } 1342 }
1343 QPtrList<Incidence> el = local->rawIncidences(); 1343 QPtrList<Incidence> el = local->rawIncidences();
1344 inL = el.first(); 1344 inL = el.first();
1345 modulo = (el.count()/10)+1; 1345 modulo = (el.count()/10)+1;
1346 bar.setCaption (i18n("Add / remove events") ); 1346 bar.setCaption (i18n("Add / remove events") );
1347 bar.setTotalSteps ( el.count() ) ; 1347 bar.setTotalSteps ( el.count() ) ;
1348 bar.show(); 1348 bar.show();
1349 incCounter = 0; 1349 incCounter = 0;
1350 1350
1351 while ( inL ) { 1351 while ( inL ) {
1352 1352
1353 qApp->processEvents(); 1353 qApp->processEvents();
1354 if ( ! bar.isVisible() ) 1354 if ( ! bar.isVisible() )
1355 return false; 1355 return false;
1356 if ( incCounter % modulo == 0 ) 1356 if ( incCounter % modulo == 0 )
1357 bar.setProgress( incCounter ); 1357 bar.setProgress( incCounter );
1358 ++incCounter; 1358 ++incCounter;
1359 uid = inL->uid(); 1359 uid = inL->uid();
1360 bool skipIncidence = false; 1360 bool skipIncidence = false;
1361 if ( uid.left(15) == QString("last-syncEvent-") ) 1361 if ( uid.left(15) == QString("last-syncEvent-") )
1362 skipIncidence = true; 1362 skipIncidence = true;
1363 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1363 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1364 skipIncidence = true; 1364 skipIncidence = true;
1365 if ( !skipIncidence ) { 1365 if ( !skipIncidence ) {
1366 inR = remote->incidence( uid ); 1366 inR = remote->incidence( uid );
1367 if ( ! inR ) { 1367 if ( ! inR ) {
1368 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1368 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1369 // no conflict ********** add or delete local 1369 // no conflict ********** add or delete local
1370 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1370 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1371 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1371 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1372 checkExternSyncEvent(eventLSyncSharp, inL); 1372 checkExternSyncEvent(eventLSyncSharp, inL);
1373 local->deleteIncidence( inL ); 1373 local->deleteIncidence( inL );
1374 ++deletedEventL; 1374 ++deletedEventL;
1375 } else { 1375 } else {
1376 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1376 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1377 inL->removeID(mCurrentSyncDevice ); 1377 inL->removeID(mCurrentSyncDevice );
1378 ++addedEventR; 1378 ++addedEventR;
1379 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1379 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1380 inL->setLastModified( modifiedCalendar ); 1380 inL->setLastModified( modifiedCalendar );
1381 inR = inL->clone(); 1381 inR = inL->clone();
1382 inR->setIDStr( ":" ); 1382 inR->setIDStr( ":" );
1383 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1383 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1384 remote->addIncidence( inR ); 1384 remote->addIncidence( inR );
1385 } 1385 }
1386 } 1386 }
1387 } else { 1387 } else {
1388 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1388 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1389 checkExternSyncEvent(eventLSyncSharp, inL); 1389 checkExternSyncEvent(eventLSyncSharp, inL);
1390 local->deleteIncidence( inL ); 1390 local->deleteIncidence( inL );
1391 ++deletedEventL; 1391 ++deletedEventL;
1392 } else { 1392 } else {
1393 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1393 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1394 ++addedEventR; 1394 ++addedEventR;
1395 inL->setLastModified( modifiedCalendar ); 1395 inL->setLastModified( modifiedCalendar );
1396 inR = inL->clone(); 1396 inR = inL->clone();
1397 inR->setIDStr( ":" ); 1397 inR->setIDStr( ":" );
1398 remote->addIncidence( inR ); 1398 remote->addIncidence( inR );
1399 } 1399 }
1400 } 1400 }
1401 } 1401 }
1402 } else { 1402 } else {
1403 ++filteredOUT; 1403 ++filteredOUT;
1404 } 1404 }
1405 } 1405 }
1406 } 1406 }
1407 inL = el.next(); 1407 inL = el.next();
1408 } 1408 }
1409 int delFut = 0; 1409 int delFut = 0;
1410 int remRem = 0; 1410 int remRem = 0;
1411 if ( mSyncManager->mWriteBackInFuture ) { 1411 if ( mSyncManager->mWriteBackInFuture ) {
1412 er = remote->rawIncidences(); 1412 er = remote->rawIncidences();
1413 remRem = er.count(); 1413 remRem = er.count();
1414 inR = er.first(); 1414 inR = er.first();
1415 QDateTime dt; 1415 QDateTime dt;
1416 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1416 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1417 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1417 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1418 while ( inR ) { 1418 while ( inR ) {
1419 if ( inR->typeID() == todoID ) { 1419 if ( inR->typeID() == todoID ) {
1420 Todo * t = (Todo*)inR; 1420 Todo * t = (Todo*)inR;
1421 if ( t->hasDueDate() ) 1421 if ( t->hasDueDate() )
1422 dt = t->dtDue(); 1422 dt = t->dtDue();
1423 else 1423 else
1424 dt = cur.addSecs( 62 ); 1424 dt = cur.addSecs( 62 );
1425 } 1425 }
1426 else if (inR->typeID() == eventID ) { 1426 else if (inR->typeID() == eventID ) {
1427 bool ok; 1427 bool ok;
1428 dt = inR->getNextOccurence( cur, &ok ); 1428 dt = inR->getNextOccurence( cur, &ok );
1429 if ( !ok ) 1429 if ( !ok )
1430 dt = cur.addSecs( -62 ); 1430 dt = cur.addSecs( -62 );
1431 } 1431 }
1432 else 1432 else
1433 dt = inR->dtStart(); 1433 dt = inR->dtStart();
1434 if ( dt < cur || dt > end ) { 1434 if ( dt < cur || dt > end ) {
1435 remote->deleteIncidence( inR ); 1435 remote->deleteIncidence( inR );
1436 ++delFut; 1436 ++delFut;
1437 } 1437 }
1438 inR = er.next(); 1438 inR = er.next();
1439 } 1439 }
1440 } 1440 }
1441 bar.hide(); 1441 bar.hide();
1442 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1442 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1443 eventLSync->setReadOnly( false ); 1443 eventLSync->setReadOnly( false );
1444 eventLSync->setDtStart( mLastCalendarSync ); 1444 eventLSync->setDtStart( mLastCalendarSync );
1445 eventRSync->setDtStart( mLastCalendarSync ); 1445 eventRSync->setDtStart( mLastCalendarSync );
1446 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1446 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1447 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1447 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1448 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1448 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1449 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1449 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1450 eventLSync->setReadOnly( true ); 1450 eventLSync->setReadOnly( true );
1451 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1451 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1452 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1452 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1453 remote->addEvent( eventRSync ); 1453 remote->addEvent( eventRSync );
1454 else 1454 else
1455 delete eventRSync; 1455 delete eventRSync;
1456 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1456 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1457 QString mes; 1457 QString mes;
1458 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 ); 1458 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 );
1459 QString delmess; 1459 QString delmess;
1460 if ( delFut ) { 1460 if ( delFut ) {
1461 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); 1461 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);
1462 mes += delmess; 1462 mes += delmess;
1463 } 1463 }
1464 mes = i18n("Local calendar changed!\n") +mes; 1464 mes = i18n("Local calendar changed!\n") +mes;
1465 mCalendar->checkAlarmForIncidence( 0, true ); 1465 mCalendar->checkAlarmForIncidence( 0, true );
1466 qDebug( mes ); 1466 qDebug( mes );
1467 if ( mSyncManager->mShowSyncSummary ) { 1467 if ( mSyncManager->mShowSyncSummary ) {
1468 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1468 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1469 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1469 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1470 qDebug("KO: WB cancelled "); 1470 qDebug("KO: WB cancelled ");
1471 mSyncManager->mWriteBackFile = false; 1471 mSyncManager->mWriteBackFile = false;
1472 return syncOK; 1472 return syncOK;
1473 } 1473 }
1474 } 1474 }
1475 return syncOK; 1475 return syncOK;
1476} 1476}
1477 1477
1478void CalendarView::setSyncDevice( QString s ) 1478void CalendarView::setSyncDevice( QString s )
1479{ 1479{
1480 mCurrentSyncDevice= s; 1480 mCurrentSyncDevice= s;
1481} 1481}
1482void CalendarView::setSyncName( QString s ) 1482void CalendarView::setSyncName( QString s )
1483{ 1483{
1484 mCurrentSyncName= s; 1484 mCurrentSyncName= s;
1485} 1485}
1486bool CalendarView::syncCalendar(QString filename, int mode) 1486bool CalendarView::syncCalendar(QString filename, int mode)
1487{ 1487{
1488 //qDebug("syncCalendar %s ", filename.latin1()); 1488 //qDebug("syncCalendar %s ", filename.latin1());
1489 mGlobalSyncMode = SYNC_MODE_NORMAL; 1489 mGlobalSyncMode = SYNC_MODE_NORMAL;
1490 CalendarLocal* calendar = new CalendarLocal(); 1490 CalendarLocal* calendar = new CalendarLocal();
1491 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1491 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1492 FileStorage* storage = new FileStorage( calendar ); 1492 FileStorage* storage = new FileStorage( calendar );
1493 bool syncOK = false; 1493 bool syncOK = false;
1494 storage->setFileName( filename ); 1494 storage->setFileName( filename );
1495 // qDebug("loading ... "); 1495 // qDebug("loading ... ");
1496 if ( storage->load() ) { 1496 if ( storage->load() ) {
1497 getEventViewerDialog()->setSyncMode( true ); 1497 getEventViewerDialog()->setSyncMode( true );
1498 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1498 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1499 getEventViewerDialog()->setSyncMode( false ); 1499 getEventViewerDialog()->setSyncMode( false );
1500 if ( syncOK ) { 1500 if ( syncOK ) {
1501 if ( mSyncManager->mWriteBackFile ) 1501 if ( mSyncManager->mWriteBackFile )
1502 { 1502 {
1503 storage->setSaveFormat( new ICalFormat() ); 1503 storage->setSaveFormat( new ICalFormat() );
1504 storage->save(); 1504 storage->save();
1505 } 1505 }
1506 } 1506 }
1507 setModified( true ); 1507 setModified( true );
1508 } 1508 }
1509 delete storage; 1509 delete storage;
1510 delete calendar; 1510 delete calendar;
1511 if ( syncOK ) 1511 if ( syncOK )
1512 updateView(); 1512 updateView();
1513 return syncOK; 1513 return syncOK;
1514} 1514}
1515 1515
1516void CalendarView::syncExternal( int mode ) 1516void CalendarView::syncExternal( int mode )
1517{ 1517{
1518 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1518 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1519 1519
1520 qApp->processEvents(); 1520 qApp->processEvents();
1521 CalendarLocal* calendar = new CalendarLocal(); 1521 CalendarLocal* calendar = new CalendarLocal();
1522 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1522 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1523 bool syncOK = false; 1523 bool syncOK = false;
1524 bool loadSuccess = false; 1524 bool loadSuccess = false;
1525 PhoneFormat* phoneFormat = 0; 1525 PhoneFormat* phoneFormat = 0;
1526 emit tempDisableBR(true); 1526 emit tempDisableBR(true);
1527#ifndef DESKTOP_VERSION 1527#ifndef DESKTOP_VERSION
1528 SharpFormat* sharpFormat = 0; 1528 SharpFormat* sharpFormat = 0;
1529 if ( mode == 0 ) { // sharp 1529 if ( mode == 0 ) { // sharp
1530 sharpFormat = new SharpFormat () ; 1530 sharpFormat = new SharpFormat () ;
1531 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1531 loadSuccess = sharpFormat->load( calendar, mCalendar );
1532 1532
1533 } else 1533 } else
1534#endif 1534#endif
1535 if ( mode == 1 ) { // phone 1535 if ( mode == 1 ) { // phone
1536 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1536 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1537 mSyncManager->mPhoneDevice, 1537 mSyncManager->mPhoneDevice,
1538 mSyncManager->mPhoneConnection, 1538 mSyncManager->mPhoneConnection,
1539 mSyncManager->mPhoneModel); 1539 mSyncManager->mPhoneModel);
1540 loadSuccess = phoneFormat->load( calendar,mCalendar); 1540 loadSuccess = phoneFormat->load( calendar,mCalendar);
1541 1541
1542 } else { 1542 } else {
1543 emit tempDisableBR(false); 1543 emit tempDisableBR(false);
1544 return; 1544 return;
1545 } 1545 }
1546 if ( loadSuccess ) { 1546 if ( loadSuccess ) {
1547 getEventViewerDialog()->setSyncMode( true ); 1547 getEventViewerDialog()->setSyncMode( true );
1548 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1548 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1549 getEventViewerDialog()->setSyncMode( false ); 1549 getEventViewerDialog()->setSyncMode( false );
1550 qApp->processEvents(); 1550 qApp->processEvents();
1551 if ( syncOK ) { 1551 if ( syncOK ) {
1552 if ( mSyncManager->mWriteBackFile ) 1552 if ( mSyncManager->mWriteBackFile )
1553 { 1553 {
1554 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1554 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1555 Incidence* inc = iL.first(); 1555 Incidence* inc = iL.first();
1556 if ( phoneFormat ) { 1556 if ( phoneFormat ) {
1557 while ( inc ) { 1557 while ( inc ) {
1558 inc->removeID(mCurrentSyncDevice); 1558 inc->removeID(mCurrentSyncDevice);
1559 inc = iL.next(); 1559 inc = iL.next();
1560 } 1560 }
1561 } 1561 }
1562#ifndef DESKTOP_VERSION 1562#ifndef DESKTOP_VERSION
1563 if ( sharpFormat ) 1563 if ( sharpFormat )
1564 sharpFormat->save(calendar); 1564 sharpFormat->save(calendar);
1565#endif 1565#endif
1566 if ( phoneFormat ) 1566 if ( phoneFormat )
1567 phoneFormat->save(calendar); 1567 phoneFormat->save(calendar);
1568 iL = calendar->rawIncidences(); 1568 iL = calendar->rawIncidences();
1569 inc = iL.first(); 1569 inc = iL.first();
1570 Incidence* loc; 1570 Incidence* loc;
1571 while ( inc ) { 1571 while ( inc ) {
1572 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1572 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1573 loc = mCalendar->incidence(inc->uid() ); 1573 loc = mCalendar->incidence(inc->uid() );
1574 if ( loc ) { 1574 if ( loc ) {
1575 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1575 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1576 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1576 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1577 } 1577 }
1578 } 1578 }
1579 inc = iL.next(); 1579 inc = iL.next();
1580 } 1580 }
1581 Incidence* lse = getLastSyncEvent(); 1581 Incidence* lse = getLastSyncEvent();
1582 if ( lse ) { 1582 if ( lse ) {
1583 lse->setReadOnly( false ); 1583 lse->setReadOnly( false );
1584 lse->setDescription( "" ); 1584 lse->setDescription( "" );
1585 lse->setReadOnly( true ); 1585 lse->setReadOnly( true );
1586 } 1586 }
1587 } 1587 }
1588 } else { 1588 } else {
1589 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1589 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1590 } 1590 }
1591 setModified( true ); 1591 setModified( true );
1592 } else { 1592 } else {
1593 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1593 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1594 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1594 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1595 question, i18n("Ok")) ; 1595 question, i18n("Ok")) ;
1596 1596
1597 } 1597 }
1598 delete calendar; 1598 delete calendar;
1599 updateView(); 1599 updateView();
1600 emit tempDisableBR(false); 1600 emit tempDisableBR(false);
1601 return ;//syncOK; 1601 return ;//syncOK;
1602 1602
1603} 1603}
1604 1604
1605bool CalendarView::importBday() 1605bool CalendarView::importBday()
1606{ 1606{
1607#ifndef KORG_NOKABC 1607#ifndef KORG_NOKABC
1608 1608
1609#ifdef DESKTOP_VERSION 1609#ifdef DESKTOP_VERSION
1610 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1610 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1611 KABC::AddressBook::Iterator it; 1611 KABC::AddressBook::Iterator it;
1612 int count = 0; 1612 int count = 0;
1613 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1613 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1614 ++count; 1614 ++count;
1615 } 1615 }
1616 QProgressBar bar(count,0 ); 1616 QProgressBar bar(count,0 );
1617 int w = 300; 1617 int w = 300;
1618 if ( QApplication::desktop()->width() < 320 ) 1618 if ( QApplication::desktop()->width() < 320 )
1619 w = 220; 1619 w = 220;
1620 int h = bar.sizeHint().height() ; 1620 int h = bar.sizeHint().height() ;
1621 int dw = QApplication::desktop()->width(); 1621 int dw = QApplication::desktop()->width();
1622 int dh = QApplication::desktop()->height(); 1622 int dh = QApplication::desktop()->height();
1623 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1623 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1624 bar.show(); 1624 bar.show();
1625 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1625 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1626 qApp->processEvents(); 1626 qApp->processEvents();
1627 count = 0; 1627 count = 0;
1628 int addCount = 0; 1628 int addCount = 0;
1629 KCal::Attendee* a = 0; 1629 KCal::Attendee* a = 0;
1630 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1630 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1631 if ( ! bar.isVisible() ) 1631 if ( ! bar.isVisible() )
1632 return false; 1632 return false;
1633 bar.setProgress( count++ ); 1633 bar.setProgress( count++ );
1634 qApp->processEvents(); 1634 qApp->processEvents();
1635 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1635 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1636 if ( (*it).birthday().date().isValid() ){ 1636 if ( (*it).birthday().date().isValid() ){
1637 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1637 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1638 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1638 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1639 ++addCount; 1639 ++addCount;
1640 } 1640 }
1641 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1641 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1642 if ( anni.isValid() ){ 1642 if ( anni.isValid() ){
1643 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1643 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1644 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1644 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1645 ++addCount; 1645 ++addCount;
1646 } 1646 }
1647 } 1647 }
1648 updateView(); 1648 updateView();
1649 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1649 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1650#else //DESKTOP_VERSION 1650#else //DESKTOP_VERSION
1651 1651
1652 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1652 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1653 // the result should now arrive through method insertBirthdays 1653 // the result should now arrive through method insertBirthdays
1654 1654
1655#endif //DESKTOP_VERSION 1655#endif //DESKTOP_VERSION
1656 1656
1657#endif //KORG_NOKABC 1657#endif //KORG_NOKABC
1658 1658
1659 1659
1660 return true; 1660 return true;
1661} 1661}
1662 1662
1663// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1663// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1664void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1664void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1665 const QStringList& anniversaryList, const QStringList& realNameList, 1665 const QStringList& anniversaryList, const QStringList& realNameList,
1666 const QStringList& emailList, const QStringList& assembledNameList, 1666 const QStringList& emailList, const QStringList& assembledNameList,
1667 const QStringList& uidList) 1667 const QStringList& uidList)
1668{ 1668{
1669 //qDebug("KO::CalendarView::insertBirthdays"); 1669 //qDebug("KO::CalendarView::insertBirthdays");
1670 if (uid == this->name()) 1670 if (uid == this->name())
1671 { 1671 {
1672 int count = birthdayList.count(); 1672 int count = birthdayList.count();
1673 int addCount = 0; 1673 int addCount = 0;
1674 KCal::Attendee* a = 0; 1674 KCal::Attendee* a = 0;
1675 1675
1676 //qDebug("CalView 1 %i", count); 1676 //qDebug("CalView 1 %i", count);
1677 1677
1678 QProgressBar bar(count,0 ); 1678 QProgressBar bar(count,0 );
1679 int w = 300; 1679 int w = 300;
1680 if ( QApplication::desktop()->width() < 320 ) 1680 if ( QApplication::desktop()->width() < 320 )
1681 w = 220; 1681 w = 220;
1682 int h = bar.sizeHint().height() ; 1682 int h = bar.sizeHint().height() ;
1683 int dw = QApplication::desktop()->width(); 1683 int dw = QApplication::desktop()->width();
1684 int dh = QApplication::desktop()->height(); 1684 int dh = QApplication::desktop()->height();
1685 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1685 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1686 bar.show(); 1686 bar.show();
1687 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1687 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1688 qApp->processEvents(); 1688 qApp->processEvents();
1689 1689
1690 QDate birthday; 1690 QDate birthday;
1691 QDate anniversary; 1691 QDate anniversary;
1692 QString realName; 1692 QString realName;
1693 QString email; 1693 QString email;
1694 QString assembledName; 1694 QString assembledName;
1695 QString uid; 1695 QString uid;
1696 bool ok = true; 1696 bool ok = true;
1697 for ( int i = 0; i < count; i++) 1697 for ( int i = 0; i < count; i++)
1698 { 1698 {
1699 if ( ! bar.isVisible() ) 1699 if ( ! bar.isVisible() )
1700 return; 1700 return;
1701 bar.setProgress( i ); 1701 bar.setProgress( i );
1702 qApp->processEvents(); 1702 qApp->processEvents();
1703 1703
1704 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1704 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1705 if (!ok) { 1705 if (!ok) {
1706 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1706 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1707 } 1707 }
1708 1708
1709 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1709 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1710 if (!ok) { 1710 if (!ok) {
1711 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1711 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1712 } 1712 }
1713 realName = realNameList[i]; 1713 realName = realNameList[i];
1714 email = emailList[i]; 1714 email = emailList[i];
1715 assembledName = assembledNameList[i]; 1715 assembledName = assembledNameList[i];
1716 uid = uidList[i]; 1716 uid = uidList[i];
1717 //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() ); 1717 //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() );
1718 1718
1719 if ( birthday.isValid() ){ 1719 if ( birthday.isValid() ){
1720 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1720 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1721 KCal::Attendee::ReqParticipant,uid) ; 1721 KCal::Attendee::ReqParticipant,uid) ;
1722 if ( addAnniversary( birthday, assembledName, a, true ) ) 1722 if ( addAnniversary( birthday, assembledName, a, true ) )
1723 ++addCount; 1723 ++addCount;
1724 } 1724 }
1725 1725
1726 if ( anniversary.isValid() ){ 1726 if ( anniversary.isValid() ){
1727 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1727 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1728 KCal::Attendee::ReqParticipant,uid) ; 1728 KCal::Attendee::ReqParticipant,uid) ;
1729 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1729 if ( addAnniversary( anniversary, assembledName, a, false ) )
1730 ++addCount; 1730 ++addCount;
1731 } 1731 }
1732 } 1732 }
1733 1733
1734 updateView(); 1734 updateView();
1735 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1735 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1736 1736
1737 } 1737 }
1738 1738
1739} 1739}
1740 1740
1741 1741
1742 1742
1743bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1743bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1744{ 1744{
1745 //qDebug("addAnni "); 1745 //qDebug("addAnni ");
1746 Event * ev = new Event(); 1746 Event * ev = new Event();
1747 ev->setOrganizer(KOPrefs::instance()->email()); 1747 ev->setOrganizer(KOPrefs::instance()->email());
1748 if ( a ) { 1748 if ( a ) {
1749 ev->addAttendee( a ); 1749 ev->addAttendee( a );
1750 } 1750 }
1751 QString kind; 1751 QString kind;
1752 if ( birthday ) { 1752 if ( birthday ) {
1753 kind = i18n( "Birthday" ); 1753 kind = i18n( "Birthday" );
1754 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1754 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1755 } 1755 }
1756 else { 1756 else {
1757 kind = i18n( "Anniversary" ); 1757 kind = i18n( "Anniversary" );
1758 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1758 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1759 } 1759 }
1760 ev->setCategories( kind ); 1760 ev->setCategories( kind );
1761 ev->setDtStart( QDateTime(date) ); 1761 ev->setDtStart( QDateTime(date) );
1762 ev->setDtEnd( QDateTime(date) ); 1762 ev->setDtEnd( QDateTime(date) );
1763 ev->setFloats( true ); 1763 ev->setFloats( true );
1764 Recurrence * rec = ev->recurrence(); 1764 Recurrence * rec = ev->recurrence();
1765 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1765 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1766 rec->addYearlyNum( date.month() ); 1766 rec->addYearlyNum( date.month() );
1767 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1767 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1768 delete ev; 1768 delete ev;
1769 return false; 1769 return false;
1770 } 1770 }
1771 return true; 1771 return true;
1772 1772
1773} 1773}
1774bool CalendarView::importQtopia( const QString &categories, 1774bool CalendarView::importQtopia( const QString &categories,
1775 const QString &datebook, 1775 const QString &datebook,
1776 const QString &todolist ) 1776 const QString &todolist )
1777{ 1777{
1778 1778
1779 QtopiaFormat qtopiaFormat; 1779 QtopiaFormat qtopiaFormat;
1780 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1780 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1781 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1781 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1782 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1782 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1783 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1783 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1784 1784
1785 updateView(); 1785 updateView();
1786 return true; 1786 return true;
1787 1787
1788#if 0 1788#if 0
1789 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1789 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1790 mCurrentSyncDevice = "qtopia-XML"; 1790 mCurrentSyncDevice = "qtopia-XML";
1791 if ( mSyncManager->mAskForPreferences ) 1791 if ( mSyncManager->mAskForPreferences )
1792 edit_sync_options(); 1792 edit_sync_options();
1793 qApp->processEvents(); 1793 qApp->processEvents();
1794 CalendarLocal* calendar = new CalendarLocal(); 1794 CalendarLocal* calendar = new CalendarLocal();
1795 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1795 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1796 bool syncOK = false; 1796 bool syncOK = false;
1797 QtopiaFormat qtopiaFormat; 1797 QtopiaFormat qtopiaFormat;
1798 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1798 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1799 bool loadOk = true; 1799 bool loadOk = true;
1800 if ( !categories.isEmpty() ) 1800 if ( !categories.isEmpty() )
1801 loadOk = qtopiaFormat.load( calendar, categories ); 1801 loadOk = qtopiaFormat.load( calendar, categories );
1802 if ( loadOk && !datebook.isEmpty() ) 1802 if ( loadOk && !datebook.isEmpty() )
1803 loadOk = qtopiaFormat.load( calendar, datebook ); 1803 loadOk = qtopiaFormat.load( calendar, datebook );
1804 if ( loadOk && !todolist.isEmpty() ) 1804 if ( loadOk && !todolist.isEmpty() )
1805 loadOk = qtopiaFormat.load( calendar, todolist ); 1805 loadOk = qtopiaFormat.load( calendar, todolist );
1806 1806
1807 if ( loadOk ) { 1807 if ( loadOk ) {
1808 getEventViewerDialog()->setSyncMode( true ); 1808 getEventViewerDialog()->setSyncMode( true );
1809 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1809 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1810 getEventViewerDialog()->setSyncMode( false ); 1810 getEventViewerDialog()->setSyncMode( false );
1811 qApp->processEvents(); 1811 qApp->processEvents();
1812 if ( syncOK ) { 1812 if ( syncOK ) {
1813 if ( mSyncManager->mWriteBackFile ) 1813 if ( mSyncManager->mWriteBackFile )
1814 { 1814 {
1815 // write back XML file 1815 // write back XML file
1816 1816
1817 } 1817 }
1818 setModified( true ); 1818 setModified( true );
1819 } 1819 }
1820 } else { 1820 } else {
1821 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1821 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1822 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1822 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1823 question, i18n("Ok")) ; 1823 question, i18n("Ok")) ;
1824 } 1824 }
1825 delete calendar; 1825 delete calendar;
1826 updateView(); 1826 updateView();
1827 return syncOK; 1827 return syncOK;
1828 1828
1829 1829
1830#endif 1830#endif
1831 1831
1832} 1832}
1833 1833
1834void CalendarView::setSyncEventsReadOnly() 1834void CalendarView::setSyncEventsReadOnly()
1835{ 1835{
1836 Event * ev; 1836 mCalendar->setSyncEventsReadOnly();
1837 QPtrList<Event> eL = mCalendar->rawEvents();
1838 ev = eL.first();
1839 while ( ev ) {
1840 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1841 ev->setReadOnly( true );
1842 ev = eL.next();
1843 }
1844} 1837}
1845 1838
1846bool CalendarView::loadCalendars() 1839bool CalendarView::loadCalendars()
1847{ 1840{
1848 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1841 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1849 KopiCalendarFile * cal = calendars.first(); 1842 KopiCalendarFile * cal = calendars.first();
1850 mCalendar->setDefaultCalendar( 1 ); 1843 mCalendar->setDefaultCalendar( 1 );
1851 openCalendar( MainWindow::defaultFileName(), false ); 1844 openCalendar( MainWindow::defaultFileName(), false );
1852 cal = calendars.next(); 1845 cal = calendars.next();
1853 while ( cal ) { 1846 while ( cal ) {
1854 addCalendar( cal ); 1847 addCalendar( cal );
1855 cal = calendars.next(); 1848 cal = calendars.next();
1856 } 1849 }
1857 restoreCalendarSettings(); 1850 restoreCalendarSettings();
1858 return true; 1851 return true;
1859} 1852}
1860bool CalendarView::restoreCalendarSettings() 1853bool CalendarView::restoreCalendarSettings()
1861{ 1854{
1862 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1855 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1863 KopiCalendarFile * cal = calendars.first(); 1856 KopiCalendarFile * cal = calendars.first();
1864 while ( cal ) { 1857 while ( cal ) {
1865 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1858 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1866 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1859 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1867 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1860 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1868 if ( cal->isStandard ) 1861 if ( cal->isStandard )
1869 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1862 mCalendar->setDefaultCalendar( cal->mCalNumber );
1870 cal = calendars.next(); 1863 cal = calendars.next();
1871 } 1864 }
1872 setSyncEventsReadOnly(); 1865 setSyncEventsReadOnly();
1873 mCalendar->reInitAlarmSettings(); 1866 mCalendar->reInitAlarmSettings();
1874 updateUnmanagedViews(); 1867 updateUnmanagedViews();
1875 updateView(); 1868 updateView();
1876 return true; 1869 return true;
1877} 1870}
1878void CalendarView::addCalendarId( int id ) 1871void CalendarView::addCalendarId( int id )
1879{ 1872{
1880 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1873 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1881 addCalendar( cal ); 1874 addCalendar( cal );
1882} 1875}
1883bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1876bool CalendarView::addCalendar( KopiCalendarFile * cal )
1884{ 1877{
1885 cal->mErrorOnLoad = false; 1878 cal->mErrorOnLoad = false;
1886 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1879 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1887 cal->mLoadDt = QDateTime::currentDateTime(); 1880 cal->mLoadDt = QDateTime::currentDateTime();
1888 return true; 1881 return true;
1889 } 1882 }
1890 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1883 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1891 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); 1884 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1892 cal->mErrorOnLoad = true; 1885 cal->mErrorOnLoad = true;
1893 return false; 1886 return false;
1894} 1887}
1895bool CalendarView::openCalendar(QString filename, bool merge) 1888bool CalendarView::openCalendar(QString filename, bool merge)
1896{ 1889{
1897 1890
1898 if (filename.isEmpty()) { 1891 if (filename.isEmpty()) {
1899 return false; 1892 return false;
1900 } 1893 }
1901 1894
1902 if (!QFile::exists(filename)) { 1895 if (!QFile::exists(filename)) {
1903 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1896 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1904 return false; 1897 return false;
1905 } 1898 }
1906 1899
1907 globalFlagBlockAgenda = 1; 1900 globalFlagBlockAgenda = 1;
1908 clearAllViews(); 1901 clearAllViews();
1909 if (!merge) { 1902 if (!merge) {
1910 mViewManager->setDocumentId( filename ); 1903 mViewManager->setDocumentId( filename );
1911 mCalendar->close(); 1904 mCalendar->close();
1912 } 1905 }
1913 mStorage->setFileName( filename ); 1906 mStorage->setFileName( filename );
1914 1907
1915 if ( mStorage->load() ) { 1908 if ( mStorage->load() ) {
1916 if ( merge ) ;//setModified( true ); 1909 if ( merge ) ;//setModified( true );
1917 else { 1910 else {
1918 //setModified( true ); 1911 //setModified( true );
1919 mViewManager->setDocumentId( filename ); 1912 mViewManager->setDocumentId( filename );
1920 mDialogManager->setDocumentId( filename ); 1913 mDialogManager->setDocumentId( filename );
1921 mTodoList->setDocumentId( filename ); 1914 mTodoList->setDocumentId( filename );
1922 } 1915 }
1923 globalFlagBlockAgenda = 2; 1916 globalFlagBlockAgenda = 2;
1924 // if ( getLastSyncEvent() ) 1917 // if ( getLastSyncEvent() )
1925 // getLastSyncEvent()->setReadOnly( true ); 1918 // getLastSyncEvent()->setReadOnly( true );
1926 mCalendar->reInitAlarmSettings(); 1919 mCalendar->reInitAlarmSettings();
1927 setSyncEventsReadOnly(); 1920 setSyncEventsReadOnly();
1928 updateUnmanagedViews(); 1921 updateUnmanagedViews();
1929 updateView(); 1922 updateView();
1930 if ( filename != MainWindow::defaultFileName() ) { 1923 if ( filename != MainWindow::defaultFileName() ) {
1931 saveCalendar( MainWindow::defaultFileName() ); 1924 saveCalendar( MainWindow::defaultFileName() );
1932 } else { 1925 } else {
1933 QFileInfo finf ( MainWindow::defaultFileName()); 1926 QFileInfo finf ( MainWindow::defaultFileName());
1934 if ( finf.exists() ) { 1927 if ( finf.exists() ) {
1935 setLoadedFileVersion( finf.lastModified () ); 1928 setLoadedFileVersion( finf.lastModified () );
1936 } 1929 }
1937 } 1930 }
1938 return true; 1931 return true;
1939 } else { 1932 } else {
1940 // while failing to load, the calendar object could 1933 // while failing to load, the calendar object could
1941 // have become partially populated. Clear it out. 1934 // have become partially populated. Clear it out.
1942 if ( !merge ) { 1935 if ( !merge ) {
1943 mCalendar->close(); 1936 mCalendar->close();
1944 mViewManager->setDocumentId( filename ); 1937 mViewManager->setDocumentId( filename );
1945 mDialogManager->setDocumentId( filename ); 1938 mDialogManager->setDocumentId( filename );
1946 mTodoList->setDocumentId( filename ); 1939 mTodoList->setDocumentId( filename );
1947 } 1940 }
1948 1941
1949 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1942 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1950 1943
1951 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1944 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1952 globalFlagBlockAgenda = 2; 1945 globalFlagBlockAgenda = 2;
1953 mCalendar->reInitAlarmSettings(); 1946 mCalendar->reInitAlarmSettings();
1954 setSyncEventsReadOnly(); 1947 setSyncEventsReadOnly();
1955 updateUnmanagedViews(); 1948 updateUnmanagedViews();
1956 updateView(); 1949 updateView();
1957 } 1950 }
1958 return false; 1951 return false;
1959} 1952}
1960void CalendarView::showOpenError() 1953void CalendarView::showOpenError()
1961{ 1954{
1962 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1955 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1963} 1956}
1964void CalendarView::setLoadedFileVersion(QDateTime dt) 1957void CalendarView::setLoadedFileVersion(QDateTime dt)
1965{ 1958{
1966 loadedFileVersion = dt; 1959 loadedFileVersion = dt;
1967} 1960}
1968bool CalendarView::checkFileChanged(QString fn) 1961bool CalendarView::checkFileChanged(QString fn)
1969{ 1962{
1970 QFileInfo finf ( fn ); 1963 QFileInfo finf ( fn );
1971 if ( !finf.exists() ) 1964 if ( !finf.exists() )
1972 return true; 1965 return true;
1973 QDateTime dt = finf.lastModified (); 1966 QDateTime dt = finf.lastModified ();
1974 if ( dt <= loadedFileVersion ) 1967 if ( dt <= loadedFileVersion )
1975 return false; 1968 return false;
1976 return true; 1969 return true;
1977 1970
1978} 1971}
1979void CalendarView::watchSavedFile() 1972void CalendarView::watchSavedFile()
1980{ 1973{
1981 QFileInfo finf ( MainWindow::defaultFileName()); 1974 QFileInfo finf ( MainWindow::defaultFileName());
1982 if ( !finf.exists() ) 1975 if ( !finf.exists() )
1983 return; 1976 return;
1984 QDateTime dt = finf.lastModified (); 1977 QDateTime dt = finf.lastModified ();
1985 if ( dt < loadedFileVersion ) { 1978 if ( dt < loadedFileVersion ) {
1986 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1979 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1987 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1980 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1988 return; 1981 return;
1989 } 1982 }
1990 loadedFileVersion = dt; 1983 loadedFileVersion = dt;
1991} 1984}
1992bool CalendarView::checkAllFileVersions() 1985bool CalendarView::checkAllFileVersions()
1993{ 1986{
1994 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1987 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1995 KopiCalendarFile * cal = calendars.first(); 1988 KopiCalendarFile * cal = calendars.first();
1996 mCalendar->setDefaultCalendar( 1 ); 1989 mCalendar->setDefaultCalendar( 1 );
1997 mCalendar->setDefaultCalendarEnabledOnly(); 1990 mCalendar->setDefaultCalendarEnabledOnly();
1998 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 1991 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
1999 if ( !checkFileVersion(MainWindow::defaultFileName())) { 1992 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2000 restoreCalendarSettings(); 1993 restoreCalendarSettings();
2001 return false; 1994 return false;
2002 } 1995 }
2003 } 1996 }
2004 cal = calendars.next(); 1997 cal = calendars.next();
2005 QDateTime storeTemp = loadedFileVersion; 1998 QDateTime storeTemp = loadedFileVersion;
2006 while ( cal ) { 1999 while ( cal ) {
2007 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2000 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2008 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2001 mCalendar->setDefaultCalendar( cal->mCalNumber );
2009 mCalendar->setDefaultCalendarEnabledOnly(); 2002 mCalendar->setDefaultCalendarEnabledOnly();
2010 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2003 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2011 if ( !checkFileVersion(cal->mFileName )) { 2004 if ( !checkFileVersion(cal->mFileName )) {
2012 loadedFileVersion = storeTemp; 2005 loadedFileVersion = storeTemp;
2013 restoreCalendarSettings(); 2006 restoreCalendarSettings();
2014 return false; 2007 return false;
2015 } 2008 }
2016 } 2009 }
2017 cal = calendars.next(); 2010 cal = calendars.next();
2018 } 2011 }
2019 loadedFileVersion = storeTemp; 2012 loadedFileVersion = storeTemp;
2020 return true; 2013 return true;
2021} 2014}
2022bool CalendarView::checkFileVersion(QString fn) 2015bool CalendarView::checkFileVersion(QString fn)
2023{ 2016{
2024 QFileInfo finf ( fn ); 2017 QFileInfo finf ( fn );
2025 if ( !finf.exists() ) 2018 if ( !finf.exists() )
2026 return true; 2019 return true;
2027 QDateTime dt = finf.lastModified (); 2020 QDateTime dt = finf.lastModified ();
2028 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1()); 2021 qDebug("loaded file version %s %s", fn.latin1(), loadedFileVersion.toString().latin1());
2029 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1()); 2022 qDebug("file on disk version %s %s", fn.latin1(),dt.toString().latin1());
2030 if ( dt <= loadedFileVersion ) 2023 if ( dt <= loadedFileVersion )
2031 return true; 2024 return true;
2032 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2025 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\n on disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(fn).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2033 i18n("KO/Pi Warning"),i18n("Overwrite"), 2026 i18n("KO/Pi Warning"),i18n("Overwrite"),
2034 i18n("Sync+save")); 2027 i18n("Sync+save"));
2035 2028
2036 if ( km == KMessageBox::Cancel ) 2029 if ( km == KMessageBox::Cancel )
2037 return false; 2030 return false;
2038 if ( km == KMessageBox::Yes ) 2031 if ( km == KMessageBox::Yes )
2039 return true; 2032 return true;
2040 2033
2041 setSyncDevice("deleteaftersync" ); 2034 setSyncDevice("deleteaftersync" );
2042 mSyncManager->mAskForPreferences = true; 2035 mSyncManager->mAskForPreferences = true;
2043 mSyncManager->mSyncAlgoPrefs = 3; 2036 mSyncManager->mSyncAlgoPrefs = 3;
2044 mSyncManager->mWriteBackFile = false; 2037 mSyncManager->mWriteBackFile = false;
2045 mSyncManager->mWriteBackExistingOnly = false; 2038 mSyncManager->mWriteBackExistingOnly = false;
2046 mSyncManager->mShowSyncSummary = false; 2039 mSyncManager->mShowSyncSummary = false;
2047 syncCalendar( fn, 3 ); 2040 syncCalendar( fn, 3 );
2048 Event * e = getLastSyncEvent(); 2041 Event * e = getLastSyncEvent();
2049 if ( e ) 2042 if ( e )
2050 mCalendar->deleteEvent( e ); 2043 mCalendar->deleteEvent( e );
2051 return true; 2044 return true;
2052} 2045}
2053bool CalendarView::saveCalendars() 2046bool CalendarView::saveCalendars()
2054{ 2047{
2055 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2048 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2056 KopiCalendarFile * cal = calendars.first(); 2049 KopiCalendarFile * cal = calendars.first();
2057 mCalendar->setDefaultCalendar( 1 ); 2050 mCalendar->setDefaultCalendar( 1 );
2058 mCalendar->setDefaultCalendarEnabledOnly(); 2051 mCalendar->setDefaultCalendarEnabledOnly();
2059 saveCalendar( MainWindow::defaultFileName() ); 2052 saveCalendar( MainWindow::defaultFileName() );
2060 cal = calendars.next(); 2053 cal = calendars.next();
2061 while ( cal ) { 2054 while ( cal ) {
2062 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2055 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2063 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2056 mCalendar->setDefaultCalendar( cal->mCalNumber );
2064 mCalendar->setDefaultCalendarEnabledOnly(); 2057 mCalendar->setDefaultCalendarEnabledOnly();
2065 if ( saveCalendar( cal->mFileName ) ) 2058 if ( saveCalendar( cal->mFileName ) )
2066 cal->mLoadDt = QDateTime::currentDateTime(); 2059 cal->mLoadDt = QDateTime::currentDateTime();
2067 } 2060 }
2068 cal = calendars.next(); 2061 cal = calendars.next();
2069 } 2062 }
2070 restoreCalendarSettings(); 2063 restoreCalendarSettings();
2071 return true; 2064 return true;
2072} 2065}
2073bool CalendarView::saveCalendar( QString filename ) 2066bool CalendarView::saveCalendar( QString filename )
2074{ 2067{
2075 2068
2076 // Store back all unsaved data into calendar object 2069 // Store back all unsaved data into calendar object
2077 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 2070 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
2078 if ( mViewManager->currentView() ) 2071 if ( mViewManager->currentView() )
2079 mViewManager->currentView()->flushView(); 2072 mViewManager->currentView()->flushView();
2080 2073
2081 2074
2082 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 2075 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
2083 mStorage->setSaveFormat( new ICalFormat() ); 2076 mStorage->setSaveFormat( new ICalFormat() );
2084 mStorage->setFileName( filename ); 2077 mStorage->setFileName( filename );
2085 bool success; 2078 bool success;
2086 success = mStorage->save(); 2079 success = mStorage->save();
2087 if ( !success ) { 2080 if ( !success ) {
2088 return false; 2081 return false;
2089 } 2082 }
2090 if ( filename == MainWindow::defaultFileName() ) { 2083 if ( filename == MainWindow::defaultFileName() ) {
2091 setLoadedFileVersion( lfv ); 2084 setLoadedFileVersion( lfv );
2092 watchSavedFile(); 2085 watchSavedFile();
2093 } 2086 }
2094 return true; 2087 return true;
2095} 2088}
2096 2089
2097void CalendarView::closeCalendar() 2090void CalendarView::closeCalendar()
2098{ 2091{
2099 2092
2100 // child windows no longer valid 2093 // child windows no longer valid
2101 clearAllViews(); 2094 clearAllViews();
2102 emit closingDown(); 2095 emit closingDown();
2103 2096
2104 mCalendar->close(); 2097 mCalendar->close();
2105 setModified(false); 2098 setModified(false);
2106 updateView(); 2099 updateView();
2107} 2100}
2108 2101
2109void CalendarView::archiveCalendar() 2102void CalendarView::archiveCalendar()
2110{ 2103{
2111 mDialogManager->showArchiveDialog(); 2104 mDialogManager->showArchiveDialog();
2112} 2105}
2113 2106
2114 2107
2115void CalendarView::readSettings() 2108void CalendarView::readSettings()
2116{ 2109{
2117 2110
2118 2111
2119 // mViewManager->showAgendaView(); 2112 // mViewManager->showAgendaView();
2120 QString str; 2113 QString str;
2121 //qDebug("CalendarView::readSettings() "); 2114 //qDebug("CalendarView::readSettings() ");
2122 // read settings from the KConfig, supplying reasonable 2115 // read settings from the KConfig, supplying reasonable
2123 // defaults where none are to be found 2116 // defaults where none are to be found
2124 KConfig *config = KOGlobals::config(); 2117 KConfig *config = KOGlobals::config();
2125#ifndef KORG_NOSPLITTER 2118#ifndef KORG_NOSPLITTER
2126 config->setGroup("KOrganizer Geometry"); 2119 config->setGroup("KOrganizer Geometry");
2127 2120
2128 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2121 QValueList<int> sizes = config->readIntListEntry("Separator1");
2129 if (sizes.count() != 2) { 2122 if (sizes.count() != 2) {
2130 sizes << mDateNavigator->minimumSizeHint().width(); 2123 sizes << mDateNavigator->minimumSizeHint().width();
2131 sizes << 300; 2124 sizes << 300;
2132 } 2125 }
2133 mPanner->setSizes(sizes); 2126 mPanner->setSizes(sizes);
2134 2127
2135 sizes = config->readIntListEntry("Separator2"); 2128 sizes = config->readIntListEntry("Separator2");
2136 if ( ( mResourceView && sizes.count() == 4 ) || 2129 if ( ( mResourceView && sizes.count() == 4 ) ||
2137 ( !mResourceView && sizes.count() == 3 ) ) { 2130 ( !mResourceView && sizes.count() == 3 ) ) {
2138 mLeftSplitter->setSizes(sizes); 2131 mLeftSplitter->setSizes(sizes);
2139 } 2132 }
2140#endif 2133#endif
2141 globalFlagBlockAgenda = 1; 2134 globalFlagBlockAgenda = 1;
2142 mViewManager->showAgendaView(); 2135 mViewManager->showAgendaView();
2143 //mViewManager->readSettings( config ); 2136 //mViewManager->readSettings( config );
2144 mTodoList->restoreLayout(config,QString("Todo Layout")); 2137 mTodoList->restoreLayout(config,QString("Todo Layout"));
2145 readFilterSettings(config); 2138 readFilterSettings(config);
2146 2139
2147#ifdef DESKTOP_VERSION 2140#ifdef DESKTOP_VERSION
2148 config->setGroup("WidgetLayout"); 2141 config->setGroup("WidgetLayout");
2149 QStringList list; 2142 QStringList list;
2150 list = config->readListEntry("MainLayout"); 2143 list = config->readListEntry("MainLayout");
2151 int x,y,w,h; 2144 int x,y,w,h;
2152 if ( ! list.isEmpty() ) { 2145 if ( ! list.isEmpty() ) {
2153 x = list[0].toInt(); 2146 x = list[0].toInt();
2154 y = list[1].toInt(); 2147 y = list[1].toInt();
2155 w = list[2].toInt(); 2148 w = list[2].toInt();
2156 h = list[3].toInt(); 2149 h = list[3].toInt();
2157 KApplication::testCoords( &x,&y,&w,&h ); 2150 KApplication::testCoords( &x,&y,&w,&h );
2158 topLevelWidget()->setGeometry(x,y,w,h); 2151 topLevelWidget()->setGeometry(x,y,w,h);
2159 2152
2160 } else { 2153 } else {
2161 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2154 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2162 } 2155 }
2163 list = config->readListEntry("EditEventLayout"); 2156 list = config->readListEntry("EditEventLayout");
2164 if ( ! list.isEmpty() ) { 2157 if ( ! list.isEmpty() ) {
2165 x = list[0].toInt(); 2158 x = list[0].toInt();
2166 y = list[1].toInt(); 2159 y = list[1].toInt();
2167 w = list[2].toInt(); 2160 w = list[2].toInt();
2168 h = list[3].toInt(); 2161 h = list[3].toInt();
2169 KApplication::testCoords( &x,&y,&w,&h ); 2162 KApplication::testCoords( &x,&y,&w,&h );
2170 mEventEditor->setGeometry(x,y,w,h); 2163 mEventEditor->setGeometry(x,y,w,h);
2171 2164
2172 } 2165 }
2173 list = config->readListEntry("EditTodoLayout"); 2166 list = config->readListEntry("EditTodoLayout");
2174 if ( ! list.isEmpty() ) { 2167 if ( ! list.isEmpty() ) {
2175 x = list[0].toInt(); 2168 x = list[0].toInt();
2176 y = list[1].toInt(); 2169 y = list[1].toInt();
2177 w = list[2].toInt(); 2170 w = list[2].toInt();
2178 h = list[3].toInt(); 2171 h = list[3].toInt();
2179 KApplication::testCoords( &x,&y,&w,&h ); 2172 KApplication::testCoords( &x,&y,&w,&h );
2180 mTodoEditor->setGeometry(x,y,w,h); 2173 mTodoEditor->setGeometry(x,y,w,h);
2181 2174
2182 } 2175 }
2183 list = config->readListEntry("ViewerLayout"); 2176 list = config->readListEntry("ViewerLayout");
2184 if ( ! list.isEmpty() ) { 2177 if ( ! list.isEmpty() ) {
2185 x = list[0].toInt(); 2178 x = list[0].toInt();
2186 y = list[1].toInt(); 2179 y = list[1].toInt();
2187 w = list[2].toInt(); 2180 w = list[2].toInt();
2188 h = list[3].toInt(); 2181 h = list[3].toInt();
2189 KApplication::testCoords( &x,&y,&w,&h ); 2182 KApplication::testCoords( &x,&y,&w,&h );
2190 getEventViewerDialog()->setGeometry(x,y,w,h); 2183 getEventViewerDialog()->setGeometry(x,y,w,h);
2191 } 2184 }
2192#endif 2185#endif
2193 config->setGroup( "Views" ); 2186 config->setGroup( "Views" );
2194 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2187 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2195 2188
2196 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2189 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2197 2190
2198 int resetval = 0; 2191 int resetval = 0;
2199 int maxVal = 0; 2192 int maxVal = 0;
2200 if (sizes.count() != 3) { 2193 if (sizes.count() != 3) {
2201 if ( KOPrefs::instance()->mVerticalScreen ) { 2194 if ( KOPrefs::instance()->mVerticalScreen ) {
2202 resetval = mDateNavigator->sizeHint().width()+2; 2195 resetval = mDateNavigator->sizeHint().width()+2;
2203 } else { 2196 } else {
2204 resetval = mDateNavigator->sizeHint().height()+2; 2197 resetval = mDateNavigator->sizeHint().height()+2;
2205 } 2198 }
2206 } 2199 }
2207 if ( resetval ) { 2200 if ( resetval ) {
2208 sizes.clear(); 2201 sizes.clear();
2209 if ( KOPrefs::instance()->mVerticalScreen ) { 2202 if ( KOPrefs::instance()->mVerticalScreen ) {
2210 maxVal = QApplication::desktop()->width() -10; 2203 maxVal = QApplication::desktop()->width() -10;
2211 } else { 2204 } else {
2212 maxVal = QApplication::desktop()->height()-10; 2205 maxVal = QApplication::desktop()->height()-10;
2213 } 2206 }
2214 sizes << resetval; 2207 sizes << resetval;
2215 if ( maxVal < resetval + resetval) 2208 if ( maxVal < resetval + resetval)
2216 resetval = maxVal - resetval; 2209 resetval = maxVal - resetval;
2217 sizes << resetval; 2210 sizes << resetval;
2218 sizes << 100; 2211 sizes << 100;
2219 } 2212 }
2220 mLeftFrame->setSizes(sizes); 2213 mLeftFrame->setSizes(sizes);
2221 sizes = config->readIntListEntry("Main Splitter Frame"); 2214 sizes = config->readIntListEntry("Main Splitter Frame");
2222 resetval = 0; 2215 resetval = 0;
2223 maxVal = 0; 2216 maxVal = 0;
2224 if (sizes.count() != 2) { 2217 if (sizes.count() != 2) {
2225 if ( !KOPrefs::instance()->mVerticalScreen ) { 2218 if ( !KOPrefs::instance()->mVerticalScreen ) {
2226 resetval = mDateNavigator->sizeHint().width()+2; 2219 resetval = mDateNavigator->sizeHint().width()+2;
2227 } else { 2220 } else {
2228 resetval = mDateNavigator->sizeHint().height()+2; 2221 resetval = mDateNavigator->sizeHint().height()+2;
2229 } 2222 }
2230 } 2223 }
2231 if ( resetval ) { 2224 if ( resetval ) {
2232 sizes.clear(); 2225 sizes.clear();
2233 if ( !KOPrefs::instance()->mVerticalScreen ) { 2226 if ( !KOPrefs::instance()->mVerticalScreen ) {
2234 maxVal = QApplication::desktop()->width() -10; 2227 maxVal = QApplication::desktop()->width() -10;
2235 } else { 2228 } else {
2236 maxVal = QApplication::desktop()->height()-10; 2229 maxVal = QApplication::desktop()->height()-10;
2237 } 2230 }
2238 sizes << resetval; 2231 sizes << resetval;
2239 if ( maxVal < resetval + resetval) 2232 if ( maxVal < resetval + resetval)
2240 resetval = maxVal - resetval; 2233 resetval = maxVal - resetval;
2241 sizes << resetval; 2234 sizes << resetval;
2242 } 2235 }
2243 mMainFrame->setSizes(sizes); 2236 mMainFrame->setSizes(sizes);
2244 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2237 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2245 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2238 else if ( dateCount == 7 ) mNavigator->selectWeek();
2246 else mNavigator->selectDates( dateCount ); 2239 else mNavigator->selectDates( dateCount );
2247 // mViewManager->readSettings( config ); 2240 // mViewManager->readSettings( config );
2248 updateConfig(); 2241 updateConfig();
2249 globalFlagBlockAgenda = 2; 2242 globalFlagBlockAgenda = 2;
2250 mViewManager->readSettings( config ); 2243 mViewManager->readSettings( config );
2251 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2244 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2252} 2245}
2253 2246
2254 2247
2255void CalendarView::writeSettings() 2248void CalendarView::writeSettings()
2256{ 2249{
2257 // kdDebug() << "CalendarView::writeSettings" << endl; 2250 // kdDebug() << "CalendarView::writeSettings" << endl;
2258 2251
2259 KConfig *config = KOGlobals::config(); 2252 KConfig *config = KOGlobals::config();
2260 2253
2261 mViewManager->writeSettings( config ); 2254 mViewManager->writeSettings( config );
2262 mTodoList->saveLayout(config,QString("Todo Layout")); 2255 mTodoList->saveLayout(config,QString("Todo Layout"));
2263 mDialogManager->writeSettings( config ); 2256 mDialogManager->writeSettings( config );
2264 //KOPrefs::instance()->usrWriteConfig(); 2257 //KOPrefs::instance()->usrWriteConfig();
2265 KOPrefs::instance()->writeConfig(); 2258 KOPrefs::instance()->writeConfig();
2266 2259
2267 writeFilterSettings(config); 2260 writeFilterSettings(config);
2268 config->setGroup( "AppRun" ); 2261 config->setGroup( "AppRun" );
2269 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2262 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2270 int days = dt.daysTo( QDate::currentDate() ); 2263 int days = dt.daysTo( QDate::currentDate() );
2271 dt = dt.addDays( days ); 2264 dt = dt.addDays( days );
2272 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2265 int secs = dt.secsTo( QDateTime::currentDateTime() );
2273 config->writeEntry( "LatestProgramStopDays", days ); 2266 config->writeEntry( "LatestProgramStopDays", days );
2274 config->writeEntry( "LatestProgramStopSecs", secs ); 2267 config->writeEntry( "LatestProgramStopSecs", secs );
2275 //qDebug("KO: Writing stop time: %d ", secs); 2268 //qDebug("KO: Writing stop time: %d ", secs);
2276 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2269 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2277 //QDateTime latest = dt.addSecs ( secs ); 2270 //QDateTime latest = dt.addSecs ( secs );
2278 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2271 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2279 config->setGroup( "Views" ); 2272 config->setGroup( "Views" );
2280 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2273 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2281 2274
2282#if 0 2275#if 0
2283 qDebug("********************* "); 2276 qDebug("********************* ");
2284 qDebug("Testcode secsto "); 2277 qDebug("Testcode secsto ");
2285 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2278 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2286 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2279 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2287 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2280 int secsto = dt_nodaylight.secsTo( dt_daylight );
2288 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2281 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2289 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2282 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2290 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2283 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2291 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2284 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2292 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2285 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2293 qDebug("********************* testcode end"); 2286 qDebug("********************* testcode end");
2294 2287
2295#endif 2288#endif
2296 2289
2297 QValueList<int> listINT = mLeftFrame->sizes(); 2290 QValueList<int> listINT = mLeftFrame->sizes();
2298 config->writeEntry("Left Splitter Frame",listINT); 2291 config->writeEntry("Left Splitter Frame",listINT);
2299 QValueList<int> listINT2 = mMainFrame->sizes(); 2292 QValueList<int> listINT2 = mMainFrame->sizes();
2300 config->writeEntry("Main Splitter Frame",listINT2); 2293 config->writeEntry("Main Splitter Frame",listINT2);
2301#ifdef DESKTOP_VERSION 2294#ifdef DESKTOP_VERSION
2302 config->setGroup("WidgetLayout"); 2295 config->setGroup("WidgetLayout");
2303 QStringList list ;//= config->readListEntry("MainLayout"); 2296 QStringList list ;//= config->readListEntry("MainLayout");
2304 int x,y,w,h; 2297 int x,y,w,h;
2305 QWidget* wid; 2298 QWidget* wid;
2306 wid = topLevelWidget(); 2299 wid = topLevelWidget();
2307 x = wid->geometry().x(); 2300 x = wid->geometry().x();
2308 y = wid->geometry().y(); 2301 y = wid->geometry().y();
2309 w = wid->width(); 2302 w = wid->width();
2310 h = wid->height(); 2303 h = wid->height();
2311 list.clear(); 2304 list.clear();
2312 list << QString::number( x ); 2305 list << QString::number( x );
2313 list << QString::number( y ); 2306 list << QString::number( y );
2314 list << QString::number( w ); 2307 list << QString::number( w );
2315 list << QString::number( h ); 2308 list << QString::number( h );
2316 config->writeEntry("MainLayout",list ); 2309 config->writeEntry("MainLayout",list );
2317 2310
2318 wid = mEventEditor; 2311 wid = mEventEditor;
2319 x = wid->geometry().x(); 2312 x = wid->geometry().x();
2320 y = wid->geometry().y(); 2313 y = wid->geometry().y();
2321 w = wid->width(); 2314 w = wid->width();
2322 h = wid->height(); 2315 h = wid->height();
2323 list.clear(); 2316 list.clear();
2324 list << QString::number( x ); 2317 list << QString::number( x );
2325 list << QString::number( y ); 2318 list << QString::number( y );
2326 list << QString::number( w ); 2319 list << QString::number( w );
2327 list << QString::number( h ); 2320 list << QString::number( h );
2328 config->writeEntry("EditEventLayout",list ); 2321 config->writeEntry("EditEventLayout",list );
2329 2322
2330 wid = mTodoEditor; 2323 wid = mTodoEditor;
2331 x = wid->geometry().x(); 2324 x = wid->geometry().x();
2332 y = wid->geometry().y(); 2325 y = wid->geometry().y();
2333 w = wid->width(); 2326 w = wid->width();
2334 h = wid->height(); 2327 h = wid->height();
2335 list.clear(); 2328 list.clear();
2336 list << QString::number( x ); 2329 list << QString::number( x );
2337 list << QString::number( y ); 2330 list << QString::number( y );
2338 list << QString::number( w ); 2331 list << QString::number( w );
2339 list << QString::number( h ); 2332 list << QString::number( h );
2340 config->writeEntry("EditTodoLayout",list ); 2333 config->writeEntry("EditTodoLayout",list );
2341 wid = getEventViewerDialog(); 2334 wid = getEventViewerDialog();
2342 x = wid->geometry().x(); 2335 x = wid->geometry().x();
2343 y = wid->geometry().y(); 2336 y = wid->geometry().y();
2344 w = wid->width(); 2337 w = wid->width();
2345 h = wid->height(); 2338 h = wid->height();
2346 list.clear(); 2339 list.clear();
2347 list << QString::number( x ); 2340 list << QString::number( x );
2348 list << QString::number( y ); 2341 list << QString::number( y );
2349 list << QString::number( w ); 2342 list << QString::number( w );
2350 list << QString::number( h ); 2343 list << QString::number( h );
2351 config->writeEntry("ViewerLayout",list ); 2344 config->writeEntry("ViewerLayout",list );
2352 wid = mDialogManager->getSearchDialog(); 2345 wid = mDialogManager->getSearchDialog();
2353 if ( wid ) { 2346 if ( wid ) {
2354 x = wid->geometry().x(); 2347 x = wid->geometry().x();
2355 y = wid->geometry().y(); 2348 y = wid->geometry().y();
2356 w = wid->width(); 2349 w = wid->width();
2357 h = wid->height(); 2350 h = wid->height();
2358 list.clear(); 2351 list.clear();
2359 list << QString::number( x ); 2352 list << QString::number( x );
2360 list << QString::number( y ); 2353 list << QString::number( y );
2361 list << QString::number( w ); 2354 list << QString::number( w );
2362 list << QString::number( h ); 2355 list << QString::number( h );
2363 config->writeEntry("SearchLayout",list ); 2356 config->writeEntry("SearchLayout",list );
2364 } 2357 }
2365#endif 2358#endif
2366 2359
2367 2360
2368 config->sync(); 2361 config->sync();
2369} 2362}
2370 2363
2371void CalendarView::readFilterSettings(KConfig *config) 2364void CalendarView::readFilterSettings(KConfig *config)
2372{ 2365{
2373 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2366 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2374 2367
2375 mFilters.clear(); 2368 mFilters.clear();
2376 2369
2377 config->setGroup("General"); 2370 config->setGroup("General");
2378 QStringList filterList = config->readListEntry("CalendarFilters"); 2371 QStringList filterList = config->readListEntry("CalendarFilters");
2379 2372
2380 QStringList::ConstIterator it = filterList.begin(); 2373 QStringList::ConstIterator it = filterList.begin();
2381 QStringList::ConstIterator end = filterList.end(); 2374 QStringList::ConstIterator end = filterList.end();
2382 while(it != end) { 2375 while(it != end) {
2383 // kdDebug() << " filter: " << (*it) << endl; 2376 // kdDebug() << " filter: " << (*it) << endl;
2384 2377
2385 CalFilter *filter; 2378 CalFilter *filter;
2386 filter = new CalFilter(*it); 2379 filter = new CalFilter(*it);
2387 config->setGroup("Filter_" + (*it).utf8()); 2380 config->setGroup("Filter_" + (*it).utf8());
2388 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2381 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2389 filter->setCriteria(config->readNumEntry("Criteria",0)); 2382 filter->setCriteria(config->readNumEntry("Criteria",0));
2390 filter->setCategoryList(config->readListEntry("CategoryList")); 2383 filter->setCategoryList(config->readListEntry("CategoryList"));
2391 mFilters.append(filter); 2384 mFilters.append(filter);
2392 2385
2393 ++it; 2386 ++it;
2394 } 2387 }
2395 2388
2396 if (mFilters.count() == 0) { 2389 if (mFilters.count() == 0) {
2397 CalFilter *filter = new CalFilter(i18n("Default")); 2390 CalFilter *filter = new CalFilter(i18n("Default"));
2398 mFilters.append(filter); 2391 mFilters.append(filter);
2399 } 2392 }
2400 mFilterView->updateFilters(); 2393 mFilterView->updateFilters();
2401 config->setGroup("FilterView"); 2394 config->setGroup("FilterView");
2402 2395
2403 mFilterView->blockSignals(true); 2396 mFilterView->blockSignals(true);
2404 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2397 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2405 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2398 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2406 mFilterView->blockSignals(false); 2399 mFilterView->blockSignals(false);
2407 // We do it manually to avoid it being done twice by the above calls 2400 // We do it manually to avoid it being done twice by the above calls
2408 updateFilter(); 2401 updateFilter();
2409} 2402}
2410 2403
2411void CalendarView::writeFilterSettings(KConfig *config) 2404void CalendarView::writeFilterSettings(KConfig *config)
2412{ 2405{
2413 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2406 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2414 2407
2415 QStringList filterList; 2408 QStringList filterList;
2416 2409
2417 CalFilter *filter = mFilters.first(); 2410 CalFilter *filter = mFilters.first();
2418 while(filter) { 2411 while(filter) {
2419 // kdDebug() << " fn: " << filter->name() << endl; 2412 // kdDebug() << " fn: " << filter->name() << endl;
2420 filterList << filter->name(); 2413 filterList << filter->name();
2421 config->setGroup("Filter_" + filter->name().utf8()); 2414 config->setGroup("Filter_" + filter->name().utf8());
2422 config->writeEntry("Criteria",filter->criteria()); 2415 config->writeEntry("Criteria",filter->criteria());
2423 config->writeEntry("CategoryList",filter->categoryList()); 2416 config->writeEntry("CategoryList",filter->categoryList());
2424 filter = mFilters.next(); 2417 filter = mFilters.next();
2425 } 2418 }
2426 config->setGroup("General"); 2419 config->setGroup("General");
2427 config->writeEntry("CalendarFilters",filterList); 2420 config->writeEntry("CalendarFilters",filterList);
2428 2421
2429 config->setGroup("FilterView"); 2422 config->setGroup("FilterView");
2430 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2423 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2431 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2424 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2432} 2425}
2433 2426
2434 2427
2435void CalendarView::goToday() 2428void CalendarView::goToday()
2436{ 2429{
2437 if ( mViewManager->currentView()->isMonthView() ) 2430 if ( mViewManager->currentView()->isMonthView() )
2438 mNavigator->selectTodayMonth(); 2431 mNavigator->selectTodayMonth();
2439 else 2432 else
2440 mNavigator->selectToday(); 2433 mNavigator->selectToday();
2441} 2434}
2442 2435
2443void CalendarView::goNext() 2436void CalendarView::goNext()
2444{ 2437{
2445 mNavigator->selectNext(); 2438 mNavigator->selectNext();
2446} 2439}
2447 2440
2448void CalendarView::goPrevious() 2441void CalendarView::goPrevious()
2449{ 2442{
2450 mNavigator->selectPrevious(); 2443 mNavigator->selectPrevious();
2451} 2444}
2452void CalendarView::goNextMonth() 2445void CalendarView::goNextMonth()
2453{ 2446{
2454 mNavigator->selectNextMonth(); 2447 mNavigator->selectNextMonth();
2455} 2448}
2456 2449
2457void CalendarView::goPreviousMonth() 2450void CalendarView::goPreviousMonth()
2458{ 2451{
2459 mNavigator->selectPreviousMonth(); 2452 mNavigator->selectPreviousMonth();
2460} 2453}
2461void CalendarView::writeLocale() 2454void CalendarView::writeLocale()
2462{ 2455{
2463 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2456 //KPimGlobalPrefs::instance()->setGlobalConfig();
2464#if 0 2457#if 0
2465 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2458 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2466 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2459 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2467 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2460 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2468 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2461 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2469 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2462 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2470 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2463 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2471 dummy = KOPrefs::instance()->mUserDateFormatShort; 2464 dummy = KOPrefs::instance()->mUserDateFormatShort;
2472 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2465 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2473 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2466 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2474 KOPrefs::instance()->mDaylightsavingStart, 2467 KOPrefs::instance()->mDaylightsavingStart,
2475 KOPrefs::instance()->mDaylightsavingEnd ); 2468 KOPrefs::instance()->mDaylightsavingEnd );
2476 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2469 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2477#endif 2470#endif
2478} 2471}
2479void CalendarView::updateConfig() 2472void CalendarView::updateConfig()
2480{ 2473{
2481 writeLocale(); 2474 writeLocale();
2482 if ( KOPrefs::instance()->mUseAppColors ) 2475 if ( KOPrefs::instance()->mUseAppColors )
2483 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2476 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2484 emit configChanged(); 2477 emit configChanged();
2485 mTodoList->updateConfig(); 2478 mTodoList->updateConfig();
2486 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2479 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2487 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2480 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2488 // To make the "fill window" configurations work 2481 // To make the "fill window" configurations work
2489 //mViewManager->raiseCurrentView(); 2482 //mViewManager->raiseCurrentView();
2490} 2483}
2491 2484
2492 2485
2493void CalendarView::eventChanged(Event *event) 2486void CalendarView::eventChanged(Event *event)
2494{ 2487{
2495 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2488 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2496 //updateUnmanagedViews(); 2489 //updateUnmanagedViews();
2497} 2490}
2498 2491
2499void CalendarView::eventAdded(Event *event) 2492void CalendarView::eventAdded(Event *event)
2500{ 2493{
2501 changeEventDisplay(event,KOGlobals::EVENTADDED); 2494 changeEventDisplay(event,KOGlobals::EVENTADDED);
2502} 2495}
2503 2496
2504void CalendarView::eventToBeDeleted(Event *) 2497void CalendarView::eventToBeDeleted(Event *)
2505{ 2498{
2506 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2499 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2507} 2500}
2508 2501
2509void CalendarView::eventDeleted() 2502void CalendarView::eventDeleted()
2510{ 2503{
2511 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2504 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2512} 2505}
2513void CalendarView::changeTodoDisplay(Todo *which, int action) 2506void CalendarView::changeTodoDisplay(Todo *which, int action)
2514{ 2507{
2515 changeIncidenceDisplay((Incidence *)which, action); 2508 changeIncidenceDisplay((Incidence *)which, action);
2516 mDateNavigator->updateView(); //LR 2509 mDateNavigator->updateView(); //LR
2517 //mDialogManager->updateSearchDialog(); 2510 //mDialogManager->updateSearchDialog();
2518 2511
2519 if (which) { 2512 if (which) {
2520 mViewManager->updateWNview(); 2513 mViewManager->updateWNview();
2521 //mTodoList->updateView(); 2514 //mTodoList->updateView();
2522 } 2515 }
2523 2516
2524} 2517}
2525 2518
2526void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2519void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2527{ 2520{
2528 updateUnmanagedViews(); 2521 updateUnmanagedViews();
2529 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2522 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2530 if ( action == KOGlobals::EVENTDELETED ) { //delete 2523 if ( action == KOGlobals::EVENTDELETED ) { //delete
2531 mCalendar->checkAlarmForIncidence( 0, true ); 2524 mCalendar->checkAlarmForIncidence( 0, true );
2532 if ( mEventViewerDialog ) 2525 if ( mEventViewerDialog )
2533 mEventViewerDialog->hide(); 2526 mEventViewerDialog->hide();
2534 } 2527 }
2535 else 2528 else
2536 mCalendar->checkAlarmForIncidence( which , false ); 2529 mCalendar->checkAlarmForIncidence( which , false );
2537} 2530}
2538 2531
2539// most of the changeEventDisplays() right now just call the view's 2532// most of the changeEventDisplays() right now just call the view's
2540// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2533// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2541void CalendarView::changeEventDisplay(Event *which, int action) 2534void CalendarView::changeEventDisplay(Event *which, int action)
2542{ 2535{
2543 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2536 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2544 changeIncidenceDisplay((Incidence *)which, action); 2537 changeIncidenceDisplay((Incidence *)which, action);
2545 mDateNavigator->updateView(); 2538 mDateNavigator->updateView();
2546 //mDialogManager->updateSearchDialog(); 2539 //mDialogManager->updateSearchDialog();
2547 2540
2548 if (which) { 2541 if (which) {
2549 // If there is an event view visible update the display 2542 // If there is an event view visible update the display
2550 mViewManager->currentView()->changeEventDisplay(which,action); 2543 mViewManager->currentView()->changeEventDisplay(which,action);
2551 // TODO: check, if update needed 2544 // TODO: check, if update needed
2552 // if (which->getTodoStatus()) { 2545 // if (which->getTodoStatus()) {
2553 mTodoList->updateView(); 2546 mTodoList->updateView();
2554 // } 2547 // }
2555 } else { 2548 } else {
2556 mViewManager->currentView()->updateView(); 2549 mViewManager->currentView()->updateView();
2557 } 2550 }
2558} 2551}
2559 2552
2560 2553
2561void CalendarView::updateTodoViews() 2554void CalendarView::updateTodoViews()
2562{ 2555{
2563 mTodoList->updateView(); 2556 mTodoList->updateView();
2564 mViewManager->currentView()->updateView(); 2557 mViewManager->currentView()->updateView();
2565 2558
2566} 2559}
2567 2560
2568 2561
2569void CalendarView::updateView(const QDate &start, const QDate &end) 2562void CalendarView::updateView(const QDate &start, const QDate &end)
2570{ 2563{
2571 mTodoList->updateView(); 2564 mTodoList->updateView();
2572 mViewManager->updateView(start, end); 2565 mViewManager->updateView(start, end);
2573 //mDateNavigator->updateView(); 2566 //mDateNavigator->updateView();
2574} 2567}
2575 2568
2576void CalendarView::clearAllViews() 2569void CalendarView::clearAllViews()
2577{ 2570{
2578 mTodoList->clearList(); 2571 mTodoList->clearList();
2579 mViewManager->clearAllViews(); 2572 mViewManager->clearAllViews();
2580 SearchDialog * sd = mDialogManager->getSearchDialog(); 2573 SearchDialog * sd = mDialogManager->getSearchDialog();
2581 if ( sd ) { 2574 if ( sd ) {
2582 KOListView* kol = sd->listview(); 2575 KOListView* kol = sd->listview();
2583 if ( kol ) 2576 if ( kol )
2584 kol->clearList(); 2577 kol->clearList();
2585 } 2578 }
2586} 2579}
2587void CalendarView::updateView() 2580void CalendarView::updateView()
2588{ 2581{
2589 DateList tmpList = mNavigator->selectedDates(); 2582 DateList tmpList = mNavigator->selectedDates();
2590 2583
2591 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2584 if ( KOPrefs::instance()->mHideNonStartedTodos )
2592 mTodoList->updateView(); 2585 mTodoList->updateView();
2593 // We assume that the navigator only selects consecutive days. 2586 // We assume that the navigator only selects consecutive days.
2594 updateView( tmpList.first(), tmpList.last() ); 2587 updateView( tmpList.first(), tmpList.last() );
2595} 2588}
2596 2589
2597void CalendarView::updateUnmanagedViews() 2590void CalendarView::updateUnmanagedViews()
2598{ 2591{
2599 mDateNavigator->updateDayMatrix(); 2592 mDateNavigator->updateDayMatrix();
2600} 2593}
2601 2594
2602int CalendarView::msgItemDelete(const QString name) 2595int CalendarView::msgItemDelete(const QString name)
2603{ 2596{
2604 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2597 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2605 i18n("This item will be\npermanently deleted."), 2598 i18n("This item will be\npermanently deleted."),
2606 i18n("KO/Pi Confirmation"),i18n("Delete")); 2599 i18n("KO/Pi Confirmation"),i18n("Delete"));
2607} 2600}
2608 2601
2609 2602
2610void CalendarView::edit_cut() 2603void CalendarView::edit_cut()
2611{ 2604{
2612 Event *anEvent=0; 2605 Event *anEvent=0;
2613 2606
2614 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2607 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2615 2608
2616 if (mViewManager->currentView()->isEventView()) { 2609 if (mViewManager->currentView()->isEventView()) {
2617 if ( incidence && incidence->typeID() == eventID ) { 2610 if ( incidence && incidence->typeID() == eventID ) {
2618 anEvent = static_cast<Event *>(incidence); 2611 anEvent = static_cast<Event *>(incidence);
2619 } 2612 }
2620 } 2613 }
2621 2614
2622 if (!anEvent) { 2615 if (!anEvent) {
2623 KNotifyClient::beep(); 2616 KNotifyClient::beep();
2624 return; 2617 return;
2625 } 2618 }
2626 DndFactory factory( mCalendar ); 2619 DndFactory factory( mCalendar );
2627 factory.cutIncidence(anEvent); 2620 factory.cutIncidence(anEvent);
2628 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2621 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2629} 2622}
2630 2623
2631void CalendarView::edit_copy() 2624void CalendarView::edit_copy()
2632{ 2625{
2633 Event *anEvent=0; 2626 Event *anEvent=0;
2634 2627
2635 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2628 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2636 2629
2637 if (mViewManager->currentView()->isEventView()) { 2630 if (mViewManager->currentView()->isEventView()) {
2638 if ( incidence && incidence->typeID() == eventID ) { 2631 if ( incidence && incidence->typeID() == eventID ) {
2639 anEvent = static_cast<Event *>(incidence); 2632 anEvent = static_cast<Event *>(incidence);
2640 } 2633 }
2641 } 2634 }
2642 2635
2643 if (!anEvent) { 2636 if (!anEvent) {
2644 KNotifyClient::beep(); 2637 KNotifyClient::beep();
2645 return; 2638 return;
2646 } 2639 }
2647 DndFactory factory( mCalendar ); 2640 DndFactory factory( mCalendar );
2648 factory.copyIncidence(anEvent); 2641 factory.copyIncidence(anEvent);
2649} 2642}
2650 2643
2651void CalendarView::edit_paste() 2644void CalendarView::edit_paste()
2652{ 2645{
2653 QDate date = mNavigator->selectedDates().first(); 2646 QDate date = mNavigator->selectedDates().first();
2654 2647
2655 DndFactory factory( mCalendar ); 2648 DndFactory factory( mCalendar );
2656 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2649 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2657 2650
2658 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2651 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2659} 2652}
2660void CalendarView::edit_global_options() 2653void CalendarView::edit_global_options()
2661{ 2654{
2662 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2655 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2663 emit save(); 2656 emit save();
2664 emit saveStopTimer(); 2657 emit saveStopTimer();
2665 mDialogManager->showGlobalOptionsDialog(); 2658 mDialogManager->showGlobalOptionsDialog();
2666 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2659 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2667 emit saveStopTimer(); 2660 emit saveStopTimer();
2668 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2661 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2669 i18n("Timezone settings"),i18n("Reload"))) { 2662 i18n("Timezone settings"),i18n("Reload"))) {
2670 qDebug("KO: TZ reload cancelled "); 2663 qDebug("KO: TZ reload cancelled ");
2671 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2664 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2672 return; 2665 return;
2673 } 2666 }
2674 qDebug("KO: Timezone change "); 2667 qDebug("KO: Timezone change ");
2675 openCalendar( MainWindow::defaultFileName() ); 2668 openCalendar( MainWindow::defaultFileName() );
2676 setModified(true); 2669 setModified(true);
2677 } 2670 }
2678 else 2671 else
2679 qDebug("KO: No tz change "); 2672 qDebug("KO: No tz change ");
2680} 2673}
2681void CalendarView::edit_options() 2674void CalendarView::edit_options()
2682{ 2675{
2683 mDialogManager->showOptionsDialog(); 2676 mDialogManager->showOptionsDialog();
2684} 2677}
2685 2678
2686 2679
2687void CalendarView::slotSelectPickerDate( QDate d) 2680void CalendarView::slotSelectPickerDate( QDate d)
2688{ 2681{
2689 mDateFrame->hide(); 2682 mDateFrame->hide();
2690 if ( mDatePickerMode == 1 ) { 2683 if ( mDatePickerMode == 1 ) {
2691 mNavigator->slotDaySelect( d ); 2684 mNavigator->slotDaySelect( d );
2692 } else if ( mDatePickerMode == 2 ) { 2685 } else if ( mDatePickerMode == 2 ) {
2693 if ( mMoveIncidence->typeID() == todoID ) { 2686 if ( mMoveIncidence->typeID() == todoID ) {
2694 Todo * to = (Todo *) mMoveIncidence; 2687 Todo * to = (Todo *) mMoveIncidence;
2695 QTime tim; 2688 QTime tim;
2696 int len = 0; 2689 int len = 0;
2697 if ( to->hasStartDate() && to->hasDueDate() ) 2690 if ( to->hasStartDate() && to->hasDueDate() )
2698 len = to->dtStart().secsTo( to->dtDue()); 2691 len = to->dtStart().secsTo( to->dtDue());
2699 if ( to->hasDueDate() ) 2692 if ( to->hasDueDate() )
2700 tim = to->dtDue().time(); 2693 tim = to->dtDue().time();
2701 else { 2694 else {
2702 tim = QTime ( 0,0,0 ); 2695 tim = QTime ( 0,0,0 );
2703 to->setFloats( true ); 2696 to->setFloats( true );
2704 to->setHasDueDate( true ); 2697 to->setHasDueDate( true );
2705 } 2698 }
2706 QDateTime dt ( d,tim ); 2699 QDateTime dt ( d,tim );
2707 to->setDtDue( dt ); 2700 to->setDtDue( dt );
2708 2701
2709 if ( to->hasStartDate() ) { 2702 if ( to->hasStartDate() ) {
2710 if ( len>0 ) 2703 if ( len>0 )
2711 to->setDtStart(to->dtDue().addSecs( -len )); 2704 to->setDtStart(to->dtDue().addSecs( -len ));
2712 else 2705 else
2713 if (to->dtStart() > to->dtDue() ) 2706 if (to->dtStart() > to->dtDue() )
2714 to->setDtStart(to->dtDue().addDays( -3 )); 2707 to->setDtStart(to->dtDue().addDays( -3 ));
2715 } 2708 }
2716 2709
2717 todoChanged( to ); 2710 todoChanged( to );
2718 } else { 2711 } else {
2719 if ( mMoveIncidence->doesRecur() ) { 2712 if ( mMoveIncidence->doesRecur() ) {
2720#if 0 2713#if 0
2721 // PENDING implement this 2714 // PENDING implement this
2722 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2715 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2723 mCalendar()->addIncidence( newInc ); 2716 mCalendar()->addIncidence( newInc );
2724 if ( mMoveIncidence->typeID() == todoID ) 2717 if ( mMoveIncidence->typeID() == todoID )
2725 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2718 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2726 else 2719 else
2727 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2720 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2728 mMoveIncidence = newInc; 2721 mMoveIncidence = newInc;
2729 2722
2730#endif 2723#endif
2731 } 2724 }
2732 QTime tim = mMoveIncidence->dtStart().time(); 2725 QTime tim = mMoveIncidence->dtStart().time();
2733 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2726 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2734 QDateTime dt ( d,tim ); 2727 QDateTime dt ( d,tim );
2735 mMoveIncidence->setDtStart( dt ); 2728 mMoveIncidence->setDtStart( dt );
2736 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2729 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2737 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2730 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2738 } 2731 }
2739 2732
2740 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2733 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2741 } 2734 }
2742} 2735}
2743 2736
2744void CalendarView::removeCategories() 2737void CalendarView::removeCategories()
2745{ 2738{
2746 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2739 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2747 QStringList catList = KOPrefs::instance()->mCustomCategories; 2740 QStringList catList = KOPrefs::instance()->mCustomCategories;
2748 QStringList catIncList; 2741 QStringList catIncList;
2749 QStringList newCatList; 2742 QStringList newCatList;
2750 Incidence* inc = incList.first(); 2743 Incidence* inc = incList.first();
2751 int i; 2744 int i;
2752 int count = 0; 2745 int count = 0;
2753 while ( inc ) { 2746 while ( inc ) {
2754 newCatList.clear(); 2747 newCatList.clear();
2755 catIncList = inc->categories() ; 2748 catIncList = inc->categories() ;
2756 for( i = 0; i< catIncList.count(); ++i ) { 2749 for( i = 0; i< catIncList.count(); ++i ) {
2757 if ( catList.contains (catIncList[i])) 2750 if ( catList.contains (catIncList[i]))
2758 newCatList.append( catIncList[i] ); 2751 newCatList.append( catIncList[i] );
2759 } 2752 }
2760 newCatList.sort(); 2753 newCatList.sort();
2761 inc->setCategories( newCatList.join(",") ); 2754 inc->setCategories( newCatList.join(",") );
2762 inc = incList.next(); 2755 inc = incList.next();
2763 } 2756 }
2764} 2757}
2765 2758
2766int CalendarView::addCategories() 2759int CalendarView::addCategories()
2767{ 2760{
2768 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2761 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2769 QStringList catList = KOPrefs::instance()->mCustomCategories; 2762 QStringList catList = KOPrefs::instance()->mCustomCategories;
2770 QStringList catIncList; 2763 QStringList catIncList;
2771 Incidence* inc = incList.first(); 2764 Incidence* inc = incList.first();
2772 int i; 2765 int i;
2773 int count = 0; 2766 int count = 0;
2774 while ( inc ) { 2767 while ( inc ) {
2775 catIncList = inc->categories() ; 2768 catIncList = inc->categories() ;
2776 for( i = 0; i< catIncList.count(); ++i ) { 2769 for( i = 0; i< catIncList.count(); ++i ) {
2777 if ( !catList.contains (catIncList[i])) { 2770 if ( !catList.contains (catIncList[i])) {
2778 catList.append( catIncList[i] ); 2771 catList.append( catIncList[i] );
2779 //qDebug("add cat %s ", catIncList[i].latin1()); 2772 //qDebug("add cat %s ", catIncList[i].latin1());
2780 ++count; 2773 ++count;
2781 } 2774 }
2782 } 2775 }
2783 inc = incList.next(); 2776 inc = incList.next();
2784 } 2777 }
2785 catList.sort(); 2778 catList.sort();
2786 KOPrefs::instance()->mCustomCategories = catList; 2779 KOPrefs::instance()->mCustomCategories = catList;
2787 return count; 2780 return count;
2788} 2781}
2789 2782
2790void CalendarView::manageCategories() 2783void CalendarView::manageCategories()
2791{ 2784{
2792 KOCatPrefs* cp = new KOCatPrefs(); 2785 KOCatPrefs* cp = new KOCatPrefs();
2793 cp->show(); 2786 cp->show();
2794 int w =cp->sizeHint().width() ; 2787 int w =cp->sizeHint().width() ;
2795 int h = cp->sizeHint().height() ; 2788 int h = cp->sizeHint().height() ;
2796 int dw = QApplication::desktop()->width(); 2789 int dw = QApplication::desktop()->width();
2797 int dh = QApplication::desktop()->height(); 2790 int dh = QApplication::desktop()->height();
2798 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2791 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2799 if ( !cp->exec() ) { 2792 if ( !cp->exec() ) {
2800 delete cp; 2793 delete cp;
2801 return; 2794 return;
2802 } 2795 }
2803 int count = 0; 2796 int count = 0;
2804 if ( cp->addCat() ) { 2797 if ( cp->addCat() ) {
2805 count = addCategories(); 2798 count = addCategories();
2806 if ( count ) { 2799 if ( count ) {
2807 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2800 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2808 writeSettings(); 2801 writeSettings();
2809 } else 2802 } else
2810 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2803 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2811 } else { 2804 } else {
2812 removeCategories(); 2805 removeCategories();
2813 updateView(); 2806 updateView();
2814 } 2807 }
2815 delete cp; 2808 delete cp;
2816} 2809}
2817 2810
2818void CalendarView::beamIncidence(Incidence * Inc) 2811void CalendarView::beamIncidence(Incidence * Inc)
2819{ 2812{
2820 QPtrList<Incidence> delSel ; 2813 QPtrList<Incidence> delSel ;
2821 delSel.append(Inc); 2814 delSel.append(Inc);
2822 beamIncidenceList( delSel ); 2815 beamIncidenceList( delSel );
2823} 2816}
2824void CalendarView::beamCalendar() 2817void CalendarView::beamCalendar()
2825{ 2818{
2826 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2819 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2827 //qDebug("beamCalendar() "); 2820 //qDebug("beamCalendar() ");
2828 beamIncidenceList( delSel ); 2821 beamIncidenceList( delSel );
2829} 2822}
2830void CalendarView::beamFilteredCalendar() 2823void CalendarView::beamFilteredCalendar()
2831{ 2824{
2832 QPtrList<Incidence> delSel = mCalendar->incidences(); 2825 QPtrList<Incidence> delSel = mCalendar->incidences();
2833 //qDebug("beamFilteredCalendar() "); 2826 //qDebug("beamFilteredCalendar() ");
2834 beamIncidenceList( delSel ); 2827 beamIncidenceList( delSel );
2835} 2828}
2836void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2829void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2837{ 2830{
2838 if ( beamDialog->exec () == QDialog::Rejected ) 2831 if ( beamDialog->exec () == QDialog::Rejected )
2839 return; 2832 return;
2840#ifdef DESKTOP_VERSION 2833#ifdef DESKTOP_VERSION
2841 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2834 QString fn = locateLocal( "tmp", "kopibeamfile" );
2842#else 2835#else
2843 QString fn = "/tmp/kopibeamfile"; 2836 QString fn = "/tmp/kopibeamfile";
2844#endif 2837#endif
2845 QString mes; 2838 QString mes;
2846 bool createbup = true; 2839 bool createbup = true;
2847 if ( createbup ) { 2840 if ( createbup ) {
2848 QString description = "\n"; 2841 QString description = "\n";
2849 CalendarLocal* cal = new CalendarLocal(); 2842 CalendarLocal* cal = new CalendarLocal();
2850 if ( beamDialog->beamLocal() ) 2843 if ( beamDialog->beamLocal() )
2851 cal->setLocalTime(); 2844 cal->setLocalTime();
2852 else 2845 else
2853 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2846 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2854 Incidence *incidence = delSel.first(); 2847 Incidence *incidence = delSel.first();
2855 bool addText = false; 2848 bool addText = false;
2856 if ( delSel.count() < 10 ) 2849 if ( delSel.count() < 10 )
2857 addText = true; 2850 addText = true;
2858 else { 2851 else {
2859 description.sprintf(i18n(" %d items?"),delSel.count() ); 2852 description.sprintf(i18n(" %d items?"),delSel.count() );
2860 } 2853 }
2861 while ( incidence ) { 2854 while ( incidence ) {
2862 Incidence *in = incidence->clone(); 2855 Incidence *in = incidence->clone();
2863 if ( ! in->summary().isEmpty() ) { 2856 if ( ! in->summary().isEmpty() ) {
2864 in->setDescription(""); 2857 in->setDescription("");
2865 } else { 2858 } else {
2866 in->setSummary( in->description().left(20)); 2859 in->setSummary( in->description().left(20));
2867 in->setDescription(""); 2860 in->setDescription("");
2868 } 2861 }
2869 if ( addText ) 2862 if ( addText )
2870 description += in->summary() + "\n"; 2863 description += in->summary() + "\n";
2871 cal->addIncidence( in ); 2864 cal->addIncidence( in );
2872 incidence = delSel.next(); 2865 incidence = delSel.next();
2873 } 2866 }
2874 if ( beamDialog->beamVcal() ) { 2867 if ( beamDialog->beamVcal() ) {
2875 fn += ".vcs"; 2868 fn += ".vcs";
2876 FileStorage storage( cal, fn, new VCalFormat ); 2869 FileStorage storage( cal, fn, new VCalFormat );
2877 storage.save(); 2870 storage.save();
2878 } else { 2871 } else {
2879 fn += ".ics"; 2872 fn += ".ics";
2880 FileStorage storage( cal, fn, new ICalFormat( ) ); 2873 FileStorage storage( cal, fn, new ICalFormat( ) );
2881 storage.save(); 2874 storage.save();
2882 } 2875 }
2883 delete cal; 2876 delete cal;
2884 mes = i18n("KO/Pi: Ready for beaming"); 2877 mes = i18n("KO/Pi: Ready for beaming");
2885 topLevelWidget()->setCaption(mes); 2878 topLevelWidget()->setCaption(mes);
2886 KApplication::convert2latin1( fn ); 2879 KApplication::convert2latin1( fn );
2887#ifndef DESKTOP_VERSION 2880#ifndef DESKTOP_VERSION
2888 Ir *ir = new Ir( this ); 2881 Ir *ir = new Ir( this );
2889 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2882 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2890 ir->send( fn, description, "text/x-vCalendar" ); 2883 ir->send( fn, description, "text/x-vCalendar" );
2891#endif 2884#endif
2892 } 2885 }
2893} 2886}
2894void CalendarView::beamDone( Ir *ir ) 2887void CalendarView::beamDone( Ir *ir )
2895{ 2888{
2896#ifndef DESKTOP_VERSION 2889#ifndef DESKTOP_VERSION
2897 delete ir; 2890 delete ir;
2898#endif 2891#endif
2899 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2892 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2900 topLevelWidget()->raise(); 2893 topLevelWidget()->raise();
2901} 2894}
2902 2895
2903void CalendarView::moveIncidence(Incidence * inc ) 2896void CalendarView::moveIncidence(Incidence * inc )
2904{ 2897{
2905 if ( !inc ) return; 2898 if ( !inc ) return;
2906 showDatePickerPopup(); 2899 showDatePickerPopup();
2907 mDatePickerMode = 2; 2900 mDatePickerMode = 2;
2908 mMoveIncidence = inc ; 2901 mMoveIncidence = inc ;
2909 QDate da; 2902 QDate da;
2910 if ( mMoveIncidence->typeID() == todoID ) { 2903 if ( mMoveIncidence->typeID() == todoID ) {
2911 Todo * to = (Todo *) mMoveIncidence; 2904 Todo * to = (Todo *) mMoveIncidence;
2912 if ( to->hasDueDate() ) 2905 if ( to->hasDueDate() )
2913 da = to->dtDue().date(); 2906 da = to->dtDue().date();
2914 else 2907 else
2915 da = QDate::currentDate(); 2908 da = QDate::currentDate();
2916 } else { 2909 } else {
2917 da = mMoveIncidence->dtStart().date(); 2910 da = mMoveIncidence->dtStart().date();
2918 } 2911 }
2919 //PENDING set date for recurring incidence to date of recurrence 2912 //PENDING set date for recurring incidence to date of recurrence
2920 //mMoveIncidenceOldDate; 2913 //mMoveIncidenceOldDate;
2921 mDatePicker->setDate( da ); 2914 mDatePicker->setDate( da );
2922} 2915}
2923void CalendarView::showDatePickerPopup() 2916void CalendarView::showDatePickerPopup()
2924{ 2917{
2925 if ( mDateFrame->isVisible() ) 2918 if ( mDateFrame->isVisible() )
2926 mDateFrame->hide(); 2919 mDateFrame->hide();
2927 else { 2920 else {
2928 int offX = 0, offY = 0; 2921 int offX = 0, offY = 0;
2929#ifdef DESKTOP_VERSION 2922#ifdef DESKTOP_VERSION
2930 int w =mDatePicker->sizeHint().width() ; 2923 int w =mDatePicker->sizeHint().width() ;
2931 int h = mDatePicker->sizeHint().height() ; 2924 int h = mDatePicker->sizeHint().height() ;
2932 int dw = topLevelWidget()->width(); 2925 int dw = topLevelWidget()->width();
2933 int dh = topLevelWidget()->height(); 2926 int dh = topLevelWidget()->height();
2934 offX = topLevelWidget()->x(); 2927 offX = topLevelWidget()->x();
2935 offY = topLevelWidget()->y(); 2928 offY = topLevelWidget()->y();
2936#else 2929#else
2937 int w =mDatePicker->sizeHint().width() ; 2930 int w =mDatePicker->sizeHint().width() ;
2938 int h = mDatePicker->sizeHint().height() ; 2931 int h = mDatePicker->sizeHint().height() ;
2939 int dw = QApplication::desktop()->width(); 2932 int dw = QApplication::desktop()->width();
2940 int dh = QApplication::desktop()->height(); 2933 int dh = QApplication::desktop()->height();
2941#endif 2934#endif
2942 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2935 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2943 mDateFrame->show(); 2936 mDateFrame->show();
2944 } 2937 }
2945} 2938}
2946void CalendarView::showDatePicker( ) 2939void CalendarView::showDatePicker( )
2947{ 2940{
2948 showDatePickerPopup(); 2941 showDatePickerPopup();
2949 mDatePickerMode = 1; 2942 mDatePickerMode = 1;
2950 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2943 mDatePicker->setDate( mNavigator->selectedDates().first() );
2951} 2944}
2952 2945
2953void CalendarView::showEventEditor() 2946void CalendarView::showEventEditor()
2954{ 2947{
2955#ifdef DESKTOP_VERSION 2948#ifdef DESKTOP_VERSION
2956 int x,y,w,h; 2949 int x,y,w,h;
2957 x = mEventEditor->geometry().x(); 2950 x = mEventEditor->geometry().x();
2958 y = mEventEditor->geometry().y(); 2951 y = mEventEditor->geometry().y();
2959 w = mEventEditor->width(); 2952 w = mEventEditor->width();
2960 h = mEventEditor->height(); 2953 h = mEventEditor->height();
2961 mEventEditor->show(); 2954 mEventEditor->show();
2962 mEventEditor->setGeometry(x,y,w,h); 2955 mEventEditor->setGeometry(x,y,w,h);
2963#else 2956#else
2964 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2957 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2965 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2958 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2966 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2959 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2967 qApp->processEvents(); 2960 qApp->processEvents();
2968 delete mEventEditor; 2961 delete mEventEditor;
2969 mEventEditor = mDialogManager->getEventEditor(); 2962 mEventEditor = mDialogManager->getEventEditor();
2970 topLevelWidget()->setCaption( i18n("") ); 2963 topLevelWidget()->setCaption( i18n("") );
2971 } 2964 }
2972 mEventEditor->showMaximized(); 2965 mEventEditor->showMaximized();
2973#endif 2966#endif
2974} 2967}
2975void CalendarView::showTodoEditor() 2968void CalendarView::showTodoEditor()
2976{ 2969{
2977#ifdef DESKTOP_VERSION 2970#ifdef DESKTOP_VERSION
2978 int x,y,w,h; 2971 int x,y,w,h;
2979 x = mTodoEditor->geometry().x(); 2972 x = mTodoEditor->geometry().x();
2980 y = mTodoEditor->geometry().y(); 2973 y = mTodoEditor->geometry().y();
2981 w = mTodoEditor->width(); 2974 w = mTodoEditor->width();
2982 h = mTodoEditor->height(); 2975 h = mTodoEditor->height();
2983 mTodoEditor->show(); 2976 mTodoEditor->show();
2984 mTodoEditor->setGeometry(x,y,w,h); 2977 mTodoEditor->setGeometry(x,y,w,h);
2985#else 2978#else
2986 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2979 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2987 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2980 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2988 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2981 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2989 qApp->processEvents(); 2982 qApp->processEvents();
2990 delete mTodoEditor; 2983 delete mTodoEditor;
2991 mTodoEditor = mDialogManager->getTodoEditor(); 2984 mTodoEditor = mDialogManager->getTodoEditor();
2992 topLevelWidget()->setCaption( i18n("") ); 2985 topLevelWidget()->setCaption( i18n("") );
2993 } 2986 }
2994 mTodoEditor->showMaximized(); 2987 mTodoEditor->showMaximized();
2995#endif 2988#endif
2996} 2989}
2997 2990
2998void CalendarView::cloneIncidence() 2991void CalendarView::cloneIncidence()
2999{ 2992{
3000 Incidence *incidence = currentSelection(); 2993 Incidence *incidence = currentSelection();
3001 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2994 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3002 if ( incidence ) { 2995 if ( incidence ) {
3003 cloneIncidence(incidence); 2996 cloneIncidence(incidence);
3004 } 2997 }
3005} 2998}
3006void CalendarView::moveIncidence() 2999void CalendarView::moveIncidence()
3007{ 3000{
3008 Incidence *incidence = currentSelection(); 3001 Incidence *incidence = currentSelection();
3009 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3002 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3010 if ( incidence ) { 3003 if ( incidence ) {
3011 moveIncidence(incidence); 3004 moveIncidence(incidence);
3012 } 3005 }
3013} 3006}
3014void CalendarView::beamIncidence() 3007void CalendarView::beamIncidence()
3015{ 3008{
3016 Incidence *incidence = currentSelection(); 3009 Incidence *incidence = currentSelection();
3017 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3010 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3018 if ( incidence ) { 3011 if ( incidence ) {
3019 beamIncidence(incidence); 3012 beamIncidence(incidence);
3020 } 3013 }
3021} 3014}
3022void CalendarView::toggleCancelIncidence() 3015void CalendarView::toggleCancelIncidence()
3023{ 3016{
3024 Incidence *incidence = currentSelection(); 3017 Incidence *incidence = currentSelection();
3025 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3018 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3026 if ( incidence ) { 3019 if ( incidence ) {
3027 cancelIncidence(incidence); 3020 cancelIncidence(incidence);
3028 } 3021 }
3029} 3022}
3030 3023
3031 3024
3032void CalendarView::cancelIncidence(Incidence * inc ) 3025void CalendarView::cancelIncidence(Incidence * inc )
3033{ 3026{
3034 inc->setCancelled( ! inc->cancelled() ); 3027 inc->setCancelled( ! inc->cancelled() );
3035 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3028 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3036 updateView(); 3029 updateView();
3037} 3030}
3038void CalendarView::cloneIncidence(Incidence * orgInc ) 3031void CalendarView::cloneIncidence(Incidence * orgInc )
3039{ 3032{
3040 Incidence * newInc = orgInc->clone(); 3033 Incidence * newInc = orgInc->clone();
3041 newInc->recreate(); 3034 newInc->recreate();
3042 3035
3043 if ( newInc->typeID() == todoID ) { 3036 if ( newInc->typeID() == todoID ) {
3044 Todo* t = (Todo*) newInc; 3037 Todo* t = (Todo*) newInc;
3045 bool cloneSub = false; 3038 bool cloneSub = false;
3046 if ( orgInc->relations().count() ) { 3039 if ( orgInc->relations().count() ) {
3047 int result = KMessageBox::warningYesNoCancel(this, 3040 int result = KMessageBox::warningYesNoCancel(this,
3048 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), 3041 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
3049 i18n("Todo has subtodos"), 3042 i18n("Todo has subtodos"),
3050 i18n("Yes"), 3043 i18n("Yes"),
3051 i18n("No")); 3044 i18n("No"));
3052 3045
3053 if ( result == KMessageBox::Cancel ) { 3046 if ( result == KMessageBox::Cancel ) {
3054 delete t; 3047 delete t;
3055 return; 3048 return;
3056 } 3049 }
3057 if (result == KMessageBox::Yes) cloneSub = true; 3050 if (result == KMessageBox::Yes) cloneSub = true;
3058 } 3051 }
3059 showTodoEditor(); 3052 showTodoEditor();
3060 mTodoEditor->editTodo( t ); 3053 mTodoEditor->editTodo( t );
3061 if ( mTodoEditor->exec() ) { 3054 if ( mTodoEditor->exec() ) {
3062 if ( cloneSub ) { 3055 if ( cloneSub ) {
3063 orgInc->cloneRelations( t ); 3056 orgInc->cloneRelations( t );
3064 mCalendar->addIncidenceBranch( t ); 3057 mCalendar->addIncidenceBranch( t );
3065 updateView(); 3058 updateView();
3066 3059
3067 } else { 3060 } else {
3068 mCalendar->addTodo( t ); 3061 mCalendar->addTodo( t );
3069 updateView(); 3062 updateView();
3070 } 3063 }
3071 } else { 3064 } else {
3072 delete t; 3065 delete t;
3073 } 3066 }
3074 } 3067 }
3075 else { 3068 else {
3076 Event* e = (Event*) newInc; 3069 Event* e = (Event*) newInc;
3077 showEventEditor(); 3070 showEventEditor();
3078 mEventEditor->editEvent( e ); 3071 mEventEditor->editEvent( e );
3079 if ( mEventEditor->exec() ) { 3072 if ( mEventEditor->exec() ) {
3080 mCalendar->addEvent( e ); 3073 mCalendar->addEvent( e );
3081 updateView(); 3074 updateView();
3082 } else { 3075 } else {
3083 delete e; 3076 delete e;
3084 } 3077 }
3085 } 3078 }
3086 setActiveWindow(); 3079 setActiveWindow();
3087} 3080}
3088 3081
3089void CalendarView::newEvent() 3082void CalendarView::newEvent()
3090{ 3083{
3091 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3084 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3092 KOAgendaView *aView = mViewManager->agendaView(); 3085 KOAgendaView *aView = mViewManager->agendaView();
3093 if (aView) { 3086 if (aView) {
3094 if (aView->selectionStart().isValid()) { 3087 if (aView->selectionStart().isValid()) {
3095 if (aView->selectedIsAllDay()) { 3088 if (aView->selectedIsAllDay()) {
3096 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3089 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3097 } else { 3090 } else {
3098 newEvent(aView->selectionStart(),aView->selectionEnd()); 3091 newEvent(aView->selectionStart(),aView->selectionEnd());
3099 } 3092 }
3100 return; 3093 return;
3101 } 3094 }
3102 } 3095 }
3103 3096
3104 QDate date = mNavigator->selectedDates().first(); 3097 QDate date = mNavigator->selectedDates().first();
3105 QDateTime current = QDateTime::currentDateTime(); 3098 QDateTime current = QDateTime::currentDateTime();
3106 if ( date <= current.date() ) { 3099 if ( date <= current.date() ) {
3107 int hour = current.time().hour() +1; 3100 int hour = current.time().hour() +1;
3108 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3101 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3109 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3102 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3110 } else 3103 } else
3111 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3104 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3112 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3105 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3113 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3106 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3114} 3107}
3115 3108
3116void CalendarView::newEvent(QDateTime fh) 3109void CalendarView::newEvent(QDateTime fh)
3117{ 3110{
3118 newEvent(fh, 3111 newEvent(fh,
3119 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3112 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3120} 3113}
3121 3114
3122void CalendarView::newEvent(QDate dt) 3115void CalendarView::newEvent(QDate dt)
3123{ 3116{
3124 newEvent(QDateTime(dt, QTime(0,0,0)), 3117 newEvent(QDateTime(dt, QTime(0,0,0)),
3125 QDateTime(dt, QTime(0,0,0)), true); 3118 QDateTime(dt, QTime(0,0,0)), true);
3126} 3119}
3127void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3120void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3128{ 3121{
3129 newEvent(fromHint, toHint, false); 3122 newEvent(fromHint, toHint, false);
3130} 3123}
3131void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3124void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3132{ 3125{
3133 3126
3134 showEventEditor(); 3127 showEventEditor();
3135 mEventEditor->newEvent(fromHint,toHint,allDay); 3128 mEventEditor->newEvent(fromHint,toHint,allDay);
3136 if ( mFilterView->filtersEnabled() ) { 3129 if ( mFilterView->filtersEnabled() ) {
3137 CalFilter *filter = mFilterView->selectedFilter(); 3130 CalFilter *filter = mFilterView->selectedFilter();
3138 if (filter && filter->showCategories()) { 3131 if (filter && filter->showCategories()) {
3139 mEventEditor->setCategories(filter->categoryList().join(",") ); 3132 mEventEditor->setCategories(filter->categoryList().join(",") );
3140 } 3133 }
3141 if ( filter ) 3134 if ( filter )
3142 mEventEditor->setSecrecy( filter->getSecrecy() ); 3135 mEventEditor->setSecrecy( filter->getSecrecy() );
3143 } 3136 }
3144 mEventEditor->exec(); 3137 mEventEditor->exec();
3145 setActiveWindow(); 3138 setActiveWindow();
3146} 3139}
3147void CalendarView::todoAdded(Todo * t) 3140void CalendarView::todoAdded(Todo * t)
3148{ 3141{
3149 3142
3150 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3143 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3151 updateTodoViews(); 3144 updateTodoViews();
3152} 3145}
3153void CalendarView::todoChanged(Todo * t) 3146void CalendarView::todoChanged(Todo * t)
3154{ 3147{
3155 emit todoModified( t, 4 ); 3148 emit todoModified( t, 4 );
3156 // updateTodoViews(); 3149 // updateTodoViews();
3157} 3150}
3158void CalendarView::todoToBeDeleted(Todo *) 3151void CalendarView::todoToBeDeleted(Todo *)
3159{ 3152{
3160 //qDebug("todoToBeDeleted(Todo *) "); 3153 //qDebug("todoToBeDeleted(Todo *) ");
3161 updateTodoViews(); 3154 updateTodoViews();
3162} 3155}
3163void CalendarView::todoDeleted() 3156void CalendarView::todoDeleted()
3164{ 3157{
3165 //qDebug(" todoDeleted()"); 3158 //qDebug(" todoDeleted()");
3166 updateTodoViews(); 3159 updateTodoViews();
3167} 3160}
3168 3161
3169 3162
3170void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3163void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3171{ 3164{
3172 showTodoEditor(); 3165 showTodoEditor();
3173 mTodoEditor->newTodo(dt,0,allday); 3166 mTodoEditor->newTodo(dt,0,allday);
3174 if ( mFilterView->filtersEnabled() ) { 3167 if ( mFilterView->filtersEnabled() ) {
3175 CalFilter *filter = mFilterView->selectedFilter(); 3168 CalFilter *filter = mFilterView->selectedFilter();
3176 if (filter && filter->showCategories()) { 3169 if (filter && filter->showCategories()) {
3177 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3170 mTodoEditor->setCategories(filter->categoryList().join(",") );
3178 } 3171 }
3179 if ( filter ) 3172 if ( filter )
3180 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3173 mTodoEditor->setSecrecy( filter->getSecrecy() );
3181 } 3174 }
3182 mTodoEditor->exec(); 3175 mTodoEditor->exec();
3183 setActiveWindow(); 3176 setActiveWindow();
3184} 3177}
3185 3178
3186void CalendarView::newTodo() 3179void CalendarView::newTodo()
3187{ 3180{
3188 newTodoDateTime( QDateTime(),true ); 3181 newTodoDateTime( QDateTime(),true );
3189} 3182}
3190 3183
3191void CalendarView::newSubTodo() 3184void CalendarView::newSubTodo()
3192{ 3185{
3193 Todo *todo = selectedTodo(); 3186 Todo *todo = selectedTodo();
3194 if ( todo ) newSubTodo( todo ); 3187 if ( todo ) newSubTodo( todo );
3195} 3188}
3196 3189
3197void CalendarView::newSubTodo(Todo *parentEvent) 3190void CalendarView::newSubTodo(Todo *parentEvent)
3198{ 3191{
3199 3192
3200 showTodoEditor(); 3193 showTodoEditor();
3201 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3194 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3202 mTodoEditor->exec(); 3195 mTodoEditor->exec();
3203 setActiveWindow(); 3196 setActiveWindow();
3204} 3197}
3205 3198
3206void CalendarView::newFloatingEvent() 3199void CalendarView::newFloatingEvent()
3207{ 3200{
3208 DateList tmpList = mNavigator->selectedDates(); 3201 DateList tmpList = mNavigator->selectedDates();
3209 QDate date = tmpList.first(); 3202 QDate date = tmpList.first();
3210 3203
3211 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3204 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3212 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3205 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3213} 3206}
3214 3207
3215 3208
3216void CalendarView::editEvent( Event *event ) 3209void CalendarView::editEvent( Event *event )
3217{ 3210{
3218 3211
3219 if ( !event ) return; 3212 if ( !event ) return;
3220 if ( event->isReadOnly() ) { 3213 if ( event->isReadOnly() ) {
3221 showEvent( event ); 3214 showEvent( event );
3222 return; 3215 return;
3223 } 3216 }
3224 showEventEditor(); 3217 showEventEditor();
3225 mEventEditor->editEvent( event , mFlagEditDescription); 3218 mEventEditor->editEvent( event , mFlagEditDescription);
3226 mEventEditor->exec(); 3219 mEventEditor->exec();
3227 setActiveWindow(); 3220 setActiveWindow();
3228 3221
3229} 3222}
3230void CalendarView::editJournal( Journal *jour ) 3223void CalendarView::editJournal( Journal *jour )
3231{ 3224{
3232 if ( !jour ) return; 3225 if ( !jour ) return;
3233 mDialogManager->hideSearchDialog(); 3226 mDialogManager->hideSearchDialog();
3234 mViewManager->showJournalView(); 3227 mViewManager->showJournalView();
3235 mNavigator->slotDaySelect( jour->dtStart().date() ); 3228 mNavigator->slotDaySelect( jour->dtStart().date() );
3236} 3229}
3237void CalendarView::editTodo( Todo *todo ) 3230void CalendarView::editTodo( Todo *todo )
3238{ 3231{
3239 if ( !todo ) return; 3232 if ( !todo ) return;
3240 3233
3241 if ( todo->isReadOnly() ) { 3234 if ( todo->isReadOnly() ) {
3242 showTodo( todo ); 3235 showTodo( todo );
3243 return; 3236 return;
3244 } 3237 }
3245 showTodoEditor(); 3238 showTodoEditor();
3246 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3239 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3247 mTodoEditor->exec(); 3240 mTodoEditor->exec();
3248 setActiveWindow(); 3241 setActiveWindow();
3249 3242
3250} 3243}
3251 3244
3252KOEventViewerDialog* CalendarView::getEventViewerDialog() 3245KOEventViewerDialog* CalendarView::getEventViewerDialog()
3253{ 3246{
3254 if ( !mEventViewerDialog ) { 3247 if ( !mEventViewerDialog ) {
3255 mEventViewerDialog = new KOEventViewerDialog(0); 3248 mEventViewerDialog = new KOEventViewerDialog(0);
3256 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3249 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3257 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3250 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3258 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3251 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3259 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3252 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3260 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3253 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3261 viewManager(), SLOT( showAgendaView( bool ) ) ); 3254 viewManager(), SLOT( showAgendaView( bool ) ) );
3262 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3255 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3263 this, SLOT( slotViewerClosed() ) ); 3256 this, SLOT( slotViewerClosed() ) );
3264 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3257 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3265 this, SLOT( todoChanged(Todo *) ) ); 3258 this, SLOT( todoChanged(Todo *) ) );
3266 mEventViewerDialog->resize( 640, 480 ); 3259 mEventViewerDialog->resize( 640, 480 );
3267 3260
3268 } 3261 }
3269 return mEventViewerDialog; 3262 return mEventViewerDialog;
3270} 3263}
3271void CalendarView::showEvent(Event *event) 3264void CalendarView::showEvent(Event *event)
3272{ 3265{
3273 getEventViewerDialog()->setEvent(event); 3266 getEventViewerDialog()->setEvent(event);
3274 getEventViewerDialog()->showMe(); 3267 getEventViewerDialog()->showMe();
3275} 3268}
3276 3269
3277void CalendarView::showTodo(Todo *event) 3270void CalendarView::showTodo(Todo *event)
3278{ 3271{
3279 getEventViewerDialog()->setTodo(event); 3272 getEventViewerDialog()->setTodo(event);
3280 getEventViewerDialog()->showMe(); 3273 getEventViewerDialog()->showMe();
3281} 3274}
3282void CalendarView::showJournal( Journal *jour ) 3275void CalendarView::showJournal( Journal *jour )
3283{ 3276{
3284 getEventViewerDialog()->setJournal(jour); 3277 getEventViewerDialog()->setJournal(jour);
3285 getEventViewerDialog()->showMe(); 3278 getEventViewerDialog()->showMe();
3286 3279
3287} 3280}
3288// void CalendarView::todoModified (Todo *event, int changed) 3281// void CalendarView::todoModified (Todo *event, int changed)
3289// { 3282// {
3290// // if (mDialogList.find (event) != mDialogList.end ()) { 3283// // if (mDialogList.find (event) != mDialogList.end ()) {
3291// // kdDebug() << "Todo modified and open" << endl; 3284// // kdDebug() << "Todo modified and open" << endl;
3292// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3285// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3293// // temp->modified (changed); 3286// // temp->modified (changed);
3294 3287
3295// // } 3288// // }
3296 3289
3297// mViewManager->updateView(); 3290// mViewManager->updateView();
3298// } 3291// }
3299 3292
3300void CalendarView::appointment_show() 3293void CalendarView::appointment_show()
3301{ 3294{
3302 Event *anEvent = 0; 3295 Event *anEvent = 0;
3303 3296
3304 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3297 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3305 3298
3306 if (mViewManager->currentView()->isEventView()) { 3299 if (mViewManager->currentView()->isEventView()) {
3307 if ( incidence && incidence->typeID() == eventID ) { 3300 if ( incidence && incidence->typeID() == eventID ) {
3308 anEvent = static_cast<Event *>(incidence); 3301 anEvent = static_cast<Event *>(incidence);
3309 } 3302 }
3310 } 3303 }
3311 3304
3312 if (!anEvent) { 3305 if (!anEvent) {
3313 KNotifyClient::beep(); 3306 KNotifyClient::beep();
3314 return; 3307 return;
3315 } 3308 }
3316 3309
3317 showEvent(anEvent); 3310 showEvent(anEvent);
3318} 3311}
3319 3312
3320void CalendarView::appointment_edit() 3313void CalendarView::appointment_edit()
3321{ 3314{
3322 Event *anEvent = 0; 3315 Event *anEvent = 0;
3323 3316
3324 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3317 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3325 3318
3326 if (mViewManager->currentView()->isEventView()) { 3319 if (mViewManager->currentView()->isEventView()) {
3327 if ( incidence && incidence->typeID() == eventID ) { 3320 if ( incidence && incidence->typeID() == eventID ) {
3328 anEvent = static_cast<Event *>(incidence); 3321 anEvent = static_cast<Event *>(incidence);
3329 } 3322 }
3330 } 3323 }
3331 3324
3332 if (!anEvent) { 3325 if (!anEvent) {
3333 KNotifyClient::beep(); 3326 KNotifyClient::beep();
3334 return; 3327 return;
3335 } 3328 }
3336 3329
3337 editEvent(anEvent); 3330 editEvent(anEvent);
3338} 3331}
3339 3332
3340void CalendarView::appointment_delete() 3333void CalendarView::appointment_delete()
3341{ 3334{
3342 Event *anEvent = 0; 3335 Event *anEvent = 0;
3343 3336
3344 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3337 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3345 3338
3346 if (mViewManager->currentView()->isEventView()) { 3339 if (mViewManager->currentView()->isEventView()) {
3347 if ( incidence && incidence->typeID() == eventID ) { 3340 if ( incidence && incidence->typeID() == eventID ) {
3348 anEvent = static_cast<Event *>(incidence); 3341 anEvent = static_cast<Event *>(incidence);
3349 } 3342 }
3350 } 3343 }
3351 3344
3352 if (!anEvent) { 3345 if (!anEvent) {
3353 KNotifyClient::beep(); 3346 KNotifyClient::beep();
3354 return; 3347 return;
3355 } 3348 }
3356 3349
3357 deleteEvent(anEvent); 3350 deleteEvent(anEvent);
3358} 3351}
3359 3352
3360void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3353void CalendarView::todo_resub( Todo * parent, Todo * sub )
3361{ 3354{
3362 if (!sub) return; 3355 if (!sub) return;
3363 if ( sub->relatedTo() == parent ) 3356 if ( sub->relatedTo() == parent )
3364 return; 3357 return;
3365 sub->setRelatedTo(parent); 3358 sub->setRelatedTo(parent);
3366 sub->updated(); 3359 sub->updated();
3367 setModified(true); 3360 setModified(true);
3368 updateView(); 3361 updateView();
3369} 3362}
3370void CalendarView::todo_unsub(Todo *anTodo ) 3363void CalendarView::todo_unsub(Todo *anTodo )
3371{ 3364{
3372 todo_resub( 0, anTodo ); 3365 todo_resub( 0, anTodo );
3373} 3366}
3374 3367
3375void CalendarView::deleteTodo(Todo *todo) 3368void CalendarView::deleteTodo(Todo *todo)
3376{ 3369{
3377 if (!todo) { 3370 if (!todo) {
3378 KNotifyClient::beep(); 3371 KNotifyClient::beep();
3379 return; 3372 return;
3380 } 3373 }
3381 if (KOPrefs::instance()->mConfirm) { 3374 if (KOPrefs::instance()->mConfirm) {
3382 QString text = todo->summary().left(20); 3375 QString text = todo->summary().left(20);
3383 if (!todo->relations().isEmpty()) { 3376 if (!todo->relations().isEmpty()) {
3384 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3377 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3385 3378
3386 } 3379 }
3387 switch (msgItemDelete(text)) { 3380 switch (msgItemDelete(text)) {
3388 case KMessageBox::Continue: // OK 3381 case KMessageBox::Continue: // OK
3389 bool deleteT = false; 3382 bool deleteT = false;
3390 if (!todo->relations().isEmpty()) { 3383 if (!todo->relations().isEmpty()) {
3391 deleteT = removeCompletedSubTodos( todo ); 3384 deleteT = removeCompletedSubTodos( todo );
3392 } 3385 }
3393 // deleteT == true: todo already deleted in removeCompletedSubTodos 3386 // deleteT == true: todo already deleted in removeCompletedSubTodos
3394 if ( !deleteT ) { 3387 if ( !deleteT ) {
3395 checkExternalId( todo ); 3388 checkExternalId( todo );
3396 calendar()->deleteTodo(todo); 3389 calendar()->deleteTodo(todo);
3397 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3390 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3398 updateView(); 3391 updateView();
3399 } 3392 }
3400 break; 3393 break;
3401 } // switch 3394 } // switch
3402 } else { 3395 } else {
3403 checkExternalId( todo ); 3396 checkExternalId( todo );
3404 mCalendar->deleteTodo(todo); 3397 mCalendar->deleteTodo(todo);
3405 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3398 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3406 updateView(); 3399 updateView();
3407 } 3400 }
3408 3401
3409 emit updateSearchDialog(); 3402 emit updateSearchDialog();
3410} 3403}
3411void CalendarView::deleteJournal(Journal *jour) 3404void CalendarView::deleteJournal(Journal *jour)
3412{ 3405{
3413 if (!jour) { 3406 if (!jour) {
3414 KNotifyClient::beep(); 3407 KNotifyClient::beep();
3415 return; 3408 return;
3416 } 3409 }
3417 if (KOPrefs::instance()->mConfirm) { 3410 if (KOPrefs::instance()->mConfirm) {
3418 switch (msgItemDelete( jour->description().left(20))) { 3411 switch (msgItemDelete( jour->description().left(20))) {
3419 case KMessageBox::Continue: // OK 3412 case KMessageBox::Continue: // OK
3420 calendar()->deleteJournal(jour); 3413 calendar()->deleteJournal(jour);
3421 updateView(); 3414 updateView();
3422 break; 3415 break;
3423 } // switch 3416 } // switch
3424 } else { 3417 } else {
3425 calendar()->deleteJournal(jour);; 3418 calendar()->deleteJournal(jour);;
3426 updateView(); 3419 updateView();
3427 } 3420 }
3428 emit updateSearchDialog(); 3421 emit updateSearchDialog();
3429} 3422}
3430 3423
3431void CalendarView::deleteEvent(Event *anEvent) 3424void CalendarView::deleteEvent(Event *anEvent)
3432{ 3425{
3433 if (!anEvent) { 3426 if (!anEvent) {
3434 KNotifyClient::beep(); 3427 KNotifyClient::beep();
3435 return; 3428 return;
3436 } 3429 }
3437 3430
3438 if (anEvent->recurrence()->doesRecur()) { 3431 if (anEvent->recurrence()->doesRecur()) {
3439 QDate itemDate = mViewManager->currentSelectionDate(); 3432 QDate itemDate = mViewManager->currentSelectionDate();
3440 int km; 3433 int km;
3441 if (!itemDate.isValid()) { 3434 if (!itemDate.isValid()) {
3442 //kdDebug() << "Date Not Valid" << endl; 3435 //kdDebug() << "Date Not Valid" << endl;
3443 if (KOPrefs::instance()->mConfirm) { 3436 if (KOPrefs::instance()->mConfirm) {
3444 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3437 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3445 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3438 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3446 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3439 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3447 if ( km == KMessageBox::Continue ) 3440 if ( km == KMessageBox::Continue )
3448 km = KMessageBox::No; // No = all below 3441 km = KMessageBox::No; // No = all below
3449 } else 3442 } else
3450 km = KMessageBox::No; 3443 km = KMessageBox::No;
3451 } else { 3444 } else {
3452 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3445 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3453 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3446 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3454 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3447 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3455 i18n("KO/Pi Confirmation"),i18n("Current"), 3448 i18n("KO/Pi Confirmation"),i18n("Current"),
3456 i18n("All")); 3449 i18n("All"));
3457 } 3450 }
3458 switch(km) { 3451 switch(km) {
3459 3452
3460 case KMessageBox::No: // Continue // all 3453 case KMessageBox::No: // Continue // all
3461 //qDebug("KMessageBox::No "); 3454 //qDebug("KMessageBox::No ");
3462 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3455 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3463 schedule(Scheduler::Cancel,anEvent); 3456 schedule(Scheduler::Cancel,anEvent);
3464 3457
3465 checkExternalId( anEvent); 3458 checkExternalId( anEvent);
3466 mCalendar->deleteEvent(anEvent); 3459 mCalendar->deleteEvent(anEvent);
3467 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3460 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3468 break; 3461 break;
3469 3462
3470 // Disabled because it does not work 3463 // Disabled because it does not work
3471 //#if 0 3464 //#if 0
3472 case KMessageBox::Yes: // just this one 3465 case KMessageBox::Yes: // just this one
3473 //QDate qd = mNavigator->selectedDates().first(); 3466 //QDate qd = mNavigator->selectedDates().first();
3474 //if (!qd.isValid()) { 3467 //if (!qd.isValid()) {
3475 // kdDebug() << "no date selected, or invalid date" << endl; 3468 // kdDebug() << "no date selected, or invalid date" << endl;
3476 // KNotifyClient::beep(); 3469 // KNotifyClient::beep();
3477 // return; 3470 // return;
3478 //} 3471 //}
3479 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3472 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3480 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3473 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3481 anEvent->addExDate(itemDate); 3474 anEvent->addExDate(itemDate);
3482 int duration = anEvent->recurrence()->duration(); 3475 int duration = anEvent->recurrence()->duration();
3483 if ( duration > 0 ) { 3476 if ( duration > 0 ) {
3484 anEvent->recurrence()->setDuration( duration - 1 ); 3477 anEvent->recurrence()->setDuration( duration - 1 );
3485 } 3478 }
3486 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3479 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3487 } 3480 }
3488 break; 3481 break;
3489 //#endif 3482 //#endif
3490 } // switch 3483 } // switch
3491 } else { 3484 } else {
3492 if (KOPrefs::instance()->mConfirm) { 3485 if (KOPrefs::instance()->mConfirm) {
3493 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3486 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3494 i18n("\nAre you sure you want\nto delete this event?"), 3487 i18n("\nAre you sure you want\nto delete this event?"),
3495 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3488 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3496 case KMessageBox::Continue: // OK 3489 case KMessageBox::Continue: // OK
3497 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3490 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3498 schedule(Scheduler::Cancel,anEvent); 3491 schedule(Scheduler::Cancel,anEvent);
3499 checkExternalId( anEvent); 3492 checkExternalId( anEvent);
3500 mCalendar->deleteEvent(anEvent); 3493 mCalendar->deleteEvent(anEvent);
3501 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3494 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3502 break; 3495 break;
3503 } // switch 3496 } // switch
3504 } else { 3497 } else {
3505 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3498 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3506 schedule(Scheduler::Cancel,anEvent); 3499 schedule(Scheduler::Cancel,anEvent);
3507 checkExternalId( anEvent); 3500 checkExternalId( anEvent);
3508 mCalendar->deleteEvent(anEvent); 3501 mCalendar->deleteEvent(anEvent);
3509 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3502 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3510 } 3503 }
3511 } // if-else 3504 } // if-else
3512 emit updateSearchDialog(); 3505 emit updateSearchDialog();
3513} 3506}
3514 3507
3515bool CalendarView::deleteEvent(const QString &uid) 3508bool CalendarView::deleteEvent(const QString &uid)
3516{ 3509{
3517 Event *ev = mCalendar->event(uid); 3510 Event *ev = mCalendar->event(uid);
3518 if (ev) { 3511 if (ev) {
3519 deleteEvent(ev); 3512 deleteEvent(ev);
3520 return true; 3513 return true;
3521 } else { 3514 } else {
3522 return false; 3515 return false;
3523 } 3516 }
3524} 3517}
3525 3518
3526/*****************************************************************************/ 3519/*****************************************************************************/
3527 3520
3528void CalendarView::action_mail() 3521void CalendarView::action_mail()
3529{ 3522{
3530#ifndef KORG_NOMAIL 3523#ifndef KORG_NOMAIL
3531 KOMailClient mailClient; 3524 KOMailClient mailClient;
3532 3525
3533 Incidence *incidence = currentSelection(); 3526 Incidence *incidence = currentSelection();
3534 3527
3535 if (!incidence) { 3528 if (!incidence) {
3536 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3529 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3537 return; 3530 return;
3538 } 3531 }
3539 if(incidence->attendeeCount() == 0 ) { 3532 if(incidence->attendeeCount() == 0 ) {
3540 KMessageBox::sorry(this, 3533 KMessageBox::sorry(this,
3541 i18n("Can't generate mail:\nNo attendees defined.\n")); 3534 i18n("Can't generate mail:\nNo attendees defined.\n"));
3542 return; 3535 return;
3543 } 3536 }
3544 3537
3545 CalendarLocal cal_tmp; 3538 CalendarLocal cal_tmp;
3546 Event *event = 0; 3539 Event *event = 0;
3547 Event *ev = 0; 3540 Event *ev = 0;
3548 if ( incidence && incidence->typeID() == eventID ) { 3541 if ( incidence && incidence->typeID() == eventID ) {
3549 event = static_cast<Event *>(incidence); 3542 event = static_cast<Event *>(incidence);
3550 ev = new Event(*event); 3543 ev = new Event(*event);
3551 cal_tmp.addEvent(ev); 3544 cal_tmp.addEvent(ev);
3552 } 3545 }
3553 ICalFormat mForm(); 3546 ICalFormat mForm();
3554 QString attachment = mForm.toString( &cal_tmp ); 3547 QString attachment = mForm.toString( &cal_tmp );
3555 if (ev) delete(ev); 3548 if (ev) delete(ev);
3556 3549
3557 mailClient.mailAttendees(currentSelection(), attachment); 3550 mailClient.mailAttendees(currentSelection(), attachment);
3558 3551
3559#endif 3552#endif
3560 3553
3561#if 0 3554#if 0
3562 Event *anEvent = 0; 3555 Event *anEvent = 0;
3563 if (mViewManager->currentView()->isEventView()) { 3556 if (mViewManager->currentView()->isEventView()) {
3564 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3557 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3565 } 3558 }
3566 3559
3567 if (!anEvent) { 3560 if (!anEvent) {
3568 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3561 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3569 return; 3562 return;
3570 } 3563 }
3571 if(anEvent->attendeeCount() == 0 ) { 3564 if(anEvent->attendeeCount() == 0 ) {
3572 KMessageBox::sorry(this, 3565 KMessageBox::sorry(this,
3573 i18n("Can't generate mail:\nNo attendees defined.\n")); 3566 i18n("Can't generate mail:\nNo attendees defined.\n"));
3574 return; 3567 return;
3575 } 3568 }
3576 3569
3577 mailobject.emailEvent(anEvent); 3570 mailobject.emailEvent(anEvent);
3578#endif 3571#endif
3579} 3572}
3580 3573
3581 3574
3582void CalendarView::schedule_publish(Incidence *incidence) 3575void CalendarView::schedule_publish(Incidence *incidence)
3583{ 3576{
3584 Event *event = 0; 3577 Event *event = 0;
3585 Todo *todo = 0; 3578 Todo *todo = 0;
3586 3579
3587 if (incidence == 0) { 3580 if (incidence == 0) {
3588 incidence = mViewManager->currentView()->selectedIncidences().first(); 3581 incidence = mViewManager->currentView()->selectedIncidences().first();
3589 if (incidence == 0) { 3582 if (incidence == 0) {
3590 incidence = mTodoList->selectedIncidences().first(); 3583 incidence = mTodoList->selectedIncidences().first();
3591 } 3584 }
3592 } 3585 }
3593 if ( incidence && incidence->typeID() == eventID ) { 3586 if ( incidence && incidence->typeID() == eventID ) {
3594 event = static_cast<Event *>(incidence); 3587 event = static_cast<Event *>(incidence);
3595 } else { 3588 } else {
3596 if ( incidence && incidence->typeID() == todoID ) { 3589 if ( incidence && incidence->typeID() == todoID ) {
3597 todo = static_cast<Todo *>(incidence); 3590 todo = static_cast<Todo *>(incidence);
3598 } 3591 }
3599 } 3592 }
3600 3593
3601 if (!event && !todo) { 3594 if (!event && !todo) {
3602 KMessageBox::sorry(this,i18n("No event selected.")); 3595 KMessageBox::sorry(this,i18n("No event selected."));
3603 return; 3596 return;
3604 } 3597 }
3605 3598
3606 PublishDialog *publishdlg = new PublishDialog(); 3599 PublishDialog *publishdlg = new PublishDialog();
3607 if (incidence->attendeeCount()>0) { 3600 if (incidence->attendeeCount()>0) {
3608 QPtrList<Attendee> attendees = incidence->attendees(); 3601 QPtrList<Attendee> attendees = incidence->attendees();
3609 attendees.first(); 3602 attendees.first();
3610 while ( attendees.current()!=0 ) { 3603 while ( attendees.current()!=0 ) {
3611 publishdlg->addAttendee(attendees.current()); 3604 publishdlg->addAttendee(attendees.current());
3612 attendees.next(); 3605 attendees.next();
3613 } 3606 }
3614 } 3607 }
3615 bool send = true; 3608 bool send = true;
3616 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3609 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3617 if ( publishdlg->exec() != QDialog::Accepted ) 3610 if ( publishdlg->exec() != QDialog::Accepted )
3618 send = false; 3611 send = false;
3619 } 3612 }
3620 if ( send ) { 3613 if ( send ) {
3621 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3614 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3622 if ( event ) { 3615 if ( event ) {
3623 Event *ev = new Event(*event); 3616 Event *ev = new Event(*event);
3624 ev->registerObserver(0); 3617 ev->registerObserver(0);
3625 ev->clearAttendees(); 3618 ev->clearAttendees();
3626 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3619 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3627 delete(ev); 3620 delete(ev);
3628 } 3621 }
3629 } else { 3622 } else {
3630 if ( todo ) { 3623 if ( todo ) {
3631 Todo *ev = new Todo(*todo); 3624 Todo *ev = new Todo(*todo);
3632 ev->registerObserver(0); 3625 ev->registerObserver(0);
3633 ev->clearAttendees(); 3626 ev->clearAttendees();
3634 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3627 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3635 delete(ev); 3628 delete(ev);
3636 } 3629 }
3637 } 3630 }
3638 } 3631 }
3639 } 3632 }
3640 delete publishdlg; 3633 delete publishdlg;
3641} 3634}
3642 3635
3643void CalendarView::schedule_request(Incidence *incidence) 3636void CalendarView::schedule_request(Incidence *incidence)
3644{ 3637{
3645 schedule(Scheduler::Request,incidence); 3638 schedule(Scheduler::Request,incidence);
3646} 3639}
3647 3640
3648void CalendarView::schedule_refresh(Incidence *incidence) 3641void CalendarView::schedule_refresh(Incidence *incidence)
3649{ 3642{
3650 schedule(Scheduler::Refresh,incidence); 3643 schedule(Scheduler::Refresh,incidence);
3651} 3644}
3652 3645
3653void CalendarView::schedule_cancel(Incidence *incidence) 3646void CalendarView::schedule_cancel(Incidence *incidence)
3654{ 3647{
3655 schedule(Scheduler::Cancel,incidence); 3648 schedule(Scheduler::Cancel,incidence);
3656} 3649}
3657 3650
3658void CalendarView::schedule_add(Incidence *incidence) 3651void CalendarView::schedule_add(Incidence *incidence)
3659{ 3652{
3660 schedule(Scheduler::Add,incidence); 3653 schedule(Scheduler::Add,incidence);
3661} 3654}
3662 3655
3663void CalendarView::schedule_reply(Incidence *incidence) 3656void CalendarView::schedule_reply(Incidence *incidence)
3664{ 3657{
3665 schedule(Scheduler::Reply,incidence); 3658 schedule(Scheduler::Reply,incidence);
3666} 3659}
3667 3660
3668void CalendarView::schedule_counter(Incidence *incidence) 3661void CalendarView::schedule_counter(Incidence *incidence)
3669{ 3662{
3670 schedule(Scheduler::Counter,incidence); 3663 schedule(Scheduler::Counter,incidence);
3671} 3664}
3672 3665
3673void CalendarView::schedule_declinecounter(Incidence *incidence) 3666void CalendarView::schedule_declinecounter(Incidence *incidence)
3674{ 3667{
3675 schedule(Scheduler::Declinecounter,incidence); 3668 schedule(Scheduler::Declinecounter,incidence);
3676} 3669}
3677 3670
3678void CalendarView::schedule_publish_freebusy(int daysToPublish) 3671void CalendarView::schedule_publish_freebusy(int daysToPublish)
3679{ 3672{
3680 QDateTime start = QDateTime::currentDateTime(); 3673 QDateTime start = QDateTime::currentDateTime();
3681 QDateTime end = start.addDays(daysToPublish); 3674 QDateTime end = start.addDays(daysToPublish);
3682 3675
3683 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3676 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3684 freebusy->setOrganizer(KOPrefs::instance()->email()); 3677 freebusy->setOrganizer(KOPrefs::instance()->email());
3685 3678
3686 3679
3687 PublishDialog *publishdlg = new PublishDialog(); 3680 PublishDialog *publishdlg = new PublishDialog();
3688 if ( publishdlg->exec() == QDialog::Accepted ) { 3681 if ( publishdlg->exec() == QDialog::Accepted ) {
3689 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3682 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3690 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3683 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3691 delete(freebusy); 3684 delete(freebusy);
3692 } 3685 }
3693 } 3686 }
3694 delete publishdlg; 3687 delete publishdlg;
3695} 3688}
3696 3689
3697void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3690void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3698{ 3691{
3699 Event *event = 0; 3692 Event *event = 0;
3700 Todo *todo = 0; 3693 Todo *todo = 0;
3701 3694
3702 if (incidence == 0) { 3695 if (incidence == 0) {
3703 incidence = mViewManager->currentView()->selectedIncidences().first(); 3696 incidence = mViewManager->currentView()->selectedIncidences().first();
3704 if (incidence == 0) { 3697 if (incidence == 0) {
3705 incidence = mTodoList->selectedIncidences().first(); 3698 incidence = mTodoList->selectedIncidences().first();
3706 } 3699 }
3707 } 3700 }
3708 if ( incidence && incidence->typeID() == eventID ) { 3701 if ( incidence && incidence->typeID() == eventID ) {
3709 event = static_cast<Event *>(incidence); 3702 event = static_cast<Event *>(incidence);
3710 } 3703 }
3711 if ( incidence && incidence->typeID() == todoID ) { 3704 if ( incidence && incidence->typeID() == todoID ) {
3712 todo = static_cast<Todo *>(incidence); 3705 todo = static_cast<Todo *>(incidence);
3713 } 3706 }
3714 3707
3715 if (!event && !todo) { 3708 if (!event && !todo) {
3716 KMessageBox::sorry(this,i18n("No event selected.")); 3709 KMessageBox::sorry(this,i18n("No event selected."));
3717 return; 3710 return;
3718 } 3711 }
3719 3712
3720 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3713 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3721 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3714 KMessageBox::sorry(this,i18n("The event has no attendees."));
3722 return; 3715 return;
3723 } 3716 }
3724 3717
3725 Event *ev = 0; 3718 Event *ev = 0;
3726 if (event) ev = new Event(*event); 3719 if (event) ev = new Event(*event);
3727 Todo *to = 0; 3720 Todo *to = 0;
3728 if (todo) to = new Todo(*todo); 3721 if (todo) to = new Todo(*todo);
3729 3722
3730 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3723 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3731 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3724 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3732 if (!me) { 3725 if (!me) {
3733 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3726 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3734 return; 3727 return;
3735 } 3728 }
3736 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3729 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3737 StatusDialog *statdlg = new StatusDialog(this); 3730 StatusDialog *statdlg = new StatusDialog(this);
3738 if (!statdlg->exec()==QDialog::Accepted) return; 3731 if (!statdlg->exec()==QDialog::Accepted) return;
3739 me->setStatus( statdlg->status() ); 3732 me->setStatus( statdlg->status() );
3740 delete(statdlg); 3733 delete(statdlg);
3741 } 3734 }
3742 Attendee *menew = new Attendee(*me); 3735 Attendee *menew = new Attendee(*me);
3743 if (ev) { 3736 if (ev) {
3744 ev->clearAttendees(); 3737 ev->clearAttendees();
3745 ev->addAttendee(menew,false); 3738 ev->addAttendee(menew,false);
3746 } else { 3739 } else {
3747 if (to) { 3740 if (to) {
3748 todo->clearAttendees(); 3741 todo->clearAttendees();
3749 todo->addAttendee(menew,false); 3742 todo->addAttendee(menew,false);
3750 } 3743 }
3751 } 3744 }
3752 } 3745 }
3753 3746
3754 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3747 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3755 if (ev) { 3748 if (ev) {
3756 if ( !dlg->addMessage(ev,method) ) delete(ev); 3749 if ( !dlg->addMessage(ev,method) ) delete(ev);
3757 } else { 3750 } else {
3758 if (to) { 3751 if (to) {
3759 if ( !dlg->addMessage(to,method) ) delete(to); 3752 if ( !dlg->addMessage(to,method) ) delete(to);
3760 } 3753 }
3761 } 3754 }
3762} 3755}
3763 3756
3764void CalendarView::openAddressbook() 3757void CalendarView::openAddressbook()
3765{ 3758{
3766 KRun::runCommand("kaddressbook"); 3759 KRun::runCommand("kaddressbook");
3767} 3760}
3768 3761
3769void CalendarView::setModified(bool modified) 3762void CalendarView::setModified(bool modified)
3770{ 3763{
3771 if ( modified ) 3764 if ( modified )
3772 emit signalmodified(); 3765 emit signalmodified();
3773 if (mModified != modified) { 3766 if (mModified != modified) {
3774 mModified = modified; 3767 mModified = modified;
3775 emit modifiedChanged(mModified); 3768 emit modifiedChanged(mModified);
3776 } 3769 }
3777} 3770}
3778 3771
3779bool CalendarView::isReadOnly() 3772bool CalendarView::isReadOnly()
3780{ 3773{
3781 return mReadOnly; 3774 return mReadOnly;
3782} 3775}
3783 3776
3784void CalendarView::setReadOnly(bool readOnly) 3777void CalendarView::setReadOnly(bool readOnly)
3785{ 3778{
3786 if (mReadOnly != readOnly) { 3779 if (mReadOnly != readOnly) {
3787 mReadOnly = readOnly; 3780 mReadOnly = readOnly;
3788 emit readOnlyChanged(mReadOnly); 3781 emit readOnlyChanged(mReadOnly);
3789 } 3782 }
3790} 3783}
3791 3784
3792bool CalendarView::isModified() 3785bool CalendarView::isModified()
3793{ 3786{
3794 return mModified; 3787 return mModified;
3795} 3788}
3796void CalendarView::slotprintSelInc() 3789void CalendarView::slotprintSelInc()
3797{ 3790{
3798 if ( currentSelection() == 0 ) { 3791 if ( currentSelection() == 0 ) {
3799 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3792 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3800 return; 3793 return;
3801 } 3794 }
3802 showIncidence(); 3795 showIncidence();
3803 getEventViewerDialog()->print(); 3796 getEventViewerDialog()->print();
3804 3797
3805} 3798}
3806void CalendarView::printSetup() 3799void CalendarView::printSetup()
3807{ 3800{
3808#ifndef KORG_NOPRINTER 3801#ifndef KORG_NOPRINTER
3809 createPrinter(); 3802 createPrinter();
3810 3803
3811 mCalPrinter->setupPrinter(); 3804 mCalPrinter->setupPrinter();
3812#endif 3805#endif
3813} 3806}
3814 3807
3815void CalendarView::print() 3808void CalendarView::print()
3816{ 3809{
3817#ifndef KORG_NOPRINTER 3810#ifndef KORG_NOPRINTER
3818 createPrinter(); 3811 createPrinter();
3819 3812
3820 DateList tmpDateList = mNavigator->selectedDates(); 3813 DateList tmpDateList = mNavigator->selectedDates();
3821 mCalPrinter->print(CalPrinter::Month, 3814 mCalPrinter->print(CalPrinter::Month,
3822 tmpDateList.first(), tmpDateList.last()); 3815 tmpDateList.first(), tmpDateList.last());
3823#endif 3816#endif
3824} 3817}
3825 3818
3826void CalendarView::printPreview() 3819void CalendarView::printPreview()
3827{ 3820{
3828#ifndef KORG_NOPRINTER 3821#ifndef KORG_NOPRINTER
3829 kdDebug() << "CalendarView::printPreview()" << endl; 3822 kdDebug() << "CalendarView::printPreview()" << endl;
3830 3823
3831 createPrinter(); 3824 createPrinter();
3832 3825
3833 DateList tmpDateList = mNavigator->selectedDates(); 3826 DateList tmpDateList = mNavigator->selectedDates();
3834 3827
3835 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3828 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3836 tmpDateList.last()); 3829 tmpDateList.last());
3837#endif 3830#endif
3838} 3831}
3839 3832
3840void CalendarView::exportICalendar() 3833void CalendarView::exportICalendar()
3841{ 3834{
3842 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3835 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3843 3836
3844 // Force correct extension 3837 // Force correct extension
3845 if (filename.right(4) != ".ics") filename += ".ics"; 3838 if (filename.right(4) != ".ics") filename += ".ics";
3846 3839
3847 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3840 FileStorage storage( mCalendar, filename, new ICalFormat() );
3848 storage.save(); 3841 storage.save();
3849} 3842}
3850 3843
3851bool CalendarView::exportVCalendar( QString filename ) 3844bool CalendarView::exportVCalendar( QString filename )
3852{ 3845{
3853 if (mCalendar->journals().count() > 0) { 3846 if (mCalendar->journals().count() > 0) {
3854 int result = KMessageBox::warningContinueCancel(this, 3847 int result = KMessageBox::warningContinueCancel(this,
3855 i18n("The journal entries can not be\nexported to a vCalendar file."), 3848 i18n("The journal entries can not be\nexported to a vCalendar file."),
3856 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3849 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3857 true); 3850 true);
3858 if (result != KMessageBox::Continue) return false; 3851 if (result != KMessageBox::Continue) return false;
3859 } 3852 }
3860 3853
3861 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3854 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3862 3855
3863 // Force correct extension 3856 // Force correct extension
3864 if (filename.right(4) != ".vcs") filename += ".vcs"; 3857 if (filename.right(4) != ".vcs") filename += ".vcs";
3865 3858
3866 FileStorage storage( mCalendar, filename, new VCalFormat ); 3859 FileStorage storage( mCalendar, filename, new VCalFormat );
3867 return storage.save(); 3860 return storage.save();
3868 3861
3869} 3862}
3870 3863
3871void CalendarView::eventUpdated(Incidence *) 3864void CalendarView::eventUpdated(Incidence *)
3872{ 3865{
3873 setModified(); 3866 setModified();
3874 // Don't call updateView here. The code, which has caused the update of the 3867 // Don't call updateView here. The code, which has caused the update of the
3875 // event is responsible for updating the view. 3868 // event is responsible for updating the view.
3876 // updateView(); 3869 // updateView();
3877} 3870}
3878 3871
3879void CalendarView::adaptNavigationUnits() 3872void CalendarView::adaptNavigationUnits()
3880{ 3873{
3881 if (mViewManager->currentView()->isEventView()) { 3874 if (mViewManager->currentView()->isEventView()) {
3882 int days = mViewManager->currentView()->currentDateCount(); 3875 int days = mViewManager->currentView()->currentDateCount();
3883 if (days == 1) { 3876 if (days == 1) {
3884 emit changeNavStringPrev(i18n("&Previous Day")); 3877 emit changeNavStringPrev(i18n("&Previous Day"));
3885 emit changeNavStringNext(i18n("&Next Day")); 3878 emit changeNavStringNext(i18n("&Next Day"));
3886 } else { 3879 } else {
3887 emit changeNavStringPrev(i18n("&Previous Week")); 3880 emit changeNavStringPrev(i18n("&Previous Week"));
3888 emit changeNavStringNext(i18n("&Next Week")); 3881 emit changeNavStringNext(i18n("&Next Week"));
3889 } 3882 }
3890 } 3883 }
3891} 3884}
3892 3885
3893void CalendarView::processMainViewSelection( Incidence *incidence ) 3886void CalendarView::processMainViewSelection( Incidence *incidence )
3894{ 3887{
3895 if ( incidence ) mTodoList->clearSelection(); 3888 if ( incidence ) mTodoList->clearSelection();
3896 processIncidenceSelection( incidence ); 3889 processIncidenceSelection( incidence );
3897} 3890}
3898 3891
3899void CalendarView::processTodoListSelection( Incidence *incidence ) 3892void CalendarView::processTodoListSelection( Incidence *incidence )
3900{ 3893{
3901 if ( incidence && mViewManager->currentView() ) { 3894 if ( incidence && mViewManager->currentView() ) {
3902 mViewManager->currentView()->clearSelection(); 3895 mViewManager->currentView()->clearSelection();
3903 } 3896 }
3904 processIncidenceSelection( incidence ); 3897 processIncidenceSelection( incidence );
3905} 3898}
3906 3899
3907void CalendarView::processIncidenceSelection( Incidence *incidence ) 3900void CalendarView::processIncidenceSelection( Incidence *incidence )
3908{ 3901{
3909 if ( incidence == mSelectedIncidence ) return; 3902 if ( incidence == mSelectedIncidence ) return;
3910 3903
3911 mSelectedIncidence = incidence; 3904 mSelectedIncidence = incidence;
3912 3905
3913 emit incidenceSelected( mSelectedIncidence ); 3906 emit incidenceSelected( mSelectedIncidence );
3914 3907
3915 if ( incidence && incidence->typeID() == eventID ) { 3908 if ( incidence && incidence->typeID() == eventID ) {
3916 Event *event = static_cast<Event *>( incidence ); 3909 Event *event = static_cast<Event *>( incidence );
3917 if ( event->organizer() == KOPrefs::instance()->email() ) { 3910 if ( event->organizer() == KOPrefs::instance()->email() ) {
3918 emit organizerEventsSelected( true ); 3911 emit organizerEventsSelected( true );
3919 } else { 3912 } else {
3920 emit organizerEventsSelected(false); 3913 emit organizerEventsSelected(false);
3921 } 3914 }
3922 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3915 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3923 KOPrefs::instance()->email() ) ) { 3916 KOPrefs::instance()->email() ) ) {
3924 emit groupEventsSelected( true ); 3917 emit groupEventsSelected( true );
3925 } else { 3918 } else {
3926 emit groupEventsSelected(false); 3919 emit groupEventsSelected(false);
3927 } 3920 }
3928 return; 3921 return;
3929 } else { 3922 } else {
3930 if ( incidence && incidence->typeID() == todoID ) { 3923 if ( incidence && incidence->typeID() == todoID ) {
3931 emit todoSelected( true ); 3924 emit todoSelected( true );
3932 Todo *event = static_cast<Todo *>( incidence ); 3925 Todo *event = static_cast<Todo *>( incidence );
3933 if ( event->organizer() == KOPrefs::instance()->email() ) { 3926 if ( event->organizer() == KOPrefs::instance()->email() ) {
3934 emit organizerEventsSelected( true ); 3927 emit organizerEventsSelected( true );
3935 } else { 3928 } else {
3936 emit organizerEventsSelected(false); 3929 emit organizerEventsSelected(false);
3937 } 3930 }
3938 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3931 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3939 KOPrefs::instance()->email() ) ) { 3932 KOPrefs::instance()->email() ) ) {
3940 emit groupEventsSelected( true ); 3933 emit groupEventsSelected( true );
3941 } else { 3934 } else {
3942 emit groupEventsSelected(false); 3935 emit groupEventsSelected(false);
3943 } 3936 }
3944 return; 3937 return;
3945 } else { 3938 } else {
3946 emit todoSelected( false ); 3939 emit todoSelected( false );
3947 emit organizerEventsSelected(false); 3940 emit organizerEventsSelected(false);
3948 emit groupEventsSelected(false); 3941 emit groupEventsSelected(false);
3949 } 3942 }
3950 return; 3943 return;
3951 } 3944 }
3952 3945
3953 /* if ( incidence && incidence->typeID() == todoID ) { 3946 /* if ( incidence && incidence->typeID() == todoID ) {
3954 emit todoSelected( true ); 3947 emit todoSelected( true );
3955 } else { 3948 } else {
3956 emit todoSelected( false ); 3949 emit todoSelected( false );
3957 }*/ 3950 }*/
3958} 3951}
3959 3952
3960 3953
3961void CalendarView::checkClipboard() 3954void CalendarView::checkClipboard()
3962{ 3955{
3963#ifndef KORG_NODND 3956#ifndef KORG_NODND
3964 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3957 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3965 emit pasteEnabled(true); 3958 emit pasteEnabled(true);
3966 } else { 3959 } else {
3967 emit pasteEnabled(false); 3960 emit pasteEnabled(false);
3968 } 3961 }
3969#endif 3962#endif
3970} 3963}
3971 3964
3972void CalendarView::showDates(const DateList &selectedDates) 3965void CalendarView::showDates(const DateList &selectedDates)
3973{ 3966{
3974 // kdDebug() << "CalendarView::selectDates()" << endl; 3967 // kdDebug() << "CalendarView::selectDates()" << endl;
3975 3968
3976 3969
3977 if ( !mBlockShowDates ) { 3970 if ( !mBlockShowDates ) {
3978 if ( mViewManager->currentView() ) { 3971 if ( mViewManager->currentView() ) {
3979 updateView( selectedDates.first(), selectedDates.last() ); 3972 updateView( selectedDates.first(), selectedDates.last() );
3980 } else { 3973 } else {
3981 mViewManager->showAgendaView(); 3974 mViewManager->showAgendaView();
3982 } 3975 }
3983 } 3976 }
3984 3977
3985 QDate date = selectedDates.first(); 3978 QDate date = selectedDates.first();
3986 if ( ! date.isValid() ) { 3979 if ( ! date.isValid() ) {
3987 topLevelWidget()->setCaption(""); 3980 topLevelWidget()->setCaption("");
3988 return; 3981 return;
3989 } 3982 }
3990 3983
3991 QString selDates; 3984 QString selDates;
3992 selDates = KGlobal::locale()->formatDate( date, true); 3985 selDates = KGlobal::locale()->formatDate( date, true);
3993 if (selectedDates.first() < selectedDates.last() ) 3986 if (selectedDates.first() < selectedDates.last() )
3994 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3987 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3995 else { 3988 else {
3996 QString addString; 3989 QString addString;
3997 if ( date == QDateTime::currentDateTime().date() ) 3990 if ( date == QDateTime::currentDateTime().date() )
3998 addString = i18n("Today"); 3991 addString = i18n("Today");
3999 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3992 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
4000 addString = i18n("Tomorrow"); 3993 addString = i18n("Tomorrow");
4001 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3994 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
4002 addString = i18n("Yesterday"); 3995 addString = i18n("Yesterday");
4003 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3996 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
4004 addString = i18n("Day before yesterday"); 3997 addString = i18n("Day before yesterday");
4005 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3998 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
4006 addString = i18n("Day after tomorrow"); 3999 addString = i18n("Day after tomorrow");
4007 if ( !addString.isEmpty() ) { 4000 if ( !addString.isEmpty() ) {
4008 topLevelWidget()->setCaption( addString+", " + selDates ); 4001 topLevelWidget()->setCaption( addString+", " + selDates );
4009 return; 4002 return;
4010 } 4003 }
4011 } 4004 }
4012 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 4005 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
4013 4006
4014} 4007}
4015 4008
4016QPtrList<CalFilter> CalendarView::filters() 4009QPtrList<CalFilter> CalendarView::filters()
4017{ 4010{
4018 return mFilters; 4011 return mFilters;
4019 4012
4020} 4013}
4021void CalendarView::editFilters() 4014void CalendarView::editFilters()
4022{ 4015{
4023 // kdDebug() << "CalendarView::editFilters()" << endl; 4016 // kdDebug() << "CalendarView::editFilters()" << endl;
4024 4017
4025 CalFilter *filter = mFilters.first(); 4018 CalFilter *filter = mFilters.first();
4026 while(filter) { 4019 while(filter) {
4027 kdDebug() << " Filter: " << filter->name() << endl; 4020 kdDebug() << " Filter: " << filter->name() << endl;
4028 filter = mFilters.next(); 4021 filter = mFilters.next();
4029 } 4022 }
4030 4023
4031 mDialogManager->showFilterEditDialog(&mFilters); 4024 mDialogManager->showFilterEditDialog(&mFilters);
4032} 4025}
4033void CalendarView::toggleFilter() 4026void CalendarView::toggleFilter()
4034{ 4027{
4035 showFilter(! mCalEditView->isVisible()); 4028 showFilter(! mCalEditView->isVisible());
4036} 4029}
4037 4030
4038KOFilterView *CalendarView::filterView() 4031KOFilterView *CalendarView::filterView()
4039{ 4032{
4040 return mFilterView; 4033 return mFilterView;
4041} 4034}
4042void CalendarView::selectFilter( int fil ) 4035void CalendarView::selectFilter( int fil )
4043{ 4036{
4044 mFilterView->setSelectedFilter( fil ); 4037 mFilterView->setSelectedFilter( fil );
4045} 4038}
4046void CalendarView::showFilter(bool visible) 4039void CalendarView::showFilter(bool visible)
4047{ 4040{
4048#if 1 4041#if 1
4049 if (visible) { 4042 if (visible) {
4050 mCalEditView->readConfig(); 4043 mCalEditView->readConfig();
4051 mCalEditView->show(); 4044 mCalEditView->show();
4052 QValueList<int> sizes; 4045 QValueList<int> sizes;
4053 sizes = mLeftFrame->sizes(); 4046 sizes = mLeftFrame->sizes();
4054 if ( sizes.count() == 4 && sizes[3] < 20 ) { 4047 if ( sizes.count() == 4 && sizes[3] < 20 ) {
4055 sizes.clear(); 4048 sizes.clear();
4056 sizes << 100; 4049 sizes << 100;
4057 sizes << 0; 4050 sizes << 0;
4058 sizes << 0; 4051 sizes << 0;
4059 sizes << 100; 4052 sizes << 100;
4060 mLeftFrame->setSizes(sizes); 4053 mLeftFrame->setSizes(sizes);
4061 } 4054 }
4062#if 0 4055#if 0
4063 sizes = mLeftFrame->sizes(); 4056 sizes = mLeftFrame->sizes();
4064 int ccc = 0; 4057 int ccc = 0;
4065 while ( ccc < sizes.count()) { 4058 while ( ccc < sizes.count()) {
4066 qDebug("size %d %d ", ccc, sizes[ccc]); 4059 qDebug("size %d %d ", ccc, sizes[ccc]);
4067 ++ccc; 4060 ++ccc;
4068 } 4061 }
4069#endif 4062#endif
4070 4063
4071 } 4064 }
4072 else { 4065 else {
4073 mCalEditView->hide(); 4066 mCalEditView->hide();
4074 } 4067 }
4075#else 4068#else
4076 if (visible) mFilterView->show(); 4069 if (visible) mFilterView->show();
4077 else mFilterView->hide(); 4070 else mFilterView->hide();
4078#endif 4071#endif
4079} 4072}
4080void CalendarView::toggleFilerEnabled( ) 4073void CalendarView::toggleFilerEnabled( )
4081{ 4074{
4082 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 4075 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
4083 if ( !mFilterView->filtersEnabled() ) 4076 if ( !mFilterView->filtersEnabled() )
4084 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 4077 topLevelWidget()->setCaption( i18n("Filter disabled ") );
4085 4078
4086} 4079}
4087void CalendarView::updateFilter() 4080void CalendarView::updateFilter()
4088{ 4081{
4089 CalFilter *filter = mFilterView->selectedFilter(); 4082 CalFilter *filter = mFilterView->selectedFilter();
4090 if (filter) { 4083 if (filter) {
4091 QString mess; 4084 QString mess;
4092 if (mFilterView->filtersEnabled()) { 4085 if (mFilterView->filtersEnabled()) {
4093 mess = i18n("Filter selected: ")+filter->name(); 4086 mess = i18n("Filter selected: ")+filter->name();
4094 filter->setEnabled(true); 4087 filter->setEnabled(true);
4095 } 4088 }
4096 else filter->setEnabled(false); 4089 else filter->setEnabled(false);
4097 mCalendar->setFilter(filter); 4090 mCalendar->setFilter(filter);
4098 updateView(); 4091 updateView();
4099 if ( !mess.isEmpty() ) 4092 if ( !mess.isEmpty() )
4100 topLevelWidget()->setCaption( mess ); 4093 topLevelWidget()->setCaption( mess );
4101 4094
4102 } 4095 }
4103} 4096}
4104 4097
4105void CalendarView::filterEdited() 4098void CalendarView::filterEdited()
4106{ 4099{
4107 mFilterView->updateFilters(); 4100 mFilterView->updateFilters();
4108 updateFilter(); 4101 updateFilter();
4109 writeSettings(); 4102 writeSettings();
4110} 4103}
4111 4104
4112 4105
4113void CalendarView::takeOverEvent() 4106void CalendarView::takeOverEvent()
4114{ 4107{
4115 Incidence *incidence = currentSelection(); 4108 Incidence *incidence = currentSelection();
4116 4109
4117 if (!incidence) return; 4110 if (!incidence) return;
4118 4111
4119 incidence->setOrganizer(KOPrefs::instance()->email()); 4112 incidence->setOrganizer(KOPrefs::instance()->email());
4120 incidence->recreate(); 4113 incidence->recreate();
4121 incidence->setReadOnly(false); 4114 incidence->setReadOnly(false);
4122 4115
4123 updateView(); 4116 updateView();
4124} 4117}
4125 4118
4126void CalendarView::takeOverCalendar() 4119void CalendarView::takeOverCalendar()
4127{ 4120{
4128 // TODO: Create Calendar::allIncidences() function and use it here 4121 // TODO: Create Calendar::allIncidences() function and use it here
4129 4122
4130 clearAllViews(); 4123 clearAllViews();
4131 QPtrList<Event> events = mCalendar->events(); 4124 QPtrList<Event> events = mCalendar->events();
4132 for(uint i=0; i<events.count(); ++i) { 4125 for(uint i=0; i<events.count(); ++i) {
4133 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4126 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4134 events.at(i)->recreate(); 4127 events.at(i)->recreate();
4135 events.at(i)->setReadOnly(false); 4128 events.at(i)->setReadOnly(false);
4136 } 4129 }
4137 4130
4138 QPtrList<Todo> todos = mCalendar->todos(); 4131 QPtrList<Todo> todos = mCalendar->todos();
4139 for(uint i=0; i<todos.count(); ++i) { 4132 for(uint i=0; i<todos.count(); ++i) {
4140 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4133 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4141 todos.at(i)->recreate(); 4134 todos.at(i)->recreate();
4142 todos.at(i)->setReadOnly(false); 4135 todos.at(i)->setReadOnly(false);
4143 } 4136 }
4144 4137
4145 QPtrList<Journal> journals = mCalendar->journals(); 4138 QPtrList<Journal> journals = mCalendar->journals();
4146 for(uint i=0; i<journals.count(); ++i) { 4139 for(uint i=0; i<journals.count(); ++i) {
4147 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4140 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4148 journals.at(i)->recreate(); 4141 journals.at(i)->recreate();
4149 journals.at(i)->setReadOnly(false); 4142 journals.at(i)->setReadOnly(false);
4150 } 4143 }
4151 4144
4152 updateView(); 4145 updateView();
4153} 4146}
4154 4147
4155void CalendarView::showIntro() 4148void CalendarView::showIntro()
4156{ 4149{
4157 kdDebug() << "To be implemented." << endl; 4150 kdDebug() << "To be implemented." << endl;
4158} 4151}
4159 4152
4160QWidgetStack *CalendarView::viewStack() 4153QWidgetStack *CalendarView::viewStack()
4161{ 4154{
4162 return mRightFrame; 4155 return mRightFrame;
4163} 4156}
4164 4157
4165QWidget *CalendarView::leftFrame() 4158QWidget *CalendarView::leftFrame()
4166{ 4159{
4167 return ( QWidget *)mLeftFrame; 4160 return ( QWidget *)mLeftFrame;
4168} 4161}
4169 4162
4170DateNavigator *CalendarView::dateNavigator() 4163DateNavigator *CalendarView::dateNavigator()
4171{ 4164{
4172 return mNavigator; 4165 return mNavigator;
4173} 4166}
4174 4167
4175KDateNavigator* CalendarView::dateNavigatorWidget() 4168KDateNavigator* CalendarView::dateNavigatorWidget()
4176{ 4169{
4177 return mDateNavigator->navigatorView(); 4170 return mDateNavigator->navigatorView();
4178} 4171}
4179void CalendarView::toggleDateNavigatorWidget() 4172void CalendarView::toggleDateNavigatorWidget()
4180{ 4173{
4181 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4174 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4182 4175
4183 if (!KOPrefs::instance()->mShowDateNavigator ) 4176 if (!KOPrefs::instance()->mShowDateNavigator )
4184 mDateNavigator->hide(); 4177 mDateNavigator->hide();
4185 else 4178 else
4186 mDateNavigator->show(); 4179 mDateNavigator->show();
4187} 4180}
4188void CalendarView::addView(KOrg::BaseView *view) 4181void CalendarView::addView(KOrg::BaseView *view)
4189{ 4182{
4190 mViewManager->addView(view); 4183 mViewManager->addView(view);
4191} 4184}
4192 4185
4193void CalendarView::showView(KOrg::BaseView *view) 4186void CalendarView::showView(KOrg::BaseView *view)
4194{ 4187{
4195 mViewManager->showView(view, mLeftFrame->isVisible()); 4188 mViewManager->showView(view, mLeftFrame->isVisible());
4196} 4189}
4197 4190
4198Incidence *CalendarView::currentSelection() 4191Incidence *CalendarView::currentSelection()
4199{ 4192{
4200 return mViewManager->currentSelection(); 4193 return mViewManager->currentSelection();
4201} 4194}
4202void CalendarView::toggleAllDaySize() 4195void CalendarView::toggleAllDaySize()
4203{ 4196{
4204 /* 4197 /*
4205 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4198 if ( KOPrefs::instance()->mAllDaySize > 47 )
4206 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4199 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4207 else 4200 else
4208 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4201 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4209 */ 4202 */
4210 viewManager()->agendaView()->toggleAllDay(); 4203 viewManager()->agendaView()->toggleAllDay();
4211} 4204}
4212void CalendarView::toggleExpand() 4205void CalendarView::toggleExpand()
4213{ 4206{
4214 // if ( mLeftFrame->isHidden() ) { 4207 // if ( mLeftFrame->isHidden() ) {
4215 // mLeftFrame->show(); 4208 // mLeftFrame->show();
4216 // emit calendarViewExpanded( false ); 4209 // emit calendarViewExpanded( false );
4217 // } else { 4210 // } else {
4218 // mLeftFrame->hide(); 4211 // mLeftFrame->hide();
4219 // emit calendarViewExpanded( true ); 4212 // emit calendarViewExpanded( true );
4220 // } 4213 // }
4221 //qDebug(" CalendarView::toggleExpand()"); 4214 //qDebug(" CalendarView::toggleExpand()");
4222 globalFlagBlockAgenda = 1; 4215 globalFlagBlockAgenda = 1;
4223 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4216 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4224 globalFlagBlockAgenda = 5; 4217 globalFlagBlockAgenda = 5;
4225 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4218 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4226 //mViewManager->showView( 0, true ); 4219 //mViewManager->showView( 0, true );
4227} 4220}
4228 4221
4229void CalendarView::calendarModified( bool modified, Calendar * ) 4222void CalendarView::calendarModified( bool modified, Calendar * )
4230{ 4223{
4231 setModified( modified ); 4224 setModified( modified );
4232} 4225}
4233 4226
4234Todo *CalendarView::selectedTodo() 4227Todo *CalendarView::selectedTodo()
4235{ 4228{
4236 Incidence *incidence = currentSelection(); 4229 Incidence *incidence = currentSelection();
4237 if ( incidence && incidence->typeID() == todoID ) { 4230 if ( incidence && incidence->typeID() == todoID ) {
4238 return static_cast<Todo *>( incidence ); 4231 return static_cast<Todo *>( incidence );
4239 } 4232 }
4240 4233
4241 incidence = mTodoList->selectedIncidences().first(); 4234 incidence = mTodoList->selectedIncidences().first();
4242 if ( incidence && incidence->typeID() == todoID ) { 4235 if ( incidence && incidence->typeID() == todoID ) {
4243 return static_cast<Todo *>( incidence ); 4236 return static_cast<Todo *>( incidence );
4244 } 4237 }
4245 4238
4246 return 0; 4239 return 0;
4247} 4240}
4248 4241
4249void CalendarView::dialogClosing(Incidence *in) 4242void CalendarView::dialogClosing(Incidence *in)
4250{ 4243{
4251 // mDialogList.remove(in); 4244 // mDialogList.remove(in);
4252} 4245}
4253 4246
4254void CalendarView::showIncidence() 4247void CalendarView::showIncidence()
4255{ 4248{
4256 mViewerCallerIsSearchDialog = false; 4249 mViewerCallerIsSearchDialog = false;
4257 Incidence *incidence = currentSelection(); 4250 Incidence *incidence = currentSelection();
4258 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4251 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4259 if ( incidence ) { 4252 if ( incidence ) {
4260 ShowIncidenceVisitor v; 4253 ShowIncidenceVisitor v;
4261 v.act( incidence, this ); 4254 v.act( incidence, this );
4262 } 4255 }
4263} 4256}
4264void CalendarView::editIncidenceDescription() 4257void CalendarView::editIncidenceDescription()
4265{ 4258{
4266 mFlagEditDescription = true; 4259 mFlagEditDescription = true;
4267 editIncidence(); 4260 editIncidence();
4268 mFlagEditDescription = false; 4261 mFlagEditDescription = false;
4269} 4262}
4270void CalendarView::editIncidence() 4263void CalendarView::editIncidence()
4271{ 4264{
4272 // qDebug("editIncidence() "); 4265 // qDebug("editIncidence() ");
4273 Incidence *incidence = currentSelection(); 4266 Incidence *incidence = currentSelection();
4274 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4267 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4275 if ( incidence ) { 4268 if ( incidence ) {
4276 EditIncidenceVisitor v; 4269 EditIncidenceVisitor v;
4277 v.act( incidence, this ); 4270 v.act( incidence, this );
4278 } 4271 }
4279} 4272}
4280 4273
4281void CalendarView::deleteIncidence() 4274void CalendarView::deleteIncidence()
4282{ 4275{
4283 Incidence *incidence = currentSelection(); 4276 Incidence *incidence = currentSelection();
4284 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4277 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4285 if ( incidence ) { 4278 if ( incidence ) {
4286 deleteIncidence(incidence); 4279 deleteIncidence(incidence);
4287 } 4280 }
4288} 4281}
4289void CalendarView::showIncidence(QString uid) 4282void CalendarView::showIncidence(QString uid)
4290{ 4283{
4291 Incidence *inc = mCalendar->incidence( uid ); 4284 Incidence *inc = mCalendar->incidence( uid );
4292 if ( inc ) 4285 if ( inc )
4293 showIncidence( inc ); 4286 showIncidence( inc );
4294} 4287}
4295void CalendarView::showIncidence(Incidence *incidence) 4288void CalendarView::showIncidence(Incidence *incidence)
4296{ 4289{
4297 mViewerCallerIsSearchDialog = false; 4290 mViewerCallerIsSearchDialog = false;
4298 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4291 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4299 if ( sender() && mDialogManager->getSearchDialog() ) { 4292 if ( sender() && mDialogManager->getSearchDialog() ) {
4300 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4293 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4301 mViewerCallerIsSearchDialog = true; 4294 mViewerCallerIsSearchDialog = true;
4302 } 4295 }
4303 } 4296 }
4304 if ( incidence ) { 4297 if ( incidence ) {
4305 ShowIncidenceVisitor v; 4298 ShowIncidenceVisitor v;
4306 v.act( incidence, this ); 4299 v.act( incidence, this );
4307 } 4300 }
4308} 4301}
4309 4302
4310void CalendarView::editIncidence(Incidence *incidence) 4303void CalendarView::editIncidence(Incidence *incidence)
4311{ 4304{
4312 if ( incidence ) { 4305 if ( incidence ) {
4313 4306
4314 EditIncidenceVisitor v; 4307 EditIncidenceVisitor v;
4315 v.act( incidence, this ); 4308 v.act( incidence, this );
4316 4309
4317 } 4310 }
4318} 4311}
4319 4312
4320void CalendarView::deleteIncidence(Incidence *incidence) 4313void CalendarView::deleteIncidence(Incidence *incidence)
4321{ 4314{
4322 //qDebug(" CalendarView::deleteIncidence "); 4315 //qDebug(" CalendarView::deleteIncidence ");
4323 if ( incidence ) { 4316 if ( incidence ) {
4324 DeleteIncidenceVisitor v; 4317 DeleteIncidenceVisitor v;
4325 v.act( incidence, this ); 4318 v.act( incidence, this );
4326 } 4319 }
4327} 4320}
4328 4321
4329 4322
4330void CalendarView::lookForOutgoingMessages() 4323void CalendarView::lookForOutgoingMessages()
4331{ 4324{
4332 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4325 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4333 ogd->loadMessages(); 4326 ogd->loadMessages();
4334} 4327}
4335 4328
4336void CalendarView::lookForIncomingMessages() 4329void CalendarView::lookForIncomingMessages()
4337{ 4330{
4338 IncomingDialog *icd = mDialogManager->incomingDialog(); 4331 IncomingDialog *icd = mDialogManager->incomingDialog();
4339 icd->retrieve(); 4332 icd->retrieve();
4340} 4333}
4341 4334
4342bool CalendarView::removeCompletedSubTodos( Todo* t ) 4335bool CalendarView::removeCompletedSubTodos( Todo* t )
4343{ 4336{
4344 bool deleteTodo = true; 4337 bool deleteTodo = true;
4345 QPtrList<Incidence> subTodos; 4338 QPtrList<Incidence> subTodos;
4346 Incidence *aTodo; 4339 Incidence *aTodo;
4347 subTodos = t->relations(); 4340 subTodos = t->relations();
4348 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4341 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4349 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4342 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4350 deleteTodo = false; 4343 deleteTodo = false;
4351 } 4344 }
4352 if ( deleteTodo ) { 4345 if ( deleteTodo ) {
4353 if ( t->isCompleted() && !t->doesRecur()) { 4346 if ( t->isCompleted() && !t->doesRecur()) {
4354 checkExternalId( t ); 4347 checkExternalId( t );
4355 mCalendar->deleteTodo( t ); 4348 mCalendar->deleteTodo( t );
4356 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4349 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4357 } 4350 }
4358 else 4351 else
4359 deleteTodo = false; 4352 deleteTodo = false;
4360 } 4353 }
4361 return deleteTodo; 4354 return deleteTodo;
4362 4355
4363} 4356}
4364void CalendarView::purgeCompleted() 4357void CalendarView::purgeCompleted()
4365{ 4358{
4366 int result = KMessageBox::warningContinueCancel(this, 4359 int result = KMessageBox::warningContinueCancel(this,
4367 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 4360 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
4368 4361
4369 if (result == KMessageBox::Continue) { 4362 if (result == KMessageBox::Continue) {
4370 4363
4371 QPtrList<Todo> todoCal; 4364 QPtrList<Todo> todoCal;
4372 QPtrList<Todo> rootTodos; 4365 QPtrList<Todo> rootTodos;
4373 //QPtrList<Incidence> rel; 4366 //QPtrList<Incidence> rel;
4374 Todo *aTodo;//, *rTodo; 4367 Todo *aTodo;//, *rTodo;
4375 Incidence *rIncidence; 4368 Incidence *rIncidence;
4376 bool childDelete = false; 4369 bool childDelete = false;
4377 bool deletedOne = true; 4370 bool deletedOne = true;
4378 todoCal = calendar()->todos(); 4371 todoCal = calendar()->todos();
4379 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 4372 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
4380 if ( !aTodo->relatedTo() ) 4373 if ( !aTodo->relatedTo() )
4381 rootTodos.append( aTodo ); 4374 rootTodos.append( aTodo );
4382 } 4375 }
4383 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4376 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4384 removeCompletedSubTodos( aTodo ); 4377 removeCompletedSubTodos( aTodo );
4385 } 4378 }
4386 4379
4387 updateView(); 4380 updateView();
4388 } 4381 }
4389} 4382}
4390 4383
4391void CalendarView::slotCalendarChanged() 4384void CalendarView::slotCalendarChanged()
4392{ 4385{
4393 ; 4386 ;
4394} 4387}
4395 4388
4396void CalendarView::keyPressEvent ( QKeyEvent *e) 4389void CalendarView::keyPressEvent ( QKeyEvent *e)
4397{ 4390{
4398 //qDebug(" alendarView::keyPressEvent "); 4391 //qDebug(" alendarView::keyPressEvent ");
4399 e->ignore(); 4392 e->ignore();
4400} 4393}
4401 4394
4402 4395
4403bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4396bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4404{ 4397{
4405 // mSyncManager = manager; 4398 // mSyncManager = manager;
4406 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4399 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4407 qDebug("KO: SyncKDE request detected!"); 4400 qDebug("KO: SyncKDE request detected!");
4408 } 4401 }
4409 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4402 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4410 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4403 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4411 return syncCalendar( filename, mode ); 4404 return syncCalendar( filename, mode );
4412} 4405}
4413bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4406bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4414{ 4407{
4415 //mSyncManager = manager; 4408 //mSyncManager = manager;
4416 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4409 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4417 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4410 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4418 if ( resource == "sharp" ) 4411 if ( resource == "sharp" )
4419 syncExternal( 0 ); 4412 syncExternal( 0 );
4420 if ( resource == "phone" ) 4413 if ( resource == "phone" )
4421 syncExternal( 1 ); 4414 syncExternal( 1 );
4422 // pending setmodified 4415 // pending setmodified
4423 return true; 4416 return true;
4424} 4417}
4425void CalendarView::setSyncManager(KSyncManager* manager) 4418void CalendarView::setSyncManager(KSyncManager* manager)
4426{ 4419{
4427 mSyncManager = manager; 4420 mSyncManager = manager;
4428} 4421}
4429 4422
4430void CalendarView::removeSyncInfo( QString syncProfile) 4423void CalendarView::removeSyncInfo( QString syncProfile)
4431{ 4424{
4432 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4425 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4433 mCalendar->removeSyncInfo( syncProfile ); 4426 mCalendar->removeSyncInfo( syncProfile );
4434 4427
4435} 4428}
4436 4429
4437void CalendarView::undo_delete() 4430void CalendarView::undo_delete()
4438{ 4431{
4439 //qDebug("undo_delete() "); 4432 //qDebug("undo_delete() ");
4440 Incidence* undo = mCalendar->undoIncidence(); 4433 Incidence* undo = mCalendar->undoIncidence();
4441 if ( !undo ) { 4434 if ( !undo ) {
4442 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4435 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4443 i18n("KO/Pi")); 4436 i18n("KO/Pi"));
4444 return; 4437 return;
4445 } 4438 }
4446 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4439 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4447 i18n("\nAre you sure you want\nto restore this?"), 4440 i18n("\nAre you sure you want\nto restore this?"),
4448 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4441 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4449 mCalendar->undoDeleteIncidence(); 4442 mCalendar->undoDeleteIncidence();
4450 updateView(); 4443 updateView();
4451 } 4444 }
4452} 4445}
4453 4446
4454void CalendarView::slotViewerClosed() 4447void CalendarView::slotViewerClosed()
4455{ 4448{
4456 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4449 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4457} 4450}
4458 4451
4459void CalendarView::resetFocus() 4452void CalendarView::resetFocus()
4460{ 4453{
4461 if ( mViewerCallerIsSearchDialog ) { 4454 if ( mViewerCallerIsSearchDialog ) {
4462 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4455 if ( mDialogManager->getSearchDialog()->isVisible() ){
4463 mDialogManager->getSearchDialog()->raise(); 4456 mDialogManager->getSearchDialog()->raise();
4464 mDialogManager->getSearchDialog()->setActiveWindow(); 4457 mDialogManager->getSearchDialog()->setActiveWindow();
4465 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4458 mDialogManager->getSearchDialog()->listview()->resetFocus();
4466 } else 4459 } else
4467 mViewerCallerIsSearchDialog = false; 4460 mViewerCallerIsSearchDialog = false;
4468 } 4461 }
4469 if ( !mViewerCallerIsSearchDialog ) { 4462 if ( !mViewerCallerIsSearchDialog ) {
4470 //mViewManager->currentView()->setFocus(); 4463 //mViewManager->currentView()->setFocus();
4471 //qDebug("sssssssssssssssset focus "); 4464 //qDebug("sssssssssssssssset focus ");
4472 topLevelWidget()->raise(); 4465 topLevelWidget()->raise();
4473 setActiveWindow(); 4466 setActiveWindow();
4474 //setFocus(); 4467 //setFocus();
4475 } 4468 }
4476 mViewerCallerIsSearchDialog = false; 4469 mViewerCallerIsSearchDialog = false;
4477} 4470}
4478 4471
4479void CalendarView::showNextAlarms() 4472void CalendarView::showNextAlarms()
4480{ 4473{
4481 QString message; 4474 QString message;
4482 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4475 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4483 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4476 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4484 QString sum = mCalendar->nextSummary(); 4477 QString sum = mCalendar->nextSummary();
4485 QDateTime nextA = mNextAlarmDateTime; 4478 QDateTime nextA = mNextAlarmDateTime;
4486 QDateTime cur = QDateTime::currentDateTime(); 4479 QDateTime cur = QDateTime::currentDateTime();
4487 int secs = cur.secsTo( nextA ); 4480 int secs = cur.secsTo( nextA );
4488 int min = secs /60; 4481 int min = secs /60;
4489 int hours = min /60; 4482 int hours = min /60;
4490 min = min % 60; 4483 min = min % 60;
4491 int days = hours /24; 4484 int days = hours /24;
4492 hours = hours % 24; 4485 hours = hours % 24;
4493 4486
4494 //message = i18n("The next alarm is in:\n"); 4487 //message = i18n("The next alarm is in:\n");
4495 if ( days > 1 ) 4488 if ( days > 1 )
4496 message += i18n("%1 days\n").arg( days ); 4489 message += i18n("%1 days\n").arg( days );
4497 else if ( days == 1 ) 4490 else if ( days == 1 )
4498 message += i18n("1 day\n"); 4491 message += i18n("1 day\n");
4499 if ( hours > 1 ) 4492 if ( hours > 1 )
4500 message += i18n("%1 hours\n").arg( hours ); 4493 message += i18n("%1 hours\n").arg( hours );
4501 else if ( hours == 1 ) 4494 else if ( hours == 1 )
4502 message += i18n("1 hour\n"); 4495 message += i18n("1 hour\n");
4503 if ( min > 1 ) 4496 if ( min > 1 )
4504 message += i18n("%1 minutes\n").arg( min ); 4497 message += i18n("%1 minutes\n").arg( min );
4505 else if ( min == 1 ) 4498 else if ( min == 1 )
4506 message += i18n("1 minute\n"); 4499 message += i18n("1 minute\n");
4507 if ( message.isEmpty() ) 4500 if ( message.isEmpty() )
4508 message = i18n("The next alarm is in\nless than one minute!"); 4501 message = i18n("The next alarm is in\nless than one minute!");
4509 else 4502 else
4510 message = i18n("The next alarm is in:\n") + message; 4503 message = i18n("The next alarm is in:\n") + message;
4511 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4504 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4512 } else { 4505 } else {
4513 message = i18n("There is no next alarm."); 4506 message = i18n("There is no next alarm.");
4514 4507
4515 } 4508 }
4516#ifdef DESKTOP_VERSION 4509#ifdef DESKTOP_VERSION
4517 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 4510 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4518 message += i18n("\nThe internal alarm notification is disabled!\n"); 4511 message += i18n("\nThe internal alarm notification is disabled!\n");
4519 message += i18n("Enable it in the settings menu, TAB alarm."); 4512 message += i18n("Enable it in the settings menu, TAB alarm.");
4520 } 4513 }
4521 4514
4522#endif 4515#endif
4523 KMessageBox::information( this, message); 4516 KMessageBox::information( this, message);
4524} 4517}
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index b2b136a..93ff55e 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1654 +1,1654 @@
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 79
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 mBlockUpdating = true; 380 mBlockUpdating = true;
381 mStartHour = 8; 381 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
383 383
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 437 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
438#endif 438#endif
439 mDayLabelsFrame = new QHBox(agendaFrame); 439 mDayLabelsFrame = new QHBox(agendaFrame);
440 //topLayout->addWidget(mDayLabelsFrame); 440 //topLayout->addWidget(mDayLabelsFrame);
441 mDayLabels = new QFrame (mDayLabelsFrame); 441 mDayLabels = new QFrame (mDayLabelsFrame);
442 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 442 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 443 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
444 agendaLayout->addWidget(mEventIndicatorTop,1,1); 444 agendaLayout->addWidget(mEventIndicatorTop,1,1);
445 445
446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 446 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
447 agendaFrame); 447 agendaFrame);
448 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 448 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
449 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 449 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
450 agendaLayout->addWidget(dummyAgendaRight,1,2); 450 agendaLayout->addWidget(dummyAgendaRight,1,2);
451 451
452 // Create time labels 452 // Create time labels
453 mTimeLabels = new TimeLabels(24,agendaFrame); 453 mTimeLabels = new TimeLabels(24,agendaFrame);
454 agendaLayout->addWidget(mTimeLabels,2,0); 454 agendaLayout->addWidget(mTimeLabels,2,0);
455 connect(mTimeLabels,SIGNAL( scaleChanged()), 455 connect(mTimeLabels,SIGNAL( scaleChanged()),
456 this,SLOT(updateConfig())); 456 this,SLOT(updateConfig()));
457 457
458 // Create agenda 458 // Create agenda
459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 459 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 460 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
461 agendaLayout->setColStretch(1,1); 461 agendaLayout->setColStretch(1,1);
462 mAgenda->setFocusPolicy(NoFocus); 462 mAgenda->setFocusPolicy(NoFocus);
463 // Create event context menu for agenda 463 // Create event context menu for agenda
464 mAllAgendaPopup = eventPopup(); 464 mAllAgendaPopup = eventPopup();
465 465
466#if 0 466#if 0
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471#endif 471#endif
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 mAgenda->setPopup( mAllAgendaPopup ); 477 mAgenda->setPopup( mAllAgendaPopup );
478 mAllDayAgenda->setPopup( mAllAgendaPopup ); 478 mAllDayAgenda->setPopup( mAllAgendaPopup );
479 // make connections between dependent widgets 479 // make connections between dependent widgets
480 mTimeLabels->setAgenda(mAgenda); 480 mTimeLabels->setAgenda(mAgenda);
481 481
482 // Update widgets to reflect user preferences 482 // Update widgets to reflect user preferences
483 // updateConfig(); 483 // updateConfig();
484 484
485 // createDayLabels(); 485 // createDayLabels();
486 486
487 // these blank widgets make the All Day Event box line up with the agenda 487 // these blank widgets make the All Day Event box line up with the agenda
488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
491 491
492 // Scrolling 492 // Scrolling
493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
494 mTimeLabels, SLOT(positionChanged())); 494 mTimeLabels, SLOT(positionChanged()));
495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
496 SLOT(setContentsPos(int))); 496 SLOT(setContentsPos(int)));
497 497
498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
500 500
501 // Create/Show/Edit/Delete Event 501 // Create/Show/Edit/Delete Event
502 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 502 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
503 SLOT(newEvent(int,int))); 503 SLOT(newEvent(int,int)));
504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
505 SLOT(newTodo(int,int))); 505 SLOT(newTodo(int,int)));
506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
507 SLOT(newEvent(int,int,int,int))); 507 SLOT(newEvent(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
509 SLOT(newEventAllDay(int,int))); 509 SLOT(newEventAllDay(int,int)));
510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
511 SLOT(newTodoAllDay(int,int))); 511 SLOT(newTodoAllDay(int,int)));
512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
513 SLOT(newEventAllDay(int,int))); 513 SLOT(newEventAllDay(int,int)));
514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
515 SLOT(newTimeSpanSelected(int,int,int,int))); 515 SLOT(newTimeSpanSelected(int,int,int,int)));
516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 520
521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
522 SIGNAL(editIncidenceSignal(Incidence *))); 522 SIGNAL(editIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
524 SIGNAL(editIncidenceSignal(Incidence *))); 524 SIGNAL(editIncidenceSignal(Incidence *)));
525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
526 SIGNAL(showIncidenceSignal(Incidence *))); 526 SIGNAL(showIncidenceSignal(Incidence *)));
527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
528 SIGNAL(showIncidenceSignal(Incidence *))); 528 SIGNAL(showIncidenceSignal(Incidence *)));
529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
530 SIGNAL(deleteIncidenceSignal(Incidence *))); 530 SIGNAL(deleteIncidenceSignal(Incidence *)));
531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
532 SIGNAL(deleteIncidenceSignal(Incidence *))); 532 SIGNAL(deleteIncidenceSignal(Incidence *)));
533 533
534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
535 SLOT(updateEventDates(KOAgendaItem *, int ))); 535 SLOT(updateEventDates(KOAgendaItem *, int )));
536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
537 SLOT(updateEventDates(KOAgendaItem *, int))); 537 SLOT(updateEventDates(KOAgendaItem *, int)));
538 538
539 // event indicator update 539 // event indicator update
540 connect(mAgenda,SIGNAL(lowerYChanged(int)), 540 connect(mAgenda,SIGNAL(lowerYChanged(int)),
541 SLOT(updateEventIndicatorTop(int))); 541 SLOT(updateEventIndicatorTop(int)));
542 connect(mAgenda,SIGNAL(upperYChanged(int)), 542 connect(mAgenda,SIGNAL(upperYChanged(int)),
543 SLOT(updateEventIndicatorBottom(int))); 543 SLOT(updateEventIndicatorBottom(int)));
544 // drag signals 544 // drag signals
545 /* 545 /*
546 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 546 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
547 SLOT(startDrag(Event *))); 547 SLOT(startDrag(Event *)));
548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
549 SLOT(startDrag(Event *))); 549 SLOT(startDrag(Event *)));
550 */ 550 */
551 // synchronize selections 551 // synchronize selections
552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
553 mAllDayAgenda, SLOT( deselectItem() ) ); 553 mAllDayAgenda, SLOT( deselectItem() ) );
554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
555 mAgenda, SLOT( deselectItem() ) ); 555 mAgenda, SLOT( deselectItem() ) );
556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
557 SIGNAL( incidenceSelected( Incidence * ) ) ); 557 SIGNAL( incidenceSelected( Incidence * ) ) );
558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
559 SIGNAL( incidenceSelected( Incidence * ) ) ); 559 SIGNAL( incidenceSelected( Incidence * ) ) );
560 connect( mAgenda, SIGNAL( resizedSignal() ), 560 connect( mAgenda, SIGNAL( resizedSignal() ),
561 SLOT( updateConfig( ) ) ); 561 SLOT( updateConfig( ) ) );
562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
565 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 565 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 568
569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) ); 569 connect( mAllDayAgenda, SIGNAL( signalClearSelection() ),mAgenda, SLOT( slotClearSelection()) );
570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) ); 570 connect( mAgenda, SIGNAL( signalClearSelection() ),mAllDayAgenda, SLOT( slotClearSelection()) );
571 571
572} 572}
573 573
574void KOAgendaView::toggleAllDay() 574void KOAgendaView::toggleAllDay()
575{ 575{
576 if ( mSplitterAgenda->firstHandle() ) 576 if ( mSplitterAgenda->firstHandle() )
577 mSplitterAgenda->firstHandle()->toggle(); 577 mSplitterAgenda->firstHandle()->toggle();
578} 578}
579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 579void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
580{ 580{
581 calendar()->addIncidence( inc ); 581 calendar()->addIncidence( inc );
582 582
583 if ( incOld ) { 583 if ( incOld ) {
584 if ( incOld->typeID() == todoID ) 584 if ( incOld->typeID() == todoID )
585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 585 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
586 else 586 else
587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 587 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
588 } 588 }
589 589
590} 590}
591 591
592KOAgendaView::~KOAgendaView() 592KOAgendaView::~KOAgendaView()
593{ 593{
594 delete mAllAgendaPopup; 594 delete mAllAgendaPopup;
595 //delete mAllDayAgendaPopup; 595 //delete mAllDayAgendaPopup;
596 delete KOAgendaItem::paintPix(); 596 delete KOAgendaItem::paintPix();
597 delete KOAgendaItem::paintPixSel(); 597 delete KOAgendaItem::paintPixSel();
598} 598}
599void KOAgendaView::resizeEvent( QResizeEvent* e ) 599void KOAgendaView::resizeEvent( QResizeEvent* e )
600{ 600{
601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 601 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
602 bool uc = false; 602 bool uc = false;
603 int ow = e->oldSize().width(); 603 int ow = e->oldSize().width();
604 int oh = e->oldSize().height(); 604 int oh = e->oldSize().height();
605 int w = e->size().width(); 605 int w = e->size().width();
606 int h = e->size().height(); 606 int h = e->size().height();
607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 607 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 608 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
609 uc = true; 609 uc = true;
610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 610 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
611 } 611 }
612 mUpcomingWidth = e->size().width() ; 612 mUpcomingWidth = e->size().width() ;
613 if ( mBlockUpdating || uc ) { 613 if ( mBlockUpdating || uc ) {
614 mBlockUpdating = false; 614 mBlockUpdating = false;
615 //mAgenda->setMinimumSize(800 , 600 ); 615 //mAgenda->setMinimumSize(800 , 600 );
616 //qDebug("mAgenda->resize+++++++++++++++ "); 616 //qDebug("mAgenda->resize+++++++++++++++ ");
617 updateConfig(); 617 updateConfig();
618 //qDebug("KOAgendaView::Updating now possible "); 618 //qDebug("KOAgendaView::Updating now possible ");
619 } else 619 } else
620 createDayLabels(); 620 createDayLabels();
621 //qDebug("resizeEvent end "); 621 //qDebug("resizeEvent end ");
622 622
623} 623}
624void KOAgendaView::slotDaylabelClicked( int num ) 624void KOAgendaView::slotDaylabelClicked( int num )
625{ 625{
626 626
627 QDate firstDate = mSelectedDates.first(); 627 QDate firstDate = mSelectedDates.first();
628 if ( num == -1 ) 628 if ( num == -1 )
629 emit showDateView( 6, firstDate ); 629 emit showDateView( 6, firstDate );
630 else if (num >= 0 ) { 630 else if (num >= 0 ) {
631 if ( mSelectedDates.count() == 1) 631 if ( mSelectedDates.count() == 1)
632 emit showDateView( 9, firstDate.addDays( num ) ); 632 emit showDateView( 9, firstDate.addDays( num ) );
633 else 633 else
634 emit showDateView( 3, firstDate.addDays( num ) ); 634 emit showDateView( 3, firstDate.addDays( num ) );
635 } 635 }
636 else 636 else
637 showDateView( 10, firstDate.addDays(1) ); 637 showDateView( 10, firstDate.addDays(1) );
638} 638}
639 639
640KOAgendaButton* KOAgendaView::getNewDaylabel() 640KOAgendaButton* KOAgendaView::getNewDaylabel()
641{ 641{
642 642
643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 643 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 644 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
645 mDayLabelsList.append( dayLabel ); 645 mDayLabelsList.append( dayLabel );
646 mLayoutDayLabels->addWidget(dayLabel); 646 mLayoutDayLabels->addWidget(dayLabel);
647 return dayLabel ; 647 return dayLabel ;
648} 648}
649 649
650void KOAgendaView::createDayLabels() 650void KOAgendaView::createDayLabels()
651{ 651{
652 652
653 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 653 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
654 // qDebug(" KOAgendaView::createDayLabels() blocked "); 654 // qDebug(" KOAgendaView::createDayLabels() blocked ");
655 return; 655 return;
656 656
657 } 657 }
658 int newHight; 658 int newHight;
659 if ( !mSelectedDates.count()) 659 if ( !mSelectedDates.count())
660 return; 660 return;
661 661
662 // ### Before deleting and recreating we could check if mSelectedDates changed... 662 // ### Before deleting and recreating we could check if mSelectedDates changed...
663 // It would remove some flickering and gain speed (since this is called by 663 // It would remove some flickering and gain speed (since this is called by
664 // each updateView() call) 664 // each updateView() call)
665 665
666 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 666 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
667 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 667 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
668 if ( maxWid < 20 ) 668 if ( maxWid < 20 )
669 maxWid = 20; 669 maxWid = 20;
670 670
671 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 671 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
672 QFontMetrics fm ( dlf ); 672 QFontMetrics fm ( dlf );
673 int selCount = mSelectedDates.count(); 673 int selCount = mSelectedDates.count();
674 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 674 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
675 QString dayTest = "Mon 20"; 675 QString dayTest = "Mon 20";
676 //QString dayTest = "Mon 20"; 676 //QString dayTest = "Mon 20";
677 int wid = fm.width( dayTest ); 677 int wid = fm.width( dayTest );
678 //maxWid -= ( selCount * 3 ); //working for QLabels 678 //maxWid -= ( selCount * 3 ); //working for QLabels
679 if ( QApplication::desktop()->width() <= 320 ) 679 if ( QApplication::desktop()->width() <= 320 )
680 maxWid -= ( selCount * 3 ); //working for QPushButton 680 maxWid -= ( selCount * 3 ); //working for QPushButton
681 else 681 else
682 maxWid -= ( selCount * 3 ); //working for QPushButton 682 maxWid -= ( selCount * 3 ); //working for QPushButton
683 if ( maxWid < 0 ) 683 if ( maxWid < 0 )
684 maxWid = 20; 684 maxWid = 20;
685 int needWid = wid * selCount; 685 int needWid = wid * selCount;
686 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 686 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
687 //if ( needWid > maxWid ) 687 //if ( needWid > maxWid )
688 // qDebug("DAYLABELS TOOOOOOO BIG "); 688 // qDebug("DAYLABELS TOOOOOOO BIG ");
689 while ( needWid > maxWid ) { 689 while ( needWid > maxWid ) {
690 dayTest = dayTest.left( dayTest.length() - 1 ); 690 dayTest = dayTest.left( dayTest.length() - 1 );
691 wid = fm.width( dayTest ); 691 wid = fm.width( dayTest );
692 needWid = wid * selCount; 692 needWid = wid * selCount;
693 } 693 }
694 int maxLen = dayTest.length(); 694 int maxLen = dayTest.length();
695 int fontPoint = dlf.pointSize(); 695 int fontPoint = dlf.pointSize();
696 if ( maxLen < 2 ) { 696 if ( maxLen < 2 ) {
697 int fontPoint = dlf.pointSize(); 697 int fontPoint = dlf.pointSize();
698 while ( fontPoint > 4 ) { 698 while ( fontPoint > 4 ) {
699 --fontPoint; 699 --fontPoint;
700 dlf.setPointSize( fontPoint ); 700 dlf.setPointSize( fontPoint );
701 QFontMetrics f( dlf ); 701 QFontMetrics f( dlf );
702 wid = f.width( "30" ); 702 wid = f.width( "30" );
703 needWid = wid * selCount; 703 needWid = wid * selCount;
704 if ( needWid < maxWid ) 704 if ( needWid < maxWid )
705 break; 705 break;
706 } 706 }
707 maxLen = 2; 707 maxLen = 2;
708 } 708 }
709 //qDebug("Max len %d ", dayTest.length() ); 709 //qDebug("Max len %d ", dayTest.length() );
710 710
711 QFontMetrics tempF( dlf ); 711 QFontMetrics tempF( dlf );
712 newHight = tempF.height(); 712 newHight = tempF.height();
713 mDayLabels->setFont( dlf ); 713 mDayLabels->setFont( dlf );
714 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 714 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
715 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 715 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
716 //mLayoutDayLabels->addSpacing( 2 ); 716 //mLayoutDayLabels->addSpacing( 2 );
717 // QFont lFont = dlf; 717 // QFont lFont = dlf;
718 bool appendLabels = false; 718 bool appendLabels = false;
719 KOAgendaButton *dayLabel; 719 KOAgendaButton *dayLabel;
720 dayLabel = mDayLabelsList.first(); 720 dayLabel = mDayLabelsList.first();
721 if ( !dayLabel ) { 721 if ( !dayLabel ) {
722 appendLabels = true; 722 appendLabels = true;
723 dayLabel = getNewDaylabel(); 723 dayLabel = getNewDaylabel();
724 } 724 }
725 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 725 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
726 dayLabel->setFont( dlf ); 726 dayLabel->setFont( dlf );
727 dayLabel->setNum( -1 ); 727 dayLabel->setNum( -1 );
728 //dayLabel->setAlignment(QLabel::AlignHCenter); 728 //dayLabel->setAlignment(QLabel::AlignHCenter);
729 729
730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 730 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
731 dayLabel->show(); 731 dayLabel->show();
732 DateList::ConstIterator dit; 732 DateList::ConstIterator dit;
733 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 733 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
734 int counter = -1; 734 int counter = -1;
735 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 735 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
736 ++counter; 736 ++counter;
737 QDate date = *dit; 737 QDate date = *dit;
738 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 738 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
739 if ( ! appendLabels ) { 739 if ( ! appendLabels ) {
740 dayLabel = mDayLabelsList.next(); 740 dayLabel = mDayLabelsList.next();
741 if ( !dayLabel ) 741 if ( !dayLabel )
742 appendLabels = true; 742 appendLabels = true;
743 } 743 }
744 if ( appendLabels ) { 744 if ( appendLabels ) {
745 dayLabel = getNewDaylabel(); 745 dayLabel = getNewDaylabel();
746 } 746 }
747 dayLabel->setMinimumWidth( 1 ); 747 dayLabel->setMinimumWidth( 1 );
748 dayLabel->setMaximumWidth( 10240 ); 748 dayLabel->setMaximumWidth( 10240 );
749 dayLabel->setFont( dlf ); 749 dayLabel->setFont( dlf );
750 dayLabel->show(); 750 dayLabel->show();
751 dayLabel->setAutoRepeat( false ); 751 dayLabel->setAutoRepeat( false );
752 dayLabel->setNum( counter ); 752 dayLabel->setNum( counter );
753 QString str; 753 QString str;
754 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 754 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
755 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 755 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
756 switch ( maxLen ) { 756 switch ( maxLen ) {
757 case 2: 757 case 2:
758 str = QString::number( date.day() ); 758 str = QString::number( date.day() );
759 break; 759 break;
760 760
761 case 3: 761 case 3:
762 str = dayName.left( 1 ) +QString::number( date.day()); 762 str = dayName.left( 1 ) +QString::number( date.day());
763 763
764 break; 764 break;
765 case 4: 765 case 4:
766 str = dayName.left( 1 ) + " " +QString::number( date.day()); 766 str = dayName.left( 1 ) + " " +QString::number( date.day());
767 767
768 break; 768 break;
769 case 5: 769 case 5:
770 str = dayName.left( 2 ) + " " +QString::number( date.day()); 770 str = dayName.left( 2 ) + " " +QString::number( date.day());
771 771
772 break; 772 break;
773 case 6: 773 case 6:
774 str = dayName.left( 3 ) + " " +QString::number( date.day()); 774 str = dayName.left( 3 ) + " " +QString::number( date.day());
775 break; 775 break;
776 776
777 default: 777 default:
778 break; 778 break;
779 } 779 }
780 if ( oneday ) { 780 if ( oneday ) {
781 QString addString; 781 QString addString;
782 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 782 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
783 addString = i18n("Today"); 783 addString = i18n("Today");
784 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 784 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
785 addString = i18n("Tomorrow"); 785 addString = i18n("Tomorrow");
786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
787 addString = i18n("Yesterday"); 787 addString = i18n("Yesterday");
788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
789 addString = i18n("Day before yesterday"); 789 addString = i18n("Day before yesterday");
790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
791 addString = i18n("Day after tomorrow"); 791 addString = i18n("Day after tomorrow");
792 if ( !addString.isEmpty() ) { 792 if ( !addString.isEmpty() ) {
793 str = addString+", " + str; 793 str = addString+", " + str;
794 } else { 794 } else {
795 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 795 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
796 } 796 }
797 } 797 }
798 dayLabel->setText(str); 798 dayLabel->setText(str);
799 //dayLabel->setAlignment(QLabel::AlignHCenter); 799 //dayLabel->setAlignment(QLabel::AlignHCenter);
800 if (date == QDate::currentDate()) { 800 if (date == QDate::currentDate()) {
801 QFont bFont = dlf; 801 QFont bFont = dlf;
802 bFont.setBold( true ); 802 bFont.setBold( true );
803 dayLabel->setFont(bFont); 803 dayLabel->setFont(bFont);
804 } 804 }
805 //dayLayout->addWidget(dayLabel); 805 //dayLayout->addWidget(dayLabel);
806 806
807#ifndef KORG_NOPLUGINS 807#ifndef KORG_NOPLUGINS
808 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 808 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
809 CalendarDecoration *it; 809 CalendarDecoration *it;
810 for(it = cds.first(); it; it = cds.next()) { 810 for(it = cds.first(); it; it = cds.next()) {
811 QString text = it->shortText( date ); 811 QString text = it->shortText( date );
812 if ( !text.isEmpty() ) { 812 if ( !text.isEmpty() ) {
813 QLabel *label = new QLabel(text,mDayLabels); 813 QLabel *label = new QLabel(text,mDayLabels);
814 label->setAlignment(AlignCenter); 814 label->setAlignment(AlignCenter);
815 dayLayout->addWidget(label); 815 dayLayout->addWidget(label);
816 } 816 }
817 } 817 }
818 818
819 for(it = cds.first(); it; it = cds.next()) { 819 for(it = cds.first(); it; it = cds.next()) {
820 QWidget *wid = it->smallWidget(mDayLabels,date); 820 QWidget *wid = it->smallWidget(mDayLabels,date);
821 if ( wid ) { 821 if ( wid ) {
822 // wid->setHeight(20); 822 // wid->setHeight(20);
823 dayLayout->addWidget(wid); 823 dayLayout->addWidget(wid);
824 } 824 }
825 } 825 }
826#endif 826#endif
827 } 827 }
828 if ( ! appendLabels ) { 828 if ( ! appendLabels ) {
829 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
830 if ( !dayLabel ) 830 if ( !dayLabel )
831 appendLabels = true; 831 appendLabels = true;
832 } 832 }
833 if ( appendLabels ) { 833 if ( appendLabels ) {
834 dayLabel = getNewDaylabel(); 834 dayLabel = getNewDaylabel();
835 } 835 }
836 //dayLabel->hide();//test only 836 //dayLabel->hide();//test only
837 837
838 dayLabel->setText(">"); 838 dayLabel->setText(">");
839 dayLabel->setFont( dlf ); 839 dayLabel->setFont( dlf );
840 dayLabel->setAutoRepeat( true ); 840 dayLabel->setAutoRepeat( true );
841 dayLabel->show(); 841 dayLabel->show();
842 dayLabel->setNum( -2 ); 842 dayLabel->setNum( -2 );
843 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 843 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
844 844
845 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 845 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
846 if ( !appendLabels ) { 846 if ( !appendLabels ) {
847 dayLabel = mDayLabelsList.next(); 847 dayLabel = mDayLabelsList.next();
848 while ( dayLabel ) { 848 while ( dayLabel ) {
849 //qDebug("!dayLabel %d",dayLabel ); 849 //qDebug("!dayLabel %d",dayLabel );
850 dayLabel->hide(); 850 dayLabel->hide();
851 dayLabel = mDayLabelsList.next(); 851 dayLabel = mDayLabelsList.next();
852 } 852 }
853 } 853 }
854 854
855 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 855 mDayLabelsFrame->setFixedHeight( newHight + 4 );
856} 856}
857 857
858int KOAgendaView::maxDatesHint() 858int KOAgendaView::maxDatesHint()
859{ 859{
860 // Not sure about the max number of events, so return 0 for now. 860 // Not sure about the max number of events, so return 0 for now.
861 return 0; 861 return 0;
862} 862}
863 863
864int KOAgendaView::currentDateCount() 864int KOAgendaView::currentDateCount()
865{ 865{
866 return mSelectedDates.count(); 866 return mSelectedDates.count();
867} 867}
868 868
869QPtrList<Incidence> KOAgendaView::selectedIncidences() 869QPtrList<Incidence> KOAgendaView::selectedIncidences()
870{ 870{
871 QPtrList<Incidence> selected; 871 QPtrList<Incidence> selected;
872 Incidence *incidence; 872 Incidence *incidence;
873 873
874 incidence = mAgenda->selectedIncidence(); 874 incidence = mAgenda->selectedIncidence();
875 if (incidence) selected.append(incidence); 875 if (incidence) selected.append(incidence);
876 876
877 incidence = mAllDayAgenda->selectedIncidence(); 877 incidence = mAllDayAgenda->selectedIncidence();
878 if (incidence) selected.append(incidence); 878 if (incidence) selected.append(incidence);
879 879
880 return selected; 880 return selected;
881} 881}
882 882
883DateList KOAgendaView::selectedDates() 883DateList KOAgendaView::selectedDates()
884{ 884{
885 DateList selected; 885 DateList selected;
886 QDate qd; 886 QDate qd;
887 887
888 qd = mAgenda->selectedIncidenceDate(); 888 qd = mAgenda->selectedIncidenceDate();
889 if (qd.isValid()) selected.append(qd); 889 if (qd.isValid()) selected.append(qd);
890 890
891 qd = mAllDayAgenda->selectedIncidenceDate(); 891 qd = mAllDayAgenda->selectedIncidenceDate();
892 if (qd.isValid()) selected.append(qd); 892 if (qd.isValid()) selected.append(qd);
893 893
894 return selected; 894 return selected;
895} 895}
896 896
897 897
898void KOAgendaView::updateView() 898void KOAgendaView::updateView()
899{ 899{
900 if ( mBlockUpdating ) 900 if ( mBlockUpdating )
901 return; 901 return;
902 // kdDebug() << "KOAgendaView::updateView()" << endl; 902 // kdDebug() << "KOAgendaView::updateView()" << endl;
903 fillAgenda(); 903 fillAgenda();
904 904
905} 905}
906 906
907 907
908/* 908/*
909 Update configuration settings for the agenda view. This method is not 909 Update configuration settings for the agenda view. This method is not
910 complete. 910 complete.
911*/ 911*/
912void KOAgendaView::updateConfig() 912void KOAgendaView::updateConfig()
913{ 913{
914 if ( mBlockUpdating ) 914 if ( mBlockUpdating )
915 return; 915 return;
916 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 916 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
917 int old = KOPrefs::instance()->mHourSize; 917 int old = KOPrefs::instance()->mHourSize;
918 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 918 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
919 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 919 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
920 } 920 }
921 921
922 922
923 // update config for children 923 // update config for children
924 mTimeLabels->updateConfig(); 924 mTimeLabels->updateConfig();
925 mAgenda->storePosition(); 925 mAgenda->storePosition();
926 mAgenda->updateConfig(); 926 mAgenda->updateConfig();
927 mAllDayAgenda->updateConfig(); 927 mAllDayAgenda->updateConfig();
928 // widget synchronization 928 // widget synchronization
929 //TODO: find a better way, maybe signal/slot 929 //TODO: find a better way, maybe signal/slot
930 mTimeLabels->positionChanged(); 930 mTimeLabels->positionChanged();
931 931
932 // for some reason, this needs to be called explicitly 932 // for some reason, this needs to be called explicitly
933 mTimeLabels->repaint(); 933 mTimeLabels->repaint();
934 934
935 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 935 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
936 936
937 // ToolTips displaying summary of events 937 // ToolTips displaying summary of events
938 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 938 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
939 ->mEnableToolTips); 939 ->mEnableToolTips);
940 940
941 //setHolidayMasks(); 941 //setHolidayMasks();
942 942
943 //createDayLabels(); called by via updateView(); 943 //createDayLabels(); called by via updateView();
944 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 944 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
945 updateView(); 945 updateView();
946 mAgenda->restorePosition(); 946 mAgenda->restorePosition();
947} 947}
948 948
949 949
950void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 950void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
951{ 951{
952 952
953 953
954 int xxx = item->cellX(); 954 int xxx = item->cellX();
955 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); 955 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() );
956 if ( mMinY.at(xxx) > item->cellYTop() ) 956 if ( mMinY.at(xxx) > item->cellYTop() )
957 mMinY.at(xxx) = item->cellYTop(); 957 mMinY.at(xxx) = item->cellYTop();
958 if ( mMaxY.at(xxx) < item->cellYBottom() ) 958 if ( mMaxY.at(xxx) < item->cellYBottom() )
959 mMaxY.at(xxx) = item->cellYBottom(); 959 mMaxY.at(xxx) = item->cellYBottom();
960 960
961 QDateTime startDt,endDt; 961 QDateTime startDt,endDt;
962 QDate startDate; 962 QDate startDate;
963 int lenInSecs; 963 int lenInSecs;
964 // if ( type == KOAgenda::RESIZETOP ) 964 // if ( type == KOAgenda::RESIZETOP )
965 // qDebug("RESIZETOP "); 965 // qDebug("RESIZETOP ");
966 // if ( type == KOAgenda::RESIZEBOTTOM ) 966 // if ( type == KOAgenda::RESIZEBOTTOM )
967 // qDebug("RESIZEBOTTOM "); 967 // qDebug("RESIZEBOTTOM ");
968 // if ( type == KOAgenda::MOVE ) 968 // if ( type == KOAgenda::MOVE )
969 // qDebug("MOVE "); 969 // qDebug("MOVE ");
970 if ( item->incidence()->typeID() == eventID ) { 970 if ( item->incidence()->typeID() == eventID ) {
971 startDt =item->incidence()->dtStart(); 971 startDt =item->incidence()->dtStart();
972 endDt = item->incidence()->dtEnd(); 972 endDt = item->incidence()->dtEnd();
973 lenInSecs = startDt.secsTo( endDt ); 973 lenInSecs = startDt.secsTo( endDt );
974 } 974 }
975 975
976 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 976 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
977 977
978 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { 978 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) {
979 startDate = mSelectedDates[item->mLastMoveXPos]; 979 startDate = mSelectedDates[item->mLastMoveXPos];
980 } else { 980 } else {
981 if (item->cellX() < 0) { 981 if (item->cellX() < 0) {
982 startDate = (mSelectedDates.first()).addDays(item->cellX()); 982 startDate = (mSelectedDates.first()).addDays(item->cellX());
983 } else { 983 } else {
984 startDate = mSelectedDates[item->cellX()]; 984 startDate = mSelectedDates[item->cellX()];
985 } 985 }
986 } 986 }
987 startDt.setDate(startDate); 987 startDt.setDate(startDate);
988 988
989 if (item->incidence()->doesFloat()) { 989 if (item->incidence()->doesFloat()) {
990 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 990 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
991 } else { 991 } else {
992 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 992 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
993 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 993 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
994 if ( item->incidence()->typeID() == eventID ) { 994 if ( item->incidence()->typeID() == eventID ) {
995 if ( type == KOAgenda::MOVE ) { 995 if ( type == KOAgenda::MOVE ) {
996 endDt = startDt.addSecs(lenInSecs); 996 endDt = startDt.addSecs(lenInSecs);
997 997
998 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 998 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
999 if (item->lastMultiItem()) { 999 if (item->lastMultiItem()) {
1000 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1000 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1001 endDt.setDate(startDate. 1001 endDt.setDate(startDate.
1002 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1002 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1003 } else { 1003 } else {
1004 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1004 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1005 endDt.setDate(startDate); 1005 endDt.setDate(startDate);
1006 } 1006 }
1007 } 1007 }
1008 } else { 1008 } else {
1009 // todo 1009 // todo
1010 if (item->lastMultiItem()) { 1010 if (item->lastMultiItem()) {
1011 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1011 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1012 endDt.setDate(startDate. 1012 endDt.setDate(startDate.
1013 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1013 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1014 } else { 1014 } else {
1015 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1015 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1016 if ( item->cellYBottom() > 0 ) 1016 if ( item->cellYBottom() > 0 )
1017 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1017 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1018 else 1018 else
1019 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1019 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1020 endDt.setDate(startDate); 1020 endDt.setDate(startDate);
1021 } 1021 }
1022 } 1022 }
1023 } 1023 }
1024 if ( item->incidence()->typeID() == eventID ) { 1024 if ( item->incidence()->typeID() == eventID ) {
1025 item->incidence()->setDtStart(startDt); 1025 item->incidence()->setDtStart(startDt);
1026 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1026 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1027 } else if ( item->incidence()->typeID() == todoID ) { 1027 } else if ( item->incidence()->typeID() == todoID ) {
1028 Todo* to = static_cast<Todo*>(item->incidence()); 1028 Todo* to = static_cast<Todo*>(item->incidence());
1029 1029
1030 to->setDtDue(endDt); 1030 to->setDtDue(endDt);
1031 if ( to->hasStartDate() ) { 1031 if ( to->hasStartDate() ) {
1032 if (to->dtStart() >= to->dtDue() ) 1032 if (to->dtStart() >= to->dtDue() )
1033 to->setDtStart(to->dtDue().addDays( -2 )); 1033 to->setDtStart(to->dtDue().addDays( -2 ));
1034 } 1034 }
1035 1035
1036 } 1036 }
1037 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1037 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1038 item->incidence()->setRevision(item->incidence()->revision()+1); 1038 item->incidence()->setRevision(item->incidence()->revision()+1);
1039 item->setItemDate(startDt.date()); 1039 item->setItemDate(startDt.date());
1040 //item->updateItem(); 1040 //item->updateItem();
1041 if ( item->incidence()->typeID() == todoID ) { 1041 if ( item->incidence()->typeID() == todoID ) {
1042 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1042 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1043 1043
1044 } 1044 }
1045 else 1045 else
1046 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1046 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1047 item->updateItem(); 1047 item->updateItem();
1048} 1048}
1049 1049
1050void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1050void KOAgendaView::showDates( const QDate &start, const QDate &end )
1051{ 1051{
1052 // kdDebug() << "KOAgendaView::selectDates" << endl; 1052 // kdDebug() << "KOAgendaView::selectDates" << endl;
1053 1053
1054 mSelectedDates.clear(); 1054 mSelectedDates.clear();
1055 // qDebug("KOAgendaView::showDates "); 1055 // qDebug("KOAgendaView::showDates ");
1056 QDate d = start; 1056 QDate d = start;
1057 while (d <= end) { 1057 while (d <= end) {
1058 mSelectedDates.append(d); 1058 mSelectedDates.append(d);
1059 d = d.addDays( 1 ); 1059 d = d.addDays( 1 );
1060 } 1060 }
1061 1061
1062 // and update the view 1062 // and update the view
1063 fillAgenda(); 1063 fillAgenda();
1064} 1064}
1065 1065
1066 1066
1067void KOAgendaView::showEvents(QPtrList<Event>) 1067void KOAgendaView::showEvents(QPtrList<Event>)
1068{ 1068{
1069 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1069 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1070} 1070}
1071 1071
1072void KOAgendaView::changeEventDisplay(Event *, int) 1072void KOAgendaView::changeEventDisplay(Event *, int)
1073{ 1073{
1074 // qDebug("KOAgendaView::changeEventDisplay "); 1074 // qDebug("KOAgendaView::changeEventDisplay ");
1075 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1075 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1076 // this should be re-written to be MUCH smarter. Right now we 1076 // this should be re-written to be MUCH smarter. Right now we
1077 // are just playing dumb. 1077 // are just playing dumb.
1078 fillAgenda(); 1078 fillAgenda();
1079} 1079}
1080 1080
1081void KOAgendaView::fillAgenda(const QDate &) 1081void KOAgendaView::fillAgenda(const QDate &)
1082{ 1082{
1083 // qDebug("KOAgendaView::fillAgenda "); 1083 // qDebug("KOAgendaView::fillAgenda ");
1084 fillAgenda(); 1084 fillAgenda();
1085} 1085}
1086 1086
1087void KOAgendaView::fillAgenda() 1087void KOAgendaView::fillAgenda()
1088{ 1088{
1089 if ( globalFlagBlockStartup ) 1089 if ( globalFlagBlockStartup )
1090 return; 1090 return;
1091 if ( globalFlagBlockAgenda == 1 ) 1091 if ( globalFlagBlockAgenda == 1 )
1092 return; 1092 return;
1093 static bool onlyOne = false; 1093 static bool onlyOne = false;
1094 if ( onlyOne ) 1094 if ( onlyOne )
1095 return; 1095 return;
1096 onlyOne = true; 1096 onlyOne = true;
1097 //if ( globalFlagBlockAgenda == 2 ) 1097 //if ( globalFlagBlockAgenda == 2 )
1098 //globalFlagBlockAgenda = 0; 1098 //globalFlagBlockAgenda = 0;
1099 // globalFlagBlockPainting = false; 1099 // globalFlagBlockPainting = false;
1100 if ( globalFlagBlockAgenda == 0 ) 1100 if ( globalFlagBlockAgenda == 0 )
1101 globalFlagBlockAgenda = 1; 1101 globalFlagBlockAgenda = 1;
1102 // clearView(); 1102 // clearView();
1103 //qDebug("fillAgenda()++++ "); 1103 //qDebug("fillAgenda()++++ ");
1104 globalFlagBlockAgendaItemPaint = 1; 1104 globalFlagBlockAgendaItemPaint = 1;
1105 1105
1106 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1106 mAllDayAgenda->changeColumns(mSelectedDates.count());
1107 mAgenda->changeColumns(mSelectedDates.count()); 1107 mAgenda->changeColumns(mSelectedDates.count());
1108 qApp->processEvents(); 1108 qApp->processEvents();
1109 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1109 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1110 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1110 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1111 setHolidayMasks(); 1111 setHolidayMasks();
1112 1112
1113 //mAgenda->hideUnused(); 1113 //mAgenda->hideUnused();
1114 //mAllDayAgenda->hideUnused(); 1114 //mAllDayAgenda->hideUnused();
1115 1115
1116 // mAgenda->blockNextRepaint( false ); 1116 // mAgenda->blockNextRepaint( false );
1117 // mAgenda->viewport()->repaint(); 1117 // mAgenda->viewport()->repaint();
1118 // mAgenda->blockNextRepaint( true ); 1118 // mAgenda->blockNextRepaint( true );
1119 mMinY.resize(mSelectedDates.count()); 1119 mMinY.resize(mSelectedDates.count());
1120 mMaxY.resize(mSelectedDates.count()); 1120 mMaxY.resize(mSelectedDates.count());
1121 1121
1122 QPtrList<Event> dayEvents; 1122 QPtrList<Event> dayEvents;
1123 1123
1124 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1124 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1125 // Therefore, gtodoset all of them. 1125 // Therefore, gtodoset all of them.
1126 QPtrList<Todo> todos = calendar()->todos(); 1126 QPtrList<Todo> todos = calendar()->todos();
1127 1127
1128 mAgenda->setDateList(mSelectedDates); 1128 mAgenda->setDateList(mSelectedDates);
1129 1129
1130 QDate today = QDate::currentDate(); 1130 QDate today = QDate::currentDate();
1131 1131
1132 DateList::ConstIterator dit; 1132 DateList::ConstIterator dit;
1133 int curCol = 0; 1133 int curCol = 0;
1134 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1134 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1135 QDate currentDate = *dit; 1135 QDate currentDate = *dit;
1136 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1136 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1137 // << endl; 1137 // << endl;
1138 1138
1139 dayEvents = calendar()->events(currentDate,true); 1139 dayEvents = calendar()->events(currentDate,true);
1140 1140
1141 // Default values, which can never be reached 1141 // Default values, which can never be reached
1142 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1142 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1143 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1143 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1144 1144
1145 unsigned int numEvent; 1145 unsigned int numEvent;
1146 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1146 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1147 Event *event = dayEvents.at(numEvent); 1147 Event *event = dayEvents.at(numEvent);
1148 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1148 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1149 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1149 if ( event->uid().left(15) == QString("last-syncEvent-") )
1150 continue; 1150 continue;
1151 // kdDebug() << " Event: " << event->summary() << endl; 1151 // kdDebug() << " Event: " << event->summary() << endl;
1152 1152
1153 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1153 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1154 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1154 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1155 1155
1156 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1156 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1157 1157
1158 if (event->doesFloat()) { 1158 if (event->doesFloat()) {
1159 if (event->recurrence()->doesRecur()) { 1159 if (event->recurrence()->doesRecur()) {
1160 if (event->isMultiDay() ) { 1160 if (event->isMultiDay() ) {
1161 endX = endX - beginX;// endX is now number of days 1161 endX = endX - beginX;// endX is now number of days
1162 if ( event->recursOn( currentDate ) ) { 1162 if ( event->recursOn( currentDate ) ) {
1163 endX += curCol; 1163 endX += curCol;
1164 beginX = curCol; 1164 beginX = curCol;
1165 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1165 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1166 } else { 1166 } else {
1167 //qDebug("days %d %s",endX , currentDate.toString().latin1()); 1167 //qDebug("days %d %s",endX , currentDate.toString().latin1());
1168 QDate dateit = currentDate.addDays( -endX ); 1168 QDate dateit = currentDate.addDays( -endX );
1169 if ( event->recursOn( dateit ) ) { 1169 if ( event->recursOn( dateit ) ) {
1170 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1170 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1171 if ( curCol-endX < 0 ) { 1171 if ( curCol-endX < 0 ) {
1172 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1172 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1173 } 1173 }
1174 } 1174 }
1175 } 1175 }
1176 } else { 1176 } else {
1177 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1177 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1178 } 1178 }
1179 1179
1180 } else { 1180 } else {
1181 if (beginX <= 0 && curCol == 0) { 1181 if (beginX <= 0 && curCol == 0) {
1182 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1182 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1183 } else if (beginX == curCol) { 1183 } else if (beginX == curCol) {
1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1184 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1185 } 1185 }
1186 } 1186 }
1187 } else if (event->isMultiDay()) { 1187 } else if (event->isMultiDay()) {
1188 if ( event->doesRecur () ) { 1188 if ( event->doesRecur () ) {
1189 QDate dateit = currentDate; 1189 QDate dateit = currentDate;
1190 int count = 0; 1190 int count = 0;
1191 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1191 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1192 while (! event->recursOn( dateit ) && count <= max ) { 1192 while (! event->recursOn( dateit ) && count <= max ) {
1193 ++count; 1193 ++count;
1194 dateit = dateit.addDays( -1 ); 1194 dateit = dateit.addDays( -1 );
1195 } 1195 }
1196 bool ok; 1196 bool ok;
1197 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1197 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1198 if ( ok ) 1198 if ( ok )
1199 { 1199 {
1200 int secs = event->dtStart().secsTo( event->dtEnd() ); 1200 int secs = event->dtStart().secsTo( event->dtEnd() );
1201 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1201 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1202 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1202 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1203 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1203 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1204 1204
1205 } 1205 }
1206 } 1206 }
1207 int startY = mAgenda->timeToY(event->dtStart().time()); 1207 int startY = mAgenda->timeToY(event->dtStart().time());
1208 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1208 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1209 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1209 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1210 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1210 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1211 //qDebug("insert!!! "); 1211 //qDebug("insert!!! ");
1212 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1212 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1213 } 1213 }
1214 if (beginX == curCol) { 1214 if (beginX == curCol) {
1215 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1215 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1216 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1216 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1217 } else if (endX == curCol) { 1217 } else if (endX == curCol) {
1218 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1218 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1219 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1219 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1220 } else { 1220 } else {
1221 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1221 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1222 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1222 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1223 } 1223 }
1224 } else { 1224 } else {
1225 int startY = mAgenda->timeToY(event->dtStart().time()); 1225 int startY = mAgenda->timeToY(event->dtStart().time());
1226 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1226 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1227 if (endY < startY) endY = startY; 1227 if (endY < startY) endY = startY;
1228 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1228 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1229 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1229 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1230 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1230 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1231 } 1231 }
1232 } 1232 }
1233 // ---------- [display Todos -------------- 1233 // ---------- [display Todos --------------
1234 unsigned int numTodo; 1234 unsigned int numTodo;
1235 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1235 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1236 Todo *todo = todos.at(numTodo); 1236 Todo *todo = todos.at(numTodo);
1237 1237
1238 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1238 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1239 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1239 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1240 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1240 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1241 // Already completed items can be displayed on their original due date 1241 // Already completed items can be displayed on their original due date
1242 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1242 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1243 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1243 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1244 bool fillIn = false; 1244 bool fillIn = false;
1245 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1245 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1246 fillIn = true; 1246 fillIn = true;
1247 if ( ! fillIn && !todo->hasCompletedDate() ) 1247 if ( ! fillIn && !todo->hasCompletedDate() )
1248 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1248 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1249 if ( fillIn ) { 1249 if ( fillIn ) {
1250 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1250 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1251 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1251 if ( KOPrefs::instance()->mShowTodoInAgenda )
1252 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1252 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1253 } 1253 }
1254 else { 1254 else {
1255 QDateTime dt; 1255 QDateTime dt;
1256 if ( todo->hasCompletedDate() ) 1256 if ( todo->hasCompletedDate() )
1257 dt = todo->completed(); 1257 dt = todo->completed();
1258 else 1258 else
1259 dt = todo->dtDue();; 1259 dt = todo->dtDue();;
1260 1260
1261 1261
1262 int endY = mAgenda->timeToY(dt.time()) - 1; 1262 int endY = mAgenda->timeToY(dt.time()) - 1;
1263 int hi = (18/KOPrefs::instance()->mHourSize); 1263 int hi = (18/KOPrefs::instance()->mHourSize);
1264 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1264 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1265 int startY = endY -hi; 1265 int startY = endY -hi;
1266 1266
1267 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1267 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1268 1268
1269 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1269 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1270 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1270 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1271 } 1271 }
1272 } 1272 }
1273 } 1273 }
1274 // ---------- display Todos] -------------- 1274 // ---------- display Todos] --------------
1275 1275
1276 ++curCol; 1276 ++curCol;
1277 } 1277 }
1278 mAgenda->hideUnused(); 1278 mAgenda->hideUnused();
1279 mAllDayAgenda->hideUnused(); 1279 mAllDayAgenda->hideUnused();
1280 mAgenda->checkScrollBoundaries(); 1280 mAgenda->checkScrollBoundaries();
1281 1281
1282 deleteSelectedDateTime(); 1282 deleteSelectedDateTime();
1283 1283
1284 createDayLabels(); 1284 createDayLabels();
1285 emit incidenceSelected( 0 ); 1285 emit incidenceSelected( 0 );
1286 1286
1287 if ( globalFlagBlockAgenda == 2 ) { 1287 if ( globalFlagBlockAgenda == 2 ) {
1288 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1288 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1289 setStartHour( KOPrefs::instance()->mDayBegins ); 1289 setStartHour( KOPrefs::instance()->mDayBegins );
1290 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1290 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1291 setStartHour( QTime::currentTime ().hour() ); 1291 setStartHour( QTime::currentTime ().hour() );
1292 // qApp->processEvents(); 1292 // qApp->processEvents();
1293 } 1293 }
1294 qApp->processEvents(); 1294 qApp->processEvents();
1295 //qDebug("qApp->processEvents(); END "); 1295 //qDebug("qApp->processEvents(); END ");
1296 globalFlagBlockAgenda = 0; 1296 globalFlagBlockAgenda = 0;
1297 1297
1298 // mAgenda->hideUnused(); 1298 // mAgenda->hideUnused();
1299 //mAllDayAgenda->hideUnused(); 1299 //mAllDayAgenda->hideUnused();
1300 mAllDayAgenda->drawContentsToPainter(); 1300 mAllDayAgenda->drawContentsToPainter();
1301 mAgenda->drawContentsToPainter(); 1301 mAgenda->drawContentsToPainter();
1302 repaintAgenda(); 1302 repaintAgenda();
1303 onlyOne = false; 1303 onlyOne = false;
1304 // mAgenda->finishUpdate(); 1304 // mAgenda->finishUpdate();
1305 //mAllDayAgenda->finishUpdate(); 1305 //mAllDayAgenda->finishUpdate();
1306 1306
1307 // repaintAgenda(); 1307 // repaintAgenda();
1308 //qApp->processEvents(); 1308 //qApp->processEvents();
1309 // globalFlagBlockAgenda = 0; 1309 // globalFlagBlockAgenda = 0;
1310} 1310}
1311void KOAgendaView::repaintAgenda() 1311void KOAgendaView::repaintAgenda()
1312{ 1312{
1313 // mAllDayAgenda->drawContentsToPainter(); 1313 // mAllDayAgenda->drawContentsToPainter();
1314// mAllDayAgenda->viewport()->repaint( false ); 1314// mAllDayAgenda->viewport()->repaint( false );
1315// mAgenda->drawContentsToPainter(); 1315// mAgenda->drawContentsToPainter();
1316// mAgenda->viewport()->repaint( false ); 1316// mAgenda->viewport()->repaint( false );
1317// qApp->processEvents(); 1317// qApp->processEvents();
1318 1318
1319 //qDebug("KOAgendaView::repaintAgenda() "); 1319 //qDebug("KOAgendaView::repaintAgenda() ");
1320 //qApp->processEvents(); 1320 //qApp->processEvents();
1321 mAgenda->viewport()->repaint( false ); 1321 mAgenda->viewport()->repaint( false );
1322 mAllDayAgenda->viewport()->repaint( false ); 1322 mAllDayAgenda->viewport()->repaint( false );
1323 mAgenda->finishUpdate(); 1323 mAgenda->finishUpdate();
1324 mAllDayAgenda->finishUpdate(); 1324 mAllDayAgenda->finishUpdate();
1325} 1325}
1326 1326
1327 1327
1328void KOAgendaView::clearView() 1328void KOAgendaView::clearView()
1329{ 1329{
1330 // kdDebug() << "ClearView" << endl; 1330 // kdDebug() << "ClearView" << endl;
1331 mAllDayAgenda->clear(); 1331 mAllDayAgenda->clear();
1332 mAgenda->clear(); 1332 mAgenda->clear();
1333} 1333}
1334void KOAgendaView::clearList() 1334void KOAgendaView::clearList()
1335{ 1335{
1336 // kdDebug() << "ClearView" << endl; 1336 // kdDebug() << "ClearView" << endl;
1337 clearView(); 1337 clearView();
1338 mAllDayAgenda->hideUnused(); 1338 mAllDayAgenda->hideUnused();
1339 mAgenda->hideUnused(); 1339 mAgenda->hideUnused();
1340} 1340}
1341 1341
1342void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1342void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1343 const QDate &td) 1343 const QDate &td)
1344{ 1344{
1345#ifndef KORG_NOPRINTER 1345#ifndef KORG_NOPRINTER
1346 if (fd == td) 1346 if (fd == td)
1347 calPrinter->preview(CalPrinter::Day, fd, td); 1347 calPrinter->preview(CalPrinter::Day, fd, td);
1348 else 1348 else
1349 calPrinter->preview(CalPrinter::Week, fd, td); 1349 calPrinter->preview(CalPrinter::Week, fd, td);
1350#endif 1350#endif
1351} 1351}
1352 1352
1353// void KOAgendaView::updateMovedTodo() 1353// void KOAgendaView::updateMovedTodo()
1354// { 1354// {
1355// // updateConfig(); 1355// // updateConfig();
1356// // emit updateTodoViews(); 1356// // emit updateTodoViews();
1357// } 1357// }
1358 1358
1359void KOAgendaView::slotShowDateView( int mode , int d ) 1359void KOAgendaView::slotShowDateView( int mode , int d )
1360{ 1360{
1361 if ( d >= mSelectedDates.count() ) { 1361 if ( d >= mSelectedDates.count() ) {
1362 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); 1362 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() );
1363 1363
1364 } else { 1364 } else {
1365 QDate day = mSelectedDates[d]; 1365 QDate day = mSelectedDates[d];
1366 emit showDateView(mode , day ); 1366 emit showDateView(mode , day );
1367 } 1367 }
1368 1368
1369} 1369}
1370void KOAgendaView::newEvent(int gx, int gy) 1370void KOAgendaView::newEvent(int gx, int gy)
1371{ 1371{
1372 if (!mSelectedDates.count()) return; 1372 if (!mSelectedDates.count()) return;
1373 1373
1374 QDate day = mSelectedDates[gx]; 1374 QDate day = mSelectedDates[gx];
1375 1375
1376 QTime time = mAgenda->gyToTime(gy); 1376 QTime time = mAgenda->gyToTime(gy);
1377 QDateTime dt(day,time); 1377 QDateTime dt(day,time);
1378 // if ( dt < QDateTime::currentDateTime () ) 1378 // if ( dt < QDateTime::currentDateTime () )
1379 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1379 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1380 emit newEventSignal(dt); 1380 emit newEventSignal(dt);
1381} 1381}
1382 1382
1383void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1383void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1384{ 1384{
1385 if (!mSelectedDates.count()) return; 1385 if (!mSelectedDates.count()) return;
1386 1386
1387 QDate dayStart = mSelectedDates[gxStart]; 1387 QDate dayStart = mSelectedDates[gxStart];
1388 QDate dayEnd = mSelectedDates[gxEnd]; 1388 QDate dayEnd = mSelectedDates[gxEnd];
1389 1389
1390 QTime timeStart = mAgenda->gyToTime(gyStart); 1390 QTime timeStart = mAgenda->gyToTime(gyStart);
1391 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1391 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1392 1392
1393 QDateTime dtStart(dayStart,timeStart); 1393 QDateTime dtStart(dayStart,timeStart);
1394 QDateTime dtEnd(dayEnd,timeEnd); 1394 QDateTime dtEnd(dayEnd,timeEnd);
1395 1395
1396 emit newEventSignal(dtStart,dtEnd); 1396 emit newEventSignal(dtStart,dtEnd);
1397} 1397}
1398 1398
1399void KOAgendaView::newEventAllDay(int gx, int ) 1399void KOAgendaView::newEventAllDay(int gx, int )
1400{ 1400{
1401 if (!mSelectedDates.count()) return; 1401 if (!mSelectedDates.count()) return;
1402 1402
1403 QDate day = mSelectedDates[gx]; 1403 QDate day = mSelectedDates[gx];
1404 1404
1405 emit newEventSignal(day); 1405 emit newEventSignal(day);
1406} 1406}
1407void KOAgendaView::newTodoAllDay(int gx, int ) 1407void KOAgendaView::newTodoAllDay(int gx, int )
1408{ 1408{
1409 if (!mSelectedDates.count()) return; 1409 if (!mSelectedDates.count()) return;
1410 1410
1411 QDateTime day (mSelectedDates[gx] ); 1411 QDateTime day (mSelectedDates[gx] );
1412 emit newTodoSignal(day, true); 1412 emit newTodoSignal(day, true);
1413} 1413}
1414void KOAgendaView::newTodo(int gx, int gy ) 1414void KOAgendaView::newTodo(int gx, int gy )
1415{ 1415{
1416 if (!mSelectedDates.count()) return; 1416 if (!mSelectedDates.count()) return;
1417 QDate dayStart = mSelectedDates[gx]; 1417 QDate dayStart = mSelectedDates[gx];
1418 QTime timeStart = mAgenda->gyToTime(gy); 1418 QTime timeStart = mAgenda->gyToTime(gy);
1419 QDateTime dt (dayStart,timeStart); 1419 QDateTime dt (dayStart,timeStart);
1420 emit newTodoSignal( dt, false ); 1420 emit newTodoSignal( dt, false );
1421} 1421}
1422 1422
1423void KOAgendaView::updateEventIndicatorTop(int newY) 1423void KOAgendaView::updateEventIndicatorTop(int newY)
1424{ 1424{
1425 uint i; 1425 uint i;
1426 for(i=0;i<mMinY.size();++i) { 1426 for(i=0;i<mMinY.size();++i) {
1427 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1427 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1428 else mEventIndicatorTop->enableColumn(i,false); 1428 else mEventIndicatorTop->enableColumn(i,false);
1429 } 1429 }
1430 1430
1431 mEventIndicatorTop->update(); 1431 mEventIndicatorTop->update();
1432} 1432}
1433 1433
1434void KOAgendaView::updateEventIndicatorBottom(int newY) 1434void KOAgendaView::updateEventIndicatorBottom(int newY)
1435{ 1435{
1436 uint i; 1436 uint i;
1437 for(i=0;i<mMaxY.size();++i) { 1437 for(i=0;i<mMaxY.size();++i) {
1438 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1438 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1439 else mEventIndicatorBottom->enableColumn(i,false); 1439 else mEventIndicatorBottom->enableColumn(i,false);
1440 } 1440 }
1441 1441
1442 mEventIndicatorBottom->update(); 1442 mEventIndicatorBottom->update();
1443} 1443}
1444 1444
1445void KOAgendaView::startDrag(Event *event) 1445void KOAgendaView::startDrag(Event *event)
1446{ 1446{
1447#ifndef KORG_NODND 1447#ifndef KORG_NODND
1448 DndFactory factory( calendar() ); 1448 DndFactory factory( calendar() );
1449 ICalDrag *vd = factory.createDrag(event,this); 1449 ICalDrag *vd = factory.createDrag(event,this);
1450 if (vd->drag()) { 1450 if (vd->drag()) {
1451 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1451 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1452 } 1452 }
1453#endif 1453#endif
1454} 1454}
1455 1455
1456void KOAgendaView::readSettings() 1456void KOAgendaView::readSettings()
1457{ 1457{
1458 readSettings(KOGlobals::config()); 1458 readSettings(KOGlobals::config());
1459} 1459}
1460 1460
1461void KOAgendaView::readSettings(KConfig *config) 1461void KOAgendaView::readSettings(KConfig *config)
1462{ 1462{
1463 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1463 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1464 1464
1465 config->setGroup("Views"); 1465 config->setGroup("Views");
1466 1466
1467 //#ifndef KORG_NOSPLITTER 1467 //#ifndef KORG_NOSPLITTER
1468 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1468 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1469 if (sizes.count() == 2) { 1469 if (sizes.count() == 2) {
1470 if ( sizes[0] < 20 ) { 1470 if ( sizes[0] < 20 ) {
1471 sizes[1] = sizes[1] +20 - sizes[0]; 1471 sizes[1] = sizes[1] +20 - sizes[0];
1472 sizes[0] = 20; 1472 sizes[0] = 20;
1473 } 1473 }
1474 mSplitterAgenda->setSizes(sizes); 1474 mSplitterAgenda->setSizes(sizes);
1475 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1475 // qDebug("read %d %d ",sizes[0],sizes[1] );
1476 } 1476 }
1477 //#endif 1477 //#endif
1478 1478
1479 // updateConfig(); 1479 // updateConfig();
1480} 1480}
1481 1481
1482void KOAgendaView::writeSettings(KConfig *config) 1482void KOAgendaView::writeSettings(KConfig *config)
1483{ 1483{
1484 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1484 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1485 1485
1486 config->setGroup("Views"); 1486 config->setGroup("Views");
1487 1487
1488 //#ifndef KORG_NOSPLITTER 1488 //#ifndef KORG_NOSPLITTER
1489 QValueList<int> list = mSplitterAgenda->sizes(); 1489 QValueList<int> list = mSplitterAgenda->sizes();
1490 config->writeEntry("Separator AgendaView",list); 1490 config->writeEntry("Separator AgendaView",list);
1491 //qDebug("write %d %d ", list[0],list[1] ); 1491 //qDebug("write %d %d ", list[0],list[1] );
1492 //#endif 1492 //#endif
1493} 1493}
1494 1494
1495void KOAgendaView::setHolidayMasks() 1495void KOAgendaView::setHolidayMasks()
1496{ 1496{
1497 mHolidayMask.resize(mSelectedDates.count()); 1497 mHolidayMask.resize(mSelectedDates.count());
1498 1498
1499 uint i; 1499 uint i;
1500 for(i=0;i<mSelectedDates.count();++i) { 1500 for(i=0;i<mSelectedDates.count();++i) {
1501 QDate date = mSelectedDates[i]; 1501 QDate date = mSelectedDates[i];
1502 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1502 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1503 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1503 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1504 bool showHoliday = false; 1504 bool showHoliday = false;
1505 if ( KOPrefs::instance()->mExcludeHolidays ) { 1505 if ( KOPrefs::instance()->mExcludeHolidays ) {
1506 QPtrList<Event> events = calendar()->events( date, true ); 1506 QPtrList<Event> events = calendar()->events( date, true );
1507 Event *event; 1507 Event *event;
1508 for( event = events.first(); event; event = events.next() ) { 1508 for( event = events.first(); event; event = events.next() ) {
1509 if ( event->isHoliday()) { 1509 if ( event->isHoliday()) {
1510 showHoliday = true; 1510 showHoliday = true;
1511 break; 1511 break;
1512 } 1512 }
1513 } 1513 }
1514 1514
1515 } 1515 }
1516 1516
1517#ifndef KORG_NOPLUGINS 1517#ifndef KORG_NOPLUGINS
1518 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1518 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1519 !KOCore::self()->holiday(date).isEmpty(); 1519 !KOCore::self()->holiday(date).isEmpty();
1520#endif 1520#endif
1521 bool showDay = showSaturday || showSunday || showHoliday; 1521 bool showDay = showSaturday || showSunday || showHoliday;
1522 1522
1523 if (showDay) { 1523 if (showDay) {
1524 mHolidayMask.at(i) = true; 1524 mHolidayMask.at(i) = true;
1525 } else { 1525 } else {
1526 mHolidayMask.at(i) = false; 1526 mHolidayMask.at(i) = false;
1527 } 1527 }
1528 } 1528 }
1529 1529
1530 mAgenda->setHolidayMask(&mHolidayMask); 1530 mAgenda->setHolidayMask(&mHolidayMask);
1531 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1531 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1532} 1532}
1533 1533
1534void KOAgendaView::setContentsPos(int y) 1534void KOAgendaView::setContentsPos(int y)
1535{ 1535{
1536 mAgenda->setContentsPos(0,y); 1536 mAgenda->setContentsPos(0,y);
1537} 1537}
1538 1538
1539void KOAgendaView::clearSelection() 1539void KOAgendaView::clearSelection()
1540{ 1540{
1541 mAgenda->deselectItem(); 1541 mAgenda->deselectItem();
1542 mAllDayAgenda->deselectItem(); 1542 mAllDayAgenda->deselectItem();
1543} 1543}
1544 1544
1545void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1545void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1546 int gxEnd, int gyEnd) 1546 int gxEnd, int gyEnd)
1547{ 1547{
1548 mTimeSpanInAllDay = true; 1548 mTimeSpanInAllDay = true;
1549 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1549 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1550} 1550}
1551 1551
1552 1552
1553 1553
1554 1554
1555void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1555void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1556 int gxEnd, int gyEnd) 1556 int gxEnd, int gyEnd)
1557{ 1557{
1558 if (!mSelectedDates.count()) return; 1558 if (!mSelectedDates.count()) return;
1559 1559
1560 QDate dayStart = mSelectedDates[gxStart]; 1560 QDate dayStart = mSelectedDates[gxStart];
1561 QDate dayEnd = mSelectedDates[gxEnd]; 1561 QDate dayEnd = mSelectedDates[gxEnd];
1562 1562
1563 QTime timeStart = mAgenda->gyToTime(gyStart); 1563 QTime timeStart = mAgenda->gyToTime(gyStart);
1564 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1564 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1565 1565
1566 QDateTime dtStart(dayStart,timeStart); 1566 QDateTime dtStart(dayStart,timeStart);
1567 QDateTime dtEnd(dayEnd,timeEnd); 1567 QDateTime dtEnd(dayEnd,timeEnd);
1568 1568
1569 mTimeSpanBegin = dtStart; 1569 mTimeSpanBegin = dtStart;
1570 mTimeSpanEnd = dtEnd; 1570 mTimeSpanEnd = dtEnd;
1571 1571
1572} 1572}
1573 1573
1574void KOAgendaView::deleteSelectedDateTime() 1574void KOAgendaView::deleteSelectedDateTime()
1575{ 1575{
1576 mTimeSpanBegin.setDate(QDate()); 1576 mTimeSpanBegin.setDate(QDate());
1577 mTimeSpanEnd.setDate(QDate()); 1577 mTimeSpanEnd.setDate(QDate());
1578 mTimeSpanInAllDay = false; 1578 mTimeSpanInAllDay = false;
1579} 1579}
1580 1580
1581void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1581void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1582{ 1582{
1583 e->ignore(); 1583 e->ignore();
1584} 1584}
1585 1585
1586void KOAgendaView::scrollOneHourUp() 1586void KOAgendaView::scrollOneHourUp()
1587{ 1587{
1588 1588
1589 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1589 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1590} 1590}
1591void KOAgendaView::scrollOneHourDown() 1591void KOAgendaView::scrollOneHourDown()
1592{ 1592{
1593 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1593 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1594} 1594}
1595 1595
1596void KOAgendaView::setStartHour( int h ) 1596void KOAgendaView::setStartHour( int h )
1597{ 1597{
1598 mAgenda->setStartHour( h ); 1598 mAgenda->setStartHour( h );
1599 1599
1600} 1600}
1601void KOAgendaView::setInitStartHour() 1601void KOAgendaView::setInitStartHour()
1602{ 1602{
1603 1603
1604 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1604 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1605 setStartHour( QTime::currentTime ().hour() ); 1605 setStartHour( QTime::currentTime ().hour() );
1606 else 1606 else
1607 setStartHour( KOPrefs::instance()->mDayBegins ); 1607 setStartHour( KOPrefs::instance()->mDayBegins );
1608 1608
1609} 1609}
1610 1610
1611 1611
1612void KOAgendaView::updateTodo( Todo * t, int ) 1612void KOAgendaView::updateTodo( Todo * t, int )
1613{ 1613{
1614 if ( !isVisible() ) 1614 if ( !isVisible() )
1615 return; 1615 return;
1616 bool remove = false; 1616 bool remove = false;
1617 bool removeAD = false; 1617 bool removeAD = false;
1618 QDate da; 1618 QDate da;
1619 if ( t->hasCompletedDate() ) 1619 if ( t->hasCompletedDate() )
1620 da = t->completed().date(); 1620 da = t->completed().date();
1621 else 1621 else
1622 da = t->dtDue().date(); 1622 da = t->dtDue().date();
1623 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1623 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1624 remove = true; 1624 remove = true;
1625 removeAD = true; 1625 removeAD = true;
1626 } 1626 }
1627 else { 1627 else {
1628 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1628 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1629 if ( overdue && 1629 if ( overdue &&
1630 QDate::currentDate() >= mSelectedDates.first() && 1630 QDate::currentDate() >= mSelectedDates.first() &&
1631 QDate::currentDate() <= mSelectedDates.last()) { 1631 QDate::currentDate() <= mSelectedDates.last()) {
1632 removeAD = false; 1632 removeAD = false;
1633 remove = true; 1633 remove = true;
1634 } 1634 }
1635 else { 1635 else {
1636 1636
1637 if ( da < mSelectedDates.first() || 1637 if ( da < mSelectedDates.first() ||
1638 da > mSelectedDates.last() ) { 1638 da > mSelectedDates.last() ) {
1639 remove = true; 1639 remove = true;
1640 removeAD = true; 1640 removeAD = true;
1641 } else { 1641 } else {
1642 remove = t->doesFloat() && !t->hasCompletedDate(); 1642 remove = t->doesFloat() && !t->hasCompletedDate();
1643 removeAD = !remove; 1643 removeAD = !remove;
1644 } 1644 }
1645 } 1645 }
1646 } 1646 }
1647 int days = mSelectedDates.first().daysTo( da ); 1647 int days = mSelectedDates.first().daysTo( da );
1648 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1648 //qDebug("daysto %d %d %d", days, remove,removeAD );
1649 mAgenda->updateTodo( t , days, remove); 1649 mAgenda->updateTodo( t , days, remove);
1650 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1650 if ( KOPrefs::instance()->mShowTodoInAgenda )
1651 mAllDayAgenda->updateTodo( t , days, removeAD); 1651 mAllDayAgenda->updateTodo( t , days, removeAD);
1652 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1652 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1653 1653
1654} 1654}
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 1f3b4c6..c705c73 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1390 +1,1446 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This 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 24
25#include <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qpainter.h> 37#include <qpainter.h>
38#include <qpaintdevicemetrics.h> 38#include <qpaintdevicemetrics.h>
39 39
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43#include <kglobal.h> 43#include <kglobal.h>
44 44
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46#include <libkcal/calendar.h> 46#include <libkcal/calendar.h>
47#include <libkcal/calendarlocal.h> 47#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h> 48#include <libkcal/icalformat.h>
49#include <libkcal/vcalformat.h> 49#include <libkcal/vcalformat.h>
50#include <libkcal/recurrence.h> 50#include <libkcal/recurrence.h>
51#include <libkcal/filestorage.h> 51#include <libkcal/filestorage.h>
52#include <libkdepim/categoryselectdialog.h> 52#include <libkdepim/categoryselectdialog.h>
53#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60#ifndef KORG_NOPRINTER 60#ifndef KORG_NOPRINTER
61#include "calprinter.h" 61#include "calprinter.h"
62#endif 62#endif
63#include "koglobals.h" 63#include "koglobals.h"
64#include "koprefs.h" 64#include "koprefs.h"
65#include "kfiledialog.h" 65#include "kfiledialog.h"
66 66
67#include "kolistview.h" 67#include "kolistview.h"
68#include "koeventviewer.h" 68#include "koeventviewer.h"
69 69
70
71
72
73class KOListViewWhatsThis :public QWhatsThis 70class KOListViewWhatsThis :public QWhatsThis
74{ 71{
75public: 72public:
76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
77 74
78protected: 75protected:
79 virtual QString text( const QPoint& p) 76 virtual QString text( const QPoint& p)
80 { 77 {
81 return _view->getWhatsThisText(p) ; 78 return _view->getWhatsThisText(p) ;
82 } 79 }
83private: 80private:
84 QWidget* _wid; 81 QWidget* _wid;
85 KOListView * _view; 82 KOListView * _view;
86}; 83};
87 84
88 85
89ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
90{ 87{
91 mItem = item; 88 mItem = item;
92 mDate = date; 89 mDate = date;
93} 90}
94 91
95ListItemVisitor::~ListItemVisitor() 92ListItemVisitor::~ListItemVisitor()
96{ 93{
97} 94}
98 95
99bool ListItemVisitor::visit(Event *e) 96bool ListItemVisitor::visit(Event *e)
100{ 97{
101 bool ok = false; 98 bool ok = false;
102 QString start, end; 99 QString start, end;
103 QDate ds, de; 100 QDate ds, de;
104 if ( e->doesRecur() ) { 101 if ( e->doesRecur() ) {
105 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
106 if ( ok ) { 103 if ( ok ) {
107 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 104 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
108 start = KGlobal::locale()->formatDate(ds,true); 105 start = KGlobal::locale()->formatDate(ds,true);
109 de = ds.addDays( days); 106 de = ds.addDays( days);
110 end = KGlobal::locale()->formatDate(de,true); 107 end = KGlobal::locale()->formatDate(de,true);
111 } 108 }
112 109
113 } 110 }
114 if ( ! ok ) { 111 if ( ! ok ) {
115 start =e->dtStartDateStr(); 112 start =e->dtStartDateStr();
116 end = e->dtEndDateStr(); 113 end = e->dtEndDateStr();
117 ds = e->dtStart().date(); 114 ds = e->dtStart().date();
118 de = e->dtEnd().date(); 115 de = e->dtEnd().date();
119 } 116 }
120 mItem->setText(0,e->summary()); 117 mItem->setText(0,e->summary());
121 mItem->setText(1,start); 118 mItem->setText(1,start);
122 if ( e->doesFloat() ) 119 if ( e->doesFloat() )
123 mItem->setText(2,"---"); 120 mItem->setText(2,"---");
124 else 121 else
125 mItem->setText(2,e->dtStartTimeStr()); 122 mItem->setText(2,e->dtStartTimeStr());
126 mItem->setText(3,end); 123 mItem->setText(3,end);
127 if ( e->doesFloat() ) 124 if ( e->doesFloat() )
128 mItem->setText(4,"---"); 125 mItem->setText(4,"---");
129 else 126 else
130 mItem->setText(4,e->dtEndTimeStr()); 127 mItem->setText(4,e->dtEndTimeStr());
131 if ( e->isAlarmEnabled() ) { 128 if ( e->isAlarmEnabled() ) {
132 mItem->setText(5,e->alarms().first()->offsetText() ); 129 mItem->setText(5,e->alarms().first()->offsetText() );
133 } else { 130 } else {
134 mItem->setText(5, i18n("No")); 131 mItem->setText(5, i18n("No"));
135 } 132 }
136 mItem->setText(6, e->recurrence()->recurrenceText()); 133 mItem->setText(6, e->recurrence()->recurrenceText());
137 if( ! e->doesRecur() ) 134 if( ! e->doesRecur() )
138 mItem->setSortKey( 6, "-" ); 135 mItem->setSortKey( 6, "-" );
139 mItem->setText(7,"---"); 136 mItem->setText(7,"---");
140 mItem->setText(8,"---"); 137 mItem->setText(8,"---");
141 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 138 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
142 mItem->setText(10,e->categoriesStr()); 139 mItem->setText(10,e->categoriesStr());
140 mItem->setText(11, KOPrefs::instance()->calName( e->calID() ));
143 141
144 QString key; 142 QString key;
145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 143 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 144 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
147 mItem->setSortKey(1,key); 145 mItem->setSortKey(1,key);
148 146
149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 147 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 148 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
151 mItem->setSortKey(3,key); 149 mItem->setSortKey(3,key);
152 return true; 150 return true;
153} 151}
154 152
155bool ListItemVisitor::visit(Todo *t) 153bool ListItemVisitor::visit(Todo *t)
156{ 154{
157 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 155 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
158 if (t->hasStartDate()) { 156 if (t->hasStartDate()) {
159 mItem->setText(1,t->dtStartDateStr()); 157 mItem->setText(1,t->dtStartDateStr());
160 if (t->doesFloat()) { 158 if (t->doesFloat()) {
161 mItem->setText(2,"---"); 159 mItem->setText(2,"---");
162 } else { 160 } else {
163 mItem->setText(2,t->dtStartTimeStr()); 161 mItem->setText(2,t->dtStartTimeStr());
164 } 162 }
165 } else { 163 } else {
166 mItem->setText(1,"---"); 164 mItem->setText(1,"---");
167 mItem->setText(2,"---"); 165 mItem->setText(2,"---");
168 } 166 }
169 mItem->setText(3,"---"); 167 mItem->setText(3,"---");
170 mItem->setText(4,"---"); 168 mItem->setText(4,"---");
171 if ( t->isAlarmEnabled() ) { 169 if ( t->isAlarmEnabled() ) {
172 mItem->setText(5,t->alarms().first()->offsetText() ); 170 mItem->setText(5,t->alarms().first()->offsetText() );
173 } else { 171 } else {
174 mItem->setText(5, i18n("No")); 172 mItem->setText(5, i18n("No"));
175 } 173 }
176 mItem->setText(6, t->recurrence()->recurrenceText()); 174 mItem->setText(6, t->recurrence()->recurrenceText());
177 if( ! t->doesRecur() ) 175 if( ! t->doesRecur() )
178 mItem->setSortKey( 6, "-" ); 176 mItem->setSortKey( 6, "-" );
179 if (t->hasDueDate()) { 177 if (t->hasDueDate()) {
180 mItem->setText(7,t->dtDueDateStr()); 178 mItem->setText(7,t->dtDueDateStr());
181 if (t->doesFloat()) { 179 if (t->doesFloat()) {
182 mItem->setText(8,"---"); 180 mItem->setText(8,"---");
183 } else { 181 } else {
184 mItem->setText(8,t->dtDueTimeStr()); 182 mItem->setText(8,t->dtDueTimeStr());
185 } 183 }
186 } else { 184 } else {
187 mItem->setText(7,"---"); 185 mItem->setText(7,"---");
188 mItem->setText(8,"---"); 186 mItem->setText(8,"---");
189 } 187 }
190 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 188 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
191 mItem->setText(10,t->categoriesStr()); 189 mItem->setText(10,t->categoriesStr());
190 mItem->setText(11, KOPrefs::instance()->calName( t->calID() ));
192 191
193 QString key; 192 QString key;
194 QDate d; 193 QDate d;
195 if (t->hasDueDate()) { 194 if (t->hasDueDate()) {
196 d = t->dtDue().date(); 195 d = t->dtDue().date();
197 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 196 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
198 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 197 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
199 mItem->setSortKey(7,key); 198 mItem->setSortKey(7,key);
200 } 199 }
201 if ( t->hasStartDate() ) { 200 if ( t->hasStartDate() ) {
202 d = t->dtStart().date(); 201 d = t->dtStart().date();
203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 202 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 203 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
205 mItem->setSortKey(1,key); 204 mItem->setSortKey(1,key);
206 } 205 }
207 return true; 206 return true;
208} 207}
209 208
210bool ListItemVisitor::visit(Journal * j) 209bool ListItemVisitor::visit(Journal * j)
211{ 210{
212 QString des = j->description().left(30); 211 QString des = j->description().left(30);
213 des = des.simplifyWhiteSpace (); 212 des = des.simplifyWhiteSpace ();
214 des.replace (QRegExp ("\\n"),"" ); 213 des.replace (QRegExp ("\\n"),"" );
215 des.replace (QRegExp ("\\r"),"" ); 214 des.replace (QRegExp ("\\r"),"" );
216 mItem->setText(0,i18n("Journal: ")+des.left(25)); 215 mItem->setText(0,i18n("Journal: ")+des.left(25));
217 mItem->setText(1,j->dtStartDateStr()); 216 mItem->setText(1,j->dtStartDateStr());
218 mItem->setText(2,"---"); 217 mItem->setText(2,"---");
219 mItem->setText(3,"---"); 218 mItem->setText(3,"---");
220 mItem->setText(4,"---"); 219 mItem->setText(4,"---");
221 mItem->setText(5,"---"); 220 mItem->setText(5,"---");
222 mItem->setText(6,"---"); 221 mItem->setText(6,"---");
223 mItem->setText(7,j->dtStartDateStr()); 222 mItem->setText(7,j->dtStartDateStr());
224 mItem->setText(8,"---"); 223 mItem->setText(8,"---");
225 mItem->setText(9,"---"); 224 mItem->setText(9,"---");
226 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 225 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
226 mItem->setText(11, KOPrefs::instance()->calName( j->calID() ));
227 227
228 QString key; 228 QString key;
229 QDate d = j->dtStart().date(); 229 QDate d = j->dtStart().date();
230 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 230 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
231 mItem->setSortKey(1,key); 231 mItem->setSortKey(1,key);
232 mItem->setSortKey(7,key); 232 mItem->setSortKey(7,key);
233 233
234 return true; 234 return true;
235} 235}
236 236
237KOListView::KOListView(Calendar *calendar, QWidget *parent, 237KOListView::KOListView(Calendar *calendar, QWidget *parent,
238 const char *name) 238 const char *name)
239 : KOEventView(calendar, parent, name) 239 : KOEventView(calendar, parent, name)
240{ 240{
241 mActiveItem = 0; 241 mActiveItem = 0;
242 mListView = new KOListViewListView(this); 242 mListView = new KOListViewListView(this);
243 mListView->addColumn(i18n("Summary")); 243 mListView->addColumn(i18n("Summary"));
244 mListView->addColumn(i18n("Start Date")); 244 mListView->addColumn(i18n("Start Date"));
245 mListView->addColumn(i18n("Start Time")); 245 mListView->addColumn(i18n("Start Time"));
246 mListView->addColumn(i18n("End Date")); 246 mListView->addColumn(i18n("End Date"));
247 mListView->addColumn(i18n("End Time")); 247 mListView->addColumn(i18n("End Time"));
248 mListView->addColumn(i18n("Alarm")); // alarm set? 248 mListView->addColumn(i18n("Alarm")); // alarm set?
249 mListView->addColumn(i18n("Recurs")); // recurs? 249 mListView->addColumn(i18n("Recurs")); // recurs?
250 mListView->addColumn(i18n("Due Date")); 250 mListView->addColumn(i18n("Due Date"));
251 mListView->addColumn(i18n("Due Time")); 251 mListView->addColumn(i18n("Due Time"));
252 mListView->addColumn(i18n("Cancelled")); 252 mListView->addColumn(i18n("Cancelled"));
253 mListView->addColumn(i18n("Categories")); 253 mListView->addColumn(i18n("Categories"));
254 mListView->addColumn(i18n("Calendar"));
254 255
255 mListView->setColumnAlignment(0,AlignLeft); 256 mListView->setColumnAlignment(0,AlignLeft);
256 mListView->setColumnAlignment(1,AlignLeft); 257 mListView->setColumnAlignment(1,AlignLeft);
257 mListView->setColumnAlignment(2,AlignHCenter); 258 mListView->setColumnAlignment(2,AlignHCenter);
258 mListView->setColumnAlignment(3,AlignLeft); 259 mListView->setColumnAlignment(3,AlignLeft);
259 mListView->setColumnAlignment(4,AlignHCenter); 260 mListView->setColumnAlignment(4,AlignHCenter);
260 mListView->setColumnAlignment(5,AlignLeft); 261 mListView->setColumnAlignment(5,AlignLeft);
261 mListView->setColumnAlignment(6,AlignLeft); 262 mListView->setColumnAlignment(6,AlignLeft);
262 mListView->setColumnAlignment(7,AlignLeft); 263 mListView->setColumnAlignment(7,AlignLeft);
263 mListView->setColumnAlignment(8,AlignLeft); 264 mListView->setColumnAlignment(8,AlignLeft);
264 mListView->setColumnAlignment(9,AlignLeft); 265 mListView->setColumnAlignment(9,AlignLeft);
265 mListView->setColumnAlignment(10,AlignLeft); 266 mListView->setColumnAlignment(10,AlignLeft);
266 mListView->setColumnWidthMode(10, QListView::Manual); 267 mListView->setColumnAlignment(11,AlignLeft);
267 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 268 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
268 269
269 int iii = 0; 270 int iii = 0;
270 for ( iii = 0; iii< 10 ; ++iii ) 271 for ( iii = 0; iii< 12 ; ++iii )
271 mListView->setColumnWidthMode( iii, QListView::Manual ); 272 mListView->setColumnWidthMode( iii, QListView::Manual );
272 273
273 QBoxLayout *layoutTop = new QVBoxLayout(this); 274 QBoxLayout *layoutTop = new QVBoxLayout(this);
274 layoutTop->addWidget(mListView); 275 layoutTop->addWidget(mListView);
275 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 276 mListView->setFont ( KOPrefs::instance()->mListViewFont );
276 mPopupMenu = eventPopup(); 277 mPopupMenu = eventPopup();
277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 278 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
278 i18n("Select all"),this, 279 i18n("Select all"),this,
279 SLOT(allSelection()),true); 280 SLOT(allSelection()),true);
280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 281 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
281 i18n("Deselect all"),this, 282 i18n("Deselect all"),this,
282 SLOT(clearSelection()),true); 283 SLOT(clearSelection()),true);
283 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 284 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
284 i18n("Delete all selected"),this, 285 i18n("Delete all selected"),this,
285 SLOT(deleteAll()),true); 286 SLOT(deleteAll()),true);
286 287
287 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 288 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
288 i18n("Hide all selected"),this, 289 i18n("Hide all selected"),this,
289 SLOT(hideAll()),true); 290 SLOT(hideAll()),true);
290 291
291 mPopupMenu->insertSeparator(); 292 mPopupMenu->insertSeparator();
292#ifdef DESKTOP_VERSION 293#ifdef DESKTOP_VERSION
293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 294 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
294 i18n("Print complete list"),this, 295 i18n("Print complete list"),this,
295 SLOT(printList()),true); 296 SLOT(printList()),true);
296 mPopupMenu->insertSeparator(); 297 mPopupMenu->insertSeparator();
297#endif 298#endif
299 mCalPopup = new QPopupMenu ( this );
300 mPopupMenu->insertItem( i18n("Set Calendar"), mCalPopup );
301
302 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
303 SLOT( populateCalPopup() ));
304 QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
305 SLOT( setCalendar( int ) ));
298 QPopupMenu * exportPO = new QPopupMenu ( this ); 306 QPopupMenu * exportPO = new QPopupMenu ( this );
299 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 307 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
300 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 308 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
301 SLOT(saveToFile())); 309 SLOT(saveToFile()));
302 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 310 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
303 SLOT(saveToFileVCS())); 311 SLOT(saveToFileVCS()));
304 exportPO->insertItem( i18n("Journal/Details..."),this, 312 exportPO->insertItem( i18n("Journal/Details..."),this,
305 SLOT(saveDescriptionToFile())); 313 SLOT(saveDescriptionToFile()));
306 // mPopupMenu->insertSeparator(); 314 // mPopupMenu->insertSeparator();
307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 315 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
308 i18n("Add Categ. to selected..."),this, 316 i18n("Add Categ. to selected..."),this,
309 SLOT(addCat()),true); 317 SLOT(addCat()),true);
310 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 318 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
311 i18n("Set Categ. for selected..."),this, 319 i18n("Set Categ. for selected..."),this,
312 SLOT(setCat()),true); 320 SLOT(setCat()),true);
313 //mPopupMenu->insertSeparator(); 321 //mPopupMenu->insertSeparator();
314 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 322 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
315 i18n("Set alarm for selected..."),this, 323 i18n("Set alarm for selected..."),this,
316 SLOT(setAlarm()),true); 324 SLOT(setAlarm()),true);
317 325
318 326
327
319#ifndef DESKTOP_VERSION 328#ifndef DESKTOP_VERSION
320 mPopupMenu->insertSeparator(); 329 mPopupMenu->insertSeparator();
321 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
322 i18n("Beam selected via IR"),this, 331 i18n("Beam selected via IR"),this,
323 SLOT(beamSelected()),true); 332 SLOT(beamSelected()),true);
324#endif 333#endif
325 /* 334 /*
326 mPopupMenu = new QPopupMenu; 335 mPopupMenu = new QPopupMenu;
327 mPopupMenu->insertItem(i18n("Edit Event"), this, 336 mPopupMenu->insertItem(i18n("Edit Event"), this,
328 SLOT (editEvent())); 337 SLOT (editEvent()));
329 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 338 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
330 SLOT (deleteEvent())); 339 SLOT (deleteEvent()));
331 mPopupMenu->insertSeparator(); 340 mPopupMenu->insertSeparator();
332 mPopupMenu->insertItem(i18n("Show Dates"), this, 341 mPopupMenu->insertItem(i18n("Show Dates"), this,
333 SLOT(showDates())); 342 SLOT(showDates()));
334 mPopupMenu->insertItem(i18n("Hide Dates"), this, 343 mPopupMenu->insertItem(i18n("Hide Dates"), this,
335 SLOT(hideDates())); 344 SLOT(hideDates()));
336 */ 345 */
337 QObject::connect(mListView,SIGNAL( newEvent()), 346 QObject::connect(mListView,SIGNAL( newEvent()),
338 this,SIGNAL(signalNewEvent())); 347 this,SIGNAL(signalNewEvent()));
339 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 348 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
340 this,SLOT(defaultItemAction(QListViewItem *))); 349 this,SLOT(defaultItemAction(QListViewItem *)));
341 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 350 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
342 const QPoint &, int )), 351 const QPoint &, int )),
343 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 352 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
344 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 353 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
345 SLOT(processSelectionChange(QListViewItem *))); 354 SLOT(processSelectionChange(QListViewItem *)));
346 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 355 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
347 SIGNAL(showIncidenceSignal(Incidence *)) ); 356 SIGNAL(showIncidenceSignal(Incidence *)) );
348 357
349 readSettings(KOGlobals::config(),"KOListView Layout"); 358 readSettings(KOGlobals::config(),"KOListView Layout");
350} 359}
351 360
352KOListView::~KOListView() 361KOListView::~KOListView()
353{ 362{
354 delete mPopupMenu; 363 delete mPopupMenu;
355#if QT_VERSION >= 0x030000 364#if QT_VERSION >= 0x030000
356 365
357#else 366#else
358 delete mKOListViewWhatsThis; 367 delete mKOListViewWhatsThis;
359#endif 368#endif
360} 369}
361 370
362QString KOListView::getWhatsThisText(QPoint p) 371QString KOListView::getWhatsThisText(QPoint p)
363{ 372{
364 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 373 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
365 if ( item ) 374 if ( item )
366 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 375 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
367 KOPrefs::instance()->mWTshowDetails, 376 KOPrefs::instance()->mWTshowDetails,
368 KOPrefs::instance()->mWTshowCreated, 377 KOPrefs::instance()->mWTshowCreated,
369 KOPrefs::instance()->mWTshowChanged); 378 KOPrefs::instance()->mWTshowChanged);
370 return i18n("That is the list view" ); 379 return i18n("That is the list view" );
371 380
372} 381}
373 382
383void KOListView::setCalendar( int c )
384{
385 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
386 i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ),
387 i18n("Continue"), i18n("Cancel"), 0,
388 0, 1 );
389 if ( result != 0 ) {
390 return;
391 }
392
393 QPtrList<Incidence> delSel = getSelectedIncidences() ;
394 int icount = delSel.count();
395 if ( icount ) {
396 Incidence *incidence = delSel.first();
397 while ( incidence ) {
398 incidence->setCalID( c );
399 KOListViewItem * item = getItemForEvent( incidence );
400 if ( item ) {
401 ListItemVisitor v(item, mStartDate );
402 incidence->accept(v);
403 }
404 incidence = delSel.next();
405 }
406 }
407 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
408 KopiCalendarFile * cal = calendars.first();
409 while ( cal ) {
410 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
411 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
412 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
413 if ( cal->isStandard )
414 mCalendar->setDefaultCalendar( cal->mCalNumber );
415 cal = calendars.next();
416 }
417 mCalendar->setSyncEventsReadOnly();
418 mCalendar->reInitAlarmSettings();
419
420}
421void KOListView::populateCalPopup()
422{
423 mCalPopup->clear();
424 KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first();
425 while ( kkf ) {
426 mCalPopup->insertItem( kkf->mName, kkf->mCalNumber);
427 kkf = KOPrefs::instance()->mCalendars.next();
428 }
429}
374void KOListView::updateList() 430void KOListView::updateList()
375{ 431{
376 // qDebug(" KOListView::updateList() "); 432 // qDebug(" KOListView::updateList() ");
377 433
378} 434}
379 435
380void KOListView::clearList() 436void KOListView::clearList()
381{ 437{
382 clear (); 438 clear ();
383} 439}
384void KOListView::addCat( ) 440void KOListView::addCat( )
385{ 441{
386 setCategories( false ); 442 setCategories( false );
387} 443}
388void KOListView::setCat() 444void KOListView::setCat()
389{ 445{
390 setCategories( true ); 446 setCategories( true );
391} 447}
392 448
393void KOListView::setAlarm() 449void KOListView::setAlarm()
394{ 450{
395 KOAlarmPrefs kap( this); 451 KOAlarmPrefs kap( this);
396 if ( !kap.exec() ) 452 if ( !kap.exec() )
397 return; 453 return;
398 QStringList itemList; 454 QStringList itemList;
399 QPtrList<KOListViewItem> sel ; 455 QPtrList<KOListViewItem> sel ;
400 QListViewItem *qitem = mListView->firstChild (); 456 QListViewItem *qitem = mListView->firstChild ();
401 while ( qitem ) { 457 while ( qitem ) {
402 if ( qitem->isSelected() ) { 458 if ( qitem->isSelected() ) {
403 Incidence* inc = ((KOListViewItem *) qitem)->data(); 459 Incidence* inc = ((KOListViewItem *) qitem)->data();
404 if ( inc->typeID() != journalID ) { 460 if ( inc->typeID() != journalID ) {
405 if ( inc->typeID() == todoID ) { 461 if ( inc->typeID() == todoID ) {
406 if ( ((Todo*)inc)->hasDueDate() ) 462 if ( ((Todo*)inc)->hasDueDate() )
407 sel.append(((KOListViewItem *)qitem)); 463 sel.append(((KOListViewItem *)qitem));
408 } else 464 } else
409 sel.append(((KOListViewItem *)qitem)); 465 sel.append(((KOListViewItem *)qitem));
410 } 466 }
411 } 467 }
412 qitem = qitem->nextSibling(); 468 qitem = qitem->nextSibling();
413 } 469 }
414 int count = 0; 470 int count = 0;
415 KOListViewItem * item, *temp; 471 KOListViewItem * item, *temp;
416 item = sel.first(); 472 item = sel.first();
417 Incidence* inc; 473 Incidence* inc;
418 while ( item ) { 474 while ( item ) {
419 inc = item->data(); 475 inc = item->data();
420 ++count; 476 ++count;
421 if (kap.mAlarmButton->isChecked()) { 477 if (kap.mAlarmButton->isChecked()) {
422 if (inc->alarms().count() == 0) 478 if (inc->alarms().count() == 0)
423 inc->newAlarm(); 479 inc->newAlarm();
424 QPtrList<Alarm> alarms = inc->alarms(); 480 QPtrList<Alarm> alarms = inc->alarms();
425 Alarm *alarm; 481 Alarm *alarm;
426 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 482 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
427 alarm->setEnabled(true); 483 alarm->setEnabled(true);
428 int j = kap.mAlarmTimeEdit->value()* -60; 484 int j = kap.mAlarmTimeEdit->value()* -60;
429 if (kap.mAlarmIncrCombo->currentItem() == 1) 485 if (kap.mAlarmIncrCombo->currentItem() == 1)
430 j = j * 60; 486 j = j * 60;
431 else if (kap.mAlarmIncrCombo->currentItem() == 2) 487 else if (kap.mAlarmIncrCombo->currentItem() == 2)
432 j = j * (60 * 24); 488 j = j * (60 * 24);
433 alarm->setStartOffset( j ); 489 alarm->setStartOffset( j );
434 490
435 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 491 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
436 alarm->setProcedureAlarm(kap.mAlarmProgram); 492 alarm->setProcedureAlarm(kap.mAlarmProgram);
437 } 493 }
438 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 494 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
439 alarm->setAudioAlarm(kap.mAlarmSound); 495 alarm->setAudioAlarm(kap.mAlarmSound);
440 else 496 else
441 alarm->setType(Alarm::Invalid); 497 alarm->setType(Alarm::Invalid);
442 //alarm->setAudioAlarm("default"); 498 //alarm->setAudioAlarm("default");
443 // TODO: Deal with multiple alarms 499 // TODO: Deal with multiple alarms
444 break; // For now, stop after the first alarm 500 break; // For now, stop after the first alarm
445 } 501 }
446 } else { 502 } else {
447 Alarm* alarm = inc->alarms().first(); 503 Alarm* alarm = inc->alarms().first();
448 if ( alarm ) { 504 if ( alarm ) {
449 alarm->setEnabled(false); 505 alarm->setEnabled(false);
450 alarm->setType(Alarm::Invalid); 506 alarm->setType(Alarm::Invalid);
451 } 507 }
452 } 508 }
453 ListItemVisitor v(item, mStartDate ); 509 ListItemVisitor v(item, mStartDate );
454 inc->accept(v); 510 inc->accept(v);
455 item = sel.next(); 511 item = sel.next();
456 } 512 }
457 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 513 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
458 qDebug("KO: Set alarm for %d items", count); 514 qDebug("KO: Set alarm for %d items", count);
459 calendar()->reInitAlarmSettings(); 515 calendar()->reInitAlarmSettings();
460 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 516 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
461} 517}
462void KOListView::setCategories( bool removeOld ) 518void KOListView::setCategories( bool removeOld )
463{ 519{
464 520
465 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 521 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
466 csd->setColorEnabled(); 522 csd->setColorEnabled();
467 if (! csd->exec()) { 523 if (! csd->exec()) {
468 delete csd; 524 delete csd;
469 return; 525 return;
470 } 526 }
471 QStringList catList = csd->selectedCategories(); 527 QStringList catList = csd->selectedCategories();
472 delete csd; 528 delete csd;
473 // if ( catList.count() == 0 ) 529 // if ( catList.count() == 0 )
474 // return; 530 // return;
475 //catList.sort(); 531 //catList.sort();
476 QString categoriesStr = catList.join(","); 532 QString categoriesStr = catList.join(",");
477 int i; 533 int i;
478 QStringList itemList; 534 QStringList itemList;
479 QPtrList<KOListViewItem> sel ; 535 QPtrList<KOListViewItem> sel ;
480 QListViewItem *qitem = mListView->firstChild (); 536 QListViewItem *qitem = mListView->firstChild ();
481 while ( qitem ) { 537 while ( qitem ) {
482 if ( qitem->isSelected() ) { 538 if ( qitem->isSelected() ) {
483 sel.append(((KOListViewItem *)qitem)); 539 sel.append(((KOListViewItem *)qitem));
484 } 540 }
485 qitem = qitem->nextSibling(); 541 qitem = qitem->nextSibling();
486 } 542 }
487 KOListViewItem * item, *temp; 543 KOListViewItem * item, *temp;
488 item = sel.first(); 544 item = sel.first();
489 if( item ) { 545 if( item ) {
490 Incidence* inc = item->data() ; 546 Incidence* inc = item->data() ;
491 bool setSub = false; 547 bool setSub = false;
492 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { 548 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) {
493 int result = KMessageBox::warningYesNoCancel(this, 549 int result = KMessageBox::warningYesNoCancel(this,
494 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), 550 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
495 i18n("Todo has subtodos"), 551 i18n("Todo has subtodos"),
496 i18n("Yes"), 552 i18n("Yes"),
497 i18n("No")); 553 i18n("No"));
498 if (result == KMessageBox::Cancel) item = 0; 554 if (result == KMessageBox::Cancel) item = 0;
499 if (result == KMessageBox::Yes) setSub = true; 555 if (result == KMessageBox::Yes) setSub = true;
500 } 556 }
501 while ( item ) { 557 while ( item ) {
502 inc = item->data(); 558 inc = item->data();
503 if ( removeOld ) { 559 if ( removeOld ) {
504 inc->setCategories( catList, setSub ); 560 inc->setCategories( catList, setSub );
505 } else { 561 } else {
506 inc->addCategories( catList, setSub ); 562 inc->addCategories( catList, setSub );
507 } 563 }
508 ListItemVisitor v(item, mStartDate ); 564 ListItemVisitor v(item, mStartDate );
509 inc->accept(v); 565 inc->accept(v);
510 item = sel.next(); 566 item = sel.next();
511 } 567 }
512 } 568 }
513 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 569 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
514} 570}
515 571
516void KOListView::beamSelected() 572void KOListView::beamSelected()
517{ 573{
518 QPtrList<Incidence> delSel = getSelectedIncidences() ; 574 QPtrList<Incidence> delSel = getSelectedIncidences() ;
519 int icount = delSel.count(); 575 int icount = delSel.count();
520 if ( icount ) { 576 if ( icount ) {
521 emit beamIncidenceList( delSel ); 577 emit beamIncidenceList( delSel );
522 return; 578 return;
523 QString fn ; 579 QString fn ;
524 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 580 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
525 QString mes; 581 QString mes;
526 bool createbup = true; 582 bool createbup = true;
527 if ( createbup ) { 583 if ( createbup ) {
528 QString description = "\n"; 584 QString description = "\n";
529 CalendarLocal* cal = new CalendarLocal(); 585 CalendarLocal* cal = new CalendarLocal();
530 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 586 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
531 Incidence *incidence = delSel.first(); 587 Incidence *incidence = delSel.first();
532 while ( incidence ) { 588 while ( incidence ) {
533 Incidence *in = incidence->clone(); 589 Incidence *in = incidence->clone();
534 description += in->summary() + "\n"; 590 description += in->summary() + "\n";
535 cal->addIncidence( in ); 591 cal->addIncidence( in );
536 incidence = delSel.next(); 592 incidence = delSel.next();
537 } 593 }
538 FileStorage storage( cal, fn, new VCalFormat ); 594 FileStorage storage( cal, fn, new VCalFormat );
539 storage.save(); 595 storage.save();
540 delete cal; 596 delete cal;
541 mes = i18n("KO/Pi: Ready for beaming"); 597 mes = i18n("KO/Pi: Ready for beaming");
542 topLevelWidget()->setCaption(mes); 598 topLevelWidget()->setCaption(mes);
543 599
544#ifndef DESKTOP_VERSION 600#ifndef DESKTOP_VERSION
545 Ir *ir = new Ir( this ); 601 Ir *ir = new Ir( this );
546 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 602 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
547 ir->send( fn, description, "text/x-vCalendar" ); 603 ir->send( fn, description, "text/x-vCalendar" );
548#endif 604#endif
549 } 605 }
550 } 606 }
551} 607}
552void KOListView::beamDone( Ir *ir ) 608void KOListView::beamDone( Ir *ir )
553{ 609{
554#ifndef DESKTOP_VERSION 610#ifndef DESKTOP_VERSION
555 delete ir; 611 delete ir;
556#endif 612#endif
557 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 613 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
558} 614}
559 615
560void KOListView::saveDescriptionToFile() 616void KOListView::saveDescriptionToFile()
561{ 617{
562 618
563 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 619 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
564 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 620 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
565 i18n("Continue"), i18n("Cancel"), 0, 621 i18n("Continue"), i18n("Cancel"), 0,
566 0, 1 ); 622 0, 1 );
567 if ( result != 0 ) { 623 if ( result != 0 ) {
568 return; 624 return;
569 } 625 }
570 QPtrList<Incidence> delSel = getSelectedIncidences() ; 626 QPtrList<Incidence> delSel = getSelectedIncidences() ;
571 int icount = delSel.count(); 627 int icount = delSel.count();
572 if ( icount ) { 628 if ( icount ) {
573 QString fn = KOPrefs::instance()->mLastSaveFile; 629 QString fn = KOPrefs::instance()->mLastSaveFile;
574 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 630 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
575 631
576 if ( fn == "" ) 632 if ( fn == "" )
577 return; 633 return;
578 QFileInfo info; 634 QFileInfo info;
579 info.setFile( fn ); 635 info.setFile( fn );
580 QString mes; 636 QString mes;
581 bool createbup = true; 637 bool createbup = true;
582 if ( info. exists() ) { 638 if ( info. exists() ) {
583 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 639 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
584 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 640 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
585 i18n("Overwrite!"), i18n("Cancel"), 0, 641 i18n("Overwrite!"), i18n("Cancel"), 0,
586 0, 1 ); 642 0, 1 );
587 if ( result != 0 ) { 643 if ( result != 0 ) {
588 createbup = false; 644 createbup = false;
589 } 645 }
590 } 646 }
591 if ( createbup ) { 647 if ( createbup ) {
592 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 648 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
593 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 649 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
594 Incidence *incidence = delSel.first(); 650 Incidence *incidence = delSel.first();
595 icount = 0; 651 icount = 0;
596 while ( incidence ) { 652 while ( incidence ) {
597 if ( incidence->typeID() == journalID ) { 653 if ( incidence->typeID() == journalID ) {
598 text += "\n************************************\n"; 654 text += "\n************************************\n";
599 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 655 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
600 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 656 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
601 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 657 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
602 ++icount; 658 ++icount;
603 659
604 } else { 660 } else {
605 if ( !incidence->description().isEmpty() ) { 661 if ( !incidence->description().isEmpty() ) {
606 text += "\n************************************\n"; 662 text += "\n************************************\n";
607 if ( incidence->typeID() == todoID ) 663 if ( incidence->typeID() == todoID )
608 text += i18n("To-Do: "); 664 text += i18n("To-Do: ");
609 text += incidence->summary(); 665 text += incidence->summary();
610 if ( incidence->hasStartDate() ) 666 if ( incidence->hasStartDate() )
611 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 667 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
612 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 668 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
613 if ( !incidence->location().isEmpty() ) 669 if ( !incidence->location().isEmpty() )
614 text += "\n" +i18n("Location: ") + incidence->location(); 670 text += "\n" +i18n("Location: ") + incidence->location();
615 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 671 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
616 ++icount; 672 ++icount;
617 673
618 } 674 }
619 } 675 }
620 incidence = delSel.next(); 676 incidence = delSel.next();
621 } 677 }
622 QFile file( fn ); 678 QFile file( fn );
623 if (!file.open( IO_WriteOnly ) ) { 679 if (!file.open( IO_WriteOnly ) ) {
624 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 680 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
625 return; 681 return;
626 } 682 }
627 QTextStream ts( &file ); 683 QTextStream ts( &file );
628 ts << text; 684 ts << text;
629 file.close(); 685 file.close();
630 //qDebug("%s ", text.latin1()); 686 //qDebug("%s ", text.latin1());
631 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 687 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
632 KOPrefs::instance()->mLastSaveFile = fn; 688 KOPrefs::instance()->mLastSaveFile = fn;
633 topLevelWidget()->setCaption(mes); 689 topLevelWidget()->setCaption(mes);
634 } 690 }
635 } 691 }
636} 692}
637void KOListView::saveToFileVCS() 693void KOListView::saveToFileVCS()
638{ 694{
639 writeToFile( false ); 695 writeToFile( false );
640} 696}
641void KOListView::saveToFile() 697void KOListView::saveToFile()
642{ 698{
643 writeToFile( true ); 699 writeToFile( true );
644} 700}
645QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) 701QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos )
646{ 702{
647 QPtrList<Incidence> delSel ; 703 QPtrList<Incidence> delSel ;
648 bool addSubTodos = false; 704 bool addSubTodos = false;
649 bool askSubTodos = true; 705 bool askSubTodos = true;
650 QListViewItem *item = mListView->firstChild (); 706 QListViewItem *item = mListView->firstChild ();
651 while ( item ) { 707 while ( item ) {
652 if ( item->isSelected() ) { 708 if ( item->isSelected() ) {
653 Incidence* inc = ((KOListViewItem *)item)->data(); 709 Incidence* inc = ((KOListViewItem *)item)->data();
654 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { 710 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) {
655 if ( (inc->typeID() == todoID && includeTodos) || 711 if ( (inc->typeID() == todoID && includeTodos) ||
656 (inc->typeID() == eventID && includeEvents) || 712 (inc->typeID() == eventID && includeEvents) ||
657 (inc->typeID() == journalID && includeJournals) ) { 713 (inc->typeID() == journalID && includeJournals) ) {
658 if ( inc->typeID() == todoID && onlyDueTodos ) { 714 if ( inc->typeID() == todoID && onlyDueTodos ) {
659 if ( ((Todo*)inc)->hasDueDate() ) 715 if ( ((Todo*)inc)->hasDueDate() )
660 delSel.append( inc ); 716 delSel.append( inc );
661 } else 717 } else
662 delSel.append( inc ); 718 delSel.append( inc );
663 719
664 } 720 }
665 } 721 }
666 if ( inc->typeID() == todoID ) { 722 if ( inc->typeID() == todoID ) {
667 Todo * todo = (Todo*) inc; 723 Todo * todo = (Todo*) inc;
668 if ( todo->relations().count() ) { 724 if ( todo->relations().count() ) {
669 if ( askSubTodos ) { 725 if ( askSubTodos ) {
670 int result = KMessageBox::warningYesNoCancel(this, 726 int result = KMessageBox::warningYesNoCancel(this,
671 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), 727 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"),
672 i18n("Todo has subtodos"), 728 i18n("Todo has subtodos"),
673 i18n("Yes"), 729 i18n("Yes"),
674 i18n("No")); 730 i18n("No"));
675 if ( result == KMessageBox::Cancel ) { 731 if ( result == KMessageBox::Cancel ) {
676 delSel.clear(); 732 delSel.clear();
677 return delSel; 733 return delSel;
678 } 734 }
679 if (result == KMessageBox::Yes) 735 if (result == KMessageBox::Yes)
680 addSubTodos = true; 736 addSubTodos = true;
681 askSubTodos = false; 737 askSubTodos = false;
682 } 738 }
683 if ( addSubTodos ) { 739 if ( addSubTodos ) {
684 inc->addRelationsToList( &delSel ); 740 inc->addRelationsToList( &delSel );
685 } 741 }
686 } 742 }
687 } 743 }
688 } 744 }
689 item = item->nextSibling(); 745 item = item->nextSibling();
690 } 746 }
691 return delSel; 747 return delSel;
692} 748}
693 749
694void KOListView::writeToFile( bool iCal ) 750void KOListView::writeToFile( bool iCal )
695{ 751{
696 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; 752 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
697 if ( !iCal ) { 753 if ( !iCal ) {
698 bool journal = false; 754 bool journal = false;
699 Incidence *incidence = delSel.first(); 755 Incidence *incidence = delSel.first();
700 while ( incidence ) { 756 while ( incidence ) {
701 if ( incidence->typeID() == journalID ) { 757 if ( incidence->typeID() == journalID ) {
702 journal = true; 758 journal = true;
703 break; 759 break;
704 } 760 }
705 incidence = delSel.next(); 761 incidence = delSel.next();
706 } 762 }
707 if ( journal ) { 763 if ( journal ) {
708 int result = KMessageBox::warningContinueCancel(this, 764 int result = KMessageBox::warningContinueCancel(this,
709 i18n("The journal entries can not be\nexported to a vCalendar file."), 765 i18n("The journal entries can not be\nexported to a vCalendar file."),
710 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 766 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
711 true); 767 true);
712 if (result != KMessageBox::Continue) return; 768 if (result != KMessageBox::Continue) return;
713 } 769 }
714 } 770 }
715 if ( delSel.count() ) { 771 if ( delSel.count() ) {
716 QString fn = KOPrefs::instance()->mLastSaveFile; 772 QString fn = KOPrefs::instance()->mLastSaveFile;
717 QString extension; 773 QString extension;
718 if ( iCal ) { 774 if ( iCal ) {
719 if ( fn.right( 4 ).lower() == ".vcs" ) { 775 if ( fn.right( 4 ).lower() == ".vcs" ) {
720 fn = fn.left( fn.length() -3) + "ics"; 776 fn = fn.left( fn.length() -3) + "ics";
721 } 777 }
722 } else { 778 } else {
723 if ( fn.right( 4 ).lower() == ".ics" ) { 779 if ( fn.right( 4 ).lower() == ".ics" ) {
724 fn = fn.left( fn.length() -3) + "vcs"; 780 fn = fn.left( fn.length() -3) + "vcs";
725 } 781 }
726 } 782 }
727 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 783 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
728 784
729 if ( fn == "" ) 785 if ( fn == "" )
730 return; 786 return;
731 QFileInfo info; 787 QFileInfo info;
732 info.setFile( fn ); 788 info.setFile( fn );
733 QString mes; 789 QString mes;
734 bool createbup = true; 790 bool createbup = true;
735 if ( info. exists() ) { 791 if ( info. exists() ) {
736 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 792 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
737 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 793 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
738 i18n("Overwrite!"), i18n("Cancel"), 0, 794 i18n("Overwrite!"), i18n("Cancel"), 0,
739 0, 1 ); 795 0, 1 );
740 if ( result != 0 ) { 796 if ( result != 0 ) {
741 createbup = false; 797 createbup = false;
742 } 798 }
743 } 799 }
744 if ( createbup ) { 800 if ( createbup ) {
745 CalendarLocal cal; 801 CalendarLocal cal;
746 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 802 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
747 Incidence *incidence = delSel.first(); 803 Incidence *incidence = delSel.first();
748 while ( incidence ) { 804 while ( incidence ) {
749 cal.addIncidence( incidence->clone() ); 805 cal.addIncidence( incidence->clone() );
750 incidence = delSel.next(); 806 incidence = delSel.next();
751 } 807 }
752 if ( iCal ) { 808 if ( iCal ) {
753 ICalFormat format; 809 ICalFormat format;
754 format.save( &cal, fn ); 810 format.save( &cal, fn );
755 } else { 811 } else {
756 812
757 VCalFormat format; 813 VCalFormat format;
758 format.save( &cal, fn ); 814 format.save( &cal, fn );
759 } 815 }
760 mes = i18n("KO/Pi:Saved %1").arg(fn ); 816 mes = i18n("KO/Pi:Saved %1").arg(fn );
761 KOPrefs::instance()->mLastSaveFile = fn; 817 KOPrefs::instance()->mLastSaveFile = fn;
762 topLevelWidget()->setCaption(mes); 818 topLevelWidget()->setCaption(mes);
763 } 819 }
764 } 820 }
765 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 821 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
766} 822}
767void KOListView::hideAll() 823void KOListView::hideAll()
768{ 824{
769 QPtrList<QListViewItem> delSel ; 825 QPtrList<QListViewItem> delSel ;
770 QListViewItem *item = mListView->firstChild (); 826 QListViewItem *item = mListView->firstChild ();
771 while ( item ) { 827 while ( item ) {
772 if ( item->isSelected() ) { 828 if ( item->isSelected() ) {
773 delSel.append(item); 829 delSel.append(item);
774 } 830 }
775 item = item->nextSibling(); 831 item = item->nextSibling();
776 } 832 }
777 item = delSel.first() ; 833 item = delSel.first() ;
778 while ( item ) { 834 while ( item ) {
779 QListViewItem * del = item; 835 QListViewItem * del = item;
780 item = delSel.next(); 836 item = delSel.next();
781 delete del; 837 delete del;
782 } 838 }
783} 839}
784void KOListView::printList() 840void KOListView::printList()
785{ 841{
786 mListView->printList(); 842 mListView->printList();
787} 843}
788void KOListView::deleteAll() 844void KOListView::deleteAll()
789{ 845{
790 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; 846 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
791 if ( delSel.count() ) { 847 if ( delSel.count() ) {
792 int icount = delSel.count(); 848 int icount = delSel.count();
793 Incidence *incidence = delSel.first(); 849 Incidence *incidence = delSel.first();
794 Incidence *toDelete; 850 Incidence *toDelete;
795 KOPrefs *p = KOPrefs::instance(); 851 KOPrefs *p = KOPrefs::instance();
796 bool confirm = p->mConfirm; 852 bool confirm = p->mConfirm;
797 QString mess; 853 QString mess;
798 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 854 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
799 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 855 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
800 p->mConfirm = false; 856 p->mConfirm = false;
801 int delCounter = 0; 857 int delCounter = 0;
802 QDialog dia ( this, "p-dialog", true ); 858 QDialog dia ( this, "p-dialog", true );
803 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 859 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
804 QVBoxLayout lay( &dia ); 860 QVBoxLayout lay( &dia );
805 lay.setMargin(7); 861 lay.setMargin(7);
806 lay.setSpacing(7); 862 lay.setSpacing(7);
807 lay.addWidget( &lab); 863 lay.addWidget( &lab);
808 QProgressBar bar( icount, &dia ); 864 QProgressBar bar( icount, &dia );
809 lay.addWidget( &bar); 865 lay.addWidget( &bar);
810 int w = 220; 866 int w = 220;
811 int h = 50; 867 int h = 50;
812 int dw = QApplication::desktop()->width(); 868 int dw = QApplication::desktop()->width();
813 int dh = QApplication::desktop()->height(); 869 int dh = QApplication::desktop()->height();
814 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 870 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
815 //dia.resize( 240,50 ); 871 //dia.resize( 240,50 );
816 dia.show(); 872 dia.show();
817 873
818 while ( incidence ) { 874 while ( incidence ) {
819 bar.setProgress( delCounter ); 875 bar.setProgress( delCounter );
820 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 876 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
821 dia.setCaption( mess ); 877 dia.setCaption( mess );
822 qApp->processEvents(); 878 qApp->processEvents();
823 toDelete = (incidence); 879 toDelete = (incidence);
824 incidence = delSel.next(); 880 incidence = delSel.next();
825 emit deleteIncidenceSignal(toDelete ); 881 emit deleteIncidenceSignal(toDelete );
826 if ( dia.result() != 0 ) 882 if ( dia.result() != 0 )
827 break; 883 break;
828 884
829 } 885 }
830 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 886 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
831 topLevelWidget ()->setCaption( mess ); 887 topLevelWidget ()->setCaption( mess );
832 p->mConfirm = confirm; 888 p->mConfirm = confirm;
833 } 889 }
834 } 890 }
835 891
836 892
837} 893}
838int KOListView::maxDatesHint() 894int KOListView::maxDatesHint()
839{ 895{
840 return 0; 896 return 0;
841} 897}
842 898
843int KOListView::currentDateCount() 899int KOListView::currentDateCount()
844{ 900{
845 return 0; 901 return 0;
846} 902}
847 903
848QPtrList<Incidence> KOListView::selectedIncidences() 904QPtrList<Incidence> KOListView::selectedIncidences()
849{ 905{
850 QPtrList<Incidence> eventList; 906 QPtrList<Incidence> eventList;
851 QListViewItem *item = mListView->firstChild (); 907 QListViewItem *item = mListView->firstChild ();
852 while ( item ) { 908 while ( item ) {
853 if ( item->isSelected() ) { 909 if ( item->isSelected() ) {
854 eventList.append(((KOListViewItem *)item)->data()); 910 eventList.append(((KOListViewItem *)item)->data());
855 } 911 }
856 912
857 item = item->nextSibling(); 913 item = item->nextSibling();
858 } 914 }
859 915
860 // // QListViewItem *item = mListView->selectedItem(); 916 // // QListViewItem *item = mListView->selectedItem();
861 //if (item) eventList.append(((KOListViewItem *)item)->data()); 917 //if (item) eventList.append(((KOListViewItem *)item)->data());
862 918
863 return eventList; 919 return eventList;
864} 920}
865 921
866DateList KOListView::selectedDates() 922DateList KOListView::selectedDates()
867{ 923{
868 DateList eventList; 924 DateList eventList;
869 return eventList; 925 return eventList;
870} 926}
871 927
872void KOListView::showDates(bool show) 928void KOListView::showDates(bool show)
873{ 929{
874 // Shouldn't we set it to a value greater 0? When showDates is called with 930 // Shouldn't we set it to a value greater 0? When showDates is called with
875 // show == true at first, then the columnwidths are set to zero. 931 // show == true at first, then the columnwidths are set to zero.
876 static int oldColWidth1 = 0; 932 static int oldColWidth1 = 0;
877 static int oldColWidth3 = 0; 933 static int oldColWidth3 = 0;
878 934
879 if (!show) { 935 if (!show) {
880 oldColWidth1 = mListView->columnWidth(1); 936 oldColWidth1 = mListView->columnWidth(1);
881 oldColWidth3 = mListView->columnWidth(3); 937 oldColWidth3 = mListView->columnWidth(3);
882 mListView->setColumnWidth(1, 0); 938 mListView->setColumnWidth(1, 0);
883 mListView->setColumnWidth(3, 0); 939 mListView->setColumnWidth(3, 0);
884 } else { 940 } else {
885 mListView->setColumnWidth(1, oldColWidth1); 941 mListView->setColumnWidth(1, oldColWidth1);
886 mListView->setColumnWidth(3, oldColWidth3); 942 mListView->setColumnWidth(3, oldColWidth3);
887 } 943 }
888 mListView->repaint(); 944 mListView->repaint();
889} 945}
890 946
891void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 947void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
892 const QDate &td) 948 const QDate &td)
893{ 949{
894#ifndef KORG_NOPRINTER 950#ifndef KORG_NOPRINTER
895 calPrinter->preview(CalPrinter::Day, fd, td); 951 calPrinter->preview(CalPrinter::Day, fd, td);
896#endif 952#endif
897} 953}
898 954
899void KOListView::showDates() 955void KOListView::showDates()
900{ 956{
901 showDates(true); 957 showDates(true);
902} 958}
903 959
904void KOListView::hideDates() 960void KOListView::hideDates()
905{ 961{
906 showDates(false); 962 showDates(false);
907} 963}
908 964
909void KOListView::resetFocus() 965void KOListView::resetFocus()
910{ 966{
911 topLevelWidget()->setActiveWindow(); 967 topLevelWidget()->setActiveWindow();
912 topLevelWidget()->raise(); 968 topLevelWidget()->raise();
913 mListView->setFocus(); 969 mListView->setFocus();
914} 970}
915void KOListView::updateView() 971void KOListView::updateView()
916{ 972{
917 mListView->setFocus(); 973 mListView->setFocus();
918 if ( mListView->firstChild () ) 974 if ( mListView->firstChild () )
919 mListView->setCurrentItem( mListView->firstChild () ); 975 mListView->setCurrentItem( mListView->firstChild () );
920} 976}
921void KOListView::updateConfig() 977void KOListView::updateConfig()
922{ 978{
923 979
924 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 980 mListView->setFont ( KOPrefs::instance()->mListViewFont );
925 updateView(); 981 updateView();
926 982
927} 983}
928void KOListView::setStartDate(const QDate &start) 984void KOListView::setStartDate(const QDate &start)
929{ 985{
930 mStartDate = start; 986 mStartDate = start;
931} 987}
932 988
933void KOListView::showDates(const QDate &start, const QDate &end) 989void KOListView::showDates(const QDate &start, const QDate &end)
934{ 990{
935 clear(); 991 clear();
936 mStartDate = start; 992 mStartDate = start;
937 QDate date = start; 993 QDate date = start;
938 QPtrList<Journal> j_list; 994 QPtrList<Journal> j_list;
939 while( date <= end ) { 995 while( date <= end ) {
940 addEvents(calendar()->events(date)); 996 addEvents(calendar()->events(date));
941 addTodos(calendar()->todos(date)); 997 addTodos(calendar()->todos(date));
942 Journal* jo = calendar()->journal(date); 998 Journal* jo = calendar()->journal(date);
943 if ( jo ) 999 if ( jo )
944 j_list.append( jo ); 1000 j_list.append( jo );
945 date = date.addDays( 1 ); 1001 date = date.addDays( 1 );
946 } 1002 }
947 addJournals(j_list); 1003 addJournals(j_list);
948 emit incidenceSelected( 0 ); 1004 emit incidenceSelected( 0 );
949 updateView(); 1005 updateView();
950 1006
951} 1007}
952 1008
953void KOListView::addEvents(QPtrList<Event> eventList) 1009void KOListView::addEvents(QPtrList<Event> eventList)
954{ 1010{
955 1011
956 Event *ev; 1012 Event *ev;
957 for(ev = eventList.first(); ev; ev = eventList.next()) { 1013 for(ev = eventList.first(); ev; ev = eventList.next()) {
958 addIncidence(ev); 1014 addIncidence(ev);
959 } 1015 }
960 if ( !mListView->currentItem() ){ 1016 if ( !mListView->currentItem() ){
961 updateView(); 1017 updateView();
962 } 1018 }
963} 1019}
964 1020
965void KOListView::addTodos(QPtrList<Todo> eventList) 1021void KOListView::addTodos(QPtrList<Todo> eventList)
966{ 1022{
967 Todo *ev; 1023 Todo *ev;
968 for(ev = eventList.first(); ev; ev = eventList.next()) { 1024 for(ev = eventList.first(); ev; ev = eventList.next()) {
969 addIncidence(ev); 1025 addIncidence(ev);
970 } 1026 }
971 if ( !mListView->currentItem() ){ 1027 if ( !mListView->currentItem() ){
972 updateView(); 1028 updateView();
973 } 1029 }
974} 1030}
975void KOListView::addJournals(QPtrList<Journal> eventList) 1031void KOListView::addJournals(QPtrList<Journal> eventList)
976{ 1032{
977 Journal *ev; 1033 Journal *ev;
978 for(ev = eventList.first(); ev; ev = eventList.next()) { 1034 for(ev = eventList.first(); ev; ev = eventList.next()) {
979 addIncidence(ev); 1035 addIncidence(ev);
980 } 1036 }
981 if ( !mListView->currentItem() ){ 1037 if ( !mListView->currentItem() ){
982 updateView(); 1038 updateView();
983 } 1039 }
984} 1040}
985 1041
986void KOListView::addIncidence(Incidence *incidence) 1042void KOListView::addIncidence(Incidence *incidence)
987{ 1043{
988 if ( mUidDict.find( incidence->uid() ) ) return; 1044 if ( mUidDict.find( incidence->uid() ) ) return;
989 1045
990 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1046 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
991 mUidDict.insert( incidence->uid(), incidence ); 1047 mUidDict.insert( incidence->uid(), incidence );
992 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1048 KOListViewItem *item = new KOListViewItem( incidence, mListView );
993 ListItemVisitor v(item, mStartDate ); 1049 ListItemVisitor v(item, mStartDate );
994 if (incidence->accept(v)) { 1050 if (incidence->accept(v)) {
995 return; 1051 return;
996 } 1052 }
997 else delete item; 1053 else delete item;
998} 1054}
999 1055
1000void KOListView::showEvents(QPtrList<Event> eventList) 1056void KOListView::showEvents(QPtrList<Event> eventList)
1001{ 1057{
1002 clear(); 1058 clear();
1003 1059
1004 addEvents(eventList); 1060 addEvents(eventList);
1005 1061
1006 // After new creation of list view no events are selected. 1062 // After new creation of list view no events are selected.
1007 emit incidenceSelected( 0 ); 1063 emit incidenceSelected( 0 );
1008} 1064}
1009int KOListView::count() 1065int KOListView::count()
1010{ 1066{
1011 return mListView->childCount(); 1067 return mListView->childCount();
1012} 1068}
1013 1069
1014void KOListView::changeEventDisplay(Event *event, int action) 1070void KOListView::changeEventDisplay(Event *event, int action)
1015{ 1071{
1016 KOListViewItem *item; 1072 KOListViewItem *item;
1017 1073
1018 switch(action) { 1074 switch(action) {
1019 case KOGlobals::EVENTADDED: 1075 case KOGlobals::EVENTADDED:
1020 addIncidence( event ); 1076 addIncidence( event );
1021 break; 1077 break;
1022 case KOGlobals::EVENTEDITED: 1078 case KOGlobals::EVENTEDITED:
1023 item = getItemForEvent(event); 1079 item = getItemForEvent(event);
1024 if (item) { 1080 if (item) {
1025 mUidDict.remove( event->uid() ); 1081 mUidDict.remove( event->uid() );
1026 delete item; 1082 delete item;
1027 addIncidence( event ); 1083 addIncidence( event );
1028 } 1084 }
1029 break; 1085 break;
1030 case KOGlobals::EVENTDELETED: 1086 case KOGlobals::EVENTDELETED:
1031 item = getItemForEvent(event); 1087 item = getItemForEvent(event);
1032 if (item) { 1088 if (item) {
1033 mUidDict.remove( event->uid() ); 1089 mUidDict.remove( event->uid() );
1034 delete item; 1090 delete item;
1035 } 1091 }
1036 break; 1092 break;
1037 default: 1093 default:
1038 ; 1094 ;
1039 } 1095 }
1040} 1096}
1041 1097
1042KOListViewItem *KOListView::getItemForEvent(Event *event) 1098KOListViewItem *KOListView::getItemForEvent(Incidence *event)
1043{ 1099{
1044 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 1100 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
1045 while (item) { 1101 while (item) {
1046 if (item->data() == event) return item; 1102 if (item->data() == event) return item;
1047 item = (KOListViewItem *)item->nextSibling(); 1103 item = (KOListViewItem *)item->nextSibling();
1048 } 1104 }
1049 return 0; 1105 return 0;
1050} 1106}
1051 1107
1052void KOListView::defaultItemAction(QListViewItem *i) 1108void KOListView::defaultItemAction(QListViewItem *i)
1053{ 1109{
1054 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1110 KOListViewItem *item = static_cast<KOListViewItem *>( i );
1055 if ( item ) defaultAction( item->data() ); 1111 if ( item ) defaultAction( item->data() );
1056 1112
1057} 1113}
1058 1114
1059void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1115void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1060{ 1116{
1061 mActiveItem = (KOListViewItem *)item; 1117 mActiveItem = (KOListViewItem *)item;
1062 if (mActiveItem) { 1118 if (mActiveItem) {
1063 Incidence *incidence = mActiveItem->data(); 1119 Incidence *incidence = mActiveItem->data();
1064 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1120 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1065 mPopupMenu->showIncidencePopup(incidence); 1121 mPopupMenu->showIncidencePopup(incidence);
1066 1122
1067 /* 1123 /*
1068 if ( incidence && incidence->type() == "Event" ) { 1124 if ( incidence && incidence->type() == "Event" ) {
1069 Event *event = static_cast<Event *>( incidence ); 1125 Event *event = static_cast<Event *>( incidence );
1070 mPopupMenu->showEventPopup(event); 1126 mPopupMenu->showEventPopup(event);
1071 } 1127 }
1072 */ 1128 */
1073 } 1129 }
1074} 1130}
1075 1131
1076void KOListView::readSettings(KConfig *config, QString setting) 1132void KOListView::readSettings(KConfig *config, QString setting)
1077{ 1133{
1078 // qDebug("KOListView::readSettings "); 1134 // qDebug("KOListView::readSettings ");
1079 mListView->restoreLayout(config,setting); 1135 mListView->restoreLayout(config,setting);
1080} 1136}
1081 1137
1082void KOListView::writeSettings(KConfig *config, QString setting) 1138void KOListView::writeSettings(KConfig *config, QString setting)
1083{ 1139{
1084 // qDebug("KOListView::writeSettings "); 1140 // qDebug("KOListView::writeSettings ");
1085 mListView->saveLayout(config, setting); 1141 mListView->saveLayout(config, setting);
1086} 1142}
1087 1143
1088void KOListView::processSelectionChange(QListViewItem *) 1144void KOListView::processSelectionChange(QListViewItem *)
1089{ 1145{
1090 1146
1091 KOListViewItem *item = 1147 KOListViewItem *item =
1092 static_cast<KOListViewItem *>( mListView->currentItem() ); 1148 static_cast<KOListViewItem *>( mListView->currentItem() );
1093 1149
1094 if ( !item ) { 1150 if ( !item ) {
1095 emit incidenceSelected( 0 ); 1151 emit incidenceSelected( 0 );
1096 } else { 1152 } else {
1097 emit incidenceSelected( item->data() ); 1153 emit incidenceSelected( item->data() );
1098 } 1154 }
1099} 1155}
1100 1156
1101void KOListView::clearSelection() 1157void KOListView::clearSelection()
1102{ 1158{
1103 mListView->selectAll( false ); 1159 mListView->selectAll( false );
1104} 1160}
1105void KOListView::allSelection() 1161void KOListView::allSelection()
1106{ 1162{
1107 mListView->selectAll( true ); 1163 mListView->selectAll( true );
1108} 1164}
1109 1165
1110void KOListView::clear() 1166void KOListView::clear()
1111{ 1167{
1112 mListView->clear(); 1168 mListView->clear();
1113 mUidDict.clear(); 1169 mUidDict.clear();
1114} 1170}
1115 1171
1116Incidence* KOListView::currentItem() 1172Incidence* KOListView::currentItem()
1117{ 1173{
1118 if ( mListView->currentItem() ) 1174 if ( mListView->currentItem() )
1119 return ((KOListViewItem*) mListView->currentItem())->data(); 1175 return ((KOListViewItem*) mListView->currentItem())->data();
1120 return 0; 1176 return 0;
1121} 1177}
1122void KOListView::keyPressEvent ( QKeyEvent *e) 1178void KOListView::keyPressEvent ( QKeyEvent *e)
1123{ 1179{
1124 1180
1125 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1181 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1126 deleteAll(); 1182 deleteAll();
1127 return; 1183 return;
1128 } 1184 }
1129 1185
1130 e->ignore(); 1186 e->ignore();
1131} 1187}
1132void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1188void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1133{ 1189{
1134 1190
1135 switch ( e->key() ) { 1191 switch ( e->key() ) {
1136 case Qt::Key_Down: 1192 case Qt::Key_Down:
1137 if ( e->state() == ShiftButton ) { 1193 if ( e->state() == ShiftButton ) {
1138 QListViewItem* cn = currentItem(); 1194 QListViewItem* cn = currentItem();
1139 if ( !cn ) 1195 if ( !cn )
1140 cn = firstChild(); 1196 cn = firstChild();
1141 if ( !cn ) 1197 if ( !cn )
1142 return; 1198 return;
1143 while ( cn->nextSibling() ) 1199 while ( cn->nextSibling() )
1144 cn = cn->nextSibling(); 1200 cn = cn->nextSibling();
1145 setCurrentItem ( cn ); 1201 setCurrentItem ( cn );
1146 ensureItemVisible ( cn ); 1202 ensureItemVisible ( cn );
1147 1203
1148 e->accept(); 1204 e->accept();
1149 return; 1205 return;
1150 } 1206 }
1151 if ( e->state() == ControlButton ) { 1207 if ( e->state() == ControlButton ) {
1152 int count = childCount (); 1208 int count = childCount ();
1153 int jump = count / 5; 1209 int jump = count / 5;
1154 QListViewItem* cn; 1210 QListViewItem* cn;
1155 cn = currentItem(); 1211 cn = currentItem();
1156 if ( ! cn ) 1212 if ( ! cn )
1157 return; 1213 return;
1158 if ( jump == 0 ) 1214 if ( jump == 0 )
1159 jump = 1; 1215 jump = 1;
1160 while ( jump && cn->nextSibling() ) { 1216 while ( jump && cn->nextSibling() ) {
1161 cn = cn->nextSibling(); 1217 cn = cn->nextSibling();
1162 --jump; 1218 --jump;
1163 } 1219 }
1164 setCurrentItem ( cn ); 1220 setCurrentItem ( cn );
1165 ensureItemVisible ( cn ); 1221 ensureItemVisible ( cn );
1166 1222
1167 } else 1223 } else
1168 QListView::keyPressEvent ( e ) ; 1224 QListView::keyPressEvent ( e ) ;
1169 e->accept(); 1225 e->accept();
1170 break; 1226 break;
1171 1227
1172 case Qt::Key_Up: 1228 case Qt::Key_Up:
1173 if ( e->state() == ShiftButton ) { 1229 if ( e->state() == ShiftButton ) {
1174 QListViewItem* cn = firstChild(); 1230 QListViewItem* cn = firstChild();
1175 if ( cn ) { 1231 if ( cn ) {
1176 setCurrentItem ( cn ); 1232 setCurrentItem ( cn );
1177 ensureItemVisible ( cn ); 1233 ensureItemVisible ( cn );
1178 } 1234 }
1179 e->accept(); 1235 e->accept();
1180 return; 1236 return;
1181 } 1237 }
1182 if ( e->state() == ControlButton ) { 1238 if ( e->state() == ControlButton ) {
1183 int count = childCount (); 1239 int count = childCount ();
1184 int jump = count / 5; 1240 int jump = count / 5;
1185 QListViewItem* cn; 1241 QListViewItem* cn;
1186 cn = currentItem(); 1242 cn = currentItem();
1187 if ( ! cn ) 1243 if ( ! cn )
1188 return; 1244 return;
1189 if ( jump == 0 ) 1245 if ( jump == 0 )
1190 jump = 1; 1246 jump = 1;
1191 while ( jump && cn->itemAbove ()) { 1247 while ( jump && cn->itemAbove ()) {
1192 cn = cn->itemAbove (); 1248 cn = cn->itemAbove ();
1193 --jump; 1249 --jump;
1194 } 1250 }
1195 setCurrentItem ( cn ); 1251 setCurrentItem ( cn );
1196 ensureItemVisible ( cn ); 1252 ensureItemVisible ( cn );
1197 } else 1253 } else
1198 QListView::keyPressEvent ( e ) ; 1254 QListView::keyPressEvent ( e ) ;
1199 e->accept(); 1255 e->accept();
1200 break; 1256 break;
1201 case Qt::Key_I: { 1257 case Qt::Key_I: {
1202 QListViewItem* cn; 1258 QListViewItem* cn;
1203 cn = currentItem(); 1259 cn = currentItem();
1204 if ( cn ) { 1260 if ( cn ) {
1205 KOListViewItem* ci = (KOListViewItem*)( cn ); 1261 KOListViewItem* ci = (KOListViewItem*)( cn );
1206 if ( ci ){ 1262 if ( ci ){
1207 //emit showIncidence( ci->data()); 1263 //emit showIncidence( ci->data());
1208 cn = cn->nextSibling(); 1264 cn = cn->nextSibling();
1209 if ( cn ) { 1265 if ( cn ) {
1210 setCurrentItem ( cn ); 1266 setCurrentItem ( cn );
1211 ensureItemVisible ( cn ); 1267 ensureItemVisible ( cn );
1212 } 1268 }
1213 emit showIncidence( ci->data()); 1269 emit showIncidence( ci->data());
1214 } 1270 }
1215 } 1271 }
1216 e->accept(); 1272 e->accept();
1217 } 1273 }
1218 break; 1274 break;
1219 case Qt::Key_Return: 1275 case Qt::Key_Return:
1220 case Qt::Key_Enter: 1276 case Qt::Key_Enter:
1221 { 1277 {
1222 QListViewItem* cn; 1278 QListViewItem* cn;
1223 cn = currentItem(); 1279 cn = currentItem();
1224 if ( cn ) { 1280 if ( cn ) {
1225 KOListViewItem* ci = (KOListViewItem*)( cn ); 1281 KOListViewItem* ci = (KOListViewItem*)( cn );
1226 if ( ci ){ 1282 if ( ci ){
1227 if ( e->state() == ShiftButton ) 1283 if ( e->state() == ShiftButton )
1228 ci->setSelected( false ); 1284 ci->setSelected( false );
1229 else 1285 else
1230 ci->setSelected( true ); 1286 ci->setSelected( true );
1231 cn = cn->nextSibling(); 1287 cn = cn->nextSibling();
1232 if ( cn ) { 1288 if ( cn ) {
1233 setCurrentItem ( cn ); 1289 setCurrentItem ( cn );
1234 ensureItemVisible ( cn ); 1290 ensureItemVisible ( cn );
1235 } 1291 }
1236 } 1292 }
1237 } 1293 }
1238 e->accept(); 1294 e->accept();
1239 } 1295 }
1240 break; 1296 break;
1241 default: 1297 default:
1242 e->ignore(); 1298 e->ignore();
1243 } 1299 }
1244} 1300}
1245KOListViewListView::KOListViewListView(KOListView * lv ) 1301KOListViewListView::KOListViewListView(KOListView * lv )
1246 : KListView( lv, "kolistlistview", false ) 1302 : KListView( lv, "kolistlistview", false )
1247{ 1303{
1248 mYMousePos = 0; 1304 mYMousePos = 0;
1249 mPopupTimer = new QTimer(this); 1305 mPopupTimer = new QTimer(this);
1250 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1306 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1251#ifndef DESKTOP_VERSION 1307#ifndef DESKTOP_VERSION
1252 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1308 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1253#endif 1309#endif
1254 setSelectionMode( QListView::Multi ); 1310 setSelectionMode( QListView::Multi );
1255 setMultiSelection( true); 1311 setMultiSelection( true);
1256} 1312}
1257bool KOListViewListView::hasMultiSelection(QListViewItem* item) 1313bool KOListViewListView::hasMultiSelection(QListViewItem* item)
1258{ 1314{
1259 int selCount = 0; 1315 int selCount = 0;
1260 QListViewItem *qitem = firstChild (); 1316 QListViewItem *qitem = firstChild ();
1261 while ( qitem ) { 1317 while ( qitem ) {
1262 if ( qitem->isSelected() && item != qitem ) 1318 if ( qitem->isSelected() && item != qitem )
1263 return true; 1319 return true;
1264 qitem = qitem->nextSibling(); 1320 qitem = qitem->nextSibling();
1265 } 1321 }
1266 return false; 1322 return false;
1267} 1323}
1268void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1324void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1269{ 1325{
1270 if (!e) return; 1326 if (!e) return;
1271 QPoint vp = contentsToViewport(e->pos()); 1327 QPoint vp = contentsToViewport(e->pos());
1272 QListViewItem *item = itemAt(vp); 1328 QListViewItem *item = itemAt(vp);
1273 if (!item) { 1329 if (!item) {
1274 emit newEvent(); 1330 emit newEvent();
1275 return; 1331 return;
1276 } 1332 }
1277 KListView::contentsMouseDoubleClickEvent(e); 1333 KListView::contentsMouseDoubleClickEvent(e);
1278} 1334}
1279#if 0 1335#if 0
1280void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1336void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1281{ 1337{
1282 //qDebug("contentsMousePressEvent++++ "); 1338 //qDebug("contentsMousePressEvent++++ ");
1283 KListView::contentsMousePressEvent( e ); 1339 KListView::contentsMousePressEvent( e );
1284 if ( e->button() == RightButton ) { 1340 if ( e->button() == RightButton ) {
1285 QListViewItem* ci = currentItem(); 1341 QListViewItem* ci = currentItem();
1286 clearSelection () ; 1342 clearSelection () ;
1287 if ( ci ) 1343 if ( ci )
1288 ci->setSelected( true ); 1344 ci->setSelected( true );
1289 } 1345 }
1290} 1346}
1291void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1347void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1292{ 1348{
1293 KListView::contentsMouseReleaseEvent(e); 1349 KListView::contentsMouseReleaseEvent(e);
1294} 1350}
1295void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1351void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1296{ 1352{
1297 KListView::contentsMouseMoveEvent(e); 1353 KListView::contentsMouseMoveEvent(e);
1298} 1354}
1299#endif 1355#endif
1300void KOListViewListView::popupMenu() 1356void KOListViewListView::popupMenu()
1301{ 1357{
1302 mPopupTimer->stop(); 1358 mPopupTimer->stop();
1303 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1359 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1304 QApplication::postEvent( this->viewport(), e ); 1360 QApplication::postEvent( this->viewport(), e );
1305 1361
1306} 1362}
1307void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1363void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1308{ 1364{
1309 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1365 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1310 mYMousePos = mapToGlobal( (e->pos())).y(); 1366 mYMousePos = mapToGlobal( (e->pos())).y();
1311 if ( e->button() == LeftButton ) { 1367 if ( e->button() == LeftButton ) {
1312 mPopupTimer->start( 600 ); 1368 mPopupTimer->start( 600 );
1313 mEventPos = contentsToViewport(e->pos()); 1369 mEventPos = contentsToViewport(e->pos());
1314 mEventGlobalPos = e->globalPos(); 1370 mEventGlobalPos = e->globalPos();
1315 } 1371 }
1316 KListView::contentsMousePressEvent( e ); 1372 KListView::contentsMousePressEvent( e );
1317 if ( e->button() == RightButton ) { 1373 if ( e->button() == RightButton ) {
1318 QListViewItem* ci = currentItem(); 1374 QListViewItem* ci = currentItem();
1319 //clearSelection(); 1375 //clearSelection();
1320 if ( ci ) 1376 if ( ci )
1321 ci->setSelected( true ); 1377 ci->setSelected( true );
1322 } 1378 }
1323} 1379}
1324void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1380void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1325{ 1381{
1326 mPopupTimer->stop(); 1382 mPopupTimer->stop();
1327 KListView::contentsMouseReleaseEvent(e); 1383 KListView::contentsMouseReleaseEvent(e);
1328} 1384}
1329void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1385void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1330{ 1386{
1331 // qDebug("contentsMouseMoveEv....... "); 1387 // qDebug("contentsMouseMoveEv....... ");
1332 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1388 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1333 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1389 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1334 if ( diff < 0 ) diff = -diff; 1390 if ( diff < 0 ) diff = -diff;
1335 if ( diff > 15 ) 1391 if ( diff > 15 )
1336 mPopupTimer->stop(); 1392 mPopupTimer->stop();
1337 else { 1393 else {
1338 mEventPos = contentsToViewport(e->pos()); 1394 mEventPos = contentsToViewport(e->pos());
1339 mEventGlobalPos = e->globalPos(); 1395 mEventGlobalPos = e->globalPos();
1340 } 1396 }
1341 KListView::contentsMouseMoveEvent(e); 1397 KListView::contentsMouseMoveEvent(e);
1342} 1398}
1343 1399
1344#define protected public 1400#define protected public
1345#include <qheader.h> 1401#include <qheader.h>
1346#undef protected 1402#undef protected
1347void KOListViewListView::printList() 1403void KOListViewListView::printList()
1348{ 1404{
1349#ifdef DESKTOP_VERSION 1405#ifdef DESKTOP_VERSION
1350 KOPrintPrefs pp ( this ); 1406 KOPrintPrefs pp ( this );
1351 if (!pp.exec() ) 1407 if (!pp.exec() )
1352 return; 1408 return;
1353 int scaleval = pp.printMode() ; 1409 int scaleval = pp.printMode() ;
1354 1410
1355 QPrinter printer; 1411 QPrinter printer;
1356 if (!printer.setup() ) 1412 if (!printer.setup() )
1357 return; 1413 return;
1358 clearSelection (); 1414 clearSelection ();
1359 QPainter p; 1415 QPainter p;
1360 p.begin ( &printer ); 1416 p.begin ( &printer );
1361 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 1417 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
1362 float dx, dy; 1418 float dx, dy;
1363 int wid = (m.width() * 9)/10; 1419 int wid = (m.width() * 9)/10;
1364 dx = (float) wid/(float)contentsWidth (); 1420 dx = (float) wid/(float)contentsWidth ();
1365 dy = (float)(m.height()) / (float)contentsHeight (); 1421 dy = (float)(m.height()) / (float)contentsHeight ();
1366 float scale; 1422 float scale;
1367 // scale to fit the width or height of the paper 1423 // scale to fit the width or height of the paper
1368 if ( dx < dy ) 1424 if ( dx < dy )
1369 scale = dx; 1425 scale = dx;
1370 else 1426 else
1371 scale = dy; 1427 scale = dy;
1372 1428
1373 p.translate( m.width()/10,m.width()/10 ); 1429 p.translate( m.width()/10,m.width()/10 );
1374 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 1430 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
1375 p.scale( scale, scale ); 1431 p.scale( scale, scale );
1376 } 1432 }
1377 1433
1378 int cou = header()->count(); 1434 int cou = header()->count();
1379 int iii; 1435 int iii;
1380 QRect rect ( 0,0,0, header()->height()); 1436 QRect rect ( 0,0,0, header()->height());
1381 for ( iii = 0; iii < cou; ++iii ) { 1437 for ( iii = 0; iii < cou; ++iii ) {
1382 rect.setLeft ( header()->sectionPos( iii ) ); 1438 rect.setLeft ( header()->sectionPos( iii ) );
1383 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); 1439 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii));
1384 header()->paintSection ( & p, header()->mapToIndex (iii), rect ); 1440 header()->paintSection ( & p, header()->mapToIndex (iii), rect );
1385 } 1441 }
1386 p.translate( 0, header()->height()); 1442 p.translate( 0, header()->height());
1387 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); 1443 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () );
1388 p.end(); 1444 p.end();
1389#endif 1445#endif
1390} 1446}
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index 9da5497..d384af0 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -1,318 +1,321 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This 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 _KOLISTVIEW_H 24#ifndef _KOLISTVIEW_H
25#define _KOLISTVIEW_H 25#define _KOLISTVIEW_H
26 26
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qmap.h> 28#include <qmap.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include <klistview.h> 31#include <klistview.h>
32 32
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/incidence.h> 38#include <libkcal/incidence.h>
39 39
40#include "koeventview.h" 40#include "koeventview.h"
41#include "customlistviewitem.h" 41#include "customlistviewitem.h"
42 42
43using namespace KCal; 43using namespace KCal;
44 44
45class KOListViewWhatsThis; 45class KOListViewWhatsThis;
46 46
47#include <qpushbutton.h> 47#include <qpushbutton.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qdialog.h> 49#include <qdialog.h>
50#include <qtimer.h> 50#include <qtimer.h>
51#include <qcombobox.h> 51#include <qcombobox.h>
52#include <qspinbox.h> 52#include <qspinbox.h>
53#include <qtooltip.h> 53#include <qtooltip.h>
54#include <qcheckbox.h> 54#include <qcheckbox.h>
55#include <qhbox.h> 55#include <qhbox.h>
56#include <qlabel.h> 56#include <qlabel.h>
57#include <kiconloader.h> 57#include <kiconloader.h>
58#include "kfiledialog.h" 58#include "kfiledialog.h"
59#include "koprefs.h" 59#include "koprefs.h"
60class KOAlarmPrefs : public QDialog 60class KOAlarmPrefs : public QDialog
61{ 61{
62 Q_OBJECT 62 Q_OBJECT
63 public: 63 public:
64 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : 64 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) :
65 QDialog( par, name, true ) 65 QDialog( par, name, true )
66 { 66 {
67 setCaption( i18n("Alarm Options") ); 67 setCaption( i18n("Alarm Options") );
68 QVBoxLayout* alarmLayout = new QVBoxLayout( this ); 68 QVBoxLayout* alarmLayout = new QVBoxLayout( this );
69 alarmLayout->setSpacing( 3 ); 69 alarmLayout->setSpacing( 3 );
70 alarmLayout->setMargin( 3 ); 70 alarmLayout->setMargin( 3 );
71 QWidget *parent = this; 71 QWidget *parent = this;
72 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); 72 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent);
73 alarmLayout->addWidget(mAlarmButton); 73 alarmLayout->addWidget(mAlarmButton);
74 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 74 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
75 mAlarmTimeEdit->setValue( 15 ); 75 mAlarmTimeEdit->setValue( 15 );
76 alarmLayout->addWidget(mAlarmTimeEdit); 76 alarmLayout->addWidget(mAlarmTimeEdit);
77 mAlarmIncrCombo = new QComboBox(false, parent); 77 mAlarmIncrCombo = new QComboBox(false, parent);
78 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 78 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
79 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 79 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
80 mAlarmIncrCombo->insertItem(i18n("day(s)")); 80 mAlarmIncrCombo->insertItem(i18n("day(s)"));
81 alarmLayout->addWidget(mAlarmIncrCombo); 81 alarmLayout->addWidget(mAlarmIncrCombo);
82 QHBox * hb = new QHBox ( parent ); 82 QHBox * hb = new QHBox ( parent );
83 alarmLayout->addWidget(hb); 83 alarmLayout->addWidget(hb);
84 mAlarmSoundButton = new QPushButton(hb); 84 mAlarmSoundButton = new QPushButton(hb);
85 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 85 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
86 mAlarmSoundButton->setToggleButton(true); 86 mAlarmSoundButton->setToggleButton(true);
87 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 87 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
88 mAlarmProgramButton = new QPushButton(hb); 88 mAlarmProgramButton = new QPushButton(hb);
89 mAlarmProgramButton->setPixmap(SmallIcon("run")); 89 mAlarmProgramButton->setPixmap(SmallIcon("run"));
90 mAlarmProgramButton->setToggleButton(true); 90 mAlarmProgramButton->setToggleButton(true);
91 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 91 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
92 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 92 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
93 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 93 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
94 mAlarmLabel = new QLabel( this ); 94 mAlarmLabel = new QLabel( this );
95 alarmLayout->addWidget( mAlarmLabel ); 95 alarmLayout->addWidget( mAlarmLabel );
96 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); 96 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) );
97 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 97 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
98 mAlarmSoundButton->setOn( true ); 98 mAlarmSoundButton->setOn( true );
99 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); 99 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this );
100 alarmLayout->addWidget( ok ); 100 alarmLayout->addWidget( ok );
101 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 101 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
102 alarmLayout->addWidget( cancel ); 102 alarmLayout->addWidget( cancel );
103 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 103 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
104 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 104 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
105 resize( 200, 200 ); 105 resize( 200, 200 );
106 106
107 } 107 }
108 108
109 109
110 110
111 QString mAlarmSound, mAlarmProgram ; 111 QString mAlarmSound, mAlarmProgram ;
112 QCheckBox* mAlarmButton; 112 QCheckBox* mAlarmButton;
113 QSpinBox* mAlarmTimeEdit; 113 QSpinBox* mAlarmTimeEdit;
114 QLabel* mAlarmLabel; 114 QLabel* mAlarmLabel;
115 QComboBox* mAlarmIncrCombo ; 115 QComboBox* mAlarmIncrCombo ;
116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; 116 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton;
117private slots: 117private slots:
118 118
119void pickAlarmSound() 119void pickAlarmSound()
120{ 120{
121 //QString prefix = mAlarmSound; 121 //QString prefix = mAlarmSound;
122 if (!mAlarmSoundButton->isOn()) { 122 if (!mAlarmSoundButton->isOn()) {
123 //mAlarmSound = ""; 123 //mAlarmSound = "";
124 QToolTip::remove(mAlarmSoundButton); 124 QToolTip::remove(mAlarmSoundButton);
125 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 125 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
126 mAlarmProgramButton->setOn(true); 126 mAlarmProgramButton->setOn(true);
127 mAlarmSoundButton->setOn(false); 127 mAlarmSoundButton->setOn(false);
128 } else { 128 } else {
129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 129 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
130 i18n("*.wav|Wav Files"), 0)); 130 i18n("*.wav|Wav Files"), 0));
131 if (!fileName.isEmpty()) { 131 if (!fileName.isEmpty()) {
132 mAlarmSound = fileName; 132 mAlarmSound = fileName;
133 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 133 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
134 QToolTip::remove(mAlarmSoundButton); 134 QToolTip::remove(mAlarmSoundButton);
135 QString dispStr = i18n("Playing '%1'").arg(fileName); 135 QString dispStr = i18n("Playing '%1'").arg(fileName);
136 QToolTip::add(mAlarmSoundButton, dispStr); 136 QToolTip::add(mAlarmSoundButton, dispStr);
137 mAlarmProgramButton->setOn(false); 137 mAlarmProgramButton->setOn(false);
138 mAlarmSoundButton->setOn(true); 138 mAlarmSoundButton->setOn(true);
139 } else { 139 } else {
140 mAlarmProgramButton->setOn(true); 140 mAlarmProgramButton->setOn(true);
141 mAlarmSoundButton->setOn(false); 141 mAlarmSoundButton->setOn(false);
142 142
143 } 143 }
144 } 144 }
145}; 145};
146 146
147void pickAlarmProgram() 147void pickAlarmProgram()
148{ 148{
149 if (!mAlarmProgramButton->isOn()) { 149 if (!mAlarmProgramButton->isOn()) {
150 //mAlarmProgram = ""; 150 //mAlarmProgram = "";
151 QToolTip::remove(mAlarmProgramButton); 151 QToolTip::remove(mAlarmProgramButton);
152 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 152 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
153 mAlarmProgramButton->setOn(false); 153 mAlarmProgramButton->setOn(false);
154 mAlarmSoundButton->setOn(true); 154 mAlarmSoundButton->setOn(true);
155 } else { 155 } else {
156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 156 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
157 if (!fileName.isEmpty()) { 157 if (!fileName.isEmpty()) {
158 mAlarmProgram = fileName; 158 mAlarmProgram = fileName;
159 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 159 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
160 QToolTip::remove(mAlarmProgramButton); 160 QToolTip::remove(mAlarmProgramButton);
161 QString dispStr = i18n("Running '%1'").arg(fileName); 161 QString dispStr = i18n("Running '%1'").arg(fileName);
162 QToolTip::add(mAlarmProgramButton, dispStr); 162 QToolTip::add(mAlarmProgramButton, dispStr);
163 mAlarmSoundButton->setOn(false); 163 mAlarmSoundButton->setOn(false);
164 mAlarmProgramButton->setOn(true); 164 mAlarmProgramButton->setOn(true);
165 } else { 165 } else {
166 mAlarmProgramButton->setOn(false); 166 mAlarmProgramButton->setOn(false);
167 mAlarmSoundButton->setOn(true); 167 mAlarmSoundButton->setOn(true);
168 } 168 }
169 } 169 }
170}; 170};
171 171
172}; 172};
173 173
174 174
175 175
176 176
177 177
178 178
179 179
180typedef CustomListViewItem<Incidence *> KOListViewItem; 180typedef CustomListViewItem<Incidence *> KOListViewItem;
181 181
182/** 182/**
183 This class provides the initialisation of a KOListViewItem for calendar 183 This class provides the initialisation of a KOListViewItem for calendar
184 components using the Incidence::Visitor. 184 components using the Incidence::Visitor.
185*/ 185*/
186class ListItemVisitor : public Incidence::Visitor 186class ListItemVisitor : public Incidence::Visitor
187{ 187{
188 public: 188 public:
189 ListItemVisitor(KOListViewItem *, QDate d); 189 ListItemVisitor(KOListViewItem *, QDate d);
190 ~ListItemVisitor(); 190 ~ListItemVisitor();
191 191
192 bool visit(Event *); 192 bool visit(Event *);
193 bool visit(Todo *); 193 bool visit(Todo *);
194 bool visit(Journal *); 194 bool visit(Journal *);
195 195
196 private: 196 private:
197 KOListViewItem *mItem; 197 KOListViewItem *mItem;
198 QDate mDate; 198 QDate mDate;
199}; 199};
200 200
201/** 201/**
202 This class provides a multi-column list view of events. It can 202 This class provides a multi-column list view of events. It can
203 display events from one particular day or several days, it doesn't 203 display events from one particular day or several days, it doesn't
204 matter. To use a view that only handles one day at a time, use 204 matter. To use a view that only handles one day at a time, use
205 KODayListView. 205 KODayListView.
206 206
207 @short multi-column list view of various events. 207 @short multi-column list view of various events.
208 @author Preston Brown <pbrown@kde.org> 208 @author Preston Brown <pbrown@kde.org>
209 @see KOBaseView, KODayListView 209 @see KOBaseView, KODayListView
210*/ 210*/
211class KOListView; 211class KOListView;
212 212
213class KOListViewListView : public KListView 213class KOListViewListView : public KListView
214{ 214{
215 Q_OBJECT 215 Q_OBJECT
216 public: 216 public:
217 KOListViewListView(KOListView * lv ); 217 KOListViewListView(KOListView * lv );
218 bool hasMultiSelection(QListViewItem*); 218 bool hasMultiSelection(QListViewItem*);
219 void printList(); 219 void printList();
220 signals: 220 signals:
221 void newEvent(); 221 void newEvent();
222 void showIncidence( Incidence* ); 222 void showIncidence( Incidence* );
223 public slots: 223 public slots:
224 void popupMenu(); 224 void popupMenu();
225 private: 225 private:
226 QPoint mEventPos; 226 QPoint mEventPos;
227 QPoint mEventGlobalPos; 227 QPoint mEventGlobalPos;
228 QTimer* mPopupTimer; 228 QTimer* mPopupTimer;
229 int mYMousePos; 229 int mYMousePos;
230 void keyPressEvent ( QKeyEvent * ) ; 230 void keyPressEvent ( QKeyEvent * ) ;
231 void contentsMouseDoubleClickEvent(QMouseEvent *e); 231 void contentsMouseDoubleClickEvent(QMouseEvent *e);
232 void contentsMousePressEvent(QMouseEvent *e); 232 void contentsMousePressEvent(QMouseEvent *e);
233 void contentsMouseReleaseEvent(QMouseEvent *e); 233 void contentsMouseReleaseEvent(QMouseEvent *e);
234 void contentsMouseMoveEvent(QMouseEvent *e); 234 void contentsMouseMoveEvent(QMouseEvent *e);
235 bool mMouseDown; 235 bool mMouseDown;
236}; 236};
237 237
238class KOListView : public KOEventView 238class KOListView : public KOEventView
239{ 239{
240 Q_OBJECT 240 Q_OBJECT
241 public: 241 public:
242 KOListView(Calendar *calendar, QWidget *parent = 0, 242 KOListView(Calendar *calendar, QWidget *parent = 0,
243 const char *name = 0); 243 const char *name = 0);
244 ~KOListView(); 244 ~KOListView();
245 245
246 virtual int maxDatesHint(); 246 virtual int maxDatesHint();
247 virtual int currentDateCount(); 247 virtual int currentDateCount();
248 virtual QPtrList<Incidence> selectedIncidences(); 248 virtual QPtrList<Incidence> selectedIncidences();
249 virtual DateList selectedDates(); 249 virtual DateList selectedDates();
250 250
251 void showDates(bool show); 251 void showDates(bool show);
252 Incidence* currentItem(); 252 Incidence* currentItem();
253 void addTodos(QPtrList<Todo> eventList); 253 void addTodos(QPtrList<Todo> eventList);
254 void addJournals(QPtrList<Journal> eventList); 254 void addJournals(QPtrList<Journal> eventList);
255 virtual void printPreview(CalPrinter *calPrinter, 255 virtual void printPreview(CalPrinter *calPrinter,
256 const QDate &, const QDate &); 256 const QDate &, const QDate &);
257 257
258 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 258 void readSettings(KConfig *config, QString setting = "KOListView Layout");
259 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 259 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
260 void updateList(); 260 void updateList();
261 void clearList(); 261 void clearList();
262 void setStartDate(const QDate &start); 262 void setStartDate(const QDate &start);
263 int count(); 263 int count();
264 QString getWhatsThisText(QPoint p); 264 QString getWhatsThisText(QPoint p);
265 QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false ); 265 QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false );
266 signals: 266 signals:
267 void signalNewEvent(); 267 void signalNewEvent();
268 void beamIncidenceList(QPtrList<Incidence>); 268 void beamIncidenceList(QPtrList<Incidence>);
269 269
270 public slots: 270 public slots:
271 void hideAll(); 271 void hideAll();
272 void printList(); 272 void printList();
273 void resetFocus(); 273 void resetFocus();
274 virtual void updateView(); 274 virtual void updateView();
275 virtual void showDates(const QDate &start, const QDate &end); 275 virtual void showDates(const QDate &start, const QDate &end);
276 virtual void showEvents(QPtrList<Event> eventList); 276 virtual void showEvents(QPtrList<Event> eventList);
277 void clearSelection(); 277 void clearSelection();
278 void allSelection(); 278 void allSelection();
279 279
280 void clear(); 280 void clear();
281 void beamDone( Ir *ir ); 281 void beamDone( Ir *ir );
282 void showDates(); 282 void showDates();
283 void hideDates(); 283 void hideDates();
284 void deleteAll(); 284 void deleteAll();
285 void saveToFile(); 285 void saveToFile();
286 void saveToFileVCS(); 286 void saveToFileVCS();
287 void saveDescriptionToFile(); 287 void saveDescriptionToFile();
288 void beamSelected(); 288 void beamSelected();
289 void updateConfig(); 289 void updateConfig();
290 void addCat(); 290 void addCat();
291 void setCat(); 291 void setCat();
292 void setAlarm(); 292 void setAlarm();
293 void setCategories( bool removeOld ); 293 void setCategories( bool removeOld );
294 void changeEventDisplay(Event *, int); 294 void changeEventDisplay(Event *, int);
295 295
296 void defaultItemAction(QListViewItem *item); 296 void defaultItemAction(QListViewItem *item);
297 void popupMenu(QListViewItem *item,const QPoint &,int); 297 void popupMenu(QListViewItem *item,const QPoint &,int);
298 void setCalendar( int c );
299 void populateCalPopup();
298 300
299 protected slots: 301 protected slots:
300 void processSelectionChange(QListViewItem *); 302 void processSelectionChange(QListViewItem *);
301 303
302 protected: 304 protected:
303 void writeToFile( bool iCal ); 305 void writeToFile( bool iCal );
304 void addEvents(QPtrList<Event> eventList); 306 void addEvents(QPtrList<Event> eventList);
305 void addIncidence(Incidence *); 307 void addIncidence(Incidence *);
306 KOListViewItem *getItemForEvent(Event *event); 308 KOListViewItem *getItemForEvent(Incidence *event);
307 309
308 private: 310 private:
311 QPopupMenu* mCalPopup;
309 KOListViewWhatsThis *mKOListViewWhatsThis; 312 KOListViewWhatsThis *mKOListViewWhatsThis;
310 KOListViewListView *mListView; 313 KOListViewListView *mListView;
311 KOEventPopupMenu *mPopupMenu; 314 KOEventPopupMenu *mPopupMenu;
312 KOListViewItem *mActiveItem; 315 KOListViewItem *mActiveItem;
313 QDict<Incidence> mUidDict; 316 QDict<Incidence> mUidDict;
314 QDate mStartDate; 317 QDate mStartDate;
315 void keyPressEvent ( QKeyEvent * ) ; 318 void keyPressEvent ( QKeyEvent * ) ;
316}; 319};
317 320
318#endif 321#endif
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 65f0342..a4ea3d3 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,595 +1,599 @@
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 <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kglobalsettings.h> 39#include <kglobalsettings.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <klocale.h> 41#include <klocale.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kemailsettings.h> 43#include <kemailsettings.h>
44#include <kstaticdeleter.h> 44#include <kstaticdeleter.h>
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48#include "mainwindow.h" 48#include "mainwindow.h"
49 49
50KOPrefs *KOPrefs::mInstance = 0; 50KOPrefs *KOPrefs::mInstance = 0;
51static KStaticDeleter<KOPrefs> insd; 51static KStaticDeleter<KOPrefs> insd;
52 52
53KOPrefs::KOPrefs() : 53KOPrefs::KOPrefs() :
54 KPimPrefs("korganizerrc") 54 KPimPrefs("korganizerrc")
55{ 55{
56 mCategoryColors.setAutoDelete(true); 56 mCategoryColors.setAutoDelete(true);
57 fillMailDefaults(); 57 fillMailDefaults();
58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
59 QColor defaultHolidayColor = QColor(255,0,0); 59 QColor defaultHolidayColor = QColor(255,0,0);
60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
63 QColor defaultTodoDueTodayColor = QColor(255,220,100); 63 QColor defaultTodoDueTodayColor = QColor(255,220,100);
64 QColor defaultTodoOverdueColor = QColor(255,153,125); 64 QColor defaultTodoOverdueColor = QColor(255,153,125);
65 QColor defaultTodoRunColor = QColor(99,194,30); 65 QColor defaultTodoRunColor = QColor(99,194,30);
66 KPrefs::setCurrentGroup("General"); 66 KPrefs::setCurrentGroup("General");
67 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 67 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
68 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 68 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
69 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 69 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
70 addItemBool("ShowIconSearch",&mShowIconSearch,true); 70 addItemBool("ShowIconSearch",&mShowIconSearch,true);
71 addItemBool("ShowIconList",&mShowIconList,true); 71 addItemBool("ShowIconList",&mShowIconList,true);
72 addItemBool("ShowIconDay1",&mShowIconDay1,true); 72 addItemBool("ShowIconDay1",&mShowIconDay1,true);
73 addItemBool("ShowIconDay5",&mShowIconDay5,true); 73 addItemBool("ShowIconDay5",&mShowIconDay5,true);
74 addItemBool("ShowIconDay6",&mShowIconDay6,true); 74 addItemBool("ShowIconDay6",&mShowIconDay6,true);
75 addItemBool("ShowIconDay7",&mShowIconDay7,true); 75 addItemBool("ShowIconDay7",&mShowIconDay7,true);
76 addItemBool("ShowIconMonth",&mShowIconMonth,true); 76 addItemBool("ShowIconMonth",&mShowIconMonth,true);
77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 77 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 78 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
79 addItemBool("ShowIconBack",&mShowIconBack,true); 79 addItemBool("ShowIconBack",&mShowIconBack,true);
80 addItemBool("ShowIconToday",&mShowIconToday,true); 80 addItemBool("ShowIconToday",&mShowIconToday,true);
81 addItemBool("ShowIconForward",&mShowIconForward,true); 81 addItemBool("ShowIconForward",&mShowIconForward,true);
82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 82 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); 83 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true); 84 addItemBool("ShowIconWeekNum",&mShowIconWeekNum,true);
85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 85 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
86 addItemBool("ShowIconNext",&mShowIconNext,true); 86 addItemBool("ShowIconNext",&mShowIconNext,true);
87 addItemBool("ShowIconJournal",&mShowIconJournal,true); 87 addItemBool("ShowIconJournal",&mShowIconJournal,true);
88 addItemBool("ShowIconStretch",&mShowIconStretch,true); 88 addItemBool("ShowIconStretch",&mShowIconStretch,true);
89 addItemBool("ShowIconFilter",&mShowIconFilter,false); 89 addItemBool("ShowIconFilter",&mShowIconFilter,false);
90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true); 90 addItemBool("ShowIconOnetoolbar",&mShowIconOnetoolbar,true);
91 91
92 bool addIcons = false; 92 bool addIcons = false;
93#ifdef DESKTOP_VERSION 93#ifdef DESKTOP_VERSION
94 addIcons = true; 94 addIcons = true;
95#endif 95#endif
96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons); 96 addItemBool("ShowIconNavigator",&mShowIconNavigator,addIcons);
97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons); 97 addItemBool("ShowIconAllday",&mShowIconAllday,addIcons);
98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons); 98 addItemBool("ShowIconFilterview",&mShowIconFilterview,addIcons);
99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons); 99 addItemBool("ShowIconToggleFull",&mShowIconToggleFull,addIcons);
100 100
101 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 101 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
102 102
103 addItemBool("AskForQuit",&mAskForQuit,false); 103 addItemBool("AskForQuit",&mAskForQuit,false);
104 104
105#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
106 addItemBool("ShowFullMenu",&mShowFullMenu,false); 106 addItemBool("ShowFullMenu",&mShowFullMenu,false);
107#else 107#else
108 addItemBool("ShowFullMenu",&mShowFullMenu,true); 108 addItemBool("ShowFullMenu",&mShowFullMenu,true);
109#endif 109#endif
110 addItemBool("ToolBarHor",&mToolBarHor, true ); 110 addItemBool("ToolBarHor",&mToolBarHor, true );
111 addItemBool("ToolBarUp",&mToolBarUp, false ); 111 addItemBool("ToolBarUp",&mToolBarUp, false );
112 addItemBool("ToolBarHorV",&mToolBarHorV, true ); 112 addItemBool("ToolBarHorV",&mToolBarHorV, true );
113 addItemBool("ToolBarUpV",&mToolBarUpV, false ); 113 addItemBool("ToolBarUpV",&mToolBarUpV, false );
114 addItemBool("ToolBarHorN",&mToolBarHorN, true ); 114 addItemBool("ToolBarHorN",&mToolBarHorN, true );
115 addItemBool("ToolBarUpN",&mToolBarUpN, false ); 115 addItemBool("ToolBarUpN",&mToolBarUpN, false );
116 addItemBool("ToolBarHorF",&mToolBarHorF, true ); 116 addItemBool("ToolBarHorF",&mToolBarHorF, true );
117 addItemBool("ToolBarUpF",&mToolBarUpF, false ); 117 addItemBool("ToolBarUpF",&mToolBarUpF, false );
118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 118 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
119 addItemInt("Whats Next Days",&mWhatsNextDays,3); 119 addItemInt("Whats Next Days",&mWhatsNextDays,3);
120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 120 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
121 121
122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 122 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true); 123 addItemBool("ShowCompletedTodoInAgenda",&mShowCompletedTodoInAgenda,true);
124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); 124 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true);
125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); 125 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false);
126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 126 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
127 addItemInt("AllDay Size",&mAllDaySize,28); 127 addItemInt("AllDay Size",&mAllDaySize,28);
128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 128 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 129 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
130 130
131 addItemStringList("LocationDefaults",&mLocationDefaults ); 131 addItemStringList("LocationDefaults",&mLocationDefaults );
132 addItemStringList("EventSummary User",&mEventSummaryUser); 132 addItemStringList("EventSummary User",&mEventSummaryUser);
133 addItemStringList("TodoSummary User",&mTodoSummaryUser); 133 addItemStringList("TodoSummary User",&mTodoSummaryUser);
134 134
135 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 135 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
136 addItemBool("Enable Project View",&mEnableProjectView,false); 136 addItemBool("Enable Project View",&mEnableProjectView,false);
137 addItemBool("Auto Save",&mAutoSave,false); 137 addItemBool("Auto Save",&mAutoSave,false);
138 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 138 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
139 addItemBool("Confirm Deletes",&mConfirm,true); 139 addItemBool("Confirm Deletes",&mConfirm,true);
140 addItemString("Archive File",&mArchiveFile); 140 addItemString("Archive File",&mArchiveFile);
141 addItemString("Html Export File",&mHtmlExportFile, 141 addItemString("Html Export File",&mHtmlExportFile,
142 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 142 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
143 addItemBool("Html With Save",&mHtmlWithSave,false); 143 addItemBool("Html With Save",&mHtmlWithSave,false);
144 144
145 KPrefs::setCurrentGroup("Personal Settings"); 145 KPrefs::setCurrentGroup("Personal Settings");
146 146
147 addItemInt("Mail Client",&mMailClient,MailClientKMail); 147 addItemInt("Mail Client",&mMailClient,MailClientKMail);
148 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 148 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
149 addItemBool("Bcc",&mBcc,false); 149 addItemBool("Bcc",&mBcc,false);
150 150
151 KPrefs::setCurrentGroup("Time & Date"); 151 KPrefs::setCurrentGroup("Time & Date");
152 152
153 153
154 addItemInt("Default Start Time",&mStartTime,10); 154 addItemInt("Default Start Time",&mStartTime,10);
155 addItemInt("Default Duration",&mDefaultDuration,2); 155 addItemInt("Default Duration",&mDefaultDuration,2);
156 addItemInt("Default Alarm Time",&mAlarmTime,3); 156 addItemInt("Default Alarm Time",&mAlarmTime,3);
157 KPrefs::setCurrentGroup("AlarmSettings"); 157 KPrefs::setCurrentGroup("AlarmSettings");
158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 158 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 159 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 160 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 161 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
162 162
163 163
164 KPrefs::setCurrentGroup("Calendar"); 164 KPrefs::setCurrentGroup("Calendar");
165 165
166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 166 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
167 167
168 KPrefs::setCurrentGroup("Fonts"); 168 KPrefs::setCurrentGroup("Fonts");
169 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 169 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
170 QFont fon = KGlobalSettings::generalFont(); 170 QFont fon = KGlobalSettings::generalFont();
171 addItemFont("TimeBar Font",&mTimeBarFont,fon ); 171 addItemFont("TimeBar Font",&mTimeBarFont,fon );
172 addItemFont("MonthView Font",&mMonthViewFont,fon); 172 addItemFont("MonthView Font",&mMonthViewFont,fon);
173 addItemFont("AgendaView Font",&mAgendaViewFont,fon); 173 addItemFont("AgendaView Font",&mAgendaViewFont,fon);
174 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon); 174 addItemFont("MarcusBains Font",&mMarcusBainsFont,fon);
175 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon); 175 addItemFont("TimeLabels Font",&mTimeLabelsFont,fon);
176 addItemFont("TodoView Font",&mTodoViewFont,fon); 176 addItemFont("TodoView Font",&mTodoViewFont,fon);
177 addItemFont("ListView Font",&mListViewFont,fon); 177 addItemFont("ListView Font",&mListViewFont,fon);
178 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon); 178 addItemFont("DateNavigator Font",&mDateNavigatorFont,fon);
179 addItemFont("EditBox Font",&mEditBoxFont,fon); 179 addItemFont("EditBox Font",&mEditBoxFont,fon);
180 addItemFont("JournalView Font",&mJornalViewFont,fon); 180 addItemFont("JournalView Font",&mJornalViewFont,fon);
181 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon); 181 addItemFont("WhatsNextView Font",&mWhatsNextFont,fon);
182 addItemFont("EventView Font",&mEventViewFont,fon); 182 addItemFont("EventView Font",&mEventViewFont,fon);
183 183
184 KPrefs::setCurrentGroup("RemoteSyncing"); 184 KPrefs::setCurrentGroup("RemoteSyncing");
185 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 185 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
186 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 186 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
187 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 187 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
188 addItemInt("LastSyncTime",&mLastSyncTime,0); 188 addItemInt("LastSyncTime",&mLastSyncTime,0);
189 189
190#ifdef _WIN32_ 190#ifdef _WIN32_
191 QString hdp= locateLocal("data","korganizer")+"\\\\"; 191 QString hdp= locateLocal("data","korganizer")+"\\\\";
192#else 192#else
193 QString hdp= locateLocal("data","korganizer")+"/"; 193 QString hdp= locateLocal("data","korganizer")+"/";
194#endif 194#endif
195 195
196 KPrefs::setCurrentGroup("LoadSaveFileNames"); 196 KPrefs::setCurrentGroup("LoadSaveFileNames");
197 197
198 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 198 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
199 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 199 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
200 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 200 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
201 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 201 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
202 202
203 203
204 KPrefs::setCurrentGroup("Locale"); 204 KPrefs::setCurrentGroup("Locale");
205 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 205 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
206 206
207 207
208 KPrefs::setCurrentGroup("Colors"); 208 KPrefs::setCurrentGroup("Colors");
209 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 209 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
210 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 210 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
211 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 211 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
212 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); 212 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) );
213 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 213 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
214 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 214 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
215 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 215 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
216 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 216 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
217 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor); 217 addItemColor("Todo running Color",&mTodoRunColor,defaultTodoRunColor);
218 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 218 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
219 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 219 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
220 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 220 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
221 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 221 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
222 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 222 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
223 addItemBool("MonthViewWeek",&mMonthViewWeek,false); 223 addItemBool("MonthViewWeek",&mMonthViewWeek,false);
224 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 224 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
225 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 225 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
226 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 226 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
227 addItemBool("UseAppColors",&mUseAppColors,false); 227 addItemBool("UseAppColors",&mUseAppColors,false);
228 228
229 229
230 230
231 KPrefs::setCurrentGroup("Views"); 231 KPrefs::setCurrentGroup("Views");
232 addItemBool("Block Popup Menu",&mBlockPopupMenu,true); 232 addItemBool("Block Popup Menu",&mBlockPopupMenu,true);
233 addItemBool("Show Date Navigator",&mShowDateNavigator,true); 233 addItemBool("Show Date Navigator",&mShowDateNavigator,true);
234 addItemInt("Hour Size",&mHourSize,8); 234 addItemInt("Hour Size",&mHourSize,8);
235 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 235 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
236 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 236 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
237 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 237 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
238 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 238 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
239 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 239 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
240 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 240 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
241 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true); 241 addItemBool("ShowTimesInMonthCell",&mMonthShowTimes,true);
242#ifdef DESKTOP_VERION 242#ifdef DESKTOP_VERION
243 addItemBool("Enable ToolTips",&mEnableToolTips,true); 243 addItemBool("Enable ToolTips",&mEnableToolTips,true);
244#else 244#else
245 addItemBool("Enable ToolTips",&mEnableToolTips,false); 245 addItemBool("Enable ToolTips",&mEnableToolTips,false);
246#endif 246#endif
247 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 247 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
248 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 248 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
249 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 249 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
250 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 250 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
251 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); 251 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true);
252 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 252 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
253 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 253 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
254 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 254 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
255 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 255 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
256 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; 256 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);;
257 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); 257 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true);
258 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 258 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
259 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 259 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
260 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 260 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
261 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 261 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
262 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 262 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
263 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); 263 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true);
264 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); 264 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true);
265 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 265 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
266 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 266 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
267#ifdef DESKTOP_VERSION 267#ifdef DESKTOP_VERSION
268 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 268 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
269#else 269#else
270 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 270 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
271#endif 271#endif
272 addItemInt("Day Begins",&mDayBegins,7); 272 addItemInt("Day Begins",&mDayBegins,7);
273 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 273 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
274 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 274 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
275 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 275 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
276 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 276 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
277 277
278 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 278 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
279 addItemBool("Full View Month",&mFullViewMonth,true); 279 addItemBool("Full View Month",&mFullViewMonth,true);
280 addItemBool("Full View Todo",&mFullViewTodo,true); 280 addItemBool("Full View Todo",&mFullViewTodo,true);
281 addItemBool("Quick Todo",&mEnableQuickTodo,false); 281 addItemBool("Quick Todo",&mEnableQuickTodo,false);
282 282
283 addItemInt("Next X Days",&mNextXDays,3); 283 addItemInt("Next X Days",&mNextXDays,3);
284 284
285 KPrefs::setCurrentGroup("Printer"); 285 KPrefs::setCurrentGroup("Printer");
286 286
287 KPrefs::setCurrentGroup("Layout"); 287 KPrefs::setCurrentGroup("Layout");
288 288
289 addItemBool("CompactDialogs",&mCompactDialogs,false); 289 addItemBool("CompactDialogs",&mCompactDialogs,false);
290 addItemBool("VerticalScreen",&mVerticalScreen,true); 290 addItemBool("VerticalScreen",&mVerticalScreen,true);
291 291
292 KPrefs::setCurrentGroup("KOrganizer Plugins"); 292 KPrefs::setCurrentGroup("KOrganizer Plugins");
293 293
294 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 294 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
295 295
296 KPrefs::setCurrentGroup("Group Scheduling"); 296 KPrefs::setCurrentGroup("Group Scheduling");
297 297
298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 298 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 299 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
300 addItemStringList("AdditionalMails",&mAdditionalMails,""); 300 addItemStringList("AdditionalMails",&mAdditionalMails,"");
301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 301 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 302 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 303 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 304 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 305 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
306 306
307 KPrefs::setCurrentGroup( "Editors" ); 307 KPrefs::setCurrentGroup( "Editors" );
308 308
309 addItemStringList( "EventTemplates", &mEventTemplates ); 309 addItemStringList( "EventTemplates", &mEventTemplates );
310 addItemStringList( "TodoTemplates", &mTodoTemplates ); 310 addItemStringList( "TodoTemplates", &mTodoTemplates );
311 311
312 addItemInt("DestinationPolicy",&mDestination,standardDestination); 312 addItemInt("DestinationPolicy",&mDestination,standardDestination);
313 313
314 KPrefs::setCurrentGroup( "ViewOptions" ); 314 KPrefs::setCurrentGroup( "ViewOptions" );
315 addItemBool("EVshowDetails",&mEVshowDetails,true); 315 addItemBool("EVshowDetails",&mEVshowDetails,true);
316 addItemBool("EVshowCreated",&mEVshowCreated,true); 316 addItemBool("EVshowCreated",&mEVshowCreated,true);
317 addItemBool("EVshowChanged",&mEVshowChanged,true); 317 addItemBool("EVshowChanged",&mEVshowChanged,true);
318 addItemBool("WTshowDetails",&mWTshowDetails,false); 318 addItemBool("WTshowDetails",&mWTshowDetails,false);
319 addItemBool("WTshowCreated",&mWTshowCreated,false); 319 addItemBool("WTshowCreated",&mWTshowCreated,false);
320 addItemBool("WTshowChanged",&mWTshowChanged,false); 320 addItemBool("WTshowChanged",&mWTshowChanged,false);
321 mCalendars.setAutoDelete( true ); 321 mCalendars.setAutoDelete( true );
322} 322}
323 323
324 324
325KOPrefs::~KOPrefs() 325KOPrefs::~KOPrefs()
326{ 326{
327 if (mInstance == this) 327 if (mInstance == this)
328 mInstance = insd.setObject(0); 328 mInstance = insd.setObject(0);
329 mCalendars.setAutoDelete( true ); 329 mCalendars.setAutoDelete( true );
330 mCalendars.clear(); 330 mCalendars.clear();
331 //qDebug("KOPrefs::~KOPrefs() "); 331 //qDebug("KOPrefs::~KOPrefs() ");
332} 332}
333 333
334 334
335KOPrefs *KOPrefs::instance() 335KOPrefs *KOPrefs::instance()
336{ 336{
337 if (!mInstance) { 337 if (!mInstance) {
338 mInstance = insd.setObject(new KOPrefs()); 338 mInstance = insd.setObject(new KOPrefs());
339 mInstance->readConfig(); 339 mInstance->readConfig();
340 } 340 }
341 341
342 return mInstance; 342 return mInstance;
343} 343}
344 344
345void KOPrefs::usrSetDefaults() 345void KOPrefs::usrSetDefaults()
346{ 346{
347 347
348} 348}
349 349
350void KOPrefs::fillMailDefaults() 350void KOPrefs::fillMailDefaults()
351{ 351{
352 if (mName.isEmpty()) mName = i18n("Anonymous"); 352 if (mName.isEmpty()) mName = i18n("Anonymous");
353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 353 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
354} 354}
355 355
356void KOPrefs::setTimeZoneIdDefault() 356void KOPrefs::setTimeZoneIdDefault()
357{ 357{
358 ; 358 ;
359} 359}
360 360
361void KOPrefs::setAllDefaults() 361void KOPrefs::setAllDefaults()
362{ 362{
363 setCategoryDefaults(); 363 setCategoryDefaults();
364 mEventSummaryUser = getDefaultList() ; 364 mEventSummaryUser = getDefaultList() ;
365 mTodoSummaryUser = getDefaultList() ; 365 mTodoSummaryUser = getDefaultList() ;
366 mLocationDefaults = getLocationDefaultList(); 366 mLocationDefaults = getLocationDefaultList();
367} 367}
368 368
369void KOPrefs::setCategoryDefaults() 369void KOPrefs::setCategoryDefaults()
370{ 370{
371 mCustomCategories.clear(); 371 mCustomCategories.clear();
372 mCustomCategories = getDefaultList(); 372 mCustomCategories = getDefaultList();
373 373
374 QStringList::Iterator it; 374 QStringList::Iterator it;
375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 375 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
376 setCategoryColor(*it,mDefaultCategoryColor); 376 setCategoryColor(*it,mDefaultCategoryColor);
377 } 377 }
378} 378}
379QStringList KOPrefs::getLocationDefaultList() 379QStringList KOPrefs::getLocationDefaultList()
380{ 380{
381 QStringList retval ; 381 QStringList retval ;
382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 382 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 383 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 384 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 385 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 386 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
387 387
388 retval.sort(); 388 retval.sort();
389 return retval; 389 return retval;
390} 390}
391QStringList KOPrefs::getDefaultList() 391QStringList KOPrefs::getDefaultList()
392{ 392{
393 QStringList retval ; 393 QStringList retval ;
394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 394 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
395 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 395 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
396 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 396 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 397 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
398 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 398 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
399 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 399 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
400 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 400 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 401 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
402 retval.sort(); 402 retval.sort();
403 //qDebug("cat %s ", retval.join("-").latin1()); 403 //qDebug("cat %s ", retval.join("-").latin1());
404 return retval; 404 return retval;
405} 405}
406 406
407void KOPrefs::usrReadConfig() 407void KOPrefs::usrReadConfig()
408{ 408{
409 config()->setGroup("General"); 409 config()->setGroup("General");
410 410
411 //qDebug("KOPrefs::usrReadConfig() "); 411 //qDebug("KOPrefs::usrReadConfig() ");
412 mCustomCategories = config()->readListEntry("Custom Categories"); 412 mCustomCategories = config()->readListEntry("Custom Categories");
413 mOldLoadedLanguage = mOldLanguage ; 413 mOldLoadedLanguage = mOldLanguage ;
414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 414 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
415 if (mLocationDefaults.isEmpty()) { 415 if (mLocationDefaults.isEmpty()) {
416 mLocationDefaults = getLocationDefaultList(); 416 mLocationDefaults = getLocationDefaultList();
417 } 417 }
418 418
419 if (mEventSummaryUser.isEmpty()) { 419 if (mEventSummaryUser.isEmpty()) {
420 mEventSummaryUser = getDefaultList() ; 420 mEventSummaryUser = getDefaultList() ;
421 } 421 }
422 if (mTodoSummaryUser.isEmpty()) { 422 if (mTodoSummaryUser.isEmpty()) {
423 mTodoSummaryUser = getDefaultList() ; 423 mTodoSummaryUser = getDefaultList() ;
424 } 424 }
425 425
426 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 426 if (mCustomCategories.isEmpty()) setCategoryDefaults();
427 427
428 config()->setGroup("Personal Settings"); 428 config()->setGroup("Personal Settings");
429 mName = config()->readEntry("user_name",""); 429 mName = config()->readEntry("user_name","");
430 mEmail = config()->readEntry("user_email",""); 430 mEmail = config()->readEntry("user_email","");
431 fillMailDefaults(); 431 fillMailDefaults();
432 432
433 config()->setGroup("Category Colors"); 433 config()->setGroup("Category Colors");
434 QStringList::Iterator it; 434 QStringList::Iterator it;
435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 435 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 436 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
437 437
438 } 438 }
439 KConfig fc (locateLocal("config","kopicalendarrc")); 439 KConfig fc (locateLocal("config","kopicalendarrc"));
440 fc.setGroup("CC"); 440 fc.setGroup("CC");
441 int numCals = fc.readNumEntry("NumberCalendars",0 ); 441 int numCals = fc.readNumEntry("NumberCalendars",0 );
442 mNextAvailableCalendar = 1; 442 mNextAvailableCalendar = 1;
443 if ( numCals == 0 ) { 443 if ( numCals == 0 ) {
444 KopiCalendarFile *kkf = getNewCalendar(); 444 KopiCalendarFile *kkf = getNewCalendar();
445 kkf->isStandard = true; 445 kkf->isStandard = true;
446 kkf->mName = i18n("Standard"); 446 kkf->mName = i18n("Standard");
447 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 447 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
448 } 448 }
449 while ( mNextAvailableCalendar <= numCals ) { 449 while ( mNextAvailableCalendar <= numCals ) {
450 //qDebug("Read cal #%d ", mNextAvailableCalendar ); 450 //qDebug("Read cal #%d ", mNextAvailableCalendar );
451 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar ); 451 QString prefix = "Cal_" +QString::number( mNextAvailableCalendar );
452 KopiCalendarFile *kkf = getNewCalendar(); 452 KopiCalendarFile *kkf = getNewCalendar();
453 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false ); 453 kkf->isStandard = fc.readBoolEntry( prefix+"_isStandard", false );
454 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true); 454 kkf->isEnabled = fc.readBoolEntry( prefix+"_isEnabled", true);
455 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true); 455 kkf->isAlarmEnabled = fc.readBoolEntry( prefix+"_isAlarmEnabled", true);
456 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false); 456 kkf->isReadOnly = fc.readBoolEntry( prefix+"_isReadOnly", false);
457 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar"); 457 kkf->mName = fc.readEntry( prefix+"_Name", "Calendar");
458 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName); 458 kkf->mFileName = fc.readEntry( prefix+"_FileName", kkf->mFileName);
459 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor); 459 kkf->mDefaultColor = fc.readColorEntry( prefix+"_Color",&mEventColor);
460 if ( kkf->mCalNumber == 1 ) { 460 if ( kkf->mCalNumber == 1 ) {
461 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" ); 461 kkf->mFileName = locateLocal( "data", "korganizer/mycalendar.ics" );
462 } 462 }
463 } 463 }
464 464
465 KPimPrefs::usrReadConfig(); 465 KPimPrefs::usrReadConfig();
466} 466}
467 467
468KopiCalendarFile * KOPrefs::getCalendar( int num ) 468KopiCalendarFile * KOPrefs::getCalendar( int num )
469{ 469{
470 return mDefCalColors[num-1]; 470 return mDefCalColors[num-1];
471} 471}
472 472
473KopiCalendarFile * KOPrefs::getNewCalendar() 473KopiCalendarFile * KOPrefs::getNewCalendar()
474{ 474{
475 KopiCalendarFile * kkf = new KopiCalendarFile(); 475 KopiCalendarFile * kkf = new KopiCalendarFile();
476 kkf->mCalNumber = mNextAvailableCalendar; 476 kkf->mCalNumber = mNextAvailableCalendar;
477 mDefCalColors.resize( mNextAvailableCalendar ); 477 mDefCalColors.resize( mNextAvailableCalendar );
478 mDefCalColors[mNextAvailableCalendar-1] = kkf; 478 mDefCalColors[mNextAvailableCalendar-1] = kkf;
479 ++mNextAvailableCalendar; 479 ++mNextAvailableCalendar;
480 kkf->mDefaultColor = mEventColor; 480 kkf->mDefaultColor = mEventColor;
481 kkf->mName = i18n("New Calendar"); 481 kkf->mName = i18n("New Calendar");
482 mCalendars.append( kkf ); 482 mCalendars.append( kkf );
483 return kkf; 483 return kkf;
484} 484}
485void KOPrefs::deleteCalendar( int num ) 485void KOPrefs::deleteCalendar( int num )
486{ 486{
487 KopiCalendarFile * kkf = mCalendars.first(); 487 KopiCalendarFile * kkf = mCalendars.first();
488 while ( kkf ) { 488 while ( kkf ) {
489 if ( kkf->mCalNumber == num ) { 489 if ( kkf->mCalNumber == num ) {
490 qDebug("KOPrefs::deleteCalendar %d ", num ); 490 qDebug("KOPrefs::deleteCalendar %d ", num );
491 mCalendars.remove( kkf ); 491 mCalendars.remove( kkf );
492 delete kkf; 492 delete kkf;
493 return; 493 return;
494 } 494 }
495 kkf = mCalendars.next(); 495 kkf = mCalendars.next();
496 } 496 }
497} 497}
498QString KOPrefs::calName( int calNum) const
499{
500 return (mDefCalColors[calNum-1])->mName;
501}
498QColor KOPrefs::defaultColor( int calNum ) const 502QColor KOPrefs::defaultColor( int calNum ) const
499{ 503{
500 if ( calNum == 1 ) return mEventColor; 504 if ( calNum == 1 ) return mEventColor;
501 return (mDefCalColors[calNum-1])->mDefaultColor; 505 return (mDefCalColors[calNum-1])->mDefaultColor;
502} 506}
503void KOPrefs::usrWriteConfig() 507void KOPrefs::usrWriteConfig()
504{ 508{
505 config()->setGroup("General"); 509 config()->setGroup("General");
506 config()->writeEntry("Custom Categories",mCustomCategories); 510 config()->writeEntry("Custom Categories",mCustomCategories);
507 511
508 config()->setGroup("Personal Settings"); 512 config()->setGroup("Personal Settings");
509 config()->writeEntry("user_name",mName); 513 config()->writeEntry("user_name",mName);
510 config()->writeEntry("user_email",mEmail); 514 config()->writeEntry("user_email",mEmail);
511 515
512 config()->setGroup("Category Colors"); 516 config()->setGroup("Category Colors");
513 QDictIterator<QColor> it(mCategoryColors); 517 QDictIterator<QColor> it(mCategoryColors);
514 while (it.current()) { 518 while (it.current()) {
515 config()->writeEntry(it.currentKey(),*(it.current())); 519 config()->writeEntry(it.currentKey(),*(it.current()));
516 ++it; 520 ++it;
517 } 521 }
518 KConfig fc (locateLocal("config","kopicalendarrc")); 522 KConfig fc (locateLocal("config","kopicalendarrc"));
519 fc.setGroup("CC"); 523 fc.setGroup("CC");
520 fc.writeEntry("NumberCalendars",mCalendars.count()); 524 fc.writeEntry("NumberCalendars",mCalendars.count());
521 int numCal = 1; 525 int numCal = 1;
522 int writeCal = 0; 526 int writeCal = 0;
523 while ( numCal < mNextAvailableCalendar ) { 527 while ( numCal < mNextAvailableCalendar ) {
524 KopiCalendarFile * kkf = mCalendars.first(); 528 KopiCalendarFile * kkf = mCalendars.first();
525 while ( kkf ) { 529 while ( kkf ) {
526 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal); 530 //qDebug("cal num %d %d ", kkf->mCalNumber, numCal);
527 if ( kkf->mCalNumber == numCal ) { 531 if ( kkf->mCalNumber == numCal ) {
528 ++writeCal; 532 ++writeCal;
529 //qDebug("Write calendar %d %d ", numCal , writeCal); 533 //qDebug("Write calendar %d %d ", numCal , writeCal);
530 QString prefix = "Cal_" + QString::number( writeCal ); 534 QString prefix = "Cal_" + QString::number( writeCal );
531 fc.writeEntry( prefix+"_isStandard", kkf->isStandard ); 535 fc.writeEntry( prefix+"_isStandard", kkf->isStandard );
532 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled ); 536 fc.writeEntry( prefix+"_isEnabled", kkf->isEnabled );
533 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled ); 537 fc.writeEntry( prefix+"_isAlarmEnabled", kkf->isAlarmEnabled );
534 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly ); 538 fc.writeEntry( prefix+"_isReadOnly", kkf->isReadOnly );
535 fc.writeEntry( prefix+"_Name", kkf->mName); 539 fc.writeEntry( prefix+"_Name", kkf->mName);
536 fc.writeEntry( prefix+"_FileName", kkf->mFileName); 540 fc.writeEntry( prefix+"_FileName", kkf->mFileName);
537 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor); 541 fc.writeEntry( prefix+"_Color",kkf->mDefaultColor);
538 } 542 }
539 kkf = mCalendars.next(); 543 kkf = mCalendars.next();
540 } 544 }
541 ++numCal; 545 ++numCal;
542 } 546 }
543 fc.sync(); 547 fc.sync();
544 KPimPrefs::usrWriteConfig(); 548 KPimPrefs::usrWriteConfig();
545} 549}
546 550
547void KOPrefs::setCategoryColor(QString cat,const QColor & color) 551void KOPrefs::setCategoryColor(QString cat,const QColor & color)
548{ 552{
549 mCategoryColors.replace(cat,new QColor(color)); 553 mCategoryColors.replace(cat,new QColor(color));
550} 554}
551 555
552QColor *KOPrefs::categoryColor(QString cat) 556QColor *KOPrefs::categoryColor(QString cat)
553{ 557{
554 QColor *color = 0; 558 QColor *color = 0;
555 559
556 if (!cat.isEmpty()) color = mCategoryColors[cat]; 560 if (!cat.isEmpty()) color = mCategoryColors[cat];
557 561
558 if (color) return color; 562 if (color) return color;
559 else return &mDefaultCategoryColor; 563 else return &mDefaultCategoryColor;
560} 564}
561 565
562void KOPrefs::setFullName(const QString &name) 566void KOPrefs::setFullName(const QString &name)
563{ 567{
564 mName = name; 568 mName = name;
565} 569}
566 570
567void KOPrefs::setEmail(const QString &email) 571void KOPrefs::setEmail(const QString &email)
568{ 572{
569 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 573 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
570 mEmail = email; 574 mEmail = email;
571} 575}
572 576
573QString KOPrefs::fullName() 577QString KOPrefs::fullName()
574{ 578{
575 if (mEmailControlCenter) { 579 if (mEmailControlCenter) {
576 KEMailSettings settings; 580 KEMailSettings settings;
577 return settings.getSetting(KEMailSettings::RealName); 581 return settings.getSetting(KEMailSettings::RealName);
578 } else { 582 } else {
579 return mName; 583 return mName;
580 } 584 }
581} 585}
582 586
583QString KOPrefs::email() 587QString KOPrefs::email()
584{ 588{
585 if (mEmailControlCenter) { 589 if (mEmailControlCenter) {
586 KEMailSettings settings; 590 KEMailSettings settings;
587 return settings.getSetting(KEMailSettings::EmailAddress); 591 return settings.getSetting(KEMailSettings::EmailAddress);
588 } else { 592 } else {
589 return mEmail; 593 return mEmail;
590 } 594 }
591} 595}
592KConfig* KOPrefs::getConfig() 596KConfig* KOPrefs::getConfig()
593{ 597{
594 return config(); 598 return config();
595} 599}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 463fc33..5cc9bfa 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,355 +1,356 @@
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 KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26 26
27#include <libkdepim/kpimprefs.h> 27#include <libkdepim/kpimprefs.h>
28#include <qdict.h> 28#include <qdict.h>
29#include <qdir.h> 29#include <qdir.h>
30#include <qobject.h> 30#include <qobject.h>
31 31
32class KConfig; 32class KConfig;
33class QFont; 33class QFont;
34class QColor; 34class QColor;
35class QStringList; 35class QStringList;
36 36
37#define VIEW_WN_VIEW 1 37#define VIEW_WN_VIEW 1
38#define VIEW_NX_VIEW 2 38#define VIEW_NX_VIEW 2
39#define VIEW_J_VIEW 3 39#define VIEW_J_VIEW 3
40#define VIEW_A_VIEW 4 40#define VIEW_A_VIEW 4
41#define VIEW_ML_VIEW 5 41#define VIEW_ML_VIEW 5
42#define VIEW_M_VIEW 6 42#define VIEW_M_VIEW 6
43#define VIEW_L_VIEW 7 43#define VIEW_L_VIEW 7
44#define VIEW_T_VIEW 8 44#define VIEW_T_VIEW 8
45 45
46class KopiCalendarFile : public QObject 46class KopiCalendarFile : public QObject
47{ 47{
48 public: 48 public:
49 KopiCalendarFile( ) : QObject( ) 49 KopiCalendarFile( ) : QObject( )
50 { 50 {
51 isStandard = false; 51 isStandard = false;
52 isEnabled = true; 52 isEnabled = true;
53 isAlarmEnabled = true; 53 isAlarmEnabled = true;
54 isReadOnly = false; 54 isReadOnly = false;
55 mName = "Calendar"; 55 mName = "Calendar";
56 mFileName = QDir::homeDirPath() + "/icalfile.ics"; 56 mFileName = QDir::homeDirPath() + "/icalfile.ics";
57 mCalNumber = 0; 57 mCalNumber = 0;
58 mDefaultColor = Qt::red; 58 mDefaultColor = Qt::red;
59 mErrorOnLoad = false; 59 mErrorOnLoad = false;
60 } 60 }
61 bool isStandard; 61 bool isStandard;
62 bool isEnabled; 62 bool isEnabled;
63 bool isAlarmEnabled; 63 bool isAlarmEnabled;
64 bool isReadOnly; 64 bool isReadOnly;
65 bool mErrorOnLoad; 65 bool mErrorOnLoad;
66 QString mName; 66 QString mName;
67 QString mFileName; 67 QString mFileName;
68 int mCalNumber; 68 int mCalNumber;
69 QColor mDefaultColor; 69 QColor mDefaultColor;
70 QDateTime mLoadDt; 70 QDateTime mLoadDt;
71}; 71};
72class KOPrefs : public KPimPrefs 72class KOPrefs : public KPimPrefs
73{ 73{
74 public: 74 public:
75 enum { FormatVCalendar, FormatICalendar }; 75 enum { FormatVCalendar, FormatICalendar };
76 enum { MailClientKMail, MailClientSendmail }; 76 enum { MailClientKMail, MailClientSendmail };
77 enum { IMIPDummy, IMIPKMail }; 77 enum { IMIPDummy, IMIPKMail };
78 enum { IMIPOutbox, IMIPdirectsend }; 78 enum { IMIPOutbox, IMIPdirectsend };
79 enum { neverAuto, addressbookAuto, selectedAuto }; 79 enum { neverAuto, addressbookAuto, selectedAuto };
80 enum { standardDestination, askDestination }; 80 enum { standardDestination, askDestination };
81 81
82 virtual ~KOPrefs(); 82 virtual ~KOPrefs();
83 83
84 /** Get instance of KOPrefs. It is made sure that there is only one 84 /** Get instance of KOPrefs. It is made sure that there is only one
85 instance. */ 85 instance. */
86 static KOPrefs *instance(); 86 static KOPrefs *instance();
87 87
88 /** Set preferences to default values */ 88 /** Set preferences to default values */
89 void usrSetDefaults(); 89 void usrSetDefaults();
90 90
91 /** Read preferences from config file */ 91 /** Read preferences from config file */
92 void usrReadConfig(); 92 void usrReadConfig();
93 93
94 /** Write preferences to config file */ 94 /** Write preferences to config file */
95 void usrWriteConfig(); 95 void usrWriteConfig();
96 void setCategoryDefaults(); 96 void setCategoryDefaults();
97 void setAllDefaults(); 97 void setAllDefaults();
98 KopiCalendarFile * getNewCalendar(); 98 KopiCalendarFile * getNewCalendar();
99 KopiCalendarFile * getCalendar( int ); 99 KopiCalendarFile * getCalendar( int );
100 void deleteCalendar( int ); 100 void deleteCalendar( int );
101 QColor defaultColor( int ) const; 101 QColor defaultColor( int ) const;
102 QString calName( int ) const;
102 protected: 103 protected:
103 void setTimeZoneIdDefault(); 104 void setTimeZoneIdDefault();
104 105
105 /** Fill empty mail fields with default values. */ 106 /** Fill empty mail fields with default values. */
106 void fillMailDefaults(); 107 void fillMailDefaults();
107 108
108 private: 109 private:
109 /** Constructor disabled for public. Use instance() to create a KOPrefs 110 /** Constructor disabled for public. Use instance() to create a KOPrefs
110 object. */ 111 object. */
111 KOPrefs(); 112 KOPrefs();
112 113
113 static KOPrefs *mInstance; 114 static KOPrefs *mInstance;
114 QStringList getDefaultList(); 115 QStringList getDefaultList();
115 QStringList getLocationDefaultList(); 116 QStringList getLocationDefaultList();
116 public: 117 public:
117 // preferences data 118 // preferences data
118 KConfig* getConfig(); 119 KConfig* getConfig();
119 void setFullName(const QString &); 120 void setFullName(const QString &);
120 QString fullName(); 121 QString fullName();
121 void setEmail(const QString &); 122 void setEmail(const QString &);
122 QString email(); 123 QString email();
123 124
124 QString mAdditional; 125 QString mAdditional;
125 126
126 bool mEmailControlCenter; 127 bool mEmailControlCenter;
127 128
128 bool mBcc; 129 bool mBcc;
129 bool mAutoSave; 130 bool mAutoSave;
130 int mAutoSaveInterval; 131 int mAutoSaveInterval;
131 bool mConfirm; 132 bool mConfirm;
132 133
133 bool mEnableGroupScheduling; 134 bool mEnableGroupScheduling;
134 bool mEnableProjectView; 135 bool mEnableProjectView;
135 136
136 int mDefaultFormat; 137 int mDefaultFormat;
137 int mMailClient; 138 int mMailClient;
138 139
139 int mStartTime; 140 int mStartTime;
140 int mDefaultDuration; 141 int mDefaultDuration;
141 int mAlarmTime; 142 int mAlarmTime;
142 143
143 int mWorkingHoursStart; 144 int mWorkingHoursStart;
144 int mWorkingHoursEnd; 145 int mWorkingHoursEnd;
145 bool mExcludeHolidays; 146 bool mExcludeHolidays;
146 bool mExcludeSaturdays; 147 bool mExcludeSaturdays;
147 bool mMarcusBainsShowSeconds; 148 bool mMarcusBainsShowSeconds;
148 149
149 QFont mTimeBarFont; 150 QFont mTimeBarFont;
150 QFont mMonthViewFont; 151 QFont mMonthViewFont;
151 QFont mAgendaViewFont; 152 QFont mAgendaViewFont;
152 QFont mMarcusBainsFont; 153 QFont mMarcusBainsFont;
153 QFont mTimeLabelsFont; 154 QFont mTimeLabelsFont;
154 QFont mTodoViewFont; 155 QFont mTodoViewFont;
155 QFont mListViewFont; 156 QFont mListViewFont;
156 QFont mDateNavigatorFont; 157 QFont mDateNavigatorFont;
157 QFont mEditBoxFont; 158 QFont mEditBoxFont;
158 QFont mJornalViewFont; 159 QFont mJornalViewFont;
159 QFont mWhatsNextFont; 160 QFont mWhatsNextFont;
160 QFont mEventViewFont; 161 QFont mEventViewFont;
161 162
162 163
163 164
164 165
165 QColor mHolidayColor; 166 QColor mHolidayColor;
166 QColor mHighlightColor; 167 QColor mHighlightColor;
167 QColor mEventColor; 168 QColor mEventColor;
168 QColor mTodoDoneColor; 169 QColor mTodoDoneColor;
169 QColor mAgendaBgColor; 170 QColor mAgendaBgColor;
170 QColor mWorkingHoursColor; 171 QColor mWorkingHoursColor;
171 QColor mTodoDueTodayColor; 172 QColor mTodoDueTodayColor;
172 QColor mTodoOverdueColor; 173 QColor mTodoOverdueColor;
173 QColor mTodoRunColor; 174 QColor mTodoRunColor;
174 QColor mMonthViewEvenColor; 175 QColor mMonthViewEvenColor;
175 QColor mMonthViewOddColor; 176 QColor mMonthViewOddColor;
176 QColor mMonthViewHolidayColor; 177 QColor mMonthViewHolidayColor;
177 bool mMonthViewUsesDayColors; 178 bool mMonthViewUsesDayColors;
178 bool mMonthViewSatSunTog; 179 bool mMonthViewSatSunTog;
179 bool mMonthViewWeek; 180 bool mMonthViewWeek;
180 QColor mAppColor1; 181 QColor mAppColor1;
181 QColor mAppColor2; 182 QColor mAppColor2;
182 bool mUseAppColors; 183 bool mUseAppColors;
183 184
184 int mDayBegins; 185 int mDayBegins;
185 int mHourSize; 186 int mHourSize;
186 int mAllDaySize; 187 int mAllDaySize;
187 bool mShowFullMenu; 188 bool mShowFullMenu;
188 bool mDailyRecur; 189 bool mDailyRecur;
189 bool mWeeklyRecur; 190 bool mWeeklyRecur;
190 bool mMonthDailyRecur; 191 bool mMonthDailyRecur;
191 bool mMonthWeeklyRecur; 192 bool mMonthWeeklyRecur;
192 bool mMonthShowIcons; 193 bool mMonthShowIcons;
193 bool mMonthShowTimes; 194 bool mMonthShowTimes;
194 bool mMonthShowShort; 195 bool mMonthShowShort;
195 bool mEnableToolTips; 196 bool mEnableToolTips;
196 bool mEnableMonthScroll; 197 bool mEnableMonthScroll;
197 bool mFullViewMonth; 198 bool mFullViewMonth;
198 bool mMonthViewUsesCategoryColor; 199 bool mMonthViewUsesCategoryColor;
199 bool mFullViewTodo; 200 bool mFullViewTodo;
200 bool mShowCompletedTodo; 201 bool mShowCompletedTodo;
201 bool mMarcusBainsEnabled; 202 bool mMarcusBainsEnabled;
202 int mNextXDays; 203 int mNextXDays;
203 int mWhatsNextDays; 204 int mWhatsNextDays;
204 int mWhatsNextPrios; 205 int mWhatsNextPrios;
205 bool mEnableQuickTodo; 206 bool mEnableQuickTodo;
206 207
207 bool mCompactDialogs; 208 bool mCompactDialogs;
208 bool mVerticalScreen; 209 bool mVerticalScreen;
209 210
210 bool mShowIconNewTodo; 211 bool mShowIconNewTodo;
211 bool mShowIconNewEvent; 212 bool mShowIconNewEvent;
212 bool mShowIconSearch; 213 bool mShowIconSearch;
213 bool mShowIconList; 214 bool mShowIconList;
214 bool mShowIconDay1; 215 bool mShowIconDay1;
215 bool mShowIconDay5; 216 bool mShowIconDay5;
216 bool mShowIconDay6; 217 bool mShowIconDay6;
217 bool mShowIconDay7; 218 bool mShowIconDay7;
218 bool mShowIconMonth; 219 bool mShowIconMonth;
219 bool mShowIconTodoview; 220 bool mShowIconTodoview;
220 bool mShowIconBackFast; 221 bool mShowIconBackFast;
221 bool mShowIconBack; 222 bool mShowIconBack;
222 bool mShowIconToday; 223 bool mShowIconToday;
223 bool mShowIconForward; 224 bool mShowIconForward;
224 bool mShowIconForwardFast; 225 bool mShowIconForwardFast;
225 bool mShowIconWhatsThis; 226 bool mShowIconWhatsThis;
226 bool mShowIconWeekNum; 227 bool mShowIconWeekNum;
227 bool mShowIconNextDays; 228 bool mShowIconNextDays;
228 bool mShowIconNext; 229 bool mShowIconNext;
229 bool mShowIconJournal; 230 bool mShowIconJournal;
230 bool mShowIconFilter; 231 bool mShowIconFilter;
231 bool mShowIconOnetoolbar; 232 bool mShowIconOnetoolbar;
232 bool mShowIconNavigator; 233 bool mShowIconNavigator;
233 bool mShowIconAllday; 234 bool mShowIconAllday;
234 bool mShowIconFilterview; 235 bool mShowIconFilterview;
235 bool mShowIconToggleFull; 236 bool mShowIconToggleFull;
236 237
237 bool mShowIconStretch; 238 bool mShowIconStretch;
238 239
239 bool mToolBarHor; 240 bool mToolBarHor;
240 bool mToolBarUp; 241 bool mToolBarUp;
241 bool mToolBarHorV; 242 bool mToolBarHorV;
242 bool mToolBarUpV; 243 bool mToolBarUpV;
243 bool mToolBarHorN; 244 bool mToolBarHorN;
244 bool mToolBarUpN; 245 bool mToolBarUpN;
245 bool mToolBarHorF; 246 bool mToolBarHorF;
246 bool mToolBarUpF; 247 bool mToolBarUpF;
247 bool mToolBarMiniIcons; 248 bool mToolBarMiniIcons;
248 249
249 bool mAskForQuit; 250 bool mAskForQuit;
250 bool mUsePassWd; 251 bool mUsePassWd;
251 bool mShowSyncEvents; 252 bool mShowSyncEvents;
252 bool mShowTodoInAgenda; 253 bool mShowTodoInAgenda;
253 bool mShowCompletedTodoInAgenda; 254 bool mShowCompletedTodoInAgenda;
254 bool mShowTimeInAgenda; 255 bool mShowTimeInAgenda;
255 bool mHideNonStartedTodos; 256 bool mHideNonStartedTodos;
256 257
257 bool mBlockPopupMenu; 258 bool mBlockPopupMenu;
258 259
259 int mLastSyncTime; 260 int mLastSyncTime;
260 void setCategoryColor(QString cat,const QColor & color); 261 void setCategoryColor(QString cat,const QColor & color);
261 QColor *categoryColor(QString cat); 262 QColor *categoryColor(QString cat);
262 263
263 QString mArchiveFile; 264 QString mArchiveFile;
264 QString mHtmlExportFile; 265 QString mHtmlExportFile;
265 bool mHtmlWithSave; 266 bool mHtmlWithSave;
266 267
267 QStringList mSelectedPlugins; 268 QStringList mSelectedPlugins;
268 269
269 QString mLastImportFile; 270 QString mLastImportFile;
270 QString mLastVcalFile; 271 QString mLastVcalFile;
271 QString mLastSaveFile; 272 QString mLastSaveFile;
272 QString mLastLoadFile; 273 QString mLastLoadFile;
273 274
274 275
275 QString mDefaultAlarmFile; 276 QString mDefaultAlarmFile;
276 int mIMIPScheduler; 277 int mIMIPScheduler;
277 int mIMIPSend; 278 int mIMIPSend;
278 QStringList mAdditionalMails; 279 QStringList mAdditionalMails;
279 int mIMIPAutoRefresh; 280 int mIMIPAutoRefresh;
280 int mIMIPAutoInsertReply; 281 int mIMIPAutoInsertReply;
281 int mIMIPAutoInsertRequest; 282 int mIMIPAutoInsertRequest;
282 int mIMIPAutoFreeBusy; 283 int mIMIPAutoFreeBusy;
283 int mIMIPAutoFreeBusyReply; 284 int mIMIPAutoFreeBusyReply;
284 285
285 QStringList mTodoTemplates; 286 QStringList mTodoTemplates;
286 QStringList mEventTemplates; 287 QStringList mEventTemplates;
287 288
288 int mDestination; 289 int mDestination;
289 290
290 291
291 bool mEditOnDoubleClick; 292 bool mEditOnDoubleClick;
292 bool mViewChangeHoldFullscreen; 293 bool mViewChangeHoldFullscreen;
293 bool mViewChangeHoldNonFullscreen; 294 bool mViewChangeHoldNonFullscreen;
294 bool mCenterOnCurrentTime; 295 bool mCenterOnCurrentTime;
295 bool mSetTimeToDayStartAt; 296 bool mSetTimeToDayStartAt;
296 bool mHighlightCurrentDay; 297 bool mHighlightCurrentDay;
297 bool mUseHighlightLightColor; 298 bool mUseHighlightLightColor;
298 bool mListViewMonthTimespan; 299 bool mListViewMonthTimespan;
299 bool mWNViewShowsParents; 300 bool mWNViewShowsParents;
300 bool mWNViewShowsPast; 301 bool mWNViewShowsPast;
301 bool mWNViewShowLocation; 302 bool mWNViewShowLocation;
302 bool mTodoViewShowsPercentage; 303 bool mTodoViewShowsPercentage;
303 bool mTodoViewUsesCatColors; 304 bool mTodoViewUsesCatColors;
304 bool mMonthViewUsesBigFont; 305 bool mMonthViewUsesBigFont;
305 bool mTodoViewUsesSmallFont; 306 bool mTodoViewUsesSmallFont;
306 bool mTodoViewUsesForegroundColor; 307 bool mTodoViewUsesForegroundColor;
307 bool mMonthViewUsesForegroundColor; 308 bool mMonthViewUsesForegroundColor;
308 309
309 bool mHightlightDateTimeEdit; 310 bool mHightlightDateTimeEdit;
310 bool mShortDateInViewer; 311 bool mShortDateInViewer;
311 312
312 bool mShowDateNavigator; 313 bool mShowDateNavigator;
313 314
314 QStringList mLocationDefaults; 315 QStringList mLocationDefaults;
315 QStringList mEventSummaryUser; 316 QStringList mEventSummaryUser;
316 QStringList mTodoSummaryUser; 317 QStringList mTodoSummaryUser;
317 318
318 bool mUseInternalAlarmNotification; 319 bool mUseInternalAlarmNotification;
319 int mAlarmPlayBeeps; 320 int mAlarmPlayBeeps;
320 int mAlarmSuspendTime; 321 int mAlarmSuspendTime;
321 int mAlarmSuspendCount; 322 int mAlarmSuspendCount;
322 int mAlarmBeepInterval; 323 int mAlarmBeepInterval;
323 int mOldLanguage; 324 int mOldLanguage;
324 int mOldLoadedLanguage; 325 int mOldLoadedLanguage;
325 326
326 327
327 QString mActiveSyncPort; 328 QString mActiveSyncPort;
328 QString mActiveSyncIP; 329 QString mActiveSyncIP;
329 330
330 // settings for eventviewer 331 // settings for eventviewer
331 bool mEVshowDetails; 332 bool mEVshowDetails;
332 bool mEVshowCreated; 333 bool mEVshowCreated;
333 bool mEVshowChanged; 334 bool mEVshowChanged;
334 bool mWTshowDetails; 335 bool mWTshowDetails;
335 bool mWTshowCreated; 336 bool mWTshowCreated;
336 bool mWTshowChanged; 337 bool mWTshowChanged;
337 338
338 int mCurrentDisplayedView; 339 int mCurrentDisplayedView;
339 QPtrList<KopiCalendarFile> mCalendars; 340 QPtrList<KopiCalendarFile> mCalendars;
340 int mNextAvailableCalendar; 341 int mNextAvailableCalendar;
341 342
342 private: 343 private:
343 QDict<QColor> mCategoryColors; 344 QDict<QColor> mCategoryColors;
344 QArray<KopiCalendarFile*> mDefCalColors; 345 QArray<KopiCalendarFile*> mDefCalColors;
345 QColor mDefaultCategoryColor; 346 QColor mDefaultCategoryColor;
346 347
347 QFont mDefaultTimeBarFont; 348 QFont mDefaultTimeBarFont;
348 QFont mDefaultViewFont; 349 QFont mDefaultViewFont;
349 QFont mDefaultMonthViewFont; 350 QFont mDefaultMonthViewFont;
350 351
351 QString mName; 352 QString mName;
352 QString mEmail; 353 QString mEmail;
353}; 354};
354 355
355#endif 356#endif