summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp19
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/koagendaview.cpp7
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/kojournalview.cpp4
-rw-r--r--korganizer/kojournalview.h1
-rw-r--r--korganizer/kolistview.cpp4
-rw-r--r--korganizer/kolistview.h1
-rw-r--r--korganizer/komonthview.cpp10
-rw-r--r--korganizer/komonthview.h1
-rw-r--r--korganizer/koviewmanager.cpp13
-rw-r--r--korganizer/koviewmanager.h1
-rw-r--r--korganizer/kowhatsnextview.cpp5
-rw-r--r--korganizer/kowhatsnextview.h1
-rw-r--r--korganizer/mainwindow.cpp1
15 files changed, 67 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 608b73b..e13d0be 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4339 +1,4354 @@
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->type() == "Event" ) { 173 if ( inc->type() == "Event" ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->type() == "Todo" ) { 175 } else if ( inc->type() == "Todo" ) {
176 tempText += "href=\"todo:"; 176 tempText += "href=\"todo:";
177 } 177 }
178 tempText += inc->uid() + "\">"; 178 tempText += inc->uid() + "\">";
179 if ( inc->type() == "Todo" ) 179 if ( inc->type() == "Todo" )
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 mTodoList->setNavigator( mNavigator ); 461 mTodoList->setNavigator( mNavigator );
462#if 0 462#if 0
463 if ( QApplication::desktop()->width() < 480 ) { 463 if ( QApplication::desktop()->width() < 480 ) {
464 leftFrameLayout->addWidget(mFilterView); 464 leftFrameLayout->addWidget(mFilterView);
465 leftFrameLayout->addWidget(mTodoList, 2 ); 465 leftFrameLayout->addWidget(mTodoList, 2 );
466 466
467 } else { 467 } else {
468 leftFrameLayout->addWidget(mTodoList,2 ); 468 leftFrameLayout->addWidget(mTodoList,2 );
469 leftFrameLayout->addWidget(mFilterView ); 469 leftFrameLayout->addWidget(mFilterView );
470 } 470 }
471#endif 471#endif
472 mFilterView->hide(); 472 mFilterView->hide();
473 QWidget *rightBox = new QWidget( mMainFrame ); 473 QWidget *rightBox = new QWidget( mMainFrame );
474 //mainBoxLayout->addWidget ( rightBox, 10 ); 474 //mainBoxLayout->addWidget ( rightBox, 10 );
475 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 475 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
476 mRightFrame = new QWidgetStack( rightBox ); 476 mRightFrame = new QWidgetStack( rightBox );
477 rightLayout->addWidget( mRightFrame, 10 ); 477 rightLayout->addWidget( mRightFrame, 10 );
478 478
479 //mLeftFrame = (QWidget *)leftFrame; 479 //mLeftFrame = (QWidget *)leftFrame;
480 if ( KOPrefs::instance()->mVerticalScreen ) { 480 if ( KOPrefs::instance()->mVerticalScreen ) {
481 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 481 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
482 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 482 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
483 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 483 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
484 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 484 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
485 } else { 485 } else {
486 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 486 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
487 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 487 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
488 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 488 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
489 } 489 }
490 if ( !KOPrefs::instance()->mShowDateNavigator) 490 if ( !KOPrefs::instance()->mShowDateNavigator)
491 mDateNavigator->hide(); 491 mDateNavigator->hide();
492 //qDebug("Calendarview Size %d %d ", width(), height()); 492 //qDebug("Calendarview Size %d %d ", width(), height());
493#endif 493#endif
494 494
495 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 495 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
496 SLOT( showDates( const KCal::DateList & ) ) ); 496 SLOT( showDates( const KCal::DateList & ) ) );
497 497
498 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 498 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
499 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 499 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
500 500
501 501
502 502
503 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 503 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
504 mViewManager, SLOT( showMonth( const QDate & ) ) ); 504 mViewManager, SLOT( showMonth( const QDate & ) ) );
505 505
506 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 506 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
507 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 507 mNavigator, SLOT( selectWeek( const QDate & ) ) );
508 508
509 connect( mDateNavigator, SIGNAL( goPrevYear() ), 509 connect( mDateNavigator, SIGNAL( goPrevYear() ),
510 mNavigator, SLOT( selectPreviousYear() ) ); 510 mNavigator, SLOT( selectPreviousYear() ) );
511 connect( mDateNavigator, SIGNAL( goNextYear() ), 511 connect( mDateNavigator, SIGNAL( goNextYear() ),
512 mNavigator, SLOT( selectNextYear() ) ); 512 mNavigator, SLOT( selectNextYear() ) );
513 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 513 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
514 mNavigator, SLOT( selectPreviousMonth() ) ); 514 mNavigator, SLOT( selectPreviousMonth() ) );
515 connect( mDateNavigator, SIGNAL( goNextMonth() ), 515 connect( mDateNavigator, SIGNAL( goNextMonth() ),
516 mNavigator, SLOT( selectNextMonth() ) ); 516 mNavigator, SLOT( selectNextMonth() ) );
517 517
518 connect( mDateNavigator, SIGNAL( goPrevious() ), 518 connect( mDateNavigator, SIGNAL( goPrevious() ),
519 mNavigator, SLOT( selectPrevious() ) ); 519 mNavigator, SLOT( selectPrevious() ) );
520 connect( mDateNavigator, SIGNAL( goNext() ), 520 connect( mDateNavigator, SIGNAL( goNext() ),
521 mNavigator, SLOT( selectNext() ) ); 521 mNavigator, SLOT( selectNext() ) );
522 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 522 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
523 mNavigator, SLOT( slotMonthSelect( int ) ) ); 523 mNavigator, SLOT( slotMonthSelect( int ) ) );
524 524
525 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 525 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
526 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 526 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
527#if 0 527#if 0
528 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 528 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
529 SLOT( incidenceAdded( Incidence *) ) ); 529 SLOT( incidenceAdded( Incidence *) ) );
530#endif 530#endif
531 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 531 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
532 532
533 connect( this, SIGNAL( configChanged() ), 533 connect( this, SIGNAL( configChanged() ),
534 mDateNavigator, SLOT( updateConfig() ) ); 534 mDateNavigator, SLOT( updateConfig() ) );
535 535
536 connect( mTodoList, SIGNAL( newTodoSignal() ), 536 connect( mTodoList, SIGNAL( newTodoSignal() ),
537 SLOT( newTodo() ) ); 537 SLOT( newTodo() ) );
538 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 538 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
539 SLOT( newSubTodo( Todo * ) ) ); 539 SLOT( newSubTodo( Todo * ) ) );
540 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 540 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
541 SLOT( editTodo( Todo * ) ) ); 541 SLOT( editTodo( Todo * ) ) );
542 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 542 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
543 SLOT( showTodo( Todo *) ) ); 543 SLOT( showTodo( Todo *) ) );
544 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 544 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
545 SLOT( deleteTodo( Todo *) ) ); 545 SLOT( deleteTodo( Todo *) ) );
546 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 546 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
547 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 547 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
548 SLOT( purgeCompleted() ) ); 548 SLOT( purgeCompleted() ) );
549 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 549 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
550 SIGNAL( todoModified( Todo *, int ) ) ); 550 SIGNAL( todoModified( Todo *, int ) ) );
551 551
552 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 552 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
553 this, SLOT ( cloneIncidence( Incidence * ) ) ); 553 this, SLOT ( cloneIncidence( Incidence * ) ) );
554 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 554 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
555 this, SLOT (cancelIncidence( Incidence * ) ) ); 555 this, SLOT (cancelIncidence( Incidence * ) ) );
556 556
557 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 557 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
558 this, SLOT ( moveIncidence( Incidence * ) ) ); 558 this, SLOT ( moveIncidence( Incidence * ) ) );
559 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 559 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
560 this, SLOT ( beamIncidence( Incidence * ) ) ); 560 this, SLOT ( beamIncidence( Incidence * ) ) );
561 561
562 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 562 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
563 this, SLOT ( todo_unsub( Todo * ) ) ); 563 this, SLOT ( todo_unsub( Todo * ) ) );
564 564
565 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 565 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
566 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 566 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
567 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 567 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
568 SLOT( updateTodo( Todo *, int ) ) ); 568 SLOT( updateTodo( Todo *, int ) ) );
569 connect( this, SIGNAL( todoModified( Todo *, int )), this, 569 connect( this, SIGNAL( todoModified( Todo *, int )), this,
570 SLOT( changeTodoDisplay( Todo *, int ) ) ); 570 SLOT( changeTodoDisplay( Todo *, int ) ) );
571 571
572 572
573 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 573 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
574 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 574 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
575 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 575 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
576 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 576 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
577 577
578 578
579 579
580 580
581 581
582 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 582 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
583 SLOT(checkClipboard())); 583 SLOT(checkClipboard()));
584 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 584 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
585 SLOT( processTodoListSelection( Incidence * ) ) ); 585 SLOT( processTodoListSelection( Incidence * ) ) );
586 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 586 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
587 587
588 // kdDebug() << "CalendarView::CalendarView() done" << endl; 588 // kdDebug() << "CalendarView::CalendarView() done" << endl;
589 589
590 mDateFrame = new QVBox(0,0,WType_Popup); 590 mDateFrame = new QVBox(0,0,WType_Popup);
591 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 591 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
592 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 592 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
593 mDateFrame->setLineWidth(3); 593 mDateFrame->setLineWidth(3);
594 mDateFrame->hide(); 594 mDateFrame->hide();
595 mDateFrame->setCaption( i18n( "Pick a date to display")); 595 mDateFrame->setCaption( i18n( "Pick a date to display"));
596 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 596 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
597 597
598 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 598 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
599 599
600 mEventEditor = mDialogManager->getEventEditor(); 600 mEventEditor = mDialogManager->getEventEditor();
601 mTodoEditor = mDialogManager->getTodoEditor(); 601 mTodoEditor = mDialogManager->getTodoEditor();
602 602
603 mFlagEditDescription = false; 603 mFlagEditDescription = false;
604 604
605 mSuspendTimer = new QTimer( this ); 605 mSuspendTimer = new QTimer( this );
606 mAlarmTimer = new QTimer( this ); 606 mAlarmTimer = new QTimer( this );
607 mRecheckAlarmTimer = new QTimer( this ); 607 mRecheckAlarmTimer = new QTimer( this );
608 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 608 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
609 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 609 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
610 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 610 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
611 mAlarmDialog = new AlarmDialog( this ); 611 mAlarmDialog = new AlarmDialog( this );
612 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 612 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
613 mAlarmDialog->setServerNotification( false ); 613 mAlarmDialog->setServerNotification( false );
614 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 614 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
615 615
616 616
617#ifndef DESKTOP_VERSION 617#ifndef DESKTOP_VERSION
618//US listen for arriving address resultsets 618//US listen for arriving address resultsets
619 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 619 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
620 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 620 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
621#endif 621#endif
622 mDateNavigator->setCalendar( mCalendar ); 622 mDateNavigator->setCalendar( mCalendar );
623} 623}
624 624
625 625
626CalendarView::~CalendarView() 626CalendarView::~CalendarView()
627{ 627{
628 // kdDebug() << "~CalendarView()" << endl; 628 // kdDebug() << "~CalendarView()" << endl;
629 //qDebug("CalendarView::~CalendarView() "); 629 //qDebug("CalendarView::~CalendarView() ");
630 delete mDialogManager; 630 delete mDialogManager;
631 delete mViewManager; 631 delete mViewManager;
632 delete mStorage; 632 delete mStorage;
633 delete mDateFrame ; 633 delete mDateFrame ;
634 delete beamDialog; 634 delete beamDialog;
635 delete mEventViewerDialog; 635 delete mEventViewerDialog;
636 //kdDebug() << "~CalendarView() done" << endl; 636 //kdDebug() << "~CalendarView() done" << endl;
637} 637}
638void CalendarView::checkAlarms() 638void CalendarView::checkAlarms()
639{ 639{
640 KConfig *config = KOGlobals::config(); 640 KConfig *config = KOGlobals::config();
641 config->setGroup( "AppRun" ); 641 config->setGroup( "AppRun" );
642 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 642 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
643 int secs = config->readNumEntry( "LatestProgramStop" ) - 30; 643 int secs = config->readNumEntry( "LatestProgramStop" ) - 30;
644 //secs -= ( 3600 * 24*3 ); // debug only 644 //secs -= ( 3600 * 24*3 ); // debug only
645 QDateTime latest = dt.addSecs ( secs ); 645 QDateTime latest = dt.addSecs ( secs );
646 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 646 qDebug("KO: Last termination on %s ", latest.toString().latin1());
647 QPtrList<Incidence> el = mCalendar->rawIncidences(); 647 QPtrList<Incidence> el = mCalendar->rawIncidences();
648 QPtrList<Incidence> al; 648 QPtrList<Incidence> al;
649 Incidence* inL = el.first(); 649 Incidence* inL = el.first();
650 while ( inL ) { 650 while ( inL ) {
651 bool ok = false; 651 bool ok = false;
652 int offset = 0; 652 int offset = 0;
653 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 653 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
654 if ( ok ) { 654 if ( ok ) {
655 //qDebug("OK %s",next.toString().latin1()); 655 //qDebug("OK %s",next.toString().latin1());
656 if ( next < QDateTime::currentDateTime() ) { 656 if ( next < QDateTime::currentDateTime() ) {
657 al.append( inL ); 657 al.append( inL );
658 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 658 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
659 } 659 }
660 } 660 }
661 inL = el.next(); 661 inL = el.next();
662 } 662 }
663 if ( al.count() ) { 663 if ( al.count() ) {
664 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 664 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
665 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 665 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
666 QVBoxLayout* lay = new QVBoxLayout( dia ); 666 QVBoxLayout* lay = new QVBoxLayout( dia );
667 lay->setSpacing( 0 ); 667 lay->setSpacing( 0 );
668 lay->setMargin( 0 ); 668 lay->setMargin( 0 );
669 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 669 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
670 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 670 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
671 lay->addWidget( matb ); 671 lay->addWidget( matb );
672 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 672 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
673 int wid = 210; 673 int wid = 210;
674 int x = QApplication::desktop()->width() - wid - 7; 674 int x = QApplication::desktop()->width() - wid - 7;
675 int y = QApplication::desktop()->height() - wid - 70; 675 int y = QApplication::desktop()->height() - wid - 70;
676 dia->setGeometry ( x,y,wid,wid); 676 dia->setGeometry ( x,y,wid,wid);
677 } else { 677 } else {
678 int si = 220; 678 int si = 220;
679 if ( QApplication::desktop()->width() > 470 ) 679 if ( QApplication::desktop()->width() > 470 )
680 si = 400; 680 si = 400;
681 dia->resize(si,si/2); 681 dia->resize(si,si/2);
682 } 682 }
683 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 683 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
684 dia->show(); 684 dia->show();
685 685
686 } 686 }
687} 687}
688void CalendarView::showDay( QDate d ) 688void CalendarView::showDay( QDate d )
689{ 689{
690 dateNavigator()->blockSignals( true ); 690 dateNavigator()->blockSignals( true );
691 dateNavigator()->selectDate( d ); 691 dateNavigator()->selectDate( d );
692 dateNavigator()->blockSignals( false ); 692 dateNavigator()->blockSignals( false );
693 mViewManager->showDayView(); 693 mViewManager->showDayView();
694 //dateNavigator()->selectDate( d ); 694 //dateNavigator()->selectDate( d );
695} 695}
696void CalendarView::timerAlarm() 696void CalendarView::timerAlarm()
697{ 697{
698 //qDebug("CalendarView::timerAlarm() "); 698 //qDebug("CalendarView::timerAlarm() ");
699 computeAlarm(mAlarmNotification ); 699 computeAlarm(mAlarmNotification );
700} 700}
701 701
702void CalendarView::suspendAlarm() 702void CalendarView::suspendAlarm()
703{ 703{
704 //qDebug(" CalendarView::suspendAlarm() "); 704 //qDebug(" CalendarView::suspendAlarm() ");
705 computeAlarm(mSuspendAlarmNotification ); 705 computeAlarm(mSuspendAlarmNotification );
706 706
707} 707}
708 708
709void CalendarView::startAlarm( QString mess , QString filename) 709void CalendarView::startAlarm( QString mess , QString filename)
710{ 710{
711 711
712 topLevelWidget()->showNormal(); 712 topLevelWidget()->showNormal();
713 topLevelWidget()->setActiveWindow(); 713 topLevelWidget()->setActiveWindow();
714 topLevelWidget()->raise(); 714 topLevelWidget()->raise();
715 715
716 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 716 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
717 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 717 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
718 718
719} 719}
720 720
721void CalendarView::checkNextTimerAlarm() 721void CalendarView::checkNextTimerAlarm()
722{ 722{
723 mCalendar->checkAlarmForIncidence( 0, true ); 723 mCalendar->checkAlarmForIncidence( 0, true );
724} 724}
725 725
726void CalendarView::computeAlarm( QString msg ) 726void CalendarView::computeAlarm( QString msg )
727{ 727{
728 728
729 QString mess = msg; 729 QString mess = msg;
730 QString mAlarmMessage = mess.mid( 9 ); 730 QString mAlarmMessage = mess.mid( 9 );
731 QString filename = MainWindow::resourcePath(); 731 QString filename = MainWindow::resourcePath();
732 filename += "koalarm.wav"; 732 filename += "koalarm.wav";
733 QString tempfilename; 733 QString tempfilename;
734 if ( mess.left( 13 ) == "suspend_alarm") { 734 if ( mess.left( 13 ) == "suspend_alarm") {
735 bool error = false; 735 bool error = false;
736 int len = mess.mid( 13 ).find("+++"); 736 int len = mess.mid( 13 ).find("+++");
737 if ( len < 2 ) 737 if ( len < 2 )
738 error = true; 738 error = true;
739 else { 739 else {
740 tempfilename = mess.mid( 13, len ); 740 tempfilename = mess.mid( 13, len );
741 if ( !QFile::exists( tempfilename ) ) 741 if ( !QFile::exists( tempfilename ) )
742 error = true; 742 error = true;
743 } 743 }
744 if ( ! error ) { 744 if ( ! error ) {
745 filename = tempfilename; 745 filename = tempfilename;
746 } 746 }
747 mAlarmMessage = mess.mid( 13+len+3 ); 747 mAlarmMessage = mess.mid( 13+len+3 );
748 //qDebug("suspend file %s ",tempfilename.latin1() ); 748 //qDebug("suspend file %s ",tempfilename.latin1() );
749 startAlarm( mAlarmMessage, filename); 749 startAlarm( mAlarmMessage, filename);
750 return; 750 return;
751 } 751 }
752 if ( mess.left( 11 ) == "timer_alarm") { 752 if ( mess.left( 11 ) == "timer_alarm") {
753 //mTimerTime = 0; 753 //mTimerTime = 0;
754 startAlarm( mess.mid( 11 ), filename ); 754 startAlarm( mess.mid( 11 ), filename );
755 return; 755 return;
756 } 756 }
757 if ( mess.left( 10 ) == "proc_alarm") { 757 if ( mess.left( 10 ) == "proc_alarm") {
758 bool error = false; 758 bool error = false;
759 int len = mess.mid( 10 ).find("+++"); 759 int len = mess.mid( 10 ).find("+++");
760 if ( len < 2 ) 760 if ( len < 2 )
761 error = true; 761 error = true;
762 else { 762 else {
763 tempfilename = mess.mid( 10, len ); 763 tempfilename = mess.mid( 10, len );
764 if ( !QFile::exists( tempfilename ) ) 764 if ( !QFile::exists( tempfilename ) )
765 error = true; 765 error = true;
766 } 766 }
767 if ( error ) { 767 if ( error ) {
768 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 768 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
769 mAlarmMessage += mess.mid( 10+len+3+9 ); 769 mAlarmMessage += mess.mid( 10+len+3+9 );
770 } else { 770 } else {
771 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 771 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
772 //qDebug("-----system command %s ",tempfilename.latin1() ); 772 //qDebug("-----system command %s ",tempfilename.latin1() );
773#ifndef _WIN32_ 773#ifndef _WIN32_
774 if ( vfork () == 0 ) { 774 if ( vfork () == 0 ) {
775 execl ( tempfilename.latin1(), 0 ); 775 execl ( tempfilename.latin1(), 0 );
776 return; 776 return;
777 } 777 }
778#else 778#else
779 QProcess* p = new QProcess(); 779 QProcess* p = new QProcess();
780 p->addArgument( tempfilename.latin1() ); 780 p->addArgument( tempfilename.latin1() );
781 p->start(); 781 p->start();
782 return; 782 return;
783#endif 783#endif
784 784
785 return; 785 return;
786 } 786 }
787 787
788 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 788 //qDebug("+++++++system command %s ",tempfilename.latin1() );
789 } 789 }
790 if ( mess.left( 11 ) == "audio_alarm") { 790 if ( mess.left( 11 ) == "audio_alarm") {
791 bool error = false; 791 bool error = false;
792 int len = mess.mid( 11 ).find("+++"); 792 int len = mess.mid( 11 ).find("+++");
793 if ( len < 2 ) 793 if ( len < 2 )
794 error = true; 794 error = true;
795 else { 795 else {
796 tempfilename = mess.mid( 11, len ); 796 tempfilename = mess.mid( 11, len );
797 if ( !QFile::exists( tempfilename ) ) 797 if ( !QFile::exists( tempfilename ) )
798 error = true; 798 error = true;
799 } 799 }
800 if ( ! error ) { 800 if ( ! error ) {
801 filename = tempfilename; 801 filename = tempfilename;
802 } 802 }
803 mAlarmMessage = mess.mid( 11+len+3+9 ); 803 mAlarmMessage = mess.mid( 11+len+3+9 );
804 //qDebug("audio file command %s ",tempfilename.latin1() ); 804 //qDebug("audio file command %s ",tempfilename.latin1() );
805 } 805 }
806 if ( mess.left( 9 ) == "cal_alarm") { 806 if ( mess.left( 9 ) == "cal_alarm") {
807 mAlarmMessage = mess.mid( 9 ) ; 807 mAlarmMessage = mess.mid( 9 ) ;
808 } 808 }
809 809
810 startAlarm( mAlarmMessage, filename ); 810 startAlarm( mAlarmMessage, filename );
811 811
812 812
813} 813}
814 814
815void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 815void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
816{ 816{
817 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 817 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
818 818
819 mSuspendAlarmNotification = noti; 819 mSuspendAlarmNotification = noti;
820 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 820 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
821 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 821 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
822 mSuspendTimer->start( ms , true ); 822 mSuspendTimer->start( ms , true );
823 823
824} 824}
825 825
826void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 826void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
827{ 827{
828 mNextAlarmDateTime = qdt; 828 mNextAlarmDateTime = qdt;
829 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 829 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
830 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 830 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
831#ifndef DESKTOP_VERSION 831#ifndef DESKTOP_VERSION
832 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 832 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
833#endif 833#endif
834 return; 834 return;
835 } 835 }
836 int maxSec; 836 int maxSec;
837 //maxSec = 5; //testing only 837 //maxSec = 5; //testing only
838 maxSec = 86400+3600; // one day+1hour 838 maxSec = 86400+3600; // one day+1hour
839 mAlarmNotification = noti; 839 mAlarmNotification = noti;
840 int sec = QDateTime::currentDateTime().secsTo( qdt ); 840 int sec = QDateTime::currentDateTime().secsTo( qdt );
841 if ( sec > maxSec ) { 841 if ( sec > maxSec ) {
842 mRecheckAlarmTimer->start( maxSec * 1000 ); 842 mRecheckAlarmTimer->start( maxSec * 1000 );
843 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 843 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
844 return; 844 return;
845 } else { 845 } else {
846 mRecheckAlarmTimer->stop(); 846 mRecheckAlarmTimer->stop();
847 } 847 }
848 //qDebug("Alarm timer started with secs: %d ", sec); 848 //qDebug("Alarm timer started with secs: %d ", sec);
849 mAlarmTimer->start( sec *1000 , true ); 849 mAlarmTimer->start( sec *1000 , true );
850 850
851} 851}
852// called by mRecheckAlarmTimer to get next alarm 852// called by mRecheckAlarmTimer to get next alarm
853// we need this, because a QTimer has only a max range of 25 days 853// we need this, because a QTimer has only a max range of 25 days
854void CalendarView::recheckTimerAlarm() 854void CalendarView::recheckTimerAlarm()
855{ 855{
856 mAlarmTimer->stop(); 856 mAlarmTimer->stop();
857 mRecheckAlarmTimer->stop(); 857 mRecheckAlarmTimer->stop();
858 mCalendar->checkAlarmForIncidence( 0, true ); 858 mCalendar->checkAlarmForIncidence( 0, true );
859} 859}
860void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 860void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
861{ 861{
862 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 862 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
863 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 863 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
864#ifndef DESKTOP_VERSION 864#ifndef DESKTOP_VERSION
865 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 865 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
866#endif 866#endif
867 return; 867 return;
868 } 868 }
869 mAlarmTimer->stop(); 869 mAlarmTimer->stop();
870} 870}
871void CalendarView::selectWeekNum ( int num ) 871void CalendarView::selectWeekNum ( int num )
872{ 872{
873 dateNavigator()->blockSignals( true ); 873 dateNavigator()->blockSignals( true );
874 dateNavigator()->selectWeek( num ); 874 dateNavigator()->selectWeek( num );
875 dateNavigator()->blockSignals( false ); 875 dateNavigator()->blockSignals( false );
876 mViewManager->showWeekView(); 876 mViewManager->showWeekView();
877} 877}
878KOViewManager *CalendarView::viewManager() 878KOViewManager *CalendarView::viewManager()
879{ 879{
880 return mViewManager; 880 return mViewManager;
881} 881}
882 882
883KODialogManager *CalendarView::dialogManager() 883KODialogManager *CalendarView::dialogManager()
884{ 884{
885 return mDialogManager; 885 return mDialogManager;
886} 886}
887 887
888QDate CalendarView::startDate() 888QDate CalendarView::startDate()
889{ 889{
890 DateList dates = mNavigator->selectedDates(); 890 DateList dates = mNavigator->selectedDates();
891 891
892 return dates.first(); 892 return dates.first();
893} 893}
894 894
895QDate CalendarView::endDate() 895QDate CalendarView::endDate()
896{ 896{
897 DateList dates = mNavigator->selectedDates(); 897 DateList dates = mNavigator->selectedDates();
898 898
899 return dates.last(); 899 return dates.last();
900} 900}
901 901
902 902
903void CalendarView::createPrinter() 903void CalendarView::createPrinter()
904{ 904{
905#ifndef KORG_NOPRINTER 905#ifndef KORG_NOPRINTER
906 if (!mCalPrinter) { 906 if (!mCalPrinter) {
907 mCalPrinter = new CalPrinter(this, mCalendar); 907 mCalPrinter = new CalPrinter(this, mCalendar);
908 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 908 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
909 } 909 }
910#endif 910#endif
911} 911}
912 912
913 913
914//KOPrefs::instance()->mWriteBackFile 914//KOPrefs::instance()->mWriteBackFile
915//KOPrefs::instance()->mWriteBackExistingOnly 915//KOPrefs::instance()->mWriteBackExistingOnly
916 916
917// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 917// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
918// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 918// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
919// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 919// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
920// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 920// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
921// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 921// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
922// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 922// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
923 923
924int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 924int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
925{ 925{
926 926
927 // 0 equal 927 // 0 equal
928 // 1 take local 928 // 1 take local
929 // 2 take remote 929 // 2 take remote
930 // 3 cancel 930 // 3 cancel
931 QDateTime lastSync = mLastCalendarSync; 931 QDateTime lastSync = mLastCalendarSync;
932 QDateTime localMod = local->lastModified(); 932 QDateTime localMod = local->lastModified();
933 QDateTime remoteMod = remote->lastModified(); 933 QDateTime remoteMod = remote->lastModified();
934 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 934 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
935 bool remCh, locCh; 935 bool remCh, locCh;
936 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 936 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
937 //if ( remCh ) 937 //if ( remCh )
938 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 938 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
939 locCh = ( localMod > mLastCalendarSync ); 939 locCh = ( localMod > mLastCalendarSync );
940 if ( !remCh && ! locCh ) { 940 if ( !remCh && ! locCh ) {
941 //qDebug("both not changed "); 941 //qDebug("both not changed ");
942 lastSync = localMod.addDays(1); 942 lastSync = localMod.addDays(1);
943 if ( mode <= SYNC_PREF_ASK ) 943 if ( mode <= SYNC_PREF_ASK )
944 return 0; 944 return 0;
945 } else { 945 } else {
946 if ( locCh ) { 946 if ( locCh ) {
947 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 947 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
948 lastSync = localMod.addDays( -1 ); 948 lastSync = localMod.addDays( -1 );
949 if ( !remCh ) 949 if ( !remCh )
950 remoteMod = ( lastSync.addDays( -1 ) ); 950 remoteMod = ( lastSync.addDays( -1 ) );
951 } else { 951 } else {
952 //qDebug(" not loc changed "); 952 //qDebug(" not loc changed ");
953 lastSync = localMod.addDays( 1 ); 953 lastSync = localMod.addDays( 1 );
954 if ( remCh ) 954 if ( remCh )
955 remoteMod =( lastSync.addDays( 1 ) ); 955 remoteMod =( lastSync.addDays( 1 ) );
956 956
957 } 957 }
958 } 958 }
959 full = true; 959 full = true;
960 if ( mode < SYNC_PREF_ASK ) 960 if ( mode < SYNC_PREF_ASK )
961 mode = SYNC_PREF_ASK; 961 mode = SYNC_PREF_ASK;
962 } else { 962 } else {
963 if ( localMod == remoteMod ) 963 if ( localMod == remoteMod )
964 // if ( local->revision() == remote->revision() ) 964 // if ( local->revision() == remote->revision() )
965 return 0; 965 return 0;
966 966
967 } 967 }
968 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 968 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
969 969
970 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 970 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
971 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 971 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
972 //full = true; //debug only 972 //full = true; //debug only
973 if ( full ) { 973 if ( full ) {
974 bool equ = false; 974 bool equ = false;
975 if ( local->type() == "Event" ) { 975 if ( local->type() == "Event" ) {
976 equ = (*((Event*) local) == *((Event*) remote)); 976 equ = (*((Event*) local) == *((Event*) remote));
977 } 977 }
978 else if ( local->type() =="Todo" ) 978 else if ( local->type() =="Todo" )
979 equ = (*((Todo*) local) == (*(Todo*) remote)); 979 equ = (*((Todo*) local) == (*(Todo*) remote));
980 else if ( local->type() =="Journal" ) 980 else if ( local->type() =="Journal" )
981 equ = (*((Journal*) local) == *((Journal*) remote)); 981 equ = (*((Journal*) local) == *((Journal*) remote));
982 if ( equ ) { 982 if ( equ ) {
983 //qDebug("equal "); 983 //qDebug("equal ");
984 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 984 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
985 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 985 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
986 } 986 }
987 if ( mode < SYNC_PREF_FORCE_LOCAL ) 987 if ( mode < SYNC_PREF_FORCE_LOCAL )
988 return 0; 988 return 0;
989 989
990 }//else //debug only 990 }//else //debug only
991 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 991 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
992 } 992 }
993 int result; 993 int result;
994 bool localIsNew; 994 bool localIsNew;
995 //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() ); 995 //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() );
996 996
997 997
998 // ************************************************ 998 // ************************************************
999 // ************************************************ 999 // ************************************************
1000 // ************************************************ 1000 // ************************************************
1001 // We may have that lastSync > remoteMod AND lastSync > localMod 1001 // We may have that lastSync > remoteMod AND lastSync > localMod
1002 // BUT remoteMod != localMod 1002 // BUT remoteMod != localMod
1003 1003
1004 1004
1005 if ( full && mode < SYNC_PREF_NEWEST ) 1005 if ( full && mode < SYNC_PREF_NEWEST )
1006 mode = SYNC_PREF_ASK; 1006 mode = SYNC_PREF_ASK;
1007 1007
1008 switch( mode ) { 1008 switch( mode ) {
1009 case SYNC_PREF_LOCAL: 1009 case SYNC_PREF_LOCAL:
1010 if ( lastSync > remoteMod ) 1010 if ( lastSync > remoteMod )
1011 return 1; 1011 return 1;
1012 if ( lastSync > localMod ) 1012 if ( lastSync > localMod )
1013 return 2; 1013 return 2;
1014 return 1; 1014 return 1;
1015 break; 1015 break;
1016 case SYNC_PREF_REMOTE: 1016 case SYNC_PREF_REMOTE:
1017 if ( lastSync > localMod ) 1017 if ( lastSync > localMod )
1018 return 2; 1018 return 2;
1019 if ( lastSync > remoteMod ) 1019 if ( lastSync > remoteMod )
1020 return 1; 1020 return 1;
1021 return 2; 1021 return 2;
1022 break; 1022 break;
1023 case SYNC_PREF_NEWEST: 1023 case SYNC_PREF_NEWEST:
1024 if ( localMod >= remoteMod ) 1024 if ( localMod >= remoteMod )
1025 return 1; 1025 return 1;
1026 else 1026 else
1027 return 2; 1027 return 2;
1028 break; 1028 break;
1029 case SYNC_PREF_ASK: 1029 case SYNC_PREF_ASK:
1030 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1030 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1031 if ( lastSync > remoteMod && lastSync > localMod) 1031 if ( lastSync > remoteMod && lastSync > localMod)
1032 return 0; 1032 return 0;
1033 if ( lastSync > remoteMod ) 1033 if ( lastSync > remoteMod )
1034 return 1; 1034 return 1;
1035 if ( lastSync > localMod ) 1035 if ( lastSync > localMod )
1036 return 2; 1036 return 2;
1037 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1037 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1038 localIsNew = localMod >= remoteMod; 1038 localIsNew = localMod >= remoteMod;
1039 if ( localIsNew ) 1039 if ( localIsNew )
1040 getEventViewerDialog()->setColorMode( 1 ); 1040 getEventViewerDialog()->setColorMode( 1 );
1041 else 1041 else
1042 getEventViewerDialog()->setColorMode( 2 ); 1042 getEventViewerDialog()->setColorMode( 2 );
1043 getEventViewerDialog()->setIncidence(local); 1043 getEventViewerDialog()->setIncidence(local);
1044 if ( localIsNew ) 1044 if ( localIsNew )
1045 getEventViewerDialog()->setColorMode( 2 ); 1045 getEventViewerDialog()->setColorMode( 2 );
1046 else 1046 else
1047 getEventViewerDialog()->setColorMode( 1 ); 1047 getEventViewerDialog()->setColorMode( 1 );
1048 getEventViewerDialog()->addIncidence(remote); 1048 getEventViewerDialog()->addIncidence(remote);
1049 getEventViewerDialog()->setColorMode( 0 ); 1049 getEventViewerDialog()->setColorMode( 0 );
1050 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1050 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1051 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1051 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1052 getEventViewerDialog()->showMe(); 1052 getEventViewerDialog()->showMe();
1053 result = getEventViewerDialog()->executeS( localIsNew ); 1053 result = getEventViewerDialog()->executeS( localIsNew );
1054 return result; 1054 return result;
1055 1055
1056 break; 1056 break;
1057 case SYNC_PREF_FORCE_LOCAL: 1057 case SYNC_PREF_FORCE_LOCAL:
1058 return 1; 1058 return 1;
1059 break; 1059 break;
1060 case SYNC_PREF_FORCE_REMOTE: 1060 case SYNC_PREF_FORCE_REMOTE:
1061 return 2; 1061 return 2;
1062 break; 1062 break;
1063 1063
1064 default: 1064 default:
1065 // SYNC_PREF_TAKE_BOTH not implemented 1065 // SYNC_PREF_TAKE_BOTH not implemented
1066 break; 1066 break;
1067 } 1067 }
1068 return 0; 1068 return 0;
1069} 1069}
1070Event* CalendarView::getLastSyncEvent() 1070Event* CalendarView::getLastSyncEvent()
1071{ 1071{
1072 Event* lse; 1072 Event* lse;
1073 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1073 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1074 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1074 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1075 if (!lse) { 1075 if (!lse) {
1076 lse = new Event(); 1076 lse = new Event();
1077 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1077 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1078 QString sum = ""; 1078 QString sum = "";
1079 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1079 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1080 sum = "E: "; 1080 sum = "E: ";
1081 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1081 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1082 lse->setDtStart( mLastCalendarSync ); 1082 lse->setDtStart( mLastCalendarSync );
1083 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1083 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1084 lse->setCategories( i18n("SyncEvent") ); 1084 lse->setCategories( i18n("SyncEvent") );
1085 lse->setReadOnly( true ); 1085 lse->setReadOnly( true );
1086 mCalendar->addEvent( lse ); 1086 mCalendar->addEvent( lse );
1087 } 1087 }
1088 1088
1089 return lse; 1089 return lse;
1090 1090
1091} 1091}
1092 1092
1093// we check, if the to delete event has a id for a profile 1093// we check, if the to delete event has a id for a profile
1094// if yes, we set this id in the profile to delete 1094// if yes, we set this id in the profile to delete
1095void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1095void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1096{ 1096{
1097 if ( lastSync.count() == 0 ) { 1097 if ( lastSync.count() == 0 ) {
1098 //qDebug(" lastSync.count() == 0"); 1098 //qDebug(" lastSync.count() == 0");
1099 return; 1099 return;
1100 } 1100 }
1101 if ( toDelete->type() == "Journal" ) 1101 if ( toDelete->type() == "Journal" )
1102 return; 1102 return;
1103 1103
1104 Event* eve = lastSync.first(); 1104 Event* eve = lastSync.first();
1105 1105
1106 while ( eve ) { 1106 while ( eve ) {
1107 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1107 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1108 if ( !id.isEmpty() ) { 1108 if ( !id.isEmpty() ) {
1109 QString des = eve->description(); 1109 QString des = eve->description();
1110 QString pref = "e"; 1110 QString pref = "e";
1111 if ( toDelete->type() == "Todo" ) 1111 if ( toDelete->type() == "Todo" )
1112 pref = "t"; 1112 pref = "t";
1113 des += pref+ id + ","; 1113 des += pref+ id + ",";
1114 eve->setReadOnly( false ); 1114 eve->setReadOnly( false );
1115 eve->setDescription( des ); 1115 eve->setDescription( des );
1116 //qDebug("setdes %s ", des.latin1()); 1116 //qDebug("setdes %s ", des.latin1());
1117 eve->setReadOnly( true ); 1117 eve->setReadOnly( true );
1118 } 1118 }
1119 eve = lastSync.next(); 1119 eve = lastSync.next();
1120 } 1120 }
1121 1121
1122} 1122}
1123void CalendarView::checkExternalId( Incidence * inc ) 1123void CalendarView::checkExternalId( Incidence * inc )
1124{ 1124{
1125 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1125 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1126 checkExternSyncEvent( lastSync, inc ); 1126 checkExternSyncEvent( lastSync, inc );
1127 1127
1128} 1128}
1129bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1129bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1130{ 1130{
1131 bool syncOK = true; 1131 bool syncOK = true;
1132 int addedEvent = 0; 1132 int addedEvent = 0;
1133 int addedEventR = 0; 1133 int addedEventR = 0;
1134 int deletedEventR = 0; 1134 int deletedEventR = 0;
1135 int deletedEventL = 0; 1135 int deletedEventL = 0;
1136 int changedLocal = 0; 1136 int changedLocal = 0;
1137 int changedRemote = 0; 1137 int changedRemote = 0;
1138 int filteredIN = 0; 1138 int filteredIN = 0;
1139 int filteredOUT = 0; 1139 int filteredOUT = 0;
1140 //QPtrList<Event> el = local->rawEvents(); 1140 //QPtrList<Event> el = local->rawEvents();
1141 Event* eventR; 1141 Event* eventR;
1142 QString uid; 1142 QString uid;
1143 int take; 1143 int take;
1144 Event* eventL; 1144 Event* eventL;
1145 Event* eventRSync; 1145 Event* eventRSync;
1146 Event* eventLSync; 1146 Event* eventLSync;
1147 clearAllViews();
1147 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1148 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1148 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1149 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1149 bool fullDateRange = false; 1150 bool fullDateRange = false;
1150 local->resetTempSyncStat(); 1151 local->resetTempSyncStat();
1151 mLastCalendarSync = QDateTime::currentDateTime(); 1152 mLastCalendarSync = QDateTime::currentDateTime();
1152 if ( mSyncManager->syncWithDesktop() ) { 1153 if ( mSyncManager->syncWithDesktop() ) {
1153 remote->resetPilotStat(1); 1154 remote->resetPilotStat(1);
1154 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1155 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1155 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1156 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1156 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1157 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1157 } else { 1158 } else {
1158 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1159 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1159 } 1160 }
1160 } 1161 }
1161 QDateTime modifiedCalendar = mLastCalendarSync; 1162 QDateTime modifiedCalendar = mLastCalendarSync;
1162 eventLSync = getLastSyncEvent(); 1163 eventLSync = getLastSyncEvent();
1163 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1164 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1164 if ( eventR ) { 1165 if ( eventR ) {
1165 eventRSync = (Event*) eventR->clone(); 1166 eventRSync = (Event*) eventR->clone();
1166 remote->deleteEvent(eventR ); 1167 remote->deleteEvent(eventR );
1167 1168
1168 } else { 1169 } else {
1169 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1170 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1170 eventRSync = (Event*)eventLSync->clone(); 1171 eventRSync = (Event*)eventLSync->clone();
1171 } else { 1172 } else {
1172 fullDateRange = true; 1173 fullDateRange = true;
1173 eventRSync = new Event(); 1174 eventRSync = new Event();
1174 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1175 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1175 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1176 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1176 eventRSync->setDtStart( mLastCalendarSync ); 1177 eventRSync->setDtStart( mLastCalendarSync );
1177 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1178 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1178 eventRSync->setCategories( i18n("SyncEvent") ); 1179 eventRSync->setCategories( i18n("SyncEvent") );
1179 } 1180 }
1180 } 1181 }
1181 if ( eventLSync->dtStart() == mLastCalendarSync ) 1182 if ( eventLSync->dtStart() == mLastCalendarSync )
1182 fullDateRange = true; 1183 fullDateRange = true;
1183 1184
1184 if ( ! fullDateRange ) { 1185 if ( ! fullDateRange ) {
1185 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1186 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1186 1187
1187 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1188 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1188 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1189 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1189 fullDateRange = true; 1190 fullDateRange = true;
1190 } 1191 }
1191 } 1192 }
1192 if ( mSyncManager->syncWithDesktop() ) { 1193 if ( mSyncManager->syncWithDesktop() ) {
1193 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1194 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1194 } 1195 }
1195 if ( fullDateRange ) 1196 if ( fullDateRange )
1196 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1197 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1197 else 1198 else
1198 mLastCalendarSync = eventLSync->dtStart(); 1199 mLastCalendarSync = eventLSync->dtStart();
1199 // for resyncing if own file has changed 1200 // for resyncing if own file has changed
1200 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1201 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1201 mLastCalendarSync = loadedFileVersion; 1202 mLastCalendarSync = loadedFileVersion;
1202 //qDebug("setting mLastCalendarSync "); 1203 //qDebug("setting mLastCalendarSync ");
1203 } 1204 }
1204 //qDebug("*************************** "); 1205 //qDebug("*************************** ");
1205 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1206 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1206 QPtrList<Incidence> er = remote->rawIncidences(); 1207 QPtrList<Incidence> er = remote->rawIncidences();
1207 Incidence* inR = er.first(); 1208 Incidence* inR = er.first();
1208 Incidence* inL; 1209 Incidence* inL;
1209 QProgressBar bar( er.count(),0 ); 1210 QProgressBar bar( er.count(),0 );
1210 bar.setCaption (i18n("Syncing - close to abort!") ); 1211 bar.setCaption (i18n("Syncing - close to abort!") );
1211 1212
1212 // ************** setting up filter ************* 1213 // ************** setting up filter *************
1213 CalFilter *filterIN = 0; 1214 CalFilter *filterIN = 0;
1214 CalFilter *filterOUT = 0; 1215 CalFilter *filterOUT = 0;
1215 CalFilter *filter = mFilters.first(); 1216 CalFilter *filter = mFilters.first();
1216 while(filter) { 1217 while(filter) {
1217 if ( filter->name() == mSyncManager->mFilterInCal ) 1218 if ( filter->name() == mSyncManager->mFilterInCal )
1218 filterIN = filter; 1219 filterIN = filter;
1219 if ( filter->name() == mSyncManager->mFilterOutCal ) 1220 if ( filter->name() == mSyncManager->mFilterOutCal )
1220 filterOUT = filter; 1221 filterOUT = filter;
1221 filter = mFilters.next(); 1222 filter = mFilters.next();
1222 } 1223 }
1223 int w = 300; 1224 int w = 300;
1224 if ( QApplication::desktop()->width() < 320 ) 1225 if ( QApplication::desktop()->width() < 320 )
1225 w = 220; 1226 w = 220;
1226 int h = bar.sizeHint().height() ; 1227 int h = bar.sizeHint().height() ;
1227 int dw = QApplication::desktop()->width(); 1228 int dw = QApplication::desktop()->width();
1228 int dh = QApplication::desktop()->height(); 1229 int dh = QApplication::desktop()->height();
1229 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1230 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1230 bar.show(); 1231 bar.show();
1231 int modulo = (er.count()/10)+1; 1232 int modulo = (er.count()/10)+1;
1232 int incCounter = 0; 1233 int incCounter = 0;
1233 while ( inR ) { 1234 while ( inR ) {
1234 if ( ! bar.isVisible() ) 1235 if ( ! bar.isVisible() )
1235 return false; 1236 return false;
1236 if ( incCounter % modulo == 0 ) 1237 if ( incCounter % modulo == 0 )
1237 bar.setProgress( incCounter ); 1238 bar.setProgress( incCounter );
1238 ++incCounter; 1239 ++incCounter;
1239 uid = inR->uid(); 1240 uid = inR->uid();
1240 bool skipIncidence = false; 1241 bool skipIncidence = false;
1241 if ( uid.left(15) == QString("last-syncEvent-") ) 1242 if ( uid.left(15) == QString("last-syncEvent-") )
1242 skipIncidence = true; 1243 skipIncidence = true;
1243 QString idS; 1244 QString idS;
1244 qApp->processEvents(); 1245 qApp->processEvents();
1245 if ( !skipIncidence ) { 1246 if ( !skipIncidence ) {
1246 inL = local->incidence( uid ); 1247 inL = local->incidence( uid );
1247 if ( inL ) { // maybe conflict - same uid in both calendars 1248 if ( inL ) { // maybe conflict - same uid in both calendars
1248 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1249 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1249 //qDebug("take %d %s ", take, inL->summary().latin1()); 1250 //qDebug("take %d %s ", take, inL->summary().latin1());
1250 if ( take == 3 ) 1251 if ( take == 3 )
1251 return false; 1252 return false;
1252 if ( take == 1 ) {// take local ********************** 1253 if ( take == 1 ) {// take local **********************
1253 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1254 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1254 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1255 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1255 else 1256 else
1256 idS = inR->IDStr(); 1257 idS = inR->IDStr();
1257 remote->deleteIncidence( inR ); 1258 remote->deleteIncidence( inR );
1258 inR = inL->clone(); 1259 inR = inL->clone();
1259 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1260 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1260 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1261 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1261 inR->setIDStr( idS ); 1262 inR->setIDStr( idS );
1262 remote->addIncidence( inR ); 1263 remote->addIncidence( inR );
1263 if ( mSyncManager->syncWithDesktop() ) 1264 if ( mSyncManager->syncWithDesktop() )
1264 inR->setPilotId( 2 ); 1265 inR->setPilotId( 2 );
1265 ++changedRemote; 1266 ++changedRemote;
1266 } else {// take remote ********************** 1267 } else {// take remote **********************
1267 idS = inL->IDStr(); 1268 idS = inL->IDStr();
1268 int pid = inL->pilotId(); 1269 int pid = inL->pilotId();
1269 local->deleteIncidence( inL ); 1270 local->deleteIncidence( inL );
1270 inL = inR->clone(); 1271 inL = inR->clone();
1271 if ( mSyncManager->syncWithDesktop() ) 1272 if ( mSyncManager->syncWithDesktop() )
1272 inL->setPilotId( pid ); 1273 inL->setPilotId( pid );
1273 inL->setIDStr( idS ); 1274 inL->setIDStr( idS );
1274 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1275 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1275 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1276 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1276 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1277 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1277 } 1278 }
1278 local->addIncidence( inL ); 1279 local->addIncidence( inL );
1279 ++changedLocal; 1280 ++changedLocal;
1280 } 1281 }
1281 } 1282 }
1282 } else { // no conflict ********** add or delete remote 1283 } else { // no conflict ********** add or delete remote
1283 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1284 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1284 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1285 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1285 QString des = eventLSync->description(); 1286 QString des = eventLSync->description();
1286 QString pref = "e"; 1287 QString pref = "e";
1287 if ( inR->type() == "Todo" ) 1288 if ( inR->type() == "Todo" )
1288 pref = "t"; 1289 pref = "t";
1289 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1290 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1290 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1291 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1291 //remote->deleteIncidence( inR ); 1292 //remote->deleteIncidence( inR );
1292 ++deletedEventR; 1293 ++deletedEventR;
1293 } else { 1294 } else {
1294 inR->setLastModified( modifiedCalendar ); 1295 inR->setLastModified( modifiedCalendar );
1295 inL = inR->clone(); 1296 inL = inR->clone();
1296 inL->setIDStr( ":" ); 1297 inL->setIDStr( ":" );
1297 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1298 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1298 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1299 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1299 local->addIncidence( inL ); 1300 local->addIncidence( inL );
1300 ++addedEvent; 1301 ++addedEvent;
1301 1302
1302 } 1303 }
1303 } else { 1304 } else {
1304 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1305 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1305 inR->setLastModified( modifiedCalendar ); 1306 inR->setLastModified( modifiedCalendar );
1306 inL = inR->clone(); 1307 inL = inR->clone();
1307 inL->setIDStr( ":" ); 1308 inL->setIDStr( ":" );
1308 local->addIncidence( inL ); 1309 local->addIncidence( inL );
1309 ++addedEvent; 1310 ++addedEvent;
1310 1311
1311 } else { 1312 } else {
1312 checkExternSyncEvent(eventRSyncSharp, inR); 1313 checkExternSyncEvent(eventRSyncSharp, inR);
1313 remote->deleteIncidence( inR ); 1314 remote->deleteIncidence( inR );
1314 ++deletedEventR; 1315 ++deletedEventR;
1315 } 1316 }
1316 } 1317 }
1317 } else { 1318 } else {
1318 ++filteredIN; 1319 ++filteredIN;
1319 } 1320 }
1320 } 1321 }
1321 } 1322 }
1322 inR = er.next(); 1323 inR = er.next();
1323 } 1324 }
1324 QPtrList<Incidence> el = local->rawIncidences(); 1325 QPtrList<Incidence> el = local->rawIncidences();
1325 inL = el.first(); 1326 inL = el.first();
1326 modulo = (el.count()/10)+1; 1327 modulo = (el.count()/10)+1;
1327 bar.setCaption (i18n("Add / remove events") ); 1328 bar.setCaption (i18n("Add / remove events") );
1328 bar.setTotalSteps ( el.count() ) ; 1329 bar.setTotalSteps ( el.count() ) ;
1329 bar.show(); 1330 bar.show();
1330 incCounter = 0; 1331 incCounter = 0;
1331 1332
1332 while ( inL ) { 1333 while ( inL ) {
1333 1334
1334 qApp->processEvents(); 1335 qApp->processEvents();
1335 if ( ! bar.isVisible() ) 1336 if ( ! bar.isVisible() )
1336 return false; 1337 return false;
1337 if ( incCounter % modulo == 0 ) 1338 if ( incCounter % modulo == 0 )
1338 bar.setProgress( incCounter ); 1339 bar.setProgress( incCounter );
1339 ++incCounter; 1340 ++incCounter;
1340 uid = inL->uid(); 1341 uid = inL->uid();
1341 bool skipIncidence = false; 1342 bool skipIncidence = false;
1342 if ( uid.left(15) == QString("last-syncEvent-") ) 1343 if ( uid.left(15) == QString("last-syncEvent-") )
1343 skipIncidence = true; 1344 skipIncidence = true;
1344 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1345 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1345 skipIncidence = true; 1346 skipIncidence = true;
1346 if ( !skipIncidence ) { 1347 if ( !skipIncidence ) {
1347 inR = remote->incidence( uid ); 1348 inR = remote->incidence( uid );
1348 if ( ! inR ) { 1349 if ( ! inR ) {
1349 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1350 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1350 // no conflict ********** add or delete local 1351 // no conflict ********** add or delete local
1351 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1352 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1352 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1353 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1353 checkExternSyncEvent(eventLSyncSharp, inL); 1354 checkExternSyncEvent(eventLSyncSharp, inL);
1354 local->deleteIncidence( inL ); 1355 local->deleteIncidence( inL );
1355 ++deletedEventL; 1356 ++deletedEventL;
1356 } else { 1357 } else {
1357 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1358 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1358 inL->removeID(mCurrentSyncDevice ); 1359 inL->removeID(mCurrentSyncDevice );
1359 ++addedEventR; 1360 ++addedEventR;
1360 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1361 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1361 inL->setLastModified( modifiedCalendar ); 1362 inL->setLastModified( modifiedCalendar );
1362 inR = inL->clone(); 1363 inR = inL->clone();
1363 inR->setIDStr( ":" ); 1364 inR->setIDStr( ":" );
1364 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1365 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1365 remote->addIncidence( inR ); 1366 remote->addIncidence( inR );
1366 } 1367 }
1367 } 1368 }
1368 } else { 1369 } else {
1369 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1370 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1370 checkExternSyncEvent(eventLSyncSharp, inL); 1371 checkExternSyncEvent(eventLSyncSharp, inL);
1371 local->deleteIncidence( inL ); 1372 local->deleteIncidence( inL );
1372 ++deletedEventL; 1373 ++deletedEventL;
1373 } else { 1374 } else {
1374 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1375 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1375 ++addedEventR; 1376 ++addedEventR;
1376 inL->setLastModified( modifiedCalendar ); 1377 inL->setLastModified( modifiedCalendar );
1377 inR = inL->clone(); 1378 inR = inL->clone();
1378 inR->setIDStr( ":" ); 1379 inR->setIDStr( ":" );
1379 remote->addIncidence( inR ); 1380 remote->addIncidence( inR );
1380 } 1381 }
1381 } 1382 }
1382 } 1383 }
1383 } else { 1384 } else {
1384 ++filteredOUT; 1385 ++filteredOUT;
1385 } 1386 }
1386 } 1387 }
1387 } 1388 }
1388 inL = el.next(); 1389 inL = el.next();
1389 } 1390 }
1390 int delFut = 0; 1391 int delFut = 0;
1391 int remRem = 0; 1392 int remRem = 0;
1392 if ( mSyncManager->mWriteBackInFuture ) { 1393 if ( mSyncManager->mWriteBackInFuture ) {
1393 er = remote->rawIncidences(); 1394 er = remote->rawIncidences();
1394 remRem = er.count(); 1395 remRem = er.count();
1395 inR = er.first(); 1396 inR = er.first();
1396 QDateTime dt; 1397 QDateTime dt;
1397 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1398 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1398 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1399 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1399 while ( inR ) { 1400 while ( inR ) {
1400 if ( inR->type() == "Todo" ) { 1401 if ( inR->type() == "Todo" ) {
1401 Todo * t = (Todo*)inR; 1402 Todo * t = (Todo*)inR;
1402 if ( t->hasDueDate() ) 1403 if ( t->hasDueDate() )
1403 dt = t->dtDue(); 1404 dt = t->dtDue();
1404 else 1405 else
1405 dt = cur.addSecs( 62 ); 1406 dt = cur.addSecs( 62 );
1406 } 1407 }
1407 else if (inR->type() == "Event" ) { 1408 else if (inR->type() == "Event" ) {
1408 bool ok; 1409 bool ok;
1409 dt = inR->getNextOccurence( cur, &ok ); 1410 dt = inR->getNextOccurence( cur, &ok );
1410 if ( !ok ) 1411 if ( !ok )
1411 dt = cur.addSecs( -62 ); 1412 dt = cur.addSecs( -62 );
1412 } 1413 }
1413 else 1414 else
1414 dt = inR->dtStart(); 1415 dt = inR->dtStart();
1415 if ( dt < cur || dt > end ) { 1416 if ( dt < cur || dt > end ) {
1416 remote->deleteIncidence( inR ); 1417 remote->deleteIncidence( inR );
1417 ++delFut; 1418 ++delFut;
1418 } 1419 }
1419 inR = er.next(); 1420 inR = er.next();
1420 } 1421 }
1421 } 1422 }
1422 bar.hide(); 1423 bar.hide();
1423 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1424 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1424 eventLSync->setReadOnly( false ); 1425 eventLSync->setReadOnly( false );
1425 eventLSync->setDtStart( mLastCalendarSync ); 1426 eventLSync->setDtStart( mLastCalendarSync );
1426 eventRSync->setDtStart( mLastCalendarSync ); 1427 eventRSync->setDtStart( mLastCalendarSync );
1427 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1428 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1428 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1429 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1429 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1430 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1430 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1431 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1431 eventLSync->setReadOnly( true ); 1432 eventLSync->setReadOnly( true );
1432 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1433 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1433 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1434 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1434 remote->addEvent( eventRSync ); 1435 remote->addEvent( eventRSync );
1435 else 1436 else
1436 delete eventRSync; 1437 delete eventRSync;
1437 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1438 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1438 QString mes; 1439 QString mes;
1439 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 ); 1440 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 );
1440 QString delmess; 1441 QString delmess;
1441 if ( delFut ) { 1442 if ( delFut ) {
1442 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); 1443 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);
1443 mes += delmess; 1444 mes += delmess;
1444 } 1445 }
1445 mes = i18n("Local calendar changed!\n") +mes; 1446 mes = i18n("Local calendar changed!\n") +mes;
1446 mCalendar->checkAlarmForIncidence( 0, true ); 1447 mCalendar->checkAlarmForIncidence( 0, true );
1447 qDebug( mes ); 1448 qDebug( mes );
1448 if ( mSyncManager->mShowSyncSummary ) { 1449 if ( mSyncManager->mShowSyncSummary ) {
1449 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1450 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1450 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1451 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1451 qDebug("KO: WB cancelled "); 1452 qDebug("KO: WB cancelled ");
1452 mSyncManager->mWriteBackFile = false; 1453 mSyncManager->mWriteBackFile = false;
1453 return syncOK; 1454 return syncOK;
1454 } 1455 }
1455 } 1456 }
1456 return syncOK; 1457 return syncOK;
1457} 1458}
1458 1459
1459void CalendarView::setSyncDevice( QString s ) 1460void CalendarView::setSyncDevice( QString s )
1460{ 1461{
1461 mCurrentSyncDevice= s; 1462 mCurrentSyncDevice= s;
1462} 1463}
1463void CalendarView::setSyncName( QString s ) 1464void CalendarView::setSyncName( QString s )
1464{ 1465{
1465 mCurrentSyncName= s; 1466 mCurrentSyncName= s;
1466} 1467}
1467bool CalendarView::syncCalendar(QString filename, int mode) 1468bool CalendarView::syncCalendar(QString filename, int mode)
1468{ 1469{
1469 //qDebug("syncCalendar %s ", filename.latin1()); 1470 //qDebug("syncCalendar %s ", filename.latin1());
1470 mGlobalSyncMode = SYNC_MODE_NORMAL; 1471 mGlobalSyncMode = SYNC_MODE_NORMAL;
1471 CalendarLocal* calendar = new CalendarLocal(); 1472 CalendarLocal* calendar = new CalendarLocal();
1472 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1473 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1473 FileStorage* storage = new FileStorage( calendar ); 1474 FileStorage* storage = new FileStorage( calendar );
1474 bool syncOK = false; 1475 bool syncOK = false;
1475 storage->setFileName( filename ); 1476 storage->setFileName( filename );
1476 // qDebug("loading ... "); 1477 // qDebug("loading ... ");
1477 if ( storage->load() ) { 1478 if ( storage->load() ) {
1478 getEventViewerDialog()->setSyncMode( true ); 1479 getEventViewerDialog()->setSyncMode( true );
1479 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1480 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1480 getEventViewerDialog()->setSyncMode( false ); 1481 getEventViewerDialog()->setSyncMode( false );
1481 if ( syncOK ) { 1482 if ( syncOK ) {
1482 if ( mSyncManager->mWriteBackFile ) 1483 if ( mSyncManager->mWriteBackFile )
1483 { 1484 {
1484 storage->setSaveFormat( new ICalFormat() ); 1485 storage->setSaveFormat( new ICalFormat() );
1485 storage->save(); 1486 storage->save();
1486 } 1487 }
1487 } 1488 }
1488 setModified( true ); 1489 setModified( true );
1489 } 1490 }
1490 delete storage; 1491 delete storage;
1491 delete calendar; 1492 delete calendar;
1492 if ( syncOK ) 1493 if ( syncOK )
1493 updateView(); 1494 updateView();
1494 return syncOK; 1495 return syncOK;
1495} 1496}
1496 1497
1497void CalendarView::syncExternal( int mode ) 1498void CalendarView::syncExternal( int mode )
1498{ 1499{
1499 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1500 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1500 1501
1501 qApp->processEvents(); 1502 qApp->processEvents();
1502 CalendarLocal* calendar = new CalendarLocal(); 1503 CalendarLocal* calendar = new CalendarLocal();
1503 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1504 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1504 bool syncOK = false; 1505 bool syncOK = false;
1505 bool loadSuccess = false; 1506 bool loadSuccess = false;
1506 PhoneFormat* phoneFormat = 0; 1507 PhoneFormat* phoneFormat = 0;
1507 emit tempDisableBR(true); 1508 emit tempDisableBR(true);
1508#ifndef DESKTOP_VERSION 1509#ifndef DESKTOP_VERSION
1509 SharpFormat* sharpFormat = 0; 1510 SharpFormat* sharpFormat = 0;
1510 if ( mode == 0 ) { // sharp 1511 if ( mode == 0 ) { // sharp
1511 sharpFormat = new SharpFormat () ; 1512 sharpFormat = new SharpFormat () ;
1512 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1513 loadSuccess = sharpFormat->load( calendar, mCalendar );
1513 1514
1514 } else 1515 } else
1515#endif 1516#endif
1516 if ( mode == 1 ) { // phone 1517 if ( mode == 1 ) { // phone
1517 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1518 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1518 mSyncManager->mPhoneDevice, 1519 mSyncManager->mPhoneDevice,
1519 mSyncManager->mPhoneConnection, 1520 mSyncManager->mPhoneConnection,
1520 mSyncManager->mPhoneModel); 1521 mSyncManager->mPhoneModel);
1521 loadSuccess = phoneFormat->load( calendar,mCalendar); 1522 loadSuccess = phoneFormat->load( calendar,mCalendar);
1522 1523
1523 } else { 1524 } else {
1524 emit tempDisableBR(false); 1525 emit tempDisableBR(false);
1525 return; 1526 return;
1526 } 1527 }
1527 if ( loadSuccess ) { 1528 if ( loadSuccess ) {
1528 getEventViewerDialog()->setSyncMode( true ); 1529 getEventViewerDialog()->setSyncMode( true );
1529 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1530 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1530 getEventViewerDialog()->setSyncMode( false ); 1531 getEventViewerDialog()->setSyncMode( false );
1531 qApp->processEvents(); 1532 qApp->processEvents();
1532 if ( syncOK ) { 1533 if ( syncOK ) {
1533 if ( mSyncManager->mWriteBackFile ) 1534 if ( mSyncManager->mWriteBackFile )
1534 { 1535 {
1535 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1536 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1536 Incidence* inc = iL.first(); 1537 Incidence* inc = iL.first();
1537 if ( phoneFormat ) { 1538 if ( phoneFormat ) {
1538 while ( inc ) { 1539 while ( inc ) {
1539 inc->removeID(mCurrentSyncDevice); 1540 inc->removeID(mCurrentSyncDevice);
1540 inc = iL.next(); 1541 inc = iL.next();
1541 } 1542 }
1542 } 1543 }
1543#ifndef DESKTOP_VERSION 1544#ifndef DESKTOP_VERSION
1544 if ( sharpFormat ) 1545 if ( sharpFormat )
1545 sharpFormat->save(calendar); 1546 sharpFormat->save(calendar);
1546#endif 1547#endif
1547 if ( phoneFormat ) 1548 if ( phoneFormat )
1548 phoneFormat->save(calendar); 1549 phoneFormat->save(calendar);
1549 iL = calendar->rawIncidences(); 1550 iL = calendar->rawIncidences();
1550 inc = iL.first(); 1551 inc = iL.first();
1551 Incidence* loc; 1552 Incidence* loc;
1552 while ( inc ) { 1553 while ( inc ) {
1553 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1554 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1554 loc = mCalendar->incidence(inc->uid() ); 1555 loc = mCalendar->incidence(inc->uid() );
1555 if ( loc ) { 1556 if ( loc ) {
1556 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1557 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1557 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1558 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1558 } 1559 }
1559 } 1560 }
1560 inc = iL.next(); 1561 inc = iL.next();
1561 } 1562 }
1562 Incidence* lse = getLastSyncEvent(); 1563 Incidence* lse = getLastSyncEvent();
1563 if ( lse ) { 1564 if ( lse ) {
1564 lse->setReadOnly( false ); 1565 lse->setReadOnly( false );
1565 lse->setDescription( "" ); 1566 lse->setDescription( "" );
1566 lse->setReadOnly( true ); 1567 lse->setReadOnly( true );
1567 } 1568 }
1568 } 1569 }
1569 } else { 1570 } else {
1570 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1571 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1571 } 1572 }
1572 setModified( true ); 1573 setModified( true );
1573 } else { 1574 } else {
1574 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1575 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1575 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1576 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1576 question, i18n("Ok")) ; 1577 question, i18n("Ok")) ;
1577 1578
1578 } 1579 }
1579 delete calendar; 1580 delete calendar;
1580 updateView(); 1581 updateView();
1581 emit tempDisableBR(false); 1582 emit tempDisableBR(false);
1582 return ;//syncOK; 1583 return ;//syncOK;
1583 1584
1584} 1585}
1585 1586
1586bool CalendarView::importBday() 1587bool CalendarView::importBday()
1587{ 1588{
1588#ifndef KORG_NOKABC 1589#ifndef KORG_NOKABC
1589 1590
1590#ifdef DESKTOP_VERSION 1591#ifdef DESKTOP_VERSION
1591 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1592 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1592 KABC::AddressBook::Iterator it; 1593 KABC::AddressBook::Iterator it;
1593 int count = 0; 1594 int count = 0;
1594 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1595 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1595 ++count; 1596 ++count;
1596 } 1597 }
1597 QProgressBar bar(count,0 ); 1598 QProgressBar bar(count,0 );
1598 int w = 300; 1599 int w = 300;
1599 if ( QApplication::desktop()->width() < 320 ) 1600 if ( QApplication::desktop()->width() < 320 )
1600 w = 220; 1601 w = 220;
1601 int h = bar.sizeHint().height() ; 1602 int h = bar.sizeHint().height() ;
1602 int dw = QApplication::desktop()->width(); 1603 int dw = QApplication::desktop()->width();
1603 int dh = QApplication::desktop()->height(); 1604 int dh = QApplication::desktop()->height();
1604 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1605 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1605 bar.show(); 1606 bar.show();
1606 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1607 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1607 qApp->processEvents(); 1608 qApp->processEvents();
1608 count = 0; 1609 count = 0;
1609 int addCount = 0; 1610 int addCount = 0;
1610 KCal::Attendee* a = 0; 1611 KCal::Attendee* a = 0;
1611 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1612 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1612 if ( ! bar.isVisible() ) 1613 if ( ! bar.isVisible() )
1613 return false; 1614 return false;
1614 bar.setProgress( count++ ); 1615 bar.setProgress( count++ );
1615 qApp->processEvents(); 1616 qApp->processEvents();
1616 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1617 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1617 if ( (*it).birthday().date().isValid() ){ 1618 if ( (*it).birthday().date().isValid() ){
1618 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1619 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1619 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1620 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1620 ++addCount; 1621 ++addCount;
1621 } 1622 }
1622 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1623 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1623 if ( anni.isValid() ){ 1624 if ( anni.isValid() ){
1624 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1625 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1625 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1626 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1626 ++addCount; 1627 ++addCount;
1627 } 1628 }
1628 } 1629 }
1629 updateView(); 1630 updateView();
1630 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1631 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1631#else //DESKTOP_VERSION 1632#else //DESKTOP_VERSION
1632 1633
1633 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1634 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1634 // the result should now arrive through method insertBirthdays 1635 // the result should now arrive through method insertBirthdays
1635 1636
1636#endif //DESKTOP_VERSION 1637#endif //DESKTOP_VERSION
1637 1638
1638#endif //KORG_NOKABC 1639#endif //KORG_NOKABC
1639 1640
1640 1641
1641 return true; 1642 return true;
1642} 1643}
1643 1644
1644// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1645// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1645void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1646void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1646 const QStringList& anniversaryList, const QStringList& realNameList, 1647 const QStringList& anniversaryList, const QStringList& realNameList,
1647 const QStringList& emailList, const QStringList& assembledNameList, 1648 const QStringList& emailList, const QStringList& assembledNameList,
1648 const QStringList& uidList) 1649 const QStringList& uidList)
1649{ 1650{
1650 //qDebug("KO::CalendarView::insertBirthdays"); 1651 //qDebug("KO::CalendarView::insertBirthdays");
1651 if (uid == this->name()) 1652 if (uid == this->name())
1652 { 1653 {
1653 int count = birthdayList.count(); 1654 int count = birthdayList.count();
1654 int addCount = 0; 1655 int addCount = 0;
1655 KCal::Attendee* a = 0; 1656 KCal::Attendee* a = 0;
1656 1657
1657 //qDebug("CalView 1 %i", count); 1658 //qDebug("CalView 1 %i", count);
1658 1659
1659 QProgressBar bar(count,0 ); 1660 QProgressBar bar(count,0 );
1660 int w = 300; 1661 int w = 300;
1661 if ( QApplication::desktop()->width() < 320 ) 1662 if ( QApplication::desktop()->width() < 320 )
1662 w = 220; 1663 w = 220;
1663 int h = bar.sizeHint().height() ; 1664 int h = bar.sizeHint().height() ;
1664 int dw = QApplication::desktop()->width(); 1665 int dw = QApplication::desktop()->width();
1665 int dh = QApplication::desktop()->height(); 1666 int dh = QApplication::desktop()->height();
1666 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1667 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1667 bar.show(); 1668 bar.show();
1668 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1669 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1669 qApp->processEvents(); 1670 qApp->processEvents();
1670 1671
1671 QDate birthday; 1672 QDate birthday;
1672 QDate anniversary; 1673 QDate anniversary;
1673 QString realName; 1674 QString realName;
1674 QString email; 1675 QString email;
1675 QString assembledName; 1676 QString assembledName;
1676 QString uid; 1677 QString uid;
1677 bool ok = true; 1678 bool ok = true;
1678 for ( int i = 0; i < count; i++) 1679 for ( int i = 0; i < count; i++)
1679 { 1680 {
1680 if ( ! bar.isVisible() ) 1681 if ( ! bar.isVisible() )
1681 return; 1682 return;
1682 bar.setProgress( i ); 1683 bar.setProgress( i );
1683 qApp->processEvents(); 1684 qApp->processEvents();
1684 1685
1685 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1686 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1686 if (!ok) { 1687 if (!ok) {
1687 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1688 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1688 } 1689 }
1689 1690
1690 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1691 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1691 if (!ok) { 1692 if (!ok) {
1692 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1693 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1693 } 1694 }
1694 realName = realNameList[i]; 1695 realName = realNameList[i];
1695 email = emailList[i]; 1696 email = emailList[i];
1696 assembledName = assembledNameList[i]; 1697 assembledName = assembledNameList[i];
1697 uid = uidList[i]; 1698 uid = uidList[i];
1698 //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() ); 1699 //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() );
1699 1700
1700 if ( birthday.isValid() ){ 1701 if ( birthday.isValid() ){
1701 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1702 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1702 KCal::Attendee::ReqParticipant,uid) ; 1703 KCal::Attendee::ReqParticipant,uid) ;
1703 if ( addAnniversary( birthday, assembledName, a, true ) ) 1704 if ( addAnniversary( birthday, assembledName, a, true ) )
1704 ++addCount; 1705 ++addCount;
1705 } 1706 }
1706 1707
1707 if ( anniversary.isValid() ){ 1708 if ( anniversary.isValid() ){
1708 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1709 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1709 KCal::Attendee::ReqParticipant,uid) ; 1710 KCal::Attendee::ReqParticipant,uid) ;
1710 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1711 if ( addAnniversary( anniversary, assembledName, a, false ) )
1711 ++addCount; 1712 ++addCount;
1712 } 1713 }
1713 } 1714 }
1714 1715
1715 updateView(); 1716 updateView();
1716 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1717 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1717 1718
1718 } 1719 }
1719 1720
1720} 1721}
1721 1722
1722 1723
1723 1724
1724bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1725bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1725{ 1726{
1726 //qDebug("addAnni "); 1727 //qDebug("addAnni ");
1727 Event * ev = new Event(); 1728 Event * ev = new Event();
1728 ev->setOrganizer(KOPrefs::instance()->email()); 1729 ev->setOrganizer(KOPrefs::instance()->email());
1729 if ( a ) { 1730 if ( a ) {
1730 ev->addAttendee( a ); 1731 ev->addAttendee( a );
1731 } 1732 }
1732 QString kind; 1733 QString kind;
1733 if ( birthday ) { 1734 if ( birthday ) {
1734 kind = i18n( "Birthday" ); 1735 kind = i18n( "Birthday" );
1735 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1736 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1736 } 1737 }
1737 else { 1738 else {
1738 kind = i18n( "Anniversary" ); 1739 kind = i18n( "Anniversary" );
1739 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1740 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1740 } 1741 }
1741 ev->setCategories( kind ); 1742 ev->setCategories( kind );
1742 ev->setDtStart( QDateTime(date) ); 1743 ev->setDtStart( QDateTime(date) );
1743 ev->setDtEnd( QDateTime(date) ); 1744 ev->setDtEnd( QDateTime(date) );
1744 ev->setFloats( true ); 1745 ev->setFloats( true );
1745 Recurrence * rec = ev->recurrence(); 1746 Recurrence * rec = ev->recurrence();
1746 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1747 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1747 rec->addYearlyNum( date.month() ); 1748 rec->addYearlyNum( date.month() );
1748 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1749 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1749 delete ev; 1750 delete ev;
1750 return false; 1751 return false;
1751 } 1752 }
1752 return true; 1753 return true;
1753 1754
1754} 1755}
1755bool CalendarView::importQtopia( const QString &categories, 1756bool CalendarView::importQtopia( const QString &categories,
1756 const QString &datebook, 1757 const QString &datebook,
1757 const QString &todolist ) 1758 const QString &todolist )
1758{ 1759{
1759 1760
1760 QtopiaFormat qtopiaFormat; 1761 QtopiaFormat qtopiaFormat;
1761 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1762 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1762 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1763 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1763 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1764 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1764 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1765 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1765 1766
1766 updateView(); 1767 updateView();
1767 return true; 1768 return true;
1768 1769
1769#if 0 1770#if 0
1770 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1771 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1771 mCurrentSyncDevice = "qtopia-XML"; 1772 mCurrentSyncDevice = "qtopia-XML";
1772 if ( mSyncManager->mAskForPreferences ) 1773 if ( mSyncManager->mAskForPreferences )
1773 edit_sync_options(); 1774 edit_sync_options();
1774 qApp->processEvents(); 1775 qApp->processEvents();
1775 CalendarLocal* calendar = new CalendarLocal(); 1776 CalendarLocal* calendar = new CalendarLocal();
1776 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1777 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1777 bool syncOK = false; 1778 bool syncOK = false;
1778 QtopiaFormat qtopiaFormat; 1779 QtopiaFormat qtopiaFormat;
1779 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1780 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1780 bool loadOk = true; 1781 bool loadOk = true;
1781 if ( !categories.isEmpty() ) 1782 if ( !categories.isEmpty() )
1782 loadOk = qtopiaFormat.load( calendar, categories ); 1783 loadOk = qtopiaFormat.load( calendar, categories );
1783 if ( loadOk && !datebook.isEmpty() ) 1784 if ( loadOk && !datebook.isEmpty() )
1784 loadOk = qtopiaFormat.load( calendar, datebook ); 1785 loadOk = qtopiaFormat.load( calendar, datebook );
1785 if ( loadOk && !todolist.isEmpty() ) 1786 if ( loadOk && !todolist.isEmpty() )
1786 loadOk = qtopiaFormat.load( calendar, todolist ); 1787 loadOk = qtopiaFormat.load( calendar, todolist );
1787 1788
1788 if ( loadOk ) { 1789 if ( loadOk ) {
1789 getEventViewerDialog()->setSyncMode( true ); 1790 getEventViewerDialog()->setSyncMode( true );
1790 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1791 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1791 getEventViewerDialog()->setSyncMode( false ); 1792 getEventViewerDialog()->setSyncMode( false );
1792 qApp->processEvents(); 1793 qApp->processEvents();
1793 if ( syncOK ) { 1794 if ( syncOK ) {
1794 if ( mSyncManager->mWriteBackFile ) 1795 if ( mSyncManager->mWriteBackFile )
1795 { 1796 {
1796 // write back XML file 1797 // write back XML file
1797 1798
1798 } 1799 }
1799 setModified( true ); 1800 setModified( true );
1800 } 1801 }
1801 } else { 1802 } else {
1802 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1803 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1803 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1804 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1804 question, i18n("Ok")) ; 1805 question, i18n("Ok")) ;
1805 } 1806 }
1806 delete calendar; 1807 delete calendar;
1807 updateView(); 1808 updateView();
1808 return syncOK; 1809 return syncOK;
1809 1810
1810 1811
1811#endif 1812#endif
1812 1813
1813} 1814}
1814 1815
1815void CalendarView::setSyncEventsReadOnly() 1816void CalendarView::setSyncEventsReadOnly()
1816{ 1817{
1817 Event * ev; 1818 Event * ev;
1818 QPtrList<Event> eL = mCalendar->rawEvents(); 1819 QPtrList<Event> eL = mCalendar->rawEvents();
1819 ev = eL.first(); 1820 ev = eL.first();
1820 while ( ev ) { 1821 while ( ev ) {
1821 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1822 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1822 ev->setReadOnly( true ); 1823 ev->setReadOnly( true );
1823 ev = eL.next(); 1824 ev = eL.next();
1824 } 1825 }
1825} 1826}
1826bool CalendarView::openCalendar(QString filename, bool merge) 1827bool CalendarView::openCalendar(QString filename, bool merge)
1827{ 1828{
1828 1829
1829 if (filename.isEmpty()) { 1830 if (filename.isEmpty()) {
1830 return false; 1831 return false;
1831 } 1832 }
1832 1833
1833 if (!QFile::exists(filename)) { 1834 if (!QFile::exists(filename)) {
1834 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1835 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1835 return false; 1836 return false;
1836 } 1837 }
1837 1838
1838 globalFlagBlockAgenda = 1; 1839 globalFlagBlockAgenda = 1;
1840 clearAllViews();
1839 if (!merge) { 1841 if (!merge) {
1840 mTodoList->clearList();
1841 mViewManager->setDocumentId( filename ); 1842 mViewManager->setDocumentId( filename );
1842 mCalendar->close(); 1843 mCalendar->close();
1843 } 1844 }
1844 mStorage->setFileName( filename ); 1845 mStorage->setFileName( filename );
1845 1846
1846 if ( mStorage->load() ) { 1847 if ( mStorage->load() ) {
1847 if ( merge ) ;//setModified( true ); 1848 if ( merge ) ;//setModified( true );
1848 else { 1849 else {
1849 //setModified( true ); 1850 //setModified( true );
1850 mViewManager->setDocumentId( filename ); 1851 mViewManager->setDocumentId( filename );
1851 mDialogManager->setDocumentId( filename ); 1852 mDialogManager->setDocumentId( filename );
1852 mTodoList->setDocumentId( filename ); 1853 mTodoList->setDocumentId( filename );
1853 } 1854 }
1854 globalFlagBlockAgenda = 2; 1855 globalFlagBlockAgenda = 2;
1855 // if ( getLastSyncEvent() ) 1856 // if ( getLastSyncEvent() )
1856 // getLastSyncEvent()->setReadOnly( true ); 1857 // getLastSyncEvent()->setReadOnly( true );
1857 mCalendar->reInitAlarmSettings(); 1858 mCalendar->reInitAlarmSettings();
1858 setSyncEventsReadOnly(); 1859 setSyncEventsReadOnly();
1859 updateUnmanagedViews(); 1860 updateUnmanagedViews();
1860 updateView(); 1861 updateView();
1861 if ( filename != MainWindow::defaultFileName() ) { 1862 if ( filename != MainWindow::defaultFileName() ) {
1862 saveCalendar( MainWindow::defaultFileName() ); 1863 saveCalendar( MainWindow::defaultFileName() );
1863 } else { 1864 } else {
1864 QFileInfo finf ( MainWindow::defaultFileName()); 1865 QFileInfo finf ( MainWindow::defaultFileName());
1865 if ( finf.exists() ) { 1866 if ( finf.exists() ) {
1866 setLoadedFileVersion( finf.lastModified () ); 1867 setLoadedFileVersion( finf.lastModified () );
1867 } 1868 }
1868 } 1869 }
1869 return true; 1870 return true;
1870 } else { 1871 } else {
1871 // while failing to load, the calendar object could 1872 // while failing to load, the calendar object could
1872 // have become partially populated. Clear it out. 1873 // have become partially populated. Clear it out.
1873 if ( !merge ) { 1874 if ( !merge ) {
1874 mCalendar->close(); 1875 mCalendar->close();
1875 mViewManager->setDocumentId( filename ); 1876 mViewManager->setDocumentId( filename );
1876 mDialogManager->setDocumentId( filename ); 1877 mDialogManager->setDocumentId( filename );
1877 mTodoList->setDocumentId( filename ); 1878 mTodoList->setDocumentId( filename );
1878 } 1879 }
1879 1880
1880 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1881 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1881 1882
1882 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1883 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1883 globalFlagBlockAgenda = 2; 1884 globalFlagBlockAgenda = 2;
1884 mCalendar->reInitAlarmSettings(); 1885 mCalendar->reInitAlarmSettings();
1885 setSyncEventsReadOnly(); 1886 setSyncEventsReadOnly();
1886 updateUnmanagedViews(); 1887 updateUnmanagedViews();
1887 updateView(); 1888 updateView();
1888 } 1889 }
1889 return false; 1890 return false;
1890} 1891}
1891void CalendarView::showOpenError() 1892void CalendarView::showOpenError()
1892{ 1893{
1893 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1894 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1894} 1895}
1895void CalendarView::setLoadedFileVersion(QDateTime dt) 1896void CalendarView::setLoadedFileVersion(QDateTime dt)
1896{ 1897{
1897 loadedFileVersion = dt; 1898 loadedFileVersion = dt;
1898} 1899}
1899bool CalendarView::checkFileChanged(QString fn) 1900bool CalendarView::checkFileChanged(QString fn)
1900{ 1901{
1901 QFileInfo finf ( fn ); 1902 QFileInfo finf ( fn );
1902 if ( !finf.exists() ) 1903 if ( !finf.exists() )
1903 return true; 1904 return true;
1904 QDateTime dt = finf.lastModified (); 1905 QDateTime dt = finf.lastModified ();
1905 if ( dt <= loadedFileVersion ) 1906 if ( dt <= loadedFileVersion )
1906 return false; 1907 return false;
1907 return true; 1908 return true;
1908 1909
1909} 1910}
1910void CalendarView::watchSavedFile() 1911void CalendarView::watchSavedFile()
1911{ 1912{
1912 QFileInfo finf ( MainWindow::defaultFileName()); 1913 QFileInfo finf ( MainWindow::defaultFileName());
1913 if ( !finf.exists() ) 1914 if ( !finf.exists() )
1914 return; 1915 return;
1915 QDateTime dt = finf.lastModified (); 1916 QDateTime dt = finf.lastModified ();
1916 if ( dt < loadedFileVersion ) { 1917 if ( dt < loadedFileVersion ) {
1917 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1918 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1918 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1919 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1919 return; 1920 return;
1920 } 1921 }
1921 loadedFileVersion = dt; 1922 loadedFileVersion = dt;
1922} 1923}
1923 1924
1924bool CalendarView::checkFileVersion(QString fn) 1925bool CalendarView::checkFileVersion(QString fn)
1925{ 1926{
1926 QFileInfo finf ( fn ); 1927 QFileInfo finf ( fn );
1927 if ( !finf.exists() ) 1928 if ( !finf.exists() )
1928 return true; 1929 return true;
1929 QDateTime dt = finf.lastModified (); 1930 QDateTime dt = finf.lastModified ();
1930 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1931 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1931 //qDebug("file on disk version %s",dt.toString().latin1()); 1932 //qDebug("file on disk version %s",dt.toString().latin1());
1932 if ( dt <= loadedFileVersion ) 1933 if ( dt <= loadedFileVersion )
1933 return true; 1934 return true;
1934 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1935 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1935 i18n("KO/Pi Warning"),i18n("Overwrite"), 1936 i18n("KO/Pi Warning"),i18n("Overwrite"),
1936 i18n("Sync+save")); 1937 i18n("Sync+save"));
1937 1938
1938 if ( km == KMessageBox::Cancel ) 1939 if ( km == KMessageBox::Cancel )
1939 return false; 1940 return false;
1940 if ( km == KMessageBox::Yes ) 1941 if ( km == KMessageBox::Yes )
1941 return true; 1942 return true;
1942 1943
1943 setSyncDevice("deleteaftersync" ); 1944 setSyncDevice("deleteaftersync" );
1944 mSyncManager->mAskForPreferences = true; 1945 mSyncManager->mAskForPreferences = true;
1945 mSyncManager->mSyncAlgoPrefs = 3; 1946 mSyncManager->mSyncAlgoPrefs = 3;
1946 mSyncManager->mWriteBackFile = false; 1947 mSyncManager->mWriteBackFile = false;
1947 mSyncManager->mWriteBackExistingOnly = false; 1948 mSyncManager->mWriteBackExistingOnly = false;
1948 mSyncManager->mShowSyncSummary = false; 1949 mSyncManager->mShowSyncSummary = false;
1949 syncCalendar( fn, 3 ); 1950 syncCalendar( fn, 3 );
1950 Event * e = getLastSyncEvent(); 1951 Event * e = getLastSyncEvent();
1951 mCalendar->deleteEvent ( e ); 1952 if ( e )
1953 deleteEvent ( e );
1952 updateView(); 1954 updateView();
1953 return true; 1955 return true;
1954} 1956}
1955 1957
1956bool CalendarView::saveCalendar( QString filename ) 1958bool CalendarView::saveCalendar( QString filename )
1957{ 1959{
1958 1960
1959 // Store back all unsaved data into calendar object 1961 // Store back all unsaved data into calendar object
1960 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1962 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1961 if ( mViewManager->currentView() ) 1963 if ( mViewManager->currentView() )
1962 mViewManager->currentView()->flushView(); 1964 mViewManager->currentView()->flushView();
1963 1965
1964 1966
1965 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1967 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1966 mStorage->setSaveFormat( new ICalFormat() ); 1968 mStorage->setSaveFormat( new ICalFormat() );
1967 mStorage->setFileName( filename ); 1969 mStorage->setFileName( filename );
1968 bool success; 1970 bool success;
1969 success = mStorage->save(); 1971 success = mStorage->save();
1970 if ( !success ) { 1972 if ( !success ) {
1971 return false; 1973 return false;
1972 } 1974 }
1973 if ( filename == MainWindow::defaultFileName() ) { 1975 if ( filename == MainWindow::defaultFileName() ) {
1974 setLoadedFileVersion( lfv ); 1976 setLoadedFileVersion( lfv );
1975 watchSavedFile(); 1977 watchSavedFile();
1976 } 1978 }
1977 return true; 1979 return true;
1978} 1980}
1979 1981
1980void CalendarView::closeCalendar() 1982void CalendarView::closeCalendar()
1981{ 1983{
1982 1984
1983 // child windows no longer valid 1985 // child windows no longer valid
1986 clearAllViews();
1984 emit closingDown(); 1987 emit closingDown();
1985 1988
1986 mCalendar->close(); 1989 mCalendar->close();
1987 setModified(false); 1990 setModified(false);
1988 updateView(); 1991 updateView();
1989} 1992}
1990 1993
1991void CalendarView::archiveCalendar() 1994void CalendarView::archiveCalendar()
1992{ 1995{
1993 mDialogManager->showArchiveDialog(); 1996 mDialogManager->showArchiveDialog();
1994} 1997}
1995 1998
1996 1999
1997void CalendarView::readSettings() 2000void CalendarView::readSettings()
1998{ 2001{
1999 2002
2000 2003
2001 // mViewManager->showAgendaView(); 2004 // mViewManager->showAgendaView();
2002 QString str; 2005 QString str;
2003 //qDebug("CalendarView::readSettings() "); 2006 //qDebug("CalendarView::readSettings() ");
2004 // read settings from the KConfig, supplying reasonable 2007 // read settings from the KConfig, supplying reasonable
2005 // defaults where none are to be found 2008 // defaults where none are to be found
2006 KConfig *config = KOGlobals::config(); 2009 KConfig *config = KOGlobals::config();
2007#ifndef KORG_NOSPLITTER 2010#ifndef KORG_NOSPLITTER
2008 config->setGroup("KOrganizer Geometry"); 2011 config->setGroup("KOrganizer Geometry");
2009 2012
2010 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2013 QValueList<int> sizes = config->readIntListEntry("Separator1");
2011 if (sizes.count() != 2) { 2014 if (sizes.count() != 2) {
2012 sizes << mDateNavigator->minimumSizeHint().width(); 2015 sizes << mDateNavigator->minimumSizeHint().width();
2013 sizes << 300; 2016 sizes << 300;
2014 } 2017 }
2015 mPanner->setSizes(sizes); 2018 mPanner->setSizes(sizes);
2016 2019
2017 sizes = config->readIntListEntry("Separator2"); 2020 sizes = config->readIntListEntry("Separator2");
2018 if ( ( mResourceView && sizes.count() == 4 ) || 2021 if ( ( mResourceView && sizes.count() == 4 ) ||
2019 ( !mResourceView && sizes.count() == 3 ) ) { 2022 ( !mResourceView && sizes.count() == 3 ) ) {
2020 mLeftSplitter->setSizes(sizes); 2023 mLeftSplitter->setSizes(sizes);
2021 } 2024 }
2022#endif 2025#endif
2023 globalFlagBlockAgenda = 1; 2026 globalFlagBlockAgenda = 1;
2024 mViewManager->showAgendaView(); 2027 mViewManager->showAgendaView();
2025 //mViewManager->readSettings( config ); 2028 //mViewManager->readSettings( config );
2026 mTodoList->restoreLayout(config,QString("Todo Layout")); 2029 mTodoList->restoreLayout(config,QString("Todo Layout"));
2027 readFilterSettings(config); 2030 readFilterSettings(config);
2028 2031
2029#ifdef DESKTOP_VERSION 2032#ifdef DESKTOP_VERSION
2030 config->setGroup("WidgetLayout"); 2033 config->setGroup("WidgetLayout");
2031 QStringList list; 2034 QStringList list;
2032 list = config->readListEntry("MainLayout"); 2035 list = config->readListEntry("MainLayout");
2033 int x,y,w,h; 2036 int x,y,w,h;
2034 if ( ! list.isEmpty() ) { 2037 if ( ! list.isEmpty() ) {
2035 x = list[0].toInt(); 2038 x = list[0].toInt();
2036 y = list[1].toInt(); 2039 y = list[1].toInt();
2037 w = list[2].toInt(); 2040 w = list[2].toInt();
2038 h = list[3].toInt(); 2041 h = list[3].toInt();
2039 KApplication::testCoords( &x,&y,&w,&h ); 2042 KApplication::testCoords( &x,&y,&w,&h );
2040 topLevelWidget()->setGeometry(x,y,w,h); 2043 topLevelWidget()->setGeometry(x,y,w,h);
2041 2044
2042 } else { 2045 } else {
2043 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2046 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2044 } 2047 }
2045 list = config->readListEntry("EditEventLayout"); 2048 list = config->readListEntry("EditEventLayout");
2046 if ( ! list.isEmpty() ) { 2049 if ( ! list.isEmpty() ) {
2047 x = list[0].toInt(); 2050 x = list[0].toInt();
2048 y = list[1].toInt(); 2051 y = list[1].toInt();
2049 w = list[2].toInt(); 2052 w = list[2].toInt();
2050 h = list[3].toInt(); 2053 h = list[3].toInt();
2051 KApplication::testCoords( &x,&y,&w,&h ); 2054 KApplication::testCoords( &x,&y,&w,&h );
2052 mEventEditor->setGeometry(x,y,w,h); 2055 mEventEditor->setGeometry(x,y,w,h);
2053 2056
2054 } 2057 }
2055 list = config->readListEntry("EditTodoLayout"); 2058 list = config->readListEntry("EditTodoLayout");
2056 if ( ! list.isEmpty() ) { 2059 if ( ! list.isEmpty() ) {
2057 x = list[0].toInt(); 2060 x = list[0].toInt();
2058 y = list[1].toInt(); 2061 y = list[1].toInt();
2059 w = list[2].toInt(); 2062 w = list[2].toInt();
2060 h = list[3].toInt(); 2063 h = list[3].toInt();
2061 KApplication::testCoords( &x,&y,&w,&h ); 2064 KApplication::testCoords( &x,&y,&w,&h );
2062 mTodoEditor->setGeometry(x,y,w,h); 2065 mTodoEditor->setGeometry(x,y,w,h);
2063 2066
2064 } 2067 }
2065 list = config->readListEntry("ViewerLayout"); 2068 list = config->readListEntry("ViewerLayout");
2066 if ( ! list.isEmpty() ) { 2069 if ( ! list.isEmpty() ) {
2067 x = list[0].toInt(); 2070 x = list[0].toInt();
2068 y = list[1].toInt(); 2071 y = list[1].toInt();
2069 w = list[2].toInt(); 2072 w = list[2].toInt();
2070 h = list[3].toInt(); 2073 h = list[3].toInt();
2071 KApplication::testCoords( &x,&y,&w,&h ); 2074 KApplication::testCoords( &x,&y,&w,&h );
2072 getEventViewerDialog()->setGeometry(x,y,w,h); 2075 getEventViewerDialog()->setGeometry(x,y,w,h);
2073 } 2076 }
2074#endif 2077#endif
2075 config->setGroup( "Views" ); 2078 config->setGroup( "Views" );
2076 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2079 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2077 2080
2078 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2081 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2079 2082
2080 int resetval = 0; 2083 int resetval = 0;
2081 int maxVal = 0; 2084 int maxVal = 0;
2082 if (sizes.count() != 3) { 2085 if (sizes.count() != 3) {
2083 if ( KOPrefs::instance()->mVerticalScreen ) { 2086 if ( KOPrefs::instance()->mVerticalScreen ) {
2084 resetval = mDateNavigator->sizeHint().width()+2; 2087 resetval = mDateNavigator->sizeHint().width()+2;
2085 } else { 2088 } else {
2086 resetval = mDateNavigator->sizeHint().height()+2; 2089 resetval = mDateNavigator->sizeHint().height()+2;
2087 } 2090 }
2088 } 2091 }
2089 if ( resetval ) { 2092 if ( resetval ) {
2090 sizes.clear(); 2093 sizes.clear();
2091 if ( KOPrefs::instance()->mVerticalScreen ) { 2094 if ( KOPrefs::instance()->mVerticalScreen ) {
2092 maxVal = QApplication::desktop()->width() -10; 2095 maxVal = QApplication::desktop()->width() -10;
2093 } else { 2096 } else {
2094 maxVal = QApplication::desktop()->height()-10; 2097 maxVal = QApplication::desktop()->height()-10;
2095 } 2098 }
2096 sizes << resetval; 2099 sizes << resetval;
2097 if ( maxVal < resetval + resetval) 2100 if ( maxVal < resetval + resetval)
2098 resetval = maxVal - resetval; 2101 resetval = maxVal - resetval;
2099 sizes << resetval; 2102 sizes << resetval;
2100 sizes << 100; 2103 sizes << 100;
2101 } 2104 }
2102 mLeftFrame->setSizes(sizes); 2105 mLeftFrame->setSizes(sizes);
2103 sizes = config->readIntListEntry("Main Splitter Frame"); 2106 sizes = config->readIntListEntry("Main Splitter Frame");
2104 resetval = 0; 2107 resetval = 0;
2105 maxVal = 0; 2108 maxVal = 0;
2106 if (sizes.count() != 2) { 2109 if (sizes.count() != 2) {
2107 if ( !KOPrefs::instance()->mVerticalScreen ) { 2110 if ( !KOPrefs::instance()->mVerticalScreen ) {
2108 resetval = mDateNavigator->sizeHint().width()+2; 2111 resetval = mDateNavigator->sizeHint().width()+2;
2109 } else { 2112 } else {
2110 resetval = mDateNavigator->sizeHint().height()+2; 2113 resetval = mDateNavigator->sizeHint().height()+2;
2111 } 2114 }
2112 } 2115 }
2113 if ( resetval ) { 2116 if ( resetval ) {
2114 sizes.clear(); 2117 sizes.clear();
2115 if ( !KOPrefs::instance()->mVerticalScreen ) { 2118 if ( !KOPrefs::instance()->mVerticalScreen ) {
2116 maxVal = QApplication::desktop()->width() -10; 2119 maxVal = QApplication::desktop()->width() -10;
2117 } else { 2120 } else {
2118 maxVal = QApplication::desktop()->height()-10; 2121 maxVal = QApplication::desktop()->height()-10;
2119 } 2122 }
2120 sizes << resetval; 2123 sizes << resetval;
2121 if ( maxVal < resetval + resetval) 2124 if ( maxVal < resetval + resetval)
2122 resetval = maxVal - resetval; 2125 resetval = maxVal - resetval;
2123 sizes << resetval; 2126 sizes << resetval;
2124 } 2127 }
2125 mMainFrame->setSizes(sizes); 2128 mMainFrame->setSizes(sizes);
2126 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2129 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2127 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2130 else if ( dateCount == 7 ) mNavigator->selectWeek();
2128 else mNavigator->selectDates( dateCount ); 2131 else mNavigator->selectDates( dateCount );
2129 // mViewManager->readSettings( config ); 2132 // mViewManager->readSettings( config );
2130 updateConfig(); 2133 updateConfig();
2131 globalFlagBlockAgenda = 2; 2134 globalFlagBlockAgenda = 2;
2132 mViewManager->readSettings( config ); 2135 mViewManager->readSettings( config );
2133 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2136 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2134} 2137}
2135 2138
2136 2139
2137void CalendarView::writeSettings() 2140void CalendarView::writeSettings()
2138{ 2141{
2139 // kdDebug() << "CalendarView::writeSettings" << endl; 2142 // kdDebug() << "CalendarView::writeSettings" << endl;
2140 2143
2141 KConfig *config = KOGlobals::config(); 2144 KConfig *config = KOGlobals::config();
2142 2145
2143 mViewManager->writeSettings( config ); 2146 mViewManager->writeSettings( config );
2144 mTodoList->saveLayout(config,QString("Todo Layout")); 2147 mTodoList->saveLayout(config,QString("Todo Layout"));
2145 mDialogManager->writeSettings( config ); 2148 mDialogManager->writeSettings( config );
2146 //KOPrefs::instance()->usrWriteConfig(); 2149 //KOPrefs::instance()->usrWriteConfig();
2147 KOPrefs::instance()->writeConfig(); 2150 KOPrefs::instance()->writeConfig();
2148 2151
2149 writeFilterSettings(config); 2152 writeFilterSettings(config);
2150 config->setGroup( "AppRun" ); 2153 config->setGroup( "AppRun" );
2151 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2154 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2152 config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) ); 2155 config->writeEntry( "LatestProgramStop", dt.secsTo( QDateTime::currentDateTime() ) );
2153 config->setGroup( "Views" ); 2156 config->setGroup( "Views" );
2154 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2157 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2155 2158
2156 QValueList<int> listINT = mLeftFrame->sizes(); 2159 QValueList<int> listINT = mLeftFrame->sizes();
2157 config->writeEntry("Left Splitter Frame",listINT); 2160 config->writeEntry("Left Splitter Frame",listINT);
2158 QValueList<int> listINT2 = mMainFrame->sizes(); 2161 QValueList<int> listINT2 = mMainFrame->sizes();
2159 config->writeEntry("Main Splitter Frame",listINT2); 2162 config->writeEntry("Main Splitter Frame",listINT2);
2160#ifdef DESKTOP_VERSION 2163#ifdef DESKTOP_VERSION
2161 config->setGroup("WidgetLayout"); 2164 config->setGroup("WidgetLayout");
2162 QStringList list ;//= config->readListEntry("MainLayout"); 2165 QStringList list ;//= config->readListEntry("MainLayout");
2163 int x,y,w,h; 2166 int x,y,w,h;
2164 QWidget* wid; 2167 QWidget* wid;
2165 wid = topLevelWidget(); 2168 wid = topLevelWidget();
2166 x = wid->geometry().x(); 2169 x = wid->geometry().x();
2167 y = wid->geometry().y(); 2170 y = wid->geometry().y();
2168 w = wid->width(); 2171 w = wid->width();
2169 h = wid->height(); 2172 h = wid->height();
2170 list.clear(); 2173 list.clear();
2171 list << QString::number( x ); 2174 list << QString::number( x );
2172 list << QString::number( y ); 2175 list << QString::number( y );
2173 list << QString::number( w ); 2176 list << QString::number( w );
2174 list << QString::number( h ); 2177 list << QString::number( h );
2175 config->writeEntry("MainLayout",list ); 2178 config->writeEntry("MainLayout",list );
2176 2179
2177 wid = mEventEditor; 2180 wid = mEventEditor;
2178 x = wid->geometry().x(); 2181 x = wid->geometry().x();
2179 y = wid->geometry().y(); 2182 y = wid->geometry().y();
2180 w = wid->width(); 2183 w = wid->width();
2181 h = wid->height(); 2184 h = wid->height();
2182 list.clear(); 2185 list.clear();
2183 list << QString::number( x ); 2186 list << QString::number( x );
2184 list << QString::number( y ); 2187 list << QString::number( y );
2185 list << QString::number( w ); 2188 list << QString::number( w );
2186 list << QString::number( h ); 2189 list << QString::number( h );
2187 config->writeEntry("EditEventLayout",list ); 2190 config->writeEntry("EditEventLayout",list );
2188 2191
2189 wid = mTodoEditor; 2192 wid = mTodoEditor;
2190 x = wid->geometry().x(); 2193 x = wid->geometry().x();
2191 y = wid->geometry().y(); 2194 y = wid->geometry().y();
2192 w = wid->width(); 2195 w = wid->width();
2193 h = wid->height(); 2196 h = wid->height();
2194 list.clear(); 2197 list.clear();
2195 list << QString::number( x ); 2198 list << QString::number( x );
2196 list << QString::number( y ); 2199 list << QString::number( y );
2197 list << QString::number( w ); 2200 list << QString::number( w );
2198 list << QString::number( h ); 2201 list << QString::number( h );
2199 config->writeEntry("EditTodoLayout",list ); 2202 config->writeEntry("EditTodoLayout",list );
2200 wid = getEventViewerDialog(); 2203 wid = getEventViewerDialog();
2201 x = wid->geometry().x(); 2204 x = wid->geometry().x();
2202 y = wid->geometry().y(); 2205 y = wid->geometry().y();
2203 w = wid->width(); 2206 w = wid->width();
2204 h = wid->height(); 2207 h = wid->height();
2205 list.clear(); 2208 list.clear();
2206 list << QString::number( x ); 2209 list << QString::number( x );
2207 list << QString::number( y ); 2210 list << QString::number( y );
2208 list << QString::number( w ); 2211 list << QString::number( w );
2209 list << QString::number( h ); 2212 list << QString::number( h );
2210 config->writeEntry("ViewerLayout",list ); 2213 config->writeEntry("ViewerLayout",list );
2211 wid = mDialogManager->getSearchDialog(); 2214 wid = mDialogManager->getSearchDialog();
2212 if ( wid ) { 2215 if ( wid ) {
2213 x = wid->geometry().x(); 2216 x = wid->geometry().x();
2214 y = wid->geometry().y(); 2217 y = wid->geometry().y();
2215 w = wid->width(); 2218 w = wid->width();
2216 h = wid->height(); 2219 h = wid->height();
2217 list.clear(); 2220 list.clear();
2218 list << QString::number( x ); 2221 list << QString::number( x );
2219 list << QString::number( y ); 2222 list << QString::number( y );
2220 list << QString::number( w ); 2223 list << QString::number( w );
2221 list << QString::number( h ); 2224 list << QString::number( h );
2222 config->writeEntry("SearchLayout",list ); 2225 config->writeEntry("SearchLayout",list );
2223 } 2226 }
2224#endif 2227#endif
2225 2228
2226 2229
2227 config->sync(); 2230 config->sync();
2228} 2231}
2229 2232
2230void CalendarView::readFilterSettings(KConfig *config) 2233void CalendarView::readFilterSettings(KConfig *config)
2231{ 2234{
2232 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2235 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2233 2236
2234 mFilters.clear(); 2237 mFilters.clear();
2235 2238
2236 config->setGroup("General"); 2239 config->setGroup("General");
2237 QStringList filterList = config->readListEntry("CalendarFilters"); 2240 QStringList filterList = config->readListEntry("CalendarFilters");
2238 2241
2239 QStringList::ConstIterator it = filterList.begin(); 2242 QStringList::ConstIterator it = filterList.begin();
2240 QStringList::ConstIterator end = filterList.end(); 2243 QStringList::ConstIterator end = filterList.end();
2241 while(it != end) { 2244 while(it != end) {
2242 // kdDebug() << " filter: " << (*it) << endl; 2245 // kdDebug() << " filter: " << (*it) << endl;
2243 2246
2244 CalFilter *filter; 2247 CalFilter *filter;
2245 filter = new CalFilter(*it); 2248 filter = new CalFilter(*it);
2246 config->setGroup("Filter_" + (*it).utf8()); 2249 config->setGroup("Filter_" + (*it).utf8());
2247 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2250 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2248 filter->setCriteria(config->readNumEntry("Criteria",0)); 2251 filter->setCriteria(config->readNumEntry("Criteria",0));
2249 filter->setCategoryList(config->readListEntry("CategoryList")); 2252 filter->setCategoryList(config->readListEntry("CategoryList"));
2250 mFilters.append(filter); 2253 mFilters.append(filter);
2251 2254
2252 ++it; 2255 ++it;
2253 } 2256 }
2254 2257
2255 if (mFilters.count() == 0) { 2258 if (mFilters.count() == 0) {
2256 CalFilter *filter = new CalFilter(i18n("Default")); 2259 CalFilter *filter = new CalFilter(i18n("Default"));
2257 mFilters.append(filter); 2260 mFilters.append(filter);
2258 } 2261 }
2259 mFilterView->updateFilters(); 2262 mFilterView->updateFilters();
2260 config->setGroup("FilterView"); 2263 config->setGroup("FilterView");
2261 2264
2262 mFilterView->blockSignals(true); 2265 mFilterView->blockSignals(true);
2263 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2266 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2264 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2267 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2265 mFilterView->blockSignals(false); 2268 mFilterView->blockSignals(false);
2266 // We do it manually to avoid it being done twice by the above calls 2269 // We do it manually to avoid it being done twice by the above calls
2267 updateFilter(); 2270 updateFilter();
2268} 2271}
2269 2272
2270void CalendarView::writeFilterSettings(KConfig *config) 2273void CalendarView::writeFilterSettings(KConfig *config)
2271{ 2274{
2272 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2275 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2273 2276
2274 QStringList filterList; 2277 QStringList filterList;
2275 2278
2276 CalFilter *filter = mFilters.first(); 2279 CalFilter *filter = mFilters.first();
2277 while(filter) { 2280 while(filter) {
2278 // kdDebug() << " fn: " << filter->name() << endl; 2281 // kdDebug() << " fn: " << filter->name() << endl;
2279 filterList << filter->name(); 2282 filterList << filter->name();
2280 config->setGroup("Filter_" + filter->name().utf8()); 2283 config->setGroup("Filter_" + filter->name().utf8());
2281 config->writeEntry("Criteria",filter->criteria()); 2284 config->writeEntry("Criteria",filter->criteria());
2282 config->writeEntry("CategoryList",filter->categoryList()); 2285 config->writeEntry("CategoryList",filter->categoryList());
2283 filter = mFilters.next(); 2286 filter = mFilters.next();
2284 } 2287 }
2285 config->setGroup("General"); 2288 config->setGroup("General");
2286 config->writeEntry("CalendarFilters",filterList); 2289 config->writeEntry("CalendarFilters",filterList);
2287 2290
2288 config->setGroup("FilterView"); 2291 config->setGroup("FilterView");
2289 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2292 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2290 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2293 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2291} 2294}
2292 2295
2293 2296
2294void CalendarView::goToday() 2297void CalendarView::goToday()
2295{ 2298{
2296 if ( mViewManager->currentView()->isMonthView() ) 2299 if ( mViewManager->currentView()->isMonthView() )
2297 mNavigator->selectTodayMonth(); 2300 mNavigator->selectTodayMonth();
2298 else 2301 else
2299 mNavigator->selectToday(); 2302 mNavigator->selectToday();
2300} 2303}
2301 2304
2302void CalendarView::goNext() 2305void CalendarView::goNext()
2303{ 2306{
2304 mNavigator->selectNext(); 2307 mNavigator->selectNext();
2305} 2308}
2306 2309
2307void CalendarView::goPrevious() 2310void CalendarView::goPrevious()
2308{ 2311{
2309 mNavigator->selectPrevious(); 2312 mNavigator->selectPrevious();
2310} 2313}
2311void CalendarView::goNextMonth() 2314void CalendarView::goNextMonth()
2312{ 2315{
2313 mNavigator->selectNextMonth(); 2316 mNavigator->selectNextMonth();
2314} 2317}
2315 2318
2316void CalendarView::goPreviousMonth() 2319void CalendarView::goPreviousMonth()
2317{ 2320{
2318 mNavigator->selectPreviousMonth(); 2321 mNavigator->selectPreviousMonth();
2319} 2322}
2320void CalendarView::writeLocale() 2323void CalendarView::writeLocale()
2321{ 2324{
2322 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2325 //KPimGlobalPrefs::instance()->setGlobalConfig();
2323#if 0 2326#if 0
2324 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2327 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2325 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2328 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2326 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2329 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2327 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2330 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2328 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2331 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2329 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2332 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2330 dummy = KOPrefs::instance()->mUserDateFormatShort; 2333 dummy = KOPrefs::instance()->mUserDateFormatShort;
2331 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2334 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2332 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2335 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2333 KOPrefs::instance()->mDaylightsavingStart, 2336 KOPrefs::instance()->mDaylightsavingStart,
2334 KOPrefs::instance()->mDaylightsavingEnd ); 2337 KOPrefs::instance()->mDaylightsavingEnd );
2335 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2338 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2336#endif 2339#endif
2337} 2340}
2338void CalendarView::updateConfig() 2341void CalendarView::updateConfig()
2339{ 2342{
2340 writeLocale(); 2343 writeLocale();
2341 if ( KOPrefs::instance()->mUseAppColors ) 2344 if ( KOPrefs::instance()->mUseAppColors )
2342 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2345 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2343 emit configChanged(); 2346 emit configChanged();
2344 mTodoList->updateConfig(); 2347 mTodoList->updateConfig();
2345 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2348 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2346 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2349 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2347 // To make the "fill window" configurations work 2350 // To make the "fill window" configurations work
2348 //mViewManager->raiseCurrentView(); 2351 //mViewManager->raiseCurrentView();
2349} 2352}
2350 2353
2351 2354
2352void CalendarView::eventChanged(Event *event) 2355void CalendarView::eventChanged(Event *event)
2353{ 2356{
2354 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2357 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2355 //updateUnmanagedViews(); 2358 //updateUnmanagedViews();
2356} 2359}
2357 2360
2358void CalendarView::eventAdded(Event *event) 2361void CalendarView::eventAdded(Event *event)
2359{ 2362{
2360 changeEventDisplay(event,KOGlobals::EVENTADDED); 2363 changeEventDisplay(event,KOGlobals::EVENTADDED);
2361} 2364}
2362 2365
2363void CalendarView::eventToBeDeleted(Event *) 2366void CalendarView::eventToBeDeleted(Event *)
2364{ 2367{
2365 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2368 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2366} 2369}
2367 2370
2368void CalendarView::eventDeleted() 2371void CalendarView::eventDeleted()
2369{ 2372{
2370 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2373 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2371} 2374}
2372void CalendarView::changeTodoDisplay(Todo *which, int action) 2375void CalendarView::changeTodoDisplay(Todo *which, int action)
2373{ 2376{
2374 changeIncidenceDisplay((Incidence *)which, action); 2377 changeIncidenceDisplay((Incidence *)which, action);
2375 mDateNavigator->updateView(); //LR 2378 mDateNavigator->updateView(); //LR
2376 //mDialogManager->updateSearchDialog(); 2379 //mDialogManager->updateSearchDialog();
2377 2380
2378 if (which) { 2381 if (which) {
2379 mViewManager->updateWNview(); 2382 mViewManager->updateWNview();
2380 //mTodoList->updateView(); 2383 //mTodoList->updateView();
2381 } 2384 }
2382 2385
2383} 2386}
2384 2387
2385void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2388void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2386{ 2389{
2387 updateUnmanagedViews(); 2390 updateUnmanagedViews();
2388 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2391 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2389 if ( action == KOGlobals::EVENTDELETED ) { //delete 2392 if ( action == KOGlobals::EVENTDELETED ) { //delete
2390 mCalendar->checkAlarmForIncidence( 0, true ); 2393 mCalendar->checkAlarmForIncidence( 0, true );
2391 if ( mEventViewerDialog ) 2394 if ( mEventViewerDialog )
2392 mEventViewerDialog->hide(); 2395 mEventViewerDialog->hide();
2393 } 2396 }
2394 else 2397 else
2395 mCalendar->checkAlarmForIncidence( which , false ); 2398 mCalendar->checkAlarmForIncidence( which , false );
2396} 2399}
2397 2400
2398// most of the changeEventDisplays() right now just call the view's 2401// most of the changeEventDisplays() right now just call the view's
2399// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2402// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2400void CalendarView::changeEventDisplay(Event *which, int action) 2403void CalendarView::changeEventDisplay(Event *which, int action)
2401{ 2404{
2402 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2405 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2403 changeIncidenceDisplay((Incidence *)which, action); 2406 changeIncidenceDisplay((Incidence *)which, action);
2404 mDateNavigator->updateView(); 2407 mDateNavigator->updateView();
2405 //mDialogManager->updateSearchDialog(); 2408 //mDialogManager->updateSearchDialog();
2406 2409
2407 if (which) { 2410 if (which) {
2408 // If there is an event view visible update the display 2411 // If there is an event view visible update the display
2409 mViewManager->currentView()->changeEventDisplay(which,action); 2412 mViewManager->currentView()->changeEventDisplay(which,action);
2410 // TODO: check, if update needed 2413 // TODO: check, if update needed
2411 // if (which->getTodoStatus()) { 2414 // if (which->getTodoStatus()) {
2412 mTodoList->updateView(); 2415 mTodoList->updateView();
2413 // } 2416 // }
2414 } else { 2417 } else {
2415 mViewManager->currentView()->updateView(); 2418 mViewManager->currentView()->updateView();
2416 } 2419 }
2417} 2420}
2418 2421
2419 2422
2420void CalendarView::updateTodoViews() 2423void CalendarView::updateTodoViews()
2421{ 2424{
2422 mTodoList->updateView(); 2425 mTodoList->updateView();
2423 mViewManager->currentView()->updateView(); 2426 mViewManager->currentView()->updateView();
2424 2427
2425} 2428}
2426 2429
2427 2430
2428void CalendarView::updateView(const QDate &start, const QDate &end) 2431void CalendarView::updateView(const QDate &start, const QDate &end)
2429{ 2432{
2430 mTodoList->updateView(); 2433 mTodoList->updateView();
2431 mViewManager->updateView(start, end); 2434 mViewManager->updateView(start, end);
2432 //mDateNavigator->updateView(); 2435 //mDateNavigator->updateView();
2433} 2436}
2434 2437
2438void CalendarView::clearAllViews()
2439{
2440 mTodoList->clearList();
2441 mViewManager->clearAllViews();
2442 SearchDialog * sd = mDialogManager->getSearchDialog();
2443 if ( sd ) {
2444 KOListView* kol = sd->listview();
2445 if ( kol )
2446 kol->clearList();
2447 }
2448}
2435void CalendarView::updateView() 2449void CalendarView::updateView()
2436{ 2450{
2437 DateList tmpList = mNavigator->selectedDates(); 2451 DateList tmpList = mNavigator->selectedDates();
2438 2452
2439 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2453 if ( KOPrefs::instance()->mHideNonStartedTodos )
2440 mTodoList->updateView(); 2454 mTodoList->updateView();
2441 // We assume that the navigator only selects consecutive days. 2455 // We assume that the navigator only selects consecutive days.
2442 updateView( tmpList.first(), tmpList.last() ); 2456 updateView( tmpList.first(), tmpList.last() );
2443} 2457}
2444 2458
2445void CalendarView::updateUnmanagedViews() 2459void CalendarView::updateUnmanagedViews()
2446{ 2460{
2447 mDateNavigator->updateDayMatrix(); 2461 mDateNavigator->updateDayMatrix();
2448} 2462}
2449 2463
2450int CalendarView::msgItemDelete(const QString name) 2464int CalendarView::msgItemDelete(const QString name)
2451{ 2465{
2452 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2466 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2453 i18n("This item will be\npermanently deleted."), 2467 i18n("This item will be\npermanently deleted."),
2454 i18n("KO/Pi Confirmation"),i18n("Delete")); 2468 i18n("KO/Pi Confirmation"),i18n("Delete"));
2455} 2469}
2456 2470
2457 2471
2458void CalendarView::edit_cut() 2472void CalendarView::edit_cut()
2459{ 2473{
2460 Event *anEvent=0; 2474 Event *anEvent=0;
2461 2475
2462 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2476 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2463 2477
2464 if (mViewManager->currentView()->isEventView()) { 2478 if (mViewManager->currentView()->isEventView()) {
2465 if ( incidence && incidence->type() == "Event" ) { 2479 if ( incidence && incidence->type() == "Event" ) {
2466 anEvent = static_cast<Event *>(incidence); 2480 anEvent = static_cast<Event *>(incidence);
2467 } 2481 }
2468 } 2482 }
2469 2483
2470 if (!anEvent) { 2484 if (!anEvent) {
2471 KNotifyClient::beep(); 2485 KNotifyClient::beep();
2472 return; 2486 return;
2473 } 2487 }
2474 DndFactory factory( mCalendar ); 2488 DndFactory factory( mCalendar );
2475 factory.cutIncidence(anEvent); 2489 factory.cutIncidence(anEvent);
2476 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2490 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2477} 2491}
2478 2492
2479void CalendarView::edit_copy() 2493void CalendarView::edit_copy()
2480{ 2494{
2481 Event *anEvent=0; 2495 Event *anEvent=0;
2482 2496
2483 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2497 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2484 2498
2485 if (mViewManager->currentView()->isEventView()) { 2499 if (mViewManager->currentView()->isEventView()) {
2486 if ( incidence && incidence->type() == "Event" ) { 2500 if ( incidence && incidence->type() == "Event" ) {
2487 anEvent = static_cast<Event *>(incidence); 2501 anEvent = static_cast<Event *>(incidence);
2488 } 2502 }
2489 } 2503 }
2490 2504
2491 if (!anEvent) { 2505 if (!anEvent) {
2492 KNotifyClient::beep(); 2506 KNotifyClient::beep();
2493 return; 2507 return;
2494 } 2508 }
2495 DndFactory factory( mCalendar ); 2509 DndFactory factory( mCalendar );
2496 factory.copyIncidence(anEvent); 2510 factory.copyIncidence(anEvent);
2497} 2511}
2498 2512
2499void CalendarView::edit_paste() 2513void CalendarView::edit_paste()
2500{ 2514{
2501 QDate date = mNavigator->selectedDates().first(); 2515 QDate date = mNavigator->selectedDates().first();
2502 2516
2503 DndFactory factory( mCalendar ); 2517 DndFactory factory( mCalendar );
2504 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2518 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2505 2519
2506 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2520 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2507} 2521}
2508 2522
2509void CalendarView::edit_options() 2523void CalendarView::edit_options()
2510{ 2524{
2511 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2525 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2512 emit save(); 2526 emit save();
2513 emit saveStopTimer(); 2527 emit saveStopTimer();
2514 mDialogManager->showOptionsDialog(); 2528 mDialogManager->showOptionsDialog();
2515 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2529 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2516 emit saveStopTimer(); 2530 emit saveStopTimer();
2517 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!"), 2531 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2518 i18n("Timezone settings"),i18n("Reload"))) { 2532 i18n("Timezone settings"),i18n("Reload"))) {
2519 qDebug("KO: TZ reload cancelled "); 2533 qDebug("KO: TZ reload cancelled ");
2520 return; 2534 return;
2521 } 2535 }
2522 qDebug("KO: Timezone change "); 2536 qDebug("KO: Timezone change ");
2523 openCalendar( MainWindow::defaultFileName() ); 2537 openCalendar( MainWindow::defaultFileName() );
2524 setModified(true); 2538 setModified(true);
2525 } 2539 }
2526 else 2540 else
2527 qDebug("KO: No tz change "); 2541 qDebug("KO: No tz change ");
2528 2542
2529} 2543}
2530 2544
2531 2545
2532void CalendarView::slotSelectPickerDate( QDate d) 2546void CalendarView::slotSelectPickerDate( QDate d)
2533{ 2547{
2534 mDateFrame->hide(); 2548 mDateFrame->hide();
2535 if ( mDatePickerMode == 1 ) { 2549 if ( mDatePickerMode == 1 ) {
2536 mNavigator->slotDaySelect( d ); 2550 mNavigator->slotDaySelect( d );
2537 } else if ( mDatePickerMode == 2 ) { 2551 } else if ( mDatePickerMode == 2 ) {
2538 if ( mMoveIncidence->type() == "Todo" ) { 2552 if ( mMoveIncidence->type() == "Todo" ) {
2539 Todo * to = (Todo *) mMoveIncidence; 2553 Todo * to = (Todo *) mMoveIncidence;
2540 QTime tim; 2554 QTime tim;
2541 int len = 0; 2555 int len = 0;
2542 if ( to->hasStartDate() && to->hasDueDate() ) 2556 if ( to->hasStartDate() && to->hasDueDate() )
2543 len = to->dtStart().secsTo( to->dtDue()); 2557 len = to->dtStart().secsTo( to->dtDue());
2544 if ( to->hasDueDate() ) 2558 if ( to->hasDueDate() )
2545 tim = to->dtDue().time(); 2559 tim = to->dtDue().time();
2546 else { 2560 else {
2547 tim = QTime ( 0,0,0 ); 2561 tim = QTime ( 0,0,0 );
2548 to->setFloats( true ); 2562 to->setFloats( true );
2549 to->setHasDueDate( true ); 2563 to->setHasDueDate( true );
2550 } 2564 }
2551 QDateTime dt ( d,tim ); 2565 QDateTime dt ( d,tim );
2552 to->setDtDue( dt ); 2566 to->setDtDue( dt );
2553 2567
2554 if ( to->hasStartDate() ) { 2568 if ( to->hasStartDate() ) {
2555 if ( len>0 ) 2569 if ( len>0 )
2556 to->setDtStart(to->dtDue().addSecs( -len )); 2570 to->setDtStart(to->dtDue().addSecs( -len ));
2557 else 2571 else
2558 if (to->dtStart() > to->dtDue() ) 2572 if (to->dtStart() > to->dtDue() )
2559 to->setDtStart(to->dtDue().addDays( -3 )); 2573 to->setDtStart(to->dtDue().addDays( -3 ));
2560 } 2574 }
2561 2575
2562 todoChanged( to ); 2576 todoChanged( to );
2563 } else { 2577 } else {
2564 if ( mMoveIncidence->doesRecur() ) { 2578 if ( mMoveIncidence->doesRecur() ) {
2565#if 0 2579#if 0
2566 // PENDING implement this 2580 // PENDING implement this
2567 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2581 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2568 mCalendar()->addIncidence( newInc ); 2582 mCalendar()->addIncidence( newInc );
2569 if ( mMoveIncidence->type() == "Todo" ) 2583 if ( mMoveIncidence->type() == "Todo" )
2570 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2584 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2571 else 2585 else
2572 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2586 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2573 mMoveIncidence = newInc; 2587 mMoveIncidence = newInc;
2574 2588
2575#endif 2589#endif
2576 } 2590 }
2577 QTime tim = mMoveIncidence->dtStart().time(); 2591 QTime tim = mMoveIncidence->dtStart().time();
2578 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2592 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2579 QDateTime dt ( d,tim ); 2593 QDateTime dt ( d,tim );
2580 mMoveIncidence->setDtStart( dt ); 2594 mMoveIncidence->setDtStart( dt );
2581 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2595 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2582 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2596 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2583 } 2597 }
2584 2598
2585 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2599 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2586 } 2600 }
2587} 2601}
2588 2602
2589void CalendarView::removeCategories() 2603void CalendarView::removeCategories()
2590{ 2604{
2591 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2605 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2592 QStringList catList = KOPrefs::instance()->mCustomCategories; 2606 QStringList catList = KOPrefs::instance()->mCustomCategories;
2593 QStringList catIncList; 2607 QStringList catIncList;
2594 QStringList newCatList; 2608 QStringList newCatList;
2595 Incidence* inc = incList.first(); 2609 Incidence* inc = incList.first();
2596 int i; 2610 int i;
2597 int count = 0; 2611 int count = 0;
2598 while ( inc ) { 2612 while ( inc ) {
2599 newCatList.clear(); 2613 newCatList.clear();
2600 catIncList = inc->categories() ; 2614 catIncList = inc->categories() ;
2601 for( i = 0; i< catIncList.count(); ++i ) { 2615 for( i = 0; i< catIncList.count(); ++i ) {
2602 if ( catList.contains (catIncList[i])) 2616 if ( catList.contains (catIncList[i]))
2603 newCatList.append( catIncList[i] ); 2617 newCatList.append( catIncList[i] );
2604 } 2618 }
2605 newCatList.sort(); 2619 newCatList.sort();
2606 inc->setCategories( newCatList.join(",") ); 2620 inc->setCategories( newCatList.join(",") );
2607 inc = incList.next(); 2621 inc = incList.next();
2608 } 2622 }
2609} 2623}
2610 2624
2611int CalendarView::addCategories() 2625int CalendarView::addCategories()
2612{ 2626{
2613 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2627 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2614 QStringList catList = KOPrefs::instance()->mCustomCategories; 2628 QStringList catList = KOPrefs::instance()->mCustomCategories;
2615 QStringList catIncList; 2629 QStringList catIncList;
2616 Incidence* inc = incList.first(); 2630 Incidence* inc = incList.first();
2617 int i; 2631 int i;
2618 int count = 0; 2632 int count = 0;
2619 while ( inc ) { 2633 while ( inc ) {
2620 catIncList = inc->categories() ; 2634 catIncList = inc->categories() ;
2621 for( i = 0; i< catIncList.count(); ++i ) { 2635 for( i = 0; i< catIncList.count(); ++i ) {
2622 if ( !catList.contains (catIncList[i])) { 2636 if ( !catList.contains (catIncList[i])) {
2623 catList.append( catIncList[i] ); 2637 catList.append( catIncList[i] );
2624 //qDebug("add cat %s ", catIncList[i].latin1()); 2638 //qDebug("add cat %s ", catIncList[i].latin1());
2625 ++count; 2639 ++count;
2626 } 2640 }
2627 } 2641 }
2628 inc = incList.next(); 2642 inc = incList.next();
2629 } 2643 }
2630 catList.sort(); 2644 catList.sort();
2631 KOPrefs::instance()->mCustomCategories = catList; 2645 KOPrefs::instance()->mCustomCategories = catList;
2632 return count; 2646 return count;
2633} 2647}
2634 2648
2635void CalendarView::manageCategories() 2649void CalendarView::manageCategories()
2636{ 2650{
2637 KOCatPrefs* cp = new KOCatPrefs(); 2651 KOCatPrefs* cp = new KOCatPrefs();
2638 cp->show(); 2652 cp->show();
2639 int w =cp->sizeHint().width() ; 2653 int w =cp->sizeHint().width() ;
2640 int h = cp->sizeHint().height() ; 2654 int h = cp->sizeHint().height() ;
2641 int dw = QApplication::desktop()->width(); 2655 int dw = QApplication::desktop()->width();
2642 int dh = QApplication::desktop()->height(); 2656 int dh = QApplication::desktop()->height();
2643 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2657 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2644 if ( !cp->exec() ) { 2658 if ( !cp->exec() ) {
2645 delete cp; 2659 delete cp;
2646 return; 2660 return;
2647 } 2661 }
2648 int count = 0; 2662 int count = 0;
2649 if ( cp->addCat() ) { 2663 if ( cp->addCat() ) {
2650 count = addCategories(); 2664 count = addCategories();
2651 if ( count ) { 2665 if ( count ) {
2652 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2666 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2653 writeSettings(); 2667 writeSettings();
2654 } else 2668 } else
2655 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2669 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2656 } else { 2670 } else {
2657 removeCategories(); 2671 removeCategories();
2658 updateView(); 2672 updateView();
2659 } 2673 }
2660 delete cp; 2674 delete cp;
2661} 2675}
2662 2676
2663void CalendarView::beamIncidence(Incidence * Inc) 2677void CalendarView::beamIncidence(Incidence * Inc)
2664{ 2678{
2665 QPtrList<Incidence> delSel ; 2679 QPtrList<Incidence> delSel ;
2666 delSel.append(Inc); 2680 delSel.append(Inc);
2667 beamIncidenceList( delSel ); 2681 beamIncidenceList( delSel );
2668} 2682}
2669void CalendarView::beamCalendar() 2683void CalendarView::beamCalendar()
2670{ 2684{
2671 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2685 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2672 //qDebug("beamCalendar() "); 2686 //qDebug("beamCalendar() ");
2673 beamIncidenceList( delSel ); 2687 beamIncidenceList( delSel );
2674} 2688}
2675void CalendarView::beamFilteredCalendar() 2689void CalendarView::beamFilteredCalendar()
2676{ 2690{
2677 QPtrList<Incidence> delSel = mCalendar->incidences(); 2691 QPtrList<Incidence> delSel = mCalendar->incidences();
2678 //qDebug("beamFilteredCalendar() "); 2692 //qDebug("beamFilteredCalendar() ");
2679 beamIncidenceList( delSel ); 2693 beamIncidenceList( delSel );
2680} 2694}
2681void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2695void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2682{ 2696{
2683 if ( beamDialog->exec () == QDialog::Rejected ) 2697 if ( beamDialog->exec () == QDialog::Rejected )
2684 return; 2698 return;
2685#ifdef DESKTOP_VERSION 2699#ifdef DESKTOP_VERSION
2686 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2700 QString fn = locateLocal( "tmp", "kopibeamfile" );
2687#else 2701#else
2688 QString fn = "/tmp/kopibeamfile"; 2702 QString fn = "/tmp/kopibeamfile";
2689#endif 2703#endif
2690 QString mes; 2704 QString mes;
2691 bool createbup = true; 2705 bool createbup = true;
2692 if ( createbup ) { 2706 if ( createbup ) {
2693 QString description = "\n"; 2707 QString description = "\n";
2694 CalendarLocal* cal = new CalendarLocal(); 2708 CalendarLocal* cal = new CalendarLocal();
2695 if ( beamDialog->beamLocal() ) 2709 if ( beamDialog->beamLocal() )
2696 cal->setLocalTime(); 2710 cal->setLocalTime();
2697 else 2711 else
2698 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2712 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2699 Incidence *incidence = delSel.first(); 2713 Incidence *incidence = delSel.first();
2700 bool addText = false; 2714 bool addText = false;
2701 if ( delSel.count() < 10 ) 2715 if ( delSel.count() < 10 )
2702 addText = true; 2716 addText = true;
2703 else { 2717 else {
2704 description.sprintf(i18n(" %d items?"),delSel.count() ); 2718 description.sprintf(i18n(" %d items?"),delSel.count() );
2705 } 2719 }
2706 while ( incidence ) { 2720 while ( incidence ) {
2707 Incidence *in = incidence->clone(); 2721 Incidence *in = incidence->clone();
2708 if ( ! in->summary().isEmpty() ) { 2722 if ( ! in->summary().isEmpty() ) {
2709 in->setDescription(""); 2723 in->setDescription("");
2710 } else { 2724 } else {
2711 in->setSummary( in->description().left(20)); 2725 in->setSummary( in->description().left(20));
2712 in->setDescription(""); 2726 in->setDescription("");
2713 } 2727 }
2714 if ( addText ) 2728 if ( addText )
2715 description += in->summary() + "\n"; 2729 description += in->summary() + "\n";
2716 cal->addIncidence( in ); 2730 cal->addIncidence( in );
2717 incidence = delSel.next(); 2731 incidence = delSel.next();
2718 } 2732 }
2719 if ( beamDialog->beamVcal() ) { 2733 if ( beamDialog->beamVcal() ) {
2720 fn += ".vcs"; 2734 fn += ".vcs";
2721 FileStorage storage( cal, fn, new VCalFormat ); 2735 FileStorage storage( cal, fn, new VCalFormat );
2722 storage.save(); 2736 storage.save();
2723 } else { 2737 } else {
2724 fn += ".ics"; 2738 fn += ".ics";
2725 FileStorage storage( cal, fn, new ICalFormat( ) ); 2739 FileStorage storage( cal, fn, new ICalFormat( ) );
2726 storage.save(); 2740 storage.save();
2727 } 2741 }
2728 delete cal; 2742 delete cal;
2729 mes = i18n("KO/Pi: Ready for beaming"); 2743 mes = i18n("KO/Pi: Ready for beaming");
2730 topLevelWidget()->setCaption(mes); 2744 topLevelWidget()->setCaption(mes);
2731 KApplication::convert2latin1( fn ); 2745 KApplication::convert2latin1( fn );
2732#ifndef DESKTOP_VERSION 2746#ifndef DESKTOP_VERSION
2733 Ir *ir = new Ir( this ); 2747 Ir *ir = new Ir( this );
2734 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2748 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2735 ir->send( fn, description, "text/x-vCalendar" ); 2749 ir->send( fn, description, "text/x-vCalendar" );
2736#endif 2750#endif
2737 } 2751 }
2738} 2752}
2739void CalendarView::beamDone( Ir *ir ) 2753void CalendarView::beamDone( Ir *ir )
2740{ 2754{
2741#ifndef DESKTOP_VERSION 2755#ifndef DESKTOP_VERSION
2742 delete ir; 2756 delete ir;
2743#endif 2757#endif
2744 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2758 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2745 topLevelWidget()->raise(); 2759 topLevelWidget()->raise();
2746} 2760}
2747 2761
2748void CalendarView::moveIncidence(Incidence * inc ) 2762void CalendarView::moveIncidence(Incidence * inc )
2749{ 2763{
2750 if ( !inc ) return; 2764 if ( !inc ) return;
2751 showDatePickerPopup(); 2765 showDatePickerPopup();
2752 mDatePickerMode = 2; 2766 mDatePickerMode = 2;
2753 mMoveIncidence = inc ; 2767 mMoveIncidence = inc ;
2754 QDate da; 2768 QDate da;
2755 if ( mMoveIncidence->type() == "Todo" ) { 2769 if ( mMoveIncidence->type() == "Todo" ) {
2756 Todo * to = (Todo *) mMoveIncidence; 2770 Todo * to = (Todo *) mMoveIncidence;
2757 if ( to->hasDueDate() ) 2771 if ( to->hasDueDate() )
2758 da = to->dtDue().date(); 2772 da = to->dtDue().date();
2759 else 2773 else
2760 da = QDate::currentDate(); 2774 da = QDate::currentDate();
2761 } else { 2775 } else {
2762 da = mMoveIncidence->dtStart().date(); 2776 da = mMoveIncidence->dtStart().date();
2763 } 2777 }
2764 //PENDING set date for recurring incidence to date of recurrence 2778 //PENDING set date for recurring incidence to date of recurrence
2765 //mMoveIncidenceOldDate; 2779 //mMoveIncidenceOldDate;
2766 mDatePicker->setDate( da ); 2780 mDatePicker->setDate( da );
2767} 2781}
2768void CalendarView::showDatePickerPopup() 2782void CalendarView::showDatePickerPopup()
2769{ 2783{
2770 if ( mDateFrame->isVisible() ) 2784 if ( mDateFrame->isVisible() )
2771 mDateFrame->hide(); 2785 mDateFrame->hide();
2772 else { 2786 else {
2773 int offX = 0, offY = 0; 2787 int offX = 0, offY = 0;
2774#ifdef DESKTOP_VERSION 2788#ifdef DESKTOP_VERSION
2775 int w =mDatePicker->sizeHint().width() ; 2789 int w =mDatePicker->sizeHint().width() ;
2776 int h = mDatePicker->sizeHint().height() ; 2790 int h = mDatePicker->sizeHint().height() ;
2777 int dw = topLevelWidget()->width(); 2791 int dw = topLevelWidget()->width();
2778 int dh = topLevelWidget()->height(); 2792 int dh = topLevelWidget()->height();
2779 offX = topLevelWidget()->x(); 2793 offX = topLevelWidget()->x();
2780 offY = topLevelWidget()->y(); 2794 offY = topLevelWidget()->y();
2781#else 2795#else
2782 int w =mDatePicker->sizeHint().width() ; 2796 int w =mDatePicker->sizeHint().width() ;
2783 int h = mDatePicker->sizeHint().height() ; 2797 int h = mDatePicker->sizeHint().height() ;
2784 int dw = QApplication::desktop()->width(); 2798 int dw = QApplication::desktop()->width();
2785 int dh = QApplication::desktop()->height(); 2799 int dh = QApplication::desktop()->height();
2786#endif 2800#endif
2787 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2801 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2788 mDateFrame->show(); 2802 mDateFrame->show();
2789 } 2803 }
2790} 2804}
2791void CalendarView::showDatePicker( ) 2805void CalendarView::showDatePicker( )
2792{ 2806{
2793 showDatePickerPopup(); 2807 showDatePickerPopup();
2794 mDatePickerMode = 1; 2808 mDatePickerMode = 1;
2795 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2809 mDatePicker->setDate( mNavigator->selectedDates().first() );
2796} 2810}
2797 2811
2798void CalendarView::showEventEditor() 2812void CalendarView::showEventEditor()
2799{ 2813{
2800#ifdef DESKTOP_VERSION 2814#ifdef DESKTOP_VERSION
2801 int x,y,w,h; 2815 int x,y,w,h;
2802 x = mEventEditor->geometry().x(); 2816 x = mEventEditor->geometry().x();
2803 y = mEventEditor->geometry().y(); 2817 y = mEventEditor->geometry().y();
2804 w = mEventEditor->width(); 2818 w = mEventEditor->width();
2805 h = mEventEditor->height(); 2819 h = mEventEditor->height();
2806 mEventEditor->show(); 2820 mEventEditor->show();
2807 mEventEditor->setGeometry(x,y,w,h); 2821 mEventEditor->setGeometry(x,y,w,h);
2808#else 2822#else
2809 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2823 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2810 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2824 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2811 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2825 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2812 qApp->processEvents(); 2826 qApp->processEvents();
2813 delete mEventEditor; 2827 delete mEventEditor;
2814 mEventEditor = mDialogManager->getEventEditor(); 2828 mEventEditor = mDialogManager->getEventEditor();
2815 topLevelWidget()->setCaption( i18n("") ); 2829 topLevelWidget()->setCaption( i18n("") );
2816 } 2830 }
2817 mEventEditor->showMaximized(); 2831 mEventEditor->showMaximized();
2818#endif 2832#endif
2819} 2833}
2820void CalendarView::showTodoEditor() 2834void CalendarView::showTodoEditor()
2821{ 2835{
2822#ifdef DESKTOP_VERSION 2836#ifdef DESKTOP_VERSION
2823 int x,y,w,h; 2837 int x,y,w,h;
2824 x = mTodoEditor->geometry().x(); 2838 x = mTodoEditor->geometry().x();
2825 y = mTodoEditor->geometry().y(); 2839 y = mTodoEditor->geometry().y();
2826 w = mTodoEditor->width(); 2840 w = mTodoEditor->width();
2827 h = mTodoEditor->height(); 2841 h = mTodoEditor->height();
2828 mTodoEditor->show(); 2842 mTodoEditor->show();
2829 mTodoEditor->setGeometry(x,y,w,h); 2843 mTodoEditor->setGeometry(x,y,w,h);
2830#else 2844#else
2831 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2845 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2832 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2846 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2833 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2847 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2834 qApp->processEvents(); 2848 qApp->processEvents();
2835 delete mTodoEditor; 2849 delete mTodoEditor;
2836 mTodoEditor = mDialogManager->getTodoEditor(); 2850 mTodoEditor = mDialogManager->getTodoEditor();
2837 topLevelWidget()->setCaption( i18n("") ); 2851 topLevelWidget()->setCaption( i18n("") );
2838 } 2852 }
2839 mTodoEditor->showMaximized(); 2853 mTodoEditor->showMaximized();
2840#endif 2854#endif
2841} 2855}
2842 2856
2843void CalendarView::cloneIncidence() 2857void CalendarView::cloneIncidence()
2844{ 2858{
2845 Incidence *incidence = currentSelection(); 2859 Incidence *incidence = currentSelection();
2846 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2860 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2847 if ( incidence ) { 2861 if ( incidence ) {
2848 cloneIncidence(incidence); 2862 cloneIncidence(incidence);
2849 } 2863 }
2850} 2864}
2851void CalendarView::moveIncidence() 2865void CalendarView::moveIncidence()
2852{ 2866{
2853 Incidence *incidence = currentSelection(); 2867 Incidence *incidence = currentSelection();
2854 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2868 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2855 if ( incidence ) { 2869 if ( incidence ) {
2856 moveIncidence(incidence); 2870 moveIncidence(incidence);
2857 } 2871 }
2858} 2872}
2859void CalendarView::beamIncidence() 2873void CalendarView::beamIncidence()
2860{ 2874{
2861 Incidence *incidence = currentSelection(); 2875 Incidence *incidence = currentSelection();
2862 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2876 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2863 if ( incidence ) { 2877 if ( incidence ) {
2864 beamIncidence(incidence); 2878 beamIncidence(incidence);
2865 } 2879 }
2866} 2880}
2867void CalendarView::toggleCancelIncidence() 2881void CalendarView::toggleCancelIncidence()
2868{ 2882{
2869 Incidence *incidence = currentSelection(); 2883 Incidence *incidence = currentSelection();
2870 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2884 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2871 if ( incidence ) { 2885 if ( incidence ) {
2872 cancelIncidence(incidence); 2886 cancelIncidence(incidence);
2873 } 2887 }
2874} 2888}
2875 2889
2876 2890
2877void CalendarView::cancelIncidence(Incidence * inc ) 2891void CalendarView::cancelIncidence(Incidence * inc )
2878{ 2892{
2879 inc->setCancelled( ! inc->cancelled() ); 2893 inc->setCancelled( ! inc->cancelled() );
2880 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2894 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2881 updateView(); 2895 updateView();
2882} 2896}
2883void CalendarView::cloneIncidence(Incidence * orgInc ) 2897void CalendarView::cloneIncidence(Incidence * orgInc )
2884{ 2898{
2885 Incidence * newInc = orgInc->clone(); 2899 Incidence * newInc = orgInc->clone();
2886 newInc->recreate(); 2900 newInc->recreate();
2887 2901
2888 if ( newInc->type() == "Todo" ) { 2902 if ( newInc->type() == "Todo" ) {
2889 Todo* t = (Todo*) newInc; 2903 Todo* t = (Todo*) newInc;
2890 bool cloneSub = false; 2904 bool cloneSub = false;
2891 if ( orgInc->relations().count() ) { 2905 if ( orgInc->relations().count() ) {
2892 int result = KMessageBox::warningYesNoCancel(this, 2906 int result = KMessageBox::warningYesNoCancel(this,
2893 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 ) ), 2907 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 ) ),
2894 i18n("Todo has subtodos"), 2908 i18n("Todo has subtodos"),
2895 i18n("Yes"), 2909 i18n("Yes"),
2896 i18n("No")); 2910 i18n("No"));
2897 2911
2898 if ( result == KMessageBox::Cancel ) { 2912 if ( result == KMessageBox::Cancel ) {
2899 delete t; 2913 delete t;
2900 return; 2914 return;
2901 } 2915 }
2902 if (result == KMessageBox::Yes) cloneSub = true; 2916 if (result == KMessageBox::Yes) cloneSub = true;
2903 } 2917 }
2904 showTodoEditor(); 2918 showTodoEditor();
2905 mTodoEditor->editTodo( t ); 2919 mTodoEditor->editTodo( t );
2906 if ( mTodoEditor->exec() ) { 2920 if ( mTodoEditor->exec() ) {
2907 if ( cloneSub ) { 2921 if ( cloneSub ) {
2908 orgInc->cloneRelations( t ); 2922 orgInc->cloneRelations( t );
2909 mCalendar->addIncidenceBranch( t ); 2923 mCalendar->addIncidenceBranch( t );
2910 updateView(); 2924 updateView();
2911 2925
2912 } else { 2926 } else {
2913 mCalendar->addTodo( t ); 2927 mCalendar->addTodo( t );
2914 updateView(); 2928 updateView();
2915 } 2929 }
2916 } else { 2930 } else {
2917 delete t; 2931 delete t;
2918 } 2932 }
2919 } 2933 }
2920 else { 2934 else {
2921 Event* e = (Event*) newInc; 2935 Event* e = (Event*) newInc;
2922 showEventEditor(); 2936 showEventEditor();
2923 mEventEditor->editEvent( e ); 2937 mEventEditor->editEvent( e );
2924 if ( mEventEditor->exec() ) { 2938 if ( mEventEditor->exec() ) {
2925 mCalendar->addEvent( e ); 2939 mCalendar->addEvent( e );
2926 updateView(); 2940 updateView();
2927 } else { 2941 } else {
2928 delete e; 2942 delete e;
2929 } 2943 }
2930 } 2944 }
2931 setActiveWindow(); 2945 setActiveWindow();
2932} 2946}
2933 2947
2934void CalendarView::newEvent() 2948void CalendarView::newEvent()
2935{ 2949{
2936 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2950 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2937 KOAgendaView *aView = mViewManager->agendaView(); 2951 KOAgendaView *aView = mViewManager->agendaView();
2938 if (aView) { 2952 if (aView) {
2939 if (aView->selectionStart().isValid()) { 2953 if (aView->selectionStart().isValid()) {
2940 if (aView->selectedIsAllDay()) { 2954 if (aView->selectedIsAllDay()) {
2941 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2955 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2942 } else { 2956 } else {
2943 newEvent(aView->selectionStart(),aView->selectionEnd()); 2957 newEvent(aView->selectionStart(),aView->selectionEnd());
2944 } 2958 }
2945 return; 2959 return;
2946 } 2960 }
2947 } 2961 }
2948 2962
2949 QDate date = mNavigator->selectedDates().first(); 2963 QDate date = mNavigator->selectedDates().first();
2950 QDateTime current = QDateTime::currentDateTime(); 2964 QDateTime current = QDateTime::currentDateTime();
2951 if ( date <= current.date() ) { 2965 if ( date <= current.date() ) {
2952 int hour = current.time().hour() +1; 2966 int hour = current.time().hour() +1;
2953 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2967 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2954 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2968 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2955 } else 2969 } else
2956 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2970 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2957 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2971 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2958 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2972 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2959} 2973}
2960 2974
2961void CalendarView::newEvent(QDateTime fh) 2975void CalendarView::newEvent(QDateTime fh)
2962{ 2976{
2963 newEvent(fh, 2977 newEvent(fh,
2964 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2978 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2965} 2979}
2966 2980
2967void CalendarView::newEvent(QDate dt) 2981void CalendarView::newEvent(QDate dt)
2968{ 2982{
2969 newEvent(QDateTime(dt, QTime(0,0,0)), 2983 newEvent(QDateTime(dt, QTime(0,0,0)),
2970 QDateTime(dt, QTime(0,0,0)), true); 2984 QDateTime(dt, QTime(0,0,0)), true);
2971} 2985}
2972void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2986void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2973{ 2987{
2974 newEvent(fromHint, toHint, false); 2988 newEvent(fromHint, toHint, false);
2975} 2989}
2976void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2990void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2977{ 2991{
2978 2992
2979 showEventEditor(); 2993 showEventEditor();
2980 mEventEditor->newEvent(fromHint,toHint,allDay); 2994 mEventEditor->newEvent(fromHint,toHint,allDay);
2981 if ( mFilterView->filtersEnabled() ) { 2995 if ( mFilterView->filtersEnabled() ) {
2982 CalFilter *filter = mFilterView->selectedFilter(); 2996 CalFilter *filter = mFilterView->selectedFilter();
2983 if (filter && filter->showCategories()) { 2997 if (filter && filter->showCategories()) {
2984 mEventEditor->setCategories(filter->categoryList().join(",") ); 2998 mEventEditor->setCategories(filter->categoryList().join(",") );
2985 } 2999 }
2986 if ( filter ) 3000 if ( filter )
2987 mEventEditor->setSecrecy( filter->getSecrecy() ); 3001 mEventEditor->setSecrecy( filter->getSecrecy() );
2988 } 3002 }
2989 mEventEditor->exec(); 3003 mEventEditor->exec();
2990 setActiveWindow(); 3004 setActiveWindow();
2991} 3005}
2992void CalendarView::todoAdded(Todo * t) 3006void CalendarView::todoAdded(Todo * t)
2993{ 3007{
2994 3008
2995 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3009 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2996 updateTodoViews(); 3010 updateTodoViews();
2997} 3011}
2998void CalendarView::todoChanged(Todo * t) 3012void CalendarView::todoChanged(Todo * t)
2999{ 3013{
3000 emit todoModified( t, 4 ); 3014 emit todoModified( t, 4 );
3001 // updateTodoViews(); 3015 // updateTodoViews();
3002} 3016}
3003void CalendarView::todoToBeDeleted(Todo *) 3017void CalendarView::todoToBeDeleted(Todo *)
3004{ 3018{
3005 //qDebug("todoToBeDeleted(Todo *) "); 3019 //qDebug("todoToBeDeleted(Todo *) ");
3006 updateTodoViews(); 3020 updateTodoViews();
3007} 3021}
3008void CalendarView::todoDeleted() 3022void CalendarView::todoDeleted()
3009{ 3023{
3010 //qDebug(" todoDeleted()"); 3024 //qDebug(" todoDeleted()");
3011 updateTodoViews(); 3025 updateTodoViews();
3012} 3026}
3013 3027
3014 3028
3015void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3029void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3016{ 3030{
3017 showTodoEditor(); 3031 showTodoEditor();
3018 mTodoEditor->newTodo(dt,0,allday); 3032 mTodoEditor->newTodo(dt,0,allday);
3019 if ( mFilterView->filtersEnabled() ) { 3033 if ( mFilterView->filtersEnabled() ) {
3020 CalFilter *filter = mFilterView->selectedFilter(); 3034 CalFilter *filter = mFilterView->selectedFilter();
3021 if (filter && filter->showCategories()) { 3035 if (filter && filter->showCategories()) {
3022 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3036 mTodoEditor->setCategories(filter->categoryList().join(",") );
3023 } 3037 }
3024 if ( filter ) 3038 if ( filter )
3025 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3039 mTodoEditor->setSecrecy( filter->getSecrecy() );
3026 } 3040 }
3027 mTodoEditor->exec(); 3041 mTodoEditor->exec();
3028 setActiveWindow(); 3042 setActiveWindow();
3029} 3043}
3030 3044
3031void CalendarView::newTodo() 3045void CalendarView::newTodo()
3032{ 3046{
3033 newTodoDateTime( QDateTime(),true ); 3047 newTodoDateTime( QDateTime(),true );
3034} 3048}
3035 3049
3036void CalendarView::newSubTodo() 3050void CalendarView::newSubTodo()
3037{ 3051{
3038 Todo *todo = selectedTodo(); 3052 Todo *todo = selectedTodo();
3039 if ( todo ) newSubTodo( todo ); 3053 if ( todo ) newSubTodo( todo );
3040} 3054}
3041 3055
3042void CalendarView::newSubTodo(Todo *parentEvent) 3056void CalendarView::newSubTodo(Todo *parentEvent)
3043{ 3057{
3044 3058
3045 showTodoEditor(); 3059 showTodoEditor();
3046 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3060 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3047 mTodoEditor->exec(); 3061 mTodoEditor->exec();
3048 setActiveWindow(); 3062 setActiveWindow();
3049} 3063}
3050 3064
3051void CalendarView::newFloatingEvent() 3065void CalendarView::newFloatingEvent()
3052{ 3066{
3053 DateList tmpList = mNavigator->selectedDates(); 3067 DateList tmpList = mNavigator->selectedDates();
3054 QDate date = tmpList.first(); 3068 QDate date = tmpList.first();
3055 3069
3056 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3070 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3057 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3071 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3058} 3072}
3059 3073
3060 3074
3061void CalendarView::editEvent( Event *event ) 3075void CalendarView::editEvent( Event *event )
3062{ 3076{
3063 3077
3064 if ( !event ) return; 3078 if ( !event ) return;
3065 if ( event->isReadOnly() ) { 3079 if ( event->isReadOnly() ) {
3066 showEvent( event ); 3080 showEvent( event );
3067 return; 3081 return;
3068 } 3082 }
3069 showEventEditor(); 3083 showEventEditor();
3070 mEventEditor->editEvent( event , mFlagEditDescription); 3084 mEventEditor->editEvent( event , mFlagEditDescription);
3071 mEventEditor->exec(); 3085 mEventEditor->exec();
3072 setActiveWindow(); 3086 setActiveWindow();
3073 3087
3074} 3088}
3075void CalendarView::editJournal( Journal *jour ) 3089void CalendarView::editJournal( Journal *jour )
3076{ 3090{
3077 if ( !jour ) return; 3091 if ( !jour ) return;
3078 mDialogManager->hideSearchDialog(); 3092 mDialogManager->hideSearchDialog();
3079 mViewManager->showJournalView(); 3093 mViewManager->showJournalView();
3080 mNavigator->slotDaySelect( jour->dtStart().date() ); 3094 mNavigator->slotDaySelect( jour->dtStart().date() );
3081} 3095}
3082void CalendarView::editTodo( Todo *todo ) 3096void CalendarView::editTodo( Todo *todo )
3083{ 3097{
3084 if ( !todo ) return; 3098 if ( !todo ) return;
3085 3099
3086 if ( todo->isReadOnly() ) { 3100 if ( todo->isReadOnly() ) {
3087 showTodo( todo ); 3101 showTodo( todo );
3088 return; 3102 return;
3089 } 3103 }
3090 showTodoEditor(); 3104 showTodoEditor();
3091 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3105 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3092 mTodoEditor->exec(); 3106 mTodoEditor->exec();
3093 setActiveWindow(); 3107 setActiveWindow();
3094 3108
3095} 3109}
3096 3110
3097KOEventViewerDialog* CalendarView::getEventViewerDialog() 3111KOEventViewerDialog* CalendarView::getEventViewerDialog()
3098{ 3112{
3099 if ( !mEventViewerDialog ) { 3113 if ( !mEventViewerDialog ) {
3100 mEventViewerDialog = new KOEventViewerDialog(0); 3114 mEventViewerDialog = new KOEventViewerDialog(0);
3101 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3115 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3102 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3116 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3103 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3117 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3104 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3118 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3105 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3119 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3106 viewManager(), SLOT( showAgendaView( bool ) ) ); 3120 viewManager(), SLOT( showAgendaView( bool ) ) );
3107 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3121 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3108 this, SLOT( slotViewerClosed() ) ); 3122 this, SLOT( slotViewerClosed() ) );
3109 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3123 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3110 this, SLOT( todoChanged(Todo *) ) ); 3124 this, SLOT( todoChanged(Todo *) ) );
3111 mEventViewerDialog->resize( 640, 480 ); 3125 mEventViewerDialog->resize( 640, 480 );
3112 3126
3113 } 3127 }
3114 return mEventViewerDialog; 3128 return mEventViewerDialog;
3115} 3129}
3116void CalendarView::showEvent(Event *event) 3130void CalendarView::showEvent(Event *event)
3117{ 3131{
3118 getEventViewerDialog()->setEvent(event); 3132 getEventViewerDialog()->setEvent(event);
3119 getEventViewerDialog()->showMe(); 3133 getEventViewerDialog()->showMe();
3120} 3134}
3121 3135
3122void CalendarView::showTodo(Todo *event) 3136void CalendarView::showTodo(Todo *event)
3123{ 3137{
3124 getEventViewerDialog()->setTodo(event); 3138 getEventViewerDialog()->setTodo(event);
3125 getEventViewerDialog()->showMe(); 3139 getEventViewerDialog()->showMe();
3126} 3140}
3127void CalendarView::showJournal( Journal *jour ) 3141void CalendarView::showJournal( Journal *jour )
3128{ 3142{
3129 getEventViewerDialog()->setJournal(jour); 3143 getEventViewerDialog()->setJournal(jour);
3130 getEventViewerDialog()->showMe(); 3144 getEventViewerDialog()->showMe();
3131 3145
3132} 3146}
3133// void CalendarView::todoModified (Todo *event, int changed) 3147// void CalendarView::todoModified (Todo *event, int changed)
3134// { 3148// {
3135// // if (mDialogList.find (event) != mDialogList.end ()) { 3149// // if (mDialogList.find (event) != mDialogList.end ()) {
3136// // kdDebug() << "Todo modified and open" << endl; 3150// // kdDebug() << "Todo modified and open" << endl;
3137// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3151// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3138// // temp->modified (changed); 3152// // temp->modified (changed);
3139 3153
3140// // } 3154// // }
3141 3155
3142// mViewManager->updateView(); 3156// mViewManager->updateView();
3143// } 3157// }
3144 3158
3145void CalendarView::appointment_show() 3159void CalendarView::appointment_show()
3146{ 3160{
3147 Event *anEvent = 0; 3161 Event *anEvent = 0;
3148 3162
3149 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3163 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3150 3164
3151 if (mViewManager->currentView()->isEventView()) { 3165 if (mViewManager->currentView()->isEventView()) {
3152 if ( incidence && incidence->type() == "Event" ) { 3166 if ( incidence && incidence->type() == "Event" ) {
3153 anEvent = static_cast<Event *>(incidence); 3167 anEvent = static_cast<Event *>(incidence);
3154 } 3168 }
3155 } 3169 }
3156 3170
3157 if (!anEvent) { 3171 if (!anEvent) {
3158 KNotifyClient::beep(); 3172 KNotifyClient::beep();
3159 return; 3173 return;
3160 } 3174 }
3161 3175
3162 showEvent(anEvent); 3176 showEvent(anEvent);
3163} 3177}
3164 3178
3165void CalendarView::appointment_edit() 3179void CalendarView::appointment_edit()
3166{ 3180{
3167 Event *anEvent = 0; 3181 Event *anEvent = 0;
3168 3182
3169 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3183 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3170 3184
3171 if (mViewManager->currentView()->isEventView()) { 3185 if (mViewManager->currentView()->isEventView()) {
3172 if ( incidence && incidence->type() == "Event" ) { 3186 if ( incidence && incidence->type() == "Event" ) {
3173 anEvent = static_cast<Event *>(incidence); 3187 anEvent = static_cast<Event *>(incidence);
3174 } 3188 }
3175 } 3189 }
3176 3190
3177 if (!anEvent) { 3191 if (!anEvent) {
3178 KNotifyClient::beep(); 3192 KNotifyClient::beep();
3179 return; 3193 return;
3180 } 3194 }
3181 3195
3182 editEvent(anEvent); 3196 editEvent(anEvent);
3183} 3197}
3184 3198
3185void CalendarView::appointment_delete() 3199void CalendarView::appointment_delete()
3186{ 3200{
3187 Event *anEvent = 0; 3201 Event *anEvent = 0;
3188 3202
3189 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3203 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3190 3204
3191 if (mViewManager->currentView()->isEventView()) { 3205 if (mViewManager->currentView()->isEventView()) {
3192 if ( incidence && incidence->type() == "Event" ) { 3206 if ( incidence && incidence->type() == "Event" ) {
3193 anEvent = static_cast<Event *>(incidence); 3207 anEvent = static_cast<Event *>(incidence);
3194 } 3208 }
3195 } 3209 }
3196 3210
3197 if (!anEvent) { 3211 if (!anEvent) {
3198 KNotifyClient::beep(); 3212 KNotifyClient::beep();
3199 return; 3213 return;
3200 } 3214 }
3201 3215
3202 deleteEvent(anEvent); 3216 deleteEvent(anEvent);
3203} 3217}
3204 3218
3205void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3219void CalendarView::todo_resub( Todo * parent, Todo * sub )
3206{ 3220{
3207 if (!sub) return; 3221 if (!sub) return;
3208 if ( sub->relatedTo() == parent ) 3222 if ( sub->relatedTo() == parent )
3209 return; 3223 return;
3210 sub->setRelatedTo(parent); 3224 sub->setRelatedTo(parent);
3211 sub->updated(); 3225 sub->updated();
3212 setModified(true); 3226 setModified(true);
3213 updateView(); 3227 updateView();
3214} 3228}
3215void CalendarView::todo_unsub(Todo *anTodo ) 3229void CalendarView::todo_unsub(Todo *anTodo )
3216{ 3230{
3217 todo_resub( 0, anTodo ); 3231 todo_resub( 0, anTodo );
3218} 3232}
3219 3233
3220void CalendarView::deleteTodo(Todo *todo) 3234void CalendarView::deleteTodo(Todo *todo)
3221{ 3235{
3222 if (!todo) { 3236 if (!todo) {
3223 KNotifyClient::beep(); 3237 KNotifyClient::beep();
3224 return; 3238 return;
3225 } 3239 }
3226 if (KOPrefs::instance()->mConfirm) { 3240 if (KOPrefs::instance()->mConfirm) {
3227 QString text = todo->summary().left(20); 3241 QString text = todo->summary().left(20);
3228 if (!todo->relations().isEmpty()) { 3242 if (!todo->relations().isEmpty()) {
3229 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3243 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3230 3244
3231 } 3245 }
3232 switch (msgItemDelete(text)) { 3246 switch (msgItemDelete(text)) {
3233 case KMessageBox::Continue: // OK 3247 case KMessageBox::Continue: // OK
3234 bool deleteT = false; 3248 bool deleteT = false;
3235 if (!todo->relations().isEmpty()) { 3249 if (!todo->relations().isEmpty()) {
3236 deleteT = removeCompletedSubTodos( todo ); 3250 deleteT = removeCompletedSubTodos( todo );
3237 } 3251 }
3238 // deleteT == true: todo already deleted in removeCompletedSubTodos 3252 // deleteT == true: todo already deleted in removeCompletedSubTodos
3239 if ( !deleteT ) { 3253 if ( !deleteT ) {
3240 checkExternalId( todo ); 3254 checkExternalId( todo );
3241 calendar()->deleteTodo(todo); 3255 calendar()->deleteTodo(todo);
3242 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3256 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3243 updateView(); 3257 updateView();
3244 } 3258 }
3245 break; 3259 break;
3246 } // switch 3260 } // switch
3247 } else { 3261 } else {
3248 checkExternalId( todo ); 3262 checkExternalId( todo );
3249 mCalendar->deleteTodo(todo); 3263 mCalendar->deleteTodo(todo);
3250 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3264 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3251 updateView(); 3265 updateView();
3252 } 3266 }
3253 3267
3254 emit updateSearchDialog(); 3268 emit updateSearchDialog();
3255} 3269}
3256void CalendarView::deleteJournal(Journal *jour) 3270void CalendarView::deleteJournal(Journal *jour)
3257{ 3271{
3258 if (!jour) { 3272 if (!jour) {
3259 KNotifyClient::beep(); 3273 KNotifyClient::beep();
3260 return; 3274 return;
3261 } 3275 }
3262 if (KOPrefs::instance()->mConfirm) { 3276 if (KOPrefs::instance()->mConfirm) {
3263 switch (msgItemDelete( jour->description().left(20))) { 3277 switch (msgItemDelete( jour->description().left(20))) {
3264 case KMessageBox::Continue: // OK 3278 case KMessageBox::Continue: // OK
3265 calendar()->deleteJournal(jour); 3279 calendar()->deleteJournal(jour);
3266 updateView(); 3280 updateView();
3267 break; 3281 break;
3268 } // switch 3282 } // switch
3269 } else { 3283 } else {
3270 calendar()->deleteJournal(jour);; 3284 calendar()->deleteJournal(jour);;
3271 updateView(); 3285 updateView();
3272 } 3286 }
3273 emit updateSearchDialog(); 3287 emit updateSearchDialog();
3274} 3288}
3275 3289
3276void CalendarView::deleteEvent(Event *anEvent) 3290void CalendarView::deleteEvent(Event *anEvent)
3277{ 3291{
3278 if (!anEvent) { 3292 if (!anEvent) {
3279 KNotifyClient::beep(); 3293 KNotifyClient::beep();
3280 return; 3294 return;
3281 } 3295 }
3282 3296
3283 if (anEvent->recurrence()->doesRecur()) { 3297 if (anEvent->recurrence()->doesRecur()) {
3284 QDate itemDate = mViewManager->currentSelectionDate(); 3298 QDate itemDate = mViewManager->currentSelectionDate();
3285 int km; 3299 int km;
3286 if (!itemDate.isValid()) { 3300 if (!itemDate.isValid()) {
3287 //kdDebug() << "Date Not Valid" << endl; 3301 //kdDebug() << "Date Not Valid" << endl;
3288 if (KOPrefs::instance()->mConfirm) { 3302 if (KOPrefs::instance()->mConfirm) {
3289 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3303 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3290 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3304 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3291 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3305 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3292 if ( km == KMessageBox::Continue ) 3306 if ( km == KMessageBox::Continue )
3293 km = KMessageBox::No; // No = all below 3307 km = KMessageBox::No; // No = all below
3294 } else 3308 } else
3295 km = KMessageBox::No; 3309 km = KMessageBox::No;
3296 } else { 3310 } else {
3297 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3311 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3298 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3312 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3299 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3313 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3300 i18n("KO/Pi Confirmation"),i18n("Current"), 3314 i18n("KO/Pi Confirmation"),i18n("Current"),
3301 i18n("All")); 3315 i18n("All"));
3302 } 3316 }
3303 switch(km) { 3317 switch(km) {
3304 3318
3305 case KMessageBox::No: // Continue // all 3319 case KMessageBox::No: // Continue // all
3306 //qDebug("KMessageBox::No "); 3320 //qDebug("KMessageBox::No ");
3307 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3321 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3308 schedule(Scheduler::Cancel,anEvent); 3322 schedule(Scheduler::Cancel,anEvent);
3309 3323
3310 checkExternalId( anEvent); 3324 checkExternalId( anEvent);
3311 mCalendar->deleteEvent(anEvent); 3325 mCalendar->deleteEvent(anEvent);
3312 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3326 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3313 break; 3327 break;
3314 3328
3315 // Disabled because it does not work 3329 // Disabled because it does not work
3316 //#if 0 3330 //#if 0
3317 case KMessageBox::Yes: // just this one 3331 case KMessageBox::Yes: // just this one
3318 //QDate qd = mNavigator->selectedDates().first(); 3332 //QDate qd = mNavigator->selectedDates().first();
3319 //if (!qd.isValid()) { 3333 //if (!qd.isValid()) {
3320 // kdDebug() << "no date selected, or invalid date" << endl; 3334 // kdDebug() << "no date selected, or invalid date" << endl;
3321 // KNotifyClient::beep(); 3335 // KNotifyClient::beep();
3322 // return; 3336 // return;
3323 //} 3337 //}
3324 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3338 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3325 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3339 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3326 anEvent->addExDate(itemDate); 3340 anEvent->addExDate(itemDate);
3327 int duration = anEvent->recurrence()->duration(); 3341 int duration = anEvent->recurrence()->duration();
3328 if ( duration > 0 ) { 3342 if ( duration > 0 ) {
3329 anEvent->recurrence()->setDuration( duration - 1 ); 3343 anEvent->recurrence()->setDuration( duration - 1 );
3330 } 3344 }
3331 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3345 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3332 } 3346 }
3333 break; 3347 break;
3334 //#endif 3348 //#endif
3335 } // switch 3349 } // switch
3336 } else { 3350 } else {
3337 if (KOPrefs::instance()->mConfirm) { 3351 if (KOPrefs::instance()->mConfirm) {
3338 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3352 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3339 i18n("\nAre you sure you want\nto delete this event?"), 3353 i18n("\nAre you sure you want\nto delete this event?"),
3340 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3354 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3341 case KMessageBox::Continue: // OK 3355 case KMessageBox::Continue: // OK
3342 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3356 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3343 schedule(Scheduler::Cancel,anEvent); 3357 schedule(Scheduler::Cancel,anEvent);
3344 checkExternalId( anEvent); 3358 checkExternalId( anEvent);
3345 mCalendar->deleteEvent(anEvent); 3359 mCalendar->deleteEvent(anEvent);
3346 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3360 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3347 break; 3361 break;
3348 } // switch 3362 } // switch
3349 } else { 3363 } else {
3350 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3364 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3351 schedule(Scheduler::Cancel,anEvent); 3365 schedule(Scheduler::Cancel,anEvent);
3352 checkExternalId( anEvent); 3366 checkExternalId( anEvent);
3353 mCalendar->deleteEvent(anEvent); 3367 mCalendar->deleteEvent(anEvent);
3354 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3368 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3355 } 3369 }
3356 } // if-else 3370 } // if-else
3357 emit updateSearchDialog(); 3371 emit updateSearchDialog();
3358} 3372}
3359 3373
3360bool CalendarView::deleteEvent(const QString &uid) 3374bool CalendarView::deleteEvent(const QString &uid)
3361{ 3375{
3362 Event *ev = mCalendar->event(uid); 3376 Event *ev = mCalendar->event(uid);
3363 if (ev) { 3377 if (ev) {
3364 deleteEvent(ev); 3378 deleteEvent(ev);
3365 return true; 3379 return true;
3366 } else { 3380 } else {
3367 return false; 3381 return false;
3368 } 3382 }
3369} 3383}
3370 3384
3371/*****************************************************************************/ 3385/*****************************************************************************/
3372 3386
3373void CalendarView::action_mail() 3387void CalendarView::action_mail()
3374{ 3388{
3375#ifndef KORG_NOMAIL 3389#ifndef KORG_NOMAIL
3376 KOMailClient mailClient; 3390 KOMailClient mailClient;
3377 3391
3378 Incidence *incidence = currentSelection(); 3392 Incidence *incidence = currentSelection();
3379 3393
3380 if (!incidence) { 3394 if (!incidence) {
3381 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3395 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3382 return; 3396 return;
3383 } 3397 }
3384 if(incidence->attendeeCount() == 0 ) { 3398 if(incidence->attendeeCount() == 0 ) {
3385 KMessageBox::sorry(this, 3399 KMessageBox::sorry(this,
3386 i18n("Can't generate mail:\nNo attendees defined.\n")); 3400 i18n("Can't generate mail:\nNo attendees defined.\n"));
3387 return; 3401 return;
3388 } 3402 }
3389 3403
3390 CalendarLocal cal_tmp; 3404 CalendarLocal cal_tmp;
3391 Event *event = 0; 3405 Event *event = 0;
3392 Event *ev = 0; 3406 Event *ev = 0;
3393 if ( incidence && incidence->type() == "Event" ) { 3407 if ( incidence && incidence->type() == "Event" ) {
3394 event = static_cast<Event *>(incidence); 3408 event = static_cast<Event *>(incidence);
3395 ev = new Event(*event); 3409 ev = new Event(*event);
3396 cal_tmp.addEvent(ev); 3410 cal_tmp.addEvent(ev);
3397 } 3411 }
3398 ICalFormat mForm(); 3412 ICalFormat mForm();
3399 QString attachment = mForm.toString( &cal_tmp ); 3413 QString attachment = mForm.toString( &cal_tmp );
3400 if (ev) delete(ev); 3414 if (ev) delete(ev);
3401 3415
3402 mailClient.mailAttendees(currentSelection(), attachment); 3416 mailClient.mailAttendees(currentSelection(), attachment);
3403 3417
3404#endif 3418#endif
3405 3419
3406#if 0 3420#if 0
3407 Event *anEvent = 0; 3421 Event *anEvent = 0;
3408 if (mViewManager->currentView()->isEventView()) { 3422 if (mViewManager->currentView()->isEventView()) {
3409 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3423 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3410 } 3424 }
3411 3425
3412 if (!anEvent) { 3426 if (!anEvent) {
3413 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3427 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3414 return; 3428 return;
3415 } 3429 }
3416 if(anEvent->attendeeCount() == 0 ) { 3430 if(anEvent->attendeeCount() == 0 ) {
3417 KMessageBox::sorry(this, 3431 KMessageBox::sorry(this,
3418 i18n("Can't generate mail:\nNo attendees defined.\n")); 3432 i18n("Can't generate mail:\nNo attendees defined.\n"));
3419 return; 3433 return;
3420 } 3434 }
3421 3435
3422 mailobject.emailEvent(anEvent); 3436 mailobject.emailEvent(anEvent);
3423#endif 3437#endif
3424} 3438}
3425 3439
3426 3440
3427void CalendarView::schedule_publish(Incidence *incidence) 3441void CalendarView::schedule_publish(Incidence *incidence)
3428{ 3442{
3429 Event *event = 0; 3443 Event *event = 0;
3430 Todo *todo = 0; 3444 Todo *todo = 0;
3431 3445
3432 if (incidence == 0) { 3446 if (incidence == 0) {
3433 incidence = mViewManager->currentView()->selectedIncidences().first(); 3447 incidence = mViewManager->currentView()->selectedIncidences().first();
3434 if (incidence == 0) { 3448 if (incidence == 0) {
3435 incidence = mTodoList->selectedIncidences().first(); 3449 incidence = mTodoList->selectedIncidences().first();
3436 } 3450 }
3437 } 3451 }
3438 if ( incidence && incidence->type() == "Event" ) { 3452 if ( incidence && incidence->type() == "Event" ) {
3439 event = static_cast<Event *>(incidence); 3453 event = static_cast<Event *>(incidence);
3440 } else { 3454 } else {
3441 if ( incidence && incidence->type() == "Todo" ) { 3455 if ( incidence && incidence->type() == "Todo" ) {
3442 todo = static_cast<Todo *>(incidence); 3456 todo = static_cast<Todo *>(incidence);
3443 } 3457 }
3444 } 3458 }
3445 3459
3446 if (!event && !todo) { 3460 if (!event && !todo) {
3447 KMessageBox::sorry(this,i18n("No event selected.")); 3461 KMessageBox::sorry(this,i18n("No event selected."));
3448 return; 3462 return;
3449 } 3463 }
3450 3464
3451 PublishDialog *publishdlg = new PublishDialog(); 3465 PublishDialog *publishdlg = new PublishDialog();
3452 if (incidence->attendeeCount()>0) { 3466 if (incidence->attendeeCount()>0) {
3453 QPtrList<Attendee> attendees = incidence->attendees(); 3467 QPtrList<Attendee> attendees = incidence->attendees();
3454 attendees.first(); 3468 attendees.first();
3455 while ( attendees.current()!=0 ) { 3469 while ( attendees.current()!=0 ) {
3456 publishdlg->addAttendee(attendees.current()); 3470 publishdlg->addAttendee(attendees.current());
3457 attendees.next(); 3471 attendees.next();
3458 } 3472 }
3459 } 3473 }
3460 bool send = true; 3474 bool send = true;
3461 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3475 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3462 if ( publishdlg->exec() != QDialog::Accepted ) 3476 if ( publishdlg->exec() != QDialog::Accepted )
3463 send = false; 3477 send = false;
3464 } 3478 }
3465 if ( send ) { 3479 if ( send ) {
3466 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3480 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3467 if ( event ) { 3481 if ( event ) {
3468 Event *ev = new Event(*event); 3482 Event *ev = new Event(*event);
3469 ev->registerObserver(0); 3483 ev->registerObserver(0);
3470 ev->clearAttendees(); 3484 ev->clearAttendees();
3471 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3485 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3472 delete(ev); 3486 delete(ev);
3473 } 3487 }
3474 } else { 3488 } else {
3475 if ( todo ) { 3489 if ( todo ) {
3476 Todo *ev = new Todo(*todo); 3490 Todo *ev = new Todo(*todo);
3477 ev->registerObserver(0); 3491 ev->registerObserver(0);
3478 ev->clearAttendees(); 3492 ev->clearAttendees();
3479 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3493 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3480 delete(ev); 3494 delete(ev);
3481 } 3495 }
3482 } 3496 }
3483 } 3497 }
3484 } 3498 }
3485 delete publishdlg; 3499 delete publishdlg;
3486} 3500}
3487 3501
3488void CalendarView::schedule_request(Incidence *incidence) 3502void CalendarView::schedule_request(Incidence *incidence)
3489{ 3503{
3490 schedule(Scheduler::Request,incidence); 3504 schedule(Scheduler::Request,incidence);
3491} 3505}
3492 3506
3493void CalendarView::schedule_refresh(Incidence *incidence) 3507void CalendarView::schedule_refresh(Incidence *incidence)
3494{ 3508{
3495 schedule(Scheduler::Refresh,incidence); 3509 schedule(Scheduler::Refresh,incidence);
3496} 3510}
3497 3511
3498void CalendarView::schedule_cancel(Incidence *incidence) 3512void CalendarView::schedule_cancel(Incidence *incidence)
3499{ 3513{
3500 schedule(Scheduler::Cancel,incidence); 3514 schedule(Scheduler::Cancel,incidence);
3501} 3515}
3502 3516
3503void CalendarView::schedule_add(Incidence *incidence) 3517void CalendarView::schedule_add(Incidence *incidence)
3504{ 3518{
3505 schedule(Scheduler::Add,incidence); 3519 schedule(Scheduler::Add,incidence);
3506} 3520}
3507 3521
3508void CalendarView::schedule_reply(Incidence *incidence) 3522void CalendarView::schedule_reply(Incidence *incidence)
3509{ 3523{
3510 schedule(Scheduler::Reply,incidence); 3524 schedule(Scheduler::Reply,incidence);
3511} 3525}
3512 3526
3513void CalendarView::schedule_counter(Incidence *incidence) 3527void CalendarView::schedule_counter(Incidence *incidence)
3514{ 3528{
3515 schedule(Scheduler::Counter,incidence); 3529 schedule(Scheduler::Counter,incidence);
3516} 3530}
3517 3531
3518void CalendarView::schedule_declinecounter(Incidence *incidence) 3532void CalendarView::schedule_declinecounter(Incidence *incidence)
3519{ 3533{
3520 schedule(Scheduler::Declinecounter,incidence); 3534 schedule(Scheduler::Declinecounter,incidence);
3521} 3535}
3522 3536
3523void CalendarView::schedule_publish_freebusy(int daysToPublish) 3537void CalendarView::schedule_publish_freebusy(int daysToPublish)
3524{ 3538{
3525 QDateTime start = QDateTime::currentDateTime(); 3539 QDateTime start = QDateTime::currentDateTime();
3526 QDateTime end = start.addDays(daysToPublish); 3540 QDateTime end = start.addDays(daysToPublish);
3527 3541
3528 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3542 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3529 freebusy->setOrganizer(KOPrefs::instance()->email()); 3543 freebusy->setOrganizer(KOPrefs::instance()->email());
3530 3544
3531 3545
3532 PublishDialog *publishdlg = new PublishDialog(); 3546 PublishDialog *publishdlg = new PublishDialog();
3533 if ( publishdlg->exec() == QDialog::Accepted ) { 3547 if ( publishdlg->exec() == QDialog::Accepted ) {
3534 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3548 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3535 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3549 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3536 delete(freebusy); 3550 delete(freebusy);
3537 } 3551 }
3538 } 3552 }
3539 delete publishdlg; 3553 delete publishdlg;
3540} 3554}
3541 3555
3542void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3556void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3543{ 3557{
3544 Event *event = 0; 3558 Event *event = 0;
3545 Todo *todo = 0; 3559 Todo *todo = 0;
3546 3560
3547 if (incidence == 0) { 3561 if (incidence == 0) {
3548 incidence = mViewManager->currentView()->selectedIncidences().first(); 3562 incidence = mViewManager->currentView()->selectedIncidences().first();
3549 if (incidence == 0) { 3563 if (incidence == 0) {
3550 incidence = mTodoList->selectedIncidences().first(); 3564 incidence = mTodoList->selectedIncidences().first();
3551 } 3565 }
3552 } 3566 }
3553 if ( incidence && incidence->type() == "Event" ) { 3567 if ( incidence && incidence->type() == "Event" ) {
3554 event = static_cast<Event *>(incidence); 3568 event = static_cast<Event *>(incidence);
3555 } 3569 }
3556 if ( incidence && incidence->type() == "Todo" ) { 3570 if ( incidence && incidence->type() == "Todo" ) {
3557 todo = static_cast<Todo *>(incidence); 3571 todo = static_cast<Todo *>(incidence);
3558 } 3572 }
3559 3573
3560 if (!event && !todo) { 3574 if (!event && !todo) {
3561 KMessageBox::sorry(this,i18n("No event selected.")); 3575 KMessageBox::sorry(this,i18n("No event selected."));
3562 return; 3576 return;
3563 } 3577 }
3564 3578
3565 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3579 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3566 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3580 KMessageBox::sorry(this,i18n("The event has no attendees."));
3567 return; 3581 return;
3568 } 3582 }
3569 3583
3570 Event *ev = 0; 3584 Event *ev = 0;
3571 if (event) ev = new Event(*event); 3585 if (event) ev = new Event(*event);
3572 Todo *to = 0; 3586 Todo *to = 0;
3573 if (todo) to = new Todo(*todo); 3587 if (todo) to = new Todo(*todo);
3574 3588
3575 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3589 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3576 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3590 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3577 if (!me) { 3591 if (!me) {
3578 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3592 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3579 return; 3593 return;
3580 } 3594 }
3581 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3595 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3582 StatusDialog *statdlg = new StatusDialog(this); 3596 StatusDialog *statdlg = new StatusDialog(this);
3583 if (!statdlg->exec()==QDialog::Accepted) return; 3597 if (!statdlg->exec()==QDialog::Accepted) return;
3584 me->setStatus( statdlg->status() ); 3598 me->setStatus( statdlg->status() );
3585 delete(statdlg); 3599 delete(statdlg);
3586 } 3600 }
3587 Attendee *menew = new Attendee(*me); 3601 Attendee *menew = new Attendee(*me);
3588 if (ev) { 3602 if (ev) {
3589 ev->clearAttendees(); 3603 ev->clearAttendees();
3590 ev->addAttendee(menew,false); 3604 ev->addAttendee(menew,false);
3591 } else { 3605 } else {
3592 if (to) { 3606 if (to) {
3593 todo->clearAttendees(); 3607 todo->clearAttendees();
3594 todo->addAttendee(menew,false); 3608 todo->addAttendee(menew,false);
3595 } 3609 }
3596 } 3610 }
3597 } 3611 }
3598 3612
3599 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3613 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3600 if (ev) { 3614 if (ev) {
3601 if ( !dlg->addMessage(ev,method) ) delete(ev); 3615 if ( !dlg->addMessage(ev,method) ) delete(ev);
3602 } else { 3616 } else {
3603 if (to) { 3617 if (to) {
3604 if ( !dlg->addMessage(to,method) ) delete(to); 3618 if ( !dlg->addMessage(to,method) ) delete(to);
3605 } 3619 }
3606 } 3620 }
3607} 3621}
3608 3622
3609void CalendarView::openAddressbook() 3623void CalendarView::openAddressbook()
3610{ 3624{
3611 KRun::runCommand("kaddressbook"); 3625 KRun::runCommand("kaddressbook");
3612} 3626}
3613 3627
3614void CalendarView::setModified(bool modified) 3628void CalendarView::setModified(bool modified)
3615{ 3629{
3616 if ( modified ) 3630 if ( modified )
3617 emit signalmodified(); 3631 emit signalmodified();
3618 if (mModified != modified) { 3632 if (mModified != modified) {
3619 mModified = modified; 3633 mModified = modified;
3620 emit modifiedChanged(mModified); 3634 emit modifiedChanged(mModified);
3621 } 3635 }
3622} 3636}
3623 3637
3624bool CalendarView::isReadOnly() 3638bool CalendarView::isReadOnly()
3625{ 3639{
3626 return mReadOnly; 3640 return mReadOnly;
3627} 3641}
3628 3642
3629void CalendarView::setReadOnly(bool readOnly) 3643void CalendarView::setReadOnly(bool readOnly)
3630{ 3644{
3631 if (mReadOnly != readOnly) { 3645 if (mReadOnly != readOnly) {
3632 mReadOnly = readOnly; 3646 mReadOnly = readOnly;
3633 emit readOnlyChanged(mReadOnly); 3647 emit readOnlyChanged(mReadOnly);
3634 } 3648 }
3635} 3649}
3636 3650
3637bool CalendarView::isModified() 3651bool CalendarView::isModified()
3638{ 3652{
3639 return mModified; 3653 return mModified;
3640} 3654}
3641void CalendarView::slotprintSelInc() 3655void CalendarView::slotprintSelInc()
3642{ 3656{
3643 if ( currentSelection() == 0 ) { 3657 if ( currentSelection() == 0 ) {
3644 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3658 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3645 return; 3659 return;
3646 } 3660 }
3647 showIncidence(); 3661 showIncidence();
3648 getEventViewerDialog()->print(); 3662 getEventViewerDialog()->print();
3649 3663
3650} 3664}
3651void CalendarView::printSetup() 3665void CalendarView::printSetup()
3652{ 3666{
3653#ifndef KORG_NOPRINTER 3667#ifndef KORG_NOPRINTER
3654 createPrinter(); 3668 createPrinter();
3655 3669
3656 mCalPrinter->setupPrinter(); 3670 mCalPrinter->setupPrinter();
3657#endif 3671#endif
3658} 3672}
3659 3673
3660void CalendarView::print() 3674void CalendarView::print()
3661{ 3675{
3662#ifndef KORG_NOPRINTER 3676#ifndef KORG_NOPRINTER
3663 createPrinter(); 3677 createPrinter();
3664 3678
3665 DateList tmpDateList = mNavigator->selectedDates(); 3679 DateList tmpDateList = mNavigator->selectedDates();
3666 mCalPrinter->print(CalPrinter::Month, 3680 mCalPrinter->print(CalPrinter::Month,
3667 tmpDateList.first(), tmpDateList.last()); 3681 tmpDateList.first(), tmpDateList.last());
3668#endif 3682#endif
3669} 3683}
3670 3684
3671void CalendarView::printPreview() 3685void CalendarView::printPreview()
3672{ 3686{
3673#ifndef KORG_NOPRINTER 3687#ifndef KORG_NOPRINTER
3674 kdDebug() << "CalendarView::printPreview()" << endl; 3688 kdDebug() << "CalendarView::printPreview()" << endl;
3675 3689
3676 createPrinter(); 3690 createPrinter();
3677 3691
3678 DateList tmpDateList = mNavigator->selectedDates(); 3692 DateList tmpDateList = mNavigator->selectedDates();
3679 3693
3680 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3694 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3681 tmpDateList.last()); 3695 tmpDateList.last());
3682#endif 3696#endif
3683} 3697}
3684 3698
3685void CalendarView::exportICalendar() 3699void CalendarView::exportICalendar()
3686{ 3700{
3687 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3701 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3688 3702
3689 // Force correct extension 3703 // Force correct extension
3690 if (filename.right(4) != ".ics") filename += ".ics"; 3704 if (filename.right(4) != ".ics") filename += ".ics";
3691 3705
3692 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3706 FileStorage storage( mCalendar, filename, new ICalFormat() );
3693 storage.save(); 3707 storage.save();
3694} 3708}
3695 3709
3696bool CalendarView::exportVCalendar( QString filename ) 3710bool CalendarView::exportVCalendar( QString filename )
3697{ 3711{
3698 if (mCalendar->journals().count() > 0) { 3712 if (mCalendar->journals().count() > 0) {
3699 int result = KMessageBox::warningContinueCancel(this, 3713 int result = KMessageBox::warningContinueCancel(this,
3700 i18n("The journal entries can not be\nexported to a vCalendar file."), 3714 i18n("The journal entries can not be\nexported to a vCalendar file."),
3701 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3715 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3702 true); 3716 true);
3703 if (result != KMessageBox::Continue) return false; 3717 if (result != KMessageBox::Continue) return false;
3704 } 3718 }
3705 3719
3706 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3720 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3707 3721
3708 // Force correct extension 3722 // Force correct extension
3709 if (filename.right(4) != ".vcs") filename += ".vcs"; 3723 if (filename.right(4) != ".vcs") filename += ".vcs";
3710 3724
3711 FileStorage storage( mCalendar, filename, new VCalFormat ); 3725 FileStorage storage( mCalendar, filename, new VCalFormat );
3712 return storage.save(); 3726 return storage.save();
3713 3727
3714} 3728}
3715 3729
3716void CalendarView::eventUpdated(Incidence *) 3730void CalendarView::eventUpdated(Incidence *)
3717{ 3731{
3718 setModified(); 3732 setModified();
3719 // Don't call updateView here. The code, which has caused the update of the 3733 // Don't call updateView here. The code, which has caused the update of the
3720 // event is responsible for updating the view. 3734 // event is responsible for updating the view.
3721 // updateView(); 3735 // updateView();
3722} 3736}
3723 3737
3724void CalendarView::adaptNavigationUnits() 3738void CalendarView::adaptNavigationUnits()
3725{ 3739{
3726 if (mViewManager->currentView()->isEventView()) { 3740 if (mViewManager->currentView()->isEventView()) {
3727 int days = mViewManager->currentView()->currentDateCount(); 3741 int days = mViewManager->currentView()->currentDateCount();
3728 if (days == 1) { 3742 if (days == 1) {
3729 emit changeNavStringPrev(i18n("&Previous Day")); 3743 emit changeNavStringPrev(i18n("&Previous Day"));
3730 emit changeNavStringNext(i18n("&Next Day")); 3744 emit changeNavStringNext(i18n("&Next Day"));
3731 } else { 3745 } else {
3732 emit changeNavStringPrev(i18n("&Previous Week")); 3746 emit changeNavStringPrev(i18n("&Previous Week"));
3733 emit changeNavStringNext(i18n("&Next Week")); 3747 emit changeNavStringNext(i18n("&Next Week"));
3734 } 3748 }
3735 } 3749 }
3736} 3750}
3737 3751
3738void CalendarView::processMainViewSelection( Incidence *incidence ) 3752void CalendarView::processMainViewSelection( Incidence *incidence )
3739{ 3753{
3740 if ( incidence ) mTodoList->clearSelection(); 3754 if ( incidence ) mTodoList->clearSelection();
3741 processIncidenceSelection( incidence ); 3755 processIncidenceSelection( incidence );
3742} 3756}
3743 3757
3744void CalendarView::processTodoListSelection( Incidence *incidence ) 3758void CalendarView::processTodoListSelection( Incidence *incidence )
3745{ 3759{
3746 if ( incidence && mViewManager->currentView() ) { 3760 if ( incidence && mViewManager->currentView() ) {
3747 mViewManager->currentView()->clearSelection(); 3761 mViewManager->currentView()->clearSelection();
3748 } 3762 }
3749 processIncidenceSelection( incidence ); 3763 processIncidenceSelection( incidence );
3750} 3764}
3751 3765
3752void CalendarView::processIncidenceSelection( Incidence *incidence ) 3766void CalendarView::processIncidenceSelection( Incidence *incidence )
3753{ 3767{
3754 if ( incidence == mSelectedIncidence ) return; 3768 if ( incidence == mSelectedIncidence ) return;
3755 3769
3756 mSelectedIncidence = incidence; 3770 mSelectedIncidence = incidence;
3757 3771
3758 emit incidenceSelected( mSelectedIncidence ); 3772 emit incidenceSelected( mSelectedIncidence );
3759 3773
3760 if ( incidence && incidence->type() == "Event" ) { 3774 if ( incidence && incidence->type() == "Event" ) {
3761 Event *event = static_cast<Event *>( incidence ); 3775 Event *event = static_cast<Event *>( incidence );
3762 if ( event->organizer() == KOPrefs::instance()->email() ) { 3776 if ( event->organizer() == KOPrefs::instance()->email() ) {
3763 emit organizerEventsSelected( true ); 3777 emit organizerEventsSelected( true );
3764 } else { 3778 } else {
3765 emit organizerEventsSelected(false); 3779 emit organizerEventsSelected(false);
3766 } 3780 }
3767 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3781 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3768 KOPrefs::instance()->email() ) ) { 3782 KOPrefs::instance()->email() ) ) {
3769 emit groupEventsSelected( true ); 3783 emit groupEventsSelected( true );
3770 } else { 3784 } else {
3771 emit groupEventsSelected(false); 3785 emit groupEventsSelected(false);
3772 } 3786 }
3773 return; 3787 return;
3774 } else { 3788 } else {
3775 if ( incidence && incidence->type() == "Todo" ) { 3789 if ( incidence && incidence->type() == "Todo" ) {
3776 emit todoSelected( true ); 3790 emit todoSelected( true );
3777 Todo *event = static_cast<Todo *>( incidence ); 3791 Todo *event = static_cast<Todo *>( incidence );
3778 if ( event->organizer() == KOPrefs::instance()->email() ) { 3792 if ( event->organizer() == KOPrefs::instance()->email() ) {
3779 emit organizerEventsSelected( true ); 3793 emit organizerEventsSelected( true );
3780 } else { 3794 } else {
3781 emit organizerEventsSelected(false); 3795 emit organizerEventsSelected(false);
3782 } 3796 }
3783 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3797 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3784 KOPrefs::instance()->email() ) ) { 3798 KOPrefs::instance()->email() ) ) {
3785 emit groupEventsSelected( true ); 3799 emit groupEventsSelected( true );
3786 } else { 3800 } else {
3787 emit groupEventsSelected(false); 3801 emit groupEventsSelected(false);
3788 } 3802 }
3789 return; 3803 return;
3790 } else { 3804 } else {
3791 emit todoSelected( false ); 3805 emit todoSelected( false );
3792 emit organizerEventsSelected(false); 3806 emit organizerEventsSelected(false);
3793 emit groupEventsSelected(false); 3807 emit groupEventsSelected(false);
3794 } 3808 }
3795 return; 3809 return;
3796 } 3810 }
3797 3811
3798 /* if ( incidence && incidence->type() == "Todo" ) { 3812 /* if ( incidence && incidence->type() == "Todo" ) {
3799 emit todoSelected( true ); 3813 emit todoSelected( true );
3800 } else { 3814 } else {
3801 emit todoSelected( false ); 3815 emit todoSelected( false );
3802 }*/ 3816 }*/
3803} 3817}
3804 3818
3805 3819
3806void CalendarView::checkClipboard() 3820void CalendarView::checkClipboard()
3807{ 3821{
3808#ifndef KORG_NODND 3822#ifndef KORG_NODND
3809 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3823 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3810 emit pasteEnabled(true); 3824 emit pasteEnabled(true);
3811 } else { 3825 } else {
3812 emit pasteEnabled(false); 3826 emit pasteEnabled(false);
3813 } 3827 }
3814#endif 3828#endif
3815} 3829}
3816 3830
3817void CalendarView::showDates(const DateList &selectedDates) 3831void CalendarView::showDates(const DateList &selectedDates)
3818{ 3832{
3819 // kdDebug() << "CalendarView::selectDates()" << endl; 3833 // kdDebug() << "CalendarView::selectDates()" << endl;
3820 3834
3821 3835
3822 if ( !mBlockShowDates ) { 3836 if ( !mBlockShowDates ) {
3823 if ( mViewManager->currentView() ) { 3837 if ( mViewManager->currentView() ) {
3824 updateView( selectedDates.first(), selectedDates.last() ); 3838 updateView( selectedDates.first(), selectedDates.last() );
3825 } else { 3839 } else {
3826 mViewManager->showAgendaView(); 3840 mViewManager->showAgendaView();
3827 } 3841 }
3828 } 3842 }
3829 3843
3830 QDate date = selectedDates.first(); 3844 QDate date = selectedDates.first();
3831 if ( ! date.isValid() ) { 3845 if ( ! date.isValid() ) {
3832 topLevelWidget()->setCaption(""); 3846 topLevelWidget()->setCaption("");
3833 return; 3847 return;
3834 } 3848 }
3835 3849
3836 QString selDates; 3850 QString selDates;
3837 selDates = KGlobal::locale()->formatDate( date, true); 3851 selDates = KGlobal::locale()->formatDate( date, true);
3838 if (selectedDates.first() < selectedDates.last() ) 3852 if (selectedDates.first() < selectedDates.last() )
3839 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3853 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3840 else { 3854 else {
3841 QString addString; 3855 QString addString;
3842 if ( date == QDateTime::currentDateTime().date() ) 3856 if ( date == QDateTime::currentDateTime().date() )
3843 addString = i18n("Today"); 3857 addString = i18n("Today");
3844 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3858 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3845 addString = i18n("Tomorrow"); 3859 addString = i18n("Tomorrow");
3846 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3860 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3847 addString = i18n("Yesterday"); 3861 addString = i18n("Yesterday");
3848 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3862 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3849 addString = i18n("Day before yesterday"); 3863 addString = i18n("Day before yesterday");
3850 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3864 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3851 addString = i18n("Day after tomorrow"); 3865 addString = i18n("Day after tomorrow");
3852 if ( !addString.isEmpty() ) { 3866 if ( !addString.isEmpty() ) {
3853 topLevelWidget()->setCaption( addString+", " + selDates ); 3867 topLevelWidget()->setCaption( addString+", " + selDates );
3854 return; 3868 return;
3855 } 3869 }
3856 } 3870 }
3857 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3871 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3858 3872
3859} 3873}
3860 3874
3861QPtrList<CalFilter> CalendarView::filters() 3875QPtrList<CalFilter> CalendarView::filters()
3862{ 3876{
3863 return mFilters; 3877 return mFilters;
3864 3878
3865} 3879}
3866void CalendarView::editFilters() 3880void CalendarView::editFilters()
3867{ 3881{
3868 // kdDebug() << "CalendarView::editFilters()" << endl; 3882 // kdDebug() << "CalendarView::editFilters()" << endl;
3869 3883
3870 CalFilter *filter = mFilters.first(); 3884 CalFilter *filter = mFilters.first();
3871 while(filter) { 3885 while(filter) {
3872 kdDebug() << " Filter: " << filter->name() << endl; 3886 kdDebug() << " Filter: " << filter->name() << endl;
3873 filter = mFilters.next(); 3887 filter = mFilters.next();
3874 } 3888 }
3875 3889
3876 mDialogManager->showFilterEditDialog(&mFilters); 3890 mDialogManager->showFilterEditDialog(&mFilters);
3877} 3891}
3878void CalendarView::toggleFilter() 3892void CalendarView::toggleFilter()
3879{ 3893{
3880 showFilter(! mFilterView->isVisible()); 3894 showFilter(! mFilterView->isVisible());
3881} 3895}
3882 3896
3883KOFilterView *CalendarView::filterView() 3897KOFilterView *CalendarView::filterView()
3884{ 3898{
3885 return mFilterView; 3899 return mFilterView;
3886} 3900}
3887void CalendarView::selectFilter( int fil ) 3901void CalendarView::selectFilter( int fil )
3888{ 3902{
3889 mFilterView->setSelectedFilter( fil ); 3903 mFilterView->setSelectedFilter( fil );
3890} 3904}
3891void CalendarView::showFilter(bool visible) 3905void CalendarView::showFilter(bool visible)
3892{ 3906{
3893 if (visible) mFilterView->show(); 3907 if (visible) mFilterView->show();
3894 else mFilterView->hide(); 3908 else mFilterView->hide();
3895} 3909}
3896void CalendarView::toggleFilerEnabled( ) 3910void CalendarView::toggleFilerEnabled( )
3897{ 3911{
3898 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3912 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3899 if ( !mFilterView->filtersEnabled() ) 3913 if ( !mFilterView->filtersEnabled() )
3900 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3914 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3901 3915
3902} 3916}
3903void CalendarView::updateFilter() 3917void CalendarView::updateFilter()
3904{ 3918{
3905 CalFilter *filter = mFilterView->selectedFilter(); 3919 CalFilter *filter = mFilterView->selectedFilter();
3906 if (filter) { 3920 if (filter) {
3907 QString mess; 3921 QString mess;
3908 if (mFilterView->filtersEnabled()) { 3922 if (mFilterView->filtersEnabled()) {
3909 mess = i18n("Filter selected: ")+filter->name(); 3923 mess = i18n("Filter selected: ")+filter->name();
3910 filter->setEnabled(true); 3924 filter->setEnabled(true);
3911 } 3925 }
3912 else filter->setEnabled(false); 3926 else filter->setEnabled(false);
3913 mCalendar->setFilter(filter); 3927 mCalendar->setFilter(filter);
3914 updateView(); 3928 updateView();
3915 if ( !mess.isEmpty() ) 3929 if ( !mess.isEmpty() )
3916 topLevelWidget()->setCaption( mess ); 3930 topLevelWidget()->setCaption( mess );
3917 3931
3918 } 3932 }
3919} 3933}
3920 3934
3921void CalendarView::filterEdited() 3935void CalendarView::filterEdited()
3922{ 3936{
3923 mFilterView->updateFilters(); 3937 mFilterView->updateFilters();
3924 updateFilter(); 3938 updateFilter();
3925 writeSettings(); 3939 writeSettings();
3926} 3940}
3927 3941
3928 3942
3929void CalendarView::takeOverEvent() 3943void CalendarView::takeOverEvent()
3930{ 3944{
3931 Incidence *incidence = currentSelection(); 3945 Incidence *incidence = currentSelection();
3932 3946
3933 if (!incidence) return; 3947 if (!incidence) return;
3934 3948
3935 incidence->setOrganizer(KOPrefs::instance()->email()); 3949 incidence->setOrganizer(KOPrefs::instance()->email());
3936 incidence->recreate(); 3950 incidence->recreate();
3937 incidence->setReadOnly(false); 3951 incidence->setReadOnly(false);
3938 3952
3939 updateView(); 3953 updateView();
3940} 3954}
3941 3955
3942void CalendarView::takeOverCalendar() 3956void CalendarView::takeOverCalendar()
3943{ 3957{
3944 // TODO: Create Calendar::allIncidences() function and use it here 3958 // TODO: Create Calendar::allIncidences() function and use it here
3945 3959
3960 clearAllViews();
3946 QPtrList<Event> events = mCalendar->events(); 3961 QPtrList<Event> events = mCalendar->events();
3947 for(uint i=0; i<events.count(); ++i) { 3962 for(uint i=0; i<events.count(); ++i) {
3948 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3963 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3949 events.at(i)->recreate(); 3964 events.at(i)->recreate();
3950 events.at(i)->setReadOnly(false); 3965 events.at(i)->setReadOnly(false);
3951 } 3966 }
3952 3967
3953 QPtrList<Todo> todos = mCalendar->todos(); 3968 QPtrList<Todo> todos = mCalendar->todos();
3954 for(uint i=0; i<todos.count(); ++i) { 3969 for(uint i=0; i<todos.count(); ++i) {
3955 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3970 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3956 todos.at(i)->recreate(); 3971 todos.at(i)->recreate();
3957 todos.at(i)->setReadOnly(false); 3972 todos.at(i)->setReadOnly(false);
3958 } 3973 }
3959 3974
3960 QPtrList<Journal> journals = mCalendar->journals(); 3975 QPtrList<Journal> journals = mCalendar->journals();
3961 for(uint i=0; i<journals.count(); ++i) { 3976 for(uint i=0; i<journals.count(); ++i) {
3962 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3977 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3963 journals.at(i)->recreate(); 3978 journals.at(i)->recreate();
3964 journals.at(i)->setReadOnly(false); 3979 journals.at(i)->setReadOnly(false);
3965 } 3980 }
3966 3981
3967 updateView(); 3982 updateView();
3968} 3983}
3969 3984
3970void CalendarView::showIntro() 3985void CalendarView::showIntro()
3971{ 3986{
3972 kdDebug() << "To be implemented." << endl; 3987 kdDebug() << "To be implemented." << endl;
3973} 3988}
3974 3989
3975QWidgetStack *CalendarView::viewStack() 3990QWidgetStack *CalendarView::viewStack()
3976{ 3991{
3977 return mRightFrame; 3992 return mRightFrame;
3978} 3993}
3979 3994
3980QWidget *CalendarView::leftFrame() 3995QWidget *CalendarView::leftFrame()
3981{ 3996{
3982 return ( QWidget *)mLeftFrame; 3997 return ( QWidget *)mLeftFrame;
3983} 3998}
3984 3999
3985DateNavigator *CalendarView::dateNavigator() 4000DateNavigator *CalendarView::dateNavigator()
3986{ 4001{
3987 return mNavigator; 4002 return mNavigator;
3988} 4003}
3989 4004
3990KDateNavigator* CalendarView::dateNavigatorWidget() 4005KDateNavigator* CalendarView::dateNavigatorWidget()
3991{ 4006{
3992 return mDateNavigator->navigatorView(); 4007 return mDateNavigator->navigatorView();
3993} 4008}
3994void CalendarView::toggleDateNavigatorWidget() 4009void CalendarView::toggleDateNavigatorWidget()
3995{ 4010{
3996 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4011 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3997 4012
3998 if (!KOPrefs::instance()->mShowDateNavigator ) 4013 if (!KOPrefs::instance()->mShowDateNavigator )
3999 mDateNavigator->hide(); 4014 mDateNavigator->hide();
4000 else 4015 else
4001 mDateNavigator->show(); 4016 mDateNavigator->show();
4002} 4017}
4003void CalendarView::addView(KOrg::BaseView *view) 4018void CalendarView::addView(KOrg::BaseView *view)
4004{ 4019{
4005 mViewManager->addView(view); 4020 mViewManager->addView(view);
4006} 4021}
4007 4022
4008void CalendarView::showView(KOrg::BaseView *view) 4023void CalendarView::showView(KOrg::BaseView *view)
4009{ 4024{
4010 mViewManager->showView(view, mLeftFrame->isVisible()); 4025 mViewManager->showView(view, mLeftFrame->isVisible());
4011} 4026}
4012 4027
4013Incidence *CalendarView::currentSelection() 4028Incidence *CalendarView::currentSelection()
4014{ 4029{
4015 return mViewManager->currentSelection(); 4030 return mViewManager->currentSelection();
4016} 4031}
4017void CalendarView::toggleAllDaySize() 4032void CalendarView::toggleAllDaySize()
4018{ 4033{
4019 /* 4034 /*
4020 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4035 if ( KOPrefs::instance()->mAllDaySize > 47 )
4021 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4036 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4022 else 4037 else
4023 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4038 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4024 */ 4039 */
4025 viewManager()->agendaView()->toggleAllDay(); 4040 viewManager()->agendaView()->toggleAllDay();
4026} 4041}
4027void CalendarView::toggleExpand() 4042void CalendarView::toggleExpand()
4028{ 4043{
4029 // if ( mLeftFrame->isHidden() ) { 4044 // if ( mLeftFrame->isHidden() ) {
4030 // mLeftFrame->show(); 4045 // mLeftFrame->show();
4031 // emit calendarViewExpanded( false ); 4046 // emit calendarViewExpanded( false );
4032 // } else { 4047 // } else {
4033 // mLeftFrame->hide(); 4048 // mLeftFrame->hide();
4034 // emit calendarViewExpanded( true ); 4049 // emit calendarViewExpanded( true );
4035 // } 4050 // }
4036 //qDebug(" CalendarView::toggleExpand()"); 4051 //qDebug(" CalendarView::toggleExpand()");
4037 globalFlagBlockAgenda = 1; 4052 globalFlagBlockAgenda = 1;
4038 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4053 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4039 globalFlagBlockAgenda = 5; 4054 globalFlagBlockAgenda = 5;
4040 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4055 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4041 //mViewManager->showView( 0, true ); 4056 //mViewManager->showView( 0, true );
4042} 4057}
4043 4058
4044void CalendarView::calendarModified( bool modified, Calendar * ) 4059void CalendarView::calendarModified( bool modified, Calendar * )
4045{ 4060{
4046 setModified( modified ); 4061 setModified( modified );
4047} 4062}
4048 4063
4049Todo *CalendarView::selectedTodo() 4064Todo *CalendarView::selectedTodo()
4050{ 4065{
4051 Incidence *incidence = currentSelection(); 4066 Incidence *incidence = currentSelection();
4052 if ( incidence && incidence->type() == "Todo" ) { 4067 if ( incidence && incidence->type() == "Todo" ) {
4053 return static_cast<Todo *>( incidence ); 4068 return static_cast<Todo *>( incidence );
4054 } 4069 }
4055 4070
4056 incidence = mTodoList->selectedIncidences().first(); 4071 incidence = mTodoList->selectedIncidences().first();
4057 if ( incidence && incidence->type() == "Todo" ) { 4072 if ( incidence && incidence->type() == "Todo" ) {
4058 return static_cast<Todo *>( incidence ); 4073 return static_cast<Todo *>( incidence );
4059 } 4074 }
4060 4075
4061 return 0; 4076 return 0;
4062} 4077}
4063 4078
4064void CalendarView::dialogClosing(Incidence *in) 4079void CalendarView::dialogClosing(Incidence *in)
4065{ 4080{
4066 // mDialogList.remove(in); 4081 // mDialogList.remove(in);
4067} 4082}
4068 4083
4069void CalendarView::showIncidence() 4084void CalendarView::showIncidence()
4070{ 4085{
4071 mViewerCallerIsSearchDialog = false; 4086 mViewerCallerIsSearchDialog = false;
4072 Incidence *incidence = currentSelection(); 4087 Incidence *incidence = currentSelection();
4073 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4088 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4074 if ( incidence ) { 4089 if ( incidence ) {
4075 ShowIncidenceVisitor v; 4090 ShowIncidenceVisitor v;
4076 v.act( incidence, this ); 4091 v.act( incidence, this );
4077 } 4092 }
4078} 4093}
4079void CalendarView::editIncidenceDescription() 4094void CalendarView::editIncidenceDescription()
4080{ 4095{
4081 mFlagEditDescription = true; 4096 mFlagEditDescription = true;
4082 editIncidence(); 4097 editIncidence();
4083 mFlagEditDescription = false; 4098 mFlagEditDescription = false;
4084} 4099}
4085void CalendarView::editIncidence() 4100void CalendarView::editIncidence()
4086{ 4101{
4087 // qDebug("editIncidence() "); 4102 // qDebug("editIncidence() ");
4088 Incidence *incidence = currentSelection(); 4103 Incidence *incidence = currentSelection();
4089 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4104 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4090 if ( incidence ) { 4105 if ( incidence ) {
4091 EditIncidenceVisitor v; 4106 EditIncidenceVisitor v;
4092 v.act( incidence, this ); 4107 v.act( incidence, this );
4093 } 4108 }
4094} 4109}
4095 4110
4096void CalendarView::deleteIncidence() 4111void CalendarView::deleteIncidence()
4097{ 4112{
4098 Incidence *incidence = currentSelection(); 4113 Incidence *incidence = currentSelection();
4099 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4114 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4100 if ( incidence ) { 4115 if ( incidence ) {
4101 deleteIncidence(incidence); 4116 deleteIncidence(incidence);
4102 } 4117 }
4103} 4118}
4104void CalendarView::showIncidence(QString uid) 4119void CalendarView::showIncidence(QString uid)
4105{ 4120{
4106 Incidence *inc = mCalendar->incidence( uid ); 4121 Incidence *inc = mCalendar->incidence( uid );
4107 if ( inc ) 4122 if ( inc )
4108 showIncidence( inc ); 4123 showIncidence( inc );
4109} 4124}
4110void CalendarView::showIncidence(Incidence *incidence) 4125void CalendarView::showIncidence(Incidence *incidence)
4111{ 4126{
4112 mViewerCallerIsSearchDialog = false; 4127 mViewerCallerIsSearchDialog = false;
4113 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4128 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4114 if ( sender() && mDialogManager->getSearchDialog() ) { 4129 if ( sender() && mDialogManager->getSearchDialog() ) {
4115 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4130 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4116 mViewerCallerIsSearchDialog = true; 4131 mViewerCallerIsSearchDialog = true;
4117 } 4132 }
4118 } 4133 }
4119 if ( incidence ) { 4134 if ( incidence ) {
4120 ShowIncidenceVisitor v; 4135 ShowIncidenceVisitor v;
4121 v.act( incidence, this ); 4136 v.act( incidence, this );
4122 } 4137 }
4123} 4138}
4124 4139
4125void CalendarView::editIncidence(Incidence *incidence) 4140void CalendarView::editIncidence(Incidence *incidence)
4126{ 4141{
4127 if ( incidence ) { 4142 if ( incidence ) {
4128 4143
4129 EditIncidenceVisitor v; 4144 EditIncidenceVisitor v;
4130 v.act( incidence, this ); 4145 v.act( incidence, this );
4131 4146
4132 } 4147 }
4133} 4148}
4134 4149
4135void CalendarView::deleteIncidence(Incidence *incidence) 4150void CalendarView::deleteIncidence(Incidence *incidence)
4136{ 4151{
4137 //qDebug(" CalendarView::deleteIncidence "); 4152 //qDebug(" CalendarView::deleteIncidence ");
4138 if ( incidence ) { 4153 if ( incidence ) {
4139 DeleteIncidenceVisitor v; 4154 DeleteIncidenceVisitor v;
4140 v.act( incidence, this ); 4155 v.act( incidence, this );
4141 } 4156 }
4142} 4157}
4143 4158
4144 4159
4145void CalendarView::lookForOutgoingMessages() 4160void CalendarView::lookForOutgoingMessages()
4146{ 4161{
4147 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4162 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4148 ogd->loadMessages(); 4163 ogd->loadMessages();
4149} 4164}
4150 4165
4151void CalendarView::lookForIncomingMessages() 4166void CalendarView::lookForIncomingMessages()
4152{ 4167{
4153 IncomingDialog *icd = mDialogManager->incomingDialog(); 4168 IncomingDialog *icd = mDialogManager->incomingDialog();
4154 icd->retrieve(); 4169 icd->retrieve();
4155} 4170}
4156 4171
4157bool CalendarView::removeCompletedSubTodos( Todo* t ) 4172bool CalendarView::removeCompletedSubTodos( Todo* t )
4158{ 4173{
4159 bool deleteTodo = true; 4174 bool deleteTodo = true;
4160 QPtrList<Incidence> subTodos; 4175 QPtrList<Incidence> subTodos;
4161 Incidence *aTodo; 4176 Incidence *aTodo;
4162 subTodos = t->relations(); 4177 subTodos = t->relations();
4163 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4178 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4164 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4179 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4165 deleteTodo = false; 4180 deleteTodo = false;
4166 } 4181 }
4167 if ( deleteTodo ) { 4182 if ( deleteTodo ) {
4168 if ( t->isCompleted() && !t->doesRecur()) { 4183 if ( t->isCompleted() && !t->doesRecur()) {
4169 checkExternalId( t ); 4184 checkExternalId( t );
4170 mCalendar->deleteTodo( t ); 4185 mCalendar->deleteTodo( t );
4171 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4186 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4172 } 4187 }
4173 else 4188 else
4174 deleteTodo = false; 4189 deleteTodo = false;
4175 } 4190 }
4176 return deleteTodo; 4191 return deleteTodo;
4177 4192
4178} 4193}
4179void CalendarView::purgeCompleted() 4194void CalendarView::purgeCompleted()
4180{ 4195{
4181 int result = KMessageBox::warningContinueCancel(this, 4196 int result = KMessageBox::warningContinueCancel(this,
4182 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 4197 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
4183 4198
4184 if (result == KMessageBox::Continue) { 4199 if (result == KMessageBox::Continue) {
4185 4200
4186 QPtrList<Todo> todoCal; 4201 QPtrList<Todo> todoCal;
4187 QPtrList<Todo> rootTodos; 4202 QPtrList<Todo> rootTodos;
4188 //QPtrList<Incidence> rel; 4203 //QPtrList<Incidence> rel;
4189 Todo *aTodo;//, *rTodo; 4204 Todo *aTodo;//, *rTodo;
4190 Incidence *rIncidence; 4205 Incidence *rIncidence;
4191 bool childDelete = false; 4206 bool childDelete = false;
4192 bool deletedOne = true; 4207 bool deletedOne = true;
4193 todoCal = calendar()->todos(); 4208 todoCal = calendar()->todos();
4194 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 4209 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
4195 if ( !aTodo->relatedTo() ) 4210 if ( !aTodo->relatedTo() )
4196 rootTodos.append( aTodo ); 4211 rootTodos.append( aTodo );
4197 } 4212 }
4198 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4213 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4199 removeCompletedSubTodos( aTodo ); 4214 removeCompletedSubTodos( aTodo );
4200 } 4215 }
4201 4216
4202 updateView(); 4217 updateView();
4203 } 4218 }
4204} 4219}
4205 4220
4206void CalendarView::slotCalendarChanged() 4221void CalendarView::slotCalendarChanged()
4207{ 4222{
4208 ; 4223 ;
4209} 4224}
4210 4225
4211void CalendarView::keyPressEvent ( QKeyEvent *e) 4226void CalendarView::keyPressEvent ( QKeyEvent *e)
4212{ 4227{
4213 //qDebug(" alendarView::keyPressEvent "); 4228 //qDebug(" alendarView::keyPressEvent ");
4214 e->ignore(); 4229 e->ignore();
4215} 4230}
4216 4231
4217 4232
4218bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4233bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4219{ 4234{
4220 // mSyncManager = manager; 4235 // mSyncManager = manager;
4221 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4236 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4222 qDebug("KO: SyncKDE request detected!"); 4237 qDebug("KO: SyncKDE request detected!");
4223 } 4238 }
4224 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4239 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4225 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4240 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4226 return syncCalendar( filename, mode ); 4241 return syncCalendar( filename, mode );
4227} 4242}
4228bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4243bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4229{ 4244{
4230 //mSyncManager = manager; 4245 //mSyncManager = manager;
4231 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4246 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4232 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4247 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4233 if ( resource == "sharp" ) 4248 if ( resource == "sharp" )
4234 syncExternal( 0 ); 4249 syncExternal( 0 );
4235 if ( resource == "phone" ) 4250 if ( resource == "phone" )
4236 syncExternal( 1 ); 4251 syncExternal( 1 );
4237 // pending setmodified 4252 // pending setmodified
4238 return true; 4253 return true;
4239} 4254}
4240void CalendarView::setSyncManager(KSyncManager* manager) 4255void CalendarView::setSyncManager(KSyncManager* manager)
4241{ 4256{
4242 mSyncManager = manager; 4257 mSyncManager = manager;
4243} 4258}
4244 4259
4245void CalendarView::removeSyncInfo( QString syncProfile) 4260void CalendarView::removeSyncInfo( QString syncProfile)
4246{ 4261{
4247 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4262 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4248 mCalendar->removeSyncInfo( syncProfile ); 4263 mCalendar->removeSyncInfo( syncProfile );
4249 4264
4250} 4265}
4251 4266
4252void CalendarView::undo_delete() 4267void CalendarView::undo_delete()
4253{ 4268{
4254 //qDebug("undo_delete() "); 4269 //qDebug("undo_delete() ");
4255 Incidence* undo = mCalendar->undoIncidence(); 4270 Incidence* undo = mCalendar->undoIncidence();
4256 if ( !undo ) { 4271 if ( !undo ) {
4257 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4272 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4258 i18n("KO/Pi")); 4273 i18n("KO/Pi"));
4259 return; 4274 return;
4260 } 4275 }
4261 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4276 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4262 i18n("\nAre you sure you want\nto restore this?"), 4277 i18n("\nAre you sure you want\nto restore this?"),
4263 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4278 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4264 mCalendar->undoDeleteIncidence(); 4279 mCalendar->undoDeleteIncidence();
4265 updateView(); 4280 updateView();
4266 } 4281 }
4267} 4282}
4268 4283
4269void CalendarView::slotViewerClosed() 4284void CalendarView::slotViewerClosed()
4270{ 4285{
4271 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4286 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4272} 4287}
4273 4288
4274void CalendarView::resetFocus() 4289void CalendarView::resetFocus()
4275{ 4290{
4276 if ( mViewerCallerIsSearchDialog ) { 4291 if ( mViewerCallerIsSearchDialog ) {
4277 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4292 if ( mDialogManager->getSearchDialog()->isVisible() ){
4278 mDialogManager->getSearchDialog()->raise(); 4293 mDialogManager->getSearchDialog()->raise();
4279 mDialogManager->getSearchDialog()->setActiveWindow(); 4294 mDialogManager->getSearchDialog()->setActiveWindow();
4280 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4295 mDialogManager->getSearchDialog()->listview()->resetFocus();
4281 } else 4296 } else
4282 mViewerCallerIsSearchDialog = false; 4297 mViewerCallerIsSearchDialog = false;
4283 } 4298 }
4284 if ( !mViewerCallerIsSearchDialog ) { 4299 if ( !mViewerCallerIsSearchDialog ) {
4285 //mViewManager->currentView()->setFocus(); 4300 //mViewManager->currentView()->setFocus();
4286 //qDebug("sssssssssssssssset focus "); 4301 //qDebug("sssssssssssssssset focus ");
4287 topLevelWidget()->raise(); 4302 topLevelWidget()->raise();
4288 setActiveWindow(); 4303 setActiveWindow();
4289 //setFocus(); 4304 //setFocus();
4290 } 4305 }
4291 mViewerCallerIsSearchDialog = false; 4306 mViewerCallerIsSearchDialog = false;
4292} 4307}
4293 4308
4294void CalendarView::showNextAlarms() 4309void CalendarView::showNextAlarms()
4295{ 4310{
4296 QString message; 4311 QString message;
4297 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4312 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4298 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4313 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4299 QString sum = mCalendar->nextSummary(); 4314 QString sum = mCalendar->nextSummary();
4300 QDateTime nextA = mNextAlarmDateTime; 4315 QDateTime nextA = mNextAlarmDateTime;
4301 QDateTime cur = QDateTime::currentDateTime(); 4316 QDateTime cur = QDateTime::currentDateTime();
4302 int secs = cur.secsTo( nextA ); 4317 int secs = cur.secsTo( nextA );
4303 int min = secs /60; 4318 int min = secs /60;
4304 int hours = min /60; 4319 int hours = min /60;
4305 min = min % 60; 4320 min = min % 60;
4306 int days = hours /24; 4321 int days = hours /24;
4307 hours = hours % 24; 4322 hours = hours % 24;
4308 4323
4309 //message = i18n("The next alarm is in:\n"); 4324 //message = i18n("The next alarm is in:\n");
4310 if ( days > 1 ) 4325 if ( days > 1 )
4311 message += i18n("%1 days\n").arg( days ); 4326 message += i18n("%1 days\n").arg( days );
4312 else if ( days == 1 ) 4327 else if ( days == 1 )
4313 message += i18n("1 day\n"); 4328 message += i18n("1 day\n");
4314 if ( hours > 1 ) 4329 if ( hours > 1 )
4315 message += i18n("%1 hours\n").arg( hours ); 4330 message += i18n("%1 hours\n").arg( hours );
4316 else if ( hours == 1 ) 4331 else if ( hours == 1 )
4317 message += i18n("1 hour\n"); 4332 message += i18n("1 hour\n");
4318 if ( min > 1 ) 4333 if ( min > 1 )
4319 message += i18n("%1 minutes\n").arg( min ); 4334 message += i18n("%1 minutes\n").arg( min );
4320 else if ( min == 1 ) 4335 else if ( min == 1 )
4321 message += i18n("1 minute\n"); 4336 message += i18n("1 minute\n");
4322 if ( message.isEmpty() ) 4337 if ( message.isEmpty() )
4323 message = i18n("The next alarm is in\nless than one minute!"); 4338 message = i18n("The next alarm is in\nless than one minute!");
4324 else 4339 else
4325 message = i18n("The next alarm is in:\n") + message; 4340 message = i18n("The next alarm is in:\n") + message;
4326 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4341 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4327 } else { 4342 } else {
4328 message = i18n("There is no next alarm."); 4343 message = i18n("There is no next alarm.");
4329 4344
4330 } 4345 }
4331#ifdef DESKTOP_VERSION 4346#ifdef DESKTOP_VERSION
4332 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 4347 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4333 message += i18n("\nThe internal alarm notification is disabled!\n"); 4348 message += i18n("\nThe internal alarm notification is disabled!\n");
4334 message += i18n("Enable it in the settings menu, TAB alarm."); 4349 message += i18n("Enable it in the settings menu, TAB alarm.");
4335 } 4350 }
4336 4351
4337#endif 4352#endif
4338 KMessageBox::information( this, message); 4353 KMessageBox::information( this, message);
4339} 4354}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 084b6db..4600090 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,641 +1,642 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42#include <KDGanttMinimizeSplitter.h> 42#include <KDGanttMinimizeSplitter.h>
43 43
44#include <korganizer/calendarviewbase.h> 44#include <korganizer/calendarviewbase.h>
45 45
46#include <ksyncmanager.h> 46#include <ksyncmanager.h>
47 47
48class QWidgetStack; 48class QWidgetStack;
49class QSplitter; 49class QSplitter;
50 50
51class CalPrinter; 51class CalPrinter;
52class KOFilterView; 52class KOFilterView;
53class KOViewManager; 53class KOViewManager;
54class KODialogManager; 54class KODialogManager;
55class KOTodoView; 55class KOTodoView;
56class KDateNavigator; 56class KDateNavigator;
57class DateNavigatorContainer; 57class DateNavigatorContainer;
58class DateNavigator; 58class DateNavigator;
59class KOIncidenceEditor; 59class KOIncidenceEditor;
60class KDatePicker; 60class KDatePicker;
61class ResourceView; 61class ResourceView;
62class KOEventEditor; 62class KOEventEditor;
63class KOTodoEditor ; 63class KOTodoEditor ;
64class KOEventViewerDialog; 64class KOEventViewerDialog;
65class KOBeamPrefs; 65class KOBeamPrefs;
66class KSyncProfile; 66class KSyncProfile;
67class AlarmDialog; 67class AlarmDialog;
68class KCal::Attendee; 68class KCal::Attendee;
69 69
70namespace KCal { class FileStorage; } 70namespace KCal { class FileStorage; }
71 71
72using namespace KCal; 72using namespace KCal;
73 73
74/** 74/**
75 This is the main calendar widget. It provides the different vies on t he 75 This is the main calendar widget. It provides the different vies on t he
76 calendar data as well as the date navigator. It also handles synchronisation 76 calendar data as well as the date navigator. It also handles synchronisation
77 of the different views and controls the different dialogs like preferences, 77 of the different views and controls the different dialogs like preferences,
78 event editor, search dialog etc. 78 event editor, search dialog etc.
79 79
80 @short main calendar view widget 80 @short main calendar view widget
81 @author Cornelius Schumacher 81 @author Cornelius Schumacher
82*/ 82*/
83 83
84#include <qtextbrowser.h> 84#include <qtextbrowser.h>
85#include <qtextcodec.h> 85#include <qtextcodec.h>
86 86
87class MissedAlarmTextBrowser : public QTextBrowser { 87class MissedAlarmTextBrowser : public QTextBrowser {
88 Q_OBJECT 88 Q_OBJECT
89 public: 89 public:
90 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start); 90 MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms ,QDateTime start);
91 ~MissedAlarmTextBrowser(); 91 ~MissedAlarmTextBrowser();
92 void setSource(const QString & n); 92 void setSource(const QString & n);
93 93
94 private: 94 private:
95 Incidence * getNextInc(QDateTime start ); 95 Incidence * getNextInc(QDateTime start );
96 QPtrList<Incidence> mAlarms; 96 QPtrList<Incidence> mAlarms;
97 signals: 97 signals:
98 void showIncidence( QString uid); 98 void showIncidence( QString uid);
99}; 99};
100 100
101 101
102class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 102class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
103{ 103{
104 Q_OBJECT 104 Q_OBJECT
105 public: 105 public:
106 /** 106 /**
107 Constructs a new calendar view widget. 107 Constructs a new calendar view widget.
108 108
109 @param calendar calendar document 109 @param calendar calendar document
110 @param parent parent window 110 @param parent parent window
111 @param name Qt internal widget object name 111 @param name Qt internal widget object name
112 */ 112 */
113 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 113 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
114 const char *name = 0 ); 114 const char *name = 0 );
115 CalendarView( Calendar *calendar, QWidget *parent = 0, 115 CalendarView( Calendar *calendar, QWidget *parent = 0,
116 const char *name = 0 ); 116 const char *name = 0 );
117 virtual ~CalendarView(); 117 virtual ~CalendarView();
118 118
119 Calendar *calendar() { return mCalendar; } 119 Calendar *calendar() { return mCalendar; }
120 120
121 KOViewManager *viewManager(); 121 KOViewManager *viewManager();
122 KODialogManager *dialogManager(); 122 KODialogManager *dialogManager();
123 123
124 QDate startDate(); 124 QDate startDate();
125 QDate endDate(); 125 QDate endDate();
126 126
127 QWidgetStack *viewStack(); 127 QWidgetStack *viewStack();
128 QWidget *leftFrame(); 128 QWidget *leftFrame();
129 129
130 DateNavigator *dateNavigator(); 130 DateNavigator *dateNavigator();
131 KDateNavigator *dateNavigatorWidget(); 131 KDateNavigator *dateNavigatorWidget();
132 132
133 void addView(KOrg::BaseView *); 133 void addView(KOrg::BaseView *);
134 void showView(KOrg::BaseView *); 134 void showView(KOrg::BaseView *);
135 KOEventViewerDialog* getEventViewerDialog(); 135 KOEventViewerDialog* getEventViewerDialog();
136 Incidence *currentSelection(); 136 Incidence *currentSelection();
137 137
138 signals: 138 signals:
139 void save (); 139 void save ();
140 void saveStopTimer (); 140 void saveStopTimer ();
141 void tempDisableBR(bool); 141 void tempDisableBR(bool);
142 /** This todo has been modified */ 142 /** This todo has been modified */
143 void todoModified(Todo *, int); 143 void todoModified(Todo *, int);
144 144
145 /** when change is made to options dialog, the topwidget will catch this 145 /** when change is made to options dialog, the topwidget will catch this
146 * and emit this signal which notifies all widgets which have registered 146 * and emit this signal which notifies all widgets which have registered
147 * for notification to update their settings. */ 147 * for notification to update their settings. */
148 void configChanged(); 148 void configChanged();
149 /** emitted when the topwidget is closing down, so that any attached 149 /** emitted when the topwidget is closing down, so that any attached
150 child windows can also close. */ 150 child windows can also close. */
151 void closingDown(); 151 void closingDown();
152 /** emitted right before we die */ 152 /** emitted right before we die */
153 void closed(QWidget *); 153 void closed(QWidget *);
154 154
155 /** Emitted when state of modified flag changes */ 155 /** Emitted when state of modified flag changes */
156 void modifiedChanged(bool); 156 void modifiedChanged(bool);
157 void signalmodified(); 157 void signalmodified();
158 158
159 /** Emitted when state of read-only flag changes */ 159 /** Emitted when state of read-only flag changes */
160 void readOnlyChanged(bool); 160 void readOnlyChanged(bool);
161 161
162 /** Emitted when the unit of navigation changes */ 162 /** Emitted when the unit of navigation changes */
163 void changeNavStringPrev(const QString &); 163 void changeNavStringPrev(const QString &);
164 void changeNavStringNext(const QString &); 164 void changeNavStringNext(const QString &);
165 165
166 /** Emitted when state of events selection has changed and user is organizer*/ 166 /** Emitted when state of events selection has changed and user is organizer*/
167 void organizerEventsSelected(bool); 167 void organizerEventsSelected(bool);
168 /** Emitted when state of events selection has changed and user is attendee*/ 168 /** Emitted when state of events selection has changed and user is attendee*/
169 void groupEventsSelected(bool); 169 void groupEventsSelected(bool);
170 /** 170 /**
171 Emitted when an incidence gets selected. If the selection is cleared the 171 Emitted when an incidence gets selected. If the selection is cleared the
172 signal is emitted with 0 as argument. 172 signal is emitted with 0 as argument.
173 */ 173 */
174 void incidenceSelected( Incidence * ); 174 void incidenceSelected( Incidence * );
175 /** Emitted, when a todoitem is selected or deselected. */ 175 /** Emitted, when a todoitem is selected or deselected. */
176 void todoSelected( bool ); 176 void todoSelected( bool );
177 177
178 /** 178 /**
179 Emitted, when clipboard content changes. Parameter indicates if paste 179 Emitted, when clipboard content changes. Parameter indicates if paste
180 is possible or not. 180 is possible or not.
181 */ 181 */
182 void pasteEnabled(bool); 182 void pasteEnabled(bool);
183 183
184 /** Emitted, when the number of incoming messages has changed. */ 184 /** Emitted, when the number of incoming messages has changed. */
185 void numIncomingChanged(int); 185 void numIncomingChanged(int);
186 186
187 /** Emitted, when the number of outgoing messages has changed. */ 187 /** Emitted, when the number of outgoing messages has changed. */
188 void numOutgoingChanged(int); 188 void numOutgoingChanged(int);
189 189
190 /** Send status message, which can e.g. be displayed in the status bar. */ 190 /** Send status message, which can e.g. be displayed in the status bar. */
191 void statusMessage(const QString &); 191 void statusMessage(const QString &);
192 192
193 void calendarViewExpanded( bool ); 193 void calendarViewExpanded( bool );
194 void updateSearchDialog(); 194 void updateSearchDialog();
195 195
196 196
197 public slots: 197 public slots:
198 void checkAlarms(); 198 void checkAlarms();
199 void slotprintSelInc(); 199 void slotprintSelInc();
200 void showNextAlarms(); 200 void showNextAlarms();
201 void showOpenError(); 201 void showOpenError();
202 void watchSavedFile(); 202 void watchSavedFile();
203 void recheckTimerAlarm(); 203 void recheckTimerAlarm();
204 void checkNextTimerAlarm(); 204 void checkNextTimerAlarm();
205 void addAlarm(const QDateTime &qdt, const QString &noti ); 205 void addAlarm(const QDateTime &qdt, const QString &noti );
206 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 206 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
207 void removeAlarm(const QDateTime &qdt, const QString &noti ); 207 void removeAlarm(const QDateTime &qdt, const QString &noti );
208 208
209 /** options dialog made a changed to the configuration. we catch this 209 /** options dialog made a changed to the configuration. we catch this
210 * and notify all widgets which need to update their configuration. */ 210 * and notify all widgets which need to update their configuration. */
211 void updateConfig(); 211 void updateConfig();
212 212
213 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 213 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
214 const QStringList& anniversaryList, const QStringList& realNameList, 214 const QStringList& anniversaryList, const QStringList& realNameList,
215 const QStringList& emailList, const QStringList& assembledNameList, 215 const QStringList& emailList, const QStringList& assembledNameList,
216 const QStringList& uidList); 216 const QStringList& uidList);
217 217
218 /** 218 /**
219 Load calendar from file \a filename. If \a merge is true, load 219 Load calendar from file \a filename. If \a merge is true, load
220 calendar into existing one, if it is false, clear calendar, before 220 calendar into existing one, if it is false, clear calendar, before
221 loading. Return true, if calendar could be successfully loaded. 221 loading. Return true, if calendar could be successfully loaded.
222 */ 222 */
223 bool openCalendar(QString filename, bool merge=false); 223 bool openCalendar(QString filename, bool merge=false);
224 bool syncCalendar(QString filename,int mode = 0 ); 224 bool syncCalendar(QString filename,int mode = 0 );
225 225
226 /** 226 /**
227 Save calendar data to file. Return true if calendar could be 227 Save calendar data to file. Return true if calendar could be
228 successfully saved. 228 successfully saved.
229 */ 229 */
230 bool saveCalendar(QString filename); 230 bool saveCalendar(QString filename);
231 231
232 /** 232 /**
233 Close calendar. Clear calendar data and reset views to display an empty 233 Close calendar. Clear calendar data and reset views to display an empty
234 calendar. 234 calendar.
235 */ 235 */
236 void closeCalendar(); 236 void closeCalendar();
237 237
238 /** Archive old events of calendar */ 238 /** Archive old events of calendar */
239 void archiveCalendar(); 239 void archiveCalendar();
240 240
241 void showIncidence(); 241 void showIncidence();
242 void editIncidence(); 242 void editIncidence();
243 void editIncidenceDescription(); 243 void editIncidenceDescription();
244 void deleteIncidence(); 244 void deleteIncidence();
245 void cloneIncidence(); 245 void cloneIncidence();
246 void moveIncidence(); 246 void moveIncidence();
247 void beamIncidence(); 247 void beamIncidence();
248 void toggleCancelIncidence(); 248 void toggleCancelIncidence();
249 249
250 /** create an editeventwin with supplied date/time, and if bool is true, 250 /** create an editeventwin with supplied date/time, and if bool is true,
251 * make the event take all day. */ 251 * make the event take all day. */
252 void newEvent(QDateTime, QDateTime, bool allDay ); 252 void newEvent(QDateTime, QDateTime, bool allDay );
253 void newEvent(QDateTime, QDateTime); 253 void newEvent(QDateTime, QDateTime);
254 void newEvent(QDateTime fh); 254 void newEvent(QDateTime fh);
255 void newEvent(QDate dt); 255 void newEvent(QDate dt);
256 /** create new event without having a date hint. Takes current date as 256 /** create new event without having a date hint. Takes current date as
257 default hint. */ 257 default hint. */
258 void newEvent(); 258 void newEvent();
259 void newFloatingEvent(); 259 void newFloatingEvent();
260 260
261 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 261 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
262 void showIncidence(Incidence *); 262 void showIncidence(Incidence *);
263 void showIncidence(QString uid); 263 void showIncidence(QString uid);
264 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 264 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
265 void editIncidence(Incidence *); 265 void editIncidence(Incidence *);
266 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 266 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
267 void deleteIncidence(Incidence *); 267 void deleteIncidence(Incidence *);
268 void cloneIncidence(Incidence *); 268 void cloneIncidence(Incidence *);
269 void cancelIncidence(Incidence *); 269 void cancelIncidence(Incidence *);
270 /** Create an editor for the supplied event. */ 270 /** Create an editor for the supplied event. */
271 void editEvent(Event *); 271 void editEvent(Event *);
272 /** Delete the supplied event. */ 272 /** Delete the supplied event. */
273 void deleteEvent(Event *); 273 void deleteEvent(Event *);
274 /** Delete the event with the given unique ID. Returns false, if event wasn't 274 /** Delete the event with the given unique ID. Returns false, if event wasn't
275 found. */ 275 found. */
276 bool deleteEvent(const QString &uid); 276 bool deleteEvent(const QString &uid);
277 /** Create a read-only viewer dialog for the supplied event. */ 277 /** Create a read-only viewer dialog for the supplied event. */
278 void showEvent(Event *); 278 void showEvent(Event *);
279 279
280 void editJournal(Journal *); 280 void editJournal(Journal *);
281 void showJournal(Journal *); 281 void showJournal(Journal *);
282 void deleteJournal(Journal *); 282 void deleteJournal(Journal *);
283 /** Create an editor dialog for a todo */ 283 /** Create an editor dialog for a todo */
284 void editTodo(Todo *); 284 void editTodo(Todo *);
285 /** Create a read-only viewer dialog for the supplied todo */ 285 /** Create a read-only viewer dialog for the supplied todo */
286 void showTodo(Todo *); 286 void showTodo(Todo *);
287 /** create new todo */ 287 /** create new todo */
288 void newTodo(); 288 void newTodo();
289 void newTodoDateTime(QDateTime, bool allday); 289 void newTodoDateTime(QDateTime, bool allday);
290 /** create new todo with a parent todo */ 290 /** create new todo with a parent todo */
291 void newSubTodo(); 291 void newSubTodo();
292 /** create new todo with a parent todo */ 292 /** create new todo with a parent todo */
293 void newSubTodo(Todo *); 293 void newSubTodo(Todo *);
294 /** Delete todo */ 294 /** Delete todo */
295 void deleteTodo(Todo *); 295 void deleteTodo(Todo *);
296 296
297 297
298 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 298 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
299 * emitted as result. */ 299 * emitted as result. */
300 void checkClipboard(); 300 void checkClipboard();
301 301
302 /** using the KConfig associated with the kapp variable, read in the 302 /** using the KConfig associated with the kapp variable, read in the
303 * settings from the config file. 303 * settings from the config file.
304 */ 304 */
305 void readSettings(); 305 void readSettings();
306 306
307 /** write current state to config file. */ 307 /** write current state to config file. */
308 void writeSettings(); 308 void writeSettings();
309 309
310 /** read settings for calendar filters */ 310 /** read settings for calendar filters */
311 void readFilterSettings(KConfig *config); 311 void readFilterSettings(KConfig *config);
312 312
313 /** write settings for calendar filters */ 313 /** write settings for calendar filters */
314 void writeFilterSettings(KConfig *config); 314 void writeFilterSettings(KConfig *config);
315 315
316 /** passes on the message that an event has changed to the currently 316 /** passes on the message that an event has changed to the currently
317 * activated view so that it can make appropriate display changes. */ 317 * activated view so that it can make appropriate display changes. */
318 void changeEventDisplay(Event *, int); 318 void changeEventDisplay(Event *, int);
319 void changeIncidenceDisplay(Incidence *, int); 319 void changeIncidenceDisplay(Incidence *, int);
320 void changeTodoDisplay(Todo *, int); 320 void changeTodoDisplay(Todo *, int);
321 321
322 void eventAdded(Event *); 322 void eventAdded(Event *);
323 void eventChanged(Event *); 323 void eventChanged(Event *);
324 void eventToBeDeleted(Event *); 324 void eventToBeDeleted(Event *);
325 void eventDeleted(); 325 void eventDeleted();
326 326
327 void todoAdded(Todo *); 327 void todoAdded(Todo *);
328 void todoChanged(Todo *); 328 void todoChanged(Todo *);
329 void todoToBeDeleted(Todo *); 329 void todoToBeDeleted(Todo *);
330 void todoDeleted(); 330 void todoDeleted();
331 331
332 void updateView(const QDate &start, const QDate &end); 332 void updateView(const QDate &start, const QDate &end);
333 void updateView(); 333 void updateView();
334 void clearAllViews();
334 335
335 /** Full update of visible todo views */ 336 /** Full update of visible todo views */
336 void updateTodoViews(); 337 void updateTodoViews();
337 338
338 void updateUnmanagedViews(); 339 void updateUnmanagedViews();
339 340
340 /** cut the current appointment to the clipboard */ 341 /** cut the current appointment to the clipboard */
341 void edit_cut(); 342 void edit_cut();
342 343
343 /** copy the current appointment(s) to the clipboard */ 344 /** copy the current appointment(s) to the clipboard */
344 void edit_copy(); 345 void edit_copy();
345 346
346 /** paste the current vobject(s) in the clipboard buffer into calendar */ 347 /** paste the current vobject(s) in the clipboard buffer into calendar */
347 void edit_paste(); 348 void edit_paste();
348 349
349 /** edit viewing and configuration options. */ 350 /** edit viewing and configuration options. */
350 void edit_options(); 351 void edit_options();
351 /** 352 /**
352 Functions for printing, previewing a print, and setting up printing 353 Functions for printing, previewing a print, and setting up printing
353 parameters. 354 parameters.
354 */ 355 */
355 void print(); 356 void print();
356 void printSetup(); 357 void printSetup();
357 void printPreview(); 358 void printPreview();
358 359
359 /** Export as iCalendar file */ 360 /** Export as iCalendar file */
360 void exportICalendar(); 361 void exportICalendar();
361 362
362 /** Export as vCalendar file */ 363 /** Export as vCalendar file */
363 bool exportVCalendar( QString fn); 364 bool exportVCalendar( QString fn);
364 365
365 /** pop up a dialog to show an existing appointment. */ 366 /** pop up a dialog to show an existing appointment. */
366 void appointment_show(); 367 void appointment_show();
367 /** 368 /**
368 * pop up an Appointment Dialog to edit an existing appointment.Get 369 * pop up an Appointment Dialog to edit an existing appointment.Get
369 * information on the appointment from the list of unique IDs that is 370 * information on the appointment from the list of unique IDs that is
370 * currently in the View, called currIds. 371 * currently in the View, called currIds.
371 */ 372 */
372 void appointment_edit(); 373 void appointment_edit();
373 /** 374 /**
374 * pop up dialog confirming deletion of currently selected event in the 375 * pop up dialog confirming deletion of currently selected event in the
375 * View. 376 * View.
376 */ 377 */
377 void appointment_delete(); 378 void appointment_delete();
378 379
379 /** mails the currently selected event to a particular user as a vCalendar 380 /** mails the currently selected event to a particular user as a vCalendar
380 attachment. */ 381 attachment. */
381 void action_mail(); 382 void action_mail();
382 383
383 /* frees a subtodo from it's relation */ 384 /* frees a subtodo from it's relation */
384 void todo_unsub( Todo * ); 385 void todo_unsub( Todo * );
385 void todo_resub( Todo * parent, Todo * sub ); 386 void todo_resub( Todo * parent, Todo * sub );
386 387
387 /** Take ownership of selected event. */ 388 /** Take ownership of selected event. */
388 void takeOverEvent(); 389 void takeOverEvent();
389 390
390 /** Take ownership of all events in calendar. */ 391 /** Take ownership of all events in calendar. */
391 void takeOverCalendar(); 392 void takeOverCalendar();
392 393
393 /** query whether or not the calendar is "dirty". */ 394 /** query whether or not the calendar is "dirty". */
394 bool isModified(); 395 bool isModified();
395 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 396 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
396 void setModified(bool modified=true); 397 void setModified(bool modified=true);
397 398
398 /** query if the calendar is read-only. */ 399 /** query if the calendar is read-only. */
399 bool isReadOnly(); 400 bool isReadOnly();
400 /** set state of calendar to read-only */ 401 /** set state of calendar to read-only */
401 void setReadOnly(bool readOnly=true); 402 void setReadOnly(bool readOnly=true);
402 403
403 void eventUpdated(Incidence *); 404 void eventUpdated(Incidence *);
404 405
405 /* iTIP scheduling actions */ 406 /* iTIP scheduling actions */
406 void schedule_publish(Incidence *incidence = 0); 407 void schedule_publish(Incidence *incidence = 0);
407 void schedule_request(Incidence *incidence = 0); 408 void schedule_request(Incidence *incidence = 0);
408 void schedule_refresh(Incidence *incidence = 0); 409 void schedule_refresh(Incidence *incidence = 0);
409 void schedule_cancel(Incidence *incidence = 0); 410 void schedule_cancel(Incidence *incidence = 0);
410 void schedule_add(Incidence *incidence = 0); 411 void schedule_add(Incidence *incidence = 0);
411 void schedule_reply(Incidence *incidence = 0); 412 void schedule_reply(Incidence *incidence = 0);
412 void schedule_counter(Incidence *incidence = 0); 413 void schedule_counter(Incidence *incidence = 0);
413 void schedule_declinecounter(Incidence *incidence = 0); 414 void schedule_declinecounter(Incidence *incidence = 0);
414 void schedule_publish_freebusy(int daysToPublish = 30); 415 void schedule_publish_freebusy(int daysToPublish = 30);
415 416
416 void openAddressbook(); 417 void openAddressbook();
417 418
418 void editFilters(); 419 void editFilters();
419 void toggleFilerEnabled(); 420 void toggleFilerEnabled();
420 QPtrList<CalFilter> filters(); 421 QPtrList<CalFilter> filters();
421 void toggleFilter(); 422 void toggleFilter();
422 void showFilter(bool visible); 423 void showFilter(bool visible);
423 void updateFilter(); 424 void updateFilter();
424 void filterEdited(); 425 void filterEdited();
425 void selectFilter( int ); 426 void selectFilter( int );
426 KOFilterView *filterView(); 427 KOFilterView *filterView();
427 428
428 void showIntro(); 429 void showIntro();
429 430
430 /** Move the curdatepient view date to today */ 431 /** Move the curdatepient view date to today */
431 void goToday(); 432 void goToday();
432 433
433 /** Move to the next date(s) in the current view */ 434 /** Move to the next date(s) in the current view */
434 void goNext(); 435 void goNext();
435 436
436 /** Move to the previous date(s) in the current view */ 437 /** Move to the previous date(s) in the current view */
437 void goPrevious(); 438 void goPrevious();
438 /** Move to the next date(s) in the current view */ 439 /** Move to the next date(s) in the current view */
439 void goNextMonth(); 440 void goNextMonth();
440 441
441 /** Move to the previous date(s) in the current view */ 442 /** Move to the previous date(s) in the current view */
442 void goPreviousMonth(); 443 void goPreviousMonth();
443 444
444 void toggleExpand(); 445 void toggleExpand();
445 void toggleDateNavigatorWidget(); 446 void toggleDateNavigatorWidget();
446 void toggleAllDaySize(); 447 void toggleAllDaySize();
447 void dialogClosing(Incidence *); 448 void dialogClosing(Incidence *);
448 449
449 /** Look for new messages in the inbox */ 450 /** Look for new messages in the inbox */
450 void lookForIncomingMessages(); 451 void lookForIncomingMessages();
451 /** Look for new messages in the outbox */ 452 /** Look for new messages in the outbox */
452 void lookForOutgoingMessages(); 453 void lookForOutgoingMessages();
453 454
454 void processMainViewSelection( Incidence * ); 455 void processMainViewSelection( Incidence * );
455 void processTodoListSelection( Incidence * ); 456 void processTodoListSelection( Incidence * );
456 457
457 void processIncidenceSelection( Incidence * ); 458 void processIncidenceSelection( Incidence * );
458 459
459 void purgeCompleted(); 460 void purgeCompleted();
460 bool removeCompletedSubTodos( Todo* ); 461 bool removeCompletedSubTodos( Todo* );
461 void slotCalendarChanged(); 462 void slotCalendarChanged();
462 bool importBday(); 463 bool importBday();
463 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 464 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
464 bool importQtopia( const QString &categoriesFile, 465 bool importQtopia( const QString &categoriesFile,
465 const QString &datebookFile, 466 const QString &datebookFile,
466 const QString &tasklistFile ); 467 const QString &tasklistFile );
467 void syncExternal( int mode ); 468 void syncExternal( int mode );
468 void slotSelectPickerDate( QDate ) ; 469 void slotSelectPickerDate( QDate ) ;
469 void showDatePicker() ; 470 void showDatePicker() ;
470 void showDatePickerPopup() ; 471 void showDatePickerPopup() ;
471 void moveIncidence(Incidence *) ; 472 void moveIncidence(Incidence *) ;
472 void beamIncidence(Incidence *) ; 473 void beamIncidence(Incidence *) ;
473 void beamCalendar() ; 474 void beamCalendar() ;
474 void beamFilteredCalendar() ; 475 void beamFilteredCalendar() ;
475 void beamIncidenceList(QPtrList<Incidence>) ; 476 void beamIncidenceList(QPtrList<Incidence>) ;
476 void manageCategories(); 477 void manageCategories();
477 int addCategories(); 478 int addCategories();
478 void removeCategories(); 479 void removeCategories();
479 void setSyncDevice( QString ); 480 void setSyncDevice( QString );
480 void setSyncName( QString ); 481 void setSyncName( QString );
481 void showDay( QDate ); 482 void showDay( QDate );
482 void undo_delete(); 483 void undo_delete();
483 protected slots: 484 protected slots:
484 void resetFocus(); 485 void resetFocus();
485 void slotViewerClosed(); 486 void slotViewerClosed();
486 void timerAlarm(); 487 void timerAlarm();
487 void suspendAlarm(); 488 void suspendAlarm();
488 void beamDone( Ir *ir ); 489 void beamDone( Ir *ir );
489 /** Select a view or adapt the current view to display the specified dates. */ 490 /** Select a view or adapt the current view to display the specified dates. */
490 void showDates( const KCal::DateList & ); 491 void showDates( const KCal::DateList & );
491 void selectWeekNum ( int ); 492 void selectWeekNum ( int );
492 493
493 public: 494 public:
494 // show a standard warning 495 // show a standard warning
495 // returns KMsgBox::yesNoCancel() 496 // returns KMsgBox::yesNoCancel()
496 int msgCalModified(); 497 int msgCalModified();
497 virtual bool sync(KSyncManager* manager, QString filename, int mode); 498 virtual bool sync(KSyncManager* manager, QString filename, int mode);
498 499
499 virtual bool syncExternal(KSyncManager* manager, QString resource); 500 virtual bool syncExternal(KSyncManager* manager, QString resource);
500 virtual void removeSyncInfo( QString syncProfile); 501 virtual void removeSyncInfo( QString syncProfile);
501 void setSyncManager(KSyncManager* manager); 502 void setSyncManager(KSyncManager* manager);
502 void setLoadedFileVersion(QDateTime); 503 void setLoadedFileVersion(QDateTime);
503 bool checkFileVersion(QString fn); 504 bool checkFileVersion(QString fn);
504 bool checkFileChanged(QString fn); 505 bool checkFileChanged(QString fn);
505 Event* getLastSyncEvent(); 506 Event* getLastSyncEvent();
506 /** Adapt navigation units correpsonding to step size of navigation of the 507 /** Adapt navigation units correpsonding to step size of navigation of the
507 * current view. 508 * current view.
508 */ 509 */
509 void adaptNavigationUnits(); 510 void adaptNavigationUnits();
510 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 511 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
511 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 512 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
512 //Attendee* getYourAttendee(Event *event); 513 //Attendee* getYourAttendee(Event *event);
513 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 514 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
514 protected: 515 protected:
515 void schedule(Scheduler::Method, Incidence *incidence = 0); 516 void schedule(Scheduler::Method, Incidence *incidence = 0);
516 517
517 // returns KMsgBox::OKCandel() 518 // returns KMsgBox::OKCandel()
518 int msgItemDelete(const QString name); 519 int msgItemDelete(const QString name);
519 void showEventEditor(); 520 void showEventEditor();
520 void showTodoEditor(); 521 void showTodoEditor();
521 void writeLocale(); 522 void writeLocale();
522 Todo *selectedTodo(); 523 Todo *selectedTodo();
523 524
524 private: 525 private:
525 QDateTime mNextAlarmDateTime; 526 QDateTime mNextAlarmDateTime;
526 bool mViewerCallerIsSearchDialog; 527 bool mViewerCallerIsSearchDialog;
527 bool mBlockShowDates; 528 bool mBlockShowDates;
528 KSyncManager* mSyncManager; 529 KSyncManager* mSyncManager;
529 AlarmDialog * mAlarmDialog; 530 AlarmDialog * mAlarmDialog;
530 QString mAlarmNotification; 531 QString mAlarmNotification;
531 QString mSuspendAlarmNotification; 532 QString mSuspendAlarmNotification;
532 QTimer* mSuspendTimer; 533 QTimer* mSuspendTimer;
533 QTimer* mAlarmTimer; 534 QTimer* mAlarmTimer;
534 QTimer* mRecheckAlarmTimer; 535 QTimer* mRecheckAlarmTimer;
535 void computeAlarm( QString ); 536 void computeAlarm( QString );
536 void startAlarm( QString, QString ); 537 void startAlarm( QString, QString );
537 void setSyncEventsReadOnly(); 538 void setSyncEventsReadOnly();
538 539
539 QDateTime loadedFileVersion; 540 QDateTime loadedFileVersion;
540 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 541 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
541 void checkExternalId( Incidence * inc ); 542 void checkExternalId( Incidence * inc );
542 int mGlobalSyncMode; 543 int mGlobalSyncMode;
543 QString mCurrentSyncDevice; 544 QString mCurrentSyncDevice;
544 QString mCurrentSyncName; 545 QString mCurrentSyncName;
545 KOBeamPrefs* beamDialog; 546 KOBeamPrefs* beamDialog;
546 void init(); 547 void init();
547 int mDatePickerMode; 548 int mDatePickerMode;
548 bool mFlagEditDescription; 549 bool mFlagEditDescription;
549 QDateTime mLastCalendarSync; 550 QDateTime mLastCalendarSync;
550 void createPrinter(); 551 void createPrinter();
551 552
552 void calendarModified( bool, Calendar * ); 553 void calendarModified( bool, Calendar * );
553 554
554 CalPrinter *mCalPrinter; 555 CalPrinter *mCalPrinter;
555 556
556 QSplitter *mPanner; 557 QSplitter *mPanner;
557 QSplitter *mLeftSplitter; 558 QSplitter *mLeftSplitter;
558 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame; 559 KDGanttMinimizeSplitter *mLeftFrame, *mMainFrame;
559 QWidgetStack *mRightFrame; 560 QWidgetStack *mRightFrame;
560 561
561 KDatePicker* mDatePicker; 562 KDatePicker* mDatePicker;
562 QVBox* mDateFrame; 563 QVBox* mDateFrame;
563 564
564 DateNavigatorContainer *mDateNavigator; // widget showing small month view. 565 DateNavigatorContainer *mDateNavigator; // widget showing small month view.
565 566
566 KOFilterView *mFilterView; 567 KOFilterView *mFilterView;
567 568
568 ResourceView *mResourceView; 569 ResourceView *mResourceView;
569 570
570 // calendar object for this viewing instance 571 // calendar object for this viewing instance
571 Calendar *mCalendar; 572 Calendar *mCalendar;
572 573
573 CalendarResourceManager *mResourceManager; 574 CalendarResourceManager *mResourceManager;
574 575
575 FileStorage *mStorage; 576 FileStorage *mStorage;
576 577
577 DateNavigator *mNavigator; 578 DateNavigator *mNavigator;
578 579
579 KOViewManager *mViewManager; 580 KOViewManager *mViewManager;
580 KODialogManager *mDialogManager; 581 KODialogManager *mDialogManager;
581 582
582 // Calendar filters 583 // Calendar filters
583 QPtrList<CalFilter> mFilters; 584 QPtrList<CalFilter> mFilters;
584 585
585 // various housekeeping variables. 586 // various housekeeping variables.
586 bool mModified; // flag indicating if calendar is modified 587 bool mModified; // flag indicating if calendar is modified
587 bool mReadOnly; // flag indicating if calendar is read-only 588 bool mReadOnly; // flag indicating if calendar is read-only
588 QDate mSaveSingleDate; 589 QDate mSaveSingleDate;
589 590
590 Incidence *mSelectedIncidence; 591 Incidence *mSelectedIncidence;
591 Incidence *mMoveIncidence; 592 Incidence *mMoveIncidence;
592 QDate mMoveIncidenceOldDate; 593 QDate mMoveIncidenceOldDate;
593 KOTodoView *mTodoList; 594 KOTodoView *mTodoList;
594 KOEventEditor * mEventEditor; 595 KOEventEditor * mEventEditor;
595 KOTodoEditor * mTodoEditor; 596 KOTodoEditor * mTodoEditor;
596 KOEventViewerDialog * mEventViewerDialog; 597 KOEventViewerDialog * mEventViewerDialog;
597 void keyPressEvent ( QKeyEvent *e) ; 598 void keyPressEvent ( QKeyEvent *e) ;
598 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 599 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
599}; 600};
600 601
601 602
602class CalendarViewVisitor : public Incidence::Visitor 603class CalendarViewVisitor : public Incidence::Visitor
603{ 604{
604 public: 605 public:
605 CalendarViewVisitor() : mView( 0 ) {} 606 CalendarViewVisitor() : mView( 0 ) {}
606 607
607 bool act( Incidence *incidence, CalendarView *view ) 608 bool act( Incidence *incidence, CalendarView *view )
608 { 609 {
609 mView = view; 610 mView = view;
610 return incidence->accept( *this ); 611 return incidence->accept( *this );
611 } 612 }
612 613
613 protected: 614 protected:
614 CalendarView *mView; 615 CalendarView *mView;
615}; 616};
616 617
617class ShowIncidenceVisitor : public CalendarViewVisitor 618class ShowIncidenceVisitor : public CalendarViewVisitor
618{ 619{
619 protected: 620 protected:
620 bool visit( Event *event ) { mView->showEvent( event ); return true; } 621 bool visit( Event *event ) { mView->showEvent( event ); return true; }
621 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 622 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
622 bool visit( Journal * j ) { mView->showJournal( j );return true; } 623 bool visit( Journal * j ) { mView->showJournal( j );return true; }
623}; 624};
624 625
625class EditIncidenceVisitor : public CalendarViewVisitor 626class EditIncidenceVisitor : public CalendarViewVisitor
626{ 627{
627 protected: 628 protected:
628 bool visit( Event *event ) { mView->editEvent( event ); return true; } 629 bool visit( Event *event ) { mView->editEvent( event ); return true; }
629 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 630 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
630 bool visit( Journal *j ) { mView->editJournal( j); return true; } 631 bool visit( Journal *j ) { mView->editJournal( j); return true; }
631}; 632};
632 633
633class DeleteIncidenceVisitor : public CalendarViewVisitor 634class DeleteIncidenceVisitor : public CalendarViewVisitor
634{ 635{
635 protected: 636 protected:
636 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 637 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
637 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 638 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
638 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 639 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
639}; 640};
640 641
641#endif 642#endif
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index fd9bf29..1320a2e 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1647 +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->type() == "Todo" ) 584 if ( incOld->type() == "Todo" )
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()->type() == "Event" ) { 970 if ( item->incidence()->type() == "Event" ) {
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()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 978 if ( item->incidence()->type()=="Todo" && 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()->type() == "Event" ) { 994 if ( item->incidence()->type() == "Event" ) {
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()->type() == "Event" ) { 1024 if ( item->incidence()->type() == "Event" ) {
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()->type() == "Todo" ) { 1027 } else if ( item->incidence()->type() == "Todo" ) {
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()->type() == "Todo" ) { 1041 if ( item->incidence()->type() == "Todo" ) {
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()
1335{
1336 // kdDebug() << "ClearView" << endl;
1337 clearView();
1338 mAllDayAgenda->hideUnused();
1339 mAgenda->hideUnused();
1340}
1334 1341
1335void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1342void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1336 const QDate &td) 1343 const QDate &td)
1337{ 1344{
1338#ifndef KORG_NOPRINTER 1345#ifndef KORG_NOPRINTER
1339 if (fd == td) 1346 if (fd == td)
1340 calPrinter->preview(CalPrinter::Day, fd, td); 1347 calPrinter->preview(CalPrinter::Day, fd, td);
1341 else 1348 else
1342 calPrinter->preview(CalPrinter::Week, fd, td); 1349 calPrinter->preview(CalPrinter::Week, fd, td);
1343#endif 1350#endif
1344} 1351}
1345 1352
1346// void KOAgendaView::updateMovedTodo() 1353// void KOAgendaView::updateMovedTodo()
1347// { 1354// {
1348// // updateConfig(); 1355// // updateConfig();
1349// // emit updateTodoViews(); 1356// // emit updateTodoViews();
1350// } 1357// }
1351 1358
1352void KOAgendaView::slotShowDateView( int mode , int d ) 1359void KOAgendaView::slotShowDateView( int mode , int d )
1353{ 1360{
1354 if ( d >= mSelectedDates.count() ) { 1361 if ( d >= mSelectedDates.count() ) {
1355 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); 1362 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() );
1356 1363
1357 } else { 1364 } else {
1358 QDate day = mSelectedDates[d]; 1365 QDate day = mSelectedDates[d];
1359 emit showDateView(mode , day ); 1366 emit showDateView(mode , day );
1360 } 1367 }
1361 1368
1362} 1369}
1363void KOAgendaView::newEvent(int gx, int gy) 1370void KOAgendaView::newEvent(int gx, int gy)
1364{ 1371{
1365 if (!mSelectedDates.count()) return; 1372 if (!mSelectedDates.count()) return;
1366 1373
1367 QDate day = mSelectedDates[gx]; 1374 QDate day = mSelectedDates[gx];
1368 1375
1369 QTime time = mAgenda->gyToTime(gy); 1376 QTime time = mAgenda->gyToTime(gy);
1370 QDateTime dt(day,time); 1377 QDateTime dt(day,time);
1371 // if ( dt < QDateTime::currentDateTime () ) 1378 // if ( dt < QDateTime::currentDateTime () )
1372 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1379 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1373 emit newEventSignal(dt); 1380 emit newEventSignal(dt);
1374} 1381}
1375 1382
1376void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1383void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1377{ 1384{
1378 if (!mSelectedDates.count()) return; 1385 if (!mSelectedDates.count()) return;
1379 1386
1380 QDate dayStart = mSelectedDates[gxStart]; 1387 QDate dayStart = mSelectedDates[gxStart];
1381 QDate dayEnd = mSelectedDates[gxEnd]; 1388 QDate dayEnd = mSelectedDates[gxEnd];
1382 1389
1383 QTime timeStart = mAgenda->gyToTime(gyStart); 1390 QTime timeStart = mAgenda->gyToTime(gyStart);
1384 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1391 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1385 1392
1386 QDateTime dtStart(dayStart,timeStart); 1393 QDateTime dtStart(dayStart,timeStart);
1387 QDateTime dtEnd(dayEnd,timeEnd); 1394 QDateTime dtEnd(dayEnd,timeEnd);
1388 1395
1389 emit newEventSignal(dtStart,dtEnd); 1396 emit newEventSignal(dtStart,dtEnd);
1390} 1397}
1391 1398
1392void KOAgendaView::newEventAllDay(int gx, int ) 1399void KOAgendaView::newEventAllDay(int gx, int )
1393{ 1400{
1394 if (!mSelectedDates.count()) return; 1401 if (!mSelectedDates.count()) return;
1395 1402
1396 QDate day = mSelectedDates[gx]; 1403 QDate day = mSelectedDates[gx];
1397 1404
1398 emit newEventSignal(day); 1405 emit newEventSignal(day);
1399} 1406}
1400void KOAgendaView::newTodoAllDay(int gx, int ) 1407void KOAgendaView::newTodoAllDay(int gx, int )
1401{ 1408{
1402 if (!mSelectedDates.count()) return; 1409 if (!mSelectedDates.count()) return;
1403 1410
1404 QDateTime day (mSelectedDates[gx] ); 1411 QDateTime day (mSelectedDates[gx] );
1405 emit newTodoSignal(day, true); 1412 emit newTodoSignal(day, true);
1406} 1413}
1407void KOAgendaView::newTodo(int gx, int gy ) 1414void KOAgendaView::newTodo(int gx, int gy )
1408{ 1415{
1409 if (!mSelectedDates.count()) return; 1416 if (!mSelectedDates.count()) return;
1410 QDate dayStart = mSelectedDates[gx]; 1417 QDate dayStart = mSelectedDates[gx];
1411 QTime timeStart = mAgenda->gyToTime(gy); 1418 QTime timeStart = mAgenda->gyToTime(gy);
1412 QDateTime dt (dayStart,timeStart); 1419 QDateTime dt (dayStart,timeStart);
1413 emit newTodoSignal( dt, false ); 1420 emit newTodoSignal( dt, false );
1414} 1421}
1415 1422
1416void KOAgendaView::updateEventIndicatorTop(int newY) 1423void KOAgendaView::updateEventIndicatorTop(int newY)
1417{ 1424{
1418 uint i; 1425 uint i;
1419 for(i=0;i<mMinY.size();++i) { 1426 for(i=0;i<mMinY.size();++i) {
1420 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1427 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1421 else mEventIndicatorTop->enableColumn(i,false); 1428 else mEventIndicatorTop->enableColumn(i,false);
1422 } 1429 }
1423 1430
1424 mEventIndicatorTop->update(); 1431 mEventIndicatorTop->update();
1425} 1432}
1426 1433
1427void KOAgendaView::updateEventIndicatorBottom(int newY) 1434void KOAgendaView::updateEventIndicatorBottom(int newY)
1428{ 1435{
1429 uint i; 1436 uint i;
1430 for(i=0;i<mMaxY.size();++i) { 1437 for(i=0;i<mMaxY.size();++i) {
1431 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1438 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1432 else mEventIndicatorBottom->enableColumn(i,false); 1439 else mEventIndicatorBottom->enableColumn(i,false);
1433 } 1440 }
1434 1441
1435 mEventIndicatorBottom->update(); 1442 mEventIndicatorBottom->update();
1436} 1443}
1437 1444
1438void KOAgendaView::startDrag(Event *event) 1445void KOAgendaView::startDrag(Event *event)
1439{ 1446{
1440#ifndef KORG_NODND 1447#ifndef KORG_NODND
1441 DndFactory factory( calendar() ); 1448 DndFactory factory( calendar() );
1442 ICalDrag *vd = factory.createDrag(event,this); 1449 ICalDrag *vd = factory.createDrag(event,this);
1443 if (vd->drag()) { 1450 if (vd->drag()) {
1444 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1451 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1445 } 1452 }
1446#endif 1453#endif
1447} 1454}
1448 1455
1449void KOAgendaView::readSettings() 1456void KOAgendaView::readSettings()
1450{ 1457{
1451 readSettings(KOGlobals::config()); 1458 readSettings(KOGlobals::config());
1452} 1459}
1453 1460
1454void KOAgendaView::readSettings(KConfig *config) 1461void KOAgendaView::readSettings(KConfig *config)
1455{ 1462{
1456 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1463 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1457 1464
1458 config->setGroup("Views"); 1465 config->setGroup("Views");
1459 1466
1460 //#ifndef KORG_NOSPLITTER 1467 //#ifndef KORG_NOSPLITTER
1461 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1468 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1462 if (sizes.count() == 2) { 1469 if (sizes.count() == 2) {
1463 if ( sizes[0] < 20 ) { 1470 if ( sizes[0] < 20 ) {
1464 sizes[1] = sizes[1] +20 - sizes[0]; 1471 sizes[1] = sizes[1] +20 - sizes[0];
1465 sizes[0] = 20; 1472 sizes[0] = 20;
1466 } 1473 }
1467 mSplitterAgenda->setSizes(sizes); 1474 mSplitterAgenda->setSizes(sizes);
1468 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1475 // qDebug("read %d %d ",sizes[0],sizes[1] );
1469 } 1476 }
1470 //#endif 1477 //#endif
1471 1478
1472 // updateConfig(); 1479 // updateConfig();
1473} 1480}
1474 1481
1475void KOAgendaView::writeSettings(KConfig *config) 1482void KOAgendaView::writeSettings(KConfig *config)
1476{ 1483{
1477 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1484 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1478 1485
1479 config->setGroup("Views"); 1486 config->setGroup("Views");
1480 1487
1481 //#ifndef KORG_NOSPLITTER 1488 //#ifndef KORG_NOSPLITTER
1482 QValueList<int> list = mSplitterAgenda->sizes(); 1489 QValueList<int> list = mSplitterAgenda->sizes();
1483 config->writeEntry("Separator AgendaView",list); 1490 config->writeEntry("Separator AgendaView",list);
1484 //qDebug("write %d %d ", list[0],list[1] ); 1491 //qDebug("write %d %d ", list[0],list[1] );
1485 //#endif 1492 //#endif
1486} 1493}
1487 1494
1488void KOAgendaView::setHolidayMasks() 1495void KOAgendaView::setHolidayMasks()
1489{ 1496{
1490 mHolidayMask.resize(mSelectedDates.count()); 1497 mHolidayMask.resize(mSelectedDates.count());
1491 1498
1492 uint i; 1499 uint i;
1493 for(i=0;i<mSelectedDates.count();++i) { 1500 for(i=0;i<mSelectedDates.count();++i) {
1494 QDate date = mSelectedDates[i]; 1501 QDate date = mSelectedDates[i];
1495 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1502 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1496 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1503 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1497 bool showHoliday = false; 1504 bool showHoliday = false;
1498 if ( KOPrefs::instance()->mExcludeHolidays ) { 1505 if ( KOPrefs::instance()->mExcludeHolidays ) {
1499 QPtrList<Event> events = calendar()->events( date, true ); 1506 QPtrList<Event> events = calendar()->events( date, true );
1500 Event *event; 1507 Event *event;
1501 for( event = events.first(); event; event = events.next() ) { 1508 for( event = events.first(); event; event = events.next() ) {
1502 if ( event->isHoliday()) { 1509 if ( event->isHoliday()) {
1503 showHoliday = true; 1510 showHoliday = true;
1504 break; 1511 break;
1505 } 1512 }
1506 } 1513 }
1507 1514
1508 } 1515 }
1509 1516
1510#ifndef KORG_NOPLUGINS 1517#ifndef KORG_NOPLUGINS
1511 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1518 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1512 !KOCore::self()->holiday(date).isEmpty(); 1519 !KOCore::self()->holiday(date).isEmpty();
1513#endif 1520#endif
1514 bool showDay = showSaturday || showSunday || showHoliday; 1521 bool showDay = showSaturday || showSunday || showHoliday;
1515 1522
1516 if (showDay) { 1523 if (showDay) {
1517 mHolidayMask.at(i) = true; 1524 mHolidayMask.at(i) = true;
1518 } else { 1525 } else {
1519 mHolidayMask.at(i) = false; 1526 mHolidayMask.at(i) = false;
1520 } 1527 }
1521 } 1528 }
1522 1529
1523 mAgenda->setHolidayMask(&mHolidayMask); 1530 mAgenda->setHolidayMask(&mHolidayMask);
1524 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1531 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1525} 1532}
1526 1533
1527void KOAgendaView::setContentsPos(int y) 1534void KOAgendaView::setContentsPos(int y)
1528{ 1535{
1529 mAgenda->setContentsPos(0,y); 1536 mAgenda->setContentsPos(0,y);
1530} 1537}
1531 1538
1532void KOAgendaView::clearSelection() 1539void KOAgendaView::clearSelection()
1533{ 1540{
1534 mAgenda->deselectItem(); 1541 mAgenda->deselectItem();
1535 mAllDayAgenda->deselectItem(); 1542 mAllDayAgenda->deselectItem();
1536} 1543}
1537 1544
1538void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1545void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1539 int gxEnd, int gyEnd) 1546 int gxEnd, int gyEnd)
1540{ 1547{
1541 mTimeSpanInAllDay = true; 1548 mTimeSpanInAllDay = true;
1542 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1549 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1543} 1550}
1544 1551
1545 1552
1546 1553
1547 1554
1548void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1555void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1549 int gxEnd, int gyEnd) 1556 int gxEnd, int gyEnd)
1550{ 1557{
1551 if (!mSelectedDates.count()) return; 1558 if (!mSelectedDates.count()) return;
1552 1559
1553 QDate dayStart = mSelectedDates[gxStart]; 1560 QDate dayStart = mSelectedDates[gxStart];
1554 QDate dayEnd = mSelectedDates[gxEnd]; 1561 QDate dayEnd = mSelectedDates[gxEnd];
1555 1562
1556 QTime timeStart = mAgenda->gyToTime(gyStart); 1563 QTime timeStart = mAgenda->gyToTime(gyStart);
1557 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1564 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1558 1565
1559 QDateTime dtStart(dayStart,timeStart); 1566 QDateTime dtStart(dayStart,timeStart);
1560 QDateTime dtEnd(dayEnd,timeEnd); 1567 QDateTime dtEnd(dayEnd,timeEnd);
1561 1568
1562 mTimeSpanBegin = dtStart; 1569 mTimeSpanBegin = dtStart;
1563 mTimeSpanEnd = dtEnd; 1570 mTimeSpanEnd = dtEnd;
1564 1571
1565} 1572}
1566 1573
1567void KOAgendaView::deleteSelectedDateTime() 1574void KOAgendaView::deleteSelectedDateTime()
1568{ 1575{
1569 mTimeSpanBegin.setDate(QDate()); 1576 mTimeSpanBegin.setDate(QDate());
1570 mTimeSpanEnd.setDate(QDate()); 1577 mTimeSpanEnd.setDate(QDate());
1571 mTimeSpanInAllDay = false; 1578 mTimeSpanInAllDay = false;
1572} 1579}
1573 1580
1574void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1581void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1575{ 1582{
1576 e->ignore(); 1583 e->ignore();
1577} 1584}
1578 1585
1579void KOAgendaView::scrollOneHourUp() 1586void KOAgendaView::scrollOneHourUp()
1580{ 1587{
1581 1588
1582 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1589 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1583} 1590}
1584void KOAgendaView::scrollOneHourDown() 1591void KOAgendaView::scrollOneHourDown()
1585{ 1592{
1586 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1593 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1587} 1594}
1588 1595
1589void KOAgendaView::setStartHour( int h ) 1596void KOAgendaView::setStartHour( int h )
1590{ 1597{
1591 mAgenda->setStartHour( h ); 1598 mAgenda->setStartHour( h );
1592 1599
1593} 1600}
1594void KOAgendaView::setInitStartHour() 1601void KOAgendaView::setInitStartHour()
1595{ 1602{
1596 1603
1597 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1604 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1598 setStartHour( QTime::currentTime ().hour() ); 1605 setStartHour( QTime::currentTime ().hour() );
1599 else 1606 else
1600 setStartHour( KOPrefs::instance()->mDayBegins ); 1607 setStartHour( KOPrefs::instance()->mDayBegins );
1601 1608
1602} 1609}
1603 1610
1604 1611
1605void KOAgendaView::updateTodo( Todo * t, int ) 1612void KOAgendaView::updateTodo( Todo * t, int )
1606{ 1613{
1607 if ( !isVisible() ) 1614 if ( !isVisible() )
1608 return; 1615 return;
1609 bool remove = false; 1616 bool remove = false;
1610 bool removeAD = false; 1617 bool removeAD = false;
1611 QDate da; 1618 QDate da;
1612 if ( t->hasCompletedDate() ) 1619 if ( t->hasCompletedDate() )
1613 da = t->completed().date(); 1620 da = t->completed().date();
1614 else 1621 else
1615 da = t->dtDue().date(); 1622 da = t->dtDue().date();
1616 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1623 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1617 remove = true; 1624 remove = true;
1618 removeAD = true; 1625 removeAD = true;
1619 } 1626 }
1620 else { 1627 else {
1621 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1628 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1622 if ( overdue && 1629 if ( overdue &&
1623 QDate::currentDate() >= mSelectedDates.first() && 1630 QDate::currentDate() >= mSelectedDates.first() &&
1624 QDate::currentDate() <= mSelectedDates.last()) { 1631 QDate::currentDate() <= mSelectedDates.last()) {
1625 removeAD = false; 1632 removeAD = false;
1626 remove = true; 1633 remove = true;
1627 } 1634 }
1628 else { 1635 else {
1629 1636
1630 if ( da < mSelectedDates.first() || 1637 if ( da < mSelectedDates.first() ||
1631 da > mSelectedDates.last() ) { 1638 da > mSelectedDates.last() ) {
1632 remove = true; 1639 remove = true;
1633 removeAD = true; 1640 removeAD = true;
1634 } else { 1641 } else {
1635 remove = t->doesFloat() && !t->hasCompletedDate(); 1642 remove = t->doesFloat() && !t->hasCompletedDate();
1636 removeAD = !remove; 1643 removeAD = !remove;
1637 } 1644 }
1638 } 1645 }
1639 } 1646 }
1640 int days = mSelectedDates.first().daysTo( da ); 1647 int days = mSelectedDates.first().daysTo( da );
1641 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1648 //qDebug("daysto %d %d %d", days, remove,removeAD );
1642 mAgenda->updateTodo( t , days, remove); 1649 mAgenda->updateTodo( t , days, remove);
1643 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1650 if ( KOPrefs::instance()->mShowTodoInAgenda )
1644 mAllDayAgenda->updateTodo( t , days, removeAD); 1651 mAllDayAgenda->updateTodo( t , days, removeAD);
1645 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1652 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1646 1653
1647} 1654}
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index c6e6602..cc953fc 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,292 +1,293 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qksplitter.h> 31#include <qksplitter.h>
32#else 32#else
33#include <qsplitter.h> 33#include <qsplitter.h>
34#endif 34#endif
35#include <qmemarray.h> 35#include <qmemarray.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48 48
49class KOAgendaButton : public QPushButton 49class KOAgendaButton : public QPushButton
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 QPixmap myPix; 104 QPixmap myPix;
105 bool mRedrawNeeded; 105 bool mRedrawNeeded;
106 int mMiniWidth; 106 int mMiniWidth;
107 int mMouseDownY; 107 int mMouseDownY;
108 QString mOrgCap; 108 QString mOrgCap;
109 int mRows; 109 int mRows;
110 int mCellHeight; 110 int mCellHeight;
111 111
112 /** */ 112 /** */
113 KOAgenda* mAgenda; 113 KOAgenda* mAgenda;
114}; 114};
115 115
116class EventIndicator : public QFrame { 116class EventIndicator : public QFrame {
117 Q_OBJECT 117 Q_OBJECT
118 public: 118 public:
119 enum Location { Top, Bottom }; 119 enum Location { Top, Bottom };
120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 120 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
121 virtual ~EventIndicator(); 121 virtual ~EventIndicator();
122 122
123 void changeColumns(int columns); 123 void changeColumns(int columns);
124 void setPaintWidget( KDGanttMinimizeSplitter* ); 124 void setPaintWidget( KDGanttMinimizeSplitter* );
125 void setXOffset( int ); 125 void setXOffset( int );
126 void enableColumn(int column, bool enable); 126 void enableColumn(int column, bool enable);
127 127
128 protected: 128 protected:
129 void drawContents(QPainter *); 129 void drawContents(QPainter *);
130 130
131 private: 131 private:
132 int mXOffset; 132 int mXOffset;
133 KDGanttMinimizeSplitter* mPaintWidget; 133 KDGanttMinimizeSplitter* mPaintWidget;
134 int mColumns; 134 int mColumns;
135 QHBox *mTopBox; 135 QHBox *mTopBox;
136 QBoxLayout *mTopLayout; 136 QBoxLayout *mTopLayout;
137 Location mLocation; 137 Location mLocation;
138 QPixmap mPixmap; 138 QPixmap mPixmap;
139 QMemArray<bool> mEnabled; 139 QMemArray<bool> mEnabled;
140}; 140};
141 141
142/** 142/**
143 KOAgendaView is the agenda-like view used to display events in an one or 143 KOAgendaView is the agenda-like view used to display events in an one or
144 multi-day view. 144 multi-day view.
145*/ 145*/
146class KOAgendaView : public KOEventView { 146class KOAgendaView : public KOEventView {
147 Q_OBJECT 147 Q_OBJECT
148 public: 148 public:
149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 149 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
150 virtual ~KOAgendaView(); 150 virtual ~KOAgendaView();
151 void setStartHour( int ); 151 void setStartHour( int );
152 void toggleAllDay(); 152 void toggleAllDay();
153 153
154 154
155 /** Returns maximum number of days supported by the koagendaview */ 155 /** Returns maximum number of days supported by the koagendaview */
156 virtual int maxDatesHint(); 156 virtual int maxDatesHint();
157 157
158 /** Returns number of currently shown dates. */ 158 /** Returns number of currently shown dates. */
159 virtual int currentDateCount(); 159 virtual int currentDateCount();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual QPtrList<Incidence> selectedIncidences(); 162 virtual QPtrList<Incidence> selectedIncidences();
163 163
164 /** returns the currently selected events */ 164 /** returns the currently selected events */
165 virtual DateList selectedDates(); 165 virtual DateList selectedDates();
166 166
167 /** Remove all events from view */ 167 /** Remove all events from view */
168 void clearView(); 168 void clearView();
169 void clearList();
169 KOAgenda *agenda() { return mAgenda;} 170 KOAgenda *agenda() { return mAgenda;}
170 virtual void printPreview(CalPrinter *calPrinter, 171 virtual void printPreview(CalPrinter *calPrinter,
171 const QDate &, const QDate &); 172 const QDate &, const QDate &);
172 173
173 /** start-datetime of selection */ 174 /** start-datetime of selection */
174 QDateTime selectionStart() {return mTimeSpanBegin;} 175 QDateTime selectionStart() {return mTimeSpanBegin;}
175 /** end-datetime of selection */ 176 /** end-datetime of selection */
176 QDateTime selectionEnd() {return mTimeSpanEnd;} 177 QDateTime selectionEnd() {return mTimeSpanEnd;}
177 /** returns true if selection is for whole day */ 178 /** returns true if selection is for whole day */
178 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 179 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
179 /** make selected start/end invalid */ 180 /** make selected start/end invalid */
180 void deleteSelectedDateTime(); 181 void deleteSelectedDateTime();
181 void repaintAgenda(); 182 void repaintAgenda();
182 public slots: 183 public slots:
183 void setInitStartHour(); 184 void setInitStartHour();
184 virtual void updateView(); 185 virtual void updateView();
185 virtual void updateConfig(); 186 virtual void updateConfig();
186 virtual void showDates(const QDate &start, const QDate &end); 187 virtual void showDates(const QDate &start, const QDate &end);
187 virtual void showEvents(QPtrList<Event> eventList); 188 virtual void showEvents(QPtrList<Event> eventList);
188 189
189 void updateTodo( Todo *, int ); 190 void updateTodo( Todo *, int );
190 void changeEventDisplay(Event *, int); 191 void changeEventDisplay(Event *, int);
191 192
192 void clearSelection(); 193 void clearSelection();
193 194
194 void newTodo(int gx,int gy); 195 void newTodo(int gx,int gy);
195 void newEvent(int gx,int gy); 196 void newEvent(int gx,int gy);
196 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 197 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
197 void newEventAllDay(int gx, int gy); 198 void newEventAllDay(int gx, int gy);
198 void newTodoAllDay(int gx, int gy); 199 void newTodoAllDay(int gx, int gy);
199 200
200 void startDrag(Event *); 201 void startDrag(Event *);
201 202
202 void readSettings(); 203 void readSettings();
203 void readSettings(KConfig *); 204 void readSettings(KConfig *);
204 void writeSettings(KConfig *); 205 void writeSettings(KConfig *);
205 206
206 void setContentsPos(int y); 207 void setContentsPos(int y);
207 208
208 void scrollOneHourUp(); 209 void scrollOneHourUp();
209 void scrollOneHourDown(); 210 void scrollOneHourDown();
210 void addToCalSlot(Incidence *, Incidence *); 211 void addToCalSlot(Incidence *, Incidence *);
211 void slotShowDateView( int, int ); 212 void slotShowDateView( int, int );
212 213
213 signals: 214 signals:
214 void showDateView( int, QDate ); 215 void showDateView( int, QDate );
215 void newTodoSignal( QDateTime ,bool ); 216 void newTodoSignal( QDateTime ,bool );
216 void toggleExpand(); 217 void toggleExpand();
217 void selectWeekNum( int ); 218 void selectWeekNum( int );
218 void todoMoved( Todo *, int ); 219 void todoMoved( Todo *, int );
219 void incidenceChanged(Incidence * , int ); 220 void incidenceChanged(Incidence * , int );
220 // void cloneIncidenceSignal(Incidence *); 221 // void cloneIncidenceSignal(Incidence *);
221 222
222 protected: 223 protected:
223 KOAgendaButton* getNewDaylabel(); 224 KOAgendaButton* getNewDaylabel();
224 bool mBlockUpdating; 225 bool mBlockUpdating;
225 int mUpcomingWidth; 226 int mUpcomingWidth;
226 /** Fill agenda beginning with date startDate */ 227 /** Fill agenda beginning with date startDate */
227 void fillAgenda(const QDate &startDate); 228 void fillAgenda(const QDate &startDate);
228 void resizeEvent( QResizeEvent* e ); 229 void resizeEvent( QResizeEvent* e );
229 /** Fill agenda using the current set value for the start date */ 230 /** Fill agenda using the current set value for the start date */
230 void fillAgenda(); 231 void fillAgenda();
231 232
232 /** Create labels for the selected dates. */ 233 /** Create labels for the selected dates. */
233 void createDayLabels(); 234 void createDayLabels();
234 235
235 /** 236 /**
236 Set the masks on the agenda widgets indicating, which days are holidays. 237 Set the masks on the agenda widgets indicating, which days are holidays.
237 */ 238 */
238 void setHolidayMasks(); 239 void setHolidayMasks();
239 240
240 protected slots: 241 protected slots:
241 void slotDaylabelClicked( int ); 242 void slotDaylabelClicked( int );
242 /** Update event belonging to agenda item */ 243 /** Update event belonging to agenda item */
243 void updateEventDates(KOAgendaItem *item, int mode = -1); 244 void updateEventDates(KOAgendaItem *item, int mode = -1);
244 //void updateMovedTodo(); 245 //void updateMovedTodo();
245 246
246 void updateEventIndicatorTop(int newY); 247 void updateEventIndicatorTop(int newY);
247 void updateEventIndicatorBottom(int newY); 248 void updateEventIndicatorBottom(int newY);
248 249
249 /** Updates data for selected timespan */ 250 /** Updates data for selected timespan */
250 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 251 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
251 /** Updates data for selected timespan for all day event*/ 252 /** Updates data for selected timespan for all day event*/
252 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 253 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
253 254
254 private: 255 private:
255 // view widgets 256 // view widgets
256 QFrame *mDayLabels; 257 QFrame *mDayLabels;
257 QHBox *mDayLabelsFrame; 258 QHBox *mDayLabelsFrame;
258 QBoxLayout *mLayoutDayLabels; 259 QBoxLayout *mLayoutDayLabels;
259 QFrame *mAllDayFrame; 260 QFrame *mAllDayFrame;
260 KOAgenda *mAllDayAgenda; 261 KOAgenda *mAllDayAgenda;
261 KOAgenda *mAgenda; 262 KOAgenda *mAgenda;
262 TimeLabels *mTimeLabels; 263 TimeLabels *mTimeLabels;
263 QWidget *mDummyAllDayLeft; 264 QWidget *mDummyAllDayLeft;
264 265
265 KDGanttMinimizeSplitter* mSplitterAgenda; 266 KDGanttMinimizeSplitter* mSplitterAgenda;
266 QPushButton *mExpandButton; 267 QPushButton *mExpandButton;
267 268
268 DateList mSelectedDates; // List of dates to be displayed 269 DateList mSelectedDates; // List of dates to be displayed
269 int mViewType; 270 int mViewType;
270 271
271 bool mWeekStartsMonday; 272 bool mWeekStartsMonday;
272 int mStartHour; 273 int mStartHour;
273 274
274 KOEventPopupMenu *mAllAgendaPopup; 275 KOEventPopupMenu *mAllAgendaPopup;
275 //KOEventPopupMenu *mAllDayAgendaPopup; 276 //KOEventPopupMenu *mAllDayAgendaPopup;
276 277
277 EventIndicator *mEventIndicatorTop; 278 EventIndicator *mEventIndicatorTop;
278 EventIndicator *mEventIndicatorBottom; 279 EventIndicator *mEventIndicatorBottom;
279 280
280 QMemArray<int> mMinY; 281 QMemArray<int> mMinY;
281 QMemArray<int> mMaxY; 282 QMemArray<int> mMaxY;
282 283
283 QMemArray<bool> mHolidayMask; 284 QMemArray<bool> mHolidayMask;
284 285
285 QPtrList<KOAgendaButton> mDayLabelsList; 286 QPtrList<KOAgendaButton> mDayLabelsList;
286 QDateTime mTimeSpanBegin; 287 QDateTime mTimeSpanBegin;
287 QDateTime mTimeSpanEnd; 288 QDateTime mTimeSpanEnd;
288 bool mTimeSpanInAllDay; 289 bool mTimeSpanInAllDay;
289 void keyPressEvent ( QKeyEvent * e ); 290 void keyPressEvent ( QKeyEvent * e );
290}; 291};
291 292
292#endif // KOAGENDAVIEW_H 293#endif // KOAGENDAVIEW_H
diff --git a/korganizer/kojournalview.cpp b/korganizer/kojournalview.cpp
index 6e6a939..bc16037 100644
--- a/korganizer/kojournalview.cpp
+++ b/korganizer/kojournalview.cpp
@@ -1,112 +1,116 @@
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// 24//
25// View of Journal entries 25// View of Journal entries
26 26
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29 29
30#include <klocale.h> 30#include <klocale.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include "koprefs.h" 32#include "koprefs.h"
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35 35
36#include "journalentry.h" 36#include "journalentry.h"
37 37
38#include "kojournalview.h" 38#include "kojournalview.h"
39using namespace KOrg; 39using namespace KOrg;
40 40
41KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent, 41KOJournalView::KOJournalView(Calendar *calendar, QWidget *parent,
42 const char *name) 42 const char *name)
43 : KOrg::BaseView(calendar, parent, name) 43 : KOrg::BaseView(calendar, parent, name)
44{ 44{
45 mEntry = new JournalEntry(calendar,this); 45 mEntry = new JournalEntry(calendar,this);
46 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 46 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
47 QBoxLayout *topLayout = new QVBoxLayout(this); 47 QBoxLayout *topLayout = new QVBoxLayout(this);
48 topLayout->addWidget(mEntry); 48 topLayout->addWidget(mEntry);
49 connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ; 49 connect ( mEntry,SIGNAL(deleteJournal(Journal *) ),this ,SIGNAL(deleteJournal(Journal *) ) ) ;
50} 50}
51 51
52KOJournalView::~KOJournalView() 52KOJournalView::~KOJournalView()
53{ 53{
54} 54}
55 55
56int KOJournalView::currentDateCount() 56int KOJournalView::currentDateCount()
57{ 57{
58 return 0; 58 return 0;
59} 59}
60 60
61QPtrList<Incidence> KOJournalView::selectedIncidences() 61QPtrList<Incidence> KOJournalView::selectedIncidences()
62{ 62{
63 QPtrList<Incidence> eventList; 63 QPtrList<Incidence> eventList;
64 64
65 return eventList; 65 return eventList;
66} 66}
67void KOJournalView::updateConfig() 67void KOJournalView::updateConfig()
68{ 68{
69 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 69 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
70} 70}
71void KOJournalView::updateView() 71void KOJournalView::updateView()
72{ 72{
73 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont ); 73 mEntry->setFont ( KOPrefs::instance()->mJornalViewFont );
74} 74}
75 75
76void KOJournalView::flushView() 76void KOJournalView::flushView()
77{ 77{
78 mEntry->flushEntry(); 78 mEntry->flushEntry();
79} 79}
80 80
81void KOJournalView::clearList()
82{
83 mEntry->clear();
84}
81void KOJournalView::showDates(const QDate &start, const QDate &) 85void KOJournalView::showDates(const QDate &start, const QDate &)
82{ 86{
83// kdDebug() << "KOJournalView::selectDates()" << endl; 87// kdDebug() << "KOJournalView::selectDates()" << endl;
84 88
85 mEntry->setDate(start); 89 mEntry->setDate(start);
86 90
87 Journal *j = calendar()->journal(start); 91 Journal *j = calendar()->journal(start);
88 if (j) mEntry->setJournal(j); 92 if (j) mEntry->setJournal(j);
89 else mEntry->clear(); 93 else mEntry->clear();
90 94
91// emit incidenceSelected( 0 ); 95// emit incidenceSelected( 0 );
92} 96}
93 97
94void KOJournalView::showEvents(QPtrList<Event>) 98void KOJournalView::showEvents(QPtrList<Event>)
95{ 99{
96 // After new creation of list view no events are selected. 100 // After new creation of list view no events are selected.
97// emit incidenceSelected( 0 ); 101// emit incidenceSelected( 0 );
98} 102}
99 103
100void KOJournalView::changeEventDisplay(Event *, int /*action*/) 104void KOJournalView::changeEventDisplay(Event *, int /*action*/)
101{ 105{
102 updateView(); 106 updateView();
103} 107}
104 108
105void KOJournalView::keyPressEvent ( QKeyEvent * e ) 109void KOJournalView::keyPressEvent ( QKeyEvent * e )
106{ 110{
107 //qDebug("keyPressEven "); 111 //qDebug("keyPressEven ");
108 if ( e->state() == Qt::ControlButton ) { 112 if ( e->state() == Qt::ControlButton ) {
109 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left ) 113 if ( e->key () == Qt::Key_Right || e->key () == Qt::Key_Left )
110 e->ignore(); 114 e->ignore();
111 } 115 }
112} 116}
diff --git a/korganizer/kojournalview.h b/korganizer/kojournalview.h
index 1c0be82..445f940 100644
--- a/korganizer/kojournalview.h
+++ b/korganizer/kojournalview.h
@@ -1,67 +1,68 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef _KOJOURNALVIEW_H 23#ifndef _KOJOURNALVIEW_H
24#define _KOJOURNALVIEW_H 24#define _KOJOURNALVIEW_H
25 25
26#include <korganizer/baseview.h> 26#include <korganizer/baseview.h>
27 27
28class JournalEntry; 28class JournalEntry;
29 29
30/** 30/**
31 * This class provides a journal view. 31 * This class provides a journal view.
32 32
33 * @short View for Journal components. 33 * @short View for Journal components.
34 * @author Cornelius Schumacher <schumacher@kde.org> 34 * @author Cornelius Schumacher <schumacher@kde.org>
35 * @see KOBaseView 35 * @see KOBaseView
36 */ 36 */
37class KOJournalView : public KOrg::BaseView 37class KOJournalView : public KOrg::BaseView
38{ 38{
39 Q_OBJECT 39 Q_OBJECT
40 public: 40 public:
41 KOJournalView(Calendar *calendar, QWidget *parent = 0, 41 KOJournalView(Calendar *calendar, QWidget *parent = 0,
42 const char *name = 0); 42 const char *name = 0);
43 ~KOJournalView(); 43 ~KOJournalView();
44 44
45 virtual int currentDateCount(); 45 virtual int currentDateCount();
46 void clearList();
46 virtual QPtrList<Incidence> selectedIncidences(); 47 virtual QPtrList<Incidence> selectedIncidences();
47 DateList selectedDates() 48 DateList selectedDates()
48 {DateList q; 49 {DateList q;
49 return q;}; 50 return q;};
50 signals: 51 signals:
51 void deleteJournal(Journal *); 52 void deleteJournal(Journal *);
52 public slots: 53 public slots:
53 void updateView(); 54 void updateView();
54 void flushView(); 55 void flushView();
55 void updateConfig(); 56 void updateConfig();
56 void showDates( const QDate &start, const QDate &end ); 57 void showDates( const QDate &start, const QDate &end );
57 void showEvents(QPtrList<Event> eventList); 58 void showEvents(QPtrList<Event> eventList);
58 59
59 void changeEventDisplay(Event *, int); 60 void changeEventDisplay(Event *, int);
60 61
61 private: 62 private:
62 JournalEntry *mEntry; 63 JournalEntry *mEntry;
63 void keyPressEvent ( QKeyEvent * ) ; 64 void keyPressEvent ( QKeyEvent * ) ;
64 65
65}; 66};
66 67
67#endif 68#endif
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 5f32e79..bc52281 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1285 +1,1289 @@
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 37
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kglobal.h> 41#include <kglobal.h>
42 42
43#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
44#include <libkcal/calendar.h> 44#include <libkcal/calendar.h>
45#include <libkcal/calendarlocal.h> 45#include <libkcal/calendarlocal.h>
46#include <libkcal/icalformat.h> 46#include <libkcal/icalformat.h>
47#include <libkcal/vcalformat.h> 47#include <libkcal/vcalformat.h>
48#include <libkcal/recurrence.h> 48#include <libkcal/recurrence.h>
49#include <libkcal/filestorage.h> 49#include <libkcal/filestorage.h>
50#include <libkdepim/categoryselectdialog.h> 50#include <libkdepim/categoryselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57 57
58#ifndef KORG_NOPRINTER 58#ifndef KORG_NOPRINTER
59#include "calprinter.h" 59#include "calprinter.h"
60#endif 60#endif
61#include "koglobals.h" 61#include "koglobals.h"
62#include "koprefs.h" 62#include "koprefs.h"
63#include "kfiledialog.h" 63#include "kfiledialog.h"
64 64
65#include "kolistview.h" 65#include "kolistview.h"
66 66
67 67
68 68
69 69
70class KOListViewWhatsThis :public QWhatsThis 70class KOListViewWhatsThis :public QWhatsThis
71{ 71{
72public: 72public:
73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
74 74
75protected: 75protected:
76 virtual QString text( const QPoint& p) 76 virtual QString text( const QPoint& p)
77 { 77 {
78 return _view->getWhatsThisText(p) ; 78 return _view->getWhatsThisText(p) ;
79 } 79 }
80private: 80private:
81 QWidget* _wid; 81 QWidget* _wid;
82 KOListView * _view; 82 KOListView * _view;
83}; 83};
84 84
85 85
86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
87{ 87{
88 mItem = item; 88 mItem = item;
89 mDate = date; 89 mDate = date;
90} 90}
91 91
92ListItemVisitor::~ListItemVisitor() 92ListItemVisitor::~ListItemVisitor()
93{ 93{
94} 94}
95 95
96bool ListItemVisitor::visit(Event *e) 96bool ListItemVisitor::visit(Event *e)
97{ 97{
98 bool ok = false; 98 bool ok = false;
99 QString start, end; 99 QString start, end;
100 QDate ds, de; 100 QDate ds, de;
101 if ( e->doesRecur() ) { 101 if ( e->doesRecur() ) {
102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
103 if ( ok ) { 103 if ( ok ) {
104 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 104 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
105 start = KGlobal::locale()->formatDate(ds,true); 105 start = KGlobal::locale()->formatDate(ds,true);
106 de = ds.addDays( days); 106 de = ds.addDays( days);
107 end = KGlobal::locale()->formatDate(de,true); 107 end = KGlobal::locale()->formatDate(de,true);
108 } 108 }
109 109
110 } 110 }
111 if ( ! ok ) { 111 if ( ! ok ) {
112 start =e->dtStartDateStr(); 112 start =e->dtStartDateStr();
113 end = e->dtEndDateStr(); 113 end = e->dtEndDateStr();
114 ds = e->dtStart().date(); 114 ds = e->dtStart().date();
115 de = e->dtEnd().date(); 115 de = e->dtEnd().date();
116 } 116 }
117 mItem->setText(0,e->summary()); 117 mItem->setText(0,e->summary());
118 mItem->setText(1,start); 118 mItem->setText(1,start);
119 if ( e->doesFloat() ) 119 if ( e->doesFloat() )
120 mItem->setText(2,"---"); 120 mItem->setText(2,"---");
121 else 121 else
122 mItem->setText(2,e->dtStartTimeStr()); 122 mItem->setText(2,e->dtStartTimeStr());
123 mItem->setText(3,end); 123 mItem->setText(3,end);
124 if ( e->doesFloat() ) 124 if ( e->doesFloat() )
125 mItem->setText(4,"---"); 125 mItem->setText(4,"---");
126 else 126 else
127 mItem->setText(4,e->dtEndTimeStr()); 127 mItem->setText(4,e->dtEndTimeStr());
128 if ( e->isAlarmEnabled() ) { 128 if ( e->isAlarmEnabled() ) {
129 mItem->setText(5,e->alarms().first()->offsetText() ); 129 mItem->setText(5,e->alarms().first()->offsetText() );
130 } else { 130 } else {
131 mItem->setText(5, i18n("No")); 131 mItem->setText(5, i18n("No"));
132 } 132 }
133 mItem->setText(6, e->recurrence()->recurrenceText()); 133 mItem->setText(6, e->recurrence()->recurrenceText());
134 if( ! e->doesRecur() ) 134 if( ! e->doesRecur() )
135 mItem->setSortKey( 6, "-" ); 135 mItem->setSortKey( 6, "-" );
136 mItem->setText(7,"---"); 136 mItem->setText(7,"---");
137 mItem->setText(8,"---"); 137 mItem->setText(8,"---");
138 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 138 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
139 mItem->setText(10,e->categoriesStr()); 139 mItem->setText(10,e->categoriesStr());
140 140
141 QString key; 141 QString key;
142 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 142 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
143 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 143 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
144 mItem->setSortKey(1,key); 144 mItem->setSortKey(1,key);
145 145
146 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 146 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
147 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 147 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
148 mItem->setSortKey(3,key); 148 mItem->setSortKey(3,key);
149 return true; 149 return true;
150} 150}
151 151
152bool ListItemVisitor::visit(Todo *t) 152bool ListItemVisitor::visit(Todo *t)
153{ 153{
154 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 154 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
155 if (t->hasStartDate()) { 155 if (t->hasStartDate()) {
156 mItem->setText(1,t->dtStartDateStr()); 156 mItem->setText(1,t->dtStartDateStr());
157 if (t->doesFloat()) { 157 if (t->doesFloat()) {
158 mItem->setText(2,"---"); 158 mItem->setText(2,"---");
159 } else { 159 } else {
160 mItem->setText(2,t->dtStartTimeStr()); 160 mItem->setText(2,t->dtStartTimeStr());
161 } 161 }
162 } else { 162 } else {
163 mItem->setText(1,"---"); 163 mItem->setText(1,"---");
164 mItem->setText(2,"---"); 164 mItem->setText(2,"---");
165 } 165 }
166 mItem->setText(3,"---"); 166 mItem->setText(3,"---");
167 mItem->setText(4,"---"); 167 mItem->setText(4,"---");
168 if ( t->isAlarmEnabled() ) { 168 if ( t->isAlarmEnabled() ) {
169 mItem->setText(5,t->alarms().first()->offsetText() ); 169 mItem->setText(5,t->alarms().first()->offsetText() );
170 } else { 170 } else {
171 mItem->setText(5, i18n("No")); 171 mItem->setText(5, i18n("No"));
172 } 172 }
173 mItem->setText(6, t->recurrence()->recurrenceText()); 173 mItem->setText(6, t->recurrence()->recurrenceText());
174 if( ! t->doesRecur() ) 174 if( ! t->doesRecur() )
175 mItem->setSortKey( 6, "-" ); 175 mItem->setSortKey( 6, "-" );
176 if (t->hasDueDate()) { 176 if (t->hasDueDate()) {
177 mItem->setText(7,t->dtDueDateStr()); 177 mItem->setText(7,t->dtDueDateStr());
178 if (t->doesFloat()) { 178 if (t->doesFloat()) {
179 mItem->setText(8,"---"); 179 mItem->setText(8,"---");
180 } else { 180 } else {
181 mItem->setText(8,t->dtDueTimeStr()); 181 mItem->setText(8,t->dtDueTimeStr());
182 } 182 }
183 } else { 183 } else {
184 mItem->setText(7,"---"); 184 mItem->setText(7,"---");
185 mItem->setText(8,"---"); 185 mItem->setText(8,"---");
186 } 186 }
187 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 187 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
188 mItem->setText(10,t->categoriesStr()); 188 mItem->setText(10,t->categoriesStr());
189 189
190 QString key; 190 QString key;
191 QDate d; 191 QDate d;
192 if (t->hasDueDate()) { 192 if (t->hasDueDate()) {
193 d = t->dtDue().date(); 193 d = t->dtDue().date();
194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
196 mItem->setSortKey(7,key); 196 mItem->setSortKey(7,key);
197 } 197 }
198 if ( t->hasStartDate() ) { 198 if ( t->hasStartDate() ) {
199 d = t->dtStart().date(); 199 d = t->dtStart().date();
200 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 200 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
201 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 201 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
202 mItem->setSortKey(1,key); 202 mItem->setSortKey(1,key);
203 } 203 }
204 return true; 204 return true;
205} 205}
206 206
207bool ListItemVisitor::visit(Journal * j) 207bool ListItemVisitor::visit(Journal * j)
208{ 208{
209 QString des = j->description().left(30); 209 QString des = j->description().left(30);
210 des = des.simplifyWhiteSpace (); 210 des = des.simplifyWhiteSpace ();
211 des.replace (QRegExp ("\\n"),"" ); 211 des.replace (QRegExp ("\\n"),"" );
212 des.replace (QRegExp ("\\r"),"" ); 212 des.replace (QRegExp ("\\r"),"" );
213 mItem->setText(0,i18n("Journal: ")+des.left(25)); 213 mItem->setText(0,i18n("Journal: ")+des.left(25));
214 mItem->setText(1,j->dtStartDateStr()); 214 mItem->setText(1,j->dtStartDateStr());
215 mItem->setText(2,"---"); 215 mItem->setText(2,"---");
216 mItem->setText(3,"---"); 216 mItem->setText(3,"---");
217 mItem->setText(4,"---"); 217 mItem->setText(4,"---");
218 mItem->setText(5,"---"); 218 mItem->setText(5,"---");
219 mItem->setText(6,"---"); 219 mItem->setText(6,"---");
220 mItem->setText(7,j->dtStartDateStr()); 220 mItem->setText(7,j->dtStartDateStr());
221 mItem->setText(8,"---"); 221 mItem->setText(8,"---");
222 mItem->setText(9,"---"); 222 mItem->setText(9,"---");
223 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 223 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
224 224
225 QString key; 225 QString key;
226 QDate d = j->dtStart().date(); 226 QDate d = j->dtStart().date();
227 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 227 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
228 mItem->setSortKey(1,key); 228 mItem->setSortKey(1,key);
229 mItem->setSortKey(7,key); 229 mItem->setSortKey(7,key);
230 230
231 return true; 231 return true;
232} 232}
233 233
234KOListView::KOListView(Calendar *calendar, QWidget *parent, 234KOListView::KOListView(Calendar *calendar, QWidget *parent,
235 const char *name) 235 const char *name)
236 : KOEventView(calendar, parent, name) 236 : KOEventView(calendar, parent, name)
237{ 237{
238 mActiveItem = 0; 238 mActiveItem = 0;
239 mListView = new KOListViewListView(this); 239 mListView = new KOListViewListView(this);
240 mListView->addColumn(i18n("Summary")); 240 mListView->addColumn(i18n("Summary"));
241 mListView->addColumn(i18n("Start Date")); 241 mListView->addColumn(i18n("Start Date"));
242 mListView->addColumn(i18n("Start Time")); 242 mListView->addColumn(i18n("Start Time"));
243 mListView->addColumn(i18n("End Date")); 243 mListView->addColumn(i18n("End Date"));
244 mListView->addColumn(i18n("End Time")); 244 mListView->addColumn(i18n("End Time"));
245 mListView->addColumn(i18n("Alarm")); // alarm set? 245 mListView->addColumn(i18n("Alarm")); // alarm set?
246 mListView->addColumn(i18n("Recurs")); // recurs? 246 mListView->addColumn(i18n("Recurs")); // recurs?
247 mListView->addColumn(i18n("Due Date")); 247 mListView->addColumn(i18n("Due Date"));
248 mListView->addColumn(i18n("Due Time")); 248 mListView->addColumn(i18n("Due Time"));
249 mListView->addColumn(i18n("Cancelled")); 249 mListView->addColumn(i18n("Cancelled"));
250 mListView->addColumn(i18n("Categories")); 250 mListView->addColumn(i18n("Categories"));
251 251
252 mListView->setColumnAlignment(0,AlignLeft); 252 mListView->setColumnAlignment(0,AlignLeft);
253 mListView->setColumnAlignment(1,AlignLeft); 253 mListView->setColumnAlignment(1,AlignLeft);
254 mListView->setColumnAlignment(2,AlignHCenter); 254 mListView->setColumnAlignment(2,AlignHCenter);
255 mListView->setColumnAlignment(3,AlignLeft); 255 mListView->setColumnAlignment(3,AlignLeft);
256 mListView->setColumnAlignment(4,AlignHCenter); 256 mListView->setColumnAlignment(4,AlignHCenter);
257 mListView->setColumnAlignment(5,AlignLeft); 257 mListView->setColumnAlignment(5,AlignLeft);
258 mListView->setColumnAlignment(6,AlignLeft); 258 mListView->setColumnAlignment(6,AlignLeft);
259 mListView->setColumnAlignment(7,AlignLeft); 259 mListView->setColumnAlignment(7,AlignLeft);
260 mListView->setColumnAlignment(8,AlignLeft); 260 mListView->setColumnAlignment(8,AlignLeft);
261 mListView->setColumnAlignment(9,AlignLeft); 261 mListView->setColumnAlignment(9,AlignLeft);
262 mListView->setColumnAlignment(10,AlignLeft); 262 mListView->setColumnAlignment(10,AlignLeft);
263 mListView->setColumnWidthMode(10, QListView::Manual); 263 mListView->setColumnWidthMode(10, QListView::Manual);
264 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 264 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
265 265
266 int iii = 0; 266 int iii = 0;
267 for ( iii = 0; iii< 10 ; ++iii ) 267 for ( iii = 0; iii< 10 ; ++iii )
268 mListView->setColumnWidthMode( iii, QListView::Manual ); 268 mListView->setColumnWidthMode( iii, QListView::Manual );
269 269
270 QBoxLayout *layoutTop = new QVBoxLayout(this); 270 QBoxLayout *layoutTop = new QVBoxLayout(this);
271 layoutTop->addWidget(mListView); 271 layoutTop->addWidget(mListView);
272 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 272 mListView->setFont ( KOPrefs::instance()->mListViewFont );
273 mPopupMenu = eventPopup(); 273 mPopupMenu = eventPopup();
274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
275 i18n("Select all"),this, 275 i18n("Select all"),this,
276 SLOT(allSelection()),true); 276 SLOT(allSelection()),true);
277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
278 i18n("Deselect all"),this, 278 i18n("Deselect all"),this,
279 SLOT(clearSelection()),true); 279 SLOT(clearSelection()),true);
280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
281 i18n("Delete all selected"),this, 281 i18n("Delete all selected"),this,
282 SLOT(deleteAll()),true); 282 SLOT(deleteAll()),true);
283 mPopupMenu->insertSeparator(); 283 mPopupMenu->insertSeparator();
284 QPopupMenu * exportPO = new QPopupMenu ( this ); 284 QPopupMenu * exportPO = new QPopupMenu ( this );
285 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 285 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
286 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 286 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
287 SLOT(saveToFile())); 287 SLOT(saveToFile()));
288 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 288 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
289 SLOT(saveToFileVCS())); 289 SLOT(saveToFileVCS()));
290 exportPO->insertItem( i18n("Journal/Details..."),this, 290 exportPO->insertItem( i18n("Journal/Details..."),this,
291 SLOT(saveDescriptionToFile())); 291 SLOT(saveDescriptionToFile()));
292 // mPopupMenu->insertSeparator(); 292 // mPopupMenu->insertSeparator();
293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
294 i18n("Add Categ. to selected..."),this, 294 i18n("Add Categ. to selected..."),this,
295 SLOT(addCat()),true); 295 SLOT(addCat()),true);
296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 296 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
297 i18n("Set Categ. for selected..."),this, 297 i18n("Set Categ. for selected..."),this,
298 SLOT(setCat()),true); 298 SLOT(setCat()),true);
299 //mPopupMenu->insertSeparator(); 299 //mPopupMenu->insertSeparator();
300 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 300 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
301 i18n("Set alarm for selected..."),this, 301 i18n("Set alarm for selected..."),this,
302 SLOT(setAlarm()),true); 302 SLOT(setAlarm()),true);
303 303
304 304
305#ifndef DESKTOP_VERSION 305#ifndef DESKTOP_VERSION
306 mPopupMenu->insertSeparator(); 306 mPopupMenu->insertSeparator();
307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
308 i18n("Beam selected via IR"),this, 308 i18n("Beam selected via IR"),this,
309 SLOT(beamSelected()),true); 309 SLOT(beamSelected()),true);
310#endif 310#endif
311 /* 311 /*
312 mPopupMenu = new QPopupMenu; 312 mPopupMenu = new QPopupMenu;
313 mPopupMenu->insertItem(i18n("Edit Event"), this, 313 mPopupMenu->insertItem(i18n("Edit Event"), this,
314 SLOT (editEvent())); 314 SLOT (editEvent()));
315 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 315 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
316 SLOT (deleteEvent())); 316 SLOT (deleteEvent()));
317 mPopupMenu->insertSeparator(); 317 mPopupMenu->insertSeparator();
318 mPopupMenu->insertItem(i18n("Show Dates"), this, 318 mPopupMenu->insertItem(i18n("Show Dates"), this,
319 SLOT(showDates())); 319 SLOT(showDates()));
320 mPopupMenu->insertItem(i18n("Hide Dates"), this, 320 mPopupMenu->insertItem(i18n("Hide Dates"), this,
321 SLOT(hideDates())); 321 SLOT(hideDates()));
322 */ 322 */
323 QObject::connect(mListView,SIGNAL( newEvent()), 323 QObject::connect(mListView,SIGNAL( newEvent()),
324 this,SIGNAL(signalNewEvent())); 324 this,SIGNAL(signalNewEvent()));
325 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 325 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
326 this,SLOT(defaultItemAction(QListViewItem *))); 326 this,SLOT(defaultItemAction(QListViewItem *)));
327 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 327 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
328 const QPoint &, int )), 328 const QPoint &, int )),
329 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 329 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
330 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 330 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
331 SLOT(processSelectionChange(QListViewItem *))); 331 SLOT(processSelectionChange(QListViewItem *)));
332 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 332 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
333 SIGNAL(showIncidenceSignal(Incidence *)) ); 333 SIGNAL(showIncidenceSignal(Incidence *)) );
334 334
335 readSettings(KOGlobals::config(),"KOListView Layout"); 335 readSettings(KOGlobals::config(),"KOListView Layout");
336} 336}
337 337
338KOListView::~KOListView() 338KOListView::~KOListView()
339{ 339{
340 delete mPopupMenu; 340 delete mPopupMenu;
341#if QT_VERSION >= 0x030000 341#if QT_VERSION >= 0x030000
342 342
343#else 343#else
344 delete mKOListViewWhatsThis; 344 delete mKOListViewWhatsThis;
345#endif 345#endif
346} 346}
347 347
348QString KOListView::getWhatsThisText(QPoint p) 348QString KOListView::getWhatsThisText(QPoint p)
349{ 349{
350 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 350 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
351 if ( item ) 351 if ( item )
352 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 352 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
353 KOPrefs::instance()->mWTshowDetails, 353 KOPrefs::instance()->mWTshowDetails,
354 KOPrefs::instance()->mWTshowCreated, 354 KOPrefs::instance()->mWTshowCreated,
355 KOPrefs::instance()->mWTshowChanged); 355 KOPrefs::instance()->mWTshowChanged);
356 return i18n("That is the list view" ); 356 return i18n("That is the list view" );
357 357
358} 358}
359 359
360void KOListView::updateList() 360void KOListView::updateList()
361{ 361{
362 // qDebug(" KOListView::updateList() "); 362 // qDebug(" KOListView::updateList() ");
363 363
364} 364}
365 365
366void KOListView::clearList()
367{
368 clear ();
369}
366void KOListView::addCat( ) 370void KOListView::addCat( )
367{ 371{
368 setCategories( false ); 372 setCategories( false );
369} 373}
370void KOListView::setCat() 374void KOListView::setCat()
371{ 375{
372 setCategories( true ); 376 setCategories( true );
373} 377}
374void KOListView::setAlarm() 378void KOListView::setAlarm()
375{ 379{
376 KOAlarmPrefs kap( this); 380 KOAlarmPrefs kap( this);
377 if ( !kap.exec() ) 381 if ( !kap.exec() )
378 return; 382 return;
379 QStringList itemList; 383 QStringList itemList;
380 QPtrList<KOListViewItem> sel ; 384 QPtrList<KOListViewItem> sel ;
381 QListViewItem *qitem = mListView->firstChild (); 385 QListViewItem *qitem = mListView->firstChild ();
382 while ( qitem ) { 386 while ( qitem ) {
383 if ( qitem->isSelected() ) { 387 if ( qitem->isSelected() ) {
384 Incidence* inc = ((KOListViewItem *) qitem)->data(); 388 Incidence* inc = ((KOListViewItem *) qitem)->data();
385 if ( inc->type() != "Journal" ) { 389 if ( inc->type() != "Journal" ) {
386 if ( inc->type() == "Todo" ) { 390 if ( inc->type() == "Todo" ) {
387 if ( ((Todo*)inc)->hasDueDate() ) 391 if ( ((Todo*)inc)->hasDueDate() )
388 sel.append(((KOListViewItem *)qitem)); 392 sel.append(((KOListViewItem *)qitem));
389 } else 393 } else
390 sel.append(((KOListViewItem *)qitem)); 394 sel.append(((KOListViewItem *)qitem));
391 } 395 }
392 } 396 }
393 qitem = qitem->nextSibling(); 397 qitem = qitem->nextSibling();
394 } 398 }
395 int count = 0; 399 int count = 0;
396 KOListViewItem * item, *temp; 400 KOListViewItem * item, *temp;
397 item = sel.first(); 401 item = sel.first();
398 Incidence* inc; 402 Incidence* inc;
399 while ( item ) { 403 while ( item ) {
400 inc = item->data(); 404 inc = item->data();
401 ++count; 405 ++count;
402 if (kap.mAlarmButton->isChecked()) { 406 if (kap.mAlarmButton->isChecked()) {
403 if (inc->alarms().count() == 0) 407 if (inc->alarms().count() == 0)
404 inc->newAlarm(); 408 inc->newAlarm();
405 QPtrList<Alarm> alarms = inc->alarms(); 409 QPtrList<Alarm> alarms = inc->alarms();
406 Alarm *alarm; 410 Alarm *alarm;
407 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 411 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
408 alarm->setEnabled(true); 412 alarm->setEnabled(true);
409 int j = kap.mAlarmTimeEdit->value()* -60; 413 int j = kap.mAlarmTimeEdit->value()* -60;
410 if (kap.mAlarmIncrCombo->currentItem() == 1) 414 if (kap.mAlarmIncrCombo->currentItem() == 1)
411 j = j * 60; 415 j = j * 60;
412 else if (kap.mAlarmIncrCombo->currentItem() == 2) 416 else if (kap.mAlarmIncrCombo->currentItem() == 2)
413 j = j * (60 * 24); 417 j = j * (60 * 24);
414 alarm->setStartOffset( j ); 418 alarm->setStartOffset( j );
415 419
416 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 420 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
417 alarm->setProcedureAlarm(kap.mAlarmProgram); 421 alarm->setProcedureAlarm(kap.mAlarmProgram);
418 } 422 }
419 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 423 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
420 alarm->setAudioAlarm(kap.mAlarmSound); 424 alarm->setAudioAlarm(kap.mAlarmSound);
421 else 425 else
422 alarm->setType(Alarm::Invalid); 426 alarm->setType(Alarm::Invalid);
423 //alarm->setAudioAlarm("default"); 427 //alarm->setAudioAlarm("default");
424 // TODO: Deal with multiple alarms 428 // TODO: Deal with multiple alarms
425 break; // For now, stop after the first alarm 429 break; // For now, stop after the first alarm
426 } 430 }
427 } else { 431 } else {
428 Alarm* alarm = inc->alarms().first(); 432 Alarm* alarm = inc->alarms().first();
429 if ( alarm ) { 433 if ( alarm ) {
430 alarm->setEnabled(false); 434 alarm->setEnabled(false);
431 alarm->setType(Alarm::Invalid); 435 alarm->setType(Alarm::Invalid);
432 } 436 }
433 } 437 }
434 ListItemVisitor v(item, mStartDate ); 438 ListItemVisitor v(item, mStartDate );
435 inc->accept(v); 439 inc->accept(v);
436 item = sel.next(); 440 item = sel.next();
437 } 441 }
438 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 442 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
439 qDebug("KO: Set alarm for %d items", count); 443 qDebug("KO: Set alarm for %d items", count);
440 calendar()->reInitAlarmSettings(); 444 calendar()->reInitAlarmSettings();
441 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 445 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
442} 446}
443void KOListView::setCategories( bool removeOld ) 447void KOListView::setCategories( bool removeOld )
444{ 448{
445 449
446 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 450 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
447 csd->setColorEnabled(); 451 csd->setColorEnabled();
448 if (! csd->exec()) { 452 if (! csd->exec()) {
449 delete csd; 453 delete csd;
450 return; 454 return;
451 } 455 }
452 QStringList catList = csd->selectedCategories(); 456 QStringList catList = csd->selectedCategories();
453 delete csd; 457 delete csd;
454 // if ( catList.count() == 0 ) 458 // if ( catList.count() == 0 )
455 // return; 459 // return;
456 //catList.sort(); 460 //catList.sort();
457 QString categoriesStr = catList.join(","); 461 QString categoriesStr = catList.join(",");
458 int i; 462 int i;
459 QStringList itemList; 463 QStringList itemList;
460 QPtrList<KOListViewItem> sel ; 464 QPtrList<KOListViewItem> sel ;
461 QListViewItem *qitem = mListView->firstChild (); 465 QListViewItem *qitem = mListView->firstChild ();
462 while ( qitem ) { 466 while ( qitem ) {
463 if ( qitem->isSelected() ) { 467 if ( qitem->isSelected() ) {
464 sel.append(((KOListViewItem *)qitem)); 468 sel.append(((KOListViewItem *)qitem));
465 } 469 }
466 qitem = qitem->nextSibling(); 470 qitem = qitem->nextSibling();
467 } 471 }
468 KOListViewItem * item, *temp; 472 KOListViewItem * item, *temp;
469 item = sel.first(); 473 item = sel.first();
470 if( item ) { 474 if( item ) {
471 Incidence* inc = item->data() ; 475 Incidence* inc = item->data() ;
472 bool setSub = false; 476 bool setSub = false;
473 if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) { 477 if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) {
474 int result = KMessageBox::warningYesNoCancel(this, 478 int result = KMessageBox::warningYesNoCancel(this,
475 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), 479 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
476 i18n("Todo has subtodos"), 480 i18n("Todo has subtodos"),
477 i18n("Yes"), 481 i18n("Yes"),
478 i18n("No")); 482 i18n("No"));
479 if (result == KMessageBox::Cancel) item = 0; 483 if (result == KMessageBox::Cancel) item = 0;
480 if (result == KMessageBox::Yes) setSub = true; 484 if (result == KMessageBox::Yes) setSub = true;
481 } 485 }
482 while ( item ) { 486 while ( item ) {
483 inc = item->data(); 487 inc = item->data();
484 if ( removeOld ) { 488 if ( removeOld ) {
485 inc->setCategories( catList, setSub ); 489 inc->setCategories( catList, setSub );
486 } else { 490 } else {
487 inc->addCategories( catList, setSub ); 491 inc->addCategories( catList, setSub );
488 } 492 }
489 ListItemVisitor v(item, mStartDate ); 493 ListItemVisitor v(item, mStartDate );
490 inc->accept(v); 494 inc->accept(v);
491 item = sel.next(); 495 item = sel.next();
492 } 496 }
493 } 497 }
494 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 498 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
495} 499}
496 500
497void KOListView::beamSelected() 501void KOListView::beamSelected()
498{ 502{
499 int icount = 0; 503 int icount = 0;
500 QPtrList<Incidence> delSel ; 504 QPtrList<Incidence> delSel ;
501 QListViewItem *item = mListView->firstChild (); 505 QListViewItem *item = mListView->firstChild ();
502 while ( item ) { 506 while ( item ) {
503 if ( item->isSelected() ) { 507 if ( item->isSelected() ) {
504 delSel.append(((KOListViewItem *)item)->data()); 508 delSel.append(((KOListViewItem *)item)->data());
505 ++icount; 509 ++icount;
506 } 510 }
507 511
508 item = item->nextSibling(); 512 item = item->nextSibling();
509 } 513 }
510 if ( icount ) { 514 if ( icount ) {
511 emit beamIncidenceList( delSel ); 515 emit beamIncidenceList( delSel );
512 return; 516 return;
513 QString fn ; 517 QString fn ;
514 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 518 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
515 QString mes; 519 QString mes;
516 bool createbup = true; 520 bool createbup = true;
517 if ( createbup ) { 521 if ( createbup ) {
518 QString description = "\n"; 522 QString description = "\n";
519 CalendarLocal* cal = new CalendarLocal(); 523 CalendarLocal* cal = new CalendarLocal();
520 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 524 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
521 Incidence *incidence = delSel.first(); 525 Incidence *incidence = delSel.first();
522 while ( incidence ) { 526 while ( incidence ) {
523 Incidence *in = incidence->clone(); 527 Incidence *in = incidence->clone();
524 description += in->summary() + "\n"; 528 description += in->summary() + "\n";
525 cal->addIncidence( in ); 529 cal->addIncidence( in );
526 incidence = delSel.next(); 530 incidence = delSel.next();
527 } 531 }
528 FileStorage storage( cal, fn, new VCalFormat ); 532 FileStorage storage( cal, fn, new VCalFormat );
529 storage.save(); 533 storage.save();
530 delete cal; 534 delete cal;
531 mes = i18n("KO/Pi: Ready for beaming"); 535 mes = i18n("KO/Pi: Ready for beaming");
532 topLevelWidget()->setCaption(mes); 536 topLevelWidget()->setCaption(mes);
533 537
534#ifndef DESKTOP_VERSION 538#ifndef DESKTOP_VERSION
535 Ir *ir = new Ir( this ); 539 Ir *ir = new Ir( this );
536 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 540 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
537 ir->send( fn, description, "text/x-vCalendar" ); 541 ir->send( fn, description, "text/x-vCalendar" );
538#endif 542#endif
539 } 543 }
540 } 544 }
541} 545}
542void KOListView::beamDone( Ir *ir ) 546void KOListView::beamDone( Ir *ir )
543{ 547{
544#ifndef DESKTOP_VERSION 548#ifndef DESKTOP_VERSION
545 delete ir; 549 delete ir;
546#endif 550#endif
547 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 551 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
548} 552}
549 553
550void KOListView::saveDescriptionToFile() 554void KOListView::saveDescriptionToFile()
551{ 555{
552 556
553 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 557 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
554 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 558 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
555 i18n("Continue"), i18n("Cancel"), 0, 559 i18n("Continue"), i18n("Cancel"), 0,
556 0, 1 ); 560 0, 1 );
557 if ( result != 0 ) { 561 if ( result != 0 ) {
558 return; 562 return;
559 } 563 }
560 int icount = 0; 564 int icount = 0;
561 QPtrList<Incidence> delSel ; 565 QPtrList<Incidence> delSel ;
562 QListViewItem *item = mListView->firstChild (); 566 QListViewItem *item = mListView->firstChild ();
563 while ( item ) { 567 while ( item ) {
564 if ( item->isSelected() ) { 568 if ( item->isSelected() ) {
565 delSel.append(((KOListViewItem *)item)->data()); 569 delSel.append(((KOListViewItem *)item)->data());
566 ++icount; 570 ++icount;
567 } 571 }
568 572
569 item = item->nextSibling(); 573 item = item->nextSibling();
570 } 574 }
571 if ( icount ) { 575 if ( icount ) {
572 QString fn = KOPrefs::instance()->mLastSaveFile; 576 QString fn = KOPrefs::instance()->mLastSaveFile;
573 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 577 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
574 578
575 if ( fn == "" ) 579 if ( fn == "" )
576 return; 580 return;
577 QFileInfo info; 581 QFileInfo info;
578 info.setFile( fn ); 582 info.setFile( fn );
579 QString mes; 583 QString mes;
580 bool createbup = true; 584 bool createbup = true;
581 if ( info. exists() ) { 585 if ( info. exists() ) {
582 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 586 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
583 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 587 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
584 i18n("Overwrite!"), i18n("Cancel"), 0, 588 i18n("Overwrite!"), i18n("Cancel"), 0,
585 0, 1 ); 589 0, 1 );
586 if ( result != 0 ) { 590 if ( result != 0 ) {
587 createbup = false; 591 createbup = false;
588 } 592 }
589 } 593 }
590 if ( createbup ) { 594 if ( createbup ) {
591 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 595 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
592 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 596 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
593 Incidence *incidence = delSel.first(); 597 Incidence *incidence = delSel.first();
594 icount = 0; 598 icount = 0;
595 while ( incidence ) { 599 while ( incidence ) {
596 if ( incidence->type() == "Journal" ) { 600 if ( incidence->type() == "Journal" ) {
597 text += "\n************************************\n"; 601 text += "\n************************************\n";
598 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 602 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
599 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 603 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
600 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 604 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
601 ++icount; 605 ++icount;
602 606
603 } else { 607 } else {
604 if ( !incidence->description().isEmpty() ) { 608 if ( !incidence->description().isEmpty() ) {
605 text += "\n************************************\n"; 609 text += "\n************************************\n";
606 if ( incidence->type() == "Todo" ) 610 if ( incidence->type() == "Todo" )
607 text += i18n("To-Do: "); 611 text += i18n("To-Do: ");
608 text += incidence->summary(); 612 text += incidence->summary();
609 if ( incidence->hasStartDate() ) 613 if ( incidence->hasStartDate() )
610 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 614 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
611 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 615 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
612 if ( !incidence->location().isEmpty() ) 616 if ( !incidence->location().isEmpty() )
613 text += "\n" +i18n("Location: ") + incidence->location(); 617 text += "\n" +i18n("Location: ") + incidence->location();
614 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 618 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
615 ++icount; 619 ++icount;
616 620
617 } 621 }
618 } 622 }
619 incidence = delSel.next(); 623 incidence = delSel.next();
620 } 624 }
621 QFile file( fn ); 625 QFile file( fn );
622 if (!file.open( IO_WriteOnly ) ) { 626 if (!file.open( IO_WriteOnly ) ) {
623 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 627 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
624 return; 628 return;
625 } 629 }
626 QTextStream ts( &file ); 630 QTextStream ts( &file );
627 ts << text; 631 ts << text;
628 file.close(); 632 file.close();
629 //qDebug("%s ", text.latin1()); 633 //qDebug("%s ", text.latin1());
630 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 634 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
631 KOPrefs::instance()->mLastSaveFile = fn; 635 KOPrefs::instance()->mLastSaveFile = fn;
632 topLevelWidget()->setCaption(mes); 636 topLevelWidget()->setCaption(mes);
633 } 637 }
634 } 638 }
635} 639}
636void KOListView::saveToFileVCS() 640void KOListView::saveToFileVCS()
637{ 641{
638 writeToFile( false ); 642 writeToFile( false );
639} 643}
640void KOListView::saveToFile() 644void KOListView::saveToFile()
641{ 645{
642 writeToFile( true ); 646 writeToFile( true );
643} 647}
644void KOListView::writeToFile( bool iCal ) 648void KOListView::writeToFile( bool iCal )
645{ 649{
646 650
647 int icount = 0; 651 int icount = 0;
648 QPtrList<Incidence> delSel ; 652 QPtrList<Incidence> delSel ;
649 QListViewItem *item = mListView->firstChild (); 653 QListViewItem *item = mListView->firstChild ();
650 bool journal = iCal; // warn only for vCal 654 bool journal = iCal; // warn only for vCal
651 while ( item ) { 655 while ( item ) {
652 if ( item->isSelected() ) { 656 if ( item->isSelected() ) {
653 if ( !journal ) 657 if ( !journal )
654 if ( ((KOListViewItem *)item)->data()->type() == "Journal") 658 if ( ((KOListViewItem *)item)->data()->type() == "Journal")
655 journal = true; 659 journal = true;
656 delSel.append(((KOListViewItem *)item)->data()); 660 delSel.append(((KOListViewItem *)item)->data());
657 ++icount; 661 ++icount;
658 } 662 }
659 663
660 item = item->nextSibling(); 664 item = item->nextSibling();
661 } 665 }
662 if ( !iCal && journal ) { 666 if ( !iCal && journal ) {
663 int result = KMessageBox::warningContinueCancel(this, 667 int result = KMessageBox::warningContinueCancel(this,
664 i18n("The journal entries can not be\nexported to a vCalendar file."), 668 i18n("The journal entries can not be\nexported to a vCalendar file."),
665 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 669 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
666 true); 670 true);
667 if (result != KMessageBox::Continue) return; 671 if (result != KMessageBox::Continue) return;
668 } 672 }
669 if ( icount ) { 673 if ( icount ) {
670 QString fn = KOPrefs::instance()->mLastSaveFile; 674 QString fn = KOPrefs::instance()->mLastSaveFile;
671 QString extension; 675 QString extension;
672 if ( iCal ) { 676 if ( iCal ) {
673 if ( fn.right( 4 ).lower() == ".vcs" ) { 677 if ( fn.right( 4 ).lower() == ".vcs" ) {
674 fn = fn.left( fn.length() -3) + "ics"; 678 fn = fn.left( fn.length() -3) + "ics";
675 } 679 }
676 } else { 680 } else {
677 if ( fn.right( 4 ).lower() == ".ics" ) { 681 if ( fn.right( 4 ).lower() == ".ics" ) {
678 fn = fn.left( fn.length() -3) + "vcs"; 682 fn = fn.left( fn.length() -3) + "vcs";
679 } 683 }
680 } 684 }
681 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 685 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
682 686
683 if ( fn == "" ) 687 if ( fn == "" )
684 return; 688 return;
685 QFileInfo info; 689 QFileInfo info;
686 info.setFile( fn ); 690 info.setFile( fn );
687 QString mes; 691 QString mes;
688 bool createbup = true; 692 bool createbup = true;
689 if ( info. exists() ) { 693 if ( info. exists() ) {
690 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 694 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
691 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 695 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
692 i18n("Overwrite!"), i18n("Cancel"), 0, 696 i18n("Overwrite!"), i18n("Cancel"), 0,
693 0, 1 ); 697 0, 1 );
694 if ( result != 0 ) { 698 if ( result != 0 ) {
695 createbup = false; 699 createbup = false;
696 } 700 }
697 } 701 }
698 if ( createbup ) { 702 if ( createbup ) {
699 CalendarLocal cal; 703 CalendarLocal cal;
700 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 704 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
701 Incidence *incidence = delSel.first(); 705 Incidence *incidence = delSel.first();
702 while ( incidence ) { 706 while ( incidence ) {
703 cal.addIncidence( incidence->clone() ); 707 cal.addIncidence( incidence->clone() );
704 incidence = delSel.next(); 708 incidence = delSel.next();
705 } 709 }
706 if ( iCal ) { 710 if ( iCal ) {
707 ICalFormat format; 711 ICalFormat format;
708 format.save( &cal, fn ); 712 format.save( &cal, fn );
709 } else { 713 } else {
710 714
711 VCalFormat format; 715 VCalFormat format;
712 format.save( &cal, fn ); 716 format.save( &cal, fn );
713 } 717 }
714 mes = i18n("KO/Pi:Saved %1").arg(fn ); 718 mes = i18n("KO/Pi:Saved %1").arg(fn );
715 KOPrefs::instance()->mLastSaveFile = fn; 719 KOPrefs::instance()->mLastSaveFile = fn;
716 topLevelWidget()->setCaption(mes); 720 topLevelWidget()->setCaption(mes);
717 } 721 }
718 } 722 }
719 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 723 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
720} 724}
721void KOListView::deleteAll() 725void KOListView::deleteAll()
722{ 726{
723 int icount = 0; 727 int icount = 0;
724 QPtrList<Incidence> delSel ; 728 QPtrList<Incidence> delSel ;
725 QListViewItem *item = mListView->firstChild (); 729 QListViewItem *item = mListView->firstChild ();
726 while ( item ) { 730 while ( item ) {
727 if ( item->isSelected() ) { 731 if ( item->isSelected() ) {
728 delSel.append(((KOListViewItem *)item)->data()); 732 delSel.append(((KOListViewItem *)item)->data());
729 ++icount; 733 ++icount;
730 } 734 }
731 735
732 item = item->nextSibling(); 736 item = item->nextSibling();
733 } 737 }
734 if ( icount ) { 738 if ( icount ) {
735 Incidence *incidence = delSel.first(); 739 Incidence *incidence = delSel.first();
736 Incidence *toDelete; 740 Incidence *toDelete;
737 KOPrefs *p = KOPrefs::instance(); 741 KOPrefs *p = KOPrefs::instance();
738 bool confirm = p->mConfirm; 742 bool confirm = p->mConfirm;
739 QString mess; 743 QString mess;
740 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 744 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
741 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")) ) { 745 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")) ) {
742 p->mConfirm = false; 746 p->mConfirm = false;
743 int delCounter = 0; 747 int delCounter = 0;
744 QDialog dia ( this, "p-dialog", true ); 748 QDialog dia ( this, "p-dialog", true );
745 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 749 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
746 QVBoxLayout lay( &dia ); 750 QVBoxLayout lay( &dia );
747 lay.setMargin(7); 751 lay.setMargin(7);
748 lay.setSpacing(7); 752 lay.setSpacing(7);
749 lay.addWidget( &lab); 753 lay.addWidget( &lab);
750 QProgressBar bar( icount, &dia ); 754 QProgressBar bar( icount, &dia );
751 lay.addWidget( &bar); 755 lay.addWidget( &bar);
752 int w = 220; 756 int w = 220;
753 int h = 50; 757 int h = 50;
754 int dw = QApplication::desktop()->width(); 758 int dw = QApplication::desktop()->width();
755 int dh = QApplication::desktop()->height(); 759 int dh = QApplication::desktop()->height();
756 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 760 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
757 //dia.resize( 240,50 ); 761 //dia.resize( 240,50 );
758 dia.show(); 762 dia.show();
759 763
760 while ( incidence ) { 764 while ( incidence ) {
761 bar.setProgress( delCounter ); 765 bar.setProgress( delCounter );
762 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 766 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
763 dia.setCaption( mess ); 767 dia.setCaption( mess );
764 qApp->processEvents(); 768 qApp->processEvents();
765 toDelete = (incidence); 769 toDelete = (incidence);
766 incidence = delSel.next(); 770 incidence = delSel.next();
767 emit deleteIncidenceSignal(toDelete ); 771 emit deleteIncidenceSignal(toDelete );
768 if ( dia.result() != 0 ) 772 if ( dia.result() != 0 )
769 break; 773 break;
770 774
771 } 775 }
772 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 776 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
773 topLevelWidget ()->setCaption( mess ); 777 topLevelWidget ()->setCaption( mess );
774 p->mConfirm = confirm; 778 p->mConfirm = confirm;
775 } 779 }
776 } 780 }
777 781
778 782
779} 783}
780int KOListView::maxDatesHint() 784int KOListView::maxDatesHint()
781{ 785{
782 return 0; 786 return 0;
783} 787}
784 788
785int KOListView::currentDateCount() 789int KOListView::currentDateCount()
786{ 790{
787 return 0; 791 return 0;
788} 792}
789 793
790QPtrList<Incidence> KOListView::selectedIncidences() 794QPtrList<Incidence> KOListView::selectedIncidences()
791{ 795{
792 QPtrList<Incidence> eventList; 796 QPtrList<Incidence> eventList;
793 QListViewItem *item = mListView->firstChild (); 797 QListViewItem *item = mListView->firstChild ();
794 while ( item ) { 798 while ( item ) {
795 if ( item->isSelected() ) { 799 if ( item->isSelected() ) {
796 eventList.append(((KOListViewItem *)item)->data()); 800 eventList.append(((KOListViewItem *)item)->data());
797 } 801 }
798 802
799 item = item->nextSibling(); 803 item = item->nextSibling();
800 } 804 }
801 805
802 // // QListViewItem *item = mListView->selectedItem(); 806 // // QListViewItem *item = mListView->selectedItem();
803 //if (item) eventList.append(((KOListViewItem *)item)->data()); 807 //if (item) eventList.append(((KOListViewItem *)item)->data());
804 808
805 return eventList; 809 return eventList;
806} 810}
807 811
808DateList KOListView::selectedDates() 812DateList KOListView::selectedDates()
809{ 813{
810 DateList eventList; 814 DateList eventList;
811 return eventList; 815 return eventList;
812} 816}
813 817
814void KOListView::showDates(bool show) 818void KOListView::showDates(bool show)
815{ 819{
816 // Shouldn't we set it to a value greater 0? When showDates is called with 820 // Shouldn't we set it to a value greater 0? When showDates is called with
817 // show == true at first, then the columnwidths are set to zero. 821 // show == true at first, then the columnwidths are set to zero.
818 static int oldColWidth1 = 0; 822 static int oldColWidth1 = 0;
819 static int oldColWidth3 = 0; 823 static int oldColWidth3 = 0;
820 824
821 if (!show) { 825 if (!show) {
822 oldColWidth1 = mListView->columnWidth(1); 826 oldColWidth1 = mListView->columnWidth(1);
823 oldColWidth3 = mListView->columnWidth(3); 827 oldColWidth3 = mListView->columnWidth(3);
824 mListView->setColumnWidth(1, 0); 828 mListView->setColumnWidth(1, 0);
825 mListView->setColumnWidth(3, 0); 829 mListView->setColumnWidth(3, 0);
826 } else { 830 } else {
827 mListView->setColumnWidth(1, oldColWidth1); 831 mListView->setColumnWidth(1, oldColWidth1);
828 mListView->setColumnWidth(3, oldColWidth3); 832 mListView->setColumnWidth(3, oldColWidth3);
829 } 833 }
830 mListView->repaint(); 834 mListView->repaint();
831} 835}
832 836
833void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 837void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
834 const QDate &td) 838 const QDate &td)
835{ 839{
836#ifndef KORG_NOPRINTER 840#ifndef KORG_NOPRINTER
837 calPrinter->preview(CalPrinter::Day, fd, td); 841 calPrinter->preview(CalPrinter::Day, fd, td);
838#endif 842#endif
839} 843}
840 844
841void KOListView::showDates() 845void KOListView::showDates()
842{ 846{
843 showDates(true); 847 showDates(true);
844} 848}
845 849
846void KOListView::hideDates() 850void KOListView::hideDates()
847{ 851{
848 showDates(false); 852 showDates(false);
849} 853}
850 854
851void KOListView::resetFocus() 855void KOListView::resetFocus()
852{ 856{
853 topLevelWidget()->setActiveWindow(); 857 topLevelWidget()->setActiveWindow();
854 topLevelWidget()->raise(); 858 topLevelWidget()->raise();
855 mListView->setFocus(); 859 mListView->setFocus();
856} 860}
857void KOListView::updateView() 861void KOListView::updateView()
858{ 862{
859 mListView->setFocus(); 863 mListView->setFocus();
860 if ( mListView->firstChild () ) 864 if ( mListView->firstChild () )
861 mListView->setCurrentItem( mListView->firstChild () ); 865 mListView->setCurrentItem( mListView->firstChild () );
862} 866}
863void KOListView::updateConfig() 867void KOListView::updateConfig()
864{ 868{
865 869
866 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 870 mListView->setFont ( KOPrefs::instance()->mListViewFont );
867 updateView(); 871 updateView();
868 872
869} 873}
870void KOListView::setStartDate(const QDate &start) 874void KOListView::setStartDate(const QDate &start)
871{ 875{
872 mStartDate = start; 876 mStartDate = start;
873} 877}
874 878
875void KOListView::showDates(const QDate &start, const QDate &end) 879void KOListView::showDates(const QDate &start, const QDate &end)
876{ 880{
877 clear(); 881 clear();
878 mStartDate = start; 882 mStartDate = start;
879 QDate date = start; 883 QDate date = start;
880 QPtrList<Journal> j_list; 884 QPtrList<Journal> j_list;
881 while( date <= end ) { 885 while( date <= end ) {
882 addEvents(calendar()->events(date)); 886 addEvents(calendar()->events(date));
883 addTodos(calendar()->todos(date)); 887 addTodos(calendar()->todos(date));
884 Journal* jo = calendar()->journal(date); 888 Journal* jo = calendar()->journal(date);
885 if ( jo ) 889 if ( jo )
886 j_list.append( jo ); 890 j_list.append( jo );
887 date = date.addDays( 1 ); 891 date = date.addDays( 1 );
888 } 892 }
889 addJournals(j_list); 893 addJournals(j_list);
890 emit incidenceSelected( 0 ); 894 emit incidenceSelected( 0 );
891 updateView(); 895 updateView();
892 896
893} 897}
894 898
895void KOListView::addEvents(QPtrList<Event> eventList) 899void KOListView::addEvents(QPtrList<Event> eventList)
896{ 900{
897 901
898 Event *ev; 902 Event *ev;
899 for(ev = eventList.first(); ev; ev = eventList.next()) { 903 for(ev = eventList.first(); ev; ev = eventList.next()) {
900 addIncidence(ev); 904 addIncidence(ev);
901 } 905 }
902 if ( !mListView->currentItem() ){ 906 if ( !mListView->currentItem() ){
903 updateView(); 907 updateView();
904 } 908 }
905} 909}
906 910
907void KOListView::addTodos(QPtrList<Todo> eventList) 911void KOListView::addTodos(QPtrList<Todo> eventList)
908{ 912{
909 Todo *ev; 913 Todo *ev;
910 for(ev = eventList.first(); ev; ev = eventList.next()) { 914 for(ev = eventList.first(); ev; ev = eventList.next()) {
911 addIncidence(ev); 915 addIncidence(ev);
912 } 916 }
913 if ( !mListView->currentItem() ){ 917 if ( !mListView->currentItem() ){
914 updateView(); 918 updateView();
915 } 919 }
916} 920}
917void KOListView::addJournals(QPtrList<Journal> eventList) 921void KOListView::addJournals(QPtrList<Journal> eventList)
918{ 922{
919 Journal *ev; 923 Journal *ev;
920 for(ev = eventList.first(); ev; ev = eventList.next()) { 924 for(ev = eventList.first(); ev; ev = eventList.next()) {
921 addIncidence(ev); 925 addIncidence(ev);
922 } 926 }
923 if ( !mListView->currentItem() ){ 927 if ( !mListView->currentItem() ){
924 updateView(); 928 updateView();
925 } 929 }
926} 930}
927 931
928void KOListView::addIncidence(Incidence *incidence) 932void KOListView::addIncidence(Incidence *incidence)
929{ 933{
930 if ( mUidDict.find( incidence->uid() ) ) return; 934 if ( mUidDict.find( incidence->uid() ) ) return;
931 935
932 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 936 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
933 mUidDict.insert( incidence->uid(), incidence ); 937 mUidDict.insert( incidence->uid(), incidence );
934 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 938 KOListViewItem *item = new KOListViewItem( incidence, mListView );
935 ListItemVisitor v(item, mStartDate ); 939 ListItemVisitor v(item, mStartDate );
936 if (incidence->accept(v)) { 940 if (incidence->accept(v)) {
937 return; 941 return;
938 } 942 }
939 else delete item; 943 else delete item;
940} 944}
941 945
942void KOListView::showEvents(QPtrList<Event> eventList) 946void KOListView::showEvents(QPtrList<Event> eventList)
943{ 947{
944 clear(); 948 clear();
945 949
946 addEvents(eventList); 950 addEvents(eventList);
947 951
948 // After new creation of list view no events are selected. 952 // After new creation of list view no events are selected.
949 emit incidenceSelected( 0 ); 953 emit incidenceSelected( 0 );
950} 954}
951int KOListView::count() 955int KOListView::count()
952{ 956{
953 return mListView->childCount(); 957 return mListView->childCount();
954} 958}
955 959
956void KOListView::changeEventDisplay(Event *event, int action) 960void KOListView::changeEventDisplay(Event *event, int action)
957{ 961{
958 KOListViewItem *item; 962 KOListViewItem *item;
959 963
960 switch(action) { 964 switch(action) {
961 case KOGlobals::EVENTADDED: 965 case KOGlobals::EVENTADDED:
962 addIncidence( event ); 966 addIncidence( event );
963 break; 967 break;
964 case KOGlobals::EVENTEDITED: 968 case KOGlobals::EVENTEDITED:
965 item = getItemForEvent(event); 969 item = getItemForEvent(event);
966 if (item) { 970 if (item) {
967 mUidDict.remove( event->uid() ); 971 mUidDict.remove( event->uid() );
968 delete item; 972 delete item;
969 addIncidence( event ); 973 addIncidence( event );
970 } 974 }
971 break; 975 break;
972 case KOGlobals::EVENTDELETED: 976 case KOGlobals::EVENTDELETED:
973 item = getItemForEvent(event); 977 item = getItemForEvent(event);
974 if (item) { 978 if (item) {
975 mUidDict.remove( event->uid() ); 979 mUidDict.remove( event->uid() );
976 delete item; 980 delete item;
977 } 981 }
978 break; 982 break;
979 default: 983 default:
980 ; 984 ;
981 } 985 }
982} 986}
983 987
984KOListViewItem *KOListView::getItemForEvent(Event *event) 988KOListViewItem *KOListView::getItemForEvent(Event *event)
985{ 989{
986 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 990 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
987 while (item) { 991 while (item) {
988 if (item->data() == event) return item; 992 if (item->data() == event) return item;
989 item = (KOListViewItem *)item->nextSibling(); 993 item = (KOListViewItem *)item->nextSibling();
990 } 994 }
991 return 0; 995 return 0;
992} 996}
993 997
994void KOListView::defaultItemAction(QListViewItem *i) 998void KOListView::defaultItemAction(QListViewItem *i)
995{ 999{
996 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1000 KOListViewItem *item = static_cast<KOListViewItem *>( i );
997 if ( item ) defaultAction( item->data() ); 1001 if ( item ) defaultAction( item->data() );
998 1002
999} 1003}
1000 1004
1001void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1005void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1002{ 1006{
1003 mActiveItem = (KOListViewItem *)item; 1007 mActiveItem = (KOListViewItem *)item;
1004 if (mActiveItem) { 1008 if (mActiveItem) {
1005 Incidence *incidence = mActiveItem->data(); 1009 Incidence *incidence = mActiveItem->data();
1006 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1010 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1007 mPopupMenu->showIncidencePopup(incidence); 1011 mPopupMenu->showIncidencePopup(incidence);
1008 1012
1009 /* 1013 /*
1010 if ( incidence && incidence->type() == "Event" ) { 1014 if ( incidence && incidence->type() == "Event" ) {
1011 Event *event = static_cast<Event *>( incidence ); 1015 Event *event = static_cast<Event *>( incidence );
1012 mPopupMenu->showEventPopup(event); 1016 mPopupMenu->showEventPopup(event);
1013 } 1017 }
1014 */ 1018 */
1015 } 1019 }
1016} 1020}
1017 1021
1018void KOListView::readSettings(KConfig *config, QString setting) 1022void KOListView::readSettings(KConfig *config, QString setting)
1019{ 1023{
1020 // qDebug("KOListView::readSettings "); 1024 // qDebug("KOListView::readSettings ");
1021 mListView->restoreLayout(config,setting); 1025 mListView->restoreLayout(config,setting);
1022} 1026}
1023 1027
1024void KOListView::writeSettings(KConfig *config, QString setting) 1028void KOListView::writeSettings(KConfig *config, QString setting)
1025{ 1029{
1026 // qDebug("KOListView::writeSettings "); 1030 // qDebug("KOListView::writeSettings ");
1027 mListView->saveLayout(config, setting); 1031 mListView->saveLayout(config, setting);
1028} 1032}
1029 1033
1030void KOListView::processSelectionChange(QListViewItem *) 1034void KOListView::processSelectionChange(QListViewItem *)
1031{ 1035{
1032 1036
1033 KOListViewItem *item = 1037 KOListViewItem *item =
1034 static_cast<KOListViewItem *>( mListView->currentItem() ); 1038 static_cast<KOListViewItem *>( mListView->currentItem() );
1035 1039
1036 if ( !item ) { 1040 if ( !item ) {
1037 emit incidenceSelected( 0 ); 1041 emit incidenceSelected( 0 );
1038 } else { 1042 } else {
1039 emit incidenceSelected( item->data() ); 1043 emit incidenceSelected( item->data() );
1040 } 1044 }
1041} 1045}
1042 1046
1043void KOListView::clearSelection() 1047void KOListView::clearSelection()
1044{ 1048{
1045 mListView->selectAll( false ); 1049 mListView->selectAll( false );
1046} 1050}
1047void KOListView::allSelection() 1051void KOListView::allSelection()
1048{ 1052{
1049 mListView->selectAll( true ); 1053 mListView->selectAll( true );
1050} 1054}
1051 1055
1052void KOListView::clear() 1056void KOListView::clear()
1053{ 1057{
1054 mListView->clear(); 1058 mListView->clear();
1055 mUidDict.clear(); 1059 mUidDict.clear();
1056} 1060}
1057 1061
1058Incidence* KOListView::currentItem() 1062Incidence* KOListView::currentItem()
1059{ 1063{
1060 if ( mListView->currentItem() ) 1064 if ( mListView->currentItem() )
1061 return ((KOListViewItem*) mListView->currentItem())->data(); 1065 return ((KOListViewItem*) mListView->currentItem())->data();
1062 return 0; 1066 return 0;
1063} 1067}
1064void KOListView::keyPressEvent ( QKeyEvent *e) 1068void KOListView::keyPressEvent ( QKeyEvent *e)
1065{ 1069{
1066 1070
1067 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1071 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1068 deleteAll(); 1072 deleteAll();
1069 return; 1073 return;
1070 } 1074 }
1071 1075
1072 e->ignore(); 1076 e->ignore();
1073} 1077}
1074void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1078void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1075{ 1079{
1076 1080
1077 switch ( e->key() ) { 1081 switch ( e->key() ) {
1078 case Qt::Key_Down: 1082 case Qt::Key_Down:
1079 if ( e->state() == ShiftButton ) { 1083 if ( e->state() == ShiftButton ) {
1080 QListViewItem* cn = currentItem(); 1084 QListViewItem* cn = currentItem();
1081 if ( !cn ) 1085 if ( !cn )
1082 cn = firstChild(); 1086 cn = firstChild();
1083 if ( !cn ) 1087 if ( !cn )
1084 return; 1088 return;
1085 while ( cn->nextSibling() ) 1089 while ( cn->nextSibling() )
1086 cn = cn->nextSibling(); 1090 cn = cn->nextSibling();
1087 setCurrentItem ( cn ); 1091 setCurrentItem ( cn );
1088 ensureItemVisible ( cn ); 1092 ensureItemVisible ( cn );
1089 1093
1090 e->accept(); 1094 e->accept();
1091 return; 1095 return;
1092 } 1096 }
1093 if ( e->state() == ControlButton ) { 1097 if ( e->state() == ControlButton ) {
1094 int count = childCount (); 1098 int count = childCount ();
1095 int jump = count / 5; 1099 int jump = count / 5;
1096 QListViewItem* cn; 1100 QListViewItem* cn;
1097 cn = currentItem(); 1101 cn = currentItem();
1098 if ( ! cn ) 1102 if ( ! cn )
1099 return; 1103 return;
1100 if ( jump == 0 ) 1104 if ( jump == 0 )
1101 jump = 1; 1105 jump = 1;
1102 while ( jump && cn->nextSibling() ) { 1106 while ( jump && cn->nextSibling() ) {
1103 cn = cn->nextSibling(); 1107 cn = cn->nextSibling();
1104 --jump; 1108 --jump;
1105 } 1109 }
1106 setCurrentItem ( cn ); 1110 setCurrentItem ( cn );
1107 ensureItemVisible ( cn ); 1111 ensureItemVisible ( cn );
1108 1112
1109 } else 1113 } else
1110 QListView::keyPressEvent ( e ) ; 1114 QListView::keyPressEvent ( e ) ;
1111 e->accept(); 1115 e->accept();
1112 break; 1116 break;
1113 1117
1114 case Qt::Key_Up: 1118 case Qt::Key_Up:
1115 if ( e->state() == ShiftButton ) { 1119 if ( e->state() == ShiftButton ) {
1116 QListViewItem* cn = firstChild(); 1120 QListViewItem* cn = firstChild();
1117 if ( cn ) { 1121 if ( cn ) {
1118 setCurrentItem ( cn ); 1122 setCurrentItem ( cn );
1119 ensureItemVisible ( cn ); 1123 ensureItemVisible ( cn );
1120 } 1124 }
1121 e->accept(); 1125 e->accept();
1122 return; 1126 return;
1123 } 1127 }
1124 if ( e->state() == ControlButton ) { 1128 if ( e->state() == ControlButton ) {
1125 int count = childCount (); 1129 int count = childCount ();
1126 int jump = count / 5; 1130 int jump = count / 5;
1127 QListViewItem* cn; 1131 QListViewItem* cn;
1128 cn = currentItem(); 1132 cn = currentItem();
1129 if ( ! cn ) 1133 if ( ! cn )
1130 return; 1134 return;
1131 if ( jump == 0 ) 1135 if ( jump == 0 )
1132 jump = 1; 1136 jump = 1;
1133 while ( jump && cn->itemAbove ()) { 1137 while ( jump && cn->itemAbove ()) {
1134 cn = cn->itemAbove (); 1138 cn = cn->itemAbove ();
1135 --jump; 1139 --jump;
1136 } 1140 }
1137 setCurrentItem ( cn ); 1141 setCurrentItem ( cn );
1138 ensureItemVisible ( cn ); 1142 ensureItemVisible ( cn );
1139 } else 1143 } else
1140 QListView::keyPressEvent ( e ) ; 1144 QListView::keyPressEvent ( e ) ;
1141 e->accept(); 1145 e->accept();
1142 break; 1146 break;
1143 case Qt::Key_I: { 1147 case Qt::Key_I: {
1144 QListViewItem* cn; 1148 QListViewItem* cn;
1145 cn = currentItem(); 1149 cn = currentItem();
1146 if ( cn ) { 1150 if ( cn ) {
1147 KOListViewItem* ci = (KOListViewItem*)( cn ); 1151 KOListViewItem* ci = (KOListViewItem*)( cn );
1148 if ( ci ){ 1152 if ( ci ){
1149 //emit showIncidence( ci->data()); 1153 //emit showIncidence( ci->data());
1150 cn = cn->nextSibling(); 1154 cn = cn->nextSibling();
1151 if ( cn ) { 1155 if ( cn ) {
1152 setCurrentItem ( cn ); 1156 setCurrentItem ( cn );
1153 ensureItemVisible ( cn ); 1157 ensureItemVisible ( cn );
1154 } 1158 }
1155 emit showIncidence( ci->data()); 1159 emit showIncidence( ci->data());
1156 } 1160 }
1157 } 1161 }
1158 e->accept(); 1162 e->accept();
1159 } 1163 }
1160 break; 1164 break;
1161 case Qt::Key_Return: 1165 case Qt::Key_Return:
1162 case Qt::Key_Enter: 1166 case Qt::Key_Enter:
1163 { 1167 {
1164 QListViewItem* cn; 1168 QListViewItem* cn;
1165 cn = currentItem(); 1169 cn = currentItem();
1166 if ( cn ) { 1170 if ( cn ) {
1167 KOListViewItem* ci = (KOListViewItem*)( cn ); 1171 KOListViewItem* ci = (KOListViewItem*)( cn );
1168 if ( ci ){ 1172 if ( ci ){
1169 if ( e->state() == ShiftButton ) 1173 if ( e->state() == ShiftButton )
1170 ci->setSelected( false ); 1174 ci->setSelected( false );
1171 else 1175 else
1172 ci->setSelected( true ); 1176 ci->setSelected( true );
1173 cn = cn->nextSibling(); 1177 cn = cn->nextSibling();
1174 if ( cn ) { 1178 if ( cn ) {
1175 setCurrentItem ( cn ); 1179 setCurrentItem ( cn );
1176 ensureItemVisible ( cn ); 1180 ensureItemVisible ( cn );
1177 } 1181 }
1178 } 1182 }
1179 } 1183 }
1180 e->accept(); 1184 e->accept();
1181 } 1185 }
1182 break; 1186 break;
1183 default: 1187 default:
1184 e->ignore(); 1188 e->ignore();
1185 } 1189 }
1186} 1190}
1187KOListViewListView::KOListViewListView(KOListView * lv ) 1191KOListViewListView::KOListViewListView(KOListView * lv )
1188 : KListView( lv, "kolistlistview", false ) 1192 : KListView( lv, "kolistlistview", false )
1189{ 1193{
1190 mYMousePos = 0; 1194 mYMousePos = 0;
1191 mPopupTimer = new QTimer(this); 1195 mPopupTimer = new QTimer(this);
1192 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1196 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1193#ifndef DESKTOP_VERSION 1197#ifndef DESKTOP_VERSION
1194 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1198 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1195#endif 1199#endif
1196 setSelectionMode( QListView::Multi ); 1200 setSelectionMode( QListView::Multi );
1197 setMultiSelection( true); 1201 setMultiSelection( true);
1198} 1202}
1199bool KOListViewListView::hasMultiSelection(QListViewItem* item) 1203bool KOListViewListView::hasMultiSelection(QListViewItem* item)
1200{ 1204{
1201 int selCount = 0; 1205 int selCount = 0;
1202 QListViewItem *qitem = firstChild (); 1206 QListViewItem *qitem = firstChild ();
1203 while ( qitem ) { 1207 while ( qitem ) {
1204 if ( qitem->isSelected() && item != qitem ) 1208 if ( qitem->isSelected() && item != qitem )
1205 return true; 1209 return true;
1206 qitem = qitem->nextSibling(); 1210 qitem = qitem->nextSibling();
1207 } 1211 }
1208 return false; 1212 return false;
1209} 1213}
1210void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1214void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1211{ 1215{
1212 if (!e) return; 1216 if (!e) return;
1213 QPoint vp = contentsToViewport(e->pos()); 1217 QPoint vp = contentsToViewport(e->pos());
1214 QListViewItem *item = itemAt(vp); 1218 QListViewItem *item = itemAt(vp);
1215 if (!item) { 1219 if (!item) {
1216 emit newEvent(); 1220 emit newEvent();
1217 return; 1221 return;
1218 } 1222 }
1219 KListView::contentsMouseDoubleClickEvent(e); 1223 KListView::contentsMouseDoubleClickEvent(e);
1220} 1224}
1221#if 0 1225#if 0
1222void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1226void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1223{ 1227{
1224 //qDebug("contentsMousePressEvent++++ "); 1228 //qDebug("contentsMousePressEvent++++ ");
1225 KListView::contentsMousePressEvent( e ); 1229 KListView::contentsMousePressEvent( e );
1226 if ( e->button() == RightButton ) { 1230 if ( e->button() == RightButton ) {
1227 QListViewItem* ci = currentItem(); 1231 QListViewItem* ci = currentItem();
1228 clearSelection () ; 1232 clearSelection () ;
1229 if ( ci ) 1233 if ( ci )
1230 ci->setSelected( true ); 1234 ci->setSelected( true );
1231 } 1235 }
1232} 1236}
1233void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1237void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1234{ 1238{
1235 KListView::contentsMouseReleaseEvent(e); 1239 KListView::contentsMouseReleaseEvent(e);
1236} 1240}
1237void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1241void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1238{ 1242{
1239 KListView::contentsMouseMoveEvent(e); 1243 KListView::contentsMouseMoveEvent(e);
1240} 1244}
1241#endif 1245#endif
1242void KOListViewListView::popupMenu() 1246void KOListViewListView::popupMenu()
1243{ 1247{
1244 mPopupTimer->stop(); 1248 mPopupTimer->stop();
1245 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1249 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1246 QApplication::postEvent( this->viewport(), e ); 1250 QApplication::postEvent( this->viewport(), e );
1247 1251
1248} 1252}
1249void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1253void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1250{ 1254{
1251 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1255 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1252 mYMousePos = mapToGlobal( (e->pos())).y(); 1256 mYMousePos = mapToGlobal( (e->pos())).y();
1253 if ( e->button() == LeftButton ) { 1257 if ( e->button() == LeftButton ) {
1254 mPopupTimer->start( 600 ); 1258 mPopupTimer->start( 600 );
1255 mEventPos = contentsToViewport(e->pos()); 1259 mEventPos = contentsToViewport(e->pos());
1256 mEventGlobalPos = e->globalPos(); 1260 mEventGlobalPos = e->globalPos();
1257 } 1261 }
1258 KListView::contentsMousePressEvent( e ); 1262 KListView::contentsMousePressEvent( e );
1259 if ( e->button() == RightButton ) { 1263 if ( e->button() == RightButton ) {
1260 QListViewItem* ci = currentItem(); 1264 QListViewItem* ci = currentItem();
1261 //clearSelection(); 1265 //clearSelection();
1262 if ( ci ) 1266 if ( ci )
1263 ci->setSelected( true ); 1267 ci->setSelected( true );
1264 } 1268 }
1265} 1269}
1266void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1270void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1267{ 1271{
1268 mPopupTimer->stop(); 1272 mPopupTimer->stop();
1269 KListView::contentsMouseReleaseEvent(e); 1273 KListView::contentsMouseReleaseEvent(e);
1270} 1274}
1271void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1275void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1272{ 1276{
1273 // qDebug("contentsMouseMoveEv....... "); 1277 // qDebug("contentsMouseMoveEv....... ");
1274 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1278 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1275 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1279 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1276 if ( diff < 0 ) diff = -diff; 1280 if ( diff < 0 ) diff = -diff;
1277 if ( diff > 15 ) 1281 if ( diff > 15 )
1278 mPopupTimer->stop(); 1282 mPopupTimer->stop();
1279 else { 1283 else {
1280 mEventPos = contentsToViewport(e->pos()); 1284 mEventPos = contentsToViewport(e->pos());
1281 mEventGlobalPos = e->globalPos(); 1285 mEventGlobalPos = e->globalPos();
1282 } 1286 }
1283 KListView::contentsMouseMoveEvent(e); 1287 KListView::contentsMouseMoveEvent(e);
1284} 1288}
1285 1289
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index dee69f6..f4d6879 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -1,313 +1,314 @@
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 signals: 219 signals:
220 void newEvent(); 220 void newEvent();
221 void showIncidence( Incidence* ); 221 void showIncidence( Incidence* );
222 public slots: 222 public slots:
223 void popupMenu(); 223 void popupMenu();
224 private: 224 private:
225 QPoint mEventPos; 225 QPoint mEventPos;
226 QPoint mEventGlobalPos; 226 QPoint mEventGlobalPos;
227 QTimer* mPopupTimer; 227 QTimer* mPopupTimer;
228 int mYMousePos; 228 int mYMousePos;
229 void keyPressEvent ( QKeyEvent * ) ; 229 void keyPressEvent ( QKeyEvent * ) ;
230 void contentsMouseDoubleClickEvent(QMouseEvent *e); 230 void contentsMouseDoubleClickEvent(QMouseEvent *e);
231 void contentsMousePressEvent(QMouseEvent *e); 231 void contentsMousePressEvent(QMouseEvent *e);
232 void contentsMouseReleaseEvent(QMouseEvent *e); 232 void contentsMouseReleaseEvent(QMouseEvent *e);
233 void contentsMouseMoveEvent(QMouseEvent *e); 233 void contentsMouseMoveEvent(QMouseEvent *e);
234 bool mMouseDown; 234 bool mMouseDown;
235}; 235};
236 236
237class KOListView : public KOEventView 237class KOListView : public KOEventView
238{ 238{
239 Q_OBJECT 239 Q_OBJECT
240 public: 240 public:
241 KOListView(Calendar *calendar, QWidget *parent = 0, 241 KOListView(Calendar *calendar, QWidget *parent = 0,
242 const char *name = 0); 242 const char *name = 0);
243 ~KOListView(); 243 ~KOListView();
244 244
245 virtual int maxDatesHint(); 245 virtual int maxDatesHint();
246 virtual int currentDateCount(); 246 virtual int currentDateCount();
247 virtual QPtrList<Incidence> selectedIncidences(); 247 virtual QPtrList<Incidence> selectedIncidences();
248 virtual DateList selectedDates(); 248 virtual DateList selectedDates();
249 249
250 void showDates(bool show); 250 void showDates(bool show);
251 Incidence* currentItem(); 251 Incidence* currentItem();
252 void addTodos(QPtrList<Todo> eventList); 252 void addTodos(QPtrList<Todo> eventList);
253 void addJournals(QPtrList<Journal> eventList); 253 void addJournals(QPtrList<Journal> eventList);
254 virtual void printPreview(CalPrinter *calPrinter, 254 virtual void printPreview(CalPrinter *calPrinter,
255 const QDate &, const QDate &); 255 const QDate &, const QDate &);
256 256
257 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 257 void readSettings(KConfig *config, QString setting = "KOListView Layout");
258 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 258 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
259 void updateList(); 259 void updateList();
260 void clearList();
260 void setStartDate(const QDate &start); 261 void setStartDate(const QDate &start);
261 int count(); 262 int count();
262 QString getWhatsThisText(QPoint p); 263 QString getWhatsThisText(QPoint p);
263 signals: 264 signals:
264 void signalNewEvent(); 265 void signalNewEvent();
265 void beamIncidenceList(QPtrList<Incidence>); 266 void beamIncidenceList(QPtrList<Incidence>);
266 267
267 public slots: 268 public slots:
268 void resetFocus(); 269 void resetFocus();
269 virtual void updateView(); 270 virtual void updateView();
270 virtual void showDates(const QDate &start, const QDate &end); 271 virtual void showDates(const QDate &start, const QDate &end);
271 virtual void showEvents(QPtrList<Event> eventList); 272 virtual void showEvents(QPtrList<Event> eventList);
272 void clearSelection(); 273 void clearSelection();
273 void allSelection(); 274 void allSelection();
274 275
275 void clear(); 276 void clear();
276 void beamDone( Ir *ir ); 277 void beamDone( Ir *ir );
277 void showDates(); 278 void showDates();
278 void hideDates(); 279 void hideDates();
279 void deleteAll(); 280 void deleteAll();
280 void saveToFile(); 281 void saveToFile();
281 void saveToFileVCS(); 282 void saveToFileVCS();
282 void saveDescriptionToFile(); 283 void saveDescriptionToFile();
283 void beamSelected(); 284 void beamSelected();
284 void updateConfig(); 285 void updateConfig();
285 void addCat(); 286 void addCat();
286 void setCat(); 287 void setCat();
287 void setAlarm(); 288 void setAlarm();
288 void setCategories( bool removeOld ); 289 void setCategories( bool removeOld );
289 void changeEventDisplay(Event *, int); 290 void changeEventDisplay(Event *, int);
290 291
291 void defaultItemAction(QListViewItem *item); 292 void defaultItemAction(QListViewItem *item);
292 void popupMenu(QListViewItem *item,const QPoint &,int); 293 void popupMenu(QListViewItem *item,const QPoint &,int);
293 294
294 protected slots: 295 protected slots:
295 void processSelectionChange(QListViewItem *); 296 void processSelectionChange(QListViewItem *);
296 297
297 protected: 298 protected:
298 void writeToFile( bool iCal ); 299 void writeToFile( bool iCal );
299 void addEvents(QPtrList<Event> eventList); 300 void addEvents(QPtrList<Event> eventList);
300 void addIncidence(Incidence *); 301 void addIncidence(Incidence *);
301 KOListViewItem *getItemForEvent(Event *event); 302 KOListViewItem *getItemForEvent(Event *event);
302 303
303 private: 304 private:
304 KOListViewWhatsThis *mKOListViewWhatsThis; 305 KOListViewWhatsThis *mKOListViewWhatsThis;
305 KOListViewListView *mListView; 306 KOListViewListView *mListView;
306 KOEventPopupMenu *mPopupMenu; 307 KOEventPopupMenu *mPopupMenu;
307 KOListViewItem *mActiveItem; 308 KOListViewItem *mActiveItem;
308 QDict<Incidence> mUidDict; 309 QDict<Incidence> mUidDict;
309 QDate mStartDate; 310 QDate mStartDate;
310 void keyPressEvent ( QKeyEvent * ) ; 311 void keyPressEvent ( QKeyEvent * ) ;
311}; 312};
312 313
313#endif 314#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 8ee1363..678cab6 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,2086 +1,2096 @@
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 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#ifndef DESKTOP_VERSION 32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#else 34#else
35#include <qapplication.h> 35#include <qapplication.h>
36#endif 36#endif
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
51#include "kocore.h" 51#include "kocore.h"
52#endif 52#endif
53#include "koglobals.h" 53#include "koglobals.h"
54#include <libkcal/kincidenceformatter.h> 54#include <libkcal/kincidenceformatter.h>
55 55
56#include "komonthview.h" 56#include "komonthview.h"
57 57
58#define PIXMAP_SIZE 5 58#define PIXMAP_SIZE 5
59#ifdef DESKTOP_VERSION 59#ifdef DESKTOP_VERSION
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p) 69 virtual QString text( const QPoint& p)
70 { 70 {
71 return _wid->getWhatsThisText(p) ; 71 return _wid->getWhatsThisText(p) ;
72 }; 72 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86 resetOnFocusIn = true; 86 resetOnFocusIn = true;
87 setVScrollBarMode(QScrollView::AlwaysOff); 87 setVScrollBarMode(QScrollView::AlwaysOff);
88 setHScrollBarMode(QScrollView::AlwaysOff); 88 setHScrollBarMode(QScrollView::AlwaysOff);
89} 89}
90KNoScrollListBox::~KNoScrollListBox() 90KNoScrollListBox::~KNoScrollListBox()
91{ 91{
92#if QT_VERSION >= 0x030000 92#if QT_VERSION >= 0x030000
93 93
94#else 94#else
95 delete mWT; 95 delete mWT;
96#endif 96#endif
97} 97}
98 98
99 99
100void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) 100void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
101{ 101{
102 QListBox::focusInEvent ( e ); 102 QListBox::focusInEvent ( e );
103 if ( count() ){ 103 if ( count() ){
104 int ci = currentItem(); 104 int ci = currentItem();
105 if ( ci < 0 ) ci = 0; 105 if ( ci < 0 ) ci = 0;
106 106
107 setCurrentItem( ci ); 107 setCurrentItem( ci );
108 setSelected ( ci, true ); 108 setSelected ( ci, true );
109 emit highlighted( item ( ci ) ); 109 emit highlighted( item ( ci ) );
110 110
111 resetOnFocusIn = true; 111 resetOnFocusIn = true;
112 112
113 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { 113 if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
114 QListBoxItem *fi = firstItem (); 114 QListBoxItem *fi = firstItem ();
115 if (fi ) { 115 if (fi ) {
116 int ihei = fi->height( this ); 116 int ihei = fi->height( this );
117 int hei = numRows () * ihei; 117 int hei = numRows () * ihei;
118 if ( hei < height() - horizontalScrollBar()->height () ) { 118 if ( hei < height() - horizontalScrollBar()->height () ) {
119 setVScrollBarMode(QScrollView::AlwaysOff); 119 setVScrollBarMode(QScrollView::AlwaysOff);
120 } 120 }
121 else 121 else
122 setVScrollBarMode(QScrollView::Auto); 122 setVScrollBarMode(QScrollView::Auto);
123 if ( ihei *3 > height() ) { 123 if ( ihei *3 > height() ) {
124 setHScrollBarMode(QScrollView::AlwaysOff); 124 setHScrollBarMode(QScrollView::AlwaysOff);
125 } 125 }
126 else { 126 else {
127 setHScrollBarMode(QScrollView::Auto); 127 setHScrollBarMode(QScrollView::Auto);
128 } 128 }
129 } else { 129 } else {
130 setVScrollBarMode(QScrollView::Auto); 130 setVScrollBarMode(QScrollView::Auto);
131 setHScrollBarMode(QScrollView::Auto); 131 setHScrollBarMode(QScrollView::Auto);
132 } 132 }
133 } 133 }
134 } 134 }
135} 135}
136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) 136void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
137{ 137{
138 int i = currentItem (); 138 int i = currentItem ();
139 if ( i >= 0 ) { 139 if ( i >= 0 ) {
140 setSelected ( i, false ); 140 setSelected ( i, false );
141 } 141 }
142 QListBox::focusOutEvent ( e ); 142 QListBox::focusOutEvent ( e );
143 setVScrollBarMode(QScrollView::AlwaysOff); 143 setVScrollBarMode(QScrollView::AlwaysOff);
144 setHScrollBarMode(QScrollView::AlwaysOff); 144 setHScrollBarMode(QScrollView::AlwaysOff);
145} 145}
146 146
147QString KNoScrollListBox::getWhatsThisText(QPoint p) 147QString KNoScrollListBox::getWhatsThisText(QPoint p)
148{ 148{
149 QListBoxItem* item = itemAt ( p ); 149 QListBoxItem* item = itemAt ( p );
150 if ( ! item ) { 150 if ( ! item ) {
151 return i18n("Click in the cell\nto add an event!"); 151 return i18n("Click in the cell\nto add an event!");
152 } 152 }
153 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), 153 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
154 KOPrefs::instance()->mWTshowDetails, 154 KOPrefs::instance()->mWTshowDetails,
155 KOPrefs::instance()->mWTshowCreated, 155 KOPrefs::instance()->mWTshowCreated,
156 KOPrefs::instance()->mWTshowChanged); 156 KOPrefs::instance()->mWTshowChanged);
157} 157}
158void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 158void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
159{ 159{
160 //qDebug("KNoScrollListBox::keyPressEvent "); 160 //qDebug("KNoScrollListBox::keyPressEvent ");
161 switch(e->key()) { 161 switch(e->key()) {
162 case Key_Right: 162 case Key_Right:
163 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 163 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
164 { 164 {
165 e->ignore(); 165 e->ignore();
166 return; 166 return;
167 } 167 }
168 scrollBy(10,0); 168 scrollBy(10,0);
169 break; 169 break;
170 case Key_Left: 170 case Key_Left:
171 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 171 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
172 { 172 {
173 e->ignore(); 173 e->ignore();
174 return; 174 return;
175 } 175 }
176 scrollBy(-10,0); 176 scrollBy(-10,0);
177 break; 177 break;
178 case Key_Up: 178 case Key_Up:
179 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 179 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
180 e->ignore(); 180 e->ignore();
181 break; 181 break;
182 } 182 }
183 if ( count() ) { 183 if ( count() ) {
184 if ( currentItem() == 0 ) { 184 if ( currentItem() == 0 ) {
185 emit prevCell(); 185 emit prevCell();
186 } else { 186 } else {
187 setCurrentItem((currentItem()+count()-1)%count()); 187 setCurrentItem((currentItem()+count()-1)%count());
188 if(!itemVisible(currentItem())) { 188 if(!itemVisible(currentItem())) {
189 if((unsigned int) currentItem() == (count()-1)) { 189 if((unsigned int) currentItem() == (count()-1)) {
190 setTopItem(currentItem()-numItemsVisible()+1); 190 setTopItem(currentItem()-numItemsVisible()+1);
191 } else { 191 } else {
192 setTopItem(topItem()-1); 192 setTopItem(topItem()-1);
193 } 193 }
194 } 194 }
195 } 195 }
196 } 196 }
197 break; 197 break;
198 case Key_Down: 198 case Key_Down:
199 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 199 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
200 e->ignore(); 200 e->ignore();
201 break; 201 break;
202 } 202 }
203 if ( count () ) { 203 if ( count () ) {
204 if ( currentItem()+1 == count () ) { 204 if ( currentItem()+1 == count () ) {
205 emit nextCell(); 205 emit nextCell();
206 } else { 206 } else {
207 setCurrentItem((currentItem()+1)%count()); 207 setCurrentItem((currentItem()+1)%count());
208 if(!itemVisible(currentItem())) { 208 if(!itemVisible(currentItem())) {
209 if(currentItem() == 0) { 209 if(currentItem() == 0) {
210 setTopItem(0); 210 setTopItem(0);
211 } else { 211 } else {
212 setTopItem(topItem()+1); 212 setTopItem(topItem()+1);
213 } 213 }
214 } 214 }
215 } 215 }
216 } 216 }
217 break; 217 break;
218 case Key_I: 218 case Key_I:
219 QTimer::singleShot( 1, this, SLOT ( oneDown() ) ); 219 QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
220 e->ignore(); 220 e->ignore();
221 break; 221 break;
222 case Key_Return: 222 case Key_Return:
223 case Key_Enter: 223 case Key_Enter:
224 { 224 {
225 if ( currentItem() >= 0 ) { 225 if ( currentItem() >= 0 ) {
226 emit doubleClicked( item( currentItem() ) ); 226 emit doubleClicked( item( currentItem() ) );
227 e->accept(); 227 e->accept();
228 } else { 228 } else {
229 e->ignore(); 229 e->ignore();
230 } 230 }
231 } 231 }
232 break; 232 break;
233 case Key_Shift: 233 case Key_Shift:
234 emit shiftDown(); 234 emit shiftDown();
235 break; 235 break;
236 default: 236 default:
237 e->ignore(); 237 e->ignore();
238 break; 238 break;
239 } 239 }
240} 240}
241 241
242void KNoScrollListBox::oneDown() 242void KNoScrollListBox::oneDown()
243{ 243{
244 if ( count () ) { 244 if ( count () ) {
245 if ( currentItem()+1 == count () ) { 245 if ( currentItem()+1 == count () ) {
246 emit nextCell(); 246 emit nextCell();
247 } else { 247 } else {
248 resetOnFocusIn = false; 248 resetOnFocusIn = false;
249 setCurrentItem((currentItem()+1)%count()); 249 setCurrentItem((currentItem()+1)%count());
250 if(!itemVisible(currentItem())) { 250 if(!itemVisible(currentItem())) {
251 if(currentItem() == 0) { 251 if(currentItem() == 0) {
252 setTopItem(0); 252 setTopItem(0);
253 } else { 253 } else {
254 setTopItem(topItem()+1); 254 setTopItem(topItem()+1);
255 } 255 }
256 } 256 }
257 } 257 }
258 } 258 }
259} 259}
260void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 260void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
261{ 261{
262 switch(e->key()) { 262 switch(e->key()) {
263 case Key_Shift: 263 case Key_Shift:
264 emit shiftUp(); 264 emit shiftUp();
265 break; 265 break;
266 default: 266 default:
267 break; 267 break;
268 } 268 }
269} 269}
270 270
271void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 271void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
272{ 272{
273 QListBox::mousePressEvent(e); 273 QListBox::mousePressEvent(e);
274 274
275 if(e->button() == RightButton) { 275 if(e->button() == RightButton) {
276 emit rightClick(); 276 emit rightClick();
277 } 277 }
278} 278}
279 279
280MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 280MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
281 : QListBoxItem() 281 : QListBoxItem()
282{ 282{
283 mblockRepaint = true; 283 mblockRepaint = true;
284 setText( s ); 284 setText( s );
285 mMultiday = 0; 285 mMultiday = 0;
286 mIncidence = incidence; 286 mIncidence = incidence;
287 mDate = qd; 287 mDate = qd;
288 mRecur = false; 288 mRecur = false;
289 mAlarm = false; 289 mAlarm = false;
290 mReply = false; 290 mReply = false;
291 mInfo = false; 291 mInfo = false;
292 mdayPos = 0; 292 mdayPos = 0;
293 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 293 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
294} 294}
295void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 295void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
296{ 296{
297 setText( s ); 297 setText( s );
298 mMultiday = 0; 298 mMultiday = 0;
299 mIncidence = incidence; 299 mIncidence = incidence;
300 mDate = qd; 300 mDate = qd;
301 mRecur = false; 301 mRecur = false;
302 mAlarm = false; 302 mAlarm = false;
303 mReply = false; 303 mReply = false;
304 mInfo = false; 304 mInfo = false;
305 mdayPos = 0; 305 mdayPos = 0;
306} 306}
307 307
308void MonthViewItem::paint(QPainter *p) 308void MonthViewItem::paint(QPainter *p)
309{ 309{
310 if ( mblockRepaint ) { 310 if ( mblockRepaint ) {
311 return; 311 return;
312 } 312 }
313#if QT_VERSION >= 0x030000 313#if QT_VERSION >= 0x030000
314 bool sel = isSelected(); 314 bool sel = isSelected();
315#else 315#else
316 bool sel = selected(); 316 bool sel = selected();
317#endif 317#endif
318 318
319 319
320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
321 { 321 {
322 p->setBackgroundColor( palette().color( QPalette::Normal, \ 322 p->setBackgroundColor( palette().color( QPalette::Normal, \
323 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 323 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
325 } 325 }
326 int x = 1; 326 int x = 1;
327 //int y = 3;//(height() - mRecurPixmap.height()) /2; 327 //int y = 3;//(height() - mRecurPixmap.height()) /2;
328 int size = PIXMAP_SIZE; 328 int size = PIXMAP_SIZE;
329 if ( QApplication::desktop()->width() < 300 ) 329 if ( QApplication::desktop()->width() < 300 )
330 size = 3; 330 size = 3;
331 int heihei = height( listBox () ); 331 int heihei = height( listBox () );
332 int y = (heihei - size -1 ) /2; 332 int y = (heihei - size -1 ) /2;
333 333
334 if ( KOPrefs::instance()->mMonthShowIcons ) { 334 if ( KOPrefs::instance()->mMonthShowIcons ) {
335 if ( mInfo ) { 335 if ( mInfo ) {
336 p->fillRect ( x, y,size,size, Qt::darkGreen ); 336 p->fillRect ( x, y,size,size, Qt::darkGreen );
337 x += size + 1; 337 x += size + 1;
338 } 338 }
339 if ( mRecur ) { 339 if ( mRecur ) {
340 p->fillRect ( x, y,size,size, Qt::blue ); 340 p->fillRect ( x, y,size,size, Qt::blue );
341 x += size + 1; 341 x += size + 1;
342 } 342 }
343 if ( mAlarm ) { 343 if ( mAlarm ) {
344 p->fillRect ( x, y,size,size, Qt::red ); 344 p->fillRect ( x, y,size,size, Qt::red );
345 x += size + 1; 345 x += size + 1;
346 } 346 }
347 if ( mReply ) { 347 if ( mReply ) {
348 p->fillRect ( x, y,size,size, Qt::yellow ); 348 p->fillRect ( x, y,size,size, Qt::yellow );
349 x += size + 1; 349 x += size + 1;
350 } 350 }
351 } 351 }
352 if ( mMultiday ) { 352 if ( mMultiday ) {
353 int yyy = y+(size/2); 353 int yyy = y+(size/2);
354 int sizeM = size+2; 354 int sizeM = size+2;
355 p->setBrush( QBrush::SolidPattern ); 355 p->setBrush( QBrush::SolidPattern );
356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
357 if ( mMultiday == 2 || mMultiday == 3 ) { 357 if ( mMultiday == 2 || mMultiday == 3 ) {
358 QPointArray pa ( 3 ); 358 QPointArray pa ( 3 );
359 pa.setPoint (0, x, yyy ); 359 pa.setPoint (0, x, yyy );
360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 361 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
362 p->drawPolygon( pa ); 362 p->drawPolygon( pa );
363 } 363 }
364 if ( mMultiday == 2 || mMultiday == 1 ) { 364 if ( mMultiday == 2 || mMultiday == 1 ) {
365 QPointArray pa ( 3 ); 365 QPointArray pa ( 3 );
366 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 366 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 367 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 368 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
369 p->drawPolygon( pa ); 369 p->drawPolygon( pa );
370 } 370 }
371 if ( mMultiday == 1 ) { 371 if ( mMultiday == 1 ) {
372 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 372 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
373 373
374 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 374 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
375 } 375 }
376 if ( mMultiday == 3 ) { 376 if ( mMultiday == 3 ) {
377 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 377 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
378 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 378 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
379 379
380 } 380 }
381 x += sizeM/2 + 1; 381 x += sizeM/2 + 1;
382 x += sizeM + 1; 382 x += sizeM + 1;
383 } 383 }
384 384
385 if ( mIncidence->type() == "Todo" ){ 385 if ( mIncidence->type() == "Todo" ){
386 Todo* td = ( Todo* ) mIncidence; 386 Todo* td = ( Todo* ) mIncidence;
387 if ( td->isCompleted() ) { 387 if ( td->isCompleted() ) {
388 int half = size/2; 388 int half = size/2;
389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 389 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
390 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 390 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
391 x += half+half + 4; 391 x += half+half + 4;
392 392
393 } else { 393 } else {
394 int val = td->percentComplete()/20; 394 int val = td->percentComplete()/20;
395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); 395 p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
396 p->drawRect ( x, y-2,7,size+4); 396 p->drawRect ( x, y-2,7,size+4);
397 x += size + 3; 397 x += size + 3;
398 } 398 }
399 } 399 }
400 QFontMetrics fm = p->fontMetrics(); 400 QFontMetrics fm = p->fontMetrics();
401 int yPos; 401 int yPos;
402 int pmheight = size; 402 int pmheight = size;
403 if( pmheight < fm.height() ) 403 if( pmheight < fm.height() )
404 yPos = fm.ascent() + fm.leading()/2; 404 yPos = fm.ascent() + fm.leading()/2;
405 else 405 else
406 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 406 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
407 p->setPen( palette().color( QPalette::Normal, sel ? \ 407 p->setPen( palette().color( QPalette::Normal, sel ? \
408 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 408 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
409 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 409 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
410 p->drawText( x, yPos, text() ); 410 p->drawText( x, yPos, text() );
411 if ( mIncidence->cancelled() ) { 411 if ( mIncidence->cancelled() ) {
412 int wid = fm.width( text() ); 412 int wid = fm.width( text() );
413 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 413 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
414 } 414 }
415 } else { 415 } else {
416 QString pText = text(); 416 QString pText = text();
417 if( pText.mid(2,1) == ":" ) 417 if( pText.mid(2,1) == ":" )
418 pText = pText.mid( 6 ); 418 pText = pText.mid( 6 );
419 p->drawText( x, yPos, pText ); 419 p->drawText( x, yPos, pText );
420 if ( mIncidence->cancelled() ) { 420 if ( mIncidence->cancelled() ) {
421 int wid = fm.width( pText ); 421 int wid = fm.width( pText );
422 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 422 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
423 } 423 }
424 } 424 }
425} 425}
426 426
427int MonthViewItem::height(const QListBox *lb) const 427int MonthViewItem::height(const QListBox *lb) const
428{ 428{
429 int ret = 10; 429 int ret = 10;
430 if ( lb ) 430 if ( lb )
431 ret = lb->fontMetrics().lineSpacing()+1; 431 ret = lb->fontMetrics().lineSpacing()+1;
432 return ret; 432 return ret;
433} 433}
434 434
435int MonthViewItem::width(const QListBox *lb) const 435int MonthViewItem::width(const QListBox *lb) const
436{ 436{
437 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 437 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
438 int size = PIXMAP_SIZE; 438 int size = PIXMAP_SIZE;
439 if ( QApplication::desktop()->width() < 300 ) 439 if ( QApplication::desktop()->width() < 300 )
440 size = 3; 440 size = 3;
441 int x = 1; 441 int x = 1;
442 if ( KOPrefs::instance()->mMonthShowIcons ) { 442 if ( KOPrefs::instance()->mMonthShowIcons ) {
443 if ( mInfo ) { 443 if ( mInfo ) {
444 x += size + 1; 444 x += size + 1;
445 } 445 }
446 if( mRecur ) { 446 if( mRecur ) {
447 x += size+1; 447 x += size+1;
448 } 448 }
449 if( mAlarm ) { 449 if( mAlarm ) {
450 x += size+1; 450 x += size+1;
451 } 451 }
452 if( mReply ) { 452 if( mReply ) {
453 x += size+1; 453 x += size+1;
454 } 454 }
455 } 455 }
456 if( mMultiday ) { 456 if( mMultiday ) {
457 x += size+1+2+size/2; 457 x += size+1+2+size/2;
458 } 458 }
459 return( x + lb->fontMetrics().width( text() ) + 1 ); 459 return( x + lb->fontMetrics().width( text() ) + 1 );
460 } 460 }
461 if ( ! lb ) 461 if ( ! lb )
462 return 10; 462 return 10;
463 return lb->width(); 463 return lb->width();
464} 464}
465 465
466 466
467MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 467MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
468 : KNoScrollListBox( par ), 468 : KNoScrollListBox( par ),
469 mMonthView( parent ) 469 mMonthView( parent )
470{ 470{
471 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 471 //QVBoxLayout *topLayout = new QVBoxLayout( this );
472 currentPalette = 0; 472 currentPalette = 0;
473 // mLabel = new QLabel( this );QPushButton 473 // mLabel = new QLabel( this );QPushButton
474 mLabel = new QPushButton( this ); 474 mLabel = new QPushButton( this );
475 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 475 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
476 //mLabel->setLineWidth( 1 ); 476 //mLabel->setLineWidth( 1 );
477 //mLabel->setAlignment( AlignCenter ); 477 //mLabel->setAlignment( AlignCenter );
478 mLabel->setFlat( true ); 478 mLabel->setFlat( true );
479 mLabel->setFocusPolicy(NoFocus); 479 mLabel->setFocusPolicy(NoFocus);
480 //mItemList = new KNoScrollListBox( this ); 480 //mItemList = new KNoScrollListBox( this );
481 setMinimumSize( 10, 10 ); 481 setMinimumSize( 10, 10 );
482 setFrameStyle( QFrame::Panel | QFrame::Plain ); 482 setFrameStyle( QFrame::Panel | QFrame::Plain );
483 setLineWidth( 1 ); 483 setLineWidth( 1 );
484 //topLayout->addWidget( mItemList ); 484 //topLayout->addWidget( mItemList );
485 mLabel->raise(); 485 mLabel->raise();
486 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 486 // QColor( 0,0,255 ) QColor( 160,1600,255 )
487 mStandardPalette = palette(); 487 mStandardPalette = palette();
488 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 488 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
489 489
490 enableScrollBars( false ); 490 enableScrollBars( false );
491 updateConfig(); 491 updateConfig();
492 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 492 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
493 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 493 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
494 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 494 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
495 SLOT( defaultAction( QListBoxItem * ) ) ); 495 SLOT( defaultAction( QListBoxItem * ) ) );
496 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 496 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
497 const QPoint &) ), 497 const QPoint &) ),
498 SLOT( contextMenu( QListBoxItem * ) ) ); 498 SLOT( contextMenu( QListBoxItem * ) ) );
499 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 499 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
500 SLOT( selection( QListBoxItem * ) ) ); 500 SLOT( selection( QListBoxItem * ) ) );
501 501
502 /* 502 /*
503 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 503 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
504 SLOT( selection( QListBoxItem * ) ) ); 504 SLOT( selection( QListBoxItem * ) ) );
505 */ 505 */
506} 506}
507#ifdef DESKTOP_VERSION 507#ifdef DESKTOP_VERSION
508QToolTipGroup *MonthViewCell::toolTipGroup() 508QToolTipGroup *MonthViewCell::toolTipGroup()
509{ 509{
510 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 510 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
511 return mToolTipGroup; 511 return mToolTipGroup;
512} 512}
513#endif 513#endif
514 514
515void MonthViewCell::setDate( const QDate &date ) 515void MonthViewCell::setDate( const QDate &date )
516{ 516{
517 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 517 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
518 mDate = date; 518 mDate = date;
519 519
520 520
521 521
522 //resizeEvent( 0 ); 522 //resizeEvent( 0 );
523} 523}
524 524
525QDate MonthViewCell::date() const 525QDate MonthViewCell::date() const
526{ 526{
527 return mDate; 527 return mDate;
528} 528}
529 529
530void MonthViewCell::setPrimary( bool primary ) 530void MonthViewCell::setPrimary( bool primary )
531{ 531{
532 mPrimary = primary; 532 mPrimary = primary;
533 //setMyPalette(); 533 //setMyPalette();
534} 534}
535void MonthViewCell::setMyPalette() 535void MonthViewCell::setMyPalette()
536{ 536{
537 537
538 if ( mHoliday) { 538 if ( mHoliday) {
539 if ( currentPalette == 1 ) return; 539 if ( currentPalette == 1 ) return;
540 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 540 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
541 setPalette( mHolidayPalette ); 541 setPalette( mHolidayPalette );
542 //mLabel->setPalette( mHolidayPalette ); 542 //mLabel->setPalette( mHolidayPalette );
543 currentPalette = 1; 543 currentPalette = 1;
544 544
545 } else { 545 } else {
546 if ( mPrimary ) { 546 if ( mPrimary ) {
547 if ( currentPalette == 2 ) return; 547 if ( currentPalette == 2 ) return;
548 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 548 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
549 //mLabel->setPalette( mPrimaryPalette ); 549 //mLabel->setPalette( mPrimaryPalette );
550 setPalette( mPrimaryPalette ); 550 setPalette( mPrimaryPalette );
551 currentPalette = 2; 551 currentPalette = 2;
552 552
553 } else { 553 } else {
554 if ( currentPalette == 3 ) return; 554 if ( currentPalette == 3 ) return;
555 setPalette( mNonPrimaryPalette ); 555 setPalette( mNonPrimaryPalette );
556 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 556 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
557 //mLabel->setPalette( mNonPrimaryPalette );; 557 //mLabel->setPalette( mNonPrimaryPalette );;
558 currentPalette = 3; 558 currentPalette = 3;
559 } 559 }
560 } 560 }
561 //QPalette pal = palette(); 561 //QPalette pal = palette();
562 562
563 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 563 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
564} 564}
565QPalette MonthViewCell::getPalette () 565QPalette MonthViewCell::getPalette ()
566{ 566{
567 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 567 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
568 return mStandardPalette; 568 return mStandardPalette;
569 if ( mHoliday) { 569 if ( mHoliday) {
570 return mHolidayPalette ; 570 return mHolidayPalette ;
571 } else { 571 } else {
572 if ( mPrimary ) { 572 if ( mPrimary ) {
573 return mPrimaryPalette ; 573 return mPrimaryPalette ;
574 } 574 }
575 } 575 }
576 return mNonPrimaryPalette; 576 return mNonPrimaryPalette;
577} 577}
578bool MonthViewCell::isPrimary() const 578bool MonthViewCell::isPrimary() const
579{ 579{
580 return mPrimary; 580 return mPrimary;
581} 581}
582 582
583void MonthViewCell::setHoliday( bool holiday ) 583void MonthViewCell::setHoliday( bool holiday )
584{ 584{
585 mHoliday = holiday; 585 mHoliday = holiday;
586 //setMyPalette(); 586 //setMyPalette();
587} 587}
588 588
589void MonthViewCell::setHoliday( const QString &holiday ) 589void MonthViewCell::setHoliday( const QString &holiday )
590{ 590{
591 mHolidayString = holiday; 591 mHolidayString = holiday;
592 592
593 if ( !holiday.isEmpty() ) { 593 if ( !holiday.isEmpty() ) {
594 setHoliday( true ); 594 setHoliday( true );
595 } 595 }
596} 596}
597 597
598void MonthViewCell::startUpdateCell() 598void MonthViewCell::startUpdateCell()
599{ 599{
600 mdayCount = 0; 600 mdayCount = 0;
601 setFocusPolicy(NoFocus); 601 setFocusPolicy(NoFocus);
602 if ( !mMonthView->isUpdatePossible() ) 602 if ( !mMonthView->isUpdatePossible() )
603 return; 603 return;
604 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 604 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
605 while ( mitem ) { 605 while ( mitem ) {
606 mitem->setBlockRepaint( true ); 606 mitem->setBlockRepaint( true );
607 mitem = (MonthViewItem *)mitem->next(); 607 mitem = (MonthViewItem *)mitem->next();
608 } 608 }
609 if ( mAvailItemList.count() > 20 ) { 609 if ( mAvailItemList.count() > 20 ) {
610 mAvailItemList.setAutoDelete( true ); 610 mAvailItemList.setAutoDelete( true );
611 mAvailItemList.clear(); 611 mAvailItemList.clear();
612 mAvailItemList.setAutoDelete( false ); 612 mAvailItemList.setAutoDelete( false );
613 } 613 }
614 614
615 setPrimary( mDate.month()%2 ); 615 setPrimary( mDate.month()%2 );
616 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 616 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
617 if ( mDate == QDate::currentDate() ) { 617 if ( mDate == QDate::currentDate() ) {
618 setLineWidth( 3 ); 618 setLineWidth( 3 );
619 } else { 619 } else {
620 setLineWidth( 1 ); 620 setLineWidth( 1 );
621 } 621 }
622 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 622 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
623 //clear(); 623 //clear();
624 while ( CurrentAvailItem ) { 624 while ( CurrentAvailItem ) {
625 MonthViewItem *item = CurrentAvailItem; 625 MonthViewItem *item = CurrentAvailItem;
626 CurrentAvailItem = (MonthViewItem *)item->next(); 626 CurrentAvailItem = (MonthViewItem *)item->next();
627 mAvailItemList.append( item ); 627 mAvailItemList.append( item );
628 takeItem ( item ); 628 takeItem ( item );
629 } 629 }
630 630
631#ifdef DESKTOP_VERSION 631#ifdef DESKTOP_VERSION
632 QToolTip::remove(this); 632 QToolTip::remove(this);
633#endif 633#endif
634 mToolTip.clear(); 634 mToolTip.clear();
635 //qApp->processEvents(); 635 //qApp->processEvents();
636#if 0 636#if 0
637 if ( !mHolidayString.isEmpty() ) { 637 if ( !mHolidayString.isEmpty() ) {
638 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 638 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
639 item->setPalette( mHolidayPalette ); 639 item->setPalette( mHolidayPalette );
640 insertItem( item ); 640 insertItem( item );
641 mToolTip.append ( mHolidayString ); 641 mToolTip.append ( mHolidayString );
642 } 642 }
643#endif 643#endif
644} 644}
645 645
646int MonthViewCell::insertEvent(Event *event) 646int MonthViewCell::insertEvent(Event *event)
647{ 647{
648 bool useToolTips = true; 648 bool useToolTips = true;
649#ifndef DESKTOP_VERSION 649#ifndef DESKTOP_VERSION
650 useToolTips = false; 650 useToolTips = false;
651#endif 651#endif
652 QString mToolTipText; 652 QString mToolTipText;
653 setFocusPolicy(WheelFocus); 653 setFocusPolicy(WheelFocus);
654 if ( !(event->doesRecur() == Recurrence::rNone) ) { 654 if ( !(event->doesRecur() == Recurrence::rNone) ) {
655 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 655 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
656 return mdayCount; 656 return mdayCount;
657 else 657 else
658 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 658 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
659 return mdayCount; 659 return mdayCount;
660 } 660 }
661 661
662 if ( event->isHoliday()) { 662 if ( event->isHoliday()) {
663 setHoliday( true ); 663 setHoliday( true );
664 if ( mDate.dayOfWeek() == 7 ) 664 if ( mDate.dayOfWeek() == 7 )
665 setLineWidth( 3 ); 665 setLineWidth( 3 );
666 } 666 }
667 QString text; 667 QString text;
668 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 668 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
669 if (event->isMultiDay()) { 669 if (event->isMultiDay()) {
670 QString prefix = "<->";multiday = 2; 670 QString prefix = "<->";multiday = 2;
671 QString time; 671 QString time;
672 if ( event->doesRecur() ) { 672 if ( event->doesRecur() ) {
673 if ( event->recursOn( mDate) ) { 673 if ( event->recursOn( mDate) ) {
674 prefix ="->" ;multiday = 1; 674 prefix ="->" ;multiday = 1;
675 } 675 }
676 else { 676 else {
677 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 677 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
678 if ( event->recursOn( mDate.addDays( -days)) ) { 678 if ( event->recursOn( mDate.addDays( -days)) ) {
679 prefix ="<-" ;multiday = 3; 679 prefix ="<-" ;multiday = 3;
680 } 680 }
681 } 681 }
682 682
683 } else { 683 } else {
684 if (mDate == event->dtStart().date()) { 684 if (mDate == event->dtStart().date()) {
685 prefix ="->" ;multiday = 1; 685 prefix ="->" ;multiday = 1;
686 } else if (mDate == event->dtEnd().date()) { 686 } else if (mDate == event->dtEnd().date()) {
687 prefix ="<-" ;multiday = 3; 687 prefix ="<-" ;multiday = 3;
688 } 688 }
689 } 689 }
690 if ( !event->doesFloat() ) { 690 if ( !event->doesFloat() ) {
691 if ( mDate == event->dtStart().date () ) 691 if ( mDate == event->dtStart().date () )
692 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 692 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
693 else if ( mDate == event->dtEnd().date () ) 693 else if ( mDate == event->dtEnd().date () )
694 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 694 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
695 695
696 } 696 }
697 text = time + event->summary(); 697 text = time + event->summary();
698 if ( useToolTips ) 698 if ( useToolTips )
699 mToolTipText += prefix + text; 699 mToolTipText += prefix + text;
700 } else { 700 } else {
701 if (event->doesFloat()) { 701 if (event->doesFloat()) {
702 text = event->summary(); 702 text = event->summary();
703 if ( useToolTips ) 703 if ( useToolTips )
704 mToolTipText += text; 704 mToolTipText += text;
705 } 705 }
706 else { 706 else {
707 text = KGlobal::locale()->formatTime(event->dtStart().time()); 707 text = KGlobal::locale()->formatTime(event->dtStart().time());
708 text += " " + event->summary(); 708 text += " " + event->summary();
709 if ( useToolTips ) 709 if ( useToolTips )
710 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 710 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
711 } 711 }
712 } 712 }
713 if ( useToolTips && ! event->location().isEmpty() ) { 713 if ( useToolTips && ! event->location().isEmpty() ) {
714 mToolTipText += " (" + event->location() +")"; 714 mToolTipText += " (" + event->location() +")";
715 } 715 }
716 MonthViewItem *item ; 716 MonthViewItem *item ;
717 717
718 if ( mAvailItemList.count() ) { 718 if ( mAvailItemList.count() ) {
719 item = mAvailItemList.first(); 719 item = mAvailItemList.first();
720 mAvailItemList.remove( item ); 720 mAvailItemList.remove( item );
721 item->recycle( event, mDate, text ); 721 item->recycle( event, mDate, text );
722 } else { 722 } else {
723 item = new MonthViewItem( event, mDate, text ); 723 item = new MonthViewItem( event, mDate, text );
724 } 724 }
725 725
726 QPalette pal; 726 QPalette pal;
727 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 727 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
728 QStringList categories = event->categories(); 728 QStringList categories = event->categories();
729 QString cat = categories.first(); 729 QString cat = categories.first();
730 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 730 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
731 pal = getPalette(); 731 pal = getPalette();
732 if (cat.isEmpty()) { 732 if (cat.isEmpty()) {
733 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 733 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
734 } else { 734 } else {
735 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 735 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
736 } 736 }
737 737
738 } else { 738 } else {
739 if (cat.isEmpty()) { 739 if (cat.isEmpty()) {
740 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 740 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
741 } else { 741 } else {
742 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 742 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
743 } 743 }
744 } 744 }
745 745
746 } else { 746 } else {
747 pal = mStandardPalette ; 747 pal = mStandardPalette ;
748 } 748 }
749 item->setPalette( pal ); 749 item->setPalette( pal );
750 item->setRecur( event->recurrence()->doesRecur() ); 750 item->setRecur( event->recurrence()->doesRecur() );
751 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 751 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
752 item->setMoreInfo( event->description().length() > 0 ); 752 item->setMoreInfo( event->description().length() > 0 );
753#ifdef DESKTOP_VERSION 753#ifdef DESKTOP_VERSION
754 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 754 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
755 KOPrefs::instance()->email()); 755 KOPrefs::instance()->email());
756 if ( me != 0 ) { 756 if ( me != 0 ) {
757 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 757 if ( me->status() == Attendee::NeedsAction && me->RSVP())
758 item->setReply(true && multiday < 2); 758 item->setReply(true && multiday < 2);
759 else 759 else
760 item->setReply(false); 760 item->setReply(false);
761 } else 761 } else
762 item->setReply(false); 762 item->setReply(false);
763#endif 763#endif
764 item->setMultiDay( multiday ); 764 item->setMultiDay( multiday );
765 if ( multiday ) { 765 if ( multiday ) {
766 insertItem( item ,mdayCount); 766 insertItem( item ,mdayCount);
767 ++mdayCount; 767 ++mdayCount;
768 } else { 768 } else {
769 uint i; 769 uint i;
770 int pos = mdayCount; 770 int pos = mdayCount;
771 for ( i = mdayCount; i < count();++i ) { 771 for ( i = mdayCount; i < count();++i ) {
772 QListBoxItem* it = this->item ( i ); 772 QListBoxItem* it = this->item ( i );
773 if ( it && text < it->text() ) { 773 if ( it && text < it->text() ) {
774 pos = i; 774 pos = i;
775 break; 775 break;
776 } 776 }
777 ++pos; 777 ++pos;
778 } 778 }
779 insertItem( item ,pos); 779 insertItem( item ,pos);
780 } 780 }
781 if ( useToolTips ) { 781 if ( useToolTips ) {
782 mToolTip.append( mToolTipText ); 782 mToolTip.append( mToolTipText );
783 } 783 }
784 return mdayCount; 784 return mdayCount;
785} 785}
786void MonthViewCell::insertTodo(Todo *todo) 786void MonthViewCell::insertTodo(Todo *todo)
787{ 787{
788 setFocusPolicy(WheelFocus); 788 setFocusPolicy(WheelFocus);
789 QString text; 789 QString text;
790 if (todo->hasDueDate()) { 790 if (todo->hasDueDate()) {
791 if (!todo->doesFloat()) { 791 if (!todo->doesFloat()) {
792 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 792 text += KGlobal::locale()->formatTime(todo->dtDue().time());
793 text += " "; 793 text += " ";
794 } 794 }
795 } 795 }
796 text += todo->summary(); 796 text += todo->summary();
797 MonthViewItem *item ; 797 MonthViewItem *item ;
798 if ( mAvailItemList.count() ) { 798 if ( mAvailItemList.count() ) {
799 item = mAvailItemList.first(); 799 item = mAvailItemList.first();
800 mAvailItemList.remove( item ); 800 mAvailItemList.remove( item );
801 item->recycle( todo, mDate, text ); 801 item->recycle( todo, mDate, text );
802 } else { 802 } else {
803 item = new MonthViewItem( todo, mDate, text ); 803 item = new MonthViewItem( todo, mDate, text );
804 } 804 }
805 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 805 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
806 //item->setPalette( mStandardPalette ); 806 //item->setPalette( mStandardPalette );
807 QPalette pal; 807 QPalette pal;
808 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 808 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
809 QStringList categories = todo->categories(); 809 QStringList categories = todo->categories();
810 QString cat = categories.first(); 810 QString cat = categories.first();
811 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 811 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
812 pal = getPalette(); 812 pal = getPalette();
813 if (cat.isEmpty()) { 813 if (cat.isEmpty()) {
814 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 814 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
815 } else { 815 } else {
816 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 816 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
817 } 817 }
818 818
819 } else { 819 } else {
820 if (cat.isEmpty()) { 820 if (cat.isEmpty()) {
821 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 821 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
822 } else { 822 } else {
823 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 823 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
824 } 824 }
825 } 825 }
826 826
827 } else { 827 } else {
828 pal = mStandardPalette ; 828 pal = mStandardPalette ;
829 } 829 }
830 item->setPalette( pal ); 830 item->setPalette( pal );
831 item->setRecur( todo->recurrence()->doesRecur() ); 831 item->setRecur( todo->recurrence()->doesRecur() );
832 item->setAlarm( todo->isAlarmEnabled() ); 832 item->setAlarm( todo->isAlarmEnabled() );
833 item->setMoreInfo( todo->description().length() > 0 ); 833 item->setMoreInfo( todo->description().length() > 0 );
834 insertItem( item , count()); 834 insertItem( item , count());
835#ifdef DESKTOP_VERSION 835#ifdef DESKTOP_VERSION
836 mToolTip.append( text ); 836 mToolTip.append( text );
837#endif 837#endif
838} 838}
839void MonthViewCell::repaintfinishUpdateCell() 839void MonthViewCell::repaintfinishUpdateCell()
840{ 840{
841 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 841 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
842 while ( mitem ) { 842 while ( mitem ) {
843 mitem->setBlockRepaint( false ); 843 mitem->setBlockRepaint( false );
844 updateItem ( mitem ); 844 updateItem ( mitem );
845 mitem = (MonthViewItem *)mitem->next(); 845 mitem = (MonthViewItem *)mitem->next();
846 } 846 }
847} 847}
848void MonthViewCell::finishUpdateCell() 848void MonthViewCell::finishUpdateCell()
849{ 849{
850 850
851 851
852 852
853#ifdef DESKTOP_VERSION 853#ifdef DESKTOP_VERSION
854 if (mToolTip.count() > 0 ) { 854 if (mToolTip.count() > 0 ) {
855 mToolTip.sort(); 855 mToolTip.sort();
856 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 856 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
857 } 857 }
858#endif 858#endif
859 //sort(); 859 //sort();
860 //setMyPalette(); 860 //setMyPalette();
861 setMyPalette(); 861 setMyPalette();
862 862
863 resizeEvent( 0 ); 863 resizeEvent( 0 );
864 864
865} 865}
866void MonthViewCell::updateCell() 866void MonthViewCell::updateCell()
867{ 867{
868 if ( !mMonthView->isUpdatePossible() ) 868 if ( !mMonthView->isUpdatePossible() )
869 return; 869 return;
870 startUpdateCell(); 870 startUpdateCell();
871 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 871 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
872 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 872 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
873 Event *event; 873 Event *event;
874 for( event = events.first(); event; event = events.next() ) { // for event 874 for( event = events.first(); event; event = events.next() ) { // for event
875 insertEvent(event); 875 insertEvent(event);
876 } 876 }
877 // insert due todos 877 // insert due todos
878 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 878 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
879 Todo *todo; 879 Todo *todo;
880 for(todo = todos.first(); todo; todo = todos.next()) { 880 for(todo = todos.first(); todo; todo = todos.next()) {
881 insertTodo( todo ); 881 insertTodo( todo );
882 } 882 }
883 finishUpdateCell(); 883 finishUpdateCell();
884 // if ( isVisible()) 884 // if ( isVisible())
885 //qApp->processEvents(); 885 //qApp->processEvents();
886} 886}
887 887
888void MonthViewCell::updateConfig( bool bigFont ) // = false 888void MonthViewCell::updateConfig( bool bigFont ) // = false
889{ 889{
890 890
891 if ( bigFont ) { 891 if ( bigFont ) {
892 QFont fo = KOPrefs::instance()->mMonthViewFont; 892 QFont fo = KOPrefs::instance()->mMonthViewFont;
893 int ps = fo.pointSize() + 2; 893 int ps = fo.pointSize() + 2;
894 if ( ps < 18 ) 894 if ( ps < 18 )
895 ps += 2; 895 ps += 2;
896 fo.setPointSize( ps ); 896 fo.setPointSize( ps );
897 setFont( fo ); 897 setFont( fo );
898 } else 898 } else
899 setFont( KOPrefs::instance()->mMonthViewFont ); 899 setFont( KOPrefs::instance()->mMonthViewFont );
900 900
901 QFontMetrics fm( font() ); 901 QFontMetrics fm( font() );
902 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 902 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
903 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 903 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
904 mHolidayPalette = mStandardPalette; 904 mHolidayPalette = mStandardPalette;
905 mPrimaryPalette = mStandardPalette; 905 mPrimaryPalette = mStandardPalette;
906 mNonPrimaryPalette = mStandardPalette; 906 mNonPrimaryPalette = mStandardPalette;
907 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 907 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
908 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 908 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
909 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 909 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
910 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 910 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
911 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 911 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
912 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 912 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
913 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 913 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
914 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 914 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
915 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 915 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
916 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 916 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
917 } 917 }
918 //updateCell(); 918 //updateCell();
919} 919}
920 920
921void MonthViewCell::enableScrollBars( bool enabled ) 921void MonthViewCell::enableScrollBars( bool enabled )
922{ 922{
923 923
924 return; 924 return;
925 if ( enabled ) { 925 if ( enabled ) {
926 QListBoxItem *fi = firstItem (); 926 QListBoxItem *fi = firstItem ();
927 if (fi ) { 927 if (fi ) {
928 int ihei = fi->height( this ); 928 int ihei = fi->height( this );
929 int hei = numRows () * ihei; 929 int hei = numRows () * ihei;
930 if ( hei < height() - horizontalScrollBar()->height () ) { 930 if ( hei < height() - horizontalScrollBar()->height () ) {
931 setVScrollBarMode(QScrollView::AlwaysOff); 931 setVScrollBarMode(QScrollView::AlwaysOff);
932 } 932 }
933 else 933 else
934 setVScrollBarMode(QScrollView::Auto); 934 setVScrollBarMode(QScrollView::Auto);
935 if ( ihei *3 > height() ) { 935 if ( ihei *3 > height() ) {
936 setHScrollBarMode(QScrollView::AlwaysOff); 936 setHScrollBarMode(QScrollView::AlwaysOff);
937 } 937 }
938 else { 938 else {
939 setHScrollBarMode(QScrollView::Auto); 939 setHScrollBarMode(QScrollView::Auto);
940 } 940 }
941 } else { 941 } else {
942 setVScrollBarMode(QScrollView::Auto); 942 setVScrollBarMode(QScrollView::Auto);
943 setHScrollBarMode(QScrollView::Auto); 943 setHScrollBarMode(QScrollView::Auto);
944 } 944 }
945 } else { 945 } else {
946 setVScrollBarMode(QScrollView::AlwaysOff); 946 setVScrollBarMode(QScrollView::AlwaysOff);
947 setHScrollBarMode(QScrollView::AlwaysOff); 947 setHScrollBarMode(QScrollView::AlwaysOff);
948 } 948 }
949} 949}
950 950
951Incidence *MonthViewCell::selectedIncidence() 951Incidence *MonthViewCell::selectedIncidence()
952{ 952{
953 int index = currentItem(); 953 int index = currentItem();
954 if ( index < 0 ) return 0; 954 if ( index < 0 ) return 0;
955 955
956 MonthViewItem *mitem = 956 MonthViewItem *mitem =
957 static_cast<MonthViewItem *>( item( index ) ); 957 static_cast<MonthViewItem *>( item( index ) );
958 958
959 if ( !mitem ) return 0; 959 if ( !mitem ) return 0;
960 960
961 return mitem->incidence(); 961 return mitem->incidence();
962} 962}
963 963
964QDate MonthViewCell::selectedIncidenceDate() 964QDate MonthViewCell::selectedIncidenceDate()
965{ 965{
966 QDate qd; 966 QDate qd;
967 int index = currentItem(); 967 int index = currentItem();
968 if ( index < 0 ) return qd; 968 if ( index < 0 ) return qd;
969 969
970 MonthViewItem *mitem = 970 MonthViewItem *mitem =
971 static_cast<MonthViewItem *>( item( index ) ); 971 static_cast<MonthViewItem *>( item( index ) );
972 972
973 if ( !mitem ) return qd; 973 if ( !mitem ) return qd;
974 974
975 return mitem->incidenceDate(); 975 return mitem->incidenceDate();
976} 976}
977 977
978void MonthViewCell::deselect() 978void MonthViewCell::deselect()
979{ 979{
980 clearSelection(); 980 clearSelection();
981 enableScrollBars( false ); 981 enableScrollBars( false );
982 // updateCell(); 982 // updateCell();
983} 983}
984void MonthViewCell::select() 984void MonthViewCell::select()
985{ 985{
986 ;// updateCell(); 986 ;// updateCell();
987} 987}
988 988
989void MonthViewCell::resizeEvent ( QResizeEvent * e ) 989void MonthViewCell::resizeEvent ( QResizeEvent * e )
990{ 990{
991 if ( !mMonthView->isUpdatePossible() ) 991 if ( !mMonthView->isUpdatePossible() )
992 return; 992 return;
993 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 993 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
994 deselect(); 994 deselect();
995 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 995 mLabel->setMaximumHeight( height() - lineWidth()*2 );
996 996
997 QString text; 997 QString text;
998 mLabel->setText( text ); 998 mLabel->setText( text );
999 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 999 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1000 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1000 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1001 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 1001 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
1002 mLabel->resize( mLabelBigSize ); 1002 mLabel->resize( mLabelBigSize );
1003 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1003 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1004 } else { 1004 } else {
1005 mLabel->resize( mLabelSize ); 1005 mLabel->resize( mLabelSize );
1006 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1006 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1007 } 1007 }
1008 mLabel->setText( text ); 1008 mLabel->setText( text );
1009 1009
1010 int size = height() - mLabel->height() - lineWidth()-1; 1010 int size = height() - mLabel->height() - lineWidth()-1;
1011 //qDebug("LW %d ", lineWidth()); 1011 //qDebug("LW %d ", lineWidth());
1012 if ( size > 0 ) 1012 if ( size > 0 )
1013 verticalScrollBar()->setMaximumHeight( size ); 1013 verticalScrollBar()->setMaximumHeight( size );
1014 size = width() - mLabel->width() -lineWidth()-1; 1014 size = width() - mLabel->width() -lineWidth()-1;
1015 if ( size > 0 ) 1015 if ( size > 0 )
1016 horizontalScrollBar()->setMaximumWidth( size ); 1016 horizontalScrollBar()->setMaximumWidth( size );
1017 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1017 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1018 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1018 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1019 // mItemList->resize ( width(), height () ); 1019 // mItemList->resize ( width(), height () );
1020 if ( e ) 1020 if ( e )
1021 KNoScrollListBox::resizeEvent ( e ); 1021 KNoScrollListBox::resizeEvent ( e );
1022} 1022}
1023 1023
1024void MonthViewCell::defaultAction( QListBoxItem *item ) 1024void MonthViewCell::defaultAction( QListBoxItem *item )
1025{ 1025{
1026 1026
1027 if ( !item ) { 1027 if ( !item ) {
1028 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1028 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1029 emit newEventSignal( dt ); 1029 emit newEventSignal( dt );
1030 return; 1030 return;
1031 } 1031 }
1032 1032
1033 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1033 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1034 Incidence *incidence = eventItem->incidence(); 1034 Incidence *incidence = eventItem->incidence();
1035 if ( incidence ) mMonthView->defaultAction( incidence ); 1035 if ( incidence ) mMonthView->defaultAction( incidence );
1036} 1036}
1037void MonthViewCell::showDay() 1037void MonthViewCell::showDay()
1038{ 1038{
1039 emit showDaySignal( date() ); 1039 emit showDaySignal( date() );
1040} 1040}
1041void MonthViewCell::newEvent() 1041void MonthViewCell::newEvent()
1042{ 1042{
1043 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1043 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1044 emit newEventSignal( dt ); 1044 emit newEventSignal( dt );
1045} 1045}
1046void MonthViewCell::cellClicked( QListBoxItem *item ) 1046void MonthViewCell::cellClicked( QListBoxItem *item )
1047{ 1047{
1048 mMonthView->setSelectedCell( this ); 1048 mMonthView->setSelectedCell( this );
1049 if ( item == 0 ) { 1049 if ( item == 0 ) {
1050 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1050 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1051 emit newEventSignal( dt ); 1051 emit newEventSignal( dt );
1052 return; 1052 return;
1053 } 1053 }
1054 1054
1055} 1055}
1056 1056
1057void MonthViewCell::contextMenu( QListBoxItem *item ) 1057void MonthViewCell::contextMenu( QListBoxItem *item )
1058{ 1058{
1059 mMonthView->setPopupCell( this ); 1059 mMonthView->setPopupCell( this );
1060 if ( !item ) { 1060 if ( !item ) {
1061 mMonthView->showContextMenu( 0 ); 1061 mMonthView->showContextMenu( 0 );
1062 return; 1062 return;
1063 } 1063 }
1064 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1064 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1065 Incidence *incidence = eventItem->incidence(); 1065 Incidence *incidence = eventItem->incidence();
1066 if ( incidence ) mMonthView->showContextMenu( incidence ); 1066 if ( incidence ) mMonthView->showContextMenu( incidence );
1067} 1067}
1068 1068
1069void MonthViewCell::selection( QListBoxItem *item ) 1069void MonthViewCell::selection( QListBoxItem *item )
1070{ 1070{
1071 if ( !item ) return; 1071 if ( !item ) return;
1072 1072
1073 mMonthView->setSelectedCell( this ); 1073 mMonthView->setSelectedCell( this );
1074} 1074}
1075 1075
1076 1076
1077// ******************************************************************************* 1077// *******************************************************************************
1078// ******************************************************************************* 1078// *******************************************************************************
1079// ******************************************************************************* 1079// *******************************************************************************
1080 1080
1081 1081
1082KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1082KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1083 : KOEventView( calendar, parent, name ), 1083 : KOEventView( calendar, parent, name ),
1084 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1084 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1085 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1085 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1086{ 1086{
1087 mFlagKeyPressed = false; 1087 mFlagKeyPressed = false;
1088 mShortDayLabelsM = false; 1088 mShortDayLabelsM = false;
1089 mShortDayLabelsW = false; 1089 mShortDayLabelsW = false;
1090 skipResize = false; 1090 skipResize = false;
1091 clPending = true; 1091 clPending = true;
1092 mPopupCell = 0; 1092 mPopupCell = 0;
1093 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1093 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1094 mWidStack = new QWidgetStack( this ); 1094 mWidStack = new QWidgetStack( this );
1095 QVBoxLayout* hb = new QVBoxLayout( this ); 1095 QVBoxLayout* hb = new QVBoxLayout( this );
1096 mMonthView = new QWidget( mWidStack ); 1096 mMonthView = new QWidget( mWidStack );
1097 mWeekView = new QWidget( mWidStack ); 1097 mWeekView = new QWidget( mWidStack );
1098#if QT_VERSION >= 0x030000 1098#if QT_VERSION >= 0x030000
1099 mWidStack->addWidget(mMonthView ); 1099 mWidStack->addWidget(mMonthView );
1100 mWidStack->addWidget(mWeekView ); 1100 mWidStack->addWidget(mWeekView );
1101#else 1101#else
1102 mWidStack->addWidget( mMonthView, 1 ); 1102 mWidStack->addWidget( mMonthView, 1 );
1103 mWidStack->addWidget( mWeekView , 1 ); 1103 mWidStack->addWidget( mWeekView , 1 );
1104#endif 1104#endif
1105 hb->addWidget( mNavigatorBar ); 1105 hb->addWidget( mNavigatorBar );
1106 hb->addWidget( mWidStack ); 1106 hb->addWidget( mWidStack );
1107 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1107 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1108 updatePossible = false; 1108 updatePossible = false;
1109 //updatePossible = true; 1109 //updatePossible = true;
1110 mCells.setAutoDelete( true ); 1110 mCells.setAutoDelete( true );
1111 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1111 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1112 mDayLabels.resize( mDaysPerWeek ); 1112 mDayLabels.resize( mDaysPerWeek );
1113 mDayLabelsW.resize( mDaysPerWeek ); 1113 mDayLabelsW.resize( mDaysPerWeek );
1114 QFont bfont = font(); 1114 QFont bfont = font();
1115 if ( QApplication::desktop()->width() < 650 ) { 1115 if ( QApplication::desktop()->width() < 650 ) {
1116 bfont.setPointSize( bfont.pointSize() - 2 ); 1116 bfont.setPointSize( bfont.pointSize() - 2 );
1117 } 1117 }
1118 bfont.setBold( true ); 1118 bfont.setBold( true );
1119 int i; 1119 int i;
1120 1120
1121 for( i = 0; i < mDaysPerWeek; i++ ) { 1121 for( i = 0; i < mDaysPerWeek; i++ ) {
1122 QLabel *label = new QLabel( mMonthView ); 1122 QLabel *label = new QLabel( mMonthView );
1123 label->setFont(bfont); 1123 label->setFont(bfont);
1124 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1124 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1125 label->setLineWidth(1); 1125 label->setLineWidth(1);
1126 label->setAlignment(AlignCenter); 1126 label->setAlignment(AlignCenter);
1127 mDayLabels.insert( i, label ); 1127 mDayLabels.insert( i, label );
1128 label = new QLabel( mWeekView ); 1128 label = new QLabel( mWeekView );
1129 label->setFont(bfont); 1129 label->setFont(bfont);
1130 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1130 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1131 label->setLineWidth(1); 1131 label->setLineWidth(1);
1132 label->setAlignment(AlignCenter); 1132 label->setAlignment(AlignCenter);
1133 mDayLabelsW.insert( i, label ); 1133 mDayLabelsW.insert( i, label );
1134 } 1134 }
1135 1135
1136 bfont.setBold( false ); 1136 bfont.setBold( false );
1137 mWeekLabels.resize( mNumWeeks+1 ); 1137 mWeekLabels.resize( mNumWeeks+1 );
1138 mWeekLabelsW.resize( 2 ); 1138 mWeekLabelsW.resize( 2 );
1139 for( i = 0; i < mNumWeeks+1; i++ ) { 1139 for( i = 0; i < mNumWeeks+1; i++ ) {
1140 KOWeekButton *label = new KOWeekButton( mMonthView ); 1140 KOWeekButton *label = new KOWeekButton( mMonthView );
1141 label->setFocusPolicy(NoFocus); 1141 label->setFocusPolicy(NoFocus);
1142 label->setFont(bfont); 1142 label->setFont(bfont);
1143 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1143 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1144 label->setFlat(true); 1144 label->setFlat(true);
1145 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1145 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1146 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1146 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1147 //label->setLineWidth(1); 1147 //label->setLineWidth(1);
1148 //label->setAlignment(AlignCenter); 1148 //label->setAlignment(AlignCenter);
1149 mWeekLabels.insert( i, label ); 1149 mWeekLabels.insert( i, label );
1150 } 1150 }
1151 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1151 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1152 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); 1152 mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus);
1153 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 1153 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
1154 1154
1155 for( i = 0; i < 1+1; i++ ) { 1155 for( i = 0; i < 1+1; i++ ) {
1156 KOWeekButton *label = new KOWeekButton( mWeekView ); 1156 KOWeekButton *label = new KOWeekButton( mWeekView );
1157 label->setFocusPolicy(NoFocus); 1157 label->setFocusPolicy(NoFocus);
1158 label->setFont(bfont); 1158 label->setFont(bfont);
1159 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 1159 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
1160 label->setFlat(true); 1160 label->setFlat(true);
1161 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 1161 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
1162 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 1162 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
1163 //label->setLineWidth(1); 1163 //label->setLineWidth(1);
1164 //label->setAlignment(AlignCenter); 1164 //label->setAlignment(AlignCenter);
1165 mWeekLabelsW.insert( i, label ); 1165 mWeekLabelsW.insert( i, label );
1166 } 1166 }
1167 mWeekLabelsW[1]->setText( i18n("W")); 1167 mWeekLabelsW[1]->setText( i18n("W"));
1168 mWeekLabelsW[1]->setFocusPolicy(WheelFocus); 1168 mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
1169 1169
1170 1170
1171 int row, col; 1171 int row, col;
1172 mCells.resize( mNumCells ); 1172 mCells.resize( mNumCells );
1173 for( row = 0; row < mNumWeeks; ++row ) { 1173 for( row = 0; row < mNumWeeks; ++row ) {
1174 for( col = 0; col < mDaysPerWeek; ++col ) { 1174 for( col = 0; col < mDaysPerWeek; ++col ) {
1175 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 1175 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
1176 mCells.insert( row * mDaysPerWeek + col, cell ); 1176 mCells.insert( row * mDaysPerWeek + col, cell );
1177 1177
1178 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1178 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1179 SLOT( defaultAction( Incidence * ) ) ); 1179 SLOT( defaultAction( Incidence * ) ) );
1180 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1180 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1181 SIGNAL( newEventSignal( QDateTime ) ) ); 1181 SIGNAL( newEventSignal( QDateTime ) ) );
1182 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1182 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1183 SIGNAL( showDaySignal( QDate ) ) ); 1183 SIGNAL( showDaySignal( QDate ) ) );
1184 connect( cell, SIGNAL( nextCell() ), 1184 connect( cell, SIGNAL( nextCell() ),
1185 SLOT( nextCell() ) ); 1185 SLOT( nextCell() ) );
1186 connect( cell, SIGNAL( prevCell() ), 1186 connect( cell, SIGNAL( prevCell() ),
1187 SLOT( prevCell() ) ); 1187 SLOT( prevCell() ) );
1188 } 1188 }
1189 } 1189 }
1190 mCellsW.resize( mDaysPerWeek ); 1190 mCellsW.resize( mDaysPerWeek );
1191 for( col = 0; col < mDaysPerWeek; ++col ) { 1191 for( col = 0; col < mDaysPerWeek; ++col ) {
1192 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 1192 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
1193 mCellsW.insert( col, cell ); 1193 mCellsW.insert( col, cell );
1194 1194
1195 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 1195 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
1196 SLOT( defaultAction( Incidence * ) ) ); 1196 SLOT( defaultAction( Incidence * ) ) );
1197 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 1197 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
1198 SIGNAL( newEventSignal( QDateTime ) ) ); 1198 SIGNAL( newEventSignal( QDateTime ) ) );
1199 connect( cell, SIGNAL( showDaySignal( QDate ) ), 1199 connect( cell, SIGNAL( showDaySignal( QDate ) ),
1200 SIGNAL( showDaySignal( QDate ) ) ); 1200 SIGNAL( showDaySignal( QDate ) ) );
1201 connect( cell, SIGNAL( nextCell() ), 1201 connect( cell, SIGNAL( nextCell() ),
1202 SLOT( nextCell() ) ); 1202 SLOT( nextCell() ) );
1203 connect( cell, SIGNAL( prevCell() ), 1203 connect( cell, SIGNAL( prevCell() ),
1204 SLOT( prevCell() ) ); 1204 SLOT( prevCell() ) );
1205 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 1205 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
1206 } 1206 }
1207 1207
1208 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 1208 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
1209 mContextMenu = eventPopup(); 1209 mContextMenu = eventPopup();
1210 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1210 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1211 i18n("New Event..."),this, 1211 i18n("New Event..."),this,
1212 SLOT(slotNewEvent()),false); 1212 SLOT(slotNewEvent()),false);
1213 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1213 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1214 i18n("New Todo..."),this, 1214 i18n("New Todo..."),this,
1215 SLOT(slotNewTodo()),false); 1215 SLOT(slotNewTodo()),false);
1216 mContextMenu->addAdditionalItem(QIconSet(QPixmap()), 1216 mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
1217 i18n("Journal"),this, 1217 i18n("Journal"),this,
1218 SLOT(slotEditJournal()),false); 1218 SLOT(slotEditJournal()),false);
1219 1219
1220 1220
1221 1221
1222 QString pathString = ""; 1222 QString pathString = "";
1223 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 1223 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
1224 if ( QApplication::desktop()->width() < 480 ) 1224 if ( QApplication::desktop()->width() < 480 )
1225 pathString += "icons16/"; 1225 pathString += "icons16/";
1226 } else 1226 } else
1227 pathString += "iconsmini/"; 1227 pathString += "iconsmini/";
1228 mNewItemMenu = new QPopupMenu( this ); 1228 mNewItemMenu = new QPopupMenu( this );
1229 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); 1229 mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent()));
1230 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); 1230 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
1231 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); 1231 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
1232 1232
1233 // updateConfig(); //useless here... 1233 // updateConfig(); //useless here...
1234 // ... but we need mWidthLongDayLabel computed 1234 // ... but we need mWidthLongDayLabel computed
1235 QFontMetrics fontmetric(mDayLabels[0]->font()); 1235 QFontMetrics fontmetric(mDayLabels[0]->font());
1236 mWidthLongDayLabel = 0; 1236 mWidthLongDayLabel = 0;
1237 for (int i = 0; i < 7; i++) { 1237 for (int i = 0; i < 7; i++) {
1238 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1238 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1239 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1239 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1240 } 1240 }
1241 1241
1242 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1242 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1243 1243
1244#if 0 1244#if 0
1245 if ( mShowWeekView ) 1245 if ( mShowWeekView )
1246 mWidStack->raiseWidget( mWeekView ); 1246 mWidStack->raiseWidget( mWeekView );
1247 else 1247 else
1248 mWidStack->raiseWidget( mMonthView ); 1248 mWidStack->raiseWidget( mMonthView );
1249#endif 1249#endif
1250 1250
1251 emit incidenceSelected( 0 ); 1251 emit incidenceSelected( 0 );
1252 1252
1253 mComputeLayoutTimer = new QTimer( this ); 1253 mComputeLayoutTimer = new QTimer( this );
1254 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1254 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1255 1255
1256 1256
1257#ifndef DESKTOP_VERSION 1257#ifndef DESKTOP_VERSION
1258 resize( QApplication::desktop()->size() ); 1258 resize( QApplication::desktop()->size() );
1259#else 1259#else
1260 resize(640, 480 ); 1260 resize(640, 480 );
1261 updatePossible = true; 1261 updatePossible = true;
1262#endif 1262#endif
1263 computeLayout(); 1263 computeLayout();
1264 1264
1265 if ( mShowWeekView ) 1265 if ( mShowWeekView )
1266 mWidStack->raiseWidget( mWeekView ); 1266 mWidStack->raiseWidget( mWeekView );
1267 else 1267 else
1268 mWidStack->raiseWidget( mMonthView ); 1268 mWidStack->raiseWidget( mMonthView );
1269} 1269}
1270 1270
1271KOMonthView::~KOMonthView() 1271KOMonthView::~KOMonthView()
1272{ 1272{
1273 delete mContextMenu; 1273 delete mContextMenu;
1274} 1274}
1275 1275
1276void KOMonthView::selectInternalWeekNum ( int n ) 1276void KOMonthView::selectInternalWeekNum ( int n )
1277{ 1277{
1278 switchView(); 1278 switchView();
1279 if ( !KOPrefs::instance()->mMonthViewWeek ) 1279 if ( !KOPrefs::instance()->mMonthViewWeek )
1280 emit selectMonth (); 1280 emit selectMonth ();
1281 else 1281 else
1282 emit selectWeekNum ( n ); 1282 emit selectWeekNum ( n );
1283} 1283}
1284 1284
1285int KOMonthView::currentWeek() 1285int KOMonthView::currentWeek()
1286{ 1286{
1287 if ( mShowWeekView ) 1287 if ( mShowWeekView )
1288 return mWeekLabelsW[0]->getWeekNum(); 1288 return mWeekLabelsW[0]->getWeekNum();
1289 return mWeekLabels[0]->getWeekNum(); 1289 return mWeekLabels[0]->getWeekNum();
1290} 1290}
1291void KOMonthView::switchView() 1291void KOMonthView::switchView()
1292{ 1292{
1293 if ( selectedCell( ) ) 1293 if ( selectedCell( ) )
1294 selectedCell()->deselect(); 1294 selectedCell()->deselect();
1295 mShowWeekView = !mShowWeekView; 1295 mShowWeekView = !mShowWeekView;
1296 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1296 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1297 if ( clPending ) { 1297 if ( clPending ) {
1298 computeLayout(); 1298 computeLayout();
1299 updateConfig(); 1299 updateConfig();
1300 } 1300 }
1301 if ( mShowWeekView ) 1301 if ( mShowWeekView )
1302 mWidStack->raiseWidget( mWeekView ); 1302 mWidStack->raiseWidget( mWeekView );
1303 else 1303 else
1304 mWidStack->raiseWidget( mMonthView ); 1304 mWidStack->raiseWidget( mMonthView );
1305 clPending = false; 1305 clPending = false;
1306} 1306}
1307 1307
1308int KOMonthView::maxDatesHint() 1308int KOMonthView::maxDatesHint()
1309{ 1309{
1310 return mNumCells; 1310 return mNumCells;
1311} 1311}
1312 1312
1313int KOMonthView::currentDateCount() 1313int KOMonthView::currentDateCount()
1314{ 1314{
1315 return mNumCells; 1315 return mNumCells;
1316} 1316}
1317 1317
1318QPtrList<Incidence> KOMonthView::selectedIncidences() 1318QPtrList<Incidence> KOMonthView::selectedIncidences()
1319{ 1319{
1320 QPtrList<Incidence> selected; 1320 QPtrList<Incidence> selected;
1321 1321
1322 if ( mSelectedCell ) { 1322 if ( mSelectedCell ) {
1323 Incidence *incidence = mSelectedCell->selectedIncidence(); 1323 Incidence *incidence = mSelectedCell->selectedIncidence();
1324 if ( incidence ) selected.append( incidence ); 1324 if ( incidence ) selected.append( incidence );
1325 } 1325 }
1326 1326
1327 return selected; 1327 return selected;
1328} 1328}
1329 1329
1330DateList KOMonthView::selectedDates() 1330DateList KOMonthView::selectedDates()
1331{ 1331{
1332 DateList selected; 1332 DateList selected;
1333 1333
1334 if ( mSelectedCell ) { 1334 if ( mSelectedCell ) {
1335 QDate qd = mSelectedCell->selectedIncidenceDate(); 1335 QDate qd = mSelectedCell->selectedIncidenceDate();
1336 if ( qd.isValid() ) selected.append( qd ); 1336 if ( qd.isValid() ) selected.append( qd );
1337 } 1337 }
1338 1338
1339 return selected; 1339 return selected;
1340} 1340}
1341 1341
1342void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1342void KOMonthView::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 calPrinter->preview(CalPrinter::Month, fd, td); 1346 calPrinter->preview(CalPrinter::Month, fd, td);
1347#endif 1347#endif
1348} 1348}
1349 1349
1350void KOMonthView::updateConfig() 1350void KOMonthView::updateConfig()
1351{ 1351{
1352 1352
1353 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1353 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1354 1354
1355 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1355 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1356 mWeekStartsMonday = true; 1356 mWeekStartsMonday = true;
1357 } 1357 }
1358 QFontMetrics fontmetric(mDayLabels[0]->font()); 1358 QFontMetrics fontmetric(mDayLabels[0]->font());
1359 mWidthLongDayLabel = 0; 1359 mWidthLongDayLabel = 0;
1360 1360
1361 for (int i = 0; i < 7; i++) { 1361 for (int i = 0; i < 7; i++) {
1362 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1362 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1363 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1363 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1364 } 1364 }
1365 bool temp = mShowSatSunComp ; 1365 bool temp = mShowSatSunComp ;
1366 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1366 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1367 if ( ! mShowWeekView ) { 1367 if ( ! mShowWeekView ) {
1368 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1368 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1369 computeLayout(); 1369 computeLayout();
1370 } 1370 }
1371 updateDayLabels(); 1371 updateDayLabels();
1372 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1372 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1373 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1373 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1374 //resizeEvent( 0 ); 1374 //resizeEvent( 0 );
1375 for (uint i = 0; i < mCells.count(); ++i) { 1375 for (uint i = 0; i < mCells.count(); ++i) {
1376 mCells[i]->updateConfig(); 1376 mCells[i]->updateConfig();
1377 } 1377 }
1378 1378
1379 for (uint i = 0; i < mCellsW.count(); ++i) { 1379 for (uint i = 0; i < mCellsW.count(); ++i) {
1380 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1380 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1381 } 1381 }
1382#ifdef DESKTOP_VERSION 1382#ifdef DESKTOP_VERSION
1383 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1383 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1384#endif 1384#endif
1385 updateView(); 1385 updateView();
1386} 1386}
1387 1387
1388void KOMonthView::updateDayLabels() 1388void KOMonthView::updateDayLabels()
1389{ 1389{
1390 1390
1391 QPtrVector<QLabel> *mDayLabelsT; 1391 QPtrVector<QLabel> *mDayLabelsT;
1392 1392
1393 mDayLabelsT = &mDayLabelsW; 1393 mDayLabelsT = &mDayLabelsW;
1394 for (int i = 0; i < 7; i++) { 1394 for (int i = 0; i < 7; i++) {
1395 { 1395 {
1396 bool show = mShortDayLabelsW; 1396 bool show = mShortDayLabelsW;
1397 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1397 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1398 show = true; 1398 show = true;
1399 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1399 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1400 } 1400 }
1401 } 1401 }
1402 mDayLabelsT = &mDayLabels; 1402 mDayLabelsT = &mDayLabels;
1403 for (int i = 0; i < 7; i++) { 1403 for (int i = 0; i < 7; i++) {
1404 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1404 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1405 bool show = mShortDayLabelsM; 1405 bool show = mShortDayLabelsM;
1406 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1406 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1407 show = true; 1407 show = true;
1408 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1408 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1409 } else { 1409 } else {
1410 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1410 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1411 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1411 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1412 1412
1413 } 1413 }
1414 } 1414 }
1415 1415
1416} 1416}
1417 1417
1418void KOMonthView::clearList()
1419{
1420 unsigned int i;
1421 for( i = 0; i < mCells.size(); ++i ) {
1422 mCells[i]->clear();
1423 }
1424 for( i = 0; i < mCellsW.size(); ++i ) {
1425 mCellsW[i]->clear();
1426 }
1427}
1418void KOMonthView::showDates(const QDate &start, const QDate &) 1428void KOMonthView::showDates(const QDate &start, const QDate &)
1419{ 1429{
1420 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1430 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1421 1431
1422 QPtrVector<MonthViewCell> *cells; 1432 QPtrVector<MonthViewCell> *cells;
1423 QPtrVector<QLabel> *dayLabels; 1433 QPtrVector<QLabel> *dayLabels;
1424 QPtrVector<KOWeekButton> *weekLabels; 1434 QPtrVector<KOWeekButton> *weekLabels;
1425 int weekNum = 6; 1435 int weekNum = 6;
1426 mStartDate = start; 1436 mStartDate = start;
1427 if ( mShowWeekView ) { 1437 if ( mShowWeekView ) {
1428 weekNum = 1; 1438 weekNum = 1;
1429 cells = &mCellsW; 1439 cells = &mCellsW;
1430 dayLabels = &mDayLabelsW; 1440 dayLabels = &mDayLabelsW;
1431 weekLabels = &mWeekLabelsW; 1441 weekLabels = &mWeekLabelsW;
1432 if ( !KGlobal::locale()->weekStartsMonday() ) { 1442 if ( !KGlobal::locale()->weekStartsMonday() ) {
1433 mStartDate = mStartDate.addDays( 1 ); 1443 mStartDate = mStartDate.addDays( 1 );
1434 } 1444 }
1435 } else { 1445 } else {
1436 cells = &mCells; 1446 cells = &mCells;
1437 dayLabels = &mDayLabels; 1447 dayLabels = &mDayLabels;
1438 weekLabels = &mWeekLabels; 1448 weekLabels = &mWeekLabels;
1439 } 1449 }
1440 1450
1441 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1451 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1442 1452
1443 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1453 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1444 mWeekStartsMonday = true; 1454 mWeekStartsMonday = true;
1445 } 1455 }
1446 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1456 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1447 1457
1448 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1458 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1449 mStartDate = mStartDate.addDays( -1 ); 1459 mStartDate = mStartDate.addDays( -1 );
1450 } 1460 }
1451 bool primary = false; 1461 bool primary = false;
1452 uint i; 1462 uint i;
1453 for( i = 0; i < (*cells).size(); ++i ) { 1463 for( i = 0; i < (*cells).size(); ++i ) {
1454 QDate date = mStartDate.addDays( i ); 1464 QDate date = mStartDate.addDays( i );
1455 (*cells)[i]->setDate( date ); 1465 (*cells)[i]->setDate( date );
1456 1466
1457#ifndef KORG_NOPLUGINS 1467#ifndef KORG_NOPLUGINS
1458 // add holiday, if present 1468 // add holiday, if present
1459 QString hstring(KOCore::self()->holiday(date)); 1469 QString hstring(KOCore::self()->holiday(date));
1460 (*cells)[i]->setHoliday( hstring ); 1470 (*cells)[i]->setHoliday( hstring );
1461#endif 1471#endif
1462 1472
1463 } 1473 }
1464 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1474 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1465 for( i = 0; i < weekNum; ++i ) { 1475 for( i = 0; i < weekNum; ++i ) {
1466 int wno; 1476 int wno;
1467 // remember, according to ISO 8601, the first week of the year is the 1477 // remember, according to ISO 8601, the first week of the year is the
1468 // first week that contains a thursday. Thus we must subtract off 4, 1478 // first week that contains a thursday. Thus we must subtract off 4,
1469 // not just 1. 1479 // not just 1.
1470 int dayOfYear = date.dayOfYear(); 1480 int dayOfYear = date.dayOfYear();
1471 if (dayOfYear % 7 != 0) 1481 if (dayOfYear % 7 != 0)
1472 wno = dayOfYear / 7 + 1; 1482 wno = dayOfYear / 7 + 1;
1473 else 1483 else
1474 wno =dayOfYear / 7; 1484 wno =dayOfYear / 7;
1475 (*weekLabels)[i]->setWeekNum( wno ); 1485 (*weekLabels)[i]->setWeekNum( wno );
1476 date = date.addDays( 7 ); 1486 date = date.addDays( 7 );
1477 } 1487 }
1478 updateView(); 1488 updateView();
1479} 1489}
1480 1490
1481void KOMonthView::showEvents(QPtrList<Event>) 1491void KOMonthView::showEvents(QPtrList<Event>)
1482{ 1492{
1483 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1493 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1484} 1494}
1485 1495
1486void KOMonthView::changeEventDisplay(Event *, int) 1496void KOMonthView::changeEventDisplay(Event *, int)
1487{ 1497{
1488 // this should be re-written to be much more efficient, but this 1498 // this should be re-written to be much more efficient, but this
1489 // quick-and-dirty-hack gets the job done for right now. 1499 // quick-and-dirty-hack gets the job done for right now.
1490 //qDebug("KOMonthView::changeEventDisplay "); 1500 //qDebug("KOMonthView::changeEventDisplay ");
1491 updateView(); 1501 updateView();
1492} 1502}
1493 1503
1494void KOMonthView::updateView() 1504void KOMonthView::updateView()
1495{ 1505{
1496 1506
1497 if ( !updatePossible ) 1507 if ( !updatePossible )
1498 return; 1508 return;
1499 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1509 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1500 //QTime ti; 1510 //QTime ti;
1501 //ti.start(); 1511 //ti.start();
1502 clearSelection(); 1512 clearSelection();
1503 QPtrVector<MonthViewCell> *cells; 1513 QPtrVector<MonthViewCell> *cells;
1504 if ( mShowWeekView ) { 1514 if ( mShowWeekView ) {
1505 cells = &mCellsW; 1515 cells = &mCellsW;
1506 } else { 1516 } else {
1507 cells = &mCells; 1517 cells = &mCells;
1508 } 1518 }
1509#if 1 1519#if 1
1510 int i; 1520 int i;
1511 int timeSpan = (*cells).size()-1; 1521 int timeSpan = (*cells).size()-1;
1512 if ( KOPrefs::instance()->mMonthViewWeek ) 1522 if ( KOPrefs::instance()->mMonthViewWeek )
1513 timeSpan = 6; 1523 timeSpan = 6;
1514 for( i = 0; i < timeSpan + 1; ++i ) { 1524 for( i = 0; i < timeSpan + 1; ++i ) {
1515 (*cells)[i]->startUpdateCell(); 1525 (*cells)[i]->startUpdateCell();
1516 } 1526 }
1517 1527
1518 QPtrList<Event> events = calendar()->events(); 1528 QPtrList<Event> events = calendar()->events();
1519 Event *event; 1529 Event *event;
1520 QDateTime dt; 1530 QDateTime dt;
1521 bool ok; 1531 bool ok;
1522 QDate endDate = mStartDate.addDays( timeSpan ); 1532 QDate endDate = mStartDate.addDays( timeSpan );
1523 for( event = events.first(); event; event = events.next() ) { // for event 1533 for( event = events.first(); event; event = events.next() ) { // for event
1524 if ( event->doesRecur() ) { 1534 if ( event->doesRecur() ) {
1525 bool last; 1535 bool last;
1526 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1536 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1527 QDateTime incidenceEnd; 1537 QDateTime incidenceEnd;
1528 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1538 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1529 bool invalid = false; 1539 bool invalid = false;
1530 while( true ) { 1540 while( true ) {
1531 if ( incidenceStart.isValid() ) { 1541 if ( incidenceStart.isValid() ) {
1532 incidenceEnd = incidenceStart.addDays( eventlen ); 1542 incidenceEnd = incidenceStart.addDays( eventlen );
1533 int st = incidenceStart.date().daysTo( endDate ); 1543 int st = incidenceStart.date().daysTo( endDate );
1534 if ( st >= 0 ) { // start before timeend 1544 if ( st >= 0 ) { // start before timeend
1535 int end = mStartDate.daysTo( incidenceEnd.date() ); 1545 int end = mStartDate.daysTo( incidenceEnd.date() );
1536 if ( end >= 0 ) { // end after timestart --- got one! 1546 if ( end >= 0 ) { // end after timestart --- got one!
1537 //normalize 1547 //normalize
1538 st = timeSpan - st; 1548 st = timeSpan - st;
1539 if ( st < 0 ) st = 0; 1549 if ( st < 0 ) st = 0;
1540 if ( end > timeSpan ) end = timeSpan; 1550 if ( end > timeSpan ) end = timeSpan;
1541 int iii; 1551 int iii;
1542 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1552 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1543 for ( iii = st;iii<= end;++iii) 1553 for ( iii = st;iii<= end;++iii)
1544 (*cells)[iii]->insertEvent( event ); 1554 (*cells)[iii]->insertEvent( event );
1545 } 1555 }
1546 } 1556 }
1547 } else { 1557 } else {
1548 if ( invalid ) 1558 if ( invalid )
1549 break; 1559 break;
1550 invalid = true; 1560 invalid = true;
1551 //qDebug("invalid %s", event->summary().latin1()); 1561 //qDebug("invalid %s", event->summary().latin1());
1552 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1562 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1553 } 1563 }
1554 if ( last ) 1564 if ( last )
1555 break; 1565 break;
1556 bool ok; 1566 bool ok;
1557 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1567 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1558 if ( ! ok ) 1568 if ( ! ok )
1559 break; 1569 break;
1560 if ( incidenceStart.date() > endDate ) 1570 if ( incidenceStart.date() > endDate )
1561 break; 1571 break;
1562 } 1572 }
1563 } else { // no recur 1573 } else { // no recur
1564 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1574 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1565 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1575 if ( event->uid().left(15) == QString("last-syncEvent-") )
1566 continue; 1576 continue;
1567 int st = event->dtStart().date().daysTo( endDate ); 1577 int st = event->dtStart().date().daysTo( endDate );
1568 if ( st >= 0 ) { // start before timeend 1578 if ( st >= 0 ) { // start before timeend
1569 int end = mStartDate.daysTo( event->dtEnd().date() ); 1579 int end = mStartDate.daysTo( event->dtEnd().date() );
1570 if ( end >= 0 ) { // end after timestart --- got one! 1580 if ( end >= 0 ) { // end after timestart --- got one!
1571 //normalize 1581 //normalize
1572 st = timeSpan - st; 1582 st = timeSpan - st;
1573 if ( st < 0 ) st = 0; 1583 if ( st < 0 ) st = 0;
1574 if ( end > timeSpan ) end = timeSpan; 1584 if ( end > timeSpan ) end = timeSpan;
1575 int iii; 1585 int iii;
1576 for ( iii = st;iii<= end;++iii) 1586 for ( iii = st;iii<= end;++iii)
1577 (*cells)[iii]->insertEvent( event ); 1587 (*cells)[iii]->insertEvent( event );
1578 } 1588 }
1579 } 1589 }
1580 } 1590 }
1581 } 1591 }
1582 // insert due todos 1592 // insert due todos
1583 QPtrList<Todo> todos = calendar()->todos( ); 1593 QPtrList<Todo> todos = calendar()->todos( );
1584 Todo *todo; 1594 Todo *todo;
1585 for(todo = todos.first(); todo; todo = todos.next()) { 1595 for(todo = todos.first(); todo; todo = todos.next()) {
1586 //insertTodo( todo ); 1596 //insertTodo( todo );
1587 if ( todo->hasDueDate() ) { 1597 if ( todo->hasDueDate() ) {
1588 int day = mStartDate.daysTo( todo->dtDue().date() ); 1598 int day = mStartDate.daysTo( todo->dtDue().date() );
1589 if ( day >= 0 && day < timeSpan + 1) { 1599 if ( day >= 0 && day < timeSpan + 1) {
1590 (*cells)[day]->insertTodo( todo ); 1600 (*cells)[day]->insertTodo( todo );
1591 } 1601 }
1592 } 1602 }
1593 } 1603 }
1594 1604
1595 for( i = 0; i < timeSpan+1; ++i ) { 1605 for( i = 0; i < timeSpan+1; ++i ) {
1596 (*cells)[i]->finishUpdateCell(); 1606 (*cells)[i]->finishUpdateCell();
1597 } 1607 }
1598 processSelectionChange(); 1608 processSelectionChange();
1599 //qApp->processEvents(); 1609 //qApp->processEvents();
1600 for( i = 0; i < timeSpan+1; ++i ) { 1610 for( i = 0; i < timeSpan+1; ++i ) {
1601 (*cells)[i]->repaintfinishUpdateCell(); 1611 (*cells)[i]->repaintfinishUpdateCell();
1602 } 1612 }
1603 setKeyBFocus(); 1613 setKeyBFocus();
1604#else 1614#else
1605 // old code 1615 // old code
1606 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1616 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1607 int i; 1617 int i;
1608 for( i = 0; i < (*cells).count(); ++i ) { 1618 for( i = 0; i < (*cells).count(); ++i ) {
1609 (*cells)[i]->updateCell(); 1619 (*cells)[i]->updateCell();
1610 } 1620 }
1611 1621
1612 //qDebug("KOMonthView::updateView() "); 1622 //qDebug("KOMonthView::updateView() ");
1613 processSelectionChange(); 1623 processSelectionChange();
1614 // qDebug("---------------------------------------------------------------------+ "); 1624 // qDebug("---------------------------------------------------------------------+ ");
1615 (*cells)[0]->setFocus(); 1625 (*cells)[0]->setFocus();
1616#endif 1626#endif
1617 1627
1618 //qDebug("update time %d ", ti.elapsed()); 1628 //qDebug("update time %d ", ti.elapsed());
1619} 1629}
1620 1630
1621void KOMonthView::setKeyBoardFocus() 1631void KOMonthView::setKeyBoardFocus()
1622{ 1632{
1623 //qDebug("KOMonthView::setKeyBoardFocus() "); 1633 //qDebug("KOMonthView::setKeyBoardFocus() ");
1624 bool shootAgain = false; 1634 bool shootAgain = false;
1625 if ( mShowWeekView ) { 1635 if ( mShowWeekView ) {
1626 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1636 shootAgain = !mWeekLabelsW[1]->hasFocus();
1627 mWeekLabelsW[1]->setFocus(); 1637 mWeekLabelsW[1]->setFocus();
1628 } 1638 }
1629 else { 1639 else {
1630 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1640 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1631 mWeekLabels[mNumWeeks]->setFocus(); 1641 mWeekLabels[mNumWeeks]->setFocus();
1632 } 1642 }
1633 if ( shootAgain ) { 1643 if ( shootAgain ) {
1634 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); 1644 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) );
1635 } 1645 }
1636} 1646}
1637void KOMonthView::setKeyBFocus() 1647void KOMonthView::setKeyBFocus()
1638{ 1648{
1639 //qDebug("KOMonthView::setKeyBFocus() "); 1649 //qDebug("KOMonthView::setKeyBFocus() ");
1640 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1650 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1641} 1651}
1642void KOMonthView::resizeEvent(QResizeEvent * e) 1652void KOMonthView::resizeEvent(QResizeEvent * e)
1643{ 1653{
1644 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1654 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1645 if ( isVisible() ) { 1655 if ( isVisible() ) {
1646 //qDebug("KOMonthView::isVisible "); 1656 //qDebug("KOMonthView::isVisible ");
1647 slotComputeLayout(); 1657 slotComputeLayout();
1648 } else 1658 } else
1649 mComputeLayoutTimer->start( 100 ); 1659 mComputeLayoutTimer->start( 100 );
1650} 1660}
1651 1661
1652void KOMonthView::slotComputeLayout() 1662void KOMonthView::slotComputeLayout()
1653{ 1663{
1654 mComputeLayoutTimer->stop(); 1664 mComputeLayoutTimer->stop();
1655 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1665 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1656 computeLayout(); 1666 computeLayout();
1657 clPending = true; 1667 clPending = true;
1658 setKeyBFocus(); 1668 setKeyBFocus();
1659} 1669}
1660void KOMonthView::computeLayoutWeek() 1670void KOMonthView::computeLayoutWeek()
1661{ 1671{
1662 static int lastWid = 0; 1672 static int lastWid = 0;
1663 static int lastHei = 0; 1673 static int lastHei = 0;
1664 int daysToShow; 1674 int daysToShow;
1665 bool combinedSatSun = false; 1675 bool combinedSatSun = false;
1666 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1676 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1667 daysToShow = 6; 1677 daysToShow = 6;
1668 combinedSatSun = true; 1678 combinedSatSun = true;
1669 } 1679 }
1670 int tWid = topLevelWidget()->size().width(); 1680 int tWid = topLevelWidget()->size().width();
1671 int tHei = topLevelWidget()->size().height(); 1681 int tHei = topLevelWidget()->size().height();
1672 1682
1673 int wid = width();//e 1683 int wid = width();//e
1674 int hei = height()-1-mNavigatorBar->height(); 1684 int hei = height()-1-mNavigatorBar->height();
1675 1685
1676 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1686 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1677 return; 1687 return;
1678 1688
1679 if ( lastWid == width() && lastHei == height() ) { 1689 if ( lastWid == width() && lastHei == height() ) {
1680 //qDebug("KOListWeekView::No compute layout needed "); 1690 //qDebug("KOListWeekView::No compute layout needed ");
1681 return; 1691 return;
1682 } 1692 }
1683 lastWid = width(); 1693 lastWid = width();
1684 lastHei = height(); 1694 lastHei = height();
1685 1695
1686 1696
1687 if ( wid < hei ) 1697 if ( wid < hei )
1688 daysToShow = 2; 1698 daysToShow = 2;
1689 else 1699 else
1690 daysToShow = 3; 1700 daysToShow = 3;
1691 mShowSatSunComp = true; 1701 mShowSatSunComp = true;
1692 combinedSatSun = true; 1702 combinedSatSun = true;
1693 1703
1694 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1704 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1695 QFontMetrics fm ( mWeekLabels[0]->font() ); 1705 QFontMetrics fm ( mWeekLabels[0]->font() );
1696 int weeklabelwid = fm.width( "888" ); 1706 int weeklabelwid = fm.width( "888" );
1697 wid -= weeklabelwid; 1707 wid -= weeklabelwid;
1698 1708
1699 int colWid = wid / daysToShow; 1709 int colWid = wid / daysToShow;
1700 int lastCol = wid - ( colWid*6 ); 1710 int lastCol = wid - ( colWid*6 );
1701 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1711 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1702 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1712 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1703 int colModulo = wid % daysToShow; 1713 int colModulo = wid % daysToShow;
1704 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1714 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1705 //qDebug("rowmod %d ", rowModulo); 1715 //qDebug("rowmod %d ", rowModulo);
1706 int i; 1716 int i;
1707 int x,y,w,h; 1717 int x,y,w,h;
1708 x= 0; 1718 x= 0;
1709 y= 0; 1719 y= 0;
1710 w = colWid; 1720 w = colWid;
1711 h = dayLabelHei ; 1721 h = dayLabelHei ;
1712 for ( i = 0; i < 7; i++) { 1722 for ( i = 0; i < 7; i++) {
1713 if ( i && !( i % daysToShow) && i < 6) { 1723 if ( i && !( i % daysToShow) && i < 6) {
1714 y += hei/(5-daysToShow); 1724 y += hei/(5-daysToShow);
1715 x = 0; 1725 x = 0;
1716 w = colWid; 1726 w = colWid;
1717 } 1727 }
1718 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1728 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1719 ++w; 1729 ++w;
1720 } 1730 }
1721 if ( i >= 5 ) { 1731 if ( i >= 5 ) {
1722 int wi = width() - x - weeklabelwid; 1732 int wi = width() - x - weeklabelwid;
1723 if ( i == 5 ) { 1733 if ( i == 5 ) {
1724 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h); 1734 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi/2+wi%2,h);
1725 } else { 1735 } else {
1726 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1736 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1727 } 1737 }
1728 x = x - w + wi - (wi/2 ); 1738 x = x - w + wi - (wi/2 );
1729 } 1739 }
1730 else { 1740 else {
1731 int wi = w; 1741 int wi = w;
1732 if ( !(( i+1) % daysToShow)) { 1742 if ( !(( i+1) % daysToShow)) {
1733 wi = width() - x - weeklabelwid; 1743 wi = width() - x - weeklabelwid;
1734 } 1744 }
1735 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h); 1745 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,wi,h);
1736 } 1746 }
1737 x += w; 1747 x += w;
1738 } 1748 }
1739 x= 0; 1749 x= 0;
1740 y= dayLabelHei; 1750 y= dayLabelHei;
1741 w = colWid; 1751 w = colWid;
1742 h = cellHei; 1752 h = cellHei;
1743 int max = 0; 1753 int max = 0;
1744 for ( i = 0; i < mCellsW.count(); ++i) { 1754 for ( i = 0; i < mCellsW.count(); ++i) {
1745 if ( i > 6 ) { 1755 if ( i > 6 ) {
1746 mCellsW[i]->hide(); 1756 mCellsW[i]->hide();
1747 continue; 1757 continue;
1748 } 1758 }
1749 1759
1750 w = colWid; 1760 w = colWid;
1751 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1761 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1752 ++w; 1762 ++w;
1753 } 1763 }
1754 if ( i == (daysToShow-1-rowModulo)*7) 1764 if ( i == (daysToShow-1-rowModulo)*7)
1755 ++h; 1765 ++h;
1756 1766
1757 if ( i >= 5 ) { 1767 if ( i >= 5 ) {
1758 if ( i ==5 ) { 1768 if ( i ==5 ) {
1759 max = h/2; 1769 max = h/2;
1760 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1770 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1761 x -= w ;y += h/2; 1771 x -= w ;y += h/2;
1762 } else { 1772 } else {
1763 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1773 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1764 ++w; 1774 ++w;
1765 } 1775 }
1766 max = h-h/2; 1776 max = h-h/2;
1767 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1777 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,max );
1768 y -= h/2; 1778 y -= h/2;
1769 } 1779 }
1770 } else { 1780 } else {
1771 max = h; 1781 max = h;
1772 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1782 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1773 } 1783 }
1774 1784
1775 1785
1776 x += w; 1786 x += w;
1777 if ( x + w/2 > wid ) { 1787 if ( x + w/2 > wid ) {
1778 x = 0; 1788 x = 0;
1779 y += h+dayLabelHei ; 1789 y += h+dayLabelHei ;
1780 } 1790 }
1781 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1791 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1782 } 1792 }
1783 y= dayLabelHei; 1793 y= dayLabelHei;
1784 h = cellHei ; 1794 h = cellHei ;
1785 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1795 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1786 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1796 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1787 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1797 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1788 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1798 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1789 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1799 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1790 updateDayLabels(); 1800 updateDayLabels();
1791 //bool forceUpdate = !updatePossible; 1801 //bool forceUpdate = !updatePossible;
1792 updatePossible = true; 1802 updatePossible = true;
1793 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1803 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1794 //if ( forceUpdate ) 1804 //if ( forceUpdate )
1795 // updateView(); 1805 // updateView();
1796} 1806}
1797void KOMonthView::computeLayout() 1807void KOMonthView::computeLayout()
1798{ 1808{
1799 1809
1800 1810
1801 static int lastWid = 0; 1811 static int lastWid = 0;
1802 static int lastHei = 0; 1812 static int lastHei = 0;
1803 1813
1804 if ( mShowWeekView ){ 1814 if ( mShowWeekView ){
1805 computeLayoutWeek(); 1815 computeLayoutWeek();
1806 return; 1816 return;
1807 } 1817 }
1808 int daysToShow = 7; 1818 int daysToShow = 7;
1809 bool combinedSatSun = false; 1819 bool combinedSatSun = false;
1810 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1820 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1811 daysToShow = 6; 1821 daysToShow = 6;
1812 combinedSatSun = true; 1822 combinedSatSun = true;
1813 } 1823 }
1814 int tWid = topLevelWidget()->size().width(); 1824 int tWid = topLevelWidget()->size().width();
1815 int tHei = topLevelWidget()->size().height(); 1825 int tHei = topLevelWidget()->size().height();
1816 1826
1817 int wid = width();//e 1827 int wid = width();//e
1818 int hei = height()-1-mNavigatorBar->height(); 1828 int hei = height()-1-mNavigatorBar->height();
1819 1829
1820 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1830 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1821 return; 1831 return;
1822 } 1832 }
1823 if ( lastWid == width() && lastHei == height() ){ 1833 if ( lastWid == width() && lastHei == height() ){
1824 //qDebug("KOMonthview::No compute layout needed "); 1834 //qDebug("KOMonthview::No compute layout needed ");
1825 return; 1835 return;
1826 } 1836 }
1827 1837
1828 lastWid = width(); 1838 lastWid = width();
1829 lastHei = height(); 1839 lastHei = height();
1830 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 1840 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
1831 QFontMetrics fm ( mWeekLabels[0]->font() ); 1841 QFontMetrics fm ( mWeekLabels[0]->font() );
1832 int weeklabelwid = fm.width( "888" ); 1842 int weeklabelwid = fm.width( "888" );
1833 wid -= weeklabelwid; 1843 wid -= weeklabelwid;
1834 1844
1835 int colWid = wid / daysToShow; 1845 int colWid = wid / daysToShow;
1836 int lastCol = wid - ( colWid*6 ); 1846 int lastCol = wid - ( colWid*6 );
1837 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1847 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1838 int cellHei = (hei - dayLabelHei) /6; 1848 int cellHei = (hei - dayLabelHei) /6;
1839 int colModulo = wid % daysToShow; 1849 int colModulo = wid % daysToShow;
1840 int rowModulo = (hei- dayLabelHei) % 6; 1850 int rowModulo = (hei- dayLabelHei) % 6;
1841 //qDebug("rowmod %d ", rowModulo); 1851 //qDebug("rowmod %d ", rowModulo);
1842 int i; 1852 int i;
1843 int x,y,w,h; 1853 int x,y,w,h;
1844 x= 0; 1854 x= 0;
1845 y= 0; 1855 y= 0;
1846 w = colWid; 1856 w = colWid;
1847 h = dayLabelHei ; 1857 h = dayLabelHei ;
1848 for ( i = 0; i < 7; i++) { 1858 for ( i = 0; i < 7; i++) {
1849 if ( i == daysToShow-colModulo ) 1859 if ( i == daysToShow-colModulo )
1850 ++w; 1860 ++w;
1851 if ( combinedSatSun ) { 1861 if ( combinedSatSun ) {
1852 if ( i >= daysToShow-1 ) { 1862 if ( i >= daysToShow-1 ) {
1853 1863
1854 if ( i == 6 ) 1864 if ( i == 6 )
1855 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); 1865 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h);
1856 else 1866 else
1857 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1867 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1858 x -= w/2 ; 1868 x -= w/2 ;
1859 } 1869 }
1860 else 1870 else
1861 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1871 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1862 } else 1872 } else
1863 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1873 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1864 x += w; 1874 x += w;
1865 } 1875 }
1866 x= 0; 1876 x= 0;
1867 y= dayLabelHei; 1877 y= dayLabelHei;
1868 w = colWid; 1878 w = colWid;
1869 h = cellHei ; 1879 h = cellHei ;
1870 int max = 0; 1880 int max = 0;
1871 for ( i = 0; i < mCells.count(); ++i) { 1881 for ( i = 0; i < mCells.count(); ++i) {
1872 //qDebug("iii %d ", i); 1882 //qDebug("iii %d ", i);
1873 w = colWid; 1883 w = colWid;
1874 if ( ((i) % 7) >= 7-colModulo ) { 1884 if ( ((i) % 7) >= 7-colModulo ) {
1875 ++w; 1885 ++w;
1876 } 1886 }
1877 if ( i == (6-rowModulo)*7) 1887 if ( i == (6-rowModulo)*7)
1878 ++h; 1888 ++h;
1879 if ( combinedSatSun ) { 1889 if ( combinedSatSun ) {
1880 if ( (i)%7 >= daysToShow-1 ) { 1890 if ( (i)%7 >= daysToShow-1 ) {
1881 if ( (i)%7 == daysToShow-1 ) { 1891 if ( (i)%7 == daysToShow-1 ) {
1882 w = width()-x-weeklabelwid; 1892 w = width()-x-weeklabelwid;
1883 max = h/2; 1893 max = h/2;
1884 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1894 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1885 x -= w ;y += h/2; 1895 x -= w ;y += h/2;
1886 } else { 1896 } else {
1887 w = width()-x-weeklabelwid; 1897 w = width()-x-weeklabelwid;
1888 max = h-h/2; 1898 max = h-h/2;
1889 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 1899 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
1890 y -= h/2; 1900 y -= h/2;
1891 } 1901 }
1892 } else { 1902 } else {
1893 max = h; 1903 max = h;
1894 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1904 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1895 } 1905 }
1896 1906
1897 } 1907 }
1898 else { 1908 else {
1899 max = h; 1909 max = h;
1900 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1910 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1901 } 1911 }
1902 x += w; 1912 x += w;
1903 if ( x + w/2 > wid ) { 1913 if ( x + w/2 > wid ) {
1904 x = 0; 1914 x = 0;
1905 y += h; 1915 y += h;
1906 } 1916 }
1907 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); 1917 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 );
1908 } 1918 }
1909 y= dayLabelHei; 1919 y= dayLabelHei;
1910 h = cellHei ; 1920 h = cellHei ;
1911 for ( i = 0; i < 6; i++) { 1921 for ( i = 0; i < 6; i++) {
1912 if ( i == (6-rowModulo)) 1922 if ( i == (6-rowModulo))
1913 ++h; 1923 ++h;
1914 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1924 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1915 y += h; 1925 y += h;
1916 } 1926 }
1917 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1927 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1918 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1928 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1919 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1929 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1920 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1930 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1921 updateDayLabels(); 1931 updateDayLabels();
1922 //bool forceUpdate = !updatePossible; 1932 //bool forceUpdate = !updatePossible;
1923 updatePossible = true; 1933 updatePossible = true;
1924 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1934 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1925} 1935}
1926 1936
1927void KOMonthView::showContextMenu( Incidence *incidence ) 1937void KOMonthView::showContextMenu( Incidence *incidence )
1928{ 1938{
1929 if( incidence ) 1939 if( incidence )
1930 mContextMenu->showIncidencePopup(incidence); 1940 mContextMenu->showIncidencePopup(incidence);
1931 else { 1941 else {
1932 //qDebug("KOMonthView::showContextMenu "); 1942 //qDebug("KOMonthView::showContextMenu ");
1933 mNewItemMenu->popup(QCursor::pos()); 1943 mNewItemMenu->popup(QCursor::pos());
1934 } 1944 }
1935 /* 1945 /*
1936 if( incidence && incidence->type() == "Event" ) { 1946 if( incidence && incidence->type() == "Event" ) {
1937 Event *event = static_cast<Event *>(incidence); 1947 Event *event = static_cast<Event *>(incidence);
1938 mContextMenu->showEventPopup(event); 1948 mContextMenu->showEventPopup(event);
1939 } else { 1949 } else {
1940 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1950 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1941 } 1951 }
1942 */ 1952 */
1943} 1953}
1944MonthViewCell * KOMonthView::selectedCell( ) 1954MonthViewCell * KOMonthView::selectedCell( )
1945{ 1955{
1946 return mSelectedCell; 1956 return mSelectedCell;
1947} 1957}
1948void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1958void KOMonthView::setSelectedCell( MonthViewCell *cell )
1949{ 1959{
1950 //qDebug("KOMonthView::setSelectedCell %d", cell); 1960 //qDebug("KOMonthView::setSelectedCell %d", cell);
1951 if ( mSelectedCell && mSelectedCell != cell ) { 1961 if ( mSelectedCell && mSelectedCell != cell ) {
1952 MonthViewCell * mvc = mSelectedCell; 1962 MonthViewCell * mvc = mSelectedCell;
1953 mSelectedCell = cell; 1963 mSelectedCell = cell;
1954 mvc->deselect(); 1964 mvc->deselect();
1955 } else 1965 } else
1956 mSelectedCell = cell; 1966 mSelectedCell = cell;
1957 // if ( mSelectedCell ) 1967 // if ( mSelectedCell )
1958 // mSelectedCell->select(); 1968 // mSelectedCell->select();
1959 if ( !mSelectedCell ) 1969 if ( !mSelectedCell )
1960 emit incidenceSelected( 0 ); 1970 emit incidenceSelected( 0 );
1961 else 1971 else
1962 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1972 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1963} 1973}
1964 1974
1965void KOMonthView::processSelectionChange() 1975void KOMonthView::processSelectionChange()
1966{ 1976{
1967 QPtrList<Incidence> incidences = selectedIncidences(); 1977 QPtrList<Incidence> incidences = selectedIncidences();
1968 if (incidences.count() > 0) { 1978 if (incidences.count() > 0) {
1969 emit incidenceSelected( incidences.first() ); 1979 emit incidenceSelected( incidences.first() );
1970 } else { 1980 } else {
1971 emit incidenceSelected( 0 ); 1981 emit incidenceSelected( 0 );
1972 clearSelection(); 1982 clearSelection();
1973 } 1983 }
1974} 1984}
1975 1985
1976void KOMonthView::clearSelection() 1986void KOMonthView::clearSelection()
1977{ 1987{
1978 if ( mSelectedCell ) { 1988 if ( mSelectedCell ) {
1979 mSelectedCell->deselect(); 1989 mSelectedCell->deselect();
1980 mSelectedCell = 0; 1990 mSelectedCell = 0;
1981 } 1991 }
1982} 1992}
1983 1993
1984void KOMonthView::keyReleaseEvent ( QKeyEvent * e) 1994void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
1985{ 1995{
1986 if ( !e->isAutoRepeat() ) { 1996 if ( !e->isAutoRepeat() ) {
1987 mFlagKeyPressed = false; 1997 mFlagKeyPressed = false;
1988 } 1998 }
1989} 1999}
1990 2000
1991void KOMonthView::keyPressEvent ( QKeyEvent * e ) 2001void KOMonthView::keyPressEvent ( QKeyEvent * e )
1992{ 2002{
1993 2003
1994 qApp->processEvents(); 2004 qApp->processEvents();
1995 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 2005 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1996 //e->ignore(); 2006 //e->ignore();
1997 e->accept(); 2007 e->accept();
1998 return; 2008 return;
1999 } 2009 }
2000 if (! e->isAutoRepeat() ) 2010 if (! e->isAutoRepeat() )
2001 mFlagKeyPressed = true; 2011 mFlagKeyPressed = true;
2002 switch(e->key()) { 2012 switch(e->key()) {
2003 case Key_Up: 2013 case Key_Up:
2004 { 2014 {
2005 if ( mShowWeekView ) { 2015 if ( mShowWeekView ) {
2006 emit selectWeekNum ( currentWeek() - 1 ); 2016 emit selectWeekNum ( currentWeek() - 1 );
2007 } 2017 }
2008 else { 2018 else {
2009 emit prevMonth(); 2019 emit prevMonth();
2010 } 2020 }
2011 } 2021 }
2012 e->accept(); 2022 e->accept();
2013 break; 2023 break;
2014 case Key_Down: 2024 case Key_Down:
2015 { 2025 {
2016 if ( mShowWeekView ) { 2026 if ( mShowWeekView ) {
2017 emit selectWeekNum ( currentWeek() +1); 2027 emit selectWeekNum ( currentWeek() +1);
2018 } 2028 }
2019 else { 2029 else {
2020 emit nextMonth(); 2030 emit nextMonth();
2021 } 2031 }
2022 2032
2023 } 2033 }
2024 e->accept(); 2034 e->accept();
2025 break; 2035 break;
2026 case Key_Return: 2036 case Key_Return:
2027 case Key_Enter: 2037 case Key_Enter:
2028 { 2038 {
2029 selectInternalWeekNum ( currentWeek() ); 2039 selectInternalWeekNum ( currentWeek() );
2030 } 2040 }
2031 e->accept(); 2041 e->accept();
2032 break; 2042 break;
2033 case Key_D: 2043 case Key_D:
2034 if ( mSelectedCell ) { 2044 if ( mSelectedCell ) {
2035 mSelectedCell->showDay(); 2045 mSelectedCell->showDay();
2036 e->accept(); 2046 e->accept();
2037 } else { 2047 } else {
2038 e->ignore(); 2048 e->ignore();
2039 } 2049 }
2040 break; 2050 break;
2041 default: 2051 default:
2042 e->ignore(); 2052 e->ignore();
2043 break; 2053 break;
2044 } 2054 }
2045} 2055}
2046 2056
2047void KOMonthView::nextCell() 2057void KOMonthView::nextCell()
2048{ 2058{
2049 bool res = focusNextPrevChild ( true ); 2059 bool res = focusNextPrevChild ( true );
2050} 2060}
2051void KOMonthView::prevCell() 2061void KOMonthView::prevCell()
2052{ 2062{
2053 focusNextPrevChild ( false ); 2063 focusNextPrevChild ( false );
2054} 2064}
2055 2065
2056void KOMonthView::slotNewTodo() 2066void KOMonthView::slotNewTodo()
2057{ 2067{
2058 //qDebug("KOMonthView::slotNewTodo() "); 2068 //qDebug("KOMonthView::slotNewTodo() ");
2059 if ( mPopupCell ){ 2069 if ( mPopupCell ){
2060 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2070 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2061 emit newTodoSignal(dt,true); 2071 emit newTodoSignal(dt,true);
2062 } 2072 }
2063 mPopupCell = 0; 2073 mPopupCell = 0;
2064} 2074}
2065void KOMonthView::slotNewEvent() 2075void KOMonthView::slotNewEvent()
2066{ 2076{
2067 if ( mPopupCell ) { 2077 if ( mPopupCell ) {
2068 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 2078 QDateTime dt( mPopupCell->date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
2069 emit newEventSignal( dt ); 2079 emit newEventSignal( dt );
2070 } 2080 }
2071 //qDebug("KOMonthView::slotNewEvent() "); 2081 //qDebug("KOMonthView::slotNewEvent() ");
2072 mPopupCell = 0; 2082 mPopupCell = 0;
2073} 2083}
2074 2084
2075void KOMonthView::slotEditJournal() 2085void KOMonthView::slotEditJournal()
2076{ 2086{
2077 if ( mPopupCell ) 2087 if ( mPopupCell )
2078 emit showJournalSignal( 7, mPopupCell->date() ); 2088 emit showJournalSignal( 7, mPopupCell->date() );
2079 //qDebug("KOMonthView::slotEditJournal() "); 2089 //qDebug("KOMonthView::slotEditJournal() ");
2080 mPopupCell = 0; 2090 mPopupCell = 0;
2081} 2091}
2082 2092
2083void KOMonthView::setPopupCell( MonthViewCell * c) 2093void KOMonthView::setPopupCell( MonthViewCell * c)
2084{ 2094{
2085 mPopupCell = c; 2095 mPopupCell = c;
2086} 2096}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index de5c014..65b5e77 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,340 +1,341 @@
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 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qintdict.h> 31#include <qintdict.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33#include <qvaluelist.h> 33#include <qvaluelist.h>
34#include <qptrvector.h> 34#include <qptrvector.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37#include <libkcal/event.h> 37#include <libkcal/event.h>
38 38
39#include "koeventview.h" 39#include "koeventview.h"
40#include "navigatorbar.h" 40#include "navigatorbar.h"
41 41
42#ifdef DESKTOP_VERSION 42#ifdef DESKTOP_VERSION
43class QToolTipGroup; 43class QToolTipGroup;
44#endif 44#endif
45 45
46class KNOWhatsThis; 46class KNOWhatsThis;
47class KOWeekButton : public QPushButton 47class KOWeekButton : public QPushButton
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 51 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
52 QPushButton( parent, name) 52 QPushButton( parent, name)
53 { 53 {
54 connect( this, SIGNAL( clicked() ), 54 connect( this, SIGNAL( clicked() ),
55 SLOT( bottonClicked() )); 55 SLOT( bottonClicked() ));
56 mNumber = -1; 56 mNumber = -1;
57 } 57 }
58 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 58 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
59 int getWeekNum() { return mNumber;} 59 int getWeekNum() { return mNumber;}
60 signals: 60 signals:
61 void selectWeekNum ( int ); 61 void selectWeekNum ( int );
62private: 62private:
63 void focusInEvent ( QFocusEvent * ){;} 63 void focusInEvent ( QFocusEvent * ){;}
64 int mNumber; 64 int mNumber;
65 void keyPressEvent ( QKeyEvent * e ) 65 void keyPressEvent ( QKeyEvent * e )
66 { 66 {
67 e->ignore(); 67 e->ignore();
68 } 68 }
69 69
70private slots : 70private slots :
71 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 71 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
72}; 72};
73 73
74class KNoScrollListBox: public QListBox 74class KNoScrollListBox: public QListBox
75{ 75{
76 Q_OBJECT 76 Q_OBJECT
77 public: 77 public:
78 KNoScrollListBox(QWidget *parent=0, const char *name=0); 78 KNoScrollListBox(QWidget *parent=0, const char *name=0);
79 ~KNoScrollListBox(); 79 ~KNoScrollListBox();
80 QString getWhatsThisText(QPoint p) ; 80 QString getWhatsThisText(QPoint p) ;
81 81
82 signals: 82 signals:
83 void shiftDown(); 83 void shiftDown();
84 void shiftUp(); 84 void shiftUp();
85 void rightClick(); 85 void rightClick();
86 void nextCell(); 86 void nextCell();
87 void prevCell(); 87 void prevCell();
88 88
89 protected slots: 89 protected slots:
90 void oneDown(); 90 void oneDown();
91 void keyPressEvent(QKeyEvent *); 91 void keyPressEvent(QKeyEvent *);
92 void keyReleaseEvent(QKeyEvent *); 92 void keyReleaseEvent(QKeyEvent *);
93 void mousePressEvent(QMouseEvent *); 93 void mousePressEvent(QMouseEvent *);
94 void focusInEvent ( QFocusEvent * ); 94 void focusInEvent ( QFocusEvent * );
95 void focusOutEvent ( QFocusEvent * ); 95 void focusOutEvent ( QFocusEvent * );
96 96
97 private: 97 private:
98 bool resetOnFocusIn; 98 bool resetOnFocusIn;
99 KNOWhatsThis * mWT; 99 KNOWhatsThis * mWT;
100}; 100};
101 101
102 102
103class MonthViewItem: public QListBoxItem 103class MonthViewItem: public QListBoxItem
104{ 104{
105 public: 105 public:
106 MonthViewItem( Incidence *, QDate qd, const QString & title ); 106 MonthViewItem( Incidence *, QDate qd, const QString & title );
107 void recycle( Incidence *incidence, QDate qd, const QString & s); 107 void recycle( Incidence *incidence, QDate qd, const QString & s);
108 void setRecur(bool on) { mRecur = on; } 108 void setRecur(bool on) { mRecur = on; }
109 void setAlarm(bool on) { mAlarm = on; } 109 void setAlarm(bool on) { mAlarm = on; }
110 void setReply(bool on) { mReply = on; } 110 void setReply(bool on) { mReply = on; }
111 void setMoreInfo(bool on) { mInfo = on; } 111 void setMoreInfo(bool on) { mInfo = on; }
112 void setMultiDay(int type) { mMultiday = type; } 112 void setMultiDay(int type) { mMultiday = type; }
113 void setMultiDayPos(int type) { mdayPos = type; } 113 void setMultiDayPos(int type) { mdayPos = type; }
114 int gettMultiDayPos() { return mdayPos; } 114 int gettMultiDayPos() { return mdayPos; }
115 void setBlockRepaint(bool on) { mblockRepaint = on; } 115 void setBlockRepaint(bool on) { mblockRepaint = on; }
116 116
117 117
118 void setPalette(const QPalette &p) { mPalette = p; } 118 void setPalette(const QPalette &p) { mPalette = p; }
119 QPalette palette() const { return mPalette; } 119 QPalette palette() const { return mPalette; }
120 120
121 Incidence *incidence() const { return mIncidence; } 121 Incidence *incidence() const { return mIncidence; }
122 QDate incidenceDate() { return mDate; } 122 QDate incidenceDate() { return mDate; }
123 123
124 protected: 124 protected:
125 virtual void paint(QPainter *); 125 virtual void paint(QPainter *);
126 virtual int height(const QListBox *) const; 126 virtual int height(const QListBox *) const;
127 virtual int width(const QListBox *) const; 127 virtual int width(const QListBox *) const;
128 128
129 private: 129 private:
130 int mdayPos; 130 int mdayPos;
131 bool isWeekItem; 131 bool isWeekItem;
132 bool mblockRepaint; 132 bool mblockRepaint;
133 int mMultiday; 133 int mMultiday;
134 bool mRecur; 134 bool mRecur;
135 bool mAlarm; 135 bool mAlarm;
136 bool mReply; 136 bool mReply;
137 bool mInfo; 137 bool mInfo;
138 138
139 QPalette mPalette; 139 QPalette mPalette;
140 QDate mDate; 140 QDate mDate;
141 141
142 Incidence *mIncidence; 142 Incidence *mIncidence;
143}; 143};
144 144
145 145
146class KOMonthView; 146class KOMonthView;
147 147
148class MonthViewCell : public KNoScrollListBox 148class MonthViewCell : public KNoScrollListBox
149{ 149{
150 Q_OBJECT 150 Q_OBJECT
151 public: 151 public:
152 MonthViewCell(KOMonthView *,QWidget* ); 152 MonthViewCell(KOMonthView *,QWidget* );
153 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 153 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
154 154
155 void setDate( const QDate & ); 155 void setDate( const QDate & );
156 QDate date() const; 156 QDate date() const;
157 157
158 void setPrimary( bool ); 158 void setPrimary( bool );
159 bool isPrimary() const; 159 bool isPrimary() const;
160 160
161 void setHoliday( bool ); 161 void setHoliday( bool );
162 void setHoliday( const QString & ); 162 void setHoliday( const QString & );
163 163
164 void updateCell(); 164 void updateCell();
165 void startUpdateCell(); 165 void startUpdateCell();
166 void finishUpdateCell(); 166 void finishUpdateCell();
167 void repaintfinishUpdateCell(); 167 void repaintfinishUpdateCell();
168 int insertEvent(Event *); 168 int insertEvent(Event *);
169 void insertTodo(Todo *); 169 void insertTodo(Todo *);
170 170
171 void updateConfig( bool bigFont = false ); 171 void updateConfig( bool bigFont = false );
172 172
173 void enableScrollBars( bool ); 173 void enableScrollBars( bool );
174 174
175 Incidence *selectedIncidence(); 175 Incidence *selectedIncidence();
176 QDate selectedIncidenceDate(); 176 QDate selectedIncidenceDate();
177 QPushButton * dateLabel() { return mLabel; } 177 QPushButton * dateLabel() { return mLabel; }
178 178
179 void deselect(); 179 void deselect();
180 void select(); 180 void select();
181#ifdef DESKTOP_VERSION 181#ifdef DESKTOP_VERSION
182 static QToolTipGroup *toolTipGroup(); 182 static QToolTipGroup *toolTipGroup();
183#endif 183#endif
184 signals: 184 signals:
185 void defaultAction( Incidence * ); 185 void defaultAction( Incidence * );
186 void newEventSignal( QDateTime ); 186 void newEventSignal( QDateTime );
187 void showDaySignal( QDate ); 187 void showDaySignal( QDate );
188 188
189 protected: 189 protected:
190 QStringList mToolTip; 190 QStringList mToolTip;
191 void resizeEvent( QResizeEvent * ); 191 void resizeEvent( QResizeEvent * );
192 192
193public slots: 193public slots:
194 void showDay(); 194 void showDay();
195 195
196 protected slots: 196 protected slots:
197 void defaultAction( QListBoxItem * ); 197 void defaultAction( QListBoxItem * );
198 void contextMenu( QListBoxItem * ); 198 void contextMenu( QListBoxItem * );
199 void selection( QListBoxItem * ); 199 void selection( QListBoxItem * );
200 void cellClicked( QListBoxItem * ); 200 void cellClicked( QListBoxItem * );
201 void newEvent(); 201 void newEvent();
202 202
203 private: 203 private:
204 int mdayCount; 204 int mdayCount;
205 QPtrList <MonthViewItem> mAvailItemList; 205 QPtrList <MonthViewItem> mAvailItemList;
206 KOMonthView *mMonthView; 206 KOMonthView *mMonthView;
207 int currentPalette; 207 int currentPalette;
208 208
209 QDate mDate; 209 QDate mDate;
210 bool mPrimary; 210 bool mPrimary;
211 bool mHoliday; 211 bool mHoliday;
212 QString mHolidayString; 212 QString mHolidayString;
213 213
214 //QLabel *mLabel; 214 //QLabel *mLabel;
215 QPushButton *mLabel; 215 QPushButton *mLabel;
216 //QListBox *mItemList; 216 //QListBox *mItemList;
217#ifdef DESKTOP_VERSION 217#ifdef DESKTOP_VERSION
218 static QToolTipGroup *mToolTipGroup; 218 static QToolTipGroup *mToolTipGroup;
219#endif 219#endif
220 QSize mLabelSize; 220 QSize mLabelSize;
221 QSize mLabelBigSize; 221 QSize mLabelBigSize;
222 QPalette mHolidayPalette; 222 QPalette mHolidayPalette;
223 QPalette mStandardPalette; 223 QPalette mStandardPalette;
224 QPalette mPrimaryPalette; 224 QPalette mPrimaryPalette;
225 QPalette mNonPrimaryPalette; 225 QPalette mNonPrimaryPalette;
226 void setMyPalette(); 226 void setMyPalette();
227 QPalette getPalette (); 227 QPalette getPalette ();
228 228
229}; 229};
230 230
231 231
232class KOMonthView: public KOEventView 232class KOMonthView: public KOEventView
233{ 233{
234 Q_OBJECT 234 Q_OBJECT
235 public: 235 public:
236 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 236 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
237 ~KOMonthView(); 237 ~KOMonthView();
238 238
239 /** Returns maximum number of days supported by the komonthview */ 239 /** Returns maximum number of days supported by the komonthview */
240 virtual int maxDatesHint(); 240 virtual int maxDatesHint();
241 241
242 /** Returns number of currently shown dates. */ 242 /** Returns number of currently shown dates. */
243 virtual int currentDateCount(); 243 virtual int currentDateCount();
244 244
245 /** returns the currently selected events */ 245 /** returns the currently selected events */
246 virtual QPtrList<Incidence> selectedIncidences(); 246 virtual QPtrList<Incidence> selectedIncidences();
247 247
248 /** returns dates of the currently selected events */ 248 /** returns dates of the currently selected events */
249 virtual DateList selectedDates(); 249 virtual DateList selectedDates();
250 250
251 virtual void printPreview(CalPrinter *calPrinter, 251 virtual void printPreview(CalPrinter *calPrinter,
252 const QDate &, const QDate &); 252 const QDate &, const QDate &);
253 bool isMonthView() { return !mShowWeekView; } 253 bool isMonthView() { return !mShowWeekView; }
254 bool isUpdatePossible() { return updatePossible; } 254 bool isUpdatePossible() { return updatePossible; }
255 255
256 MonthViewCell * selectedCell(); 256 MonthViewCell * selectedCell();
257 bool skipResize; 257 bool skipResize;
258 NavigatorBar* navigatorBar() { return mNavigatorBar ;} 258 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
259 void clearList();
259 public slots: 260 public slots:
260 void nextCell(); 261 void nextCell();
261 void prevCell(); 262 void prevCell();
262 virtual void updateView(); 263 virtual void updateView();
263 virtual void updateConfig(); 264 virtual void updateConfig();
264 virtual void showDates(const QDate &start, const QDate &end); 265 virtual void showDates(const QDate &start, const QDate &end);
265 virtual void showEvents(QPtrList<Event> eventList); 266 virtual void showEvents(QPtrList<Event> eventList);
266 267
267 void changeEventDisplay(Event *, int); 268 void changeEventDisplay(Event *, int);
268 269
269 void clearSelection(); 270 void clearSelection();
270 271
271 void showContextMenu( Incidence * ); 272 void showContextMenu( Incidence * );
272 273
273 void setSelectedCell( MonthViewCell * ); 274 void setSelectedCell( MonthViewCell * );
274 void setPopupCell( MonthViewCell * ); 275 void setPopupCell( MonthViewCell * );
275 void switchView(); 276 void switchView();
276 void setKeyBoardFocus(); 277 void setKeyBoardFocus();
277 void setKeyBFocus(); 278 void setKeyBFocus();
278 279
279 protected slots: 280 protected slots:
280 void slotNewTodo(); 281 void slotNewTodo();
281 void slotNewEvent(); 282 void slotNewEvent();
282 void slotEditJournal(); 283 void slotEditJournal();
283 void slotComputeLayout(); 284 void slotComputeLayout();
284 void selectInternalWeekNum ( int ); 285 void selectInternalWeekNum ( int );
285 void processSelectionChange(); 286 void processSelectionChange();
286 signals: 287 signals:
287 void nextMonth(); 288 void nextMonth();
288 void prevMonth(); 289 void prevMonth();
289 void selectWeekNum ( int ); 290 void selectWeekNum ( int );
290 void selectMonth (); 291 void selectMonth ();
291 void showDaySignal( QDate ); 292 void showDaySignal( QDate );
292 void newTodoSignal( QDateTime, bool ); 293 void newTodoSignal( QDateTime, bool );
293 void showJournalSignal( int,QDate ); 294 void showJournalSignal( int,QDate );
294 protected: 295 protected:
295 void resizeEvent(QResizeEvent *); 296 void resizeEvent(QResizeEvent *);
296 void viewChanged(); 297 void viewChanged();
297 void updateDayLabels(); 298 void updateDayLabels();
298 299
299 private: 300 private:
300 QTimer* mComputeLayoutTimer; 301 QTimer* mComputeLayoutTimer;
301 NavigatorBar* mNavigatorBar; 302 NavigatorBar* mNavigatorBar;
302 int currentWeek(); 303 int currentWeek();
303 bool clPending; 304 bool clPending;
304 QWidgetStack * mWidStack; 305 QWidgetStack * mWidStack;
305 QWidget* mMonthView; 306 QWidget* mMonthView;
306 QWidget* mWeekView; 307 QWidget* mWeekView;
307 bool mShowWeekView; 308 bool mShowWeekView;
308 bool updatePossible; 309 bool updatePossible;
309 int mDaysPerWeek; 310 int mDaysPerWeek;
310 int mNumWeeks; 311 int mNumWeeks;
311 int mNumCells; 312 int mNumCells;
312 //bool mWeekStartsMonday; 313 //bool mWeekStartsMonday;
313 bool mShowSatSunComp; 314 bool mShowSatSunComp;
314 void computeLayout(); 315 void computeLayout();
315 void computeLayoutWeek(); 316 void computeLayoutWeek();
316 317
317 QPtrVector<MonthViewCell> mCells; 318 QPtrVector<MonthViewCell> mCells;
318 QPtrVector<QLabel> mDayLabels; 319 QPtrVector<QLabel> mDayLabels;
319 QPtrVector<KOWeekButton> mWeekLabels; 320 QPtrVector<KOWeekButton> mWeekLabels;
320 QPtrVector<MonthViewCell> mCellsW; 321 QPtrVector<MonthViewCell> mCellsW;
321 QPtrVector<QLabel> mDayLabelsW; 322 QPtrVector<QLabel> mDayLabelsW;
322 QPtrVector<KOWeekButton> mWeekLabelsW; 323 QPtrVector<KOWeekButton> mWeekLabelsW;
323 324
324 bool mShortDayLabelsM; 325 bool mShortDayLabelsM;
325 bool mShortDayLabelsW; 326 bool mShortDayLabelsW;
326 int mWidthLongDayLabel; 327 int mWidthLongDayLabel;
327 328
328 QDate mStartDate; 329 QDate mStartDate;
329 330
330 MonthViewCell *mSelectedCell; 331 MonthViewCell *mSelectedCell;
331 MonthViewCell *mPopupCell; 332 MonthViewCell *mPopupCell;
332 bool mFlagKeyPressed; 333 bool mFlagKeyPressed;
333 KOEventPopupMenu *mContextMenu; 334 KOEventPopupMenu *mContextMenu;
334 QPopupMenu *mNewItemMenu; 335 QPopupMenu *mNewItemMenu;
335 void keyPressEvent ( QKeyEvent * ) ; 336 void keyPressEvent ( QKeyEvent * ) ;
336 void keyReleaseEvent ( QKeyEvent * ) ; 337 void keyReleaseEvent ( QKeyEvent * ) ;
337 338
338}; 339};
339 340
340#endif 341#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index fb4de37..5d9af6d 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,838 +1,849 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 flagResetViewChangeDate = 0; 64 flagResetViewChangeDate = 0;
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") { 91 else if (view == "Month") {
92 if ( !KOPrefs::instance()->mMonthViewWeek ) 92 if ( !KOPrefs::instance()->mMonthViewWeek )
93 showMonthView(); 93 showMonthView();
94 else 94 else
95 showMonthViewWeek(); 95 showMonthViewWeek();
96 } 96 }
97 else if (view == "List") showListView(); 97 else if (view == "List") showListView();
98 else if (view == "Journal") showJournalView(); 98 else if (view == "Journal") showJournalView();
99 else if (view == "TimeSpan") showTimeSpanView(); 99 else if (view == "TimeSpan") showTimeSpanView();
100 else if (view == "Todo") showTodoView(); 100 else if (view == "Todo") showTodoView();
101 else { 101 else {
102 config->setGroup( "Views" ); 102 config->setGroup( "Views" );
103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
104 mCurrentAgendaView = dateCount; 104 mCurrentAgendaView = dateCount;
105 showAgendaView(); 105 showAgendaView();
106 mCurrentAgendaView = dateCount; 106 mCurrentAgendaView = dateCount;
107#ifdef DESKTOP_VERSION 107#ifdef DESKTOP_VERSION
108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
109#endif 109#endif
110 } 110 }
111} 111}
112 112
113void KOViewManager::showDateView( int view, QDate date) 113void KOViewManager::showDateView( int view, QDate date)
114{ 114{
115 static int lastMode = 0; 115 static int lastMode = 0;
116 static int lastCount = 0; 116 static int lastCount = 0;
117 static bool lastNDMode = false; 117 static bool lastNDMode = false;
118 static QDate lastDate; 118 static QDate lastDate;
119 //qDebug("date %d %s", view, date.toString().latin1()); 119 //qDebug("date %d %s", view, date.toString().latin1());
120 120
121 if (view != 9) 121 if (view != 9)
122 lastMode = 0; 122 lastMode = 0;
123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
124 bool savemFlagShowNextxDays = mFlagShowNextxDays; 124 bool savemFlagShowNextxDays = mFlagShowNextxDays;
125 mFlagShowNextxDays = false; 125 mFlagShowNextxDays = false;
126 if ( view == 3 ) { 126 if ( view == 3 ) {
127 //mCurrentAgendaView = 1 ; 127 //mCurrentAgendaView = 1 ;
128 lastDate = mMainView->dateNavigator()->selectedDates().first(); 128 lastDate = mMainView->dateNavigator()->selectedDates().first();
129 lastCount = mMainView->dateNavigator()->selectedDates().count(); 129 lastCount = mMainView->dateNavigator()->selectedDates().count();
130 lastNDMode = savemFlagShowNextxDays; 130 lastNDMode = savemFlagShowNextxDays;
131 mMainView->dateNavigator()->selectDate( date ); 131 mMainView->dateNavigator()->selectDate( date );
132 lastMode = 1; 132 lastMode = 1;
133 mCurrentAgendaView = 1 ; 133 mCurrentAgendaView = 1 ;
134 } else if (view == 4 ) { 134 } else if (view == 4 ) {
135 mCurrentAgendaView = 7 ; 135 mCurrentAgendaView = 7 ;
136 mMainView->dateNavigator()->selectDates( date, 7 ); 136 mMainView->dateNavigator()->selectDates( date, 7 );
137 } else if (view == 5 ) { 137 } else if (view == 5 ) {
138 mCurrentAgendaView = 14 ; 138 mCurrentAgendaView = 14 ;
139 mMainView->dateNavigator()->selectDates( date, 14); 139 mMainView->dateNavigator()->selectDates( date, 14);
140 } else if (view == 6 ) { 140 } else if (view == 6 ) {
141 resetDateSilent( date,1); 141 resetDateSilent( date,1);
142 showMonthView(); 142 showMonthView();
143 } else if (view == 7 ) { 143 } else if (view == 7 ) {
144 mMainView->dateNavigator()->selectDate( date ); 144 mMainView->dateNavigator()->selectDate( date );
145 showJournalView(); 145 showJournalView();
146 } else if (view == 8 ) { 146 } else if (view == 8 ) {
147 globalFlagBlockAgenda = 1; 147 globalFlagBlockAgenda = 1;
148 if ( mCurrentAgendaView != 3 ) 148 if ( mCurrentAgendaView != 3 )
149 mCurrentAgendaView = -1; 149 mCurrentAgendaView = -1;
150 showAgendaView(KOPrefs::instance()->mFullViewMonth); 150 showAgendaView(KOPrefs::instance()->mFullViewMonth);
151 globalFlagBlockAgenda = 2; 151 globalFlagBlockAgenda = 2;
152 mMainView->dateNavigator()->selectDates( date , 152 mMainView->dateNavigator()->selectDates( date ,
153 KOPrefs::instance()->mNextXDays ); 153 KOPrefs::instance()->mNextXDays );
154 mFlagShowNextxDays = true; 154 mFlagShowNextxDays = true;
155 mCurrentAgendaView = 3 ; 155 mCurrentAgendaView = 3 ;
156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
157 if ( lastMode ) { 157 if ( lastMode ) {
158 mCurrentAgendaView = lastCount ; 158 mCurrentAgendaView = lastCount ;
159 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 159 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
160 mFlagShowNextxDays = lastNDMode; 160 mFlagShowNextxDays = lastNDMode;
161 if ( mFlagShowNextxDays ) { 161 if ( mFlagShowNextxDays ) {
162 mCurrentAgendaView = 3 ; 162 mCurrentAgendaView = 3 ;
163 } 163 }
164 } else 164 } else
165 showWeekView(); 165 showWeekView();
166 } else if (view == 10) { 166 } else if (view == 10) {
167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
168 } 168 }
169} 169}
170 170
171 171
172 172
173void KOViewManager::writeSettings(KConfig *config) 173void KOViewManager::writeSettings(KConfig *config)
174{ 174{
175 config->setGroup("General"); 175 config->setGroup("General");
176 176
177 QString view; 177 QString view;
178 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 178 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
179 else if (mCurrentView == mMonthView) view = "Month"; 179 else if (mCurrentView == mMonthView) view = "Month";
180 else if (mCurrentView == mListView) view = "List"; 180 else if (mCurrentView == mListView) view = "List";
181 else if (mCurrentView == mJournalView) view = "Journal"; 181 else if (mCurrentView == mJournalView) view = "Journal";
182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
183 else if (mCurrentView == mTodoView) view = "Todo"; 183 else if (mCurrentView == mTodoView) view = "Todo";
184 else view = "Agenda"; 184 else view = "Agenda";
185 185
186 config->writeEntry("Current View",view); 186 config->writeEntry("Current View",view);
187 187
188 if (mAgendaView) { 188 if (mAgendaView) {
189 mAgendaView->writeSettings(config); 189 mAgendaView->writeSettings(config);
190 } 190 }
191 if (mTimeSpanView) { 191 if (mTimeSpanView) {
192 mTimeSpanView->writeSettings(config); 192 mTimeSpanView->writeSettings(config);
193 } 193 }
194 if (mListView) { 194 if (mListView) {
195 mListView->writeSettings(config); 195 mListView->writeSettings(config);
196 } 196 }
197 if (mTodoView) { 197 if (mTodoView) {
198 mTodoView->saveLayout(config,"Todo View"); 198 mTodoView->saveLayout(config,"Todo View");
199 } 199 }
200} 200}
201void KOViewManager::showNextView() 201void KOViewManager::showNextView()
202{ 202{
203 static int selecteddatescount = 0; 203 static int selecteddatescount = 0;
204 static QDate selecteddate = QDate ( 2000, 1, 1 ); 204 static QDate selecteddate = QDate ( 2000, 1, 1 );
205 static QDate baseCycleDate = QDate ( 2000, 1, 1 ); 205 static QDate baseCycleDate = QDate ( 2000, 1, 1 );
206 int newCount = mMainView->dateNavigator()->selectedDates().count(); 206 int newCount = mMainView->dateNavigator()->selectedDates().count();
207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { 207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) {
208 flagResetViewChangeDate = 1; 208 flagResetViewChangeDate = 1;
209 } 209 }
210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) 210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() )
211 flagResetViewChangeDate = 1; 211 flagResetViewChangeDate = 1;
212 if ( flagResetViewChangeDate > 0 ) { 212 if ( flagResetViewChangeDate > 0 ) {
213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); 213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first();
214 //qDebug("newCycle "); 214 //qDebug("newCycle ");
215 } 215 }
216 if (mCurrentView == mWhatsNextView) goto NEXT_X; 216 if (mCurrentView == mWhatsNextView) goto NEXT_X;
217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; 217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL;
218 if (mCurrentView == mJournalView ) goto DAY_1; 218 if (mCurrentView == mJournalView ) goto DAY_1;
219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; 219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5;
220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; 220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7;
221 if (mCurrentView == mAgendaView ) goto DAY_6; 221 if (mCurrentView == mAgendaView ) goto DAY_6;
222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; 222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH;
223 if (mCurrentView == mMonthView ) goto LIST; 223 if (mCurrentView == mMonthView ) goto LIST;
224 if (mCurrentView == mListView ) goto TODO; 224 if (mCurrentView == mListView ) goto TODO;
225 // if (mCurrentView == mTodoView ) goto NEXT; 225 // if (mCurrentView == mTodoView ) goto NEXT;
226 NEXT: 226 NEXT:
227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} 227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;}
228 NEXT_X: 228 NEXT_X:
229 if ( KOPrefs::instance()->mShowIconNextDays ) { 229 if ( KOPrefs::instance()->mShowIconNextDays ) {
230 showNextXView(); 230 showNextXView();
231 goto ENTE ; 231 goto ENTE ;
232 } 232 }
233 JOURNAL: 233 JOURNAL:
234 if ( KOPrefs::instance()->mShowIconJournal ) { 234 if ( KOPrefs::instance()->mShowIconJournal ) {
235 resetDateSilent( baseCycleDate , 1 ); 235 resetDateSilent( baseCycleDate , 1 );
236 showJournalView() ;goto ENTE ;} 236 showJournalView() ;goto ENTE ;}
237 DAY_1: 237 DAY_1:
238 if ( KOPrefs::instance()->mShowIconDay1 ) { 238 if ( KOPrefs::instance()->mShowIconDay1 ) {
239 resetDateSilent( baseCycleDate , 2 ); 239 resetDateSilent( baseCycleDate , 2 );
240 showDayView() ;goto ENTE ;} 240 showDayView() ;goto ENTE ;}
241 DAY_5: 241 DAY_5:
242 if ( KOPrefs::instance()->mShowIconDay5 ) { 242 if ( KOPrefs::instance()->mShowIconDay5 ) {
243 resetDateSilent( baseCycleDate , 2 ); 243 resetDateSilent( baseCycleDate , 2 );
244 showWorkWeekView() ;goto ENTE ;} 244 showWorkWeekView() ;goto ENTE ;}
245 DAY_7: 245 DAY_7:
246 if ( KOPrefs::instance()->mShowIconDay7 ) { 246 if ( KOPrefs::instance()->mShowIconDay7 ) {
247 resetDateSilent( baseCycleDate , 2 ); 247 resetDateSilent( baseCycleDate , 2 );
248 showWeekView();goto ENTE ;} 248 showWeekView();goto ENTE ;}
249 DAY_6: 249 DAY_6:
250 if ( KOPrefs::instance()->mShowIconDay6 ) { 250 if ( KOPrefs::instance()->mShowIconDay6 ) {
251 resetDateSilent( baseCycleDate , 2 ); 251 resetDateSilent( baseCycleDate , 2 );
252 showMonthViewWeek();goto ENTE ;} 252 showMonthViewWeek();goto ENTE ;}
253 MONTH: 253 MONTH:
254 if ( KOPrefs::instance()->mShowIconMonth ) { 254 if ( KOPrefs::instance()->mShowIconMonth ) {
255 resetDateSilent( baseCycleDate , 2 ); 255 resetDateSilent( baseCycleDate , 2 );
256 showMonthView();goto ENTE ;} 256 showMonthView();goto ENTE ;}
257 LIST: 257 LIST:
258 if ( KOPrefs::instance()->mShowIconList ) { 258 if ( KOPrefs::instance()->mShowIconList ) {
259 resetDateSilent( baseCycleDate , 2 ); 259 resetDateSilent( baseCycleDate , 2 );
260 showListView() ;goto ENTE ;} 260 showListView() ;goto ENTE ;}
261 TODO: 261 TODO:
262 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 262 if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
263 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;} 263 if ( KOPrefs::instance()->mShowIconNext ) { goto NEXT ;}
264 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;} 264 if ( KOPrefs::instance()->mShowIconNextDays ) { goto NEXT_X ;}
265 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;} 265 if ( KOPrefs::instance()->mShowIconJournal ) { goto JOURNAL;}
266 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;} 266 if ( KOPrefs::instance()->mShowIconDay1 ) { goto DAY_1 ;}
267 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;} 267 if ( KOPrefs::instance()->mShowIconDay5 ) { goto DAY_5 ;}
268 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;} 268 if ( KOPrefs::instance()->mShowIconDay7 ) { goto DAY_7 ;}
269 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;} 269 if ( KOPrefs::instance()->mShowIconDay6 ) { goto DAY_6 ;}
270 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;} 270 if ( KOPrefs::instance()->mShowIconMonth ) {goto MONTH ;}
271 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;} 271 if ( KOPrefs::instance()->mShowIconList ) { goto LIST ;}
272 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;} 272 //if ( KOPrefs::instance()->mShowIconTodoview ) { showTodoView() ;goto ENTE ;}
273 ENTE: 273 ENTE:
274 flagResetViewChangeDate = 0; 274 flagResetViewChangeDate = 0;
275 selecteddatescount = mMainView->dateNavigator()->selectedDates().count(); 275 selecteddatescount = mMainView->dateNavigator()->selectedDates().count();
276 selecteddate = mMainView->dateNavigator()->selectedDates().first(); 276 selecteddate = mMainView->dateNavigator()->selectedDates().first();
277 277
278} 278}
279void KOViewManager::resetDateSilent( QDate date , int days ) 279void KOViewManager::resetDateSilent( QDate date , int days )
280{ 280{
281 mMainView->dateNavigator()->blockSignals( true ); 281 mMainView->dateNavigator()->blockSignals( true );
282 mMainView->dateNavigator()->selectDates( date , days ); 282 mMainView->dateNavigator()->selectDates( date , days );
283 mMainView->dateNavigator()->blockSignals( false ); 283 mMainView->dateNavigator()->blockSignals( false );
284} 284}
285void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 285void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
286{ 286{
287 if ( flagResetViewChangeDate < 10 ) 287 if ( flagResetViewChangeDate < 10 )
288 ++flagResetViewChangeDate; 288 ++flagResetViewChangeDate;
289 //mFlagShowNextxDays = false; 289 //mFlagShowNextxDays = false;
290 //if(view == mCurrentView) return; 290 //if(view == mCurrentView) return;
291 if ( view == 0 ) { 291 if ( view == 0 ) {
292 view = mCurrentView; 292 view = mCurrentView;
293 if ( view == 0 ) 293 if ( view == 0 )
294 return; 294 return;
295 } 295 }
296 bool callupdate = !(view == mCurrentView); 296 bool callupdate = !(view == mCurrentView);
297 bool full = fullScreen; 297 bool full = fullScreen;
298 if(view == mCurrentView && view != mWhatsNextView ) { 298 if(view == mCurrentView && view != mWhatsNextView ) {
299 if ( mCurrentAgendaView < 0 ) 299 if ( mCurrentAgendaView < 0 )
300 return; 300 return;
301 if ( view != mMonthView ) 301 if ( view != mMonthView )
302 full = mMainView->leftFrame()->isVisible(); 302 full = mMainView->leftFrame()->isVisible();
303 } else { 303 } else {
304 if ( view == mMonthView && mMonthView) 304 if ( view == mMonthView && mMonthView)
305 ;//mMonthView->skipResize = true ; 305 ;//mMonthView->skipResize = true ;
306 mCurrentView = view; 306 mCurrentView = view;
307 // bool full = fullScreen; 307 // bool full = fullScreen;
308 bool isFull = !mMainView->leftFrame()->isVisible(); 308 bool isFull = !mMainView->leftFrame()->isVisible();
309 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 309 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
310 full = true; 310 full = true;
311 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 311 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
312 full = false; 312 full = false;
313 } 313 }
314 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 314 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
315 //raiseCurrentView( full ); 315 //raiseCurrentView( full );
316 mMainView->processIncidenceSelection( 0 ); 316 mMainView->processIncidenceSelection( 0 );
317 //mMainView->updateView(); 317 //mMainView->updateView();
318 raiseCurrentView( full, callupdate ); 318 raiseCurrentView( full, callupdate );
319 mMainView->adaptNavigationUnits(); 319 mMainView->adaptNavigationUnits();
320 mMainView->updateUnmanagedViews(); 320 mMainView->updateUnmanagedViews();
321} 321}
322 322
323void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 323void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
324{ 324{
325 mCurrentAgendaView = 0; 325 mCurrentAgendaView = 0;
326 if ( fullScreen ) { 326 if ( fullScreen ) {
327 mMainView->leftFrame()->hide(); 327 mMainView->leftFrame()->hide();
328 } else { 328 } else {
329 mMainView->leftFrame()->show(); 329 mMainView->leftFrame()->show();
330 } 330 }
331 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 331 //if ( mCurrentView == mMonthView ) qApp->processEvents();
332 emit signalFullScreen( !fullScreen ); 332 emit signalFullScreen( !fullScreen );
333 if ( callUpdateView ) 333 if ( callUpdateView )
334 mMainView->updateView(); 334 mMainView->updateView();
335 335
336 if ( globalFlagBlockAgenda == 5 ) { 336 if ( globalFlagBlockAgenda == 5 ) {
337 globalFlagBlockAgenda = 4; 337 globalFlagBlockAgenda = 4;
338 globalFlagBlockAgendaItemPaint = 1; 338 globalFlagBlockAgendaItemPaint = 1;
339 } 339 }
340 mMainView->viewStack()->raiseWidget(mCurrentView); 340 mMainView->viewStack()->raiseWidget(mCurrentView);
341 if ( globalFlagBlockAgenda == 4 ) { 341 if ( globalFlagBlockAgenda == 4 ) {
342 if ( mCurrentView == mAgendaView ) { 342 if ( mCurrentView == mAgendaView ) {
343 //globalFlagBlockAgenda =1 ; 343 //globalFlagBlockAgenda =1 ;
344 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 344 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
345 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 345 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
346 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 346 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
347 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 347 mAgendaView->setStartHour( QTime::currentTime ().hour() );
348 qApp->processEvents(); 348 qApp->processEvents();
349 //qDebug("qApp->processEvents() "); 349 //qDebug("qApp->processEvents() ");
350 globalFlagBlockAgenda = 0; 350 globalFlagBlockAgenda = 0;
351 mAgendaView->repaintAgenda(); 351 mAgendaView->repaintAgenda();
352 352
353 } 353 }
354 globalFlagBlockAgenda = 0; 354 globalFlagBlockAgenda = 0;
355 } 355 }
356 emit signalAgendaView( mCurrentView == mAgendaView ); 356 emit signalAgendaView( mCurrentView == mAgendaView );
357 //qDebug("raiseCurrentView ende "); 357 //qDebug("raiseCurrentView ende ");
358 358
359} 359}
360 360
361void KOViewManager::clearAllViews()
362{
363
364 if ( mTodoView ) mTodoView->clearList();
365 if ( mListView ) mListView->clearList();
366
367 if ( mAgendaView ) mAgendaView->clearList();
368 if ( mMonthView ) mMonthView->clearList();
369 if ( mWhatsNextView ) mWhatsNextView->clearList();
370 if ( mJournalView ) mJournalView->clearList();
371
372}
361void KOViewManager::updateView() 373void KOViewManager::updateView()
362{ 374{
363 // qDebug("KOViewManager::updateView() "); 375 // qDebug("KOViewManager::updateView() ");
364 // if we are updating mTodoView, we get endless recursion 376 // if we are updating mTodoView, we get endless recursion
365 if ( mTodoView == mCurrentView ) 377 if ( mTodoView == mCurrentView )
366 return; 378 return;
367 if ( mCurrentView ) mCurrentView->updateView(); 379 if ( mCurrentView ) mCurrentView->updateView();
368 380
369} 381}
370 382
371void KOViewManager::updateView(const QDate &start, const QDate &end) 383void KOViewManager::updateView(const QDate &start, const QDate &end)
372{ 384{
373 // kdDebug() << "KOViewManager::updateView()" << endl; 385 // kdDebug() << "KOViewManager::updateView()" << endl;
374 386
375 if (mCurrentView) mCurrentView->showDates(start, end); 387 if (mCurrentView) mCurrentView->showDates(start, end);
376 388
377 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 389 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
378} 390}
379 391
380 392
381void KOViewManager::updateWNview() 393void KOViewManager::updateWNview()
382{ 394{
383 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 395 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
384 mWhatsNextView->updateView(); 396 mWhatsNextView->updateView();
385 if ( mCurrentView == mMonthView && mMonthView ) 397 if ( mCurrentView == mMonthView && mMonthView )
386 mMonthView->updateView(); 398 mMonthView->updateView();
387 399
388} 400}
389void KOViewManager::showWhatsNextView() 401void KOViewManager::showWhatsNextView()
390{ 402{
391 if (!mWhatsNextView) { 403 if (!mWhatsNextView) {
392 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 404 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
393 "KOViewManager::WhatsNextView"); 405 "KOViewManager::WhatsNextView");
394 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 406 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
395 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 407 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
396 addView(mWhatsNextView); 408 addView(mWhatsNextView);
397 connect(this, SIGNAL( printWNV() ), 409 connect(this, SIGNAL( printWNV() ),
398 mWhatsNextView, SLOT( printMe() ) ); 410 mWhatsNextView, SLOT( printMe() ) );
399 } 411 }
400 globalFlagBlockAgenda = 1; 412 globalFlagBlockAgenda = 1;
401 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 413 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
402 showView(mWhatsNextView, true ); 414 showView(mWhatsNextView, true );
403 //mWhatsNextView->updateView(); 415 //mWhatsNextView->updateView();
404 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW; 416 KOPrefs::instance()->mCurrentDisplayedView = VIEW_WN_VIEW;
405} 417}
406 418
407void KOViewManager::slotprintWNV() 419void KOViewManager::slotprintWNV()
408{ 420{
409 if (!mWhatsNextView) 421 if (!mWhatsNextView)
410 showWhatsNextView(); 422 showWhatsNextView();
411 emit printWNV(); 423 emit printWNV();
412 424
413} 425}
414void KOViewManager::showListView() 426void KOViewManager::showListView()
415{ 427{
416 if (!mListView) { 428 if (!mListView) {
417 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 429 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
418 addView(mListView); 430 addView(mListView);
419 431
420 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 432 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
421 mMainView, SLOT(showIncidence(Incidence *))); 433 mMainView, SLOT(showIncidence(Incidence *)));
422 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 434 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
423 mMainView, SLOT(editIncidence(Incidence *))); 435 mMainView, SLOT(editIncidence(Incidence *)));
424 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 436 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
425 mMainView, SLOT(deleteIncidence(Incidence *))); 437 mMainView, SLOT(deleteIncidence(Incidence *)));
426 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 438 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
427 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 439 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
428 connect( mListView, SIGNAL( signalNewEvent() ), 440 connect( mListView, SIGNAL( signalNewEvent() ),
429 mMainView, SLOT( newEvent() ) ); 441 mMainView, SLOT( newEvent() ) );
430 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 442 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
431 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 443 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
432 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 444 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
433 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 445 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
434 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 446 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
435 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 447 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
436 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 448 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
437 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 449 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
438 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 450 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
439 } 451 }
440 // bool temp = mFlagShowNextxDays; 452 // bool temp = mFlagShowNextxDays;
441 //globalFlagBlockPainting = true; 453 //globalFlagBlockPainting = true;
442 globalFlagBlockAgenda = 1; 454 globalFlagBlockAgenda = 1;
443 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 455 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
444 mMainView->setBlockShowDates( true ); 456 mMainView->setBlockShowDates( true );
445 mMainView->dateNavigator()->selectMonth(); 457 mMainView->dateNavigator()->selectMonth();
446 mMainView->setBlockShowDates( false ); 458 mMainView->setBlockShowDates( false );
447 } 459 }
448 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 460 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
449 showView(mListView, KOPrefs::instance()->mFullViewTodo); 461 showView(mListView, KOPrefs::instance()->mFullViewTodo);
450 //mFlagShowNextxDays = temp; 462 //mFlagShowNextxDays = temp;
451 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW; 463 KOPrefs::instance()->mCurrentDisplayedView = VIEW_L_VIEW;
452} 464}
453 465
454void KOViewManager::showAgendaView( bool fullScreen ) 466void KOViewManager::showAgendaView( bool fullScreen )
455{ 467{
456 468
457 mMainView->dialogManager()->hideSearchDialog(); 469 mMainView->dialogManager()->hideSearchDialog();
458 // qDebug("KOViewManager::showAgendaView "); 470 // qDebug("KOViewManager::showAgendaView ");
459 bool full; 471 bool full;
460 full = fullScreen; 472 full = fullScreen;
461 if (!mAgendaView) { 473 if (!mAgendaView) {
462 full = false; 474 full = false;
463 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 475 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
464 addView(mAgendaView); 476 addView(mAgendaView);
465#ifndef DESKTOP_VERSION 477#ifndef DESKTOP_VERSION
466 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 478 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
467#endif 479#endif
468 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 480 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
469 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 481 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
470 482
471 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 483 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
472 484
473 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 485 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
474 486
475 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 487 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
476 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 488 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
477 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 489 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
478 mMainView, SLOT(newEvent(QDateTime))); 490 mMainView, SLOT(newEvent(QDateTime)));
479 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 491 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
480 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 492 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
481 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 493 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
482 mMainView, SLOT(newEvent(QDate))); 494 mMainView, SLOT(newEvent(QDate)));
483 495
484 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 496 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
485 mMainView, SLOT(editIncidence(Incidence *))); 497 mMainView, SLOT(editIncidence(Incidence *)));
486 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 498 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
487 mMainView, SLOT(showIncidence(Incidence *))); 499 mMainView, SLOT(showIncidence(Incidence *)));
488 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 500 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
489 mMainView, SLOT(deleteIncidence(Incidence *))); 501 mMainView, SLOT(deleteIncidence(Incidence *)));
490 502
491 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 503 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
492 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 504 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
493 505
494 connect(mAgendaView, SIGNAL( toggleExpand() ), 506 connect(mAgendaView, SIGNAL( toggleExpand() ),
495 mMainView, SLOT( toggleExpand() ) ); 507 mMainView, SLOT( toggleExpand() ) );
496 508
497 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 509 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
498 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 510 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
499 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 511 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
500 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 512 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
501 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 513 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
502 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 514 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
503 SLOT( updateTodo( Todo *, int ) ) ); 515 SLOT( updateTodo( Todo *, int ) ) );
504 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 516 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
505 mMainView, SIGNAL( todoModified( Todo *, int ))); 517 mMainView, SIGNAL( todoModified( Todo *, int )));
506 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 518 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
507 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 519 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
508 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 520 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
509 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 521 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
510 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 522 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
511 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 523 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
512 mAgendaView->readSettings(); 524 mAgendaView->readSettings();
513 mAgendaView->updateConfig(); 525 mAgendaView->updateConfig();
514 } 526 }
515 527
516 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; 528 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
517 showView( mAgendaView, full); 529 showView( mAgendaView, full);
518 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW; 530 KOPrefs::instance()->mCurrentDisplayedView = VIEW_A_VIEW;
519} 531}
520 532
521void KOViewManager::showDayView() 533void KOViewManager::showDayView()
522{ 534{
523 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 535 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
524 mFlagShowNextxDays = false; 536 mFlagShowNextxDays = false;
525 globalFlagBlockLabel = 1; 537 globalFlagBlockLabel = 1;
526 globalFlagBlockAgenda = 1; 538 globalFlagBlockAgenda = 1;
527 if ( mCurrentAgendaView != 1 ) 539 if ( mCurrentAgendaView != 1 )
528 mCurrentAgendaView = -1; 540 mCurrentAgendaView = -1;
529 showAgendaView(); 541 showAgendaView();
530 qApp->processEvents(); 542 qApp->processEvents();
531 globalFlagBlockAgenda = 2; 543 globalFlagBlockAgenda = 2;
532 globalFlagBlockLabel = 0; 544 globalFlagBlockLabel = 0;
533 mMainView->dateNavigator()->selectDates( 1 ); 545 mMainView->dateNavigator()->selectDates( 1 );
534 mCurrentAgendaView = 1 ; 546 mCurrentAgendaView = 1 ;
535 547
536} 548}
537 549
538void KOViewManager::showWorkWeekView() 550void KOViewManager::showWorkWeekView()
539{ 551{
540 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 552 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
541 mFlagShowNextxDays = false; 553 mFlagShowNextxDays = false;
542 globalFlagBlockAgenda = 1; 554 globalFlagBlockAgenda = 1;
543 globalFlagBlockLabel = 1; 555 globalFlagBlockLabel = 1;
544 if ( mCurrentAgendaView != 5 ) 556 if ( mCurrentAgendaView != 5 )
545 mCurrentAgendaView = -1; 557 mCurrentAgendaView = -1;
546 showAgendaView(); 558 showAgendaView();
547 qApp->processEvents(); 559 qApp->processEvents();
548 globalFlagBlockAgenda = 2; 560 globalFlagBlockAgenda = 2;
549 globalFlagBlockLabel = 0; 561 globalFlagBlockLabel = 0;
550 mMainView->dateNavigator()->selectWorkWeek(); 562 mMainView->dateNavigator()->selectWorkWeek();
551 mCurrentAgendaView = 5 ; 563 mCurrentAgendaView = 5 ;
552 564
553} 565}
554 566
555void KOViewManager::showWeekView() 567void KOViewManager::showWeekView()
556{ 568{
557 569
558 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count(); 570 mCurrentAgendaView = mMainView->dateNavigator()->selectedDates().count();
559 mFlagShowNextxDays = false; 571 mFlagShowNextxDays = false;
560 globalFlagBlockAgenda = 1; 572 globalFlagBlockAgenda = 1;
561 globalFlagBlockLabel = 1; 573 globalFlagBlockLabel = 1;
562 if ( mCurrentAgendaView != 7 ) 574 if ( mCurrentAgendaView != 7 )
563 mCurrentAgendaView = -1; 575 mCurrentAgendaView = -1;
564 showAgendaView(); 576 showAgendaView();
565 qApp->processEvents(); 577 qApp->processEvents();
566 globalFlagBlockAgenda = 2; 578 globalFlagBlockAgenda = 2;
567 globalFlagBlockLabel = 0; 579 globalFlagBlockLabel = 0;
568 mMainView->dateNavigator()->selectWeek(); 580 mMainView->dateNavigator()->selectWeek();
569 mCurrentAgendaView = 7 ; 581 mCurrentAgendaView = 7 ;
570} 582}
571 583
572void KOViewManager::showNextXView() 584void KOViewManager::showNextXView()
573{ 585{
574 586
575 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; 587 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
576 globalFlagBlockAgenda = 1; 588 globalFlagBlockAgenda = 1;
577 if ( mCurrentAgendaView != 3 ) 589 if ( mCurrentAgendaView != 3 )
578 mCurrentAgendaView = -1; 590 mCurrentAgendaView = -1;
579 showAgendaView(KOPrefs::instance()->mFullViewMonth); 591 showAgendaView(KOPrefs::instance()->mFullViewMonth);
580 globalFlagBlockAgenda = 2; 592 globalFlagBlockAgenda = 2;
581 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 593 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
582 KOPrefs::instance()->mNextXDays ); 594 KOPrefs::instance()->mNextXDays );
583 mFlagShowNextxDays = true; 595 mFlagShowNextxDays = true;
584 mCurrentAgendaView = 3 ; 596 mCurrentAgendaView = 3 ;
585 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW; 597 KOPrefs::instance()->mCurrentDisplayedView = VIEW_NX_VIEW;
586} 598}
587bool KOViewManager::showsNextDays() 599bool KOViewManager::showsNextDays()
588{ 600{
589 return mFlagShowNextxDays; 601 return mFlagShowNextxDays;
590} 602}
591void KOViewManager::createMonthView() 603void KOViewManager::createMonthView()
592{ 604{
593if (!mMonthView) { 605if (!mMonthView) {
594 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 606 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
595 607
596 addView(mMonthView); 608 addView(mMonthView);
597 // mMonthView->show(); 609 // mMonthView->show();
598 // SIGNALS/SLOTS FOR MONTH VIEW 610 // SIGNALS/SLOTS FOR MONTH VIEW
599 611
600 connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate ))); 612 connect(mMonthView,SIGNAL(showJournalSignal( int, QDate )),SLOT(showDateView( int, QDate )));
601 613
602 connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)), 614 connect(mMonthView, SIGNAL(newTodoSignal(QDateTime,bool)),
603 mMainView, SLOT(newTodoDateTime(QDateTime, bool))); 615 mMainView, SLOT(newTodoDateTime(QDateTime, bool)));
604 616
605 617
606 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 618 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
607 mMainView, SLOT(newEvent(QDateTime))); 619 mMainView, SLOT(newEvent(QDateTime)));
608 620
609 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 621 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
610 mMainView, SLOT(showIncidence(Incidence *))); 622 mMainView, SLOT(showIncidence(Incidence *)));
611 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 623 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
612 mMainView, SLOT(editIncidence(Incidence *))); 624 mMainView, SLOT(editIncidence(Incidence *)));
613 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 625 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
614 mMainView, SLOT(deleteIncidence(Incidence *))); 626 mMainView, SLOT(deleteIncidence(Incidence *)));
615 627
616 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 628 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
617 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 629 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
618 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 630 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
619 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 631 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
620 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 632 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
621 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 633 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
622 634
623 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 635 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
624 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 636 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
625 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 637 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
626 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 638 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
627 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 639 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
628 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) ); 640 mMainView->dateNavigator(), SLOT ( selectWeekFromMonthView( int ) ) );
629 connect( mMonthView, SIGNAL( selectMonth() ), 641 connect( mMonthView, SIGNAL( selectMonth() ),
630 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) ); 642 mMainView->dateNavigator(), SLOT ( selectMonthFromMonthview() ) );
631 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 643 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
632 mMainView, SLOT ( showDay( QDate ) ) ); 644 mMainView, SLOT ( showDay( QDate ) ) );
633 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 645 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
634 connect( mMonthView, SIGNAL(nextMonth() ), 646 connect( mMonthView, SIGNAL(nextMonth() ),
635 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) ); 647 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
636 connect( mMonthView, SIGNAL(prevMonth() ), 648 connect( mMonthView, SIGNAL(prevMonth() ),
637 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 649 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
638 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ), 650 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
639 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) ); 651 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
640 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ), 652 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
641 mMainView->dateNavigator(), SLOT( selectNextYear() ) ); 653 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
642 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ), 654 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
643 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) ); 655 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
644 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ), 656 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
645 mMainView->dateNavigator(), SLOT( selectNextMonth() ) ); 657 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
646 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ), 658 connect( mMonthView->navigatorBar(), SIGNAL( goPrevWeek() ),
647 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) ); 659 mMainView->dateNavigator(), SLOT( selectPreviousWeek() ) );
648 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ), 660 connect( mMonthView->navigatorBar(), SIGNAL( goNextWeek() ),
649 mMainView->dateNavigator(), SLOT( selectNextWeek() ) ); 661 mMainView->dateNavigator(), SLOT( selectNextWeek() ) );
650 662
651 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 663 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
652 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) ); 664 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
653 665
654 666
655 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ), 667 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
656 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) ); 668 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
657 669
658 } 670 }
659} 671}
660void KOViewManager::showMonthViewWeek() 672void KOViewManager::showMonthViewWeek()
661{ 673{
662 createMonthView(); 674 createMonthView();
663 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; 675 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
664 globalFlagBlockAgenda = 1; 676 globalFlagBlockAgenda = 1;
665 bool full = true; 677 bool full = true;
666 if ( mCurrentView == mMonthView) 678 if ( mCurrentView == mMonthView)
667 full = mMainView->leftFrame()->isVisible(); 679 full = mMainView->leftFrame()->isVisible();
668 if ( !KOPrefs::instance()->mMonthViewWeek ) { 680 if ( !KOPrefs::instance()->mMonthViewWeek ) {
669 mMonthView->switchView(); 681 mMonthView->switchView();
670 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 682 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
671 full = false; 683 full = false;
672 else 684 else
673 full = true; 685 full = true;
674 } 686 }
675 mMainView->dateNavigator()->selectWeek(); 687 mMainView->dateNavigator()->selectWeek();
676 showView(mMonthView, full ); 688 showView(mMonthView, full );
677 mMonthView->setKeyBFocus(); 689 mMonthView->setKeyBFocus();
678 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ; 690 KOPrefs::instance()->mCurrentDisplayedView = VIEW_ML_VIEW ;
679} 691}
680 692
681void KOViewManager::showMonth( const QDate & date ) 693void KOViewManager::showMonth( const QDate & date )
682{ 694{
683 mMainView->dateNavigator()->blockSignals( true ); 695 mMainView->dateNavigator()->blockSignals( true );
684 mMainView->dateNavigator()->selectDate( date ); 696 mMainView->dateNavigator()->selectDate( date );
685 mMainView->dateNavigator()->blockSignals( false ); 697 mMainView->dateNavigator()->blockSignals( false );
686 showMonthView(); 698 showMonthView();
687} 699}
688void KOViewManager::showMonthView() 700void KOViewManager::showMonthView()
689 { 701 {
690 702
691 createMonthView(); 703 createMonthView();
692 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; 704 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
693 globalFlagBlockAgenda = 1; 705 globalFlagBlockAgenda = 1;
694 //mFlagShowNextxDays = false; 706 //mFlagShowNextxDays = false;
695 bool full = true; 707 bool full = true;
696 if ( mCurrentView == mMonthView) 708 if ( mCurrentView == mMonthView)
697 full = mMainView->leftFrame()->isVisible(); 709 full = mMainView->leftFrame()->isVisible();
698 // if(mMonthView == mCurrentView) return; 710 // if(mMonthView == mCurrentView) return;
699 if ( KOPrefs::instance()->mMonthViewWeek ) { 711 if ( KOPrefs::instance()->mMonthViewWeek ) {
700 mMonthView->switchView(); 712 mMonthView->switchView();
701 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() ) 713 if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
702 full = false; 714 full = false;
703 else 715 else
704 full = true; 716 full = true;
705 } 717 }
706 mMainView->dateNavigator()->selectMonth(); 718 mMainView->dateNavigator()->selectMonth();
707 719
708 showView(mMonthView, full ); 720 showView(mMonthView, full );
709 mMonthView->setKeyBFocus(); 721 mMonthView->setKeyBFocus();
710 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ; 722 KOPrefs::instance()->mCurrentDisplayedView = VIEW_M_VIEW ;
711 723
712} 724}
713 725
714void KOViewManager::showTodoView() 726void KOViewManager::showTodoView()
715{ 727{
716 //mFlagShowNextxDays = false; 728 //mFlagShowNextxDays = false;
717 if ( !mTodoView ) { 729 if ( !mTodoView ) {
718 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 730 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
719 "KOViewManager::TodoView" ); 731 "KOViewManager::TodoView" );
720 732
721 addView( mTodoView ); 733 addView( mTodoView );
722 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 734 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
723 735
724 // SIGNALS/SLOTS FOR TODO VIEW 736 // SIGNALS/SLOTS FOR TODO VIEW
725 connect( mTodoView, SIGNAL( newTodoSignal() ), 737 connect( mTodoView, SIGNAL( newTodoSignal() ),
726 mMainView, SLOT( newTodo() ) ); 738 mMainView, SLOT( newTodo() ) );
727 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 739 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
728 mMainView, SLOT( newSubTodo( Todo *) ) ); 740 mMainView, SLOT( newSubTodo( Todo *) ) );
729 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 741 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
730 mMainView, SLOT( showTodo( Todo * ) ) ); 742 mMainView, SLOT( showTodo( Todo * ) ) );
731 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 743 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
732 mMainView, SLOT( editTodo( Todo * ) ) ); 744 mMainView, SLOT( editTodo( Todo * ) ) );
733 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 745 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
734 mMainView, SLOT( deleteTodo( Todo * ) ) ); 746 mMainView, SLOT( deleteTodo( Todo * ) ) );
735 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 747 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
736 mMainView, SLOT( purgeCompleted() ) ); 748 mMainView, SLOT( purgeCompleted() ) );
737 749
738 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 750 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
739 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 751 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
740 752
741 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 753 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
742 SLOT( updateConfig() ) ); 754 SLOT( updateConfig() ) );
743 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 755 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
744 SLOT( updateTodo( Todo *, int ) ) ); 756 SLOT( updateTodo( Todo *, int ) ) );
745 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 757 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
746 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 758 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
747 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 759 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
748 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 760 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
749 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 761 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
750 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 762 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
751 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 763 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
752 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 764 mMainView, SLOT ( todo_unsub( Todo * ) ) );
753 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 765 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
754 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 766 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
755 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 767 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
756 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 768 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
757 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 769 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
758 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 770 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
759 KConfig *config = KOGlobals::config(); 771 KConfig *config = KOGlobals::config();
760 mTodoView->restoreLayout(config,"Todo View"); 772 mTodoView->restoreLayout(config,"Todo View");
761 mTodoView->setNavigator( mMainView->dateNavigator() ); 773 mTodoView->setNavigator( mMainView->dateNavigator() );
762 } 774 }
763 775
764 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 776 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
765 globalFlagBlockAgenda = 1; 777 globalFlagBlockAgenda = 1;
766 showView( mTodoView, true ); 778 showView( mTodoView, true );
767 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ; 779 KOPrefs::instance()->mCurrentDisplayedView = VIEW_T_VIEW ;
768 780
769} 781}
770 782
771void KOViewManager::showJournalView() 783void KOViewManager::showJournalView()
772{ 784{
773 //mFlagShowNextxDays = false; 785 //mFlagShowNextxDays = false;
774 if (!mJournalView) { 786 if (!mJournalView) {
775 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 787 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
776 "KOViewManager::JournalView"); 788 "KOViewManager::JournalView");
777 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 789 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
778 SLOT( updateConfig() ) ); 790 SLOT( updateConfig() ) );
779 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 791 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
780 addView(mJournalView); 792 addView(mJournalView);
781 } 793 }
782 794
783 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 795 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
784 showView(mJournalView); 796 showView(mJournalView);
785 mMainView->dateNavigator()->selectDates( 1 ); 797 mMainView->dateNavigator()->selectDates( 1 );
786 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ; 798 KOPrefs::instance()->mCurrentDisplayedView = VIEW_J_VIEW ;
787} 799}
788 800
789void KOViewManager::showTimeSpanView() 801void KOViewManager::showTimeSpanView()
790{ 802{
791 //mFlagShowNextxDays = false; 803 //mFlagShowNextxDays = false;
792 if (!mTimeSpanView) { 804 if (!mTimeSpanView) {
793 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 805 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
794 "KOViewManager::TimeSpanView"); 806 "KOViewManager::TimeSpanView");
795 addView(mTimeSpanView); 807 addView(mTimeSpanView);
796 808
797 mTimeSpanView->readSettings(); 809 mTimeSpanView->readSettings();
798 } 810 }
799 811
800 showView(mTimeSpanView); 812 showView(mTimeSpanView);
801} 813}
802 814
803Incidence *KOViewManager::currentSelection() 815Incidence *KOViewManager::currentSelection()
804{ 816{
805 if (!mCurrentView) return 0; 817 if (!mCurrentView) return 0;
806 if ( mCurrentView == mListView ) { 818 if ( mCurrentView == mListView ) {
807 if ( mListView->currentItem() ) 819 if ( mListView->currentItem() )
808 return mListView->currentItem(); 820 return mListView->currentItem();
809 } 821 }
810 return mCurrentView->selectedIncidences().first(); 822 return mCurrentView->selectedIncidences().first();
811} 823}
812 824
813QDate KOViewManager::currentSelectionDate() 825QDate KOViewManager::currentSelectionDate()
814{ 826{
815 QDate qd; 827 QDate qd;
816 if (mCurrentView) { 828 if (mCurrentView) {
817 DateList qvl = mCurrentView->selectedDates(); 829 DateList qvl = mCurrentView->selectedDates();
818 if (!qvl.isEmpty()) qd = qvl.first(); 830 if (!qvl.isEmpty()) qd = qvl.first();
819 } 831 }
820 return qd; 832 return qd;
821} 833}
822 834
823void KOViewManager::addView(KOrg::BaseView *view) 835void KOViewManager::addView(KOrg::BaseView *view)
824{ 836{
825#if QT_VERSION >= 0x030000 837#if QT_VERSION >= 0x030000
826 mMainView->viewStack()->addWidget( view ); 838 mMainView->viewStack()->addWidget( view );
827#else 839#else
828 mMainView->viewStack()->addWidget( view, 1 ); 840 mMainView->viewStack()->addWidget( view, 1 );
829#endif 841#endif
830} 842}
831 843
832void KOViewManager::setDocumentId( const QString &id ) 844void KOViewManager::setDocumentId( const QString &id )
833{ 845{
834 if (mTodoView) { 846 if (mTodoView) {
835 mTodoView->clearList();
836 mTodoView->setDocumentId( id ); 847 mTodoView->setDocumentId( id );
837 } 848 }
838} 849}
diff --git a/korganizer/koviewmanager.h b/korganizer/koviewmanager.h
index 8dc03e0..838583b 100644
--- a/korganizer/koviewmanager.h
+++ b/korganizer/koviewmanager.h
@@ -1,126 +1,127 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 3 Copyright (c) 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef KOVIEWMANAGER_H 24#ifndef KOVIEWMANAGER_H
25#define KOVIEWMANAGER_H 25#define KOVIEWMANAGER_H
26 26
27#include <qobject.h> 27#include <qobject.h>
28 28
29#include <korganizer/baseview.h> 29#include <korganizer/baseview.h>
30 30
31class CalendarView; 31class CalendarView;
32 32
33class KOListView; 33class KOListView;
34class KOAgendaView; 34class KOAgendaView;
35class KOMonthView; 35class KOMonthView;
36class KOTimeSpanView; 36class KOTimeSpanView;
37class KOTodoView; 37class KOTodoView;
38class KOWhatsNextView; 38class KOWhatsNextView;
39class KOJournalView; 39class KOJournalView;
40 40
41using namespace KCal; 41using namespace KCal;
42 42
43/** 43/**
44 This class manages the views of the calendar. It owns the objects and handles 44 This class manages the views of the calendar. It owns the objects and handles
45 creation and selection. 45 creation and selection.
46*/ 46*/
47class KOViewManager : public QObject 47class KOViewManager : public QObject
48{ 48{
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 KOViewManager( CalendarView * ); 51 KOViewManager( CalendarView * );
52 virtual ~KOViewManager(); 52 virtual ~KOViewManager();
53 53
54 /** changes the view to be the currently selected view */ 54 /** changes the view to be the currently selected view */
55 void showView(KOrg::BaseView *, bool fullScreen = false ); 55 void showView(KOrg::BaseView *, bool fullScreen = false );
56 void updateWNview(); 56 void updateWNview();
57 void readSettings(KConfig *config); 57 void readSettings(KConfig *config);
58 void writeSettings(KConfig *config); 58 void writeSettings(KConfig *config);
59 bool showsNextDays(); 59 bool showsNextDays();
60 /** Read which view was shown last from config file */ 60 /** Read which view was shown last from config file */
61 void readCurrentView(KConfig *); 61 void readCurrentView(KConfig *);
62 /** Write which view is currently shown to config file */ 62 /** Write which view is currently shown to config file */
63 void writeCurrentView(KConfig *); 63 void writeCurrentView(KConfig *);
64 64
65 KOrg::BaseView *currentView(); 65 KOrg::BaseView *currentView();
66 66
67 void setDocumentId( const QString & ); 67 void setDocumentId( const QString & );
68 68
69 void updateView( const QDate &start, const QDate &end ); 69 void updateView( const QDate &start, const QDate &end );
70 void clearAllViews();
70 71
71 void raiseCurrentView( bool fullScreen = false , bool updateView = false); 72 void raiseCurrentView( bool fullScreen = false , bool updateView = false);
72 73
73 void addView(KOrg::BaseView *); 74 void addView(KOrg::BaseView *);
74 75
75 Incidence *currentSelection(); 76 Incidence *currentSelection();
76 QDate currentSelectionDate(); 77 QDate currentSelectionDate();
77 78
78 KOAgendaView *agendaView() const { return mAgendaView; } 79 KOAgendaView *agendaView() const { return mAgendaView; }
79 80
80 signals: 81 signals:
81 void printWNV(); 82 void printWNV();
82 void signalFullScreen( bool ); 83 void signalFullScreen( bool );
83 void signalAgendaView( bool ); 84 void signalAgendaView( bool );
84 public slots: 85 public slots:
85 void slotprintWNV(); 86 void slotprintWNV();
86 void showNextView(); 87 void showNextView();
87 void showMonth( const QDate & ); 88 void showMonth( const QDate & );
88 void showDateView( int, QDate ); 89 void showDateView( int, QDate );
89 void updateView(); 90 void updateView();
90 void showWhatsNextView(); 91 void showWhatsNextView();
91 void showListView(); 92 void showListView();
92 void showAgendaView( bool fullScreen = false ); 93 void showAgendaView( bool fullScreen = false );
93 void showDayView(); 94 void showDayView();
94 void showWorkWeekView(); 95 void showWorkWeekView();
95 void showWeekView(); 96 void showWeekView();
96 void showNextXView(); 97 void showNextXView();
97 void showMonthView(); 98 void showMonthView();
98 void showMonthViewWeek(); 99 void showMonthViewWeek();
99 void showTodoView(); 100 void showTodoView();
100 void showJournalView(); 101 void showJournalView();
101 void showTimeSpanView(); 102 void showTimeSpanView();
102 103
103 private: 104 private:
104 void resetDateSilent( QDate date , int days ); 105 void resetDateSilent( QDate date , int days );
105 int flagResetViewChangeDate; 106 int flagResetViewChangeDate;
106 QDate currentViewChangeDate; 107 QDate currentViewChangeDate;
107 void createMonthView(); 108 void createMonthView();
108 CalendarView *mMainView; 109 CalendarView *mMainView;
109 110
110 int mCurrentAgendaView; 111 int mCurrentAgendaView;
111 KOAgendaView *mAgendaView; 112 KOAgendaView *mAgendaView;
112 KOListView *mListView; 113 KOListView *mListView;
113 KOMonthView *mMonthView; 114 KOMonthView *mMonthView;
114 KOTodoView *mTodoView; 115 KOTodoView *mTodoView;
115 KOWhatsNextView *mWhatsNextView; 116 KOWhatsNextView *mWhatsNextView;
116 KOJournalView *mJournalView; 117 KOJournalView *mJournalView;
117 KOTimeSpanView *mTimeSpanView; 118 KOTimeSpanView *mTimeSpanView;
118 119
119 KOrg::BaseView *mCurrentView; // currently active event view 120 KOrg::BaseView *mCurrentView; // currently active event view
120 121
121 int mAgendaViewMode; 122 int mAgendaViewMode;
122 bool mFlagShowNextxDays; 123 bool mFlagShowNextxDays;
123 124
124}; 125};
125 126
126#endif 127#endif
diff --git a/korganizer/kowhatsnextview.cpp b/korganizer/kowhatsnextview.cpp
index 65d8ac3..62d7ede 100644
--- a/korganizer/kowhatsnextview.cpp
+++ b/korganizer/kowhatsnextview.cpp
@@ -1,784 +1,789 @@
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 19
20#include <qlayout.h> 20#include <qlayout.h>
21#include <qtextbrowser.h> 21#include <qtextbrowser.h>
22#include <qtextcodec.h> 22#include <qtextcodec.h>
23#include <qfileinfo.h> 23#include <qfileinfo.h>
24#include <qlabel.h> 24#include <qlabel.h>
25 25
26#include <qapplication.h> 26#include <qapplication.h>
27#ifdef DESKTOP_VERSION 27#ifdef DESKTOP_VERSION
28#include <qpaintdevicemetrics.h> 28#include <qpaintdevicemetrics.h>
29#endif 29#endif
30#include <kglobal.h> 30#include <kglobal.h>
31#include <klocale.h> 31#include <klocale.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kmessagebox.h> 34#include <kmessagebox.h>
35 35
36#include <libkcal/calendar.h> 36#include <libkcal/calendar.h>
37 37
38#ifndef KORG_NOPRINTER 38#ifndef KORG_NOPRINTER
39#include "calprinter.h" 39#include "calprinter.h"
40#endif 40#endif
41#include "koglobals.h" 41#include "koglobals.h"
42#include "koprefs.h" 42#include "koprefs.h"
43#include "koeventviewerdialog.h" 43#include "koeventviewerdialog.h"
44#include "koeventviewer.h" 44#include "koeventviewer.h"
45#include <qstylesheet.h> 45#include <qstylesheet.h>
46#include "kowhatsnextview.h" 46#include "kowhatsnextview.h"
47using namespace KOrg; 47using namespace KOrg;
48 48
49void WhatsNextTextBrowser::setSource(const QString& n) 49void WhatsNextTextBrowser::setSource(const QString& n)
50{ 50{
51 51
52 if (n.startsWith("event:")) { 52 if (n.startsWith("event:")) {
53 emit showIncidence(n); 53 emit showIncidence(n);
54 return; 54 return;
55 } else if (n.startsWith("todo:")) { 55 } else if (n.startsWith("todo:")) {
56 emit showIncidence(n); 56 emit showIncidence(n);
57 return; 57 return;
58 } else { 58 } else {
59 QTextBrowser::setSource(n); 59 QTextBrowser::setSource(n);
60 } 60 }
61} 61}
62void WhatsNextTextBrowser::printMe() 62void WhatsNextTextBrowser::printMe()
63{ 63{
64#ifdef DESKTOP_VERSION 64#ifdef DESKTOP_VERSION
65 KOPrintPrefs pp ( this ); 65 KOPrintPrefs pp ( this );
66 if (!pp.exec() ) 66 if (!pp.exec() )
67 return; 67 return;
68 int scaleval = pp.printMode() ; 68 int scaleval = pp.printMode() ;
69 69
70 QPrinter printer; 70 QPrinter printer;
71 if (!printer.setup() ) 71 if (!printer.setup() )
72 return; 72 return;
73 QPainter p; 73 QPainter p;
74 p.begin ( &printer ); 74 p.begin ( &printer );
75 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 75 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
76 float dx, dy; 76 float dx, dy;
77 int wid = (m.width() * 9)/10; 77 int wid = (m.width() * 9)/10;
78 dx = (float) wid/(float)contentsWidth (); 78 dx = (float) wid/(float)contentsWidth ();
79 dy = (float)(m.height()) / (float)contentsHeight (); 79 dy = (float)(m.height()) / (float)contentsHeight ();
80 float scale; 80 float scale;
81 // scale to fit the width or height of the paper 81 // scale to fit the width or height of the paper
82 if ( dx < dy ) 82 if ( dx < dy )
83 scale = dx; 83 scale = dx;
84 else 84 else
85 scale = dy; 85 scale = dy;
86 p.translate( m.width()/10,0 ); 86 p.translate( m.width()/10,0 );
87 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 87 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
88 p.scale( scale, scale ); 88 p.scale( scale, scale );
89 } 89 }
90 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () ); 90 drawContents ( &p, 0,0, contentsWidth (), contentsHeight () );
91 p.end(); 91 p.end();
92#endif 92#endif
93} 93}
94 94
95KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent, 95KOWhatsNextView::KOWhatsNextView(Calendar *calendar, QWidget *parent,
96 const char *name) 96 const char *name)
97 : KOrg::BaseView(calendar, parent, name) 97 : KOrg::BaseView(calendar, parent, name)
98{ 98{
99 // mDateLabel = 99 // mDateLabel =
100 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this); 100 // new QLabel(KGlobal::locale()->formatDate(QDate::currentDate()),this);
101 // mDateLabel->setMargin(2); 101 // mDateLabel->setMargin(2);
102 // mDateLabel->setAlignment(AlignCenter); 102 // mDateLabel->setAlignment(AlignCenter);
103 setFont( KOPrefs::instance()->mWhatsNextFont ); 103 setFont( KOPrefs::instance()->mWhatsNextFont );
104 mView = new WhatsNextTextBrowser(this); 104 mView = new WhatsNextTextBrowser(this);
105 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &))); 105 connect(mView,SIGNAL(showIncidence(const QString &)),SLOT(showIncidence(const QString &)));
106 QStyleSheet* stsh = mView->styleSheet(); 106 QStyleSheet* stsh = mView->styleSheet();
107 QStyleSheetItem * style ; 107 QStyleSheetItem * style ;
108 style = stsh->item ("h2" ); 108 style = stsh->item ("h2" );
109 if ( style ) { 109 if ( style ) {
110 style->setMargin(QStyleSheetItem::MarginAll,0); 110 style->setMargin(QStyleSheetItem::MarginAll,0);
111 } 111 }
112 style = stsh->item ("h3" ); 112 style = stsh->item ("h3" );
113 if ( style ) { 113 if ( style ) {
114 style->setMargin(QStyleSheetItem::MarginAll,0); 114 style->setMargin(QStyleSheetItem::MarginAll,0);
115 } 115 }
116 mEventViewer = 0; 116 mEventViewer = 0;
117 117
118 QBoxLayout *topLayout = new QVBoxLayout(this); 118 QBoxLayout *topLayout = new QVBoxLayout(this);
119 // topLayout->addWidget(mDateLabel); 119 // topLayout->addWidget(mDateLabel);
120 topLayout->addWidget(mView); 120 topLayout->addWidget(mView);
121 mTimer = new QTimer( this ); 121 mTimer = new QTimer( this );
122 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView())); 122 connect(mTimer,SIGNAL( timeout() ),this, SLOT(updateView()));
123 123
124 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 124 connect(mView->horizontalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
125 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer())); 125 connect(mView->verticalScrollBar (),SIGNAL( sliderReleased () ),this, SLOT(restartTimer()));
126} 126}
127 127
128KOWhatsNextView::~KOWhatsNextView() 128KOWhatsNextView::~KOWhatsNextView()
129{ 129{
130} 130}
131 131
132int KOWhatsNextView::maxDatesHint() 132int KOWhatsNextView::maxDatesHint()
133{ 133{
134 return 0; 134 return 0;
135} 135}
136 136
137int KOWhatsNextView::currentDateCount() 137int KOWhatsNextView::currentDateCount()
138{ 138{
139 return 0; 139 return 0;
140} 140}
141 141
142void KOWhatsNextView::clearList()
143{
144 mTimer->stop();
145 mView->setText(" ");
146}
142QPtrList<Incidence> KOWhatsNextView::selectedIncidences() 147QPtrList<Incidence> KOWhatsNextView::selectedIncidences()
143{ 148{
144 QPtrList<Incidence> eventList; 149 QPtrList<Incidence> eventList;
145 150
146 return eventList; 151 return eventList;
147} 152}
148 153
149void KOWhatsNextView::printMe() 154void KOWhatsNextView::printMe()
150{ 155{
151#ifdef DESKTOP_VERSION 156#ifdef DESKTOP_VERSION
152 mView->printMe(); 157 mView->printMe();
153#endif 158#endif
154} 159}
155void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd, 160void KOWhatsNextView::printPreview(CalPrinter *calPrinter, const QDate &fd,
156 const QDate &td) 161 const QDate &td)
157{ 162{
158#ifndef KORG_NOPRINTER 163#ifndef KORG_NOPRINTER
159 calPrinter->preview(CalPrinter::Day, fd, td); 164 calPrinter->preview(CalPrinter::Day, fd, td);
160#endif 165#endif
161} 166}
162void KOWhatsNextView::updateConfig() 167void KOWhatsNextView::updateConfig()
163{ 168{
164 setFont( KOPrefs::instance()->mWhatsNextFont ); 169 setFont( KOPrefs::instance()->mWhatsNextFont );
165 updateView(); 170 updateView();
166 171
167} 172}
168void KOWhatsNextView::showEvent ( QShowEvent * e ) 173void KOWhatsNextView::showEvent ( QShowEvent * e )
169{ 174{
170 //qDebug("KOWhatsNextView::showEvent "); 175 //qDebug("KOWhatsNextView::showEvent ");
171 restartTimer(); 176 restartTimer();
172 QWidget::showEvent ( e ); 177 QWidget::showEvent ( e );
173} 178}
174void KOWhatsNextView::hideEvent ( QHideEvent * e) 179void KOWhatsNextView::hideEvent ( QHideEvent * e)
175{ 180{
176 //qDebug(" KOWhatsNextView::hideEvent"); 181 //qDebug(" KOWhatsNextView::hideEvent");
177 mTimer->stop(); 182 mTimer->stop();
178 QWidget::hideEvent ( e ); 183 QWidget::hideEvent ( e );
179} 184}
180void KOWhatsNextView::restartTimer() 185void KOWhatsNextView::restartTimer()
181{ 186{
182 //qDebug("KOWhatsNextView::restartTimer() "); 187 //qDebug("KOWhatsNextView::restartTimer() ");
183 mTimer->start( 300000 ); 188 mTimer->start( 300000 );
184 //mTimer->start( 5000 ); 189 //mTimer->start( 5000 );
185} 190}
186void KOWhatsNextView::updateView() 191void KOWhatsNextView::updateView()
187{ 192{
188 //qDebug("KOWhatsNextView::updateView() "); 193 //qDebug("KOWhatsNextView::updateView() ");
189 if ( mTimer->isActive() ) 194 if ( mTimer->isActive() )
190 restartTimer(); 195 restartTimer();
191 mCurrentMaxPrio = 5; 196 mCurrentMaxPrio = 5;
192 //qDebug("KOWhatsNextView::updateView() "); 197 //qDebug("KOWhatsNextView::updateView() ");
193 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate())); 198 // mDateLabel->setText(KGlobal::locale()->formatDate(QDate::currentDate()));
194 KIconLoader kil("korganizer"); 199 KIconLoader kil("korganizer");
195 QString ipath;// = new QString(); 200 QString ipath;// = new QString();
196 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath); 201 // kil.loadIcon("korganizer",KIcon::NoGroup,32,KIcon::DefaultState,&ipath);
197 //<big><big><strong>" + date + "</strong></big></big>\n"; 202 //<big><big><strong>" + date + "</strong></big></big>\n";
198 mText = "<table width=\"100%\">\n"; 203 mText = "<table width=\"100%\">\n";
199 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 204 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
200#ifdef DESKTOP_VERSION 205#ifdef DESKTOP_VERSION
201 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>"; 206 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h1>";
202#else 207#else
203 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 208 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
204#endif 209#endif
205 // mText += "<img src=\""; 210 // mText += "<img src=\"";
206 // mText += ipath; 211 // mText += ipath;
207 // mText += "\">"; 212 // mText += "\">";
208 mEventDate = QDate::currentDate(); 213 mEventDate = QDate::currentDate();
209#ifdef DESKTOP_VERSION 214#ifdef DESKTOP_VERSION
210 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>"; 215 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h1>";
211#else 216#else
212 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>"; 217 mText += "<font color=\"#FFFFFF\"> <em>" + KGlobal::locale()->formatDate( mEventDate , false )+"</em></font></h2>";
213#endif 218#endif
214 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 219 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
215 int iii; 220 int iii;
216 mTodos.clear(); 221 mTodos.clear();
217 QPtrList<Event> events; 222 QPtrList<Event> events;
218 QPtrList<Todo> todos = calendar()->todos(); 223 QPtrList<Todo> todos = calendar()->todos();
219 Todo * todo; 224 Todo * todo;
220 //mText += "<h2>" + i18n("Events: ") + "</h2>\n"; 225 //mText += "<h2>" + i18n("Events: ") + "</h2>\n";
221 int daysToShow = KOPrefs::instance()->mWhatsNextDays ; 226 int daysToShow = KOPrefs::instance()->mWhatsNextDays ;
222 bool itemAdded = false; 227 bool itemAdded = false;
223 for ( iii = 0; iii < daysToShow; ++iii ) { 228 for ( iii = 0; iii < daysToShow; ++iii ) {
224 QString date; 229 QString date;
225 itemAdded = false; 230 itemAdded = false;
226 events = calendar()->events( mEventDate, true ); 231 events = calendar()->events( mEventDate, true );
227 232
228 if ( iii == 0 ) { // today !!! 233 if ( iii == 0 ) { // today !!!
229 todo = todos.first(); 234 todo = todos.first();
230 while(todo) { 235 while(todo) {
231 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) { 236 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() < mEventDate ) {
232 if ( ! itemAdded ) { 237 if ( ! itemAdded ) {
233 appendDay ( iii, mEventDate ); 238 appendDay ( iii, mEventDate );
234 //itemAdded = true; 239 //itemAdded = true;
235 240
236 } //bool reply=false, bool notRed = true, bool appendTable = false); 241 } //bool reply=false, bool notRed = true, bool appendTable = false);
237 appendEvent(todo, false, false, !itemAdded ); 242 appendEvent(todo, false, false, !itemAdded );
238 itemAdded = true; 243 itemAdded = true;
239 } 244 }
240 todo = todos.next(); 245 todo = todos.next();
241 } 246 }
242 } 247 }
243 248
244 249
245 if (events.count() > 0) { 250 if (events.count() > 0) {
246 // mText += "<p></p>"; 251 // mText += "<p></p>";
247 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 252 // kil.loadIcon("month",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
248 // mText += "<h2>"; 253 // mText += "<h2>";
249 //mText += " <img src=\""; 254 //mText += " <img src=\"";
250 //mText += ipath; 255 //mText += ipath;
251 //mText += "\">"; 256 //mText += "\">";
252 if ( ! itemAdded ) { 257 if ( ! itemAdded ) {
253 appendDay ( iii, mEventDate ); 258 appendDay ( iii, mEventDate );
254 259
255 } 260 }
256 // for first day (iii == 0) 261 // for first day (iii == 0)
257 // we may have syncevents, or events in the past, which maybe should not be diaplayed 262 // we may have syncevents, or events in the past, which maybe should not be diaplayed
258 // for that reason we cannot append <table> in appendDay () for iii == 0 263 // for that reason we cannot append <table> in appendDay () for iii == 0
259 // we must append it in the first successful call of appendEvent() 264 // we must append it in the first successful call of appendEvent()
260 Event *ev = events.first(); 265 Event *ev = events.first();
261 while(ev) { 266 while(ev) {
262 //qDebug("+++++event append %s", ev->summary().latin1()); 267 //qDebug("+++++event append %s", ev->summary().latin1());
263 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) { 268 if ( true /*!ev->recurrence()->doesRecur() || ev->recursOn( mEventDate)*/) {
264 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) ) 269 if ( appendEvent(ev, false , iii!= 0,!itemAdded ) )
265 itemAdded = true; 270 itemAdded = true;
266 } 271 }
267 ev = events.next(); 272 ev = events.next();
268 } 273 }
269 274
270 //mText += "</table>\n"; 275 //mText += "</table>\n";
271 } 276 }
272 277
273 todo = todos.first(); 278 todo = todos.first();
274 while(todo) { 279 while(todo) {
275 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) { 280 if ( !todo->isCompleted() &&todo->hasDueDate() && todo->dtDue().date() == mEventDate ) {
276 if ( ! itemAdded ) { 281 if ( ! itemAdded ) {
277 appendDay ( iii, mEventDate ); 282 appendDay ( iii, mEventDate );
278 //itemAdded = true; 283 //itemAdded = true;
279 } 284 }
280 appendEvent(todo, false , iii!= 0,!itemAdded); 285 appendEvent(todo, false , iii!= 0,!itemAdded);
281 itemAdded = true; 286 itemAdded = true;
282 } 287 }
283 todo = todos.next(); 288 todo = todos.next();
284 } 289 }
285 if ( !itemAdded && iii == 0 ) { 290 if ( !itemAdded && iii == 0 ) {
286 // appendDay ( iii, mEventDate ); 291 // appendDay ( iii, mEventDate );
287 //mText += "<table>"; 292 //mText += "<table>";
288 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n"; 293 // mText += "<b><font color=\"#000080\"><em>"+i18n("No event, nothing to do.") +"</em></font></b>\n";
289 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n"; 294 mText += "<h3 align=\"center\"><font color=\"#008000\"><em>"+i18n("No event, nothing to do.") +"</em></font></h3>\n";
290 //mText +="</table>"; 295 //mText +="</table>";
291 } 296 }
292 if ( itemAdded ) 297 if ( itemAdded )
293 mText += "</table>\n"; 298 mText += "</table>\n";
294 mEventDate = mEventDate.addDays( 1 ); 299 mEventDate = mEventDate.addDays( 1 );
295 } 300 }
296 301
297 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios; 302 int topmostPrios = KOPrefs::instance()->mWhatsNextPrios;
298 if (todos.count() > 0 && topmostPrios > 0 ) { 303 if (todos.count() > 0 && topmostPrios > 0 ) {
299 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 304 // kil.loadIcon("todo",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
300 // mText += "<h2>"; 305 // mText += "<h2>";
301 //<img src=\""; 306 //<img src=\"";
302 // mText += ipath; 307 // mText += ipath;
303 // mText += "\">"; 308 // mText += "\">";
304 // mText += i18n("Overdue To-Do:") + "</h2>\n"; 309 // mText += i18n("Overdue To-Do:") + "</h2>\n";
305 310
306 //mText += "<ul>\n"; 311 //mText += "<ul>\n";
307 bool gotone = false; 312 bool gotone = false;
308 int priority = 1; 313 int priority = 1;
309 int priosFound = 0; 314 int priosFound = 0;
310#ifdef DESKTOP_VERSION 315#ifdef DESKTOP_VERSION
311 mText +="<p></p>"; 316 mText +="<p></p>";
312#endif 317#endif
313 318
314 mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n"; 319 mText +="<h2><em><font color=\"#000080\">" + i18n("Incomplete Todo:") + "</font></em></h2>\n";
315 mText += "<ul>\n"; 320 mText += "<ul>\n";
316 while (!gotone && priority<6) { 321 while (!gotone && priority<6) {
317 todo = todos.first(); 322 todo = todos.first();
318 while(todo) { 323 while(todo) {
319 if (!todo->isCompleted() && (todo->priority() == priority) ) { 324 if (!todo->isCompleted() && (todo->priority() == priority) ) {
320 mCurrentMaxPrio = priority - priosFound + topmostPrios -1; 325 mCurrentMaxPrio = priority - priosFound + topmostPrios -1;
321 if ( appendTodo(todo) ) 326 if ( appendTodo(todo) )
322 gotone = true; 327 gotone = true;
323 } 328 }
324 todo = todos.next(); 329 todo = todos.next();
325 } 330 }
326 if ( gotone ) { 331 if ( gotone ) {
327 gotone = false; 332 gotone = false;
328 ++priosFound; 333 ++priosFound;
329 if ( priosFound == topmostPrios ) 334 if ( priosFound == topmostPrios )
330 break; 335 break;
331 } 336 }
332 priority++; 337 priority++;
333 // kdDebug() << "adding the todos..." << endl; 338 // kdDebug() << "adding the todos..." << endl;
334 } 339 }
335 mText += "</ul>\n"; 340 mText += "</ul>\n";
336 } 341 }
337 342
338 int replys = 0; 343 int replys = 0;
339 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6)); 344 events = calendar()->events(QDate::currentDate(), QDate(2975,12,6));
340 if (events.count() > 0) { 345 if (events.count() > 0) {
341 Event *ev = events.first(); 346 Event *ev = events.first();
342 while(ev) { 347 while(ev) {
343 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 348 Attendee *me = ev->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
344 if (me!=0) { 349 if (me!=0) {
345 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 350 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
346 if (replys == 0) { 351 if (replys == 0) {
347 mText += "<p></p>"; 352 mText += "<p></p>";
348 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath); 353 // kil.loadIcon("reply",KIcon::NoGroup,22,KIcon::DefaultState,&ipath);
349 //mText += "<h2>"; 354 //mText += "<h2>";
350 //<img src=\""; 355 //<img src=\"";
351 // mText += ipath; 356 // mText += ipath;
352 // mText += "\">"; 357 // mText += "\">";
353 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n"; 358 //mText += i18n("Events and To-Dos that need a reply:") + "</h2>\n";
354 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; 359 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n";
355 mText += "<table>\n"; 360 mText += "<table>\n";
356 } 361 }
357 replys++; 362 replys++;
358 appendEvent(ev,true); 363 appendEvent(ev,true);
359 } 364 }
360 } 365 }
361 ev = events.next(); 366 ev = events.next();
362 } 367 }
363 } 368 }
364 todos = calendar()->todos(); 369 todos = calendar()->todos();
365 if (todos.count() > 0) { 370 if (todos.count() > 0) {
366 Todo *to = todos.first(); 371 Todo *to = todos.first();
367 while(to) { 372 while(to) {
368 if ( !to->isCompleted() ){ 373 if ( !to->isCompleted() ){
369 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 374 Attendee *me = to->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
370 if (me!=0) { 375 if (me!=0) {
371 if (me->status()==Attendee::NeedsAction && me->RSVP()) { 376 if (me->status()==Attendee::NeedsAction && me->RSVP()) {
372 if (replys == 0) { 377 if (replys == 0) {
373 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n"; 378 mText +="<h2><em><font color=\"#000080\">" + i18n("Events and To-Dos that need a reply:") + "</font></em></h2>\n";
374 mText += "<table>\n"; 379 mText += "<table>\n";
375 } 380 }
376 replys++; 381 replys++;
377 appendEvent(to, true); 382 appendEvent(to, true);
378 } 383 }
379 } 384 }
380 } 385 }
381 to = todos.next(); 386 to = todos.next();
382 } 387 }
383 } 388 }
384 if (replys > 0 ) mText += "</table>\n"; 389 if (replys > 0 ) mText += "</table>\n";
385 390
386 391
387 mText += "</td></tr>\n</table>\n"; 392 mText += "</td></tr>\n</table>\n";
388 393
389 mView->setText(mText); 394 mView->setText(mText);
390 mView->setFocus(); 395 mView->setFocus();
391 396
392 // QPixmap bPix = SmallIcon( "back" ); 397 // QPixmap bPix = SmallIcon( "back" );
393 // qDebug("xxxxxxxxxxxxxxxxxxxxx "); 398 // qDebug("xxxxxxxxxxxxxxxxxxxxx ");
394 // QWidget* test = new QWidget(); 399 // QWidget* test = new QWidget();
395 // test->setBackgroundMode(FixedPixmap ); 400 // test->setBackgroundMode(FixedPixmap );
396 // test->setBackgroundPixmap ( bPix ); 401 // test->setBackgroundPixmap ( bPix );
397 // test->resize( 300, 400 ); 402 // test->resize( 300, 400 );
398 // test->show(); 403 // test->show();
399 // mView->setBackgroundMode(FixedPixmap ); 404 // mView->setBackgroundMode(FixedPixmap );
400 // mView->setBackgroundPixmap ( bPix ); 405 // mView->setBackgroundPixmap ( bPix );
401 // qDebug("%s ",mText.latin1()); 406 // qDebug("%s ",mText.latin1());
402} 407}
403 408
404void KOWhatsNextView::appendDay( int i, QDate eventDate ) 409void KOWhatsNextView::appendDay( int i, QDate eventDate )
405{ 410{
406 QString date; 411 QString date;
407 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer); 412 QString day = KGlobal::locale()->formatDate( eventDate , KOPrefs::instance()->mShortDateInViewer);
408 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) { 413 if ( ! KOPrefs::instance()->mShortDateInViewer && QApplication::desktop()->width() < 320 ) {
409 if ( i == 0 ) { 414 if ( i == 0 ) {
410 //mText += "<table>\n"; 415 //mText += "<table>\n";
411 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>"; 416 return;//date = "<em><font color=\"#008000\"><em>" + day+"</font></em>";
412 } 417 }
413 else if ( i == 1 ) 418 else if ( i == 1 )
414 date = "<em><font color=\"#000080\">" + day + "</font></em>" ; 419 date = "<em><font color=\"#000080\">" + day + "</font></em>" ;
415 else date = "<em><font color=\"#000080\">" + day + "</font></em>"; 420 else date = "<em><font color=\"#000080\">" + day + "</font></em>";
416 mText += "<h2>" + date + "</h2>\n"; 421 mText += "<h2>" + date + "</h2>\n";
417 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 422 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
418 mText += "<table>\n"; 423 mText += "<table>\n";
419 424
420 425
421 426
422 } else { 427 } else {
423 if ( i == 0 ) { 428 if ( i == 0 ) {
424 //mText += "<table>\n"; 429 //mText += "<table>\n";
425 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>"; 430 return;// date = "<font color=\"#008000\"><em>" +i18n("Today: ") +"</em>" + day+"</font>";
426 } 431 }
427 432
428#ifdef DESKTOP_VERSION 433#ifdef DESKTOP_VERSION
429 else if ( i == 1 ) { 434 else if ( i == 1 ) {
430 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ; 435 date = "<h2><em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em></h2>" ;
431 } 436 }
432 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>"; 437 else date = "<h2><em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em></h2>";
433#else 438#else
434 else if ( i == 1 ) { 439 else if ( i == 1 ) {
435 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ; 440 date = "<em><font color=\"#000080\">" + i18n("Tomorrow: ") + day +"</font></em>" ;
436 } 441 }
437 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>"; 442 else date = "<em><font color=\"#000080\">" + i18n("In %1 days: ").arg( i ) +day + "</font></em>";
438 443
439#endif 444#endif
440 mText += "<h2>" + date + "</h2>\n"; 445 mText += "<h2>" + date + "</h2>\n";
441 //mText += "<big><big><strong>" + date + "</strong></big></big>\n"; 446 //mText += "<big><big><strong>" + date + "</strong></big></big>\n";
442 mText += "<table>\n"; 447 mText += "<table>\n";
443 } 448 }
444} 449}
445 450
446 451
447void KOWhatsNextView::showDates(const QDate &, const QDate &) 452void KOWhatsNextView::showDates(const QDate &, const QDate &)
448{ 453{
449 updateView(); 454 updateView();
450} 455}
451 456
452void KOWhatsNextView::showEvents(QPtrList<Event>) 457void KOWhatsNextView::showEvents(QPtrList<Event>)
453{ 458{
454} 459}
455 460
456void KOWhatsNextView::changeEventDisplay(Event *, int action) 461void KOWhatsNextView::changeEventDisplay(Event *, int action)
457{ 462{
458 switch(action) { 463 switch(action) {
459 case KOGlobals::EVENTADDED: 464 case KOGlobals::EVENTADDED:
460 updateView(); 465 updateView();
461 break; 466 break;
462 case KOGlobals::EVENTEDITED: 467 case KOGlobals::EVENTEDITED:
463 updateView(); 468 updateView();
464 break; 469 break;
465 case KOGlobals::EVENTDELETED: 470 case KOGlobals::EVENTDELETED:
466 updateView(); 471 updateView();
467 break; 472 break;
468 default: 473 default:
469 updateView(); 474 updateView();
470 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl; 475 kdDebug() << "KOWhatsNextView::changeEventDisplay(): Illegal action " << action << endl;
471 } 476 }
472} 477}
473 478
474bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable ) 479bool KOWhatsNextView::appendEvent(Incidence *ev, bool reply, bool notRed, bool appendTable )
475{ 480{
476 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") ) 481 if ( !KOPrefs::instance()->mShowSyncEvents && ev->uid().left(15) == QString("last-syncEvent-") )
477 return false; 482 return false;
478 QDateTime cdt = QDateTime::currentDateTime(); 483 QDateTime cdt = QDateTime::currentDateTime();
479 QDateTime noc; 484 QDateTime noc;
480 QString tempText; 485 QString tempText;
481 if ( appendTable && !notRed ) { 486 if ( appendTable && !notRed ) {
482 tempText = "<table>"; 487 tempText = "<table>";
483 } 488 }
484 bool ok = true; 489 bool ok = true;
485 if ( reply ) { 490 if ( reply ) {
486 noc = ev->getNextOccurence( cdt, &ok ); 491 noc = ev->getNextOccurence( cdt, &ok );
487 if (! ok && ev->type() == "Event") 492 if (! ok && ev->type() == "Event")
488 return false; 493 return false;
489 } 494 }
490 bool bDay = false; 495 bool bDay = false;
491 if ( ev->isBirthday() || ev->isAnniversary() ) 496 if ( ev->isBirthday() || ev->isAnniversary() )
492 bDay = true; 497 bDay = true;
493 tempText += "<tr><td><b>"; 498 tempText += "<tr><td><b>";
494 if (ev->type()=="Event") { 499 if (ev->type()=="Event") {
495 if (reply) { 500 if (reply) {
496 if (!ev->doesFloat()) 501 if (!ev->doesFloat())
497 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": "; 502 tempText += KGlobal::locale()->formatDateTime( noc , KOPrefs::instance()->mShortDateInViewer) +": ";
498 else 503 else
499 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 504 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
500 505
501 } else { 506 } else {
502 if (!ev->doesFloat()) { 507 if (!ev->doesFloat()) {
503 Event *event = static_cast<Event *>(ev); 508 Event *event = static_cast<Event *>(ev);
504 QDateTime st,end; 509 QDateTime st,end;
505 if ( event->recurrence()->doesRecur() ) { 510 if ( event->recurrence()->doesRecur() ) {
506 QDate recDate= mEventDate; 511 QDate recDate= mEventDate;
507 int days = event->dtStart().date().daysTo (event->dtEnd().date() ); 512 int days = event->dtStart().date().daysTo (event->dtEnd().date() );
508 while ( ! event->recursOn( recDate ) ) { 513 while ( ! event->recursOn( recDate ) ) {
509 recDate = recDate.addDays( -1 ); 514 recDate = recDate.addDays( -1 );
510 515
511 } 516 }
512 st = QDateTime ( recDate, event->dtStart().time() ); 517 st = QDateTime ( recDate, event->dtStart().time() );
513 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() ); 518 end = QDateTime ( recDate.addDays( days ), event->dtEnd().time() );
514 } 519 }
515 else { 520 else {
516 st = event->dtStart(); 521 st = event->dtStart();
517 end = event->dtEnd(); 522 end = event->dtEnd();
518 } 523 }
519 524
520 525
521 QString dateText; 526 QString dateText;
522 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() ); 527 // qDebug("%s %s %s %s ", mEventDate.toString().latin1(),event->summary().latin1(), st .toString().latin1(),end.toString().latin1() );
523 if ( st.date() < mEventDate ) 528 if ( st.date() < mEventDate )
524 dateText = "++:++-"; 529 dateText = "++:++-";
525 else 530 else
526 dateText = event->dtStartTimeStr() + "-"; 531 dateText = event->dtStartTimeStr() + "-";
527 if ( end.date() > mEventDate ) 532 if ( end.date() > mEventDate )
528 dateText += "++:++"; 533 dateText += "++:++";
529 else 534 else
530 dateText += event->dtEndTimeStr(); 535 dateText += event->dtEndTimeStr();
531 if ( notRed ) 536 if ( notRed )
532 tempText += dateText; 537 tempText += dateText;
533 else { 538 else {
534 if ( end < cdt ) { 539 if ( end < cdt ) {
535 if ( !KOPrefs::instance()->mWNViewShowsPast ) 540 if ( !KOPrefs::instance()->mWNViewShowsPast )
536 return false; 541 return false;
537 tempText += "<font color=\"#F00000\">" + dateText + "</font>"; 542 tempText += "<font color=\"#F00000\">" + dateText + "</font>";
538 } 543 }
539 else if ( st < cdt ) 544 else if ( st < cdt )
540 tempText += "<font color=\"#008000\">" + dateText + "</font>"; 545 tempText += "<font color=\"#008000\">" + dateText + "</font>";
541 else 546 else
542 tempText += dateText; 547 tempText += dateText;
543 548
544 } 549 }
545 550
546 } else { 551 } else {
547 if ( bDay ) { 552 if ( bDay ) {
548 553
549 if ( ev->isBirthday()) 554 if ( ev->isBirthday())
550 tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>"; 555 tempText += "<font color=\"#00B000\">" + i18n("Birthday") +":</font>";
551 else 556 else
552 tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>"; 557 tempText += "<font color=\"#00B0000\">" + i18n("Anniversary")+":</font>";
553 } else { 558 } else {
554 tempText += i18n("Allday:"); 559 tempText += i18n("Allday:");
555 } 560 }
556 561
557 } 562 }
558 } 563 }
559 } else { 564 } else {
560 mTodos.append( ev ); 565 mTodos.append( ev );
561 tempText += i18n("ToDo:"); 566 tempText += i18n("ToDo:");
562 if (reply) { 567 if (reply) {
563 tempText += " "; 568 tempText += " ";
564 if ( noc != cdt ) { 569 if ( noc != cdt ) {
565 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 570 tempText += KGlobal::locale()->formatDate( noc.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
566 } 571 }
567 } else { 572 } else {
568 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) { 573 if ( ((Todo*)ev)->dtDue().date() < QDate::currentDate() ) {
569 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 574 // tempText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
570 QString dfs = KGlobal::locale()->dateFormatShort(); 575 QString dfs = KGlobal::locale()->dateFormatShort();
571 KGlobal::locale()->setDateFormatShort("%d.%b"); 576 KGlobal::locale()->setDateFormatShort("%d.%b");
572 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>"; 577 tempText +="<font color=\"#F00000\">" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "</font>";
573 KGlobal::locale()->setDateFormatShort(dfs); 578 KGlobal::locale()->setDateFormatShort(dfs);
574 } else { 579 } else {
575 if (!ev->doesFloat() ) 580 if (!ev->doesFloat() )
576 if( ( (Todo*)ev)->dtDue() < cdt ) { 581 if( ( (Todo*)ev)->dtDue() < cdt ) {
577 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>"; 582 tempText +="<font color=\"#F00000\">" + ((Todo*)ev)->dtDueTimeStr() + "</font>";
578 583
579 584
580 } else 585 } else
581 tempText +=((Todo*)ev)->dtDueTimeStr(); 586 tempText +=((Todo*)ev)->dtDueTimeStr();
582 mTodos.append( ev ); 587 mTodos.append( ev );
583 } 588 }
584 } 589 }
585 } 590 }
586 tempText += "</b></td><td>"; 591 tempText += "</b></td><td>";
587 bool needClose = false; 592 bool needClose = false;
588 if ( ev->cancelled() ) { 593 if ( ev->cancelled() ) {
589 tempText += "<font color=\"#F00000\">[c"; 594 tempText += "<font color=\"#F00000\">[c";
590 needClose =true; 595 needClose =true;
591 596
592 } 597 }
593 if ( ev->isAlarmEnabled() ) { 598 if ( ev->isAlarmEnabled() ) {
594 if ( !needClose) 599 if ( !needClose)
595 tempText +="["; 600 tempText +="[";
596 tempText += "a"; 601 tempText += "a";
597 needClose =true; 602 needClose =true;
598 603
599 } 604 }
600 if ( ev->description().length() > 0 ) { 605 if ( ev->description().length() > 0 ) {
601 if ( !needClose) 606 if ( !needClose)
602 tempText +="["; 607 tempText +="[";
603 tempText += "i"; 608 tempText += "i";
604 needClose =true; 609 needClose =true;
605 } 610 }
606 if ( ev->recurrence()->doesRecur() ) { 611 if ( ev->recurrence()->doesRecur() ) {
607 if ( !needClose) 612 if ( !needClose)
608 tempText +="["; 613 tempText +="[";
609 tempText += "r"; 614 tempText += "r";
610 needClose =true; 615 needClose =true;
611 } 616 }
612 if ( needClose ) { 617 if ( needClose ) {
613 tempText += "] "; 618 tempText += "] ";
614 } 619 }
615 if ( ev->cancelled() ) 620 if ( ev->cancelled() )
616 tempText += "</font>"; 621 tempText += "</font>";
617 tempText += "<a "; 622 tempText += "<a ";
618 if (ev->type()=="Event") tempText += "href=\"event:"; 623 if (ev->type()=="Event") tempText += "href=\"event:";
619 if (ev->type()=="Todo") tempText += "href=\"todo:"; 624 if (ev->type()=="Todo") tempText += "href=\"todo:";
620 tempText += ev->uid() + "\">"; 625 tempText += ev->uid() + "\">";
621 if ( ev->summary().length() > 0 ) 626 if ( ev->summary().length() > 0 )
622 tempText += ev->summary(); 627 tempText += ev->summary();
623 else 628 else
624 tempText += i18n("-no summary-"); 629 tempText += i18n("-no summary-");
625 if ( bDay ) { 630 if ( bDay ) {
626 noc = ev->getNextOccurence( cdt.addDays(-1), &ok ); 631 noc = ev->getNextOccurence( cdt.addDays(-1), &ok );
627 if ( ok ) { 632 if ( ok ) {
628 int years = 0; 633 int years = 0;
629 if ( ev->type() =="Todo" ) { 634 if ( ev->type() =="Todo" ) {
630 years = noc.date().year() -((Todo*)ev)->dtDue().date().year(); 635 years = noc.date().year() -((Todo*)ev)->dtDue().date().year();
631 } else 636 } else
632 years = noc.date().year() - ev->dtStart().date().year(); 637 years = noc.date().year() - ev->dtStart().date().year();
633 tempText += i18n(" (%1 y.)"). arg( years ); 638 tempText += i18n(" (%1 y.)"). arg( years );
634 } 639 }
635 } 640 }
636 641
637 tempText += "</a>"; 642 tempText += "</a>";
638 if ( KOPrefs::instance()->mWNViewShowLocation ) 643 if ( KOPrefs::instance()->mWNViewShowLocation )
639 if ( !ev->location().isEmpty() ) 644 if ( !ev->location().isEmpty() )
640 tempText += " ("+ev->location() +")"; 645 tempText += " ("+ev->location() +")";
641 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents) 646 if ( ev->relatedTo() && KOPrefs::instance()->mWNViewShowsParents)
642 tempText += " ["+ev->relatedTo()->summary() +"]"; 647 tempText += " ["+ev->relatedTo()->summary() +"]";
643 tempText += "</td></tr>\n"; 648 tempText += "</td></tr>\n";
644 mText += tempText; 649 mText += tempText;
645 return true; 650 return true;
646} 651}
647 652
648bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub ) 653bool KOWhatsNextView::appendTodo(Incidence *ev, QString ind , bool isSub )
649{ 654{
650 if ( mTodos.find( ev ) != mTodos.end() ) return false; 655 if ( mTodos.find( ev ) != mTodos.end() ) return false;
651 656
652 mTodos.append( ev ); 657 mTodos.append( ev );
653 if ( !isSub ) 658 if ( !isSub )
654 mText += "<p>"; 659 mText += "<p>";
655 else 660 else
656 mText += "<li>"; 661 mText += "<li>";
657 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] "; 662 mText += "[" +QString::number(ev->priority()) + "/" + QString::number(((Todo*)ev)->percentComplete())+"%] ";
658 663
659 664
660 mText += ind; 665 mText += ind;
661 bool needClose = false; 666 bool needClose = false;
662 if ( ev->cancelled() ) { 667 if ( ev->cancelled() ) {
663 mText += "<font color=\"#F00000\">[c"; 668 mText += "<font color=\"#F00000\">[c";
664 needClose =true; 669 needClose =true;
665 670
666 } 671 }
667 if ( ev->isAlarmEnabled() ) { 672 if ( ev->isAlarmEnabled() ) {
668 if ( !needClose) 673 if ( !needClose)
669 mText +="["; 674 mText +="[";
670 mText += "a"; 675 mText += "a";
671 needClose =true; 676 needClose =true;
672 677
673 } 678 }
674 679
675 if ( ev->description().length() > 0 ) { 680 if ( ev->description().length() > 0 ) {
676 if ( !needClose) 681 if ( !needClose)
677 mText +="["; 682 mText +="[";
678 mText += "i"; 683 mText += "i";
679 needClose =true; 684 needClose =true;
680 } 685 }
681 if ( ev->doesRecur() ) { 686 if ( ev->doesRecur() ) {
682 if ( !needClose) 687 if ( !needClose)
683 mText +="["; 688 mText +="[";
684 mText += "r"; 689 mText += "r";
685 needClose =true; 690 needClose =true;
686 } 691 }
687 // if ( ev->recurrence()->doesRecur() ) { 692 // if ( ev->recurrence()->doesRecur() ) {
688 // if ( !needClose) 693 // if ( !needClose)
689 // mText +="("; 694 // mText +="(";
690 // mText += "r"; 695 // mText += "r";
691 // needClose =true; 696 // needClose =true;
692 // } 697 // }
693 if ( needClose ) 698 if ( needClose )
694 mText += "] "; 699 mText += "] ";
695 if ( ev->cancelled() ) 700 if ( ev->cancelled() )
696 mText += "</font>"; 701 mText += "</font>";
697 mText += "<a href=\"todo:" + ev->uid() + "\">"; 702 mText += "<a href=\"todo:" + ev->uid() + "\">";
698 if ( ev->summary().length() > 0 ) 703 if ( ev->summary().length() > 0 )
699 mText += ev->summary(); 704 mText += ev->summary();
700 else 705 else
701 mText += i18n("-no summary-"); 706 mText += i18n("-no summary-");
702 mText += "</a>"; 707 mText += "</a>";
703 if ( ((Todo*)ev)->hasDueDate () ) { 708 if ( ((Todo*)ev)->hasDueDate () ) {
704 QString year = ""; 709 QString year = "";
705 int ye = ((Todo*)ev)->dtDue().date().year(); 710 int ye = ((Todo*)ev)->dtDue().date().year();
706 if ( QDateTime::currentDateTime().date().year() != ye ) 711 if ( QDateTime::currentDateTime().date().year() != ye )
707 year = QString::number( ye ); 712 year = QString::number( ye );
708 QString dfs = KGlobal::locale()->dateFormatShort(); 713 QString dfs = KGlobal::locale()->dateFormatShort();
709 KGlobal::locale()->setDateFormatShort("%d.%b"); 714 KGlobal::locale()->setDateFormatShort("%d.%b");
710 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>"; 715 mText +="<font color=\"#00A000\"> [" + KGlobal::locale()->formatDate(((Todo*)ev)->dtDue().date(), true, KLocale::Userdefined) + "."+ year +"]</font>";
711 KGlobal::locale()->setDateFormatShort(dfs); 716 KGlobal::locale()->setDateFormatShort(dfs);
712 } 717 }
713 if ( KOPrefs::instance()->mWNViewShowLocation ) 718 if ( KOPrefs::instance()->mWNViewShowLocation )
714 if ( !ev->location().isEmpty() ) 719 if ( !ev->location().isEmpty() )
715 mText += " ("+ev->location() +")"; 720 mText += " ("+ev->location() +")";
716 if ( !isSub ) { 721 if ( !isSub ) {
717 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents) 722 if ( ((Todo*)ev)->relatedTo()&& KOPrefs::instance()->mWNViewShowsParents)
718 mText += " ["+ev->relatedTo()->summary() +"]"; 723 mText += " ["+ev->relatedTo()->summary() +"]";
719 mText += "</p>\n"; 724 mText += "</p>\n";
720 } 725 }
721 else { 726 else {
722 ind += "-"; 727 ind += "-";
723 mText += "</li>\n"; 728 mText += "</li>\n";
724 } 729 }
725 QPtrList<Incidence> Relations = ev->relations(); 730 QPtrList<Incidence> Relations = ev->relations();
726 Incidence *to; 731 Incidence *to;
727 for (to=Relations.first();to;to=Relations.next()) { 732 for (to=Relations.first();to;to=Relations.next()) {
728 if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio ) 733 if (!((Todo*)to)->isCompleted() && ((Todo*)to)->priority() <= mCurrentMaxPrio )
729 appendTodo( to, ind , true ); 734 appendTodo( to, ind , true );
730 } 735 }
731 736
732 return true; 737 return true;
733} 738}
734 739
735/* 740/*
736 void KOWhatsNextView::createEventViewer() 741 void KOWhatsNextView::createEventViewer()
737 { 742 {
738 if (!mEventViewer) { 743 if (!mEventViewer) {
739 744
740 mEventViewer = new KOEventViewerDialog(this); 745 mEventViewer = new KOEventViewerDialog(this);
741 } 746 }
742 } 747 }
743*/ 748*/
744void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v ) 749void KOWhatsNextView::setEventViewer(KOEventViewerDialog* v )
745{ 750{
746 mEventViewer = v; 751 mEventViewer = v;
747} 752}
748 753
749// TODO: Create this function in CalendarView and remove it from here 754// TODO: Create this function in CalendarView and remove it from here
750void KOWhatsNextView::showIncidence(const QString &uid) 755void KOWhatsNextView::showIncidence(const QString &uid)
751{ 756{
752 757
753 if ( !mEventViewer ) { 758 if ( !mEventViewer ) {
754 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set "); 759 qDebug("KOWhatsNextView::showIncidence::sorry, no event viewer set ");
755 return; 760 return;
756 } 761 }
757 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl; 762 //kdDebug() << "KOWhatsNextView::showIncidence(): " << uid << endl;
758 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1()); 763 //qDebug("KOWhatsNextView::showIncidence %s ", uid.latin1());
759 if (uid.startsWith("event:")) { 764 if (uid.startsWith("event:")) {
760#ifdef DESKTOP_VERSION 765#ifdef DESKTOP_VERSION
761 Event *event = calendar()->event(uid.mid(8)); 766 Event *event = calendar()->event(uid.mid(8));
762#else 767#else
763 Event *event = calendar()->event(uid.mid(6)); 768 Event *event = calendar()->event(uid.mid(6));
764#endif 769#endif
765 //qDebug("event %d uid %s ", event, uid.mid(6).latin1()); 770 //qDebug("event %d uid %s ", event, uid.mid(6).latin1());
766 if (!event) return; 771 if (!event) return;
767 //createEventViewer(); 772 //createEventViewer();
768 mEventViewer->setEvent(event); 773 mEventViewer->setEvent(event);
769 } else if (uid.startsWith("todo:")) { 774 } else if (uid.startsWith("todo:")) {
770#ifdef DESKTOP_VERSION 775#ifdef DESKTOP_VERSION
771 Todo *todo = calendar()->todo(uid.mid(7)); 776 Todo *todo = calendar()->todo(uid.mid(7));
772#else 777#else
773 Todo *todo = calendar()->todo(uid.mid(5)); 778 Todo *todo = calendar()->todo(uid.mid(5));
774#endif 779#endif
775 if (!todo) return; 780 if (!todo) return;
776 //createEventViewer(); 781 //createEventViewer();
777 mEventViewer->setTodo(todo); 782 mEventViewer->setTodo(todo);
778 } else { 783 } else {
779 return; 784 return;
780 785
781 } 786 }
782 mEventViewer->showMe(); 787 mEventViewer->showMe();
783 mEventViewer->raise(); 788 mEventViewer->raise();
784} 789}
diff --git a/korganizer/kowhatsnextview.h b/korganizer/kowhatsnextview.h
index d6727ac..93574ef 100644
--- a/korganizer/kowhatsnextview.h
+++ b/korganizer/kowhatsnextview.h
@@ -1,101 +1,102 @@
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#ifndef KOWHATSNEXTVIEW_H 19#ifndef KOWHATSNEXTVIEW_H
20#define KOWHATSNEXTVIEW_H 20#define KOWHATSNEXTVIEW_H
21 21
22#include <qtextbrowser.h> 22#include <qtextbrowser.h>
23#include <qtimer.h> 23#include <qtimer.h>
24 24
25#include <korganizer/baseview.h> 25#include <korganizer/baseview.h>
26 26
27class QListView; 27class QListView;
28class QLabel; 28class QLabel;
29 29
30class KOEventViewerDialog; 30class KOEventViewerDialog;
31 31
32#include <qpainter.h> 32#include <qpainter.h>
33#include <qwidget.h> 33#include <qwidget.h>
34class WhatsNextTextBrowser : public QTextBrowser { 34class WhatsNextTextBrowser : public QTextBrowser {
35 Q_OBJECT 35 Q_OBJECT
36 public: 36 public:
37 WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {}; 37 WhatsNextTextBrowser(QWidget *parent) : QTextBrowser(parent) {};
38 38
39 void setSource(const QString &); 39 void setSource(const QString &);
40 void printMe(); 40 void printMe();
41 41
42 signals: 42 signals:
43 void showIncidence(const QString &uid); 43 void showIncidence(const QString &uid);
44}; 44};
45 45
46 46
47/** 47/**
48 This class provides a view of the next events and todos 48 This class provides a view of the next events and todos
49*/ 49*/
50class KOWhatsNextView : public KOrg::BaseView 50class KOWhatsNextView : public KOrg::BaseView
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 public: 53 public:
54 KOWhatsNextView(Calendar *calendar, QWidget *parent = 0, 54 KOWhatsNextView(Calendar *calendar, QWidget *parent = 0,
55 const char *name = 0); 55 const char *name = 0);
56 ~KOWhatsNextView(); 56 ~KOWhatsNextView();
57 57
58 virtual int maxDatesHint(); 58 virtual int maxDatesHint();
59 virtual int currentDateCount(); 59 virtual int currentDateCount();
60 void setEventViewer(KOEventViewerDialog* v ); 60 void setEventViewer(KOEventViewerDialog* v );
61 virtual QPtrList<Incidence> selectedIncidences(); 61 virtual QPtrList<Incidence> selectedIncidences();
62 void clearList();
62 DateList selectedDates() 63 DateList selectedDates()
63 {DateList q; 64 {DateList q;
64 return q;} 65 return q;}
65 virtual void printPreview(CalPrinter *calPrinter, 66 virtual void printPreview(CalPrinter *calPrinter,
66 const QDate &, const QDate &); 67 const QDate &, const QDate &);
67 68
68 public slots: 69 public slots:
69 virtual void updateView(); 70 virtual void updateView();
70 void printMe(); 71 void printMe();
71 virtual void showDates(const QDate &start, const QDate &end); 72 virtual void showDates(const QDate &start, const QDate &end);
72 virtual void showEvents(QPtrList<Event> eventList); 73 virtual void showEvents(QPtrList<Event> eventList);
73 void updateConfig(); 74 void updateConfig();
74 void changeEventDisplay(Event *, int); 75 void changeEventDisplay(Event *, int);
75 76
76 protected: 77 protected:
77 bool appendEvent(Incidence *, bool reply=false, bool notRed = true, bool appendTable = false); 78 bool appendEvent(Incidence *, bool reply=false, bool notRed = true, bool appendTable = false);
78 bool appendTodo(Incidence *, QString ind = "", bool isSub = false ); 79 bool appendTodo(Incidence *, QString ind = "", bool isSub = false );
79 void appendDay( int i, QDate date ); 80 void appendDay( int i, QDate date );
80 QDate mEventDate; 81 QDate mEventDate;
81 virtual void showEvent ( QShowEvent * ); 82 virtual void showEvent ( QShowEvent * );
82 virtual void hideEvent ( QHideEvent * ); 83 virtual void hideEvent ( QHideEvent * );
83 84
84 private slots: 85 private slots:
85 void showIncidence(const QString &); 86 void showIncidence(const QString &);
86 void restartTimer(); 87 void restartTimer();
87 88
88 89
89 private: 90 private:
90 int mCurrentMaxPrio; 91 int mCurrentMaxPrio;
91 //void createEventViewer(); 92 //void createEventViewer();
92 QTimer* mTimer; 93 QTimer* mTimer;
93 WhatsNextTextBrowser *mView; 94 WhatsNextTextBrowser *mView;
94 QString mText; 95 QString mText;
95 // QLabel *mDateLabel; 96 // QLabel *mDateLabel;
96 KOEventViewerDialog *mEventViewer; 97 KOEventViewerDialog *mEventViewer;
97 98
98 QValueList<Incidence *> mTodos; 99 QValueList<Incidence *> mTodos;
99}; 100};
100 101
101#endif 102#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 63053a5..d959a7a 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2497 +1,2498 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "ktoolbar.h" 60#include "ktoolbar.h"
61#include "klocale.h" 61#include "klocale.h"
62#include "kconfig.h" 62#include "kconfig.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64#include <kglobalsettings.h> 64#include <kglobalsettings.h>
65 65
66using namespace KCal; 66using namespace KCal;
67#ifndef _WIN32_ 67#ifndef _WIN32_
68#include <unistd.h> 68#include <unistd.h>
69#else 69#else
70#ifdef _OL_IMPORT_ 70#ifdef _OL_IMPORT_
71#include "koimportoldialog.h" 71#include "koimportoldialog.h"
72#endif 72#endif
73#endif 73#endif
74#include "mainwindow.h" 74#include "mainwindow.h"
75 75
76 76
77class KOex2phonePrefs : public QDialog 77class KOex2phonePrefs : public QDialog
78{ 78{
79 public: 79 public:
80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 80 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
81 QDialog( parent, name, true ) 81 QDialog( parent, name, true )
82 { 82 {
83 setCaption( i18n("Export to phone options") ); 83 setCaption( i18n("Export to phone options") );
84 QVBoxLayout* lay = new QVBoxLayout( this ); 84 QVBoxLayout* lay = new QVBoxLayout( this );
85 lay->setSpacing( 3 ); 85 lay->setSpacing( 3 );
86 lay->setMargin( 3 ); 86 lay->setMargin( 3 );
87 QLabel *lab; 87 QLabel *lab;
88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 88 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
89 lab->setAlignment (AlignHCenter ); 89 lab->setAlignment (AlignHCenter );
90 QHBox* temphb; 90 QHBox* temphb;
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("I/O device: "), temphb ); 92 new QLabel( i18n("I/O device: "), temphb );
93 mPhoneDevice = new QLineEdit( temphb); 93 mPhoneDevice = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Connection: "), temphb ); 96 new QLabel( i18n("Connection: "), temphb );
97 mPhoneConnection = new QLineEdit( temphb); 97 mPhoneConnection = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 temphb = new QHBox( this ); 99 temphb = new QHBox( this );
100 new QLabel( i18n("Model(opt.): "), temphb ); 100 new QLabel( i18n("Model(opt.): "), temphb );
101 mPhoneModel = new QLineEdit( temphb); 101 mPhoneModel = new QLineEdit( temphb);
102 lay->addWidget( temphb ); 102 lay->addWidget( temphb );
103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 103 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
104 mWriteBackFuture->setChecked( true ); 104 mWriteBackFuture->setChecked( true );
105 lay->addWidget( mWriteBackFuture ); 105 lay->addWidget( mWriteBackFuture );
106 temphb = new QHBox( this ); 106 temphb = new QHBox( this );
107 new QLabel( i18n("Max. weeks in future: ") , temphb ); 107 new QLabel( i18n("Max. weeks in future: ") , temphb );
108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 108 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
109 mWriteBackFutureWeeks->setValue( 8 ); 109 mWriteBackFutureWeeks->setValue( 8 );
110 lay->addWidget( temphb ); 110 lay->addWidget( temphb );
111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 111 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
112 lab->setAlignment (AlignHCenter ); 112 lab->setAlignment (AlignHCenter );
113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 113 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
114 lay->addWidget( ok ); 114 lay->addWidget( ok );
115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 115 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
116 lay->addWidget( cancel ); 116 lay->addWidget( cancel );
117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 117 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 118 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
119 resize( 220, 240 ); 119 resize( 220, 240 );
120 qApp->processEvents(); 120 qApp->processEvents();
121 int dw = QApplication::desktop()->width(); 121 int dw = QApplication::desktop()->width();
122 int dh = QApplication::desktop()->height(); 122 int dh = QApplication::desktop()->height();
123 move( (dw-width())/2, (dh - height() )/2 ); 123 move( (dw-width())/2, (dh - height() )/2 );
124 } 124 }
125 125
126public: 126public:
127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 127 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
128 QCheckBox* mWriteBackFuture; 128 QCheckBox* mWriteBackFuture;
129 QSpinBox* mWriteBackFutureWeeks; 129 QSpinBox* mWriteBackFutureWeeks;
130}; 130};
131 131
132int globalFlagBlockStartup; 132int globalFlagBlockStartup;
133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 133MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
134 QMainWindow( parent, name ) 134 QMainWindow( parent, name )
135{ 135{
136 136
137 mClosed = false; 137 mClosed = false;
138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 138 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
139 QString confFile = locateLocal("config","korganizerrc"); 139 QString confFile = locateLocal("config","korganizerrc");
140 QFileInfo finf ( confFile ); 140 QFileInfo finf ( confFile );
141 bool showWarning = !finf.exists(); 141 bool showWarning = !finf.exists();
142 setIcon(SmallIcon( "ko24" ) ); 142 setIcon(SmallIcon( "ko24" ) );
143 mBlockAtStartup = true; 143 mBlockAtStartup = true;
144 mFlagKeyPressed = false; 144 mFlagKeyPressed = false;
145 setCaption("KO/Pi"); 145 setCaption("KO/Pi");
146 KOPrefs *p = KOPrefs::instance(); 146 KOPrefs *p = KOPrefs::instance();
147 KPimGlobalPrefs::instance()->setGlobalConfig(); 147 KPimGlobalPrefs::instance()->setGlobalConfig();
148 p->mCurrentDisplayedView = 0; 148 p->mCurrentDisplayedView = 0;
149 if ( p->mHourSize > 22 ) 149 if ( p->mHourSize > 22 )
150 p->mHourSize = 22; 150 p->mHourSize = 22;
151 QMainWindow::ToolBarDock tbd; 151 QMainWindow::ToolBarDock tbd;
152 if ( p->mToolBarHor ) { 152 if ( p->mToolBarHor ) {
153 if ( p->mToolBarUp ) 153 if ( p->mToolBarUp )
154 tbd = Bottom; 154 tbd = Bottom;
155 else 155 else
156 tbd = Top; 156 tbd = Top;
157 } 157 }
158 else { 158 else {
159 if ( p->mToolBarUp ) 159 if ( p->mToolBarUp )
160 tbd = Right; 160 tbd = Right;
161 else 161 else
162 tbd = Left; 162 tbd = Left;
163 } 163 }
164 if ( KOPrefs::instance()->mUseAppColors ) 164 if ( KOPrefs::instance()->mUseAppColors )
165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 165 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
166 globalFlagBlockStartup = 1; 166 globalFlagBlockStartup = 1;
167 iconToolBar = new QPEToolBar( this ); 167 iconToolBar = new QPEToolBar( this );
168 addToolBar (iconToolBar , tbd ); 168 addToolBar (iconToolBar , tbd );
169 169
170#ifdef DESKTOP_VERSION 170#ifdef DESKTOP_VERSION
171 if ( KOPrefs::instance()->mShowIconFilter ) 171 if ( KOPrefs::instance()->mShowIconFilter )
172#else 172#else
173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar ) 173 if ( KOPrefs::instance()->mShowIconFilter || !p->mShowIconOnetoolbar )
174#endif 174#endif
175 175
176{ 176{
177 if ( p->mToolBarHorF ) { 177 if ( p->mToolBarHorF ) {
178 if ( p->mToolBarUpF ) 178 if ( p->mToolBarUpF )
179 tbd = Bottom; 179 tbd = Bottom;
180 else 180 else
181 tbd = Top; 181 tbd = Top;
182 } 182 }
183 else { 183 else {
184 if ( p->mToolBarUpF ) 184 if ( p->mToolBarUpF )
185 tbd = Right; 185 tbd = Right;
186 else 186 else
187 tbd = Left; 187 tbd = Left;
188 } 188 }
189 filterToolBar = new QPEToolBar ( this ); 189 filterToolBar = new QPEToolBar ( this );
190 filterMenubar = new QMenuBar( 0 ); 190 filterMenubar = new QMenuBar( 0 );
191 QFontMetrics fm ( filterMenubar->font() ); 191 QFontMetrics fm ( filterMenubar->font() );
192 192
193 filterPopupMenu = new QPopupMenu( this ); 193 filterPopupMenu = new QPopupMenu( this );
194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 ); 194 filterMenubar->insertItem( i18n("No Filter"), filterPopupMenu,0 );
195 QString addTest = "A"; 195 QString addTest = "A";
196 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) ); 196 filterMenubar->setMinimumWidth( fm.width( i18n("No Filter")+addTest ) );
197#ifdef DESKTOP_VERSION 197#ifdef DESKTOP_VERSION
198 addTest = "AAABBBCCCx"; 198 addTest = "AAABBBCCCx";
199#else 199#else
200 addTest = "AAx"; 200 addTest = "AAx";
201#endif 201#endif
202 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) ); 202 filterMenubar->setMaximumWidth( fm.width( i18n("No Filter")+addTest ) );
203 addToolBar (filterToolBar , tbd ); 203 addToolBar (filterToolBar , tbd );
204 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) ); 204 connect ( filterPopupMenu , SIGNAL( activated ( int ) ), this, SLOT (selectFilterPopup( int ) ) );
205 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) ); 205 connect ( filterPopupMenu , SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenuPopup() ) );
206 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar ) 206 if ( !KOPrefs::instance()->mShowIconFilter && !p->mShowIconOnetoolbar )
207 filterToolBar->hide(); 207 filterToolBar->hide();
208 } else { 208 } else {
209 filterToolBar = 0; 209 filterToolBar = 0;
210 filterMenubar = 0; 210 filterMenubar = 0;
211 filterPopupMenu = 0; 211 filterPopupMenu = 0;
212 } 212 }
213 if ( p->mShowIconOnetoolbar ) { 213 if ( p->mShowIconOnetoolbar ) {
214 viewToolBar = iconToolBar ; 214 viewToolBar = iconToolBar ;
215 navigatorToolBar = iconToolBar ; 215 navigatorToolBar = iconToolBar ;
216 } else { 216 } else {
217#ifndef DESKTOP_VERSION 217#ifndef DESKTOP_VERSION
218 setToolBarsMovable( false ); 218 setToolBarsMovable( false );
219#endif 219#endif
220 if ( p->mToolBarHorV ) { 220 if ( p->mToolBarHorV ) {
221 if ( p->mToolBarUpV ) 221 if ( p->mToolBarUpV )
222 tbd = Bottom; 222 tbd = Bottom;
223 else 223 else
224 tbd = Top; 224 tbd = Top;
225 } 225 }
226 else { 226 else {
227 if ( p->mToolBarUpV ) 227 if ( p->mToolBarUpV )
228 tbd = Right; 228 tbd = Right;
229 else 229 else
230 tbd = Left; 230 tbd = Left;
231 } 231 }
232 viewToolBar = new QPEToolBar( this ); 232 viewToolBar = new QPEToolBar( this );
233 addToolBar (viewToolBar , tbd ); 233 addToolBar (viewToolBar , tbd );
234 if ( p->mToolBarHorN ) { 234 if ( p->mToolBarHorN ) {
235 if ( p->mToolBarUpN ) 235 if ( p->mToolBarUpN )
236 tbd = Bottom; 236 tbd = Bottom;
237 else 237 else
238 tbd = Top; 238 tbd = Top;
239 } 239 }
240 else { 240 else {
241 if ( p->mToolBarUpN ) 241 if ( p->mToolBarUpN )
242 tbd = Right; 242 tbd = Right;
243 else 243 else
244 tbd = Left; 244 tbd = Left;
245 } 245 }
246 navigatorToolBar = new QPEToolBar( this ); 246 navigatorToolBar = new QPEToolBar( this );
247 addToolBar (navigatorToolBar , tbd ); 247 addToolBar (navigatorToolBar , tbd );
248 } 248 }
249 249
250 250
251 251
252 mCalendarModifiedFlag = false; 252 mCalendarModifiedFlag = false;
253 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 253 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
254 splash->setAlignment ( AlignCenter ); 254 splash->setAlignment ( AlignCenter );
255 setCentralWidget( splash ); 255 setCentralWidget( splash );
256#ifndef DESKTOP_VERSION 256#ifndef DESKTOP_VERSION
257 showMaximized(); 257 showMaximized();
258#endif 258#endif
259 259
260 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 260 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
261 setDefaultPreferences(); 261 setDefaultPreferences();
262 mCalendar = new CalendarLocal(); 262 mCalendar = new CalendarLocal();
263 mView = new CalendarView( mCalendar, this,"mCalendar " ); 263 mView = new CalendarView( mCalendar, this,"mCalendar " );
264 mView->hide(); 264 mView->hide();
265 //mView->resize(splash->size() ); 265 //mView->resize(splash->size() );
266 initActions(); 266 initActions();
267 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 267 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
268 mSyncManager->setBlockSave(false); 268 mSyncManager->setBlockSave(false);
269 mView->setSyncManager(mSyncManager); 269 mView->setSyncManager(mSyncManager);
270#ifndef DESKTOP_VERSION 270#ifndef DESKTOP_VERSION
271 iconToolBar->show(); 271 iconToolBar->show();
272 qApp->processEvents(); 272 qApp->processEvents();
273#endif 273#endif
274 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 274 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
275 int vh = height() ; 275 int vh = height() ;
276 int vw = width(); 276 int vw = width();
277 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 277 //qDebug("Toolbar hei %d ",iconToolBar->height() );
278 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 278 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
279 vh -= iconToolBar->height(); 279 vh -= iconToolBar->height();
280 } else { 280 } else {
281 vw -= iconToolBar->height(); 281 vw -= iconToolBar->height();
282 } 282 }
283 //mView->setMaximumSize( splash->size() ); 283 //mView->setMaximumSize( splash->size() );
284 //mView->resize( splash->size() ); 284 //mView->resize( splash->size() );
285 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 285 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
286 mView->readSettings(); 286 mView->readSettings();
287 bool newFile = false; 287 bool newFile = false;
288 if( !QFile::exists( defaultFileName() ) ) { 288 if( !QFile::exists( defaultFileName() ) ) {
289 QFileInfo finfo ( defaultFileName() ); 289 QFileInfo finfo ( defaultFileName() );
290 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 290 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
291 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 291 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
292 finfo.setFile( oldFile ); 292 finfo.setFile( oldFile );
293 if (finfo.exists() ) { 293 if (finfo.exists() ) {
294 KMessageBox::information( this, message); 294 KMessageBox::information( this, message);
295 mView->openCalendar( oldFile ); 295 mView->openCalendar( oldFile );
296 qApp->processEvents(); 296 qApp->processEvents();
297 } else { 297 } else {
298 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 298 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
299 finfo.setFile( oldFile ); 299 finfo.setFile( oldFile );
300 if (finfo.exists() ) { 300 if (finfo.exists() ) {
301 KMessageBox::information( this, message); 301 KMessageBox::information( this, message);
302 mView->openCalendar( oldFile ); 302 mView->openCalendar( oldFile );
303 qApp->processEvents(); 303 qApp->processEvents();
304 } 304 }
305 } 305 }
306 mView->saveCalendar( defaultFileName() ); 306 mView->saveCalendar( defaultFileName() );
307 newFile = true; 307 newFile = true;
308 } 308 }
309 309
310 QTime neededSaveTime = QDateTime::currentDateTime().time(); 310 QTime neededSaveTime = QDateTime::currentDateTime().time();
311 mView->openCalendar( defaultFileName() ); 311 mView->openCalendar( defaultFileName() );
312 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 312 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
313 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 313 qDebug("KO: Calendar loading time: %d ms",msNeeded );
314 314
315 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 315 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
316 KOPrefs::instance()->setAllDefaults(); 316 KOPrefs::instance()->setAllDefaults();
317 int count = mView->addCategories(); 317 int count = mView->addCategories();
318 } 318 }
319 processIncidenceSelection( 0 ); 319 processIncidenceSelection( 0 );
320 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 320 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
321 SLOT( processIncidenceSelection( Incidence * ) ) ); 321 SLOT( processIncidenceSelection( Incidence * ) ) );
322 connect( mView, SIGNAL( modifiedChanged( bool ) ), 322 connect( mView, SIGNAL( modifiedChanged( bool ) ),
323 SLOT( slotModifiedChanged( bool ) ) ); 323 SLOT( slotModifiedChanged( bool ) ) );
324 324
325 325
326 connect( mView, SIGNAL( tempDisableBR(bool) ), 326 connect( mView, SIGNAL( tempDisableBR(bool) ),
327 SLOT( disableBR(bool) ) ); 327 SLOT( disableBR(bool) ) );
328 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 328 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
329 mView->setModified( false ); 329 mView->setModified( false );
330 mBlockAtStartup = false; 330 mBlockAtStartup = false;
331 mView->setModified( false ); 331 mView->setModified( false );
332 setCentralWidget( mView ); 332 setCentralWidget( mView );
333 globalFlagBlockStartup = 0; 333 globalFlagBlockStartup = 0;
334 mView->show(); 334 mView->show();
335 delete splash; 335 delete splash;
336 if ( newFile ) 336 if ( newFile )
337 mView->updateConfig(); 337 mView->updateConfig();
338 // qApp->processEvents(); 338 // qApp->processEvents();
339 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 339 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
340 //fillSyncMenu(); 340 //fillSyncMenu();
341 341
342 342
343 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 343 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
344 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 344 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
345 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 345 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
346 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 346 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
347 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 347 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
348 mSyncManager->setDefaultFileName( sentSyncFile()); 348 mSyncManager->setDefaultFileName( sentSyncFile());
349 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 349 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
350 mSyncManager->fillSyncMenu(); 350 mSyncManager->fillSyncMenu();
351 351
352 352
353 353
354 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 354 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
355 if ( showWarning ) { 355 if ( showWarning ) {
356 KMessageBox::information( this, 356 KMessageBox::information( this,
357 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 357 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
358 qApp->processEvents(); 358 qApp->processEvents();
359 mView->dialogManager()->showSyncOptions(); 359 mView->dialogManager()->showSyncOptions();
360 } 360 }
361 361
362 //US listen for result adressed from Ka/Pi 362 //US listen for result adressed from Ka/Pi
363#ifndef DESKTOP_VERSION 363#ifndef DESKTOP_VERSION
364 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 364 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
365#endif 365#endif
366#ifndef DESKTOP_VERSION 366#ifndef DESKTOP_VERSION
367 infrared = 0; 367 infrared = 0;
368#endif 368#endif
369 updateFilterToolbar(); 369 updateFilterToolbar();
370 updateWeek( mView->startDate() ); 370 updateWeek( mView->startDate() );
371 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 371 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
372 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 372 SLOT( updateWeekNum( const KCal::DateList & ) ) );
373 mBRdisabled = false; 373 mBRdisabled = false;
374 //toggleBeamReceive(); 374 //toggleBeamReceive();
375 int tiint= 3000; 375 int tiint= 3000;
376#ifndef DESKTOP_VERSION 376#ifndef DESKTOP_VERSION
377 tiint = 5000; 377 tiint = 5000;
378#endif 378#endif
379 QTimer::singleShot( tiint, mView, SLOT ( checkAlarms() )); 379 QTimer::singleShot( tiint, mView, SLOT ( checkAlarms() ));
380} 380}
381MainWindow::~MainWindow() 381MainWindow::~MainWindow()
382{ 382{
383 //qDebug("MainWindow::~MainWindow() "); 383 //qDebug("MainWindow::~MainWindow() ");
384 //save toolbar location 384 //save toolbar location
385 delete mCalendar; 385 delete mCalendar;
386 delete mSyncManager; 386 delete mSyncManager;
387#ifndef DESKTOP_VERSION 387#ifndef DESKTOP_VERSION
388 if ( infrared ) 388 if ( infrared )
389 delete infrared; 389 delete infrared;
390#endif 390#endif
391 391
392 392
393} 393}
394 394
395void MainWindow::disableBR(bool b) 395void MainWindow::disableBR(bool b)
396{ 396{
397#ifndef DESKTOP_VERSION 397#ifndef DESKTOP_VERSION
398 if ( b ) { 398 if ( b ) {
399 if ( infrared ) { 399 if ( infrared ) {
400 toggleBeamReceive(); 400 toggleBeamReceive();
401 mBRdisabled = true; 401 mBRdisabled = true;
402 } 402 }
403 mBRdisabled = true; 403 mBRdisabled = true;
404 } else { 404 } else {
405 if ( mBRdisabled ) { 405 if ( mBRdisabled ) {
406 mBRdisabled = false; 406 mBRdisabled = false;
407 //makes no sense,because other cal ap is probably running 407 //makes no sense,because other cal ap is probably running
408 // toggleBeamReceive(); 408 // toggleBeamReceive();
409 } 409 }
410 } 410 }
411#endif 411#endif
412 412
413} 413}
414bool MainWindow::beamReceiveEnabled() 414bool MainWindow::beamReceiveEnabled()
415{ 415{
416#ifndef DESKTOP_VERSION 416#ifndef DESKTOP_VERSION
417 return ( infrared != 0 ); 417 return ( infrared != 0 );
418#endif 418#endif
419 return false; 419 return false;
420} 420}
421 421
422void MainWindow::toggleBeamReceive() 422void MainWindow::toggleBeamReceive()
423{ 423{
424 if ( mBRdisabled ) 424 if ( mBRdisabled )
425 return; 425 return;
426#ifndef DESKTOP_VERSION 426#ifndef DESKTOP_VERSION
427 if ( infrared ) { 427 if ( infrared ) {
428 qDebug("KO: Disable BeamReceive "); 428 qDebug("KO: Disable BeamReceive ");
429 delete infrared; 429 delete infrared;
430 infrared = 0; 430 infrared = 0;
431 brAction->setOn(false); 431 brAction->setOn(false);
432 return; 432 return;
433 } 433 }
434 qDebug("KO: Enable BeamReceive "); 434 qDebug("KO: Enable BeamReceive ");
435 brAction->setOn(true); 435 brAction->setOn(true);
436 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 436 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
437 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 437 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
438#endif 438#endif
439} 439}
440void MainWindow::showMaximized () 440void MainWindow::showMaximized ()
441{ 441{
442#ifndef DESKTOP_VERSION 442#ifndef DESKTOP_VERSION
443 if ( ! globalFlagBlockStartup ) 443 if ( ! globalFlagBlockStartup )
444 if ( mClosed ) 444 if ( mClosed )
445 mView->goToday(); 445 mView->goToday();
446#endif 446#endif
447 QWidget::showMaximized () ; 447 QWidget::showMaximized () ;
448 mClosed = false; 448 mClosed = false;
449} 449}
450void MainWindow::closeEvent( QCloseEvent* ce ) 450void MainWindow::closeEvent( QCloseEvent* ce )
451{ 451{
452 452
453 453
454 454
455 if ( ! KOPrefs::instance()->mAskForQuit ) { 455 if ( ! KOPrefs::instance()->mAskForQuit ) {
456 saveOnClose(); 456 saveOnClose();
457 mClosed = true; 457 mClosed = true;
458 ce->accept(); 458 ce->accept();
459 return; 459 return;
460 460
461 } 461 }
462 462
463 switch( QMessageBox::information( this, "KO/Pi", 463 switch( QMessageBox::information( this, "KO/Pi",
464 i18n("Do you really want\nto close KO/Pi?"), 464 i18n("Do you really want\nto close KO/Pi?"),
465 i18n("Close"), i18n("No"), 465 i18n("Close"), i18n("No"),
466 0, 0 ) ) { 466 0, 0 ) ) {
467 case 0: 467 case 0:
468 saveOnClose(); 468 saveOnClose();
469 mClosed = true; 469 mClosed = true;
470 ce->accept(); 470 ce->accept();
471 break; 471 break;
472 case 1: 472 case 1:
473 ce->ignore(); 473 ce->ignore();
474 break; 474 break;
475 case 2: 475 case 2:
476 476
477 default: 477 default:
478 break; 478 break;
479 } 479 }
480 480
481 481
482} 482}
483 483
484void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 484void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
485{ 485{
486 QDataStream stream( data, IO_ReadOnly ); 486 QDataStream stream( data, IO_ReadOnly );
487 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 487 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
488 //QString datamess; 488 //QString datamess;
489 //qDebug("message "); 489 //qDebug("message ");
490 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 490 qDebug("KO: QCOP message received: %s ", cmsg.data() );
491 491
492 if ( cmsg == "setDocument(QString)" ) { 492 if ( cmsg == "setDocument(QString)" ) {
493 QDataStream stream( data, IO_ReadOnly ); 493 QDataStream stream( data, IO_ReadOnly );
494 QString fileName; 494 QString fileName;
495 stream >> fileName; 495 stream >> fileName;
496 //qDebug("filename %s ", fileName.latin1()); 496 //qDebug("filename %s ", fileName.latin1());
497 showMaximized(); 497 showMaximized();
498 raise(); 498 raise();
499 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 499 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
500 mSyncManager->slotSyncMenu( 1002 ); 500 mSyncManager->slotSyncMenu( 1002 );
501 return; 501 return;
502 } 502 }
503 503
504 if ( cmsg == "-writeFile" ) { 504 if ( cmsg == "-writeFile" ) {
505 // I made from the "-writeFile" an "-writeAlarm" 505 // I made from the "-writeFile" an "-writeAlarm"
506 mView->viewManager()->showWhatsNextView(); 506 mView->viewManager()->showWhatsNextView();
507 mCalendar->checkAlarmForIncidence( 0, true); 507 mCalendar->checkAlarmForIncidence( 0, true);
508 showMaximized(); 508 showMaximized();
509 raise(); 509 raise();
510 return; 510 return;
511 511
512 } 512 }
513 if ( cmsg == "-writeFileSilent" ) { 513 if ( cmsg == "-writeFileSilent" ) {
514 // I made from the "-writeFile" an "-writeAlarm" 514 // I made from the "-writeFile" an "-writeAlarm"
515 // mView->viewManager()->showWhatsNextView(); 515 // mView->viewManager()->showWhatsNextView();
516 mCalendar->checkAlarmForIncidence( 0, true); 516 mCalendar->checkAlarmForIncidence( 0, true);
517 //showMaximized(); 517 //showMaximized();
518 //raise(); 518 //raise();
519 hide(); 519 hide();
520 return; 520 return;
521 } 521 }
522 if ( cmsg == "-newCountdown" ) { 522 if ( cmsg == "-newCountdown" ) {
523 qDebug("newCountdown "); 523 qDebug("newCountdown ");
524 524
525 } 525 }
526 QString msg ; 526 QString msg ;
527 QString allmsg = cmsg; 527 QString allmsg = cmsg;
528 while ( allmsg.length() > 0 ) { 528 while ( allmsg.length() > 0 ) {
529 int nextC = allmsg.find( "-", 1 ); 529 int nextC = allmsg.find( "-", 1 );
530 if ( nextC == -1 ) { 530 if ( nextC == -1 ) {
531 msg = allmsg; 531 msg = allmsg;
532 allmsg = ""; 532 allmsg = "";
533 } else{ 533 } else{
534 msg = allmsg.left( nextC ); 534 msg = allmsg.left( nextC );
535 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 535 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
536 } 536 }
537 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 537 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
538 if ( msg == "-newEvent" ) { 538 if ( msg == "-newEvent" ) {
539 mView->newEvent(); 539 mView->newEvent();
540 } 540 }
541 if ( msg == "-newTodo" ) { 541 if ( msg == "-newTodo" ) {
542 mView->newTodo(); 542 mView->newTodo();
543 543
544 } 544 }
545 if ( msg == "-showWN" ) { 545 if ( msg == "-showWN" ) {
546 mView->viewManager()->showWhatsNextView(); 546 mView->viewManager()->showWhatsNextView();
547 } 547 }
548 if ( msg == "-showTodo" ) { 548 if ( msg == "-showTodo" ) {
549 mView->viewManager()->showTodoView(); 549 mView->viewManager()->showTodoView();
550 } 550 }
551 if ( msg == "-showList" ) { 551 if ( msg == "-showList" ) {
552 mView->viewManager()->showListView(); 552 mView->viewManager()->showListView();
553 } 553 }
554 else if ( msg == "-showDay" ) { 554 else if ( msg == "-showDay" ) {
555 mView->viewManager()->showDayView(); 555 mView->viewManager()->showDayView();
556 } 556 }
557 else if ( msg == "-showWWeek" ) { 557 else if ( msg == "-showWWeek" ) {
558 mView->viewManager()->showWorkWeekView(); 558 mView->viewManager()->showWorkWeekView();
559 } 559 }
560 else if ( msg == "-ringSync" ) { 560 else if ( msg == "-ringSync" ) {
561 mSyncManager->multiSync( false ); 561 mSyncManager->multiSync( false );
562 } 562 }
563 else if ( msg == "-showWeek" ) { 563 else if ( msg == "-showWeek" ) {
564 mView->viewManager()->showWeekView(); 564 mView->viewManager()->showWeekView();
565 } 565 }
566 else if ( msg == "-showTodo" ) { 566 else if ( msg == "-showTodo" ) {
567 mView->viewManager()->showTodoView(); 567 mView->viewManager()->showTodoView();
568 } 568 }
569 else if ( msg == "-showJournal" ) { 569 else if ( msg == "-showJournal" ) {
570 mView->dateNavigator()->selectDates( 1 ); 570 mView->dateNavigator()->selectDates( 1 );
571 mView->dateNavigator()->selectToday(); 571 mView->dateNavigator()->selectToday();
572 mView->viewManager()->showJournalView(); 572 mView->viewManager()->showJournalView();
573 } 573 }
574 else if ( msg == "-showKO" ) { 574 else if ( msg == "-showKO" ) {
575 mView->viewManager()->showNextXView(); 575 mView->viewManager()->showNextXView();
576 } 576 }
577 else if ( msg == "-showWNext" ) { 577 else if ( msg == "-showWNext" ) {
578 mView->viewManager()->showWhatsNextView(); 578 mView->viewManager()->showWhatsNextView();
579 } 579 }
580 else if ( msg == "nextView()" ) { 580 else if ( msg == "nextView()" ) {
581 mView->viewManager()->showNextView(); 581 mView->viewManager()->showNextView();
582 } 582 }
583 else if ( msg == "-showNextXView" ) { 583 else if ( msg == "-showNextXView" ) {
584 mView->viewManager()->showNextXView(); 584 mView->viewManager()->showNextXView();
585 } 585 }
586 586
587 587
588 } 588 }
589 589
590 showMaximized(); 590 showMaximized();
591 raise(); 591 raise();
592} 592}
593 593
594QPixmap MainWindow::loadPixmap( QString name ) 594QPixmap MainWindow::loadPixmap( QString name )
595{ 595{
596 return SmallIcon( name ); 596 return SmallIcon( name );
597 597
598} 598}
599void MainWindow::setUsesBigPixmaps ( bool b ) 599void MainWindow::setUsesBigPixmaps ( bool b )
600{ 600{
601 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b); 601 qDebug("KO: MainWindow::setUsesBigPixmaps %d called", b);
602 if ( b ) 602 if ( b )
603 qDebug("KO: BigPixmaps are not supported "); 603 qDebug("KO: BigPixmaps are not supported ");
604} 604}
605void MainWindow::initActions() 605void MainWindow::initActions()
606{ 606{
607 //KOPrefs::instance()->mShowFullMenu 607 //KOPrefs::instance()->mShowFullMenu
608 iconToolBar->clear(); 608 iconToolBar->clear();
609 KOPrefs *p = KOPrefs::instance(); 609 KOPrefs *p = KOPrefs::instance();
610 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 610 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
611 611
612 QPopupMenu *viewMenu = new QPopupMenu( this ); 612 QPopupMenu *viewMenu = new QPopupMenu( this );
613 QPopupMenu *actionMenu = new QPopupMenu( this ); 613 QPopupMenu *actionMenu = new QPopupMenu( this );
614 QPopupMenu *importMenu = new QPopupMenu( this ); 614 QPopupMenu *importMenu = new QPopupMenu( this );
615 QPopupMenu *importMenu_X = new QPopupMenu( this ); 615 QPopupMenu *importMenu_X = new QPopupMenu( this );
616 QPopupMenu *exportMenu_X = new QPopupMenu( this ); 616 QPopupMenu *exportMenu_X = new QPopupMenu( this );
617 QPopupMenu *beamMenu_X = new QPopupMenu( this ); 617 QPopupMenu *beamMenu_X = new QPopupMenu( this );
618 selectFilterMenu = new QPopupMenu( this ); 618 selectFilterMenu = new QPopupMenu( this );
619 selectFilterMenu->setCheckable( true ); 619 selectFilterMenu->setCheckable( true );
620 syncMenu = new QPopupMenu( this ); 620 syncMenu = new QPopupMenu( this );
621 configureAgendaMenu = new QPopupMenu( this ); 621 configureAgendaMenu = new QPopupMenu( this );
622 configureToolBarMenu = new QPopupMenu( this ); 622 configureToolBarMenu = new QPopupMenu( this );
623 QPopupMenu *helpMenu = new QPopupMenu( this ); 623 QPopupMenu *helpMenu = new QPopupMenu( this );
624 QIconSet icon; 624 QIconSet icon;
625 int pixWid = 22, pixHei = 22; 625 int pixWid = 22, pixHei = 22;
626 QString pathString = ""; 626 QString pathString = "";
627 if ( !p->mToolBarMiniIcons ) { 627 if ( !p->mToolBarMiniIcons ) {
628 if ( QApplication::desktop()->width() < 480 ) { 628 if ( QApplication::desktop()->width() < 480 ) {
629 pathString += "icons16/"; 629 pathString += "icons16/";
630 pixWid = 18; pixHei = 16; 630 pixWid = 18; pixHei = 16;
631 } 631 }
632 } else { 632 } else {
633 pathString += "iconsmini/"; 633 pathString += "iconsmini/";
634 pixWid = 18; pixHei = 16; 634 pixWid = 18; pixHei = 16;
635 } 635 }
636 if ( KOPrefs::instance()->mShowFullMenu ) { 636 if ( KOPrefs::instance()->mShowFullMenu ) {
637 QMenuBar *menuBar1; 637 QMenuBar *menuBar1;
638 menuBar1 = menuBar(); 638 menuBar1 = menuBar();
639 menuBar1->insertItem( i18n("File"), importMenu ); 639 menuBar1->insertItem( i18n("File"), importMenu );
640 menuBar1->insertItem( i18n("View"), viewMenu ); 640 menuBar1->insertItem( i18n("View"), viewMenu );
641 menuBar1->insertItem( i18n("Actions"), actionMenu ); 641 menuBar1->insertItem( i18n("Actions"), actionMenu );
642#ifdef DESKTOP_VERSION 642#ifdef DESKTOP_VERSION
643 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 643 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
644 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 644 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
645#else 645#else
646 menuBar1->insertItem( i18n("Sync"), syncMenu ); 646 menuBar1->insertItem( i18n("Sync"), syncMenu );
647 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 647 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
648#endif 648#endif
649 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 649 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
650 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 650 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
651 menuBar1->insertItem( i18n("Help"), helpMenu ); 651 menuBar1->insertItem( i18n("Help"), helpMenu );
652 } else { 652 } else {
653 QPEMenuBar *menuBar1; 653 QPEMenuBar *menuBar1;
654 menuBar1 = new QPEMenuBar( iconToolBar ); 654 menuBar1 = new QPEMenuBar( iconToolBar );
655 QPopupMenu *menuBar = new QPopupMenu( this ); 655 QPopupMenu *menuBar = new QPopupMenu( this );
656 icon = loadPixmap( pathString + "z_menu" ); 656 icon = loadPixmap( pathString + "z_menu" );
657 menuBar1->insertItem( icon.pixmap(), menuBar); 657 menuBar1->insertItem( icon.pixmap(), menuBar);
658 //menuBar1->insertItem( i18n("ME"), menuBar); 658 //menuBar1->insertItem( i18n("ME"), menuBar);
659 menuBar->insertItem( i18n("File"), importMenu ); 659 menuBar->insertItem( i18n("File"), importMenu );
660 menuBar->insertItem( i18n("View"), viewMenu ); 660 menuBar->insertItem( i18n("View"), viewMenu );
661 menuBar->insertItem( i18n("Actions"), actionMenu ); 661 menuBar->insertItem( i18n("Actions"), actionMenu );
662 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 662 menuBar->insertItem( i18n("Synchronize"), syncMenu );
663 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 663 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
664 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 664 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
665 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 665 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
666 menuBar->insertItem( i18n("Help"), helpMenu ); 666 menuBar->insertItem( i18n("Help"), helpMenu );
667 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 667 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
668 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 668 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
669 } 669 }
670 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 670 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
671 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 671 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
672 672
673 673
674 mWeekBgColor = iconToolBar->backgroundColor(); 674 mWeekBgColor = iconToolBar->backgroundColor();
675 mWeekPixmap.resize( pixWid , pixHei ); 675 mWeekPixmap.resize( pixWid , pixHei );
676 mWeekPixmap.fill( mWeekBgColor ); 676 mWeekPixmap.fill( mWeekBgColor );
677 icon = mWeekPixmap; 677 icon = mWeekPixmap;
678 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 678 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
679 if ( p-> mShowIconWeekNum ) 679 if ( p-> mShowIconWeekNum )
680 mWeekAction->addTo( iconToolBar ); 680 mWeekAction->addTo( iconToolBar );
681 mWeekFont = font(); 681 mWeekFont = font();
682 682
683 int fontPoint = mWeekFont.pointSize(); 683 int fontPoint = mWeekFont.pointSize();
684 QFontMetrics f( mWeekFont ); 684 QFontMetrics f( mWeekFont );
685 int fontWid = f.width( "30" ); 685 int fontWid = f.width( "30" );
686 while ( fontWid > pixWid ) { 686 while ( fontWid > pixWid ) {
687 --fontPoint; 687 --fontPoint;
688 mWeekFont.setPointSize( fontPoint ); 688 mWeekFont.setPointSize( fontPoint );
689 QFontMetrics f( mWeekFont ); 689 QFontMetrics f( mWeekFont );
690 fontWid = f.width( "30" ); 690 fontWid = f.width( "30" );
691 //qDebug("dec-- "); 691 //qDebug("dec-- ");
692 } 692 }
693 693
694 connect( mWeekAction, SIGNAL( activated() ), 694 connect( mWeekAction, SIGNAL( activated() ),
695 this, SLOT( weekAction() ) ); 695 this, SLOT( weekAction() ) );
696 696
697 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 697 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
698 if ( p->mShowIconFilterview ) { 698 if ( p->mShowIconFilterview ) {
699 icon = loadPixmap( pathString + "filter" ); 699 icon = loadPixmap( pathString + "filter" );
700 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this ); 700 actionFilterMenuTB = new QAction( i18n("Filter selector"), icon, i18n("Filter selector"), 0, this );
701 connect( actionFilterMenuTB, SIGNAL( activated() ), 701 connect( actionFilterMenuTB, SIGNAL( activated() ),
702 this, SLOT( fillFilterMenuTB() ) ); 702 this, SLOT( fillFilterMenuTB() ) );
703 actionFilterMenuTB->addTo( iconToolBar ); 703 actionFilterMenuTB->addTo( iconToolBar );
704 selectFilterMenuTB = new QPopupMenu( this ); 704 selectFilterMenuTB = new QPopupMenu( this );
705 selectFilterMenuTB->setCheckable( true ); 705 selectFilterMenuTB->setCheckable( true );
706 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 706 connect ( selectFilterMenuTB, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
707 } 707 }
708 708
709 //#endif 709 //#endif
710 // ****************** 710 // ******************
711 QAction *action; 711 QAction *action;
712 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 712 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
713 configureToolBarMenu->setCheckable( true ); 713 configureToolBarMenu->setCheckable( true );
714 714
715 715
716 configureAgendaMenu->setCheckable( true ); 716 configureAgendaMenu->setCheckable( true );
717 int iii ; 717 int iii ;
718 for ( iii = 1;iii<= 10 ;++iii ){ 718 for ( iii = 1;iii<= 10 ;++iii ){
719 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 719 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
720 } 720 }
721 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 721 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
722 722
723 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 723 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
724 this, SLOT( showConfigureAgenda( ) ) ); 724 this, SLOT( showConfigureAgenda( ) ) );
725 725
726 icon = loadPixmap( pathString + "configure" ); 726 icon = loadPixmap( pathString + "configure" );
727 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 727 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
728 action->addTo( actionMenu ); 728 action->addTo( actionMenu );
729 connect( action, SIGNAL( activated() ), 729 connect( action, SIGNAL( activated() ),
730 mView, SLOT( edit_options() ) ); 730 mView, SLOT( edit_options() ) );
731 actionMenu->insertSeparator(); 731 actionMenu->insertSeparator();
732 732
733 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 733 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
734 action->addTo( actionMenu ); 734 action->addTo( actionMenu );
735 connect( action, SIGNAL( activated() ), 735 connect( action, SIGNAL( activated() ),
736 mView, SLOT( undo_delete() ) ); 736 mView, SLOT( undo_delete() ) );
737 actionMenu->insertSeparator(); 737 actionMenu->insertSeparator();
738 738
739 icon = loadPixmap( pathString + "newevent" ); 739 icon = loadPixmap( pathString + "newevent" );
740 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 740 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
741 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 ); 741 configureToolBarMenu->insertItem(i18n("Only one toolbar"), 6 );
742 configureToolBarMenu->insertSeparator(); 742 configureToolBarMenu->insertSeparator();
743 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 ); 743 configureToolBarMenu->insertItem(i18n("Filtermenu"), 7 );
744 configureToolBarMenu->insertSeparator(); 744 configureToolBarMenu->insertSeparator();
745 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 745 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
746 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 746 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
747 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 747 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
748 ne_action->addTo( actionMenu ); 748 ne_action->addTo( actionMenu );
749 connect( ne_action, SIGNAL( activated() ), 749 connect( ne_action, SIGNAL( activated() ),
750 mView, SLOT( newEvent() ) ); 750 mView, SLOT( newEvent() ) );
751 icon = loadPixmap( pathString + "newtodo" ); 751 icon = loadPixmap( pathString + "newtodo" );
752 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 752 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
753 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 753 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
754 nt_action->addTo( actionMenu ); 754 nt_action->addTo( actionMenu );
755 connect( nt_action, SIGNAL( activated() ), 755 connect( nt_action, SIGNAL( activated() ),
756 mView, SLOT( newTodo() ) ); 756 mView, SLOT( newTodo() ) );
757 757
758 icon = loadPixmap( pathString + "today" ); 758 icon = loadPixmap( pathString + "today" );
759 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 759 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
760 today_action->addTo( viewMenu ); 760 today_action->addTo( viewMenu );
761 connect( today_action, SIGNAL( activated() ), 761 connect( today_action, SIGNAL( activated() ),
762 mView, SLOT( goToday() ) ); 762 mView, SLOT( goToday() ) );
763 viewMenu->insertSeparator(); 763 viewMenu->insertSeparator();
764 764
765 // *********************** 765 // ***********************
766 if ( KOPrefs::instance()->mVerticalScreen ) { 766 if ( KOPrefs::instance()->mVerticalScreen ) {
767 icon = SmallIcon( "1updownarrow" ); 767 icon = SmallIcon( "1updownarrow" );
768 } else { 768 } else {
769 icon = SmallIcon("1leftrightarrow" ); 769 icon = SmallIcon("1leftrightarrow" );
770 } 770 }
771 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 ); 771 configureToolBarMenu->insertItem(icon, i18n("Toggle Fullscreen"), 28 );
772 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this ); 772 QAction* FSaction = new QAction( i18n("Toggle Fullscreen"), icon, i18n("Toggle Fullscreen"), 0, this );
773 FSaction->addTo( viewMenu ); 773 FSaction->addTo( viewMenu );
774 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() )); 774 connect( FSaction, SIGNAL( activated() ), mView, SLOT( toggleExpand() ));
775 775
776 icon = loadPixmap( pathString + "navi" ); 776 icon = loadPixmap( pathString + "navi" );
777 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 ); 777 configureToolBarMenu->insertItem(icon, i18n("Toggle DateNavigator"), 22 );
778 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 778 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
779 action->addTo( viewMenu ); 779 action->addTo( viewMenu );
780 connect( action, SIGNAL( activated() ), 780 connect( action, SIGNAL( activated() ),
781 mView, SLOT( toggleDateNavigatorWidget() ) ); 781 mView, SLOT( toggleDateNavigatorWidget() ) );
782 mToggleNav = action ; 782 mToggleNav = action ;
783 icon = loadPixmap( pathString + "filter" ); 783 icon = loadPixmap( pathString + "filter" );
784 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 ); 784 configureToolBarMenu->insertItem(icon, i18n("Filter menu icon"), 26 );
785 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 785 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
786 action->addTo( viewMenu ); 786 action->addTo( viewMenu );
787 connect( action, SIGNAL( activated() ), 787 connect( action, SIGNAL( activated() ),
788 mView, SLOT( toggleFilter() ) ); 788 mView, SLOT( toggleFilter() ) );
789 mToggleFilter = action; 789 mToggleFilter = action;
790 icon = loadPixmap( pathString + "allday" ); 790 icon = loadPixmap( pathString + "allday" );
791 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 ); 791 configureToolBarMenu->insertItem(icon, i18n("Toggle Allday"), 24 );
792 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 792 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
793 action->addTo( viewMenu ); 793 action->addTo( viewMenu );
794 connect( action, SIGNAL( activated() ), 794 connect( action, SIGNAL( activated() ),
795 mView, SLOT( toggleAllDaySize() ) ); 795 mView, SLOT( toggleAllDaySize() ) );
796 mToggleAllday = action; 796 mToggleAllday = action;
797 797
798 798
799 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 799 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
800 mToggleNav, SLOT( setEnabled ( bool ) ) ); 800 mToggleNav, SLOT( setEnabled ( bool ) ) );
801 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 801 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
802 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 802 mToggleFilter, SLOT( setEnabled ( bool ) ) );
803 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 803 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
804 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 804 mToggleAllday, SLOT( setEnabled ( bool ) ) );
805 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 805 // connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
806 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) ); 806 // configureAgendaMenu, SLOT( setEnabled ( bool ) ) );
807 807
808 viewMenu->insertSeparator(); 808 viewMenu->insertSeparator();
809 icon = loadPixmap( pathString + "picker" ); 809 icon = loadPixmap( pathString + "picker" );
810 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 810 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
811 action->addTo( viewMenu ); 811 action->addTo( viewMenu );
812 connect( action, SIGNAL( activated() ), 812 connect( action, SIGNAL( activated() ),
813 mView, SLOT( showDatePicker() ) ); 813 mView, SLOT( showDatePicker() ) );
814 action->addTo( iconToolBar ); 814 action->addTo( iconToolBar );
815 viewMenu->insertSeparator(); 815 viewMenu->insertSeparator();
816 816
817 if ( p-> mShowIconToggleFull ) 817 if ( p-> mShowIconToggleFull )
818 FSaction->addTo( iconToolBar ); 818 FSaction->addTo( iconToolBar );
819 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar ); 819 if ( p->mShowIconNavigator ) mToggleNav ->addTo( iconToolBar );
820 820
821 //******************** 821 //********************
822 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar ); 822 if ( p->mShowIconAllday ) mToggleAllday->addTo( iconToolBar );
823 823
824 824
825 icon = loadPixmap( pathString + "whatsnext" ); 825 icon = loadPixmap( pathString + "whatsnext" );
826 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 ); 826 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110 );
827 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 827 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
828 whatsnext_action->addTo( viewMenu ); 828 whatsnext_action->addTo( viewMenu );
829 connect( whatsnext_action, SIGNAL( activated() ), 829 connect( whatsnext_action, SIGNAL( activated() ),
830 mView->viewManager(), SLOT( showWhatsNextView() ) ); 830 mView->viewManager(), SLOT( showWhatsNextView() ) );
831 831
832 icon = loadPixmap( pathString + "xdays" ); 832 icon = loadPixmap( pathString + "xdays" );
833 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 ); 833 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100 );
834 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 834 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
835 xdays_action->addTo( viewMenu ); 835 xdays_action->addTo( viewMenu );
836 connect( xdays_action, SIGNAL( activated() ), 836 connect( xdays_action, SIGNAL( activated() ),
837 mView->viewManager(), SLOT( showNextXView() ) ); 837 mView->viewManager(), SLOT( showNextXView() ) );
838 838
839 839
840 icon = loadPixmap( pathString + "journal" ); 840 icon = loadPixmap( pathString + "journal" );
841 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 841 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
842 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 842 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
843 viewjournal_action->addTo( viewMenu ); 843 viewjournal_action->addTo( viewMenu );
844 connect( viewjournal_action, SIGNAL( activated() ), 844 connect( viewjournal_action, SIGNAL( activated() ),
845 mView->viewManager(), SLOT( showJournalView() ) ); 845 mView->viewManager(), SLOT( showJournalView() ) );
846 846
847 847
848 icon = loadPixmap( pathString + "day" ); 848 icon = loadPixmap( pathString + "day" );
849 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 849 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
850 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 850 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
851 day1_action->addTo( viewMenu ); 851 day1_action->addTo( viewMenu );
852 // action->addTo( toolBar ); 852 // action->addTo( toolBar );
853 connect( day1_action, SIGNAL( activated() ), 853 connect( day1_action, SIGNAL( activated() ),
854 mView->viewManager(), SLOT( showDayView() ) ); 854 mView->viewManager(), SLOT( showDayView() ) );
855 855
856 icon = loadPixmap( pathString + "workweek" ); 856 icon = loadPixmap( pathString + "workweek" );
857 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 857 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
858 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 858 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
859 day5_action->addTo( viewMenu ); 859 day5_action->addTo( viewMenu );
860 connect( day5_action, SIGNAL( activated() ), 860 connect( day5_action, SIGNAL( activated() ),
861 mView->viewManager(), SLOT( showWorkWeekView() ) ); 861 mView->viewManager(), SLOT( showWorkWeekView() ) );
862 862
863 icon = loadPixmap( pathString + "week" ); 863 icon = loadPixmap( pathString + "week" );
864 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 864 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
865 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 865 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
866 day7_action->addTo( viewMenu ); 866 day7_action->addTo( viewMenu );
867 connect( day7_action, SIGNAL( activated() ), 867 connect( day7_action, SIGNAL( activated() ),
868 mView->viewManager(), SLOT( showWeekView() ) ); 868 mView->viewManager(), SLOT( showWeekView() ) );
869 869
870 icon = loadPixmap( pathString + "workweek2" ); 870 icon = loadPixmap( pathString + "workweek2" );
871 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 871 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
872 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 872 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
873 day6_action->addTo( viewMenu ); 873 day6_action->addTo( viewMenu );
874 connect( day6_action, SIGNAL( activated() ), 874 connect( day6_action, SIGNAL( activated() ),
875 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 875 mView->viewManager(), SLOT( showMonthViewWeek() ) );
876 876
877 icon = loadPixmap( pathString + "month" ); 877 icon = loadPixmap( pathString + "month" );
878 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 878 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
879 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 879 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
880 month_action->addTo( viewMenu ); 880 month_action->addTo( viewMenu );
881 connect( month_action, SIGNAL( activated() ), 881 connect( month_action, SIGNAL( activated() ),
882 mView->viewManager(), SLOT( showMonthView() ) ); 882 mView->viewManager(), SLOT( showMonthView() ) );
883 883
884 icon = loadPixmap( pathString + "list" ); 884 icon = loadPixmap( pathString + "list" );
885 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 885 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
886 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 886 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
887 showlist_action->addTo( viewMenu ); 887 showlist_action->addTo( viewMenu );
888 connect( showlist_action, SIGNAL( activated() ), 888 connect( showlist_action, SIGNAL( activated() ),
889 mView->viewManager(), SLOT( showListView() ) ); 889 mView->viewManager(), SLOT( showListView() ) );
890 890
891 icon = loadPixmap( pathString + "todo" ); 891 icon = loadPixmap( pathString + "todo" );
892 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 892 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
893 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 893 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
894 todoview_action->addTo( viewMenu ); 894 todoview_action->addTo( viewMenu );
895 connect( todoview_action, SIGNAL( activated() ), 895 connect( todoview_action, SIGNAL( activated() ),
896 mView->viewManager(), SLOT( showTodoView() ) ); 896 mView->viewManager(), SLOT( showTodoView() ) );
897 897
898 898
899 899
900#if 0 900#if 0
901 action = new QAction( "view_timespan", "Time Span", 0, this ); 901 action = new QAction( "view_timespan", "Time Span", 0, this );
902 action->addTo( viewMenu ); 902 action->addTo( viewMenu );
903 connect( action, SIGNAL( activated() ), 903 connect( action, SIGNAL( activated() ),
904 mView->viewManager(), SLOT( showTimeSpanView() ) ); 904 mView->viewManager(), SLOT( showTimeSpanView() ) );
905#endif 905#endif
906 906
907 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 907 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
908 this ); 908 this );
909 mNewSubTodoAction->addTo( actionMenu ); 909 mNewSubTodoAction->addTo( actionMenu );
910 connect( mNewSubTodoAction, SIGNAL( activated() ), 910 connect( mNewSubTodoAction, SIGNAL( activated() ),
911 mView, SLOT( newSubTodo() ) ); 911 mView, SLOT( newSubTodo() ) );
912 912
913 actionMenu->insertSeparator(); 913 actionMenu->insertSeparator();
914 914
915 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 915 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
916 mShowAction->addTo( actionMenu ); 916 mShowAction->addTo( actionMenu );
917 connect( mShowAction, SIGNAL( activated() ), 917 connect( mShowAction, SIGNAL( activated() ),
918 mView, SLOT( showIncidence() ) ); 918 mView, SLOT( showIncidence() ) );
919 919
920 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 920 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
921 mEditAction->addTo( actionMenu ); 921 mEditAction->addTo( actionMenu );
922 connect( mEditAction, SIGNAL( activated() ), 922 connect( mEditAction, SIGNAL( activated() ),
923 mView, SLOT( editIncidence() ) ); 923 mView, SLOT( editIncidence() ) );
924 924
925 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 925 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
926 mDeleteAction->addTo( actionMenu ); 926 mDeleteAction->addTo( actionMenu );
927 connect( mDeleteAction, SIGNAL( activated() ), 927 connect( mDeleteAction, SIGNAL( activated() ),
928 mView, SLOT( deleteIncidence() ) ); 928 mView, SLOT( deleteIncidence() ) );
929 929
930 930
931 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 931 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
932 mCloneAction->addTo( actionMenu ); 932 mCloneAction->addTo( actionMenu );
933 connect( mCloneAction, SIGNAL( activated() ), 933 connect( mCloneAction, SIGNAL( activated() ),
934 mView, SLOT( cloneIncidence() ) ); 934 mView, SLOT( cloneIncidence() ) );
935 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 935 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
936 mMoveAction->addTo( actionMenu ); 936 mMoveAction->addTo( actionMenu );
937 connect( mMoveAction, SIGNAL( activated() ), 937 connect( mMoveAction, SIGNAL( activated() ),
938 mView, SLOT( moveIncidence() ) ); 938 mView, SLOT( moveIncidence() ) );
939 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 939 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
940 mBeamAction->addTo( actionMenu ); 940 mBeamAction->addTo( actionMenu );
941 connect( mBeamAction, SIGNAL( activated() ), 941 connect( mBeamAction, SIGNAL( activated() ),
942 mView, SLOT( beamIncidence() ) ); 942 mView, SLOT( beamIncidence() ) );
943 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 943 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
944 mCancelAction->addTo( actionMenu ); 944 mCancelAction->addTo( actionMenu );
945 connect( mCancelAction, SIGNAL( activated() ), 945 connect( mCancelAction, SIGNAL( activated() ),
946 mView, SLOT( toggleCancelIncidence() ) ); 946 mView, SLOT( toggleCancelIncidence() ) );
947 947
948 actionMenu->insertSeparator(); 948 actionMenu->insertSeparator();
949 949
950 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 950 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
951 this ); 951 this );
952 action->addTo( actionMenu ); 952 action->addTo( actionMenu );
953 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 953 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
954 954
955 icon = loadPixmap( pathString + "search" ); 955 icon = loadPixmap( pathString + "search" );
956 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 956 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
957 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5); 957 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 5);
958 search_action->addTo( actionMenu ); 958 search_action->addTo( actionMenu );
959 connect( search_action, SIGNAL( activated() ), 959 connect( search_action, SIGNAL( activated() ),
960 mView->dialogManager(), SLOT( showSearchDialog() ) ); 960 mView->dialogManager(), SLOT( showSearchDialog() ) );
961 961
962 962
963 963
964 if ( KOPrefs::instance()->mShowFullMenu ) { 964 if ( KOPrefs::instance()->mShowFullMenu ) {
965 actionMenu->insertSeparator(); 965 actionMenu->insertSeparator();
966 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 966 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
967 967
968 } 968 }
969 // actionMenu->insertSeparator(); 969 // actionMenu->insertSeparator();
970 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 970 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
971 this ); 971 this );
972 action->addTo( importMenu_X ); 972 action->addTo( importMenu_X );
973 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 973 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
974 action = new QAction( "import_quick", i18n("Import last file"), 0, 974 action = new QAction( "import_quick", i18n("Import last file"), 0,
975 this ); 975 this );
976 action->addTo( importMenu_X ); 976 action->addTo( importMenu_X );
977 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 977 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
978 importMenu_X->insertSeparator(); 978 importMenu_X->insertSeparator();
979 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 979 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
980 this ); 980 this );
981 action->addTo( importMenu_X ); 981 action->addTo( importMenu_X );
982 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 982 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
983 //#ifndef DESKTOP_VERSION 983 //#ifndef DESKTOP_VERSION
984 importMenu_X->insertSeparator(); 984 importMenu_X->insertSeparator();
985 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 985 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
986 this ); 986 this );
987 action->addTo( importMenu_X ); 987 action->addTo( importMenu_X );
988 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 988 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
989 //#else 989 //#else
990#ifdef _OL_IMPORT_ 990#ifdef _OL_IMPORT_
991 importMenu_X->insertSeparator(); 991 importMenu_X->insertSeparator();
992 action = new QAction( "import_ol", i18n("Import from OL"), 0, 992 action = new QAction( "import_ol", i18n("Import from OL"), 0,
993 this ); 993 this );
994 action->addTo( importMenu_X ); 994 action->addTo( importMenu_X );
995 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 995 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
996#endif 996#endif
997 //#endif 997 //#endif
998 998
999 //importMenu->insertSeparator(); 999 //importMenu->insertSeparator();
1000 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 1000 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
1001 this ); 1001 this );
1002 action->addTo( importMenu ); 1002 action->addTo( importMenu );
1003 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 1003 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
1004 1004
1005 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 1005 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
1006 this ); 1006 this );
1007 action->addTo( importMenu ); 1007 action->addTo( importMenu );
1008 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 1008 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
1009 importMenu->insertSeparator(); 1009 importMenu->insertSeparator();
1010 importMenu->insertItem( i18n("Import"), importMenu_X ); 1010 importMenu->insertItem( i18n("Import"), importMenu_X );
1011 //importMenu->insertSeparator(); 1011 //importMenu->insertSeparator();
1012 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 1012 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
1013 this ); 1013 this );
1014 action->addTo( exportMenu_X ); 1014 action->addTo( exportMenu_X );
1015 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 1015 connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
1016 1016
1017 1017
1018 //LR 1018 //LR
1019 QPopupMenu *ex2phone = new QPopupMenu( this ); 1019 QPopupMenu *ex2phone = new QPopupMenu( this );
1020 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1020 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1021 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1021 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1022 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 1022 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
1023 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone ); 1023 exportMenu_X->insertItem( i18n("Export to phone"), ex2phone );
1024 1024
1025 importMenu->insertItem( i18n("Export"), exportMenu_X ); 1025 importMenu->insertItem( i18n("Export"), exportMenu_X );
1026#ifndef DESKTOP_VERSION 1026#ifndef DESKTOP_VERSION
1027 //importMenu->insertSeparator(); 1027 //importMenu->insertSeparator();
1028 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 1028 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
1029 this ); 1029 this );
1030 brAction->addTo( beamMenu_X ); 1030 brAction->addTo( beamMenu_X );
1031 brAction->setToggleAction (true ) ; 1031 brAction->setToggleAction (true ) ;
1032 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 1032 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
1033 1033
1034 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 1034 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
1035 this ); 1035 this );
1036 action->addTo( beamMenu_X ); 1036 action->addTo( beamMenu_X );
1037 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 1037 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
1038 1038
1039 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 1039 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
1040 this ); 1040 this );
1041 action->addTo( beamMenu_X ); 1041 action->addTo( beamMenu_X );
1042 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 1042 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
1043 importMenu->insertItem( i18n("Beam"), beamMenu_X ); 1043 importMenu->insertItem( i18n("Beam"), beamMenu_X );
1044#else 1044#else
1045 //importMenu->insertSeparator(); 1045 //importMenu->insertSeparator();
1046 icon = loadPixmap( pathString + "print" ); 1046 icon = loadPixmap( pathString + "print" );
1047 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 1047 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
1048 action->addTo( beamMenu_X ); 1048 action->addTo( beamMenu_X );
1049 connect( action, SIGNAL( activated() ), 1049 connect( action, SIGNAL( activated() ),
1050 this, SLOT( printCal() ) ); 1050 this, SLOT( printCal() ) );
1051 1051
1052 icon = loadPixmap( pathString + "print" ); 1052 icon = loadPixmap( pathString + "print" );
1053 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 1053 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
1054 action->addTo( beamMenu_X ); 1054 action->addTo( beamMenu_X );
1055 connect( action, SIGNAL( activated() ), 1055 connect( action, SIGNAL( activated() ),
1056 this, SLOT( printSel() ) ); 1056 this, SLOT( printSel() ) );
1057 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 1057 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
1058 action->addTo( beamMenu_X ); 1058 action->addTo( beamMenu_X );
1059 connect( action, SIGNAL( activated() ), 1059 connect( action, SIGNAL( activated() ),
1060 mView->viewManager(), SLOT( slotprintWNV() ) ); 1060 mView->viewManager(), SLOT( slotprintWNV() ) );
1061 1061
1062 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this ); 1062 action = new QAction( i18n("Print selected event / todo..."),icon,i18n("Print selected event / todo..."), 0, this );
1063 action->addTo( beamMenu_X ); 1063 action->addTo( beamMenu_X );
1064 connect( action, SIGNAL( activated() ), 1064 connect( action, SIGNAL( activated() ),
1065 mView, SLOT( slotprintSelInc() ) ); 1065 mView, SLOT( slotprintSelInc() ) );
1066 1066
1067 1067
1068 importMenu->insertItem( i18n("Print"), beamMenu_X ); 1068 importMenu->insertItem( i18n("Print"), beamMenu_X );
1069#endif 1069#endif
1070 importMenu->insertSeparator(); 1070 importMenu->insertSeparator();
1071 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 1071 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
1072 this ); 1072 this );
1073 action->addTo( importMenu ); 1073 action->addTo( importMenu );
1074 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 1074 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
1075 importMenu->insertSeparator(); 1075 importMenu->insertSeparator();
1076 action = new QAction( "beam all", i18n("Save"), 0, 1076 action = new QAction( "beam all", i18n("Save"), 0,
1077 this ); 1077 this );
1078 action->addTo( importMenu ); 1078 action->addTo( importMenu );
1079 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 1079 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
1080 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 1080 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
1081 this ); 1081 this );
1082 action->addTo( importMenu ); 1082 action->addTo( importMenu );
1083 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 1083 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
1084 1084
1085 //menuBar->insertItem( "Configure",configureMenu ); 1085 //menuBar->insertItem( "Configure",configureMenu );
1086 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 1086 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
1087 icon = loadPixmap( "korganizer/korganizer" ); 1087 icon = loadPixmap( "korganizer/korganizer" );
1088 1088
1089 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 1089 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
1090 action->addTo( helpMenu ); 1090 action->addTo( helpMenu );
1091 connect( action, SIGNAL( activated() ), 1091 connect( action, SIGNAL( activated() ),
1092 SLOT( whatsNew() ) ); 1092 SLOT( whatsNew() ) );
1093 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 1093 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
1094 action->addTo( helpMenu ); 1094 action->addTo( helpMenu );
1095 connect( action, SIGNAL( activated() ), 1095 connect( action, SIGNAL( activated() ),
1096 SLOT( features() ) ); 1096 SLOT( features() ) );
1097 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 1097 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
1098 action->addTo( helpMenu ); 1098 action->addTo( helpMenu );
1099 connect( action, SIGNAL( activated() ), 1099 connect( action, SIGNAL( activated() ),
1100 SLOT( keyBindings() ) ); 1100 SLOT( keyBindings() ) );
1101 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this ); 1101 action = new QAction( "Storage Howto", i18n("Storage HowTo..."), 0,this );
1102 action->addTo( helpMenu ); 1102 action->addTo( helpMenu );
1103 connect( action, SIGNAL( activated() ), 1103 connect( action, SIGNAL( activated() ),
1104 SLOT( storagehowto() ) ); 1104 SLOT( storagehowto() ) );
1105 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this ); 1105 action = new QAction( "Timetracking Howto", i18n("Timetracking HowTo..."), 0,this );
1106 action->addTo( helpMenu ); 1106 action->addTo( helpMenu );
1107 connect( action, SIGNAL( activated() ), 1107 connect( action, SIGNAL( activated() ),
1108 SLOT( timetrackinghowto() ) ); 1108 SLOT( timetrackinghowto() ) );
1109 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 1109 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
1110 action->addTo( helpMenu ); 1110 action->addTo( helpMenu );
1111 connect( action, SIGNAL( activated() ), 1111 connect( action, SIGNAL( activated() ),
1112 SLOT( synchowto() ) ); 1112 SLOT( synchowto() ) );
1113 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 1113 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
1114 action->addTo( helpMenu ); 1114 action->addTo( helpMenu );
1115 connect( action, SIGNAL( activated() ), 1115 connect( action, SIGNAL( activated() ),
1116 SLOT( kdesynchowto() ) ); 1116 SLOT( kdesynchowto() ) );
1117 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 1117 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
1118 action->addTo( helpMenu ); 1118 action->addTo( helpMenu );
1119 connect( action, SIGNAL( activated() ), 1119 connect( action, SIGNAL( activated() ),
1120 SLOT( multisynchowto() ) ); 1120 SLOT( multisynchowto() ) );
1121 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 1121 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
1122 action->addTo( helpMenu ); 1122 action->addTo( helpMenu );
1123 connect( action, SIGNAL( activated() ), 1123 connect( action, SIGNAL( activated() ),
1124 SLOT( aboutAutoSaving() ) ); 1124 SLOT( aboutAutoSaving() ) );
1125 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 1125 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
1126 action->addTo( helpMenu ); 1126 action->addTo( helpMenu );
1127 connect( action, SIGNAL( activated() ), 1127 connect( action, SIGNAL( activated() ),
1128 SLOT( aboutKnownBugs() ) ); 1128 SLOT( aboutKnownBugs() ) );
1129 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 1129 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
1130 action->addTo( helpMenu ); 1130 action->addTo( helpMenu );
1131 connect( action, SIGNAL( activated() ), 1131 connect( action, SIGNAL( activated() ),
1132 SLOT( usertrans() ) ); 1132 SLOT( usertrans() ) );
1133 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 1133 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
1134 action->addTo( helpMenu ); 1134 action->addTo( helpMenu );
1135 connect( action, SIGNAL( activated() ), 1135 connect( action, SIGNAL( activated() ),
1136 SLOT( faq() ) ); 1136 SLOT( faq() ) );
1137 action = new QAction( "licence", i18n("Licence..."), 0, this ); 1137 action = new QAction( "licence", i18n("Licence..."), 0, this );
1138 action->addTo( helpMenu ); 1138 action->addTo( helpMenu );
1139 connect( action, SIGNAL( activated() ), 1139 connect( action, SIGNAL( activated() ),
1140 SLOT( licence() ) ); 1140 SLOT( licence() ) );
1141 action = new QAction( "about", i18n("About..."), 0, this ); 1141 action = new QAction( "about", i18n("About..."), 0, this );
1142 action->addTo( helpMenu ); 1142 action->addTo( helpMenu );
1143 connect( action, SIGNAL( activated() ), 1143 connect( action, SIGNAL( activated() ),
1144 SLOT( about() ) ); 1144 SLOT( about() ) );
1145 //menuBar->insertSeparator(); 1145 //menuBar->insertSeparator();
1146 1146
1147 // ****************************************************** 1147 // ******************************************************
1148 // menubar icons 1148 // menubar icons
1149 1149
1150 1150
1151 1151
1152 //menuBar->insertItem( iconToolBar ); 1152 //menuBar->insertItem( iconToolBar );
1153 //xdays_action 1153 //xdays_action
1154 if (p-> mShowIconNewEvent) 1154 if (p-> mShowIconNewEvent)
1155 ne_action->addTo( iconToolBar ); 1155 ne_action->addTo( iconToolBar );
1156 if (p->mShowIconNewTodo ) 1156 if (p->mShowIconNewTodo )
1157 nt_action->addTo( iconToolBar ); 1157 nt_action->addTo( iconToolBar );
1158 if (p-> mShowIconSearch) 1158 if (p-> mShowIconSearch)
1159 search_action->addTo( iconToolBar ); 1159 search_action->addTo( iconToolBar );
1160 if (p-> mShowIconWhatsThis) 1160 if (p-> mShowIconWhatsThis)
1161 QWhatsThis::whatsThisButton ( iconToolBar ); 1161 QWhatsThis::whatsThisButton ( iconToolBar );
1162 if (p-> mShowIconNext) 1162 if (p-> mShowIconNext)
1163 whatsnext_action->addTo( viewToolBar ); 1163 whatsnext_action->addTo( viewToolBar );
1164 if (p-> mShowIconNextDays) 1164 if (p-> mShowIconNextDays)
1165 xdays_action->addTo( viewToolBar ); 1165 xdays_action->addTo( viewToolBar );
1166 if (p-> mShowIconJournal) 1166 if (p-> mShowIconJournal)
1167 viewjournal_action->addTo( viewToolBar ); 1167 viewjournal_action->addTo( viewToolBar );
1168 if (p-> mShowIconDay1) 1168 if (p-> mShowIconDay1)
1169 day1_action->addTo( viewToolBar ); 1169 day1_action->addTo( viewToolBar );
1170 if (p-> mShowIconDay5) 1170 if (p-> mShowIconDay5)
1171 day5_action->addTo( viewToolBar ); 1171 day5_action->addTo( viewToolBar );
1172 if (p-> mShowIconDay7) 1172 if (p-> mShowIconDay7)
1173 day7_action->addTo( viewToolBar ); 1173 day7_action->addTo( viewToolBar );
1174 if (p-> mShowIconDay6) 1174 if (p-> mShowIconDay6)
1175 day6_action->addTo( viewToolBar ); 1175 day6_action->addTo( viewToolBar );
1176 if (p-> mShowIconMonth) 1176 if (p-> mShowIconMonth)
1177 month_action->addTo( viewToolBar ); 1177 month_action->addTo( viewToolBar );
1178 if (p-> mShowIconList) 1178 if (p-> mShowIconList)
1179 showlist_action->addTo( viewToolBar ); 1179 showlist_action->addTo( viewToolBar );
1180 if (p-> mShowIconTodoview) 1180 if (p-> mShowIconTodoview)
1181 todoview_action->addTo( viewToolBar ); 1181 todoview_action->addTo( viewToolBar );
1182 1182
1183 icon = loadPixmap( pathString + "2leftarrowB" ); 1183 icon = loadPixmap( pathString + "2leftarrowB" );
1184 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200); 1184 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200);
1185 if (p-> mShowIconBackFast) { 1185 if (p-> mShowIconBackFast) {
1186 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1186 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1187 connect( action, SIGNAL( activated() ), 1187 connect( action, SIGNAL( activated() ),
1188 mView, SLOT( goPreviousMonth() ) ); 1188 mView, SLOT( goPreviousMonth() ) );
1189 action->addTo( navigatorToolBar ); 1189 action->addTo( navigatorToolBar );
1190 } 1190 }
1191 icon = loadPixmap( pathString + "1leftarrowB" ); 1191 icon = loadPixmap( pathString + "1leftarrowB" );
1192 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210); 1192 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210);
1193 if (p-> mShowIconBack) { 1193 if (p-> mShowIconBack) {
1194 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1194 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1195 connect( action, SIGNAL( activated() ), 1195 connect( action, SIGNAL( activated() ),
1196 mView, SLOT( goPrevious() ) ); 1196 mView, SLOT( goPrevious() ) );
1197 action->addTo( navigatorToolBar ); 1197 action->addTo( navigatorToolBar );
1198 } 1198 }
1199 icon = loadPixmap( pathString + "today" ); 1199 icon = loadPixmap( pathString + "today" );
1200 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1200 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1201 if (p-> mShowIconToday) 1201 if (p-> mShowIconToday)
1202 today_action->addTo( navigatorToolBar ); 1202 today_action->addTo( navigatorToolBar );
1203 icon = loadPixmap( pathString + "1rightarrowB" ); 1203 icon = loadPixmap( pathString + "1rightarrowB" );
1204 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1204 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1205 if (p-> mShowIconForward) { 1205 if (p-> mShowIconForward) {
1206 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1206 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1207 connect( action, SIGNAL( activated() ), 1207 connect( action, SIGNAL( activated() ),
1208 mView, SLOT( goNext() ) ); 1208 mView, SLOT( goNext() ) );
1209 action->addTo( navigatorToolBar ); 1209 action->addTo( navigatorToolBar );
1210 } 1210 }
1211 icon = loadPixmap( pathString + "2rightarrowB" ); 1211 icon = loadPixmap( pathString + "2rightarrowB" );
1212 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1212 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1213 if (p-> mShowIconForwardFast) { 1213 if (p-> mShowIconForwardFast) {
1214 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1214 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1215 connect( action, SIGNAL( activated() ), 1215 connect( action, SIGNAL( activated() ),
1216 mView, SLOT( goNextMonth() ) ); 1216 mView, SLOT( goNextMonth() ) );
1217 action->addTo( navigatorToolBar ); 1217 action->addTo( navigatorToolBar );
1218 } 1218 }
1219 1219
1220 1220
1221 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6); 1221 configureToolBarMenu->insertItem(i18n("What's This?"), 300, 6);
1222 1222
1223 1223
1224 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true); 1224 if ( p->mShowIconNavigator ) configureToolBarMenu->setItemChecked( 22 , true);
1225 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true); 1225 if ( p->mShowIconAllday ) configureToolBarMenu->setItemChecked( 24 , true);
1226 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true); 1226 if ( p->mShowIconFilterview ) configureToolBarMenu->setItemChecked( 26 , true);
1227 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true); 1227 if ( p->mShowIconToggleFull ) configureToolBarMenu->setItemChecked( 28 , true);
1228 1228
1229 if (p-> mShowIconNewEvent) 1229 if (p-> mShowIconNewEvent)
1230 configureToolBarMenu->setItemChecked( 10, true ); 1230 configureToolBarMenu->setItemChecked( 10, true );
1231 if (p->mShowIconNewTodo ) 1231 if (p->mShowIconNewTodo )
1232 configureToolBarMenu->setItemChecked( 20, true ); 1232 configureToolBarMenu->setItemChecked( 20, true );
1233 if (p-> mShowIconSearch) 1233 if (p-> mShowIconSearch)
1234 configureToolBarMenu->setItemChecked( 120, true ); 1234 configureToolBarMenu->setItemChecked( 120, true );
1235 if (p-> mShowIconList) 1235 if (p-> mShowIconList)
1236 configureToolBarMenu->setItemChecked( 30, true ); 1236 configureToolBarMenu->setItemChecked( 30, true );
1237 if (p-> mShowIconDay1) 1237 if (p-> mShowIconDay1)
1238 configureToolBarMenu->setItemChecked( 40, true ); 1238 configureToolBarMenu->setItemChecked( 40, true );
1239 if (p-> mShowIconDay5) 1239 if (p-> mShowIconDay5)
1240 configureToolBarMenu->setItemChecked( 50, true ); 1240 configureToolBarMenu->setItemChecked( 50, true );
1241 if (p-> mShowIconDay6) 1241 if (p-> mShowIconDay6)
1242 configureToolBarMenu->setItemChecked( 75, true ); 1242 configureToolBarMenu->setItemChecked( 75, true );
1243 if (p-> mShowIconDay7) 1243 if (p-> mShowIconDay7)
1244 configureToolBarMenu->setItemChecked( 60, true ); 1244 configureToolBarMenu->setItemChecked( 60, true );
1245 if (p-> mShowIconMonth) 1245 if (p-> mShowIconMonth)
1246 configureToolBarMenu->setItemChecked( 70, true ); 1246 configureToolBarMenu->setItemChecked( 70, true );
1247 if (p-> mShowIconTodoview) 1247 if (p-> mShowIconTodoview)
1248 configureToolBarMenu->setItemChecked( 80, true ); 1248 configureToolBarMenu->setItemChecked( 80, true );
1249 if (p-> mShowIconBackFast) 1249 if (p-> mShowIconBackFast)
1250 configureToolBarMenu->setItemChecked( 200, true ); 1250 configureToolBarMenu->setItemChecked( 200, true );
1251 if (p-> mShowIconBack) 1251 if (p-> mShowIconBack)
1252 configureToolBarMenu->setItemChecked( 210, true ); 1252 configureToolBarMenu->setItemChecked( 210, true );
1253 if (p-> mShowIconToday) 1253 if (p-> mShowIconToday)
1254 configureToolBarMenu->setItemChecked( 130, true ); 1254 configureToolBarMenu->setItemChecked( 130, true );
1255 if (p-> mShowIconForward) 1255 if (p-> mShowIconForward)
1256 configureToolBarMenu->setItemChecked( 220, true ); 1256 configureToolBarMenu->setItemChecked( 220, true );
1257 if (p-> mShowIconForwardFast) 1257 if (p-> mShowIconForwardFast)
1258 configureToolBarMenu->setItemChecked( 230, true ); 1258 configureToolBarMenu->setItemChecked( 230, true );
1259 if (p-> mShowIconNextDays) 1259 if (p-> mShowIconNextDays)
1260 configureToolBarMenu->setItemChecked( 100, true ); 1260 configureToolBarMenu->setItemChecked( 100, true );
1261 if (p-> mShowIconNext) 1261 if (p-> mShowIconNext)
1262 configureToolBarMenu->setItemChecked( 110, true ); 1262 configureToolBarMenu->setItemChecked( 110, true );
1263 if (p-> mShowIconJournal) 1263 if (p-> mShowIconJournal)
1264 configureToolBarMenu->setItemChecked( 90, true ); 1264 configureToolBarMenu->setItemChecked( 90, true );
1265 if (p-> mShowIconWhatsThis) 1265 if (p-> mShowIconWhatsThis)
1266 configureToolBarMenu->setItemChecked( 300, true ); 1266 configureToolBarMenu->setItemChecked( 300, true );
1267 if (p-> mShowIconWeekNum) 1267 if (p-> mShowIconWeekNum)
1268 configureToolBarMenu->setItemChecked( 400, true ); 1268 configureToolBarMenu->setItemChecked( 400, true );
1269 if (!p-> mShowIconStretch) { 1269 if (!p-> mShowIconStretch) {
1270 QLabel* dummy = new QLabel( iconToolBar ); 1270 QLabel* dummy = new QLabel( iconToolBar );
1271 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1271 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1272 dummy->setMinimumWidth( 0 ); 1272 dummy->setMinimumWidth( 0 );
1273 iconToolBar->setStretchableWidget ( dummy ) ; 1273 iconToolBar->setStretchableWidget ( dummy ) ;
1274 } 1274 }
1275 else { 1275 else {
1276 iconToolBar->setHorizontalStretchable (true ); 1276 iconToolBar->setHorizontalStretchable (true );
1277 viewToolBar->setHorizontalStretchable (true ); 1277 viewToolBar->setHorizontalStretchable (true );
1278 navigatorToolBar->setHorizontalStretchable (true ); 1278 navigatorToolBar->setHorizontalStretchable (true );
1279 iconToolBar->setVerticalStretchable (true ); 1279 iconToolBar->setVerticalStretchable (true );
1280 viewToolBar->setVerticalStretchable (true ); 1280 viewToolBar->setVerticalStretchable (true );
1281 navigatorToolBar->setVerticalStretchable (true ); 1281 navigatorToolBar->setVerticalStretchable (true );
1282 configureToolBarMenu->setItemChecked( 5, true ); 1282 configureToolBarMenu->setItemChecked( 5, true );
1283 } 1283 }
1284 if (p-> mShowIconFilter) 1284 if (p-> mShowIconFilter)
1285 configureToolBarMenu->setItemChecked( 7, true ); 1285 configureToolBarMenu->setItemChecked( 7, true );
1286 if (p-> mShowIconOnetoolbar) 1286 if (p-> mShowIconOnetoolbar)
1287 configureToolBarMenu->setItemChecked( 6, true ); 1287 configureToolBarMenu->setItemChecked( 6, true );
1288 1288
1289 1289
1290 if ( filterMenubar ) { 1290 if ( filterMenubar ) {
1291 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) ); 1291 filterMenubar->reparent(filterToolBar,0,QPoint(0,0) );
1292 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) ); 1292 connect( mView->filterView(), SIGNAL( filterChanged() ), SLOT( updateFilterToolbar() ) );
1293 } 1293 }
1294 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1294 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1295 configureAgenda( p->mHourSize ); 1295 configureAgenda( p->mHourSize );
1296 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1296 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1297} 1297}
1298 1298
1299void MainWindow::exportToPhone( int mode ) 1299void MainWindow::exportToPhone( int mode )
1300{ 1300{
1301 1301
1302 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1302 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1303 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1303 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1304 KOex2phonePrefs ex2phone; 1304 KOex2phonePrefs ex2phone;
1305 1305
1306 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1306 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1307 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1307 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1308 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1308 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1309 if ( mode == 1 ) 1309 if ( mode == 1 )
1310 ex2phone.setCaption(i18n("Export complete calendar")); 1310 ex2phone.setCaption(i18n("Export complete calendar"));
1311 if ( mode == 2 ) 1311 if ( mode == 2 )
1312 ex2phone.setCaption(i18n("Export filtered calendar")); 1312 ex2phone.setCaption(i18n("Export filtered calendar"));
1313 1313
1314 if ( !ex2phone.exec() ) { 1314 if ( !ex2phone.exec() ) {
1315 return; 1315 return;
1316 } 1316 }
1317 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1317 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1318 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1318 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1319 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1319 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1320 1320
1321 int inFuture = 0; 1321 int inFuture = 0;
1322 if ( ex2phone.mWriteBackFuture->isChecked() ) 1322 if ( ex2phone.mWriteBackFuture->isChecked() )
1323 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1323 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1324 QPtrList<Incidence> delSel; 1324 QPtrList<Incidence> delSel;
1325 if ( mode == 1 ) 1325 if ( mode == 1 )
1326 delSel = mCalendar->rawIncidences(); 1326 delSel = mCalendar->rawIncidences();
1327 if ( mode == 2 ) 1327 if ( mode == 2 )
1328 delSel = mCalendar->incidences(); 1328 delSel = mCalendar->incidences();
1329 CalendarLocal* cal = new CalendarLocal(); 1329 CalendarLocal* cal = new CalendarLocal();
1330 cal->setLocalTime(); 1330 cal->setLocalTime();
1331 Incidence *incidence = delSel.first(); 1331 Incidence *incidence = delSel.first();
1332 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1332 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1333 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1333 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1334 while ( incidence ) { 1334 while ( incidence ) {
1335 if ( incidence->type() != "Journal" ) { 1335 if ( incidence->type() != "Journal" ) {
1336 bool add = true; 1336 bool add = true;
1337 if ( inFuture ) { 1337 if ( inFuture ) {
1338 QDateTime dt; 1338 QDateTime dt;
1339 if ( incidence->type() == "Todo" ) { 1339 if ( incidence->type() == "Todo" ) {
1340 Todo * t = (Todo*)incidence; 1340 Todo * t = (Todo*)incidence;
1341 if ( t->hasDueDate() ) 1341 if ( t->hasDueDate() )
1342 dt = t->dtDue(); 1342 dt = t->dtDue();
1343 else 1343 else
1344 dt = cur.addSecs( 62 ); 1344 dt = cur.addSecs( 62 );
1345 } 1345 }
1346 else { 1346 else {
1347 bool ok; 1347 bool ok;
1348 dt = incidence->getNextOccurence( cur, &ok ); 1348 dt = incidence->getNextOccurence( cur, &ok );
1349 if ( !ok ) 1349 if ( !ok )
1350 dt = cur.addSecs( -62 ); 1350 dt = cur.addSecs( -62 );
1351 } 1351 }
1352 if ( dt < cur || dt > end ) { 1352 if ( dt < cur || dt > end ) {
1353 add = false; 1353 add = false;
1354 } 1354 }
1355 } 1355 }
1356 if ( add ) { 1356 if ( add ) {
1357 Incidence *in = incidence->clone(); 1357 Incidence *in = incidence->clone();
1358 cal->addIncidence( in ); 1358 cal->addIncidence( in );
1359 } 1359 }
1360 } 1360 }
1361 incidence = delSel.next(); 1361 incidence = delSel.next();
1362 } 1362 }
1363 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1363 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1364 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1364 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1365 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1365 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1366 1366
1367 setCaption( i18n("Writing to phone...")); 1367 setCaption( i18n("Writing to phone..."));
1368 if ( PhoneFormat::writeToPhone( cal ) ) 1368 if ( PhoneFormat::writeToPhone( cal ) )
1369 setCaption( i18n("Export to phone successful!")); 1369 setCaption( i18n("Export to phone successful!"));
1370 else 1370 else
1371 setCaption( i18n("Error exporting to phone!")); 1371 setCaption( i18n("Error exporting to phone!"));
1372 delete cal; 1372 delete cal;
1373} 1373}
1374 1374
1375 1375
1376void MainWindow::setDefaultPreferences() 1376void MainWindow::setDefaultPreferences()
1377{ 1377{
1378 KOPrefs *p = KOPrefs::instance(); 1378 KOPrefs *p = KOPrefs::instance();
1379 1379
1380 p->mCompactDialogs = true; 1380 p->mCompactDialogs = true;
1381 p->mConfirm = true; 1381 p->mConfirm = true;
1382 // p->mEnableQuickTodo = false; 1382 // p->mEnableQuickTodo = false;
1383 1383
1384} 1384}
1385 1385
1386QString MainWindow::resourcePath() 1386QString MainWindow::resourcePath()
1387{ 1387{
1388 return KGlobal::iconLoader()->iconPath(); 1388 return KGlobal::iconLoader()->iconPath();
1389} 1389}
1390 1390
1391void MainWindow::displayText( QString text ,QString cap ) 1391void MainWindow::displayText( QString text ,QString cap )
1392{ 1392{
1393 QDialog dia( this, "name", true ); ; 1393 QDialog dia( this, "name", true ); ;
1394 dia.setCaption( cap ); 1394 dia.setCaption( cap );
1395 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1395 QVBoxLayout* lay = new QVBoxLayout( &dia );
1396 lay->setSpacing( 3 ); 1396 lay->setSpacing( 3 );
1397 lay->setMargin( 3 ); 1397 lay->setMargin( 3 );
1398 QTextBrowser tb ( &dia ); 1398 QTextBrowser tb ( &dia );
1399 lay->addWidget( &tb ); 1399 lay->addWidget( &tb );
1400 tb.setText( text ); 1400 tb.setText( text );
1401#ifdef DESKTOP_VERSION 1401#ifdef DESKTOP_VERSION
1402 dia.resize( 640, 480); 1402 dia.resize( 640, 480);
1403#else 1403#else
1404 dia.showMaximized(); 1404 dia.showMaximized();
1405#endif 1405#endif
1406 dia.exec(); 1406 dia.exec();
1407} 1407}
1408 1408
1409void MainWindow::features() 1409void MainWindow::features()
1410{ 1410{
1411 1411
1412 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1412 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1413} 1413}
1414 1414
1415void MainWindow::usertrans() 1415void MainWindow::usertrans()
1416{ 1416{
1417 1417
1418 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1418 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1419} 1419}
1420 1420
1421void MainWindow::storagehowto() 1421void MainWindow::storagehowto()
1422{ 1422{
1423 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" ); 1423 KApplication::showFile( "KDE-Pim/Pi Storage HowTo", "kdepim/storagehowto.txt" );
1424} 1424}
1425void MainWindow::timetrackinghowto() 1425void MainWindow::timetrackinghowto()
1426{ 1426{
1427 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" ); 1427 KApplication::showFile( "KO/Pi Timetracking HowTo", "kdepim/timetrackerhowto.txt" );
1428} 1428}
1429void MainWindow::kdesynchowto() 1429void MainWindow::kdesynchowto()
1430{ 1430{
1431 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1431 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1432} 1432}
1433void MainWindow::multisynchowto() 1433void MainWindow::multisynchowto()
1434{ 1434{
1435 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1435 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1436} 1436}
1437void MainWindow::synchowto() 1437void MainWindow::synchowto()
1438{ 1438{
1439 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1439 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1440} 1440}
1441void MainWindow::faq() 1441void MainWindow::faq()
1442{ 1442{
1443 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1443 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1444 1444
1445} 1445}
1446void MainWindow::whatsNew() 1446void MainWindow::whatsNew()
1447{ 1447{
1448 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1448 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1449 1449
1450} 1450}
1451void MainWindow::licence() 1451void MainWindow::licence()
1452{ 1452{
1453 KApplication::showLicence(); 1453 KApplication::showLicence();
1454 1454
1455} 1455}
1456void MainWindow::about() 1456void MainWindow::about()
1457{ 1457{
1458 QString version; 1458 QString version;
1459#include <../version> 1459#include <../version>
1460 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1460 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1461 i18n("KOrganizer/Platform-independent\n") + 1461 i18n("KOrganizer/Platform-independent\n") +
1462 "(KO/Pi) " + version + " - " + 1462 "(KO/Pi) " + version + " - " +
1463 1463
1464#ifdef DESKTOP_VERSION 1464#ifdef DESKTOP_VERSION
1465 i18n("Desktop Edition\n") + 1465 i18n("Desktop Edition\n") +
1466#else 1466#else
1467 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1467 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1468#endif 1468#endif
1469 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1469 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.info --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1470} 1470}
1471void MainWindow::keyBindings() 1471void MainWindow::keyBindings()
1472{ 1472{
1473 QString cap = i18n("KO/Pi Keys + Colors"); 1473 QString cap = i18n("KO/Pi Keys + Colors");
1474 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1474 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1475 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1475 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1476 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") + 1476 i18n("<p><b>N</b>: Switch to next view which has a toolbar icon</p>\n") +
1477 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") + 1477 i18n("<p><b>A+(shift or ctrl)</b>: Show occurence of next alarm</p>\n") +
1478 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1478 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1479 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1479 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1480 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1480 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1481 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1481 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1482 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1482 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1483 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+ 1483 i18n("<p><b>X</b>: Next X days view| <b>W</b>: What's next view\n ")+
1484 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1484 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1485 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1485 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1486 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1486 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1487 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1487 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1488 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1488 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1489 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1489 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1490 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+ 1490 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X+ctrl</b>: Toggle datenavigator</p>\n")+
1491 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1491 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1492 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1492 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1493 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1493 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1494 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1494 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1495 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1495 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1496 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1496 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1497 i18n("<p><h3>In agenda view:</h3></p>\n") + 1497 i18n("<p><h3>In agenda view:</h3></p>\n") +
1498 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1498 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1499 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1499 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1500 i18n("<p><h3>In todo view:</h3></p>\n") + 1500 i18n("<p><h3>In todo view:</h3></p>\n") +
1501 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1501 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1502 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1502 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1503 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1503 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1504 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1504 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1505 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1505 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1506 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1506 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1507 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1507 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1508 i18n("<p><h3>In list view:</h3></p>\n") + 1508 i18n("<p><h3>In list view:</h3></p>\n") +
1509 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1509 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1510 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1510 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1511 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1511 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1512 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1512 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1513 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1513 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1514 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1514 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1515 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1515 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1516 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1516 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1517 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1517 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1518 i18n("<p><b>E</b>: Edit item</p>\n") + 1518 i18n("<p><b>E</b>: Edit item</p>\n") +
1519 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1519 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1520 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1520 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1521 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1521 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1522 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1522 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1523 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1523 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1524 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1524 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1525 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1525 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1526 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1526 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1527 i18n("<p><b>White</b>: Item readonly</p>\n"); 1527 i18n("<p><b>White</b>: Item readonly</p>\n");
1528 displayText( text, cap); 1528 displayText( text, cap);
1529} 1529}
1530void MainWindow::aboutAutoSaving() 1530void MainWindow::aboutAutoSaving()
1531{ 1531{
1532 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1532 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1533 1533
1534 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1534 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1535 1535
1536} 1536}
1537void MainWindow::aboutKnownBugs() 1537void MainWindow::aboutKnownBugs()
1538{ 1538{
1539 QMessageBox* msg; 1539 QMessageBox* msg;
1540 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1540 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1541 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1541 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1542 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1542 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1543 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + 1543 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") +
1544 i18n("\nor report them in the bugtracker on\n") + 1544 i18n("\nor report them in the bugtracker on\n") +
1545 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1545 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1546 QMessageBox::NoIcon, 1546 QMessageBox::NoIcon,
1547 QMessageBox::Ok, 1547 QMessageBox::Ok,
1548 QMessageBox::NoButton, 1548 QMessageBox::NoButton,
1549 QMessageBox::NoButton); 1549 QMessageBox::NoButton);
1550 msg->exec(); 1550 msg->exec();
1551 delete msg; 1551 delete msg;
1552 1552
1553} 1553}
1554 1554
1555QString MainWindow::defaultFileName() 1555QString MainWindow::defaultFileName()
1556{ 1556{
1557 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1557 return locateLocal( "data", "korganizer/mycalendar.ics" );
1558} 1558}
1559QString MainWindow::syncFileName() 1559QString MainWindow::syncFileName()
1560{ 1560{
1561#ifdef DESKTOP_VERSION 1561#ifdef DESKTOP_VERSION
1562 return locateLocal( "tmp", "synccalendar.ics" ); 1562 return locateLocal( "tmp", "synccalendar.ics" );
1563#else 1563#else
1564 return QString( "/tmp/synccalendar.ics" ); 1564 return QString( "/tmp/synccalendar.ics" );
1565#endif 1565#endif
1566} 1566}
1567#include "koglobals.h" 1567#include "koglobals.h"
1568#include <kcalendarsystem.h> 1568#include <kcalendarsystem.h>
1569void MainWindow::updateWeek(QDate seda) 1569void MainWindow::updateWeek(QDate seda)
1570{ 1570{
1571 int weekNum = KGlobal::locale()->weekNum ( seda ); 1571 int weekNum = KGlobal::locale()->weekNum ( seda );
1572 mWeekPixmap.fill( mWeekBgColor ); 1572 mWeekPixmap.fill( mWeekBgColor );
1573 QPainter p ( &mWeekPixmap ); 1573 QPainter p ( &mWeekPixmap );
1574 p.setFont( mWeekFont ); 1574 p.setFont( mWeekFont );
1575 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1575 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1576 p.end(); 1576 p.end();
1577 QIconSet icon3 ( mWeekPixmap ); 1577 QIconSet icon3 ( mWeekPixmap );
1578 mWeekAction->setIconSet ( icon3 ); 1578 mWeekAction->setIconSet ( icon3 );
1579 1579
1580} 1580}
1581void MainWindow::updateWeekNum(const DateList &selectedDates) 1581void MainWindow::updateWeekNum(const DateList &selectedDates)
1582{ 1582{
1583 updateWeek( selectedDates.first() ); 1583 updateWeek( selectedDates.first() );
1584} 1584}
1585void MainWindow::processIncidenceSelection( Incidence *incidence ) 1585void MainWindow::processIncidenceSelection( Incidence *incidence )
1586{ 1586{
1587 1587
1588 if ( !incidence ) { 1588 if ( !incidence ) {
1589 enableIncidenceActions( false ); 1589 enableIncidenceActions( false );
1590 1590
1591 mNewSubTodoAction->setEnabled( false ); 1591 mNewSubTodoAction->setEnabled( false );
1592 setCaptionToDates(); 1592 setCaptionToDates();
1593 return; 1593 return;
1594 1594
1595 } 1595 }
1596 1596
1597 //KGlobal::locale()->formatDateTime(nextA, true); 1597 //KGlobal::locale()->formatDateTime(nextA, true);
1598 QString startString = ""; 1598 QString startString = "";
1599 if ( incidence->type() != "Todo" ) { 1599 if ( incidence->type() != "Todo" ) {
1600 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1600 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1601 if ( incidence->doesFloat() ) { 1601 if ( incidence->doesFloat() ) {
1602 startString += ": "+incidence->dtStartDateStr( true ); 1602 startString += ": "+incidence->dtStartDateStr( true );
1603 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1603 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1604 1604
1605 } else { 1605 } else {
1606 startString = ": "+incidence->dtStartStr(true); 1606 startString = ": "+incidence->dtStartStr(true);
1607 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1607 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1608 1608
1609 } 1609 }
1610 1610
1611 } else { 1611 } else {
1612 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1612 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1613 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1613 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1614 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1614 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1615 1615
1616 if ( incidence->isBirthday() || incidence->isAnniversary() ) { 1616 if ( incidence->isBirthday() || incidence->isAnniversary() ) {
1617 bool ok; 1617 bool ok;
1618 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1618 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1619 if ( ok ) { 1619 if ( ok ) {
1620 int years = noc.date().year() - incidence->dtStart().date().year(); 1620 int years = noc.date().year() - incidence->dtStart().date().year();
1621 startString += i18n(" (%1 y.)"). arg( years ); 1621 startString += i18n(" (%1 y.)"). arg( years );
1622 } 1622 }
1623 } 1623 }
1624 else 1624 else
1625 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1625 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1626 } 1626 }
1627 1627
1628 } 1628 }
1629 else 1629 else
1630 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1630 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1631 if ( !incidence->location().isEmpty() ) 1631 if ( !incidence->location().isEmpty() )
1632 startString += " (" +incidence->location()+")"; 1632 startString += " (" +incidence->location()+")";
1633 setCaption( incidence->summary()+startString); 1633 setCaption( incidence->summary()+startString);
1634 1634
1635 enableIncidenceActions( true ); 1635 enableIncidenceActions( true );
1636 1636
1637 if ( incidence->type() == "Event" ) { 1637 if ( incidence->type() == "Event" ) {
1638 mShowAction->setText( i18n("Show Event...") ); 1638 mShowAction->setText( i18n("Show Event...") );
1639 mEditAction->setText( i18n("Edit Event...") ); 1639 mEditAction->setText( i18n("Edit Event...") );
1640 mDeleteAction->setText( i18n("Delete Event...") ); 1640 mDeleteAction->setText( i18n("Delete Event...") );
1641 1641
1642 mNewSubTodoAction->setEnabled( false ); 1642 mNewSubTodoAction->setEnabled( false );
1643 } else if ( incidence->type() == "Todo" ) { 1643 } else if ( incidence->type() == "Todo" ) {
1644 mShowAction->setText( i18n("Show Todo...") ); 1644 mShowAction->setText( i18n("Show Todo...") );
1645 mEditAction->setText( i18n("Edit Todo...") ); 1645 mEditAction->setText( i18n("Edit Todo...") );
1646 mDeleteAction->setText( i18n("Delete Todo...") ); 1646 mDeleteAction->setText( i18n("Delete Todo...") );
1647 1647
1648 mNewSubTodoAction->setEnabled( true ); 1648 mNewSubTodoAction->setEnabled( true );
1649 } else { 1649 } else {
1650 mShowAction->setText( i18n("Show...") ); 1650 mShowAction->setText( i18n("Show...") );
1651 mShowAction->setText( i18n("Edit...") ); 1651 mShowAction->setText( i18n("Edit...") );
1652 mShowAction->setText( i18n("Delete...") ); 1652 mShowAction->setText( i18n("Delete...") );
1653 1653
1654 mNewSubTodoAction->setEnabled( false ); 1654 mNewSubTodoAction->setEnabled( false );
1655 } 1655 }
1656} 1656}
1657 1657
1658void MainWindow::enableIncidenceActions( bool enabled ) 1658void MainWindow::enableIncidenceActions( bool enabled )
1659{ 1659{
1660 mShowAction->setEnabled( enabled ); 1660 mShowAction->setEnabled( enabled );
1661 mEditAction->setEnabled( enabled ); 1661 mEditAction->setEnabled( enabled );
1662 mDeleteAction->setEnabled( enabled ); 1662 mDeleteAction->setEnabled( enabled );
1663 1663
1664 mCloneAction->setEnabled( enabled ); 1664 mCloneAction->setEnabled( enabled );
1665 mMoveAction->setEnabled( enabled ); 1665 mMoveAction->setEnabled( enabled );
1666 mBeamAction->setEnabled( enabled ); 1666 mBeamAction->setEnabled( enabled );
1667 mCancelAction->setEnabled( enabled ); 1667 mCancelAction->setEnabled( enabled );
1668} 1668}
1669 1669
1670void MainWindow::importOL() 1670void MainWindow::importOL()
1671{ 1671{
1672#ifdef _OL_IMPORT_ 1672#ifdef _OL_IMPORT_
1673 mView->clearAllViews();
1673 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1674 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1674 id->exec(); 1675 id->exec();
1675 delete id; 1676 delete id;
1676 mView->updateView(); 1677 mView->updateView();
1677#endif 1678#endif
1678} 1679}
1679void MainWindow::importBday() 1680void MainWindow::importBday()
1680{ 1681{
1681 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1682 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1682 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1683 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1683 i18n("Import!"), i18n("Cancel"), 0, 1684 i18n("Import!"), i18n("Cancel"), 0,
1684 0, 1 ); 1685 0, 1 );
1685 if ( result == 0 ) { 1686 if ( result == 0 ) {
1686 mView->importBday(); 1687 mView->importBday();
1687 1688
1688 } 1689 }
1689 1690
1690 1691
1691} 1692}
1692void MainWindow::importQtopia() 1693void MainWindow::importQtopia()
1693{ 1694{
1694 //#ifndef DESKTOP_VERSION 1695 //#ifndef DESKTOP_VERSION
1695 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"); 1696 QString mess = i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing");
1696#ifdef DESKTOP_VERSION 1697#ifdef DESKTOP_VERSION
1697 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml"); 1698 mess += i18n("The content of the following files will be\nimported (located in your home directory (hd)):\n(hd)/Applications/datebook/datebook.xml\n(hd)/Applications/todolist/todolist.xml\nThe following category file will be used:\n(hd)/Settings/Categories.xml");
1698#endif 1699#endif
1699 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess, 1700 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mess,
1700 i18n("Import!"), i18n("Cancel"), 0, 1701 i18n("Import!"), i18n("Cancel"), 0,
1701 0, 1 ); 1702 0, 1 );
1702 if ( result == 0 ) { 1703 if ( result == 0 ) {
1703#ifndef DESKTOP_VERSION 1704#ifndef DESKTOP_VERSION
1704 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1705 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1705 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1706 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1706 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1707 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1707#else 1708#else
1708 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml"; 1709 QString datebook = QDir::homeDirPath()+ "/Applications/datebook/datebook.xml";
1709 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml"; 1710 QString todolist = QDir::homeDirPath()+ "/Applications/todolist/todolist.xml";
1710 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml"; 1711 QString categories = QDir::homeDirPath()+ "/Settings/Categories.xml";
1711#endif 1712#endif
1712 mView->importQtopia( categories, datebook, todolist ); 1713 mView->importQtopia( categories, datebook, todolist );
1713 } 1714 }
1714#if 0 1715#if 0
1715 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1716 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1716 i18n("Not supported \non desktop!\n"), 1717 i18n("Not supported \non desktop!\n"),
1717 i18n("Ok"), i18n("Cancel"), 0, 1718 i18n("Ok"), i18n("Cancel"), 0,
1718 0, 1 ); 1719 0, 1 );
1719 1720
1720#endif 1721#endif
1721} 1722}
1722 1723
1723void MainWindow::saveOnClose() 1724void MainWindow::saveOnClose()
1724{ 1725{
1725 KOPrefs *p = KOPrefs::instance(); 1726 KOPrefs *p = KOPrefs::instance();
1726 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1727 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1727 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal ); 1728 p->mToolBarHorV = ( viewToolBar->orientation () == Qt:: Horizontal );
1728 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal ); 1729 p->mToolBarHorN = ( navigatorToolBar->orientation () == Qt:: Horizontal );
1729 if ( filterToolBar ) { 1730 if ( filterToolBar ) {
1730 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal ); 1731 p->mToolBarHorF = ( filterToolBar->orientation () == Qt:: Horizontal );
1731 } 1732 }
1732#ifdef DESKTOP_VERSION 1733#ifdef DESKTOP_VERSION
1733 1734
1734 QPoint myP; 1735 QPoint myP;
1735 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) ); 1736 myP = mapFromGlobal( iconToolBar->mapToGlobal( QPoint( 0,0) ) );
1736 if ( p->mToolBarHor ) 1737 if ( p->mToolBarHor )
1737 p->mToolBarUp = myP.y() > height()/2; 1738 p->mToolBarUp = myP.y() > height()/2;
1738 else 1739 else
1739 p->mToolBarUp = myP.x() > width()/2; 1740 p->mToolBarUp = myP.x() > width()/2;
1740 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) ); 1741 myP = mapFromGlobal( viewToolBar->mapToGlobal( QPoint( 0,0) ) );
1741 if ( p->mToolBarHorV ) 1742 if ( p->mToolBarHorV )
1742 p->mToolBarUpV = myP.y() > height()/2; 1743 p->mToolBarUpV = myP.y() > height()/2;
1743 else 1744 else
1744 p->mToolBarUpV = myP.x() > width()/2 ; 1745 p->mToolBarUpV = myP.x() > width()/2 ;
1745 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) ); 1746 myP = mapFromGlobal( navigatorToolBar->mapToGlobal( QPoint( 0,0) ) );
1746 if ( p->mToolBarHorN ) 1747 if ( p->mToolBarHorN )
1747 p->mToolBarUpN = myP.y() > height()/2; 1748 p->mToolBarUpN = myP.y() > height()/2;
1748 else 1749 else
1749 p->mToolBarUpN = myP.x() > width()/2 ; 1750 p->mToolBarUpN = myP.x() > width()/2 ;
1750 if ( filterToolBar ) { 1751 if ( filterToolBar ) {
1751 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) ); 1752 myP = mapFromGlobal( filterToolBar->mapToGlobal( QPoint( 0,0) ) );
1752 if ( p->mToolBarHorF ) 1753 if ( p->mToolBarHorF )
1753 p->mToolBarUpF = myP.y() > height()/2; 1754 p->mToolBarUpF = myP.y() > height()/2;
1754 else 1755 else
1755 p->mToolBarUpF = myP.x() > width()/2 ; 1756 p->mToolBarUpF = myP.x() > width()/2 ;
1756 } 1757 }
1757#else 1758#else
1758 if ( p->mToolBarHor ) 1759 if ( p->mToolBarHor )
1759 p->mToolBarUp = iconToolBar->y() > height()/2; 1760 p->mToolBarUp = iconToolBar->y() > height()/2;
1760 else 1761 else
1761 p->mToolBarUp = iconToolBar->x() > width()/2; 1762 p->mToolBarUp = iconToolBar->x() > width()/2;
1762 if ( p->mToolBarHorV ) 1763 if ( p->mToolBarHorV )
1763 p->mToolBarUpV = viewToolBar->y() > height()/2; 1764 p->mToolBarUpV = viewToolBar->y() > height()/2;
1764 else 1765 else
1765 p->mToolBarUpV = viewToolBar->x() > width()/2 ; 1766 p->mToolBarUpV = viewToolBar->x() > width()/2 ;
1766 1767
1767 if ( p->mToolBarHorN ) 1768 if ( p->mToolBarHorN )
1768 p->mToolBarUpN = navigatorToolBar->y() > height()/2; 1769 p->mToolBarUpN = navigatorToolBar->y() > height()/2;
1769 else 1770 else
1770 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ; 1771 p->mToolBarUpN = navigatorToolBar->x() > width()/2 ;
1771 if ( filterToolBar ) { 1772 if ( filterToolBar ) {
1772 if ( p->mToolBarHorF ) 1773 if ( p->mToolBarHorF )
1773 p->mToolBarUpF = filterToolBar->y() > height()/2; 1774 p->mToolBarUpF = filterToolBar->y() > height()/2;
1774 else 1775 else
1775 p->mToolBarUpF = filterToolBar->x() > width()/2 ; 1776 p->mToolBarUpF = filterToolBar->x() > width()/2 ;
1776 } 1777 }
1777#endif 1778#endif
1778 1779
1779 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1780 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1780 save(); 1781 save();
1781 mView->writeSettings(); 1782 mView->writeSettings();
1782} 1783}
1783void MainWindow::slotModifiedChanged( bool changed ) 1784void MainWindow::slotModifiedChanged( bool changed )
1784{ 1785{
1785 if ( mBlockAtStartup ) 1786 if ( mBlockAtStartup )
1786 return; 1787 return;
1787 1788
1788 int msec; 1789 int msec;
1789 // we store the changes after 1 minute, 1790 // we store the changes after 1 minute,
1790 // and for safety reasons after 10 minutes again 1791 // and for safety reasons after 10 minutes again
1791 if ( !mSyncManager->blockSave() ) 1792 if ( !mSyncManager->blockSave() )
1792 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1793 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1793 else 1794 else
1794 msec = 1000 * 600; 1795 msec = 1000 * 600;
1795 mSaveTimer.start( msec, true ); // 1 minute 1796 mSaveTimer.start( msec, true ); // 1 minute
1796 qDebug("KO: Saving File in %d secs!", msec/1000); 1797 qDebug("KO: Saving File in %d secs!", msec/1000);
1797 mCalendarModifiedFlag = true; 1798 mCalendarModifiedFlag = true;
1798} 1799}
1799void MainWindow::saveStopTimer() 1800void MainWindow::saveStopTimer()
1800{ 1801{
1801 mSaveTimer.stop(); 1802 mSaveTimer.stop();
1802} 1803}
1803void MainWindow::save() 1804void MainWindow::save()
1804{ 1805{
1805 if ( !mCalendarModifiedFlag ) { 1806 if ( !mCalendarModifiedFlag ) {
1806 qDebug("KO: Calendar not modified. Nothing saved."); 1807 qDebug("KO: Calendar not modified. Nothing saved.");
1807 return; 1808 return;
1808 } 1809 }
1809 if ( mSyncManager->blockSave() ) 1810 if ( mSyncManager->blockSave() )
1810 return; 1811 return;
1811 mSyncManager->setBlockSave(true); 1812 mSyncManager->setBlockSave(true);
1812 if ( mView->checkFileVersion( defaultFileName()) ) { 1813 if ( mView->checkFileVersion( defaultFileName()) ) {
1813 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){ 1814 if ( KPimGlobalPrefs::instance()->mBackupEnabled ){
1814 QDate reference ( 2000,1,1); 1815 QDate reference ( 2000,1,1);
1815 int daysTo = reference.daysTo ( QDate::currentDate() ); 1816 int daysTo = reference.daysTo ( QDate::currentDate() );
1816 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) { 1817 if ( daysTo - KPimGlobalPrefs::instance()->mBackupDayCount >= KOPrefs::instance()->mLastBackupDate ) {
1817 setCaption(i18n("Creating backup ... please wait ..." )); 1818 setCaption(i18n("Creating backup ... please wait ..." ));
1818 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate); 1819 qDebug("KO: Last backup was %d days ago ", daysTo - KOPrefs::instance()->mLastBackupDate);
1819 // we need the file path, the backup dir and the number of bups as param 1820 // we need the file path, the backup dir and the number of bups as param
1820 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir; 1821 QString bupDir = KPimGlobalPrefs::instance()->mBackupDatadir;
1821 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir) 1822 if ( KPimGlobalPrefs::instance()->mBackupUseDefaultDir)
1822 bupDir = KGlobalSettings::backupDataDir(); 1823 bupDir = KGlobalSettings::backupDataDir();
1823 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers ); 1824 int retval = KApplication::createBackup( defaultFileName(), bupDir, KPimGlobalPrefs::instance()->mBackupNumbers );
1824 if ( retval == 0 ) { 1825 if ( retval == 0 ) {
1825 qDebug("KO: Backup cancelled. Will try again tomorrow "); 1826 qDebug("KO: Backup cancelled. Will try again tomorrow ");
1826 // retval == 0 : backup skipped for today, try again tomorrow 1827 // retval == 0 : backup skipped for today, try again tomorrow
1827 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1; 1828 KOPrefs::instance()->mLastBackupDate = daysTo- KPimGlobalPrefs::instance()->mBackupDayCount+1;
1828 } else if ( retval == 1 ){ 1829 } else if ( retval == 1 ){
1829 qDebug("KO: Backup created."); 1830 qDebug("KO: Backup created.");
1830 // backup ok 1831 // backup ok
1831 KOPrefs::instance()->mLastBackupDate = daysTo; 1832 KOPrefs::instance()->mLastBackupDate = daysTo;
1832 1833
1833 } else if ( retval == 2 ){ 1834 } else if ( retval == 2 ){
1834 qDebug("KO: Backup globally cancelled."); 1835 qDebug("KO: Backup globally cancelled.");
1835 // backup globally cancelled 1836 // backup globally cancelled
1836 KPimGlobalPrefs::instance()->mBackupEnabled = false; 1837 KPimGlobalPrefs::instance()->mBackupEnabled = false;
1837 } 1838 }
1838 // retval == 3: do nothing, try again later 1839 // retval == 3: do nothing, try again later
1839 } 1840 }
1840 ; // KPimGlobalPrefs::instance()->mLastBackupDate 1841 ; // KPimGlobalPrefs::instance()->mLastBackupDate
1841 } 1842 }
1842 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1843 QTime neededSaveTime = QDateTime::currentDateTime().time();
1843 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1844 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1844 qDebug("KO: Start saving data to file!"); 1845 qDebug("KO: Start saving data to file!");
1845 mView->saveCalendar( defaultFileName() ); 1846 mView->saveCalendar( defaultFileName() );
1846 mCalendarModifiedFlag = false; 1847 mCalendarModifiedFlag = false;
1847 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1848 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1848 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1849 qDebug("KO: Needed %d ms for saving.",msNeeded );
1849 QString savemes; 1850 QString savemes;
1850 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1851 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1851 setCaption(savemes); 1852 setCaption(savemes);
1852 } else 1853 } else
1853 setCaption(i18n("Saving cancelled!")); 1854 setCaption(i18n("Saving cancelled!"));
1854 mSyncManager->setBlockSave( false ); 1855 mSyncManager->setBlockSave( false );
1855} 1856}
1856 1857
1857void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1858void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1858{ 1859{
1859 if ( !e->isAutoRepeat() ) { 1860 if ( !e->isAutoRepeat() ) {
1860 mFlagKeyPressed = false; 1861 mFlagKeyPressed = false;
1861 } 1862 }
1862} 1863}
1863void MainWindow::keyPressEvent ( QKeyEvent * e ) 1864void MainWindow::keyPressEvent ( QKeyEvent * e )
1864{ 1865{
1865 qApp->processEvents(); 1866 qApp->processEvents();
1866 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1867 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1867 e->ignore(); 1868 e->ignore();
1868 // qDebug(" ignore %d",e->isAutoRepeat() ); 1869 // qDebug(" ignore %d",e->isAutoRepeat() );
1869 return; 1870 return;
1870 } 1871 }
1871 if (! e->isAutoRepeat() ) 1872 if (! e->isAutoRepeat() )
1872 mFlagKeyPressed = true; 1873 mFlagKeyPressed = true;
1873 KOPrefs *p = KOPrefs::instance(); 1874 KOPrefs *p = KOPrefs::instance();
1874 bool showSelectedDates = false; 1875 bool showSelectedDates = false;
1875 int size; 1876 int size;
1876 int pro = 0; 1877 int pro = 0;
1877 //qDebug("MainWindow::keyPressEvent "); 1878 //qDebug("MainWindow::keyPressEvent ");
1878 switch ( e->key() ) { 1879 switch ( e->key() ) {
1879 case Qt::Key_Right: 1880 case Qt::Key_Right:
1880 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1881 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1881 mView->goNextMonth(); 1882 mView->goNextMonth();
1882 else 1883 else
1883 mView->goNext(); 1884 mView->goNext();
1884 showSelectedDates = true; 1885 showSelectedDates = true;
1885 break; 1886 break;
1886 case Qt::Key_Left: 1887 case Qt::Key_Left:
1887 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1888 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1888 mView->goPreviousMonth(); 1889 mView->goPreviousMonth();
1889 else 1890 else
1890 mView->goPrevious(); 1891 mView->goPrevious();
1891 showSelectedDates = true; 1892 showSelectedDates = true;
1892 break; 1893 break;
1893 case Qt::Key_Down: 1894 case Qt::Key_Down:
1894 mView->viewManager()->agendaView()->scrollOneHourDown(); 1895 mView->viewManager()->agendaView()->scrollOneHourDown();
1895 break; 1896 break;
1896 case Qt::Key_Up: 1897 case Qt::Key_Up:
1897 mView->viewManager()->agendaView()->scrollOneHourUp(); 1898 mView->viewManager()->agendaView()->scrollOneHourUp();
1898 break; 1899 break;
1899 case Qt::Key_K: 1900 case Qt::Key_K:
1900 mView->viewManager()->showMonthViewWeek(); 1901 mView->viewManager()->showMonthViewWeek();
1901 break; 1902 break;
1902 case Qt::Key_I: 1903 case Qt::Key_I:
1903 mView->showIncidence(); 1904 mView->showIncidence();
1904 break; 1905 break;
1905 case Qt::Key_Delete: 1906 case Qt::Key_Delete:
1906 case Qt::Key_Backspace: 1907 case Qt::Key_Backspace:
1907 mView->deleteIncidence(); 1908 mView->deleteIncidence();
1908 break; 1909 break;
1909 case Qt::Key_D: 1910 case Qt::Key_D:
1910 mView->viewManager()->showDayView(); 1911 mView->viewManager()->showDayView();
1911 showSelectedDates = true; 1912 showSelectedDates = true;
1912 break; 1913 break;
1913 case Qt::Key_O: 1914 case Qt::Key_O:
1914 mView->toggleFilerEnabled( ); 1915 mView->toggleFilerEnabled( );
1915 break; 1916 break;
1916 case Qt::Key_0: 1917 case Qt::Key_0:
1917 case Qt::Key_1: 1918 case Qt::Key_1:
1918 case Qt::Key_2: 1919 case Qt::Key_2:
1919 case Qt::Key_3: 1920 case Qt::Key_3:
1920 case Qt::Key_4: 1921 case Qt::Key_4:
1921 case Qt::Key_5: 1922 case Qt::Key_5:
1922 case Qt::Key_6: 1923 case Qt::Key_6:
1923 case Qt::Key_7: 1924 case Qt::Key_7:
1924 case Qt::Key_8: 1925 case Qt::Key_8:
1925 case Qt::Key_9: 1926 case Qt::Key_9:
1926 pro = e->key()-48; 1927 pro = e->key()-48;
1927 if ( pro == 0 ) 1928 if ( pro == 0 )
1928 pro = 10; 1929 pro = 10;
1929 if ( e->state() == Qt::ControlButton) 1930 if ( e->state() == Qt::ControlButton)
1930 pro += 10; 1931 pro += 10;
1931 break; 1932 break;
1932 case Qt::Key_M: 1933 case Qt::Key_M:
1933 mView->viewManager()->showMonthView(); 1934 mView->viewManager()->showMonthView();
1934 showSelectedDates = true; 1935 showSelectedDates = true;
1935 break; 1936 break;
1936 case Qt::Key_Insert: 1937 case Qt::Key_Insert:
1937 mView->newEvent(); 1938 mView->newEvent();
1938 break; 1939 break;
1939 case Qt::Key_S : 1940 case Qt::Key_S :
1940 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1941 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1941 mView->newSubTodo(); 1942 mView->newSubTodo();
1942 else 1943 else
1943 mView->dialogManager()->showSearchDialog(); 1944 mView->dialogManager()->showSearchDialog();
1944 break; 1945 break;
1945 case Qt::Key_Y : 1946 case Qt::Key_Y :
1946 case Qt::Key_Z : 1947 case Qt::Key_Z :
1947 mView->viewManager()->showWorkWeekView(); 1948 mView->viewManager()->showWorkWeekView();
1948 showSelectedDates = true; 1949 showSelectedDates = true;
1949 break; 1950 break;
1950 case Qt::Key_U : 1951 case Qt::Key_U :
1951 mView->viewManager()->showWeekView(); 1952 mView->viewManager()->showWeekView();
1952 showSelectedDates = true; 1953 showSelectedDates = true;
1953 break; 1954 break;
1954 case Qt::Key_H : 1955 case Qt::Key_H :
1955 keyBindings(); 1956 keyBindings();
1956 break; 1957 break;
1957 case Qt::Key_W: 1958 case Qt::Key_W:
1958 mView->viewManager()->showWhatsNextView(); 1959 mView->viewManager()->showWhatsNextView();
1959 break; 1960 break;
1960 case Qt::Key_L: 1961 case Qt::Key_L:
1961 mView->viewManager()->showListView(); 1962 mView->viewManager()->showListView();
1962 break; 1963 break;
1963 case Qt::Key_N: 1964 case Qt::Key_N:
1964 mView->viewManager()->showNextView(); 1965 mView->viewManager()->showNextView();
1965 break; 1966 break;
1966 case Qt::Key_V: 1967 case Qt::Key_V:
1967 mView->viewManager()->showTodoView(); 1968 mView->viewManager()->showTodoView();
1968 break; 1969 break;
1969 case Qt::Key_C: 1970 case Qt::Key_C:
1970 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1971 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1971 break; 1972 break;
1972 case Qt::Key_P: 1973 case Qt::Key_P:
1973 mView->showDatePicker( ); 1974 mView->showDatePicker( );
1974 break; 1975 break;
1975 case Qt::Key_F: 1976 case Qt::Key_F:
1976 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1977 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1977 mView->editFilters(); 1978 mView->editFilters();
1978 else 1979 else
1979 mView->toggleFilter(); 1980 mView->toggleFilter();
1980 break; 1981 break;
1981 case Qt::Key_X: 1982 case Qt::Key_X:
1982 if ( e->state() == Qt::ControlButton ) 1983 if ( e->state() == Qt::ControlButton )
1983 mView->toggleDateNavigatorWidget(); 1984 mView->toggleDateNavigatorWidget();
1984 else { 1985 else {
1985 mView->viewManager()->showNextXView(); 1986 mView->viewManager()->showNextXView();
1986 showSelectedDates = true; 1987 showSelectedDates = true;
1987 } 1988 }
1988 break; 1989 break;
1989 case Qt::Key_Space: 1990 case Qt::Key_Space:
1990 mView->toggleExpand(); 1991 mView->toggleExpand();
1991 break; 1992 break;
1992 case Qt::Key_A: 1993 case Qt::Key_A:
1993 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) 1994 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton )
1994 mView->showNextAlarms(); 1995 mView->showNextAlarms();
1995 else 1996 else
1996 mView->toggleAllDaySize(); 1997 mView->toggleAllDaySize();
1997 break; 1998 break;
1998 case Qt::Key_T: 1999 case Qt::Key_T:
1999 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2000 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2000 mView->newTodo(); 2001 mView->newTodo();
2001 else { 2002 else {
2002 mView->goToday(); 2003 mView->goToday();
2003 showSelectedDates = true; 2004 showSelectedDates = true;
2004 } 2005 }
2005 break; 2006 break;
2006 case Qt::Key_J: 2007 case Qt::Key_J:
2007 mView->viewManager()->showJournalView(); 2008 mView->viewManager()->showJournalView();
2008 break; 2009 break;
2009 case Qt::Key_B: 2010 case Qt::Key_B:
2010 mView->editIncidenceDescription();; 2011 mView->editIncidenceDescription();;
2011 break; 2012 break;
2012 // case Qt::Key_Return: 2013 // case Qt::Key_Return:
2013 case Qt::Key_E: 2014 case Qt::Key_E:
2014 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 2015 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
2015 mView->newEvent(); 2016 mView->newEvent();
2016 else 2017 else
2017 mView->editIncidence(); 2018 mView->editIncidence();
2018 break; 2019 break;
2019 case Qt::Key_Plus: 2020 case Qt::Key_Plus:
2020 size = p->mHourSize +2; 2021 size = p->mHourSize +2;
2021 if ( size <= 22 ) 2022 if ( size <= 22 )
2022 configureAgenda( size ); 2023 configureAgenda( size );
2023 break; 2024 break;
2024 case Qt::Key_Minus: 2025 case Qt::Key_Minus:
2025 size = p->mHourSize - 2; 2026 size = p->mHourSize - 2;
2026 if ( size >= 4 ) 2027 if ( size >= 4 )
2027 configureAgenda( size ); 2028 configureAgenda( size );
2028 break; 2029 break;
2029 2030
2030 2031
2031 default: 2032 default:
2032 e->ignore(); 2033 e->ignore();
2033 } 2034 }
2034 if ( pro > 0 ) { 2035 if ( pro > 0 ) {
2035 mView->selectFilter( pro-1 ); 2036 mView->selectFilter( pro-1 );
2036 } 2037 }
2037 if ( showSelectedDates ) { 2038 if ( showSelectedDates ) {
2038 ;// setCaptionToDates(); 2039 ;// setCaptionToDates();
2039 } 2040 }
2040 2041
2041} 2042}
2042void MainWindow::fillFilterMenuTB() 2043void MainWindow::fillFilterMenuTB()
2043{ 2044{
2044 selectFilterMenuTB->clear(); 2045 selectFilterMenuTB->clear();
2045 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 ); 2046 selectFilterMenuTB->insertItem(i18n ( "Edit Filters" ), 0 );
2046 selectFilterMenuTB->insertSeparator(); 2047 selectFilterMenuTB->insertSeparator();
2047 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 ); 2048 selectFilterMenuTB->insertItem(i18n ( "No Filter" ), 1 );
2048 2049
2049 selectFilterMenuTB->insertSeparator(); 2050 selectFilterMenuTB->insertSeparator();
2050 QPtrList<CalFilter> fili = mView->filters(); 2051 QPtrList<CalFilter> fili = mView->filters();
2051 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2052 CalFilter *curfilter = mView->filterView()->selectedFilter();
2052 CalFilter *filter = fili.first(); 2053 CalFilter *filter = fili.first();
2053 int iii = 2; 2054 int iii = 2;
2054 bool checkitem = mView->filterView()->filtersEnabled(); 2055 bool checkitem = mView->filterView()->filtersEnabled();
2055 while(filter) { 2056 while(filter) {
2056 selectFilterMenuTB->insertItem( filter->name(), iii ); 2057 selectFilterMenuTB->insertItem( filter->name(), iii );
2057 if ( filter == curfilter) 2058 if ( filter == curfilter)
2058 selectFilterMenuTB->setItemChecked( iii, checkitem ); 2059 selectFilterMenuTB->setItemChecked( iii, checkitem );
2059 filter = fili.next(); 2060 filter = fili.next();
2060 ++iii; 2061 ++iii;
2061 } 2062 }
2062 if ( !checkitem ) 2063 if ( !checkitem )
2063 selectFilterMenuTB->setItemChecked( 1, true ); 2064 selectFilterMenuTB->setItemChecked( 1, true );
2064 2065
2065 int x = 0; 2066 int x = 0;
2066 int y = iconToolBar->height(); 2067 int y = iconToolBar->height();
2067 int dX = 0; 2068 int dX = 0;
2068 int dY = 0; 2069 int dY = 0;
2069 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2070 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2070 if ( iconToolBar->y() > height()/2 ) { 2071 if ( iconToolBar->y() > height()/2 ) {
2071 dY = selectFilterMenuTB->sizeHint().height()+8; 2072 dY = selectFilterMenuTB->sizeHint().height()+8;
2072 y = 0; 2073 y = 0;
2073 } 2074 }
2074 } else { 2075 } else {
2075 if ( iconToolBar->x() > width()/2 ) { // right side 2076 if ( iconToolBar->x() > width()/2 ) { // right side
2076 x=0; 2077 x=0;
2077 dX= selectFilterMenuTB->sizeHint().width()+8; 2078 dX= selectFilterMenuTB->sizeHint().width()+8;
2078 y = 0; 2079 y = 0;
2079 } else { 2080 } else {
2080 x= iconToolBar->width(); 2081 x= iconToolBar->width();
2081 y = 0; 2082 y = 0;
2082 } 2083 }
2083 } 2084 }
2084 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2085 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2085 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))); 2086 selectFilterMenuTB->popup(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)));
2086} 2087}
2087void MainWindow::fillFilterMenu() 2088void MainWindow::fillFilterMenu()
2088{ 2089{
2089 selectFilterMenu->clear(); 2090 selectFilterMenu->clear();
2090 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 2091 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
2091 selectFilterMenu->insertSeparator(); 2092 selectFilterMenu->insertSeparator();
2092 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 ); 2093 selectFilterMenu->insertItem(i18n ( "No Filter" ), 1 );
2093 2094
2094 selectFilterMenu->insertSeparator(); 2095 selectFilterMenu->insertSeparator();
2095 QPtrList<CalFilter> fili = mView->filters(); 2096 QPtrList<CalFilter> fili = mView->filters();
2096 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2097 CalFilter *curfilter = mView->filterView()->selectedFilter();
2097 CalFilter *filter = fili.first(); 2098 CalFilter *filter = fili.first();
2098 int iii = 2; 2099 int iii = 2;
2099 bool checkitem = mView->filterView()->filtersEnabled(); 2100 bool checkitem = mView->filterView()->filtersEnabled();
2100 while(filter) { 2101 while(filter) {
2101 selectFilterMenu->insertItem( filter->name(), iii ); 2102 selectFilterMenu->insertItem( filter->name(), iii );
2102 if ( filter == curfilter) 2103 if ( filter == curfilter)
2103 selectFilterMenu->setItemChecked( iii, checkitem ); 2104 selectFilterMenu->setItemChecked( iii, checkitem );
2104 filter = fili.next(); 2105 filter = fili.next();
2105 ++iii; 2106 ++iii;
2106 } 2107 }
2107 if ( !checkitem ) 2108 if ( !checkitem )
2108 selectFilterMenu->setItemChecked( 1, true ); 2109 selectFilterMenu->setItemChecked( 1, true );
2109} 2110}
2110void MainWindow::fillFilterMenuPopup() 2111void MainWindow::fillFilterMenuPopup()
2111{ 2112{
2112 filterPopupMenu->clear(); 2113 filterPopupMenu->clear();
2113 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 ); 2114 filterPopupMenu->insertItem(i18n ( "No Filter" ), 0 );
2114 2115
2115 filterPopupMenu->insertSeparator(); 2116 filterPopupMenu->insertSeparator();
2116 QPtrList<CalFilter> fili = mView->filters(); 2117 QPtrList<CalFilter> fili = mView->filters();
2117 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2118 CalFilter *curfilter = mView->filterView()->selectedFilter();
2118 CalFilter *filter = fili.first(); 2119 CalFilter *filter = fili.first();
2119 int iii = 1; 2120 int iii = 1;
2120 bool checkitem = mView->filterView()->filtersEnabled(); 2121 bool checkitem = mView->filterView()->filtersEnabled();
2121 while(filter) { 2122 while(filter) {
2122 filterPopupMenu->insertItem( filter->name(), iii ); 2123 filterPopupMenu->insertItem( filter->name(), iii );
2123 if ( filter == curfilter) 2124 if ( filter == curfilter)
2124 filterPopupMenu->setItemChecked( iii, checkitem ); 2125 filterPopupMenu->setItemChecked( iii, checkitem );
2125 filter = fili.next(); 2126 filter = fili.next();
2126 ++iii; 2127 ++iii;
2127 } 2128 }
2128 if ( !checkitem ) 2129 if ( !checkitem )
2129 filterPopupMenu->setItemChecked( 0, true ); 2130 filterPopupMenu->setItemChecked( 0, true );
2130} 2131}
2131void MainWindow::selectFilter( int fil ) 2132void MainWindow::selectFilter( int fil )
2132{ 2133{
2133 2134
2134 if ( fil == 0 ) { 2135 if ( fil == 0 ) {
2135 mView->editFilters( ); 2136 mView->editFilters( );
2136 } else if ( fil == 1 ){ 2137 } else if ( fil == 1 ){
2137 if ( mView->filterView()->filtersEnabled() ) 2138 if ( mView->filterView()->filtersEnabled() )
2138 mView->toggleFilerEnabled( ); 2139 mView->toggleFilerEnabled( );
2139 } else { 2140 } else {
2140 if ( !mView->filterView()->filtersEnabled() ) { 2141 if ( !mView->filterView()->filtersEnabled() ) {
2141 mView->filterView()->blockSignals( true ); 2142 mView->filterView()->blockSignals( true );
2142 mView->toggleFilerEnabled( ); 2143 mView->toggleFilerEnabled( );
2143 mView->filterView()->blockSignals( false ); 2144 mView->filterView()->blockSignals( false );
2144 } 2145 }
2145 mView->selectFilter( fil-2 ); 2146 mView->selectFilter( fil-2 );
2146 } 2147 }
2147} 2148}
2148void MainWindow::updateFilterToolbar() 2149void MainWindow::updateFilterToolbar()
2149{ 2150{
2150 if ( filterMenubar ) { 2151 if ( filterMenubar ) {
2151 if ( !mView->filterView()->filtersEnabled() ) { 2152 if ( !mView->filterView()->filtersEnabled() ) {
2152 filterMenubar->changeItem( 0, i18n("No Filter") ); 2153 filterMenubar->changeItem( 0, i18n("No Filter") );
2153 } else { 2154 } else {
2154 CalFilter *curfilter = mView->filterView()->selectedFilter(); 2155 CalFilter *curfilter = mView->filterView()->selectedFilter();
2155 if ( curfilter ) { 2156 if ( curfilter ) {
2156 filterMenubar->changeItem( 0, curfilter->name() ); 2157 filterMenubar->changeItem( 0, curfilter->name() );
2157 } 2158 }
2158 } 2159 }
2159 } 2160 }
2160} 2161}
2161void MainWindow::selectFilterPopup( int fil ) 2162void MainWindow::selectFilterPopup( int fil )
2162{ 2163{
2163 selectFilter( fil + 1 ); 2164 selectFilter( fil + 1 );
2164 2165
2165} 2166}
2166void MainWindow::configureToolBar( int item ) 2167void MainWindow::configureToolBar( int item )
2167{ 2168{
2168 2169
2169 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 2170 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
2170 KOPrefs *p = KOPrefs::instance(); 2171 KOPrefs *p = KOPrefs::instance();
2171 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 2172 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
2172 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 ); 2173 p-> mShowIconOnetoolbar = configureToolBarMenu->isItemChecked( 6 );
2173 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 ); 2174 p-> mShowIconFilter = configureToolBarMenu->isItemChecked( 7 );
2174 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 2175 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
2175 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 2176 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
2176 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 ); 2177 p->mShowIconNavigator = configureToolBarMenu->isItemChecked( 22 );
2177 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 ); 2178 p->mShowIconAllday = configureToolBarMenu->isItemChecked( 24 );
2178 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 ); 2179 p->mShowIconFilterview = configureToolBarMenu->isItemChecked( 26 );
2179 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 ); 2180 p->mShowIconToggleFull = configureToolBarMenu->isItemChecked( 28 );
2180 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 2181 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
2181 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 2182 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
2182 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 2183 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
2183 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 2184 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
2184 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 2185 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
2185 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 2186 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
2186 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 2187 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
2187 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 2188 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
2188 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 2189 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
2189 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 2190 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
2190 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 2191 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
2191 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 2192 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
2192 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 2193 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
2193 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 2194 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
2194 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 2195 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
2195 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 2196 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
2196 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 2197 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
2197 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 2198 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
2198 // initActions(); 2199 // initActions();
2199} 2200}
2200void MainWindow::setCaption ( const QString & c ) 2201void MainWindow::setCaption ( const QString & c )
2201{ 2202{
2202 QString cap = c; 2203 QString cap = c;
2203 cap.replace( QRegExp("\n"), " " ); 2204 cap.replace( QRegExp("\n"), " " );
2204 cap = cap.stripWhiteSpace(); 2205 cap = cap.stripWhiteSpace();
2205 if ( cap.isEmpty() ) 2206 if ( cap.isEmpty() )
2206 cap = "KO/Pi"; 2207 cap = "KO/Pi";
2207 QWidget::setCaption( cap ); 2208 QWidget::setCaption( cap );
2208} 2209}
2209void MainWindow::setCaptionToDates() 2210void MainWindow::setCaptionToDates()
2210{ 2211{
2211 QString selDates; 2212 QString selDates;
2212 QDate date = mView->startDate(); 2213 QDate date = mView->startDate();
2213 if ( ! date.isValid() ) { 2214 if ( ! date.isValid() ) {
2214 setCaption(""); 2215 setCaption("");
2215 return; 2216 return;
2216 } 2217 }
2217 selDates = KGlobal::locale()->formatDate( date, true); 2218 selDates = KGlobal::locale()->formatDate( date, true);
2218 if (mView->startDate() < mView->endDate() ) 2219 if (mView->startDate() < mView->endDate() )
2219 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 2220 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
2220 else { 2221 else {
2221 QString addString; 2222 QString addString;
2222 if ( date == QDateTime::currentDateTime().date() ) 2223 if ( date == QDateTime::currentDateTime().date() )
2223 addString = i18n("Today"); 2224 addString = i18n("Today");
2224 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 2225 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
2225 addString = i18n("Tomorrow"); 2226 addString = i18n("Tomorrow");
2226 if ( !addString.isEmpty() ) 2227 if ( !addString.isEmpty() )
2227 selDates = addString+", "+selDates ; 2228 selDates = addString+", "+selDates ;
2228 } 2229 }
2229 setCaption( i18n("Dates: ") + selDates ); 2230 setCaption( i18n("Dates: ") + selDates );
2230 2231
2231} 2232}
2232void MainWindow::showConfigureAgenda( ) 2233void MainWindow::showConfigureAgenda( )
2233{ 2234{
2234 int iii; 2235 int iii;
2235 for ( iii = 1;iii<= 10 ;++iii ){ 2236 for ( iii = 1;iii<= 10 ;++iii ){
2236 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 2237 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
2237 } 2238 }
2238 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 2239 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
2239} 2240}
2240void MainWindow::configureAgenda( int item ) 2241void MainWindow::configureAgenda( int item )
2241{ 2242{
2242 if ( KOPrefs::instance()->mHourSize == item ) 2243 if ( KOPrefs::instance()->mHourSize == item )
2243 return; 2244 return;
2244 KOPrefs::instance()->mHourSize=item; 2245 KOPrefs::instance()->mHourSize=item;
2245 mView->viewManager()->agendaView()->updateConfig(); 2246 mView->viewManager()->agendaView()->updateConfig();
2246} 2247}
2247 2248
2248void MainWindow::saveCalendar() 2249void MainWindow::saveCalendar()
2249{ 2250{
2250 QString fn = KOPrefs::instance()->mLastSaveFile; 2251 QString fn = KOPrefs::instance()->mLastSaveFile;
2251 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 2252 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
2252 2253
2253 if ( fn == "" ) 2254 if ( fn == "" )
2254 return; 2255 return;
2255 QFileInfo info; 2256 QFileInfo info;
2256 info.setFile( fn ); 2257 info.setFile( fn );
2257 QString mes; 2258 QString mes;
2258 bool createbup = true; 2259 bool createbup = true;
2259 if ( info. exists() ) { 2260 if ( info. exists() ) {
2260 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 2261 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
2261 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2262 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2262 i18n("Overwrite!"), i18n("Cancel"), 0, 2263 i18n("Overwrite!"), i18n("Cancel"), 0,
2263 0, 1 ); 2264 0, 1 );
2264 if ( result != 0 ) { 2265 if ( result != 0 ) {
2265 createbup = false; 2266 createbup = false;
2266 } 2267 }
2267 } 2268 }
2268 if ( createbup ) { 2269 if ( createbup ) {
2269 mView->saveCalendar( fn ); 2270 mView->saveCalendar( fn );
2270 mes = i18n("KO/Pi:Saved %1").arg(fn); 2271 mes = i18n("KO/Pi:Saved %1").arg(fn);
2271 KOPrefs::instance()->mLastSaveFile = fn; 2272 KOPrefs::instance()->mLastSaveFile = fn;
2272 setCaption(mes); 2273 setCaption(mes);
2273 } 2274 }
2274} 2275}
2275void MainWindow::loadCalendar() 2276void MainWindow::loadCalendar()
2276{ 2277{
2277 2278
2278 QString fn = KOPrefs::instance()->mLastLoadFile; 2279 QString fn = KOPrefs::instance()->mLastLoadFile;
2279 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 2280 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
2280 2281
2281 if ( fn == "" ) 2282 if ( fn == "" )
2282 return; 2283 return;
2283 QFileInfo info; 2284 QFileInfo info;
2284 info.setFile( fn ); 2285 info.setFile( fn );
2285 QString mess; 2286 QString mess;
2286 bool loadbup = true; 2287 bool loadbup = true;
2287 if ( info. exists() ) { 2288 if ( info. exists() ) {
2288 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2289 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2289 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 2290 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
2290 mess, 2291 mess,
2291 i18n("Load!"), i18n("Cancel"), 0, 2292 i18n("Load!"), i18n("Cancel"), 0,
2292 0, 1 ); 2293 0, 1 );
2293 if ( result != 0 ) { 2294 if ( result != 0 ) {
2294 loadbup = false; 2295 loadbup = false;
2295 } 2296 }
2296 } else { 2297 } else {
2297 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2298 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2298 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 2299 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
2299 0, 1 ); 2300 0, 1 );
2300 2301
2301 return; 2302 return;
2302 } 2303 }
2303 if ( loadbup ) { 2304 if ( loadbup ) {
2304 mView->openCalendar( fn ); 2305 mView->openCalendar( fn );
2305 KOPrefs::instance()->mLastLoadFile = fn; 2306 KOPrefs::instance()->mLastLoadFile = fn;
2306 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 2307 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
2307 setCaption(mess); 2308 setCaption(mess);
2308 } 2309 }
2309 2310
2310} 2311}
2311void MainWindow::quickImportIcal() 2312void MainWindow::quickImportIcal()
2312{ 2313{
2313 importFile( KOPrefs::instance()->mLastImportFile, false ); 2314 importFile( KOPrefs::instance()->mLastImportFile, false );
2314} 2315}
2315void MainWindow::importFile( QString fn, bool quick ) 2316void MainWindow::importFile( QString fn, bool quick )
2316{ 2317{
2317 QFileInfo info; 2318 QFileInfo info;
2318 info.setFile( fn ); 2319 info.setFile( fn );
2319 QString mess; 2320 QString mess;
2320 bool loadbup = true; 2321 bool loadbup = true;
2321 if ( !info. exists() ) { 2322 if ( !info. exists() ) {
2322 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 2323 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
2323 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2324 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2324 mess ); 2325 mess );
2325 return; 2326 return;
2326 } 2327 }
2327 int result = 0; 2328 int result = 0;
2328 if ( !quick ) { 2329 if ( !quick ) {
2329 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2330 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2330 result = QMessageBox::warning( this, "KO/Pi: Warning!", 2331 result = QMessageBox::warning( this, "KO/Pi: Warning!",
2331 mess, 2332 mess,
2332 "Import", "Cancel", 0, 2333 "Import", "Cancel", 0,
2333 0, 1 ); 2334 0, 1 );
2334 } 2335 }
2335 if ( result == 0 ) { 2336 if ( result == 0 ) {
2336 if ( mView->openCalendar( fn, true )) { 2337 if ( mView->openCalendar( fn, true )) {
2337 KOPrefs::instance()->mLastImportFile = fn; 2338 KOPrefs::instance()->mLastImportFile = fn;
2338 setCaption(i18n("Imported file successfully")); 2339 setCaption(i18n("Imported file successfully"));
2339 } else { 2340 } else {
2340 setCaption(i18n("Error importing file")); 2341 setCaption(i18n("Error importing file"));
2341 } 2342 }
2342 } 2343 }
2343} 2344}
2344 2345
2345void MainWindow::importIcal() 2346void MainWindow::importIcal()
2346{ 2347{
2347 2348
2348 QString fn =KOPrefs::instance()->mLastImportFile; 2349 QString fn =KOPrefs::instance()->mLastImportFile;
2349 2350
2350 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 2351 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
2351 if ( fn == "" ) 2352 if ( fn == "" )
2352 return; 2353 return;
2353 importFile( fn, true ); 2354 importFile( fn, true );
2354 2355
2355} 2356}
2356 2357
2357void MainWindow::exportVCalendar() 2358void MainWindow::exportVCalendar()
2358{ 2359{
2359 QString fn = KOPrefs::instance()->mLastVcalFile; 2360 QString fn = KOPrefs::instance()->mLastVcalFile;
2360 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 2361 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
2361 if ( fn == "" ) 2362 if ( fn == "" )
2362 return; 2363 return;
2363 QFileInfo info; 2364 QFileInfo info;
2364 info.setFile( fn ); 2365 info.setFile( fn );
2365 QString mes; 2366 QString mes;
2366 bool createbup = true; 2367 bool createbup = true;
2367 if ( info. exists() ) { 2368 if ( info. exists() ) {
2368 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 2369 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
2369 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 2370 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
2370 i18n("Overwrite!"), i18n("Cancel"), 0, 2371 i18n("Overwrite!"), i18n("Cancel"), 0,
2371 0, 1 ); 2372 0, 1 );
2372 if ( result != 0 ) { 2373 if ( result != 0 ) {
2373 createbup = false; 2374 createbup = false;
2374 } 2375 }
2375 } 2376 }
2376 if ( createbup ) { 2377 if ( createbup ) {
2377 if ( mView->exportVCalendar( fn ) ) { 2378 if ( mView->exportVCalendar( fn ) ) {
2378 KOPrefs::instance()->mLastVcalFile = fn; 2379 KOPrefs::instance()->mLastVcalFile = fn;
2379 if ( fn.length() > 20 ) 2380 if ( fn.length() > 20 )
2380 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2381 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2381 else 2382 else
2382 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2383 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2383 setCaption(mes); 2384 setCaption(mes);
2384 } 2385 }
2385 } 2386 }
2386 2387
2387} 2388}
2388QString MainWindow::sentSyncFile() 2389QString MainWindow::sentSyncFile()
2389{ 2390{
2390#ifdef DESKTOP_VERSION 2391#ifdef DESKTOP_VERSION
2391 return locateLocal( "tmp", "copysynccal.ics" ); 2392 return locateLocal( "tmp", "copysynccal.ics" );
2392#else 2393#else
2393 return QString( "/tmp/copysynccal.ics" ); 2394 return QString( "/tmp/copysynccal.ics" );
2394#endif 2395#endif
2395} 2396}
2396 2397
2397void MainWindow::syncFileRequest() 2398void MainWindow::syncFileRequest()
2398{ 2399{
2399 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2400 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2400 mSyncManager->slotSyncMenu( 999 ); 2401 mSyncManager->slotSyncMenu( 999 );
2401 } 2402 }
2402 2403
2403 setCaption(i18n("Saving Data to temp file ..." )); 2404 setCaption(i18n("Saving Data to temp file ..." ));
2404 mView->saveCalendar( sentSyncFile() ); 2405 mView->saveCalendar( sentSyncFile() );
2405 setCaption(i18n("Data saved to temp file!" )); 2406 setCaption(i18n("Data saved to temp file!" ));
2406 2407
2407} 2408}
2408void MainWindow::getFile( bool success ) 2409void MainWindow::getFile( bool success )
2409{ 2410{
2410 if ( ! success ) { 2411 if ( ! success ) {
2411 setCaption( i18n("Error receiving file. Nothing changed!") ); 2412 setCaption( i18n("Error receiving file. Nothing changed!") );
2412 return; 2413 return;
2413 } 2414 }
2414 mView->openCalendar( sentSyncFile() ); 2415 mView->openCalendar( sentSyncFile() );
2415 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2416 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2416 mSyncManager->slotSyncMenu( 999 ); 2417 mSyncManager->slotSyncMenu( 999 );
2417 } 2418 }
2418 setCaption( i18n("Pi-Sync successful!") ); 2419 setCaption( i18n("Pi-Sync successful!") );
2419} 2420}
2420 2421
2421void MainWindow::printSel( ) 2422void MainWindow::printSel( )
2422{ 2423{
2423 mView->viewManager()->agendaView()->agenda()->printSelection(); 2424 mView->viewManager()->agendaView()->agenda()->printSelection();
2424} 2425}
2425 2426
2426void MainWindow::printCal() 2427void MainWindow::printCal()
2427{ 2428{
2428 mView->print();//mCp->showDialog(); 2429 mView->print();//mCp->showDialog();
2429} 2430}
2430 2431
2431 2432
2432#include "libkdepim/kdatepicker.h" 2433#include "libkdepim/kdatepicker.h"
2433#include <kdatetbl.h> 2434#include <kdatetbl.h>
2434 2435
2435void MainWindow::weekAction() 2436void MainWindow::weekAction()
2436{ 2437{
2437 int month; 2438 int month;
2438 KPopupFrame* popup = new KPopupFrame(this); 2439 KPopupFrame* popup = new KPopupFrame(this);
2439 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2440 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2440 // ----- 2441 // -----
2441 picker->resize(picker->sizeHint()); 2442 picker->resize(picker->sizeHint());
2442 popup->setMainWidget(picker); 2443 popup->setMainWidget(picker);
2443 picker->setFocus(); 2444 picker->setFocus();
2444 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2445 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2445 int x = 0; 2446 int x = 0;
2446 int y = iconToolBar->height(); 2447 int y = iconToolBar->height();
2447 int dX = 0; 2448 int dX = 0;
2448 int dY = 0; 2449 int dY = 0;
2449 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2450 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2450 if ( iconToolBar->y() > height()/2 ) { 2451 if ( iconToolBar->y() > height()/2 ) {
2451 dY = picker->sizeHint().height()+8; 2452 dY = picker->sizeHint().height()+8;
2452 y = 0; 2453 y = 0;
2453 } 2454 }
2454 } else { 2455 } else {
2455 if ( iconToolBar->x() > width()/2 ) { // right side 2456 if ( iconToolBar->x() > width()/2 ) { // right side
2456 x=0; 2457 x=0;
2457 dX= picker->sizeHint().width()+8; 2458 dX= picker->sizeHint().width()+8;
2458 y = 0; 2459 y = 0;
2459 } else { 2460 } else {
2460 x= iconToolBar->width(); 2461 x= iconToolBar->width();
2461 y = 0; 2462 y = 0;
2462 } 2463 }
2463 } 2464 }
2464 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2465 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2465 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2466 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2466 { 2467 {
2467 month = picker->getResult(); 2468 month = picker->getResult();
2468 emit selectWeek ( month ); 2469 emit selectWeek ( month );
2469 //qDebug("weekSelected %d ", month); 2470 //qDebug("weekSelected %d ", month);
2470 } 2471 }
2471 delete popup; 2472 delete popup;
2472} 2473}
2473 2474
2474void MainWindow::hideEvent ( QHideEvent * ) 2475void MainWindow::hideEvent ( QHideEvent * )
2475{ 2476{
2476 QString message; 2477 QString message;
2477 QDateTime nextA = mCalendar->nextAlarmEventDateTime(); 2478 QDateTime nextA = mCalendar->nextAlarmEventDateTime();
2478 if ( nextA.isValid() ) { 2479 if ( nextA.isValid() ) {
2479 QString sum = mCalendar->nextSummary(); 2480 QString sum = mCalendar->nextSummary();
2480 2481
2481 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false)); 2482 message = i18n("%1 %2 - %3 (next event/todo with alarm)").arg( KGlobal::locale()->formatTime(nextA.time() , false)).arg(sum ).arg( KGlobal::locale()->formatDate(nextA.date() , false));
2482 setCaption( message ); 2483 setCaption( message );
2483 } 2484 }
2484} 2485}
2485 2486
2486void MainWindow::resizeEvent( QResizeEvent* e) 2487void MainWindow::resizeEvent( QResizeEvent* e)
2487{ 2488{
2488#ifndef DESKTOP_VERSION 2489#ifndef DESKTOP_VERSION
2489 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) { 2490 if ( !KOPrefs::instance()->mShowIconFilter && !KOPrefs::instance()->mShowIconOnetoolbar && QApplication::desktop()->width() > 320) {
2490 if (QApplication::desktop()->width() > QApplication::desktop()->height() ) 2491 if (QApplication::desktop()->width() > QApplication::desktop()->height() )
2491 filterToolBar->hide(); 2492 filterToolBar->hide();
2492 else 2493 else
2493 filterToolBar->show(); 2494 filterToolBar->show();
2494 } 2495 }
2495#endif 2496#endif
2496 QMainWindow::resizeEvent( e); 2497 QMainWindow::resizeEvent( e);
2497} 2498}