summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp64
-rw-r--r--korganizer/koagenda.cpp4
-rw-r--r--korganizer/koagenda.h1
-rw-r--r--korganizer/komonthview.cpp5
4 files changed, 15 insertions, 59 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 426e8f9..2582931 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,1163 +1,1111 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preton.brown@yale.edu) 8 Preston Brown (preton.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "koagenda.h"
107#include "kodialogmanager.h" 108#include "kodialogmanager.h"
108#include "outgoingdialog.h" 109#include "outgoingdialog.h"
109#include "incomingdialog.h" 110#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 111#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 112#include "statusdialog.h"
112#include "kdatenavigator.h" 113#include "kdatenavigator.h"
113#include "kotodoview.h" 114#include "kotodoview.h"
114#include "datenavigator.h" 115#include "datenavigator.h"
115#include "resourceview.h" 116#include "resourceview.h"
116#include "navigatorbar.h" 117#include "navigatorbar.h"
117#include "searchdialog.h" 118#include "searchdialog.h"
118#include "mainwindow.h" 119#include "mainwindow.h"
119#include "categoryeditdialog.h" 120#include "categoryeditdialog.h"
120 121
121#include "calendarview.h" 122#include "calendarview.h"
122#ifndef DESKTOP_VERSION 123#ifndef DESKTOP_VERSION
123#include <qtopia/alarmserver.h> 124#include <qtopia/alarmserver.h>
124#endif 125#endif
125#ifndef _WIN32_ 126#ifndef _WIN32_
126#include <stdlib.h> 127#include <stdlib.h>
127#include <stdio.h> 128#include <stdio.h>
128#include <unistd.h> 129#include <unistd.h>
129#else 130#else
130#include <qprocess.h> 131#include <qprocess.h>
131#endif 132#endif
132 133
133#ifdef DESKTOP_VERSION 134#ifdef DESKTOP_VERSION
134#include <kabc/stdaddressbook.h> 135#include <kabc/stdaddressbook.h>
135#endif 136#endif
136using namespace KOrg; 137using namespace KOrg;
137using namespace KCal; 138using namespace KCal;
138extern int globalFlagBlockAgenda; 139extern int globalFlagBlockAgenda;
139extern int globalFlagBlockStartup; 140extern int globalFlagBlockStartup;
140 141
141 142
142MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
143 144
144{ 145{
145 mAlarms = alarms; 146 mAlarms = alarms;
146 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
147 QString mText = "<table width=\"100%\">\n"; 148 QString mText = "<table width=\"100%\">\n";
148 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
149#ifdef DESKTOP_VERSION 150#ifdef DESKTOP_VERSION
150 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
151#else 152#else
152 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
153#endif 154#endif
154 // mText += "<img src=\""; 155 // mText += "<img src=\"";
155 // mText += ipath; 156 // mText += ipath;
156 // mText += "\">"; 157 // mText += "\">";
157 //mEventDate = QDate::currentDate(); 158 //mEventDate = QDate::currentDate();
158#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
159 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
160#else 161#else
161 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
162#endif 163#endif
163 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
164 165
165 Incidence * inc = getNextInc( start ); 166 Incidence * inc = getNextInc( start );
166 int time = 0; 167 int time = 0;
167 //mText += "<table>"; 168 //mText += "<table>";
168 while ( inc ) { 169 while ( inc ) {
169 QDateTime dt ; 170 QDateTime dt ;
170 QString tempText = "<a "; 171 QString tempText = "<a ";
171 bool ok; 172 bool ok;
172 dt = inc->getNextOccurence( start, &ok ); 173 dt = inc->getNextOccurence( start, &ok );
173 if ( !ok ) continue; 174 if ( !ok ) continue;
174 if ( inc->typeID() == eventID ) { 175 if ( inc->typeID() == eventID ) {
175 tempText += "href=\"event:"; 176 tempText += "href=\"event:";
176 } else if ( inc->typeID() == todoID ) { 177 } else if ( inc->typeID() == todoID ) {
177 tempText += "href=\"todo:"; 178 tempText += "href=\"todo:";
178 } 179 }
179 tempText += inc->uid() + "\">"; 180 tempText += inc->uid() + "\">";
180 if ( inc->typeID() == todoID ) 181 if ( inc->typeID() == todoID )
181 tempText += i18n("Todo: "); 182 tempText += i18n("Todo: ");
182 if ( inc->summary().length() > 0 ) 183 if ( inc->summary().length() > 0 )
183 tempText += inc->summary(); 184 tempText += inc->summary();
184 else 185 else
185 tempText += i18n("-no summary-"); 186 tempText += i18n("-no summary-");
186 QString timestr; 187 QString timestr;
187 if (!inc->doesFloat()) 188 if (!inc->doesFloat())
188 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
189 else 190 else
190 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
191 if ( dt.date() < QDate::currentDate() && time == 0 ) { 192 if ( dt.date() < QDate::currentDate() && time == 0 ) {
192 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
193 mText += "<table>"; 194 mText += "<table>";
194 time = 1; 195 time = 1;
195 } 196 }
196 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 197 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
197 if ( time > 0 ) 198 if ( time > 0 )
198 mText +="</table>"; 199 mText +="</table>";
199 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
200 mText += "<table>"; 201 mText += "<table>";
201 time = 2; 202 time = 2;
202 203
203 } 204 }
204 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 205 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
205 if ( time > 0 ) 206 if ( time > 0 )
206 mText +="</table>"; 207 mText +="</table>";
207 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
208 mText += "<table>"; 209 mText += "<table>";
209 time = 3; 210 time = 3;
210 } 211 }
211 mText +="<tr><td><b>"; 212 mText +="<tr><td><b>";
212 mText += timestr; 213 mText += timestr;
213 mText += "</b></td><td>"; 214 mText += "</b></td><td>";
214 mText += tempText; 215 mText += tempText;
215 mText += "</td></tr>\n"; 216 mText += "</td></tr>\n";
216 inc = getNextInc( start ); 217 inc = getNextInc( start );
217 } 218 }
218 mText +="</table>"; 219 mText +="</table>";
219 setText( mText ); 220 setText( mText );
220} 221}
221 222
222MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 223MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
223{ 224{
224 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
225} 226}
226Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
227{ 228{
228 QDateTime dt ; 229 QDateTime dt ;
229 Incidence * retInc; 230 Incidence * retInc;
230 Incidence * inc = mAlarms.first(); 231 Incidence * inc = mAlarms.first();
231 if ( inc == 0 ) 232 if ( inc == 0 )
232 return 0; 233 return 0;
233 bool ok; 234 bool ok;
234 dt = inc->getNextOccurence( start, &ok ); 235 dt = inc->getNextOccurence( start, &ok );
235 if ( ! ok ) return 0; 236 if ( ! ok ) return 0;
236 QDateTime dtn ; 237 QDateTime dtn ;
237 retInc = inc; 238 retInc = inc;
238 inc = mAlarms.next(); 239 inc = mAlarms.next();
239 while ( inc ) { 240 while ( inc ) {
240 dtn = inc->getNextOccurence( start, &ok ); 241 dtn = inc->getNextOccurence( start, &ok );
241 if ( ! ok ) return 0; 242 if ( ! ok ) return 0;
242 if ( dtn < dt ) { 243 if ( dtn < dt ) {
243 dt = dtn; 244 dt = dtn;
244 retInc = inc; 245 retInc = inc;
245 } 246 }
246 inc = mAlarms.next(); 247 inc = mAlarms.next();
247 } 248 }
248 mAlarms.remove( retInc ); 249 mAlarms.remove( retInc );
249 return retInc; 250 return retInc;
250 251
251} 252}
252void MissedAlarmTextBrowser::setSource(const QString & n) 253void MissedAlarmTextBrowser::setSource(const QString & n)
253{ 254{
254 if (n.startsWith("event:")) { 255 if (n.startsWith("event:")) {
255#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
256 emit showIncidence(n.mid(8)); 257 emit showIncidence(n.mid(8));
257#else 258#else
258 emit showIncidence(n.mid(6)); 259 emit showIncidence(n.mid(6));
259#endif 260#endif
260 return; 261 return;
261 } else if (n.startsWith("todo:")) { 262 } else if (n.startsWith("todo:")) {
262#ifdef DESKTOP_VERSION 263#ifdef DESKTOP_VERSION
263 emit showIncidence(n.mid(7)); 264 emit showIncidence(n.mid(7));
264#else 265#else
265 emit showIncidence(n.mid(5)); 266 emit showIncidence(n.mid(5));
266#endif 267#endif
267 return; 268 return;
268 } 269 }
269} 270}
270 271
271 272
272class KOBeamPrefs : public QDialog 273class KOBeamPrefs : public QDialog
273{ 274{
274 public: 275 public:
275 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
276 QDialog( parent, name, true ) 277 QDialog( parent, name, true )
277 { 278 {
278 setCaption( i18n("Beam Options") ); 279 setCaption( i18n("Beam Options") );
279 QVBoxLayout* lay = new QVBoxLayout( this ); 280 QVBoxLayout* lay = new QVBoxLayout( this );
280 lay->setSpacing( 3 ); 281 lay->setSpacing( 3 );
281 lay->setMargin( 3 ); 282 lay->setMargin( 3 );
282 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
283 lay->addWidget( format ); 284 lay->addWidget( format );
284 format->setExclusive ( true ) ; 285 format->setExclusive ( true ) ;
285 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
286 lay->addWidget( time ); time->setExclusive ( true ) ; 287 lay->addWidget( time ); time->setExclusive ( true ) ;
287 vcal = new QRadioButton(" vCalendar ", format ); 288 vcal = new QRadioButton(" vCalendar ", format );
288 ical = new QRadioButton(" iCalendar ", format ); 289 ical = new QRadioButton(" iCalendar ", format );
289 vcal->setChecked( true ); 290 vcal->setChecked( true );
290 tz = new QRadioButton(i18n(" With timezone "), time ); 291 tz = new QRadioButton(i18n(" With timezone "), time );
291 local = new QRadioButton(i18n(" Local time "), time ); 292 local = new QRadioButton(i18n(" Local time "), time );
292 tz->setChecked( true ); 293 tz->setChecked( true );
293 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
294 lay->addWidget( ok ); 295 lay->addWidget( ok );
295 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
296 lay->addWidget( cancel ); 297 lay->addWidget( cancel );
297 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
298 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
299 resize( 200, 200 ); 300 resize( 200, 200 );
300 } 301 }
301 302
302 bool beamVcal() { return vcal->isChecked(); } 303 bool beamVcal() { return vcal->isChecked(); }
303 bool beamLocal() { return local->isChecked(); } 304 bool beamLocal() { return local->isChecked(); }
304private: 305private:
305 QRadioButton* vcal, *ical, *local, *tz; 306 QRadioButton* vcal, *ical, *local, *tz;
306}; 307};
307class KOCatPrefs : public QDialog 308class KOCatPrefs : public QDialog
308{ 309{
309 public: 310 public:
310 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
311 QDialog( parent, name, true ) 312 QDialog( parent, name, true )
312 { 313 {
313 setCaption( i18n("Manage new Categories") ); 314 setCaption( i18n("Manage new Categories") );
314 QVBoxLayout* lay = new QVBoxLayout( this ); 315 QVBoxLayout* lay = new QVBoxLayout( this );
315 lay->setSpacing( 3 ); 316 lay->setSpacing( 3 );
316 lay->setMargin( 3 ); 317 lay->setMargin( 3 );
317 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
318 lay->addWidget( lab ); 319 lay->addWidget( lab );
319 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
320 lay->addWidget( format ); 321 lay->addWidget( format );
321 format->setExclusive ( true ) ; 322 format->setExclusive ( true ) ;
322 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 323 addCatBut = new QRadioButton(i18n("Add to category list"), format );
323 new QRadioButton(i18n("Remove from Events/Todos"), format ); 324 new QRadioButton(i18n("Remove from Events/Todos"), format );
324 addCatBut->setChecked( true ); 325 addCatBut->setChecked( true );
325 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
326 lay->addWidget( ok ); 327 lay->addWidget( ok );
327 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
328 lay->addWidget( cancel ); 329 lay->addWidget( cancel );
329 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
330 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
331 resize( 200, 200 ); 332 resize( 200, 200 );
332 } 333 }
333 334
334 bool addCat() { return addCatBut->isChecked(); } 335 bool addCat() { return addCatBut->isChecked(); }
335private: 336private:
336 QRadioButton* addCatBut; 337 QRadioButton* addCatBut;
337}; 338};
338 339
339 340
340 341
341CalendarView::CalendarView( CalendarResources *calendar, 342CalendarView::CalendarView( CalendarResources *calendar,
342 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
343 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
344 mCalendar( calendar ), 345 mCalendar( calendar ),
345 mResourceManager( calendar->resourceManager() ) 346 mResourceManager( calendar->resourceManager() )
346{ 347{
347 348
348 mEventEditor = 0; 349 mEventEditor = 0;
349 mTodoEditor = 0; 350 mTodoEditor = 0;
350 351
351 init(); 352 init();
352} 353}
353 354
354CalendarView::CalendarView( Calendar *calendar, 355CalendarView::CalendarView( Calendar *calendar,
355 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
356 : CalendarViewBase( parent, name ), 357 : CalendarViewBase( parent, name ),
357 mCalendar( calendar ), 358 mCalendar( calendar ),
358 mResourceManager( 0 ) 359 mResourceManager( 0 )
359{ 360{
360 361
361 mEventEditor = 0; 362 mEventEditor = 0;
362 mTodoEditor = 0; 363 mTodoEditor = 0;
363 init(); 364 init();
364} 365}
365 366
366void CalendarView::init() 367void CalendarView::init()
367{ 368{
368 mNextAlarmDateTime = QDateTime::currentDateTime(); 369 mNextAlarmDateTime = QDateTime::currentDateTime();
369 setFocusPolicy ( NoFocus ); 370 setFocusPolicy ( NoFocus );
370 mViewerCallerIsSearchDialog = false; 371 mViewerCallerIsSearchDialog = false;
371 mBlockShowDates = false; 372 mBlockShowDates = false;
372 373
373 mDatePickerMode = 0; 374 mDatePickerMode = 0;
374 mCurrentSyncDevice = ""; 375 mCurrentSyncDevice = "";
375 mViewManager = new KOViewManager( this ); 376 mViewManager = new KOViewManager( this );
376 mDialogManager = new KODialogManager( this ); 377 mDialogManager = new KODialogManager( this );
377 mEventViewerDialog = 0; 378 mEventViewerDialog = 0;
378 mModified = false; 379 mModified = false;
379 mReadOnly = false; 380 mReadOnly = false;
380 mSelectedIncidence = 0; 381 mSelectedIncidence = 0;
381 mCalPrinter = 0; 382 mCalPrinter = 0;
382 mFilters.setAutoDelete(true); 383 mFilters.setAutoDelete(true);
383 384
384 mCalendar->registerObserver( this ); 385 mCalendar->registerObserver( this );
385 // TODO: Make sure that view is updated, when calendar is changed. 386 // TODO: Make sure that view is updated, when calendar is changed.
386 387
387 mStorage = new FileStorage( mCalendar ); 388 mStorage = new FileStorage( mCalendar );
388 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 389 mNavigator = new DateNavigator( this, "datevav", mViewManager );
389 390
390 QBoxLayout *topLayout = (QBoxLayout*)layout(); 391 QBoxLayout *topLayout = (QBoxLayout*)layout();
391#ifndef KORG_NOSPLITTER 392#ifndef KORG_NOSPLITTER
392 // create the main layout frames. 393 // create the main layout frames.
393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
394 topLayout->addWidget(mPanner); 395 topLayout->addWidget(mPanner);
395 396
396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
397 "CalendarView::LeftFrame"); 398 "CalendarView::LeftFrame");
398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
399 400
400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
401 "CalendarView::DateNavigator" ); 402 "CalendarView::DateNavigator" );
402 403
403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
405 mTodoList->setNavigator( mNavigator ); 406 mTodoList->setNavigator( mNavigator );
406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
407 408
408#ifdef KORG_NORESOURCEVIEW 409#ifdef KORG_NORESOURCEVIEW
409 mResourceView = 0; 410 mResourceView = 0;
410#else 411#else
411 if ( mResourceManager ) { 412 if ( mResourceManager ) {
412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
413 mResourceView->updateView(); 414 mResourceView->updateView();
414 connect( mResourceView, SIGNAL( resourcesChanged() ), 415 connect( mResourceView, SIGNAL( resourcesChanged() ),
415 SLOT( updateView() ) ); 416 SLOT( updateView() ) );
416 } else { 417 } else {
417 mResourceView = 0; 418 mResourceView = 0;
418 } 419 }
419#endif 420#endif
420 QWidget *rightBox = new QWidget( mPanner ); 421 QWidget *rightBox = new QWidget( mPanner );
421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
422 423
423 mRightFrame = new QWidgetStack( rightBox ); 424 mRightFrame = new QWidgetStack( rightBox );
424 rightLayout->addWidget( mRightFrame, 1 ); 425 rightLayout->addWidget( mRightFrame, 1 );
425 426
426 mLeftFrame = mLeftSplitter; 427 mLeftFrame = mLeftSplitter;
427#else 428#else
428 //QWidget *mainBox = new QWidget( this ); 429 //QWidget *mainBox = new QWidget( this );
429 //QWidget *leftFrame = new QWidget( mainBox ); 430 //QWidget *leftFrame = new QWidget( mainBox );
430 //QBoxLayout * mainBoxLayout; 431 //QBoxLayout * mainBoxLayout;
431 if ( KOPrefs::instance()->mVerticalScreen ) { 432 if ( KOPrefs::instance()->mVerticalScreen ) {
432 //mainBoxLayout = new QVBoxLayout(mainBox); 433 //mainBoxLayout = new QVBoxLayout(mainBox);
433 //leftFrameLayout = new QHBoxLayout(leftFrame ); 434 //leftFrameLayout = new QHBoxLayout(leftFrame );
434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
438 } else { 439 } else {
439 //mainBoxLayout = new QHBoxLayout(mainBox); 440 //mainBoxLayout = new QHBoxLayout(mainBox);
440 //leftFrameLayout = new QVBoxLayout(leftFrame ); 441 //leftFrameLayout = new QVBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
445 } 446 }
446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
447 //QBoxLayout * leftFrameLayout; 448 //QBoxLayout * leftFrameLayout;
448 topLayout->addWidget( mMainFrame ); 449 topLayout->addWidget( mMainFrame );
449#ifdef DESKTOP_VERSION 450#ifdef DESKTOP_VERSION
450 mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); 451 mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this );
451 topLayout->addWidget( mDateScrollBar ); 452 topLayout->addWidget( mDateScrollBar );
452 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
453 if ( QApplication::desktop()->width() < 800 ) 454 if ( QApplication::desktop()->width() < 800 )
454 mDateScrollBar->hide(); 455 mDateScrollBar->hide();
455#endif 456#endif
456 //mainBoxLayout->addWidget (mLeftFrame); 457 //mainBoxLayout->addWidget (mLeftFrame);
457 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 458 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
458 "CalendarView::DateNavigator" ); 459 "CalendarView::DateNavigator" );
459#if 0 460#if 0
460 // FIXME 461 // FIXME
461 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
462 "CalendarView::DateNavigator", QDate::currentDate()); 463 "CalendarView::DateNavigator", QDate::currentDate());
463#endif 464#endif
464 // mDateNavigator->blockSignals( true ); 465 // mDateNavigator->blockSignals( true );
465 //leftFrameLayout->addWidget( mDateNavigator ); 466 //leftFrameLayout->addWidget( mDateNavigator );
466 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
467 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
468 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
469 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
470 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
471 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
472 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
474 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
475 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
476 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
477 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
478 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
479 480
480 mTodoList->setNavigator( mNavigator ); 481 mTodoList->setNavigator( mNavigator );
481#if 0 482#if 0
482 if ( QApplication::desktop()->width() < 480 ) { 483 if ( QApplication::desktop()->width() < 480 ) {
483 leftFrameLayout->addWidget(mFilterView); 484 leftFrameLayout->addWidget(mFilterView);
484 leftFrameLayout->addWidget(mTodoList, 2 ); 485 leftFrameLayout->addWidget(mTodoList, 2 );
485 486
486 } else { 487 } else {
487 leftFrameLayout->addWidget(mTodoList,2 ); 488 leftFrameLayout->addWidget(mTodoList,2 );
488 leftFrameLayout->addWidget(mFilterView ); 489 leftFrameLayout->addWidget(mFilterView );
489 } 490 }
490#endif 491#endif
491 mFilterView->hide(); 492 mFilterView->hide();
492 mCalEditView->hide(); 493 mCalEditView->hide();
493 QWidget *rightBox = new QWidget( mMainFrame ); 494 QWidget *rightBox = new QWidget( mMainFrame );
494 //mainBoxLayout->addWidget ( rightBox, 10 ); 495 //mainBoxLayout->addWidget ( rightBox, 10 );
495 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
496 mRightFrame = new QWidgetStack( rightBox ); 497 mRightFrame = new QWidgetStack( rightBox );
497 rightLayout->addWidget( mRightFrame, 10 ); 498 rightLayout->addWidget( mRightFrame, 10 );
498 499
499 //mLeftFrame = (QWidget *)leftFrame; 500 //mLeftFrame = (QWidget *)leftFrame;
500 if ( KOPrefs::instance()->mVerticalScreen ) { 501 if ( KOPrefs::instance()->mVerticalScreen ) {
501 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
502 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
503 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
504 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
505 } else { 506 } else {
506 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
507 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
508 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
509 } 510 }
510 if ( !KOPrefs::instance()->mShowDateNavigator) 511 if ( !KOPrefs::instance()->mShowDateNavigator)
511 mDateNavigator->hide(); 512 mDateNavigator->hide();
512 //qDebug("Calendarview Size %d %d ", width(), height()); 513 //qDebug("Calendarview Size %d %d ", width(), height());
513#endif 514#endif
514 515
515 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
516 SLOT( showDates( const KCal::DateList & ) ) ); 517 SLOT( showDates( const KCal::DateList & ) ) );
517 518
518 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
519 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
520 521
521 522
522 523
523 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
524 mViewManager, SLOT( showMonth( const QDate & ) ) ); 525 mViewManager, SLOT( showMonth( const QDate & ) ) );
525 526
526 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
527 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 528 mNavigator, SLOT( selectWeek( const QDate & ) ) );
528 529
529 connect( mDateNavigator, SIGNAL( goPrevYear() ), 530 connect( mDateNavigator, SIGNAL( goPrevYear() ),
530 mNavigator, SLOT( selectPreviousYear() ) ); 531 mNavigator, SLOT( selectPreviousYear() ) );
531 connect( mDateNavigator, SIGNAL( goNextYear() ), 532 connect( mDateNavigator, SIGNAL( goNextYear() ),
532 mNavigator, SLOT( selectNextYear() ) ); 533 mNavigator, SLOT( selectNextYear() ) );
533 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 534 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
534 mNavigator, SLOT( selectPreviousMonth() ) ); 535 mNavigator, SLOT( selectPreviousMonth() ) );
535 connect( mDateNavigator, SIGNAL( goNextMonth() ), 536 connect( mDateNavigator, SIGNAL( goNextMonth() ),
536 mNavigator, SLOT( selectNextMonth() ) ); 537 mNavigator, SLOT( selectNextMonth() ) );
537 538
538 connect( mDateNavigator, SIGNAL( goPrevious() ), 539 connect( mDateNavigator, SIGNAL( goPrevious() ),
539 mNavigator, SLOT( selectPrevious() ) ); 540 mNavigator, SLOT( selectPrevious() ) );
540 connect( mDateNavigator, SIGNAL( goNext() ), 541 connect( mDateNavigator, SIGNAL( goNext() ),
541 mNavigator, SLOT( selectNext() ) ); 542 mNavigator, SLOT( selectNext() ) );
542 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
543 mNavigator, SLOT( slotMonthSelect( int ) ) ); 544 mNavigator, SLOT( slotMonthSelect( int ) ) );
544 545
545 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
546 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
547#if 0 548#if 0
548 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
549 SLOT( incidenceAdded( Incidence *) ) ); 550 SLOT( incidenceAdded( Incidence *) ) );
550#endif 551#endif
551 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
552 553
553 connect( this, SIGNAL( configChanged() ), 554 connect( this, SIGNAL( configChanged() ),
554 mDateNavigator, SLOT( updateConfig() ) ); 555 mDateNavigator, SLOT( updateConfig() ) );
555 556
556 connect( mTodoList, SIGNAL( newTodoSignal() ), 557 connect( mTodoList, SIGNAL( newTodoSignal() ),
557 SLOT( newTodo() ) ); 558 SLOT( newTodo() ) );
558 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
559 SLOT( newSubTodo( Todo * ) ) ); 560 SLOT( newSubTodo( Todo * ) ) );
560 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
561 SLOT( editTodo( Todo * ) ) ); 562 SLOT( editTodo( Todo * ) ) );
562 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 563 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
563 SLOT( showTodo( Todo *) ) ); 564 SLOT( showTodo( Todo *) ) );
564 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 565 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
565 SLOT( deleteTodo( Todo *) ) ); 566 SLOT( deleteTodo( Todo *) ) );
566 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 567 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
567 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 568 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
568 SLOT( purgeCompleted() ) ); 569 SLOT( purgeCompleted() ) );
569 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 570 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
570 SIGNAL( todoModified( Todo *, int ) ) ); 571 SIGNAL( todoModified( Todo *, int ) ) );
571 572
572 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 573 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
573 this, SLOT ( cloneIncidence( Incidence * ) ) ); 574 this, SLOT ( cloneIncidence( Incidence * ) ) );
574 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 575 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
575 this, SLOT (cancelIncidence( Incidence * ) ) ); 576 this, SLOT (cancelIncidence( Incidence * ) ) );
576 577
577 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 578 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
578 this, SLOT ( moveIncidence( Incidence * ) ) ); 579 this, SLOT ( moveIncidence( Incidence * ) ) );
579 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 580 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
580 this, SLOT ( beamIncidence( Incidence * ) ) ); 581 this, SLOT ( beamIncidence( Incidence * ) ) );
581 582
582 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 583 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
583 this, SLOT ( todo_unsub( Todo * ) ) ); 584 this, SLOT ( todo_unsub( Todo * ) ) );
584 585
585 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 586 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
586 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 587 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
587 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 588 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
588 SLOT( updateTodo( Todo *, int ) ) ); 589 SLOT( updateTodo( Todo *, int ) ) );
589 connect( this, SIGNAL( todoModified( Todo *, int )), this, 590 connect( this, SIGNAL( todoModified( Todo *, int )), this,
590 SLOT( changeTodoDisplay( Todo *, int ) ) ); 591 SLOT( changeTodoDisplay( Todo *, int ) ) );
591 592
592 593
593 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 594 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
594 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 595 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
595 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 596 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
596 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 597 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
597 598
598 599
599 600
600 601
601 602
602 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 603 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
603 SLOT(checkClipboard())); 604 SLOT(checkClipboard()));
604 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 605 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
605 SLOT( processTodoListSelection( Incidence * ) ) ); 606 SLOT( processTodoListSelection( Incidence * ) ) );
606 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 607 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
607 608
608 // kdDebug() << "CalendarView::CalendarView() done" << endl; 609 // kdDebug() << "CalendarView::CalendarView() done" << endl;
609 610
610 mDateFrame = new QVBox(0,0,WType_Popup); 611 mDateFrame = new QVBox(0,0,WType_Popup);
611 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 612 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
612 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 613 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
613 mDateFrame->setLineWidth(3); 614 mDateFrame->setLineWidth(3);
614 mDateFrame->hide(); 615 mDateFrame->hide();
615 mDateFrame->setCaption( i18n( "Pick a date to display")); 616 mDateFrame->setCaption( i18n( "Pick a date to display"));
616 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 617 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
617 618
618 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 619 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
619 620
620 mEventEditor = mDialogManager->getEventEditor(); 621 mEventEditor = mDialogManager->getEventEditor();
621 mTodoEditor = mDialogManager->getTodoEditor(); 622 mTodoEditor = mDialogManager->getTodoEditor();
622 623
623 mFlagEditDescription = false; 624 mFlagEditDescription = false;
624 625
625 mSuspendTimer = new QTimer( this ); 626 mSuspendTimer = new QTimer( this );
626 mAlarmTimer = new QTimer( this ); 627 mAlarmTimer = new QTimer( this );
627 mRecheckAlarmTimer = new QTimer( this ); 628 mRecheckAlarmTimer = new QTimer( this );
628 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 629 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
629 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 630 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
630 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 631 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
631 mAlarmDialog = new AlarmDialog( this ); 632 mAlarmDialog = new AlarmDialog( this );
632 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 633 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
633 mAlarmDialog->setServerNotification( false ); 634 mAlarmDialog->setServerNotification( false );
634 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 635 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
635 636
636 637
637#ifndef DESKTOP_VERSION 638#ifndef DESKTOP_VERSION
638//US listen for arriving address resultsets 639//US listen for arriving address resultsets
639 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 640 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
640 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 641 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
641#endif 642#endif
642 mDateNavigator->setCalendar( mCalendar ); 643 mDateNavigator->setCalendar( mCalendar );
643} 644}
644 645
645 646
646CalendarView::~CalendarView() 647CalendarView::~CalendarView()
647{ 648{
648 // kdDebug() << "~CalendarView()" << endl; 649 // kdDebug() << "~CalendarView()" << endl;
649 //qDebug("CalendarView::~CalendarView() "); 650 //qDebug("CalendarView::~CalendarView() ");
650 delete mDialogManager; 651 delete mDialogManager;
651 delete mViewManager; 652 delete mViewManager;
652 delete mStorage; 653 delete mStorage;
653 delete mDateFrame ; 654 delete mDateFrame ;
654 delete mEventViewerDialog; 655 delete mEventViewerDialog;
655 //kdDebug() << "~CalendarView() done" << endl; 656 //kdDebug() << "~CalendarView() done" << endl;
656} 657}
657void CalendarView::nextConflict( bool all, bool allday ) 658void CalendarView::nextConflict( bool all, bool allday )
658{ 659{
659 660
660 QPtrList<Event> testlist = mCalendar->events(); 661 QPtrList<Event> testlist = mCalendar->events();
661 Event * test = testlist.first(); 662 Event * test = testlist.first();
662 while ( test ) { 663 while ( test ) {
663 test->setTagged( false ); 664 test->setTagged( false );
664 test = testlist.next(); 665 test = testlist.next();
665 } 666 }
666 QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0)); 667 QTime st ( 0,0,0);
668 if ( mViewManager->currentView() == mViewManager->agendaView() )
669 st = mViewManager->agendaView()->agenda()->getEndTime();
670 //qDebug("time %s ", st.toString().latin1());
671 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
667 QDateTime conflict; 672 QDateTime conflict;
668 QDateTime retVal; 673 QDateTime retVal;
669 bool found = false; 674 bool found = false;
670 Event * cE = 0; 675 Event * cE = 0;
671 Event * cE2 = 0; 676 Event * cE2 = 0;
672 QPtrList<Event> testlist2 = testlist; 677 QPtrList<Event> testlist2 = testlist;
673 test = testlist.first(); 678 test = testlist.first();
674 bool skip = false; 679 bool skip = false;
675 while ( test ) { 680 while ( test ) {
676 skip = false; 681 skip = false;
677 if ( !all ) skip = ( allday != test->doesFloat() ); 682 if ( !all ) skip = ( allday != test->doesFloat() );
678 if ( !skip ) { 683 if ( !skip ) {
679 Event * test2 = testlist2.first(); 684 Event * test2 = testlist2.first();
680 while ( test2 ) { 685 while ( test2 ) {
681 skip = false; 686 skip = false;
682 if ( !all ) skip = ( allday != test2->doesFloat() ); 687 if ( !all ) skip = ( allday != test2->doesFloat() );
683 if ( !skip ) { 688 if ( !skip ) {
684 if ( !test2->isTagged() ) { 689 if ( !test2->isTagged() ) {
685 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { 690 if ( test->isOverlapping ( test2, &retVal, &startDT ) ) {
686 //qDebug("overlap "); 691 //qDebug("overlap ");
687 if ( ! found ) { 692 if ( ! found ) {
688 if ( retVal >= startDT ) { 693 if ( retVal >= startDT ) {
689 conflict = retVal; 694 conflict = retVal;
690 cE = test; 695 cE = test;
691 cE2 = test2; 696 cE2 = test2;
692 found = true; 697 found = true;
693 } 698 }
694 } else { 699 } else {
695 if ( retVal >= startDT && retVal < conflict ) { 700 if ( retVal >= startDT && retVal < conflict ) {
696 conflict = retVal; 701 conflict = retVal;
697 cE = test; 702 cE = test;
698 cE2 = test2; 703 cE2 = test2;
699 } 704 }
700 } 705 }
701 } 706 }
702 } 707 }
703 } 708 }
704 test2 = testlist2.next(); 709 test2 = testlist2.next();
705 } 710 }
706 } 711 }
707 test->setTagged( true ); 712 test->setTagged( true );
708 test = testlist.next(); 713 test = testlist.next();
709 } 714 }
710 if ( found ) { 715 if ( found ) {
711 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) 716 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
712 mViewManager->showDayView(); 717 mViewManager->showDayView();
713 mNavigator->slotDaySelect( conflict.date() ); 718 mNavigator->slotDaySelect( conflict.date() );
714 int hour = conflict.time().hour(); 719 int hour = conflict.time().hour();
715 mViewManager->agendaView()->setStartHour( hour ); 720 mViewManager->agendaView()->setStartHour( hour );
716 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); 721 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) );
717 return; 722 return;
718 } 723 }
719 724
720 topLevelWidget()->setCaption( i18n("No conflict found") ); 725 topLevelWidget()->setCaption( i18n("No conflict found") );
721 qDebug("No conflict found "); 726 qDebug("No conflict found ");
722 return; 727 return;
723
724
725
726
727
728#if 0
729
730
731 QDate end = start.addDays( 365*2);
732 while ( start < end ) {
733 QPtrList<Event> eventList = calendar()->events( start );
734 Event * ev = eventList.first();
735 QPtrList<Event> test = eventList;
736 while ( ev ) {
737 //qDebug("found %d on %s ", eventList.count(), start.toString().latin1());
738 Event * t_ev = test.first();
739 QDateTime es = ev->dtStart();
740 QDateTime ee = ev->dtEnd();
741 if ( ev->doesFloat() )
742 ee = ee.addDays( 1 );
743 if ( ! all ) {
744 if ( ev->doesFloat() != allday )
745 t_ev = 0;
746 }
747 while ( t_ev ) {
748 bool skip = false;
749 if ( ! all ) {
750 if ( t_ev->doesFloat() != allday )
751 skip = true;
752 }
753 if ( !skip && ev != t_ev ) {
754 QDateTime ets = t_ev->dtStart();
755 QDateTime ete = t_ev->dtEnd();
756 if ( t_ev->doesFloat() )
757 ete = ete.addDays( 1 );
758 //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() );
759 if ( es < ete && ets < ee ) {
760 if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 )
761 mViewManager->showDayView();
762 mNavigator->slotDaySelect( start );
763 int hour = es.time().hour();
764 if ( ets > es )
765 hour = ets.time().hour();
766 mViewManager->agendaView()->setStartHour( hour );
767 topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) );
768 return;
769 }
770 }
771 t_ev = test.next();
772 }
773 ev = eventList.next();
774 }
775 start = start.addDays( 1 );
776 }
777 topLevelWidget()->setCaption( i18n("No conflict found within the next two years") );
778 qDebug("No conflict found ");
779#endif
780} 728}
781 729
782void CalendarView::conflictAll() 730void CalendarView::conflictAll()
783{ 731{
784 nextConflict ( true, true ); 732 nextConflict ( true, true );
785} 733}
786void CalendarView::conflictAllday() 734void CalendarView::conflictAllday()
787{ 735{
788 nextConflict ( false, true ); 736 nextConflict ( false, true );
789} 737}
790void CalendarView::conflictNotAll() 738void CalendarView::conflictNotAll()
791{ 739{
792 nextConflict ( false, false ); 740 nextConflict ( false, false );
793} 741}
794 742
795void CalendarView::setCalReadOnly( int id, bool readO ) 743void CalendarView::setCalReadOnly( int id, bool readO )
796{ 744{
797 if ( readO ) { 745 if ( readO ) {
798 emit save(); 746 emit save();
799 } 747 }
800 mCalendar->setReadOnly( id, readO ); 748 mCalendar->setReadOnly( id, readO );
801} 749}
802void CalendarView::setScrollBarStep(int val ) 750void CalendarView::setScrollBarStep(int val )
803{ 751{
804#ifdef DESKTOP_VERSION 752#ifdef DESKTOP_VERSION
805 mDateScrollBar->setLineStep ( val ); 753 mDateScrollBar->setLineStep ( val );
806#endif 754#endif
807} 755}
808void CalendarView::scrollBarValue(int val ) 756void CalendarView::scrollBarValue(int val )
809{ 757{
810#ifdef DESKTOP_VERSION 758#ifdef DESKTOP_VERSION
811 if ( QApplication::desktop()->width() < 800 ) return; 759 if ( QApplication::desktop()->width() < 800 ) return;
812 static bool block = false; 760 static bool block = false;
813 if ( block ) return; 761 if ( block ) return;
814 block = true; 762 block = true;
815 int count = mNavigator->selectedDates().count(); 763 int count = mNavigator->selectedDates().count();
816 int day = mNavigator->selectedDates().first().dayOfYear(); 764 int day = mNavigator->selectedDates().first().dayOfYear();
817 int stepdays = val; 765 int stepdays = val;
818 if ( mDateScrollBar->lineStep () <= count ) { 766 if ( mDateScrollBar->lineStep () <= count ) {
819 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 767 //val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
820 //qDebug("VAL %d ",val ); 768 //qDebug("VAL %d ",val );
821 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 769 stepdays = (val-day)/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
822 stepdays = day+stepdays; 770 stepdays = day+stepdays;
823 if ( stepdays < 0 ) stepdays = 0; 771 if ( stepdays < 0 ) stepdays = 0;
824 } 772 }
825 if ( stepdays == day ) { 773 if ( stepdays == day ) {
826 block = false; 774 block = false;
827 return; 775 return;
828 } 776 }
829 int year = mNavigator->selectedDates().first().year(); 777 int year = mNavigator->selectedDates().first().year();
830 QDate d ( year,1,1 ); 778 QDate d ( year,1,1 );
831 mNavigator->selectDates( d.addDays( stepdays-1) , count ); 779 mNavigator->selectDates( d.addDays( stepdays-1) , count );
832 block = false; 780 block = false;
833#endif 781#endif
834 782
835} 783}
836void CalendarView::updateView(const QDate &start, const QDate &end) 784void CalendarView::updateView(const QDate &start, const QDate &end)
837{ 785{
838#ifdef DESKTOP_VERSION 786#ifdef DESKTOP_VERSION
839 if ( ! mDateScrollBar->draggingSlider () ) { 787 if ( ! mDateScrollBar->draggingSlider () ) {
840 int dof = start.dayOfYear(); 788 int dof = start.dayOfYear();
841 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 789 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
842 if ( dof != mDateScrollBar->value() ) { 790 if ( dof != mDateScrollBar->value() ) {
843 mDateScrollBar->blockSignals( true ); 791 mDateScrollBar->blockSignals( true );
844 mDateScrollBar->setValue( start.dayOfYear()); 792 mDateScrollBar->setValue( start.dayOfYear());
845 mDateScrollBar->blockSignals( false ); 793 mDateScrollBar->blockSignals( false );
846 } 794 }
847 } 795 }
848#endif 796#endif
849 mTodoList->updateView(); 797 mTodoList->updateView();
850 mViewManager->updateView(start, end); 798 mViewManager->updateView(start, end);
851 //mDateNavigator->updateView(); 799 //mDateNavigator->updateView();
852} 800}
853 801
854 802
855 803
856void CalendarView::checkFiles() 804void CalendarView::checkFiles()
857{ 805{
858 QString message; 806 QString message;
859 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 807 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
860 KopiCalendarFile * cal = calendars.first(); 808 KopiCalendarFile * cal = calendars.first();
861 while ( cal ) { 809 while ( cal ) {
862 if ( cal->mErrorOnLoad ) { 810 if ( cal->mErrorOnLoad ) {
863 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 811 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
864 } 812 }
865 cal = calendars.next(); 813 cal = calendars.next();
866 } 814 }
867 if ( !message.isEmpty() ) { 815 if ( !message.isEmpty() ) {
868 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); 816 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0);
869 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed")); 817 KMessageBox::error(this,message, i18n("Loding of calendar(s) failed"));
870 } 818 }
871 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 819 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
872} 820}
873void CalendarView::checkAlarms() 821void CalendarView::checkAlarms()
874{ 822{
875 823
876 824
877 KConfig *config = KOGlobals::config(); 825 KConfig *config = KOGlobals::config();
878 config->setGroup( "AppRun" ); 826 config->setGroup( "AppRun" );
879 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 827 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
880 int daysto = dt.daysTo( QDate::currentDate() ); 828 int daysto = dt.daysTo( QDate::currentDate() );
881 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 829 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
882 dt = dt.addDays( days ); 830 dt = dt.addDays( days );
883 int secto = dt.secsTo( QDateTime::currentDateTime() ); 831 int secto = dt.secsTo( QDateTime::currentDateTime() );
884 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 832 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
885 //qDebug("KO: Reading program stop %d ", secs); 833 //qDebug("KO: Reading program stop %d ", secs);
886 //secs -= ( 3600 * 24*3 ); // debug only 834 //secs -= ( 3600 * 24*3 ); // debug only
887 QDateTime latest = dt.addSecs ( secs ); 835 QDateTime latest = dt.addSecs ( secs );
888 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 836 qDebug("KO: Last termination on %s ", latest.toString().latin1());
889 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 837 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
890 QPtrList<Incidence> el = mCalendar->rawIncidences(); 838 QPtrList<Incidence> el = mCalendar->rawIncidences();
891 QPtrList<Incidence> al; 839 QPtrList<Incidence> al;
892 Incidence* inL = el.first(); 840 Incidence* inL = el.first();
893 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 841 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
894 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 842 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
895 while ( inL ) { 843 while ( inL ) {
896 bool ok = false; 844 bool ok = false;
897 int offset = 0; 845 int offset = 0;
898 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 846 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
899 if ( ok ) { 847 if ( ok ) {
900 //qDebug("OK %s",next.toString().latin1()); 848 //qDebug("OK %s",next.toString().latin1());
901 if ( next < cur ) { 849 if ( next < cur ) {
902 al.append( inL ); 850 al.append( inL );
903 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 851 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
904 } 852 }
905 } 853 }
906 inL = el.next(); 854 inL = el.next();
907 } 855 }
908 if ( al.count() ) { 856 if ( al.count() ) {
909 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 857 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
910 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 858 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
911 QVBoxLayout* lay = new QVBoxLayout( dia ); 859 QVBoxLayout* lay = new QVBoxLayout( dia );
912 lay->setSpacing( 0 ); 860 lay->setSpacing( 0 );
913 lay->setMargin( 0 ); 861 lay->setMargin( 0 );
914 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 862 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
915 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 863 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
916 lay->addWidget( matb ); 864 lay->addWidget( matb );
917 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 865 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
918 int wid = 210; 866 int wid = 210;
919 int x = QApplication::desktop()->width() - wid - 7; 867 int x = QApplication::desktop()->width() - wid - 7;
920 int y = QApplication::desktop()->height() - wid - 70; 868 int y = QApplication::desktop()->height() - wid - 70;
921 dia->setGeometry ( x,y,wid,wid); 869 dia->setGeometry ( x,y,wid,wid);
922 } else { 870 } else {
923 int si = 220; 871 int si = 220;
924 if ( QApplication::desktop()->width() > 470 ) 872 if ( QApplication::desktop()->width() > 470 )
925 si = 400; 873 si = 400;
926 dia->resize(si,si/2); 874 dia->resize(si,si/2);
927 } 875 }
928 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 876 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
929 dia->show(); 877 dia->show();
930 878
931 } 879 }
932} 880}
933void CalendarView::showDay( QDate d ) 881void CalendarView::showDay( QDate d )
934{ 882{
935 dateNavigator()->blockSignals( true ); 883 dateNavigator()->blockSignals( true );
936 dateNavigator()->selectDate( d ); 884 dateNavigator()->selectDate( d );
937 dateNavigator()->blockSignals( false ); 885 dateNavigator()->blockSignals( false );
938 mViewManager->showDayView(); 886 mViewManager->showDayView();
939 //dateNavigator()->selectDate( d ); 887 //dateNavigator()->selectDate( d );
940} 888}
941void CalendarView::timerAlarm() 889void CalendarView::timerAlarm()
942{ 890{
943 //qDebug("CalendarView::timerAlarm() "); 891 //qDebug("CalendarView::timerAlarm() ");
944 computeAlarm(mAlarmNotification ); 892 computeAlarm(mAlarmNotification );
945} 893}
946 894
947void CalendarView::suspendAlarm() 895void CalendarView::suspendAlarm()
948{ 896{
949 //qDebug(" CalendarView::suspendAlarm() "); 897 //qDebug(" CalendarView::suspendAlarm() ");
950 computeAlarm(mSuspendAlarmNotification ); 898 computeAlarm(mSuspendAlarmNotification );
951 899
952} 900}
953 901
954void CalendarView::startAlarm( QString mess , QString filename) 902void CalendarView::startAlarm( QString mess , QString filename)
955{ 903{
956 904
957 topLevelWidget()->showNormal(); 905 topLevelWidget()->showNormal();
958 topLevelWidget()->setActiveWindow(); 906 topLevelWidget()->setActiveWindow();
959 topLevelWidget()->raise(); 907 topLevelWidget()->raise();
960 908
961 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 909 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
962 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) ); 910 QTimer::singleShot( 2000, this, SLOT( checkNextTimerAlarm() ) );
963 911
964} 912}
965 913
966void CalendarView::checkNextTimerAlarm() 914void CalendarView::checkNextTimerAlarm()
967{ 915{
968 mCalendar->checkAlarmForIncidence( 0, true ); 916 mCalendar->checkAlarmForIncidence( 0, true );
969} 917}
970 918
971void CalendarView::computeAlarm( QString msg ) 919void CalendarView::computeAlarm( QString msg )
972{ 920{
973 921
974 QString mess = msg; 922 QString mess = msg;
975 QString mAlarmMessage = mess.mid( 9 ); 923 QString mAlarmMessage = mess.mid( 9 );
976 QString filename = MainWindow::resourcePath(); 924 QString filename = MainWindow::resourcePath();
977 filename += "koalarm.wav"; 925 filename += "koalarm.wav";
978 QString tempfilename; 926 QString tempfilename;
979 if ( mess.left( 13 ) == "suspend_alarm") { 927 if ( mess.left( 13 ) == "suspend_alarm") {
980 bool error = false; 928 bool error = false;
981 int len = mess.mid( 13 ).find("+++"); 929 int len = mess.mid( 13 ).find("+++");
982 if ( len < 2 ) 930 if ( len < 2 )
983 error = true; 931 error = true;
984 else { 932 else {
985 tempfilename = mess.mid( 13, len ); 933 tempfilename = mess.mid( 13, len );
986 if ( !QFile::exists( tempfilename ) ) 934 if ( !QFile::exists( tempfilename ) )
987 error = true; 935 error = true;
988 } 936 }
989 if ( ! error ) { 937 if ( ! error ) {
990 filename = tempfilename; 938 filename = tempfilename;
991 } 939 }
992 mAlarmMessage = mess.mid( 13+len+3 ); 940 mAlarmMessage = mess.mid( 13+len+3 );
993 //qDebug("suspend file %s ",tempfilename.latin1() ); 941 //qDebug("suspend file %s ",tempfilename.latin1() );
994 startAlarm( mAlarmMessage, filename); 942 startAlarm( mAlarmMessage, filename);
995 return; 943 return;
996 } 944 }
997 if ( mess.left( 11 ) == "timer_alarm") { 945 if ( mess.left( 11 ) == "timer_alarm") {
998 //mTimerTime = 0; 946 //mTimerTime = 0;
999 startAlarm( mess.mid( 11 ), filename ); 947 startAlarm( mess.mid( 11 ), filename );
1000 return; 948 return;
1001 } 949 }
1002 if ( mess.left( 10 ) == "proc_alarm") { 950 if ( mess.left( 10 ) == "proc_alarm") {
1003 bool error = false; 951 bool error = false;
1004 int len = mess.mid( 10 ).find("+++"); 952 int len = mess.mid( 10 ).find("+++");
1005 if ( len < 2 ) 953 if ( len < 2 )
1006 error = true; 954 error = true;
1007 else { 955 else {
1008 tempfilename = mess.mid( 10, len ); 956 tempfilename = mess.mid( 10, len );
1009 if ( !QFile::exists( tempfilename ) ) 957 if ( !QFile::exists( tempfilename ) )
1010 error = true; 958 error = true;
1011 } 959 }
1012 if ( error ) { 960 if ( error ) {
1013 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 961 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
1014 mAlarmMessage += mess.mid( 10+len+3+9 ); 962 mAlarmMessage += mess.mid( 10+len+3+9 );
1015 } else { 963 } else {
1016 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 964 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
1017 //qDebug("-----system command %s ",tempfilename.latin1() ); 965 //qDebug("-----system command %s ",tempfilename.latin1() );
1018#ifndef _WIN32_ 966#ifndef _WIN32_
1019 if ( vfork () == 0 ) { 967 if ( vfork () == 0 ) {
1020 execl ( tempfilename.latin1(), 0 ); 968 execl ( tempfilename.latin1(), 0 );
1021 return; 969 return;
1022 } 970 }
1023#else 971#else
1024 QProcess* p = new QProcess(); 972 QProcess* p = new QProcess();
1025 p->addArgument( tempfilename.latin1() ); 973 p->addArgument( tempfilename.latin1() );
1026 p->start(); 974 p->start();
1027 return; 975 return;
1028#endif 976#endif
1029 977
1030 return; 978 return;
1031 } 979 }
1032 980
1033 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 981 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1034 } 982 }
1035 if ( mess.left( 11 ) == "audio_alarm") { 983 if ( mess.left( 11 ) == "audio_alarm") {
1036 bool error = false; 984 bool error = false;
1037 int len = mess.mid( 11 ).find("+++"); 985 int len = mess.mid( 11 ).find("+++");
1038 if ( len < 2 ) 986 if ( len < 2 )
1039 error = true; 987 error = true;
1040 else { 988 else {
1041 tempfilename = mess.mid( 11, len ); 989 tempfilename = mess.mid( 11, len );
1042 if ( !QFile::exists( tempfilename ) ) 990 if ( !QFile::exists( tempfilename ) )
1043 error = true; 991 error = true;
1044 } 992 }
1045 if ( ! error ) { 993 if ( ! error ) {
1046 filename = tempfilename; 994 filename = tempfilename;
1047 } 995 }
1048 mAlarmMessage = mess.mid( 11+len+3+9 ); 996 mAlarmMessage = mess.mid( 11+len+3+9 );
1049 //qDebug("audio file command %s ",tempfilename.latin1() ); 997 //qDebug("audio file command %s ",tempfilename.latin1() );
1050 } 998 }
1051 if ( mess.left( 9 ) == "cal_alarm") { 999 if ( mess.left( 9 ) == "cal_alarm") {
1052 mAlarmMessage = mess.mid( 9 ) ; 1000 mAlarmMessage = mess.mid( 9 ) ;
1053 } 1001 }
1054 1002
1055 startAlarm( mAlarmMessage, filename ); 1003 startAlarm( mAlarmMessage, filename );
1056 1004
1057 1005
1058} 1006}
1059 1007
1060void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1008void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1061{ 1009{
1062 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1010 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1063 1011
1064 mSuspendAlarmNotification = noti; 1012 mSuspendAlarmNotification = noti;
1065 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1013 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1066 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1014 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1067 mSuspendTimer->start( ms , true ); 1015 mSuspendTimer->start( ms , true );
1068 1016
1069} 1017}
1070 1018
1071void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1019void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1072{ 1020{
1073 mNextAlarmDateTime = qdt; 1021 mNextAlarmDateTime = qdt;
1074 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1022 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1075 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1023 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1076#ifndef DESKTOP_VERSION 1024#ifndef DESKTOP_VERSION
1077 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1025 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1078#endif 1026#endif
1079 return; 1027 return;
1080 } 1028 }
1081 int maxSec; 1029 int maxSec;
1082 //maxSec = 5; //testing only 1030 //maxSec = 5; //testing only
1083 maxSec = 86400+3600; // one day+1hour 1031 maxSec = 86400+3600; // one day+1hour
1084 mAlarmNotification = noti; 1032 mAlarmNotification = noti;
1085 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1033 int sec = QDateTime::currentDateTime().secsTo( qdt );
1086 if ( sec > maxSec ) { 1034 if ( sec > maxSec ) {
1087 mRecheckAlarmTimer->start( maxSec * 1000 ); 1035 mRecheckAlarmTimer->start( maxSec * 1000 );
1088 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1036 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1089 return; 1037 return;
1090 } else { 1038 } else {
1091 mRecheckAlarmTimer->stop(); 1039 mRecheckAlarmTimer->stop();
1092 } 1040 }
1093 //qDebug("Alarm timer started with secs: %d ", sec); 1041 //qDebug("Alarm timer started with secs: %d ", sec);
1094 mAlarmTimer->start( sec *1000 , true ); 1042 mAlarmTimer->start( sec *1000 , true );
1095 1043
1096} 1044}
1097// called by mRecheckAlarmTimer to get next alarm 1045// called by mRecheckAlarmTimer to get next alarm
1098// we need this, because a QTimer has only a max range of 25 days 1046// we need this, because a QTimer has only a max range of 25 days
1099void CalendarView::recheckTimerAlarm() 1047void CalendarView::recheckTimerAlarm()
1100{ 1048{
1101 mAlarmTimer->stop(); 1049 mAlarmTimer->stop();
1102 mRecheckAlarmTimer->stop(); 1050 mRecheckAlarmTimer->stop();
1103 mCalendar->checkAlarmForIncidence( 0, true ); 1051 mCalendar->checkAlarmForIncidence( 0, true );
1104} 1052}
1105#ifndef DESKTOP_VERSION 1053#ifndef DESKTOP_VERSION
1106void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 1054void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
1107#else 1055#else
1108void CalendarView::removeAlarm(const QDateTime &, const QString & ) 1056void CalendarView::removeAlarm(const QDateTime &, const QString & )
1109#endif 1057#endif
1110{ 1058{
1111 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1059 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1112 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1060 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1113#ifndef DESKTOP_VERSION 1061#ifndef DESKTOP_VERSION
1114 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() ); 1062 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.utf8() );
1115#endif 1063#endif
1116 return; 1064 return;
1117 } 1065 }
1118 mAlarmTimer->stop(); 1066 mAlarmTimer->stop();
1119} 1067}
1120void CalendarView::selectWeekNum ( int num ) 1068void CalendarView::selectWeekNum ( int num )
1121{ 1069{
1122 dateNavigator()->blockSignals( true ); 1070 dateNavigator()->blockSignals( true );
1123 dateNavigator()->selectWeek( num ); 1071 dateNavigator()->selectWeek( num );
1124 dateNavigator()->blockSignals( false ); 1072 dateNavigator()->blockSignals( false );
1125 mViewManager->showWeekView(); 1073 mViewManager->showWeekView();
1126} 1074}
1127KOViewManager *CalendarView::viewManager() 1075KOViewManager *CalendarView::viewManager()
1128{ 1076{
1129 return mViewManager; 1077 return mViewManager;
1130} 1078}
1131 1079
1132KODialogManager *CalendarView::dialogManager() 1080KODialogManager *CalendarView::dialogManager()
1133{ 1081{
1134 return mDialogManager; 1082 return mDialogManager;
1135} 1083}
1136 1084
1137QDate CalendarView::startDate() 1085QDate CalendarView::startDate()
1138{ 1086{
1139 DateList dates = mNavigator->selectedDates(); 1087 DateList dates = mNavigator->selectedDates();
1140 1088
1141 return dates.first(); 1089 return dates.first();
1142} 1090}
1143 1091
1144QDate CalendarView::endDate() 1092QDate CalendarView::endDate()
1145{ 1093{
1146 DateList dates = mNavigator->selectedDates(); 1094 DateList dates = mNavigator->selectedDates();
1147 1095
1148 return dates.last(); 1096 return dates.last();
1149} 1097}
1150 1098
1151 1099
1152void CalendarView::createPrinter() 1100void CalendarView::createPrinter()
1153{ 1101{
1154#ifndef KORG_NOPRINTER 1102#ifndef KORG_NOPRINTER
1155 if (!mCalPrinter) { 1103 if (!mCalPrinter) {
1156 mCalPrinter = new CalPrinter(this, mCalendar); 1104 mCalPrinter = new CalPrinter(this, mCalendar);
1157 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 1105 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
1158 } 1106 }
1159#endif 1107#endif
1160} 1108}
1161 1109
1162 1110
1163//KOPrefs::instance()->mWriteBackFile 1111//KOPrefs::instance()->mWriteBackFile
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index b290020..779f12e 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1252,768 +1252,772 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1252 } 1252 }
1253 } 1253 }
1254 } 1254 }
1255 } else { 1255 } else {
1256 placeItem->setSubCell(0); 1256 placeItem->setSubCell(0);
1257 placeItem->setSubCells(1); 1257 placeItem->setSubCells(1);
1258 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1258 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1259 else placeItem->resize(mGridSpacingX,placeItem->height()); 1259 else placeItem->resize(mGridSpacingX,placeItem->height());
1260 int x,y; 1260 int x,y;
1261 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1261 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1262 moveChild(placeItem,x,y); 1262 moveChild(placeItem,x,y);
1263 } 1263 }
1264 placeItem->setConflictItems(conflictItems); 1264 placeItem->setConflictItems(conflictItems);
1265 // for ( item=conflictItems.first(); item != 0; 1265 // for ( item=conflictItems.first(); item != 0;
1266// item=conflictItems.next() ) { 1266// item=conflictItems.next() ) {
1267// //item->updateItem(); 1267// //item->updateItem();
1268// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1268// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1269// } 1269// }
1270// placeItem->updateItem(); 1270// placeItem->updateItem();
1271} 1271}
1272 1272
1273void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1273void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1274{ 1274{
1275 if ( globalFlagBlockAgenda ) 1275 if ( globalFlagBlockAgenda )
1276 return; 1276 return;
1277 1277
1278 if ( mInvalidPixmap ) { 1278 if ( mInvalidPixmap ) {
1279 mInvalidPixmap = false; 1279 mInvalidPixmap = false;
1280 qDebug("KO: Upsizing Pixmaps "); 1280 qDebug("KO: Upsizing Pixmaps ");
1281 computeSizes(); 1281 computeSizes();
1282 emit updateViewSignal(); 1282 emit updateViewSignal();
1283 return; 1283 return;
1284 } 1284 }
1285 if ( ! mAllDayMode ) { 1285 if ( ! mAllDayMode ) {
1286 // currently not working for 1286 // currently not working for
1287 1287
1288 //qDebug("KOAgenda::drawContents "); 1288 //qDebug("KOAgenda::drawContents ");
1289#if 0 1289#if 0
1290 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1290 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1291 qDebug("WAU "); 1291 qDebug("WAU ");
1292 drawContentsToPainter(); 1292 drawContentsToPainter();
1293 } 1293 }
1294#endif 1294#endif
1295 QPaintDevice* pd = p->device(); 1295 QPaintDevice* pd = p->device();
1296 p->end(); 1296 p->end();
1297 int vx, vy; 1297 int vx, vy;
1298 int selectionX = KOGlobals::self()->reverseLayout() ? 1298 int selectionX = KOGlobals::self()->reverseLayout() ?
1299 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1299 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1300 mSelectionCellX * mGridSpacingX; 1300 mSelectionCellX * mGridSpacingX;
1301 contentsToViewport ( cx, cy, vx,vy); 1301 contentsToViewport ( cx, cy, vx,vy);
1302 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1302 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1303 1303
1304 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1304 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1305 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1305 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1306 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1306 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1307 1307
1308 int vxSel, vySel; 1308 int vxSel, vySel;
1309 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1309 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1310 int off = mSelectionHeight; 1310 int off = mSelectionHeight;
1311 if ( vySel < 0 ) 1311 if ( vySel < 0 )
1312 off += vySel; 1312 off += vySel;
1313 //qDebug("OFF %d %d %d", off,vySel, vy ); 1313 //qDebug("OFF %d %d %d", off,vySel, vy );
1314 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1314 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1315 } else { 1315 } else {
1316 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1316 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1317 } 1317 }
1318 } 1318 }
1319 if ( mSelectionHeight > 0 ) { 1319 if ( mSelectionHeight > 0 ) {
1320 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1320 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1321 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1321 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1322 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1322 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1323 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1323 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1324 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1324 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1325 int hei = mSelectionHeight; 1325 int hei = mSelectionHeight;
1326 int offset = 0; 1326 int offset = 0;
1327 while ( hei > 0 ) { 1327 while ( hei > 0 ) {
1328 int p_hei = 5; 1328 int p_hei = 5;
1329 if ( hei < 5 ) p_hei = hei; 1329 if ( hei < 5 ) p_hei = hei;
1330 hei -= 5; 1330 hei -= 5;
1331 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1331 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1332 offset += 5; 1332 offset += 5;
1333 } 1333 }
1334 } 1334 }
1335 } 1335 }
1336 p->begin( pd ); 1336 p->begin( pd );
1337 } else { 1337 } else {
1338#if 0 1338#if 0
1339 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() ); 1339 qDebug("mCurPixWid %d %d ",mCurPixWid, contentsWidth() );
1340 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) { 1340 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) {
1341 qDebug("WAUWAU "); 1341 qDebug("WAUWAU ");
1342 drawContentsToPainter(); 1342 drawContentsToPainter();
1343 } 1343 }
1344#endif 1344#endif
1345 QPaintDevice* pd = p->device(); 1345 QPaintDevice* pd = p->device();
1346 p->end(); 1346 p->end();
1347 int vx, vy; 1347 int vx, vy;
1348 int selectionX = KOGlobals::self()->reverseLayout() ? 1348 int selectionX = KOGlobals::self()->reverseLayout() ?
1349 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1349 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1350 mSelectionCellX * mGridSpacingX; 1350 mSelectionCellX * mGridSpacingX;
1351 contentsToViewport ( cx, cy, vx,vy); 1351 contentsToViewport ( cx, cy, vx,vy);
1352 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ; 1352 // qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
1353 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) 1353 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
1354 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1354 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1355 1355
1356 if ( mSelectionHeight > 0 ) { 1356 if ( mSelectionHeight > 0 ) {
1357 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1357 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1358 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1358 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1359 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1359 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1360 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1360 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1361 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1361 //bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1362 int hei = mSelectionHeight; 1362 int hei = mSelectionHeight;
1363 int offset = 0; 1363 int offset = 0;
1364 while ( hei > 0 ) { 1364 while ( hei > 0 ) {
1365 int p_hei = 5; 1365 int p_hei = 5;
1366 if ( hei < 5 ) p_hei = hei; 1366 if ( hei < 5 ) p_hei = hei;
1367 hei -= 5; 1367 hei -= 5;
1368 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1368 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1369 offset += 5; 1369 offset += 5;
1370 } 1370 }
1371 } 1371 }
1372 } 1372 }
1373 p->begin( pd ); 1373 p->begin( pd );
1374 } 1374 }
1375 1375
1376} 1376}
1377 1377
1378void KOAgenda::finishUpdate() 1378void KOAgenda::finishUpdate()
1379{ 1379{
1380 1380
1381 KOAgendaItem *item; 1381 KOAgendaItem *item;
1382 globalFlagBlockAgendaItemPaint = 1; 1382 globalFlagBlockAgendaItemPaint = 1;
1383 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 1383 // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems
1384 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1384 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1385 if ( !item->checkLayout() ) { 1385 if ( !item->checkLayout() ) {
1386 //qDebug(" conflictitem found "); 1386 //qDebug(" conflictitem found ");
1387 int newSubCellWidth; 1387 int newSubCellWidth;
1388 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); 1388 if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
1389 else newSubCellWidth = mGridSpacingX / item->subCells(); 1389 else newSubCellWidth = mGridSpacingX / item->subCells();
1390 1390
1391 if (mAllDayMode) { 1391 if (mAllDayMode) {
1392 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); 1392 item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth);
1393 } else { 1393 } else {
1394 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); 1394 item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY);
1395 } 1395 }
1396 int x,y; 1396 int x,y;
1397 gridToContents(item->cellX(),item->cellYTop(),x,y); 1397 gridToContents(item->cellX(),item->cellYTop(),x,y);
1398 if (mAllDayMode) { 1398 if (mAllDayMode) {
1399 y += item->subCell() * newSubCellWidth; 1399 y += item->subCell() * newSubCellWidth;
1400 } else { 1400 } else {
1401 x += item->subCell() * newSubCellWidth; 1401 x += item->subCell() * newSubCellWidth;
1402 } 1402 }
1403 moveChild(item,x,y); 1403 moveChild(item,x,y);
1404 } 1404 }
1405 } 1405 }
1406 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1406 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1407 if ( !item->isVisible() ) 1407 if ( !item->isVisible() )
1408 item->show(); 1408 item->show();
1409 1409
1410 } 1410 }
1411 globalFlagBlockAgendaItemUpdate = 0; 1411 globalFlagBlockAgendaItemUpdate = 0;
1412 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1412 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1413 item->repaintMe( ); 1413 item->repaintMe( );
1414 } 1414 }
1415 globalFlagBlockAgendaItemUpdate = 1; 1415 globalFlagBlockAgendaItemUpdate = 1;
1416 qApp->processEvents(); 1416 qApp->processEvents();
1417 globalFlagBlockAgendaItemPaint = 0; 1417 globalFlagBlockAgendaItemPaint = 0;
1418 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1418 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1419 item->repaint( false ); 1419 item->repaint( false );
1420 } 1420 }
1421 marcus_bains(); 1421 marcus_bains();
1422} 1422}
1423 1423
1424/* 1424/*
1425 Draw grid in the background of the agenda. 1425 Draw grid in the background of the agenda.
1426*/ 1426*/
1427void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch) 1427void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
1428{ 1428{
1429 1429
1430 1430
1431 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask ) 1431 if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
1432 return; 1432 return;
1433 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 ) 1433 if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
1434 return; 1434 return;
1435 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight(); 1435 int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
1436 if ( ch < 1 ) 1436 if ( ch < 1 )
1437 ch = 1; 1437 ch = 1;
1438 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) { 1438 if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
1439 mPaintPixmap.resize( contentsWidth()+42, ch ); 1439 mPaintPixmap.resize( contentsWidth()+42, ch );
1440 } 1440 }
1441 mCurPixWid = contentsWidth(); 1441 mCurPixWid = contentsWidth();
1442 mCurPixHei = ch; 1442 mCurPixHei = ch;
1443 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) { 1443 if ( mHighlightPixmap.width() < mGridSpacingX-1 ) {
1444 mHighlightPixmap.resize( mGridSpacingX-1, 5 ); 1444 mHighlightPixmap.resize( mGridSpacingX-1, 5 );
1445 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor ); 1445 mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
1446 } 1446 }
1447 mPixPainter.begin( &mPaintPixmap) ; 1447 mPixPainter.begin( &mPaintPixmap) ;
1448 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() ); 1448 //qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
1449 QPainter * p ; 1449 QPainter * p ;
1450 if (paint == 0) { 1450 if (paint == 0) {
1451 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor); 1451 mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
1452 p = &mPixPainter; 1452 p = &mPixPainter;
1453 } 1453 }
1454 else 1454 else
1455 p = paint ; 1455 p = paint ;
1456 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch); 1456 // qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
1457 1457
1458 //--cx;++cw; 1458 //--cx;++cw;
1459 int lGridSpacingY = mGridSpacingY*2; 1459 int lGridSpacingY = mGridSpacingY*2;
1460 int selDay; 1460 int selDay;
1461 QDate curDate = QDate::currentDate(); 1461 QDate curDate = QDate::currentDate();
1462 if ( !backgroundOnly ) { 1462 if ( !backgroundOnly ) {
1463 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay) 1463 for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
1464 { 1464 {
1465 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) { 1465 if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) {
1466 int x1 = cx; 1466 int x1 = cx;
1467 int y1 = 0; 1467 int y1 = 0;
1468 if (y1 < cy) y1 = cy; 1468 if (y1 < cy) y1 = cy;
1469 int x2 = cx+cw-1; 1469 int x2 = cx+cw-1;
1470 int y2 = contentsHeight(); 1470 int y2 = contentsHeight();
1471 if (y2 > cy+ch-1) y2=cy+ch-1; 1471 if (y2 > cy+ch-1) y2=cy+ch-1;
1472 if (x2 >= x1 && y2 >= y1) { 1472 if (x2 >= x1 && y2 >= y1) {
1473 int gxStart = selDay; 1473 int gxStart = selDay;
1474 int gxEnd = gxStart ; 1474 int gxEnd = gxStart ;
1475 int xStart = KOGlobals::self()->reverseLayout() ? 1475 int xStart = KOGlobals::self()->reverseLayout() ?
1476 (mColumns - 1 - gxStart)*mGridSpacingX : 1476 (mColumns - 1 - gxStart)*mGridSpacingX :
1477 gxStart*mGridSpacingX; 1477 gxStart*mGridSpacingX;
1478 if (xStart < x1) xStart = x1; 1478 if (xStart < x1) xStart = x1;
1479 int xEnd = KOGlobals::self()->reverseLayout() ? 1479 int xEnd = KOGlobals::self()->reverseLayout() ?
1480 (mColumns - gxStart)*mGridSpacingX-1 : 1480 (mColumns - gxStart)*mGridSpacingX-1 :
1481 (gxStart+1)*mGridSpacingX-1; 1481 (gxStart+1)*mGridSpacingX-1;
1482 if (xEnd > x2) xEnd = x2; 1482 if (xEnd > x2) xEnd = x2;
1483 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1483 if ( KOPrefs::instance()->mUseHighlightLightColor )
1484 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1484 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1485 KOPrefs::instance()->mAgendaBgColor.light()); 1485 KOPrefs::instance()->mAgendaBgColor.light());
1486 else 1486 else
1487 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1487 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1488 KOPrefs::instance()->mAgendaBgColor.dark()); 1488 KOPrefs::instance()->mAgendaBgColor.dark());
1489 1489
1490 } 1490 }
1491 } 1491 }
1492 } 1492 }
1493 } 1493 }
1494 // Highlight working hours 1494 // Highlight working hours
1495 1495
1496 if ( !backgroundOnly ) 1496 if ( !backgroundOnly )
1497 if (mWorkingHoursEnable) { 1497 if (mWorkingHoursEnable) {
1498 int x1 = cx; 1498 int x1 = cx;
1499 int y1 = mWorkingHoursYTop; 1499 int y1 = mWorkingHoursYTop;
1500 if (y1 < cy) y1 = cy; 1500 if (y1 < cy) y1 = cy;
1501 int x2 = cx+cw-1; 1501 int x2 = cx+cw-1;
1502 // int x2 = mGridSpacingX * 5 - 1; 1502 // int x2 = mGridSpacingX * 5 - 1;
1503 // if (x2 > cx+cw-1) x2 = cx + cw - 1; 1503 // if (x2 > cx+cw-1) x2 = cx + cw - 1;
1504 int y2 = mWorkingHoursYBottom; 1504 int y2 = mWorkingHoursYBottom;
1505 if (y2 > cy+ch-1) y2=cy+ch-1; 1505 if (y2 > cy+ch-1) y2=cy+ch-1;
1506 1506
1507 if (x2 >= x1 && y2 >= y1) { 1507 if (x2 >= x1 && y2 >= y1) {
1508 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX ); 1508 // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
1509 int gxStart = x1/mGridSpacingX; 1509 int gxStart = x1/mGridSpacingX;
1510 int gxEnd = x2/mGridSpacingX; 1510 int gxEnd = x2/mGridSpacingX;
1511 while(gxStart <= gxEnd) { 1511 while(gxStart <= gxEnd) {
1512 if (gxStart < int(mHolidayMask->count()) && 1512 if (gxStart < int(mHolidayMask->count()) &&
1513 !mHolidayMask->at(gxStart)) { 1513 !mHolidayMask->at(gxStart)) {
1514 int xStart = KOGlobals::self()->reverseLayout() ? 1514 int xStart = KOGlobals::self()->reverseLayout() ?
1515 (mColumns - 1 - gxStart)*mGridSpacingX : 1515 (mColumns - 1 - gxStart)*mGridSpacingX :
1516 gxStart*mGridSpacingX; 1516 gxStart*mGridSpacingX;
1517 if (xStart < x1) xStart = x1; 1517 if (xStart < x1) xStart = x1;
1518 int xEnd = KOGlobals::self()->reverseLayout() ? 1518 int xEnd = KOGlobals::self()->reverseLayout() ?
1519 (mColumns - gxStart)*mGridSpacingX-1 : 1519 (mColumns - gxStart)*mGridSpacingX-1 :
1520 (gxStart+1)*mGridSpacingX-1; 1520 (gxStart+1)*mGridSpacingX-1;
1521 if (xEnd > x2) xEnd = x2; 1521 if (xEnd > x2) xEnd = x2;
1522 if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) { 1522 if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) {
1523 if ( KOPrefs::instance()->mUseHighlightLightColor ) 1523 if ( KOPrefs::instance()->mUseHighlightLightColor )
1524 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1524 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1525 KOPrefs::instance()->mWorkingHoursColor.light()); 1525 KOPrefs::instance()->mWorkingHoursColor.light());
1526 else 1526 else
1527 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1527 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1528 KOPrefs::instance()->mWorkingHoursColor.dark()); 1528 KOPrefs::instance()->mWorkingHoursColor.dark());
1529 } else { 1529 } else {
1530 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1, 1530 p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
1531 KOPrefs::instance()->mWorkingHoursColor); 1531 KOPrefs::instance()->mWorkingHoursColor);
1532 } 1532 }
1533 } 1533 }
1534 ++gxStart; 1534 ++gxStart;
1535 } 1535 }
1536 } 1536 }
1537 } 1537 }
1538 /* 1538 /*
1539 int selectionX = KOGlobals::self()->reverseLayout() ? 1539 int selectionX = KOGlobals::self()->reverseLayout() ?
1540 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1540 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1541 mSelectionCellX * mGridSpacingX; 1541 mSelectionCellX * mGridSpacingX;
1542 1542
1543 // Draw selection 1543 // Draw selection
1544 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1544 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1545 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1545 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1546 // TODO: paint only part within cx,cy,cw,ch 1546 // TODO: paint only part within cx,cy,cw,ch
1547 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX, 1547 p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
1548 mSelectionHeight, KOPrefs::instance()->mHighlightColor ); 1548 mSelectionHeight, KOPrefs::instance()->mHighlightColor );
1549 } 1549 }
1550 */ 1550 */
1551 // Draw vertical lines of grid 1551 // Draw vertical lines of grid
1552 1552
1553 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX; 1553 int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
1554 if ( mGridSpacingX > 0 ) { 1554 if ( mGridSpacingX > 0 ) {
1555 while (x < cx + cw) { 1555 while (x < cx + cw) {
1556 p->drawLine(x,cy,x,cy+ch); 1556 p->drawLine(x,cy,x,cy+ch);
1557 x+=mGridSpacingX; 1557 x+=mGridSpacingX;
1558 } 1558 }
1559 } 1559 }
1560 // Draw horizontal lines of grid 1560 // Draw horizontal lines of grid
1561 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY; 1561 int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
1562 if ( lGridSpacingY > 0 ) { 1562 if ( lGridSpacingY > 0 ) {
1563 while (y < cy + ch) { 1563 while (y < cy + ch) {
1564 p->setPen( SolidLine ); 1564 p->setPen( SolidLine );
1565 p->drawLine(cx,y,cx+cw,y); 1565 p->drawLine(cx,y,cx+cw,y);
1566 y+=lGridSpacingY; 1566 y+=lGridSpacingY;
1567 p->setPen( DotLine ); 1567 p->setPen( DotLine );
1568 p->drawLine(cx,y,cx+cw,y); 1568 p->drawLine(cx,y,cx+cw,y);
1569 y+=lGridSpacingY; 1569 y+=lGridSpacingY;
1570 } 1570 }
1571 p->setPen( SolidLine ); 1571 p->setPen( SolidLine );
1572 } 1572 }
1573 mPixPainter.end() ; 1573 mPixPainter.end() ;
1574} 1574}
1575 1575
1576/* 1576/*
1577 Convert srcollview contents coordinates to agenda grid coordinates. 1577 Convert srcollview contents coordinates to agenda grid coordinates.
1578*/ 1578*/
1579void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy) 1579void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
1580{ 1580{
1581 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX : 1581 gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
1582 x/mGridSpacingX; 1582 x/mGridSpacingX;
1583 gy = y/mGridSpacingY; 1583 gy = y/mGridSpacingY;
1584} 1584}
1585 1585
1586/* 1586/*
1587 Convert agenda grid coordinates to scrollview contents coordinates. 1587 Convert agenda grid coordinates to scrollview contents coordinates.
1588*/ 1588*/
1589void KOAgenda::gridToContents (int gx, int gy, int& x, int& y) 1589void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
1590{ 1590{
1591 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX: 1591 x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
1592 gx*mGridSpacingX; 1592 gx*mGridSpacingX;
1593 y = gy*mGridSpacingY; 1593 y = gy*mGridSpacingY;
1594} 1594}
1595 1595
1596 1596
1597/* 1597/*
1598 Return Y coordinate corresponding to time. Coordinates are rounded to fit into 1598 Return Y coordinate corresponding to time. Coordinates are rounded to fit into
1599 the grid. 1599 the grid.
1600*/ 1600*/
1601int KOAgenda::timeToY(const QTime &time) 1601int KOAgenda::timeToY(const QTime &time)
1602{ 1602{
1603 int minutesPerCell = 24 * 60 / mRows; 1603 int minutesPerCell = 24 * 60 / mRows;
1604 int timeMinutes = time.hour() * 60 + time.minute(); 1604 int timeMinutes = time.hour() * 60 + time.minute();
1605 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell; 1605 int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
1606 return Y; 1606 return Y;
1607} 1607}
1608 1608
1609 1609
1610/* 1610/*
1611 Return time corresponding to cell y coordinate. Coordinates are rounded to 1611 Return time corresponding to cell y coordinate. Coordinates are rounded to
1612 fit into the grid. 1612 fit into the grid.
1613*/ 1613*/
1614QTime KOAgenda::gyToTime(int gy) 1614QTime KOAgenda::gyToTime(int gy)
1615{ 1615{
1616 1616
1617 int secondsPerCell = 24 * 60 * 60/ mRows; 1617 int secondsPerCell = 24 * 60 * 60/ mRows;
1618 1618
1619 int timeSeconds = secondsPerCell * gy; 1619 int timeSeconds = secondsPerCell * gy;
1620 1620
1621 QTime time( 0, 0, 0 ); 1621 QTime time( 0, 0, 0 );
1622 if ( timeSeconds < 24 * 60 * 60 ) { 1622 if ( timeSeconds < 24 * 60 * 60 ) {
1623 time = time.addSecs(timeSeconds); 1623 time = time.addSecs(timeSeconds);
1624 } else { 1624 } else {
1625 time.setHMS( 23, 59, 59 ); 1625 time.setHMS( 23, 59, 59 );
1626 } 1626 }
1627 1627
1628 return time; 1628 return time;
1629} 1629}
1630 1630
1631void KOAgenda::setStartHour(int startHour) 1631void KOAgenda::setStartHour(int startHour)
1632{ 1632{
1633 int startCell = startHour * mRows / 24; 1633 int startCell = startHour * mRows / 24;
1634 setContentsPos(0,startCell * gridSpacingY()); 1634 setContentsPos(0,startCell * gridSpacingY());
1635} 1635}
1636QTime KOAgenda::getEndTime()
1637{
1638 return QTime ( (contentsY ()+viewport()->height())*24/contentsHeight ()+1,0,0);
1639}
1636void KOAgenda::hideUnused() 1640void KOAgenda::hideUnused()
1637{ 1641{
1638 // experimental only 1642 // experimental only
1639 // return; 1643 // return;
1640 KOAgendaItem *item; 1644 KOAgendaItem *item;
1641 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) { 1645 for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
1642 item->hide(); 1646 item->hide();
1643 } 1647 }
1644} 1648}
1645 1649
1646 1650
1647KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view) 1651KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
1648{ 1652{
1649 1653
1650 KOAgendaItem *fi; 1654 KOAgendaItem *fi;
1651 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) { 1655 for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
1652 if ( fi->incidence() == event ) { 1656 if ( fi->incidence() == event ) {
1653 mUnusedItems.remove(); 1657 mUnusedItems.remove();
1654 fi->init( event, qd ); 1658 fi->init( event, qd );
1655 return fi; 1659 return fi;
1656 } 1660 }
1657 } 1661 }
1658 fi=mUnusedItems.first(); 1662 fi=mUnusedItems.first();
1659 if ( fi ) { 1663 if ( fi ) {
1660 mUnusedItems.remove(); 1664 mUnusedItems.remove();
1661 fi->init( event, qd ); 1665 fi->init( event, qd );
1662 return fi; 1666 return fi;
1663 } 1667 }
1664 // qDebug("new KOAgendaItem "); 1668 // qDebug("new KOAgendaItem ");
1665 1669
1666 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode ); 1670 KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
1667 agendaItem->installEventFilter(this); 1671 agendaItem->installEventFilter(this);
1668 addChild(agendaItem,0,0); 1672 addChild(agendaItem,0,0);
1669 return agendaItem; 1673 return agendaItem;
1670} 1674}
1671KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo ) 1675KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
1672{ 1676{
1673 KOAgendaItem *item; 1677 KOAgendaItem *item;
1674 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1678 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1675 if ( item->incidence() == todo ) { 1679 if ( item->incidence() == todo ) {
1676 mItems.remove(); 1680 mItems.remove();
1677 return item; 1681 return item;
1678 } 1682 }
1679 } 1683 }
1680 return 0; 1684 return 0;
1681} 1685}
1682 1686
1683 1687
1684void KOAgenda::updateTodo( Todo * todo, int days, bool remove) 1688void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
1685{ 1689{
1686 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )|| 1690 // ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
1687 KOAgendaItem *item; 1691 KOAgendaItem *item;
1688 item = getItemForTodo ( todo ); 1692 item = getItemForTodo ( todo );
1689 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove); 1693 //qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
1690 if ( item ) { 1694 if ( item ) {
1691 blockSignals( true ); 1695 blockSignals( true );
1692 //qDebug("item found "); 1696 //qDebug("item found ");
1693 item->hide(); 1697 item->hide();
1694 item->setCellX(-2, -1 ); 1698 item->setCellX(-2, -1 );
1695 item->select(false); 1699 item->select(false);
1696 mUnusedItems.append( item ); 1700 mUnusedItems.append( item );
1697 mItems.remove( item ); 1701 mItems.remove( item );
1698 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1702 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1699 KOAgendaItem *itemit; 1703 KOAgendaItem *itemit;
1700 //globalFlagBlockAgendaItemPaint = 1; 1704 //globalFlagBlockAgendaItemPaint = 1;
1701 for ( itemit=oldconflictItems.first(); itemit != 0; 1705 for ( itemit=oldconflictItems.first(); itemit != 0;
1702 itemit=oldconflictItems.next() ) { 1706 itemit=oldconflictItems.next() ) {
1703 if ( itemit != item ) 1707 if ( itemit != item )
1704 placeSubCells(itemit); 1708 placeSubCells(itemit);
1705 } 1709 }
1706 qApp->processEvents(); 1710 qApp->processEvents();
1707 //globalFlagBlockAgendaItemPaint = 0; 1711 //globalFlagBlockAgendaItemPaint = 0;
1708 for ( itemit=oldconflictItems.first(); itemit != 0; 1712 for ( itemit=oldconflictItems.first(); itemit != 0;
1709 itemit=oldconflictItems.next() ) { 1713 itemit=oldconflictItems.next() ) {
1710 globalFlagBlockAgendaItemUpdate = 0; 1714 globalFlagBlockAgendaItemUpdate = 0;
1711 if ( itemit != item ) 1715 if ( itemit != item )
1712 itemit->repaintMe(); 1716 itemit->repaintMe();
1713 globalFlagBlockAgendaItemUpdate = 1; 1717 globalFlagBlockAgendaItemUpdate = 1;
1714 //qDebug("sigleshot "); 1718 //qDebug("sigleshot ");
1715 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() )); 1719 QTimer::singleShot( 0, itemit, SLOT ( repaintItem() ));
1716 //itemit->repaint( false ); repaintItem() 1720 //itemit->repaint( false ); repaintItem()
1717 } 1721 }
1718 blockSignals( false ); 1722 blockSignals( false );
1719 } 1723 }
1720 if ( remove ) { 1724 if ( remove ) {
1721 //qDebug("remove****************************************** "); 1725 //qDebug("remove****************************************** ");
1722 return; 1726 return;
1723 } 1727 }
1724 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) 1728 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda )
1725 return; 1729 return;
1726 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ "); 1730 //qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
1727 QDate currentDate = QDate::currentDate(); 1731 QDate currentDate = QDate::currentDate();
1728 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda ); 1732 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda );
1729 QDateTime dt; 1733 QDateTime dt;
1730 if ( todo->hasCompletedDate() ) 1734 if ( todo->hasCompletedDate() )
1731 dt = todo->completed(); 1735 dt = todo->completed();
1732 else 1736 else
1733 dt = todo->dtDue(); 1737 dt = todo->dtDue();
1734 if ( overdue ) { 1738 if ( overdue ) {
1735 days += todo->dtDue().date().daysTo( currentDate ); 1739 days += todo->dtDue().date().daysTo( currentDate );
1736 } 1740 }
1737 else 1741 else
1738 currentDate = dt.date(); 1742 currentDate = dt.date();
1739 1743
1740 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) { 1744 if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
1741 if ( ! mAllDayMode ) return; 1745 if ( ! mAllDayMode ) return;
1742 // aldayagenda 1746 // aldayagenda
1743 globalFlagBlockAgendaItemPaint = 1; 1747 globalFlagBlockAgendaItemPaint = 1;
1744 item = insertAllDayItem(todo, currentDate,days, days); 1748 item = insertAllDayItem(todo, currentDate,days, days);
1745 item->show(); 1749 item->show();
1746 1750
1747 } 1751 }
1748 else { 1752 else {
1749 if ( mAllDayMode ) return; 1753 if ( mAllDayMode ) return;
1750 // mAgenda 1754 // mAgenda
1751 globalFlagBlockAgendaItemPaint = 1; 1755 globalFlagBlockAgendaItemPaint = 1;
1752 int endY = timeToY(dt.time()) - 1; 1756 int endY = timeToY(dt.time()) - 1;
1753 int hi = 12/KOPrefs::instance()->mHourSize; 1757 int hi = 12/KOPrefs::instance()->mHourSize;
1754 int startY = endY - 1-hi; 1758 int startY = endY - 1-hi;
1755 item = insertItem(todo,currentDate,days,startY,endY); 1759 item = insertItem(todo,currentDate,days,startY,endY);
1756 item->show(); 1760 item->show();
1757 } 1761 }
1758 qApp->processEvents(); 1762 qApp->processEvents();
1759 globalFlagBlockAgendaItemPaint = 0; 1763 globalFlagBlockAgendaItemPaint = 0;
1760 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems(); 1764 QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
1761 KOAgendaItem *itemit; 1765 KOAgendaItem *itemit;
1762 for ( itemit=oldconflictItems.first(); itemit != 0; 1766 for ( itemit=oldconflictItems.first(); itemit != 0;
1763 itemit=oldconflictItems.next() ) { 1767 itemit=oldconflictItems.next() ) {
1764 globalFlagBlockAgendaItemUpdate = 0; 1768 globalFlagBlockAgendaItemUpdate = 0;
1765 itemit->repaintMe(); 1769 itemit->repaintMe();
1766 globalFlagBlockAgendaItemUpdate = 1; 1770 globalFlagBlockAgendaItemUpdate = 1;
1767 itemit->repaint(); 1771 itemit->repaint();
1768 } 1772 }
1769 globalFlagBlockAgendaItemUpdate = 0; 1773 globalFlagBlockAgendaItemUpdate = 0;
1770 item->repaintMe(); 1774 item->repaintMe();
1771 globalFlagBlockAgendaItemUpdate = 1; 1775 globalFlagBlockAgendaItemUpdate = 1;
1772 item->repaint(); 1776 item->repaint();
1773} 1777}
1774/* 1778/*
1775 Insert KOAgendaItem into agenda. 1779 Insert KOAgendaItem into agenda.
1776*/ 1780*/
1777KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom) 1781KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
1778{ 1782{
1779 if (mAllDayMode) { 1783 if (mAllDayMode) {
1780 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. "); 1784 qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
1781 return 0; 1785 return 0;
1782 } 1786 }
1783 1787
1784 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1788 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1785 //agendaItem->setFrameStyle(WinPanel|Raised); 1789 //agendaItem->setFrameStyle(WinPanel|Raised);
1786 1790
1787 int YSize = YBottom - YTop + 1; 1791 int YSize = YBottom - YTop + 1;
1788 if (YSize < 0) { 1792 if (YSize < 0) {
1789 YSize = 1; 1793 YSize = 1;
1790 } 1794 }
1791 int iheight = mGridSpacingY * YSize; 1795 int iheight = mGridSpacingY * YSize;
1792 1796
1793 agendaItem->resize(mGridSpacingX,iheight ); 1797 agendaItem->resize(mGridSpacingX,iheight );
1794 agendaItem->setCellXY(X,YTop,YBottom); 1798 agendaItem->setCellXY(X,YTop,YBottom);
1795 agendaItem->setCellXWidth(X); 1799 agendaItem->setCellXWidth(X);
1796 1800
1797 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY); 1801 //addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
1798 mItems.append(agendaItem); 1802 mItems.append(agendaItem);
1799 1803
1800 placeSubCells(agendaItem); 1804 placeSubCells(agendaItem);
1801 1805
1802 //agendaItem->show(); 1806 //agendaItem->show();
1803 1807
1804 1808
1805 return agendaItem; 1809 return agendaItem;
1806} 1810}
1807 1811
1808 1812
1809/* 1813/*
1810 Insert all-day KOAgendaItem into agenda. 1814 Insert all-day KOAgendaItem into agenda.
1811*/ 1815*/
1812KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) 1816KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
1813{ 1817{
1814 if (!mAllDayMode) { 1818 if (!mAllDayMode) {
1815 return 0; 1819 return 0;
1816 } 1820 }
1817 1821
1818 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 1822 KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
1819 1823
1820 agendaItem->setCellXY(XBegin,0,0); 1824 agendaItem->setCellXY(XBegin,0,0);
1821 agendaItem->setCellXWidth(XEnd); 1825 agendaItem->setCellXWidth(XEnd);
1822 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); 1826 agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
1823 1827
1824 //addChild(agendaItem,XBegin*mGridSpacingX,0); 1828 //addChild(agendaItem,XBegin*mGridSpacingX,0);
1825 mItems.append(agendaItem); 1829 mItems.append(agendaItem);
1826 1830
1827 placeSubCells(agendaItem); 1831 placeSubCells(agendaItem);
1828 1832
1829 //agendaItem->show(); 1833 //agendaItem->show();
1830 1834
1831 return agendaItem; 1835 return agendaItem;
1832} 1836}
1833 1837
1834 1838
1835void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 1839void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
1836 int YTop,int YBottom) 1840 int YTop,int YBottom)
1837{ 1841{
1838 if (mAllDayMode) { 1842 if (mAllDayMode) {
1839 ; 1843 ;
1840 return; 1844 return;
1841 } 1845 }
1842 1846
1843 int cellX,cellYTop,cellYBottom; 1847 int cellX,cellYTop,cellYBottom;
1844 QString newtext; 1848 QString newtext;
1845 int width = XEnd - XBegin + 1; 1849 int width = XEnd - XBegin + 1;
1846 int count = 0; 1850 int count = 0;
1847 KOAgendaItem *current = 0; 1851 KOAgendaItem *current = 0;
1848 QPtrList<KOAgendaItem> multiItems; 1852 QPtrList<KOAgendaItem> multiItems;
1849 for (cellX = XBegin;cellX <= XEnd;++cellX) { 1853 for (cellX = XBegin;cellX <= XEnd;++cellX) {
1850 if (cellX == XBegin) cellYTop = YTop; 1854 if (cellX == XBegin) cellYTop = YTop;
1851 else cellYTop = 0; 1855 else cellYTop = 0;
1852 if (cellX == XEnd) cellYBottom = YBottom; 1856 if (cellX == XEnd) cellYBottom = YBottom;
1853 else cellYBottom = rows() - 1; 1857 else cellYBottom = rows() - 1;
1854 newtext = QString("(%1/%2): ").arg(++count).arg(width); 1858 newtext = QString("(%1/%2): ").arg(++count).arg(width);
1855 newtext.append(event->summary()); 1859 newtext.append(event->summary());
1856 current = insertItem(event,qd,cellX,cellYTop,cellYBottom); 1860 current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
1857 current->setText(newtext); 1861 current->setText(newtext);
1858 multiItems.append(current); 1862 multiItems.append(current);
1859 } 1863 }
1860 1864
1861 KOAgendaItem *next = 0; 1865 KOAgendaItem *next = 0;
1862 KOAgendaItem *last = multiItems.last(); 1866 KOAgendaItem *last = multiItems.last();
1863 KOAgendaItem *first = multiItems.first(); 1867 KOAgendaItem *first = multiItems.first();
1864 KOAgendaItem *setFirst,*setLast; 1868 KOAgendaItem *setFirst,*setLast;
1865 current = first; 1869 current = first;
1866 while (current) { 1870 while (current) {
1867 next = multiItems.next(); 1871 next = multiItems.next();
1868 if (current == first) setFirst = 0; 1872 if (current == first) setFirst = 0;
1869 else setFirst = first; 1873 else setFirst = first;
1870 if (current == last) setLast = 0; 1874 if (current == last) setLast = 0;
1871 else setLast = last; 1875 else setLast = last;
1872 1876
1873 current->setMultiItem(setFirst,next,setLast); 1877 current->setMultiItem(setFirst,next,setLast);
1874 current = next; 1878 current = next;
1875 } 1879 }
1876} 1880}
1877 1881
1878 1882
1879//QSizePolicy KOAgenda::sizePolicy() const 1883//QSizePolicy KOAgenda::sizePolicy() const
1880//{ 1884//{
1881 // Thought this would make the all-day event agenda minimum size and the 1885 // Thought this would make the all-day event agenda minimum size and the
1882 // normal agenda take the remaining space. But it doesn´t work. The QSplitter 1886 // normal agenda take the remaining space. But it doesn´t work. The QSplitter
1883 // don´t seem to think that an Expanding widget needs more space than a 1887 // don´t seem to think that an Expanding widget needs more space than a
1884 // Preferred one. 1888 // Preferred one.
1885 // But it doesn´t hurt, so it stays. 1889 // But it doesn´t hurt, so it stays.
1886// if (mAllDayMode) { 1890// if (mAllDayMode) {
1887// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred); 1891// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
1888// } else { 1892// } else {
1889// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); 1893// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
1890// } 1894// }
1891//} 1895//}
1892void KOAgenda::finishResize ( ) 1896void KOAgenda::finishResize ( )
1893{ 1897{
1894 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) "); 1898 //qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
1895 if ( globalFlagBlockAgenda == 0 ) { 1899 if ( globalFlagBlockAgenda == 0 ) {
1896 finishUpdate(); 1900 finishUpdate();
1897 //qDebug("finishUpdate() called "); 1901 //qDebug("finishUpdate() called ");
1898 } 1902 }
1899} 1903}
1900/* 1904/*
1901 Overridden from QScrollView to provide proper resizing of KOAgendaItems. 1905 Overridden from QScrollView to provide proper resizing of KOAgendaItems.
1902*/ 1906*/
1903void KOAgenda::resizeEvent ( QResizeEvent *ev ) 1907void KOAgenda::resizeEvent ( QResizeEvent *ev )
1904{ 1908{
1905 mSelectionHeight = 0; 1909 mSelectionHeight = 0;
1906 mResizeTimer.start( 150 , true ); 1910 mResizeTimer.start( 150 , true );
1907 computeSizes(); 1911 computeSizes();
1908 return; 1912 return;
1909 1913
1910} 1914}
1911void KOAgenda::computeSizes() 1915void KOAgenda::computeSizes()
1912{ 1916{
1913 if ( globalFlagBlockStartup ) 1917 if ( globalFlagBlockStartup )
1914 return; 1918 return;
1915 int frameOffset = frameWidth() * 2 +1; 1919 int frameOffset = frameWidth() * 2 +1;
1916 if (mAllDayMode) { 1920 if (mAllDayMode) {
1917 mGridSpacingX = (width()-frameOffset) / mColumns; 1921 mGridSpacingX = (width()-frameOffset) / mColumns;
1918 mGridSpacingY = height() - 2 * frameWidth() - 1; 1922 mGridSpacingY = height() - 2 * frameWidth() - 1;
1919 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1923 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1920 // mGridSpacingY = height(); 1924 // mGridSpacingY = height();
1921 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1925 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1922 1926
1923 KOAgendaItem *item; 1927 KOAgendaItem *item;
1924 int subCellWidth; 1928 int subCellWidth;
1925 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1929 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1926 subCellWidth = mGridSpacingY / item->subCells(); 1930 subCellWidth = mGridSpacingY / item->subCells();
1927 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1931 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1928 moveChild(item,KOGlobals::self()->reverseLayout() ? 1932 moveChild(item,KOGlobals::self()->reverseLayout() ?
1929 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1933 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1930 item->cellX() * mGridSpacingX, 1934 item->cellX() * mGridSpacingX,
1931 item->subCell() * subCellWidth); 1935 item->subCell() * subCellWidth);
1932 } 1936 }
1933 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1937 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1934 } else { 1938 } else {
1935 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1939 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1936 if (height() > mGridSpacingY * mRows + 1 ) { 1940 if (height() > mGridSpacingY * mRows + 1 ) {
1937 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1941 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1938 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1942 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1939 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1943 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1940 emit resizedSignal(); 1944 emit resizedSignal();
1941 } else 1945 } else
1942 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1946 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1943 KOAgendaItem *item; 1947 KOAgendaItem *item;
1944 int subCellWidth; 1948 int subCellWidth;
1945 1949
1946 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1950 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1947 subCellWidth = mGridSpacingX / item->subCells(); 1951 subCellWidth = mGridSpacingX / item->subCells();
1948 item->resize(subCellWidth,item->height()); 1952 item->resize(subCellWidth,item->height());
1949 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1953 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1950 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1954 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1951 item->cellX() * mGridSpacingX) + 1955 item->cellX() * mGridSpacingX) +
1952 item->subCell() * subCellWidth,childY(item)); 1956 item->subCell() * subCellWidth,childY(item));
1953 } 1957 }
1954 } 1958 }
1955 int cw = contentsWidth(); 1959 int cw = contentsWidth();
1956 int ch = contentsHeight(); 1960 int ch = contentsHeight();
1957 if ( mAllDayMode ) { 1961 if ( mAllDayMode ) {
1958 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1962 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1959 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { 1963 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) {
1960 //qDebug("paintPixAll->resize "); 1964 //qDebug("paintPixAll->resize ");
1961 paintPixAll->resize( cw, ch ); 1965 paintPixAll->resize( cw, ch );
1962 } 1966 }
1963 } else { 1967 } else {
1964 QPixmap* paintPix = KOAgendaItem::paintPix(); 1968 QPixmap* paintPix = KOAgendaItem::paintPix();
1965 if ( paintPix->width() < cw || paintPix->height() < ch ) { 1969 if ( paintPix->width() < cw || paintPix->height() < ch ) {
1966 //qDebug("paintPix->resize "); 1970 //qDebug("paintPix->resize ");
1967 paintPix->resize( cw , ch ); 1971 paintPix->resize( cw , ch );
1968 } 1972 }
1969 } 1973 }
1970 1974
1971 checkScrollBoundaries(); 1975 checkScrollBoundaries();
1972 drawContentsToPainter(); 1976 drawContentsToPainter();
1973 viewport()->repaint(false); 1977 viewport()->repaint(false);
1974} 1978}
1975 1979
1976void KOAgenda::scrollUp() 1980void KOAgenda::scrollUp()
1977{ 1981{
1978 scrollBy(0,-mScrollOffset); 1982 scrollBy(0,-mScrollOffset);
1979} 1983}
1980 1984
1981 1985
1982void KOAgenda::scrollDown() 1986void KOAgenda::scrollDown()
1983{ 1987{
1984 scrollBy(0,mScrollOffset); 1988 scrollBy(0,mScrollOffset);
1985} 1989}
1986 1990
1987void KOAgenda::popupAlarm() 1991void KOAgenda::popupAlarm()
1988{ 1992{
1989 if (!mClickedItem) { 1993 if (!mClickedItem) {
1990 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 1994 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1991 return; 1995 return;
1992 } 1996 }
1993 // TODO: deal correctly with multiple alarms 1997 // TODO: deal correctly with multiple alarms
1994 Alarm* alarm; 1998 Alarm* alarm;
1995 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1999 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1996 for(alarm=list.first();alarm;alarm=list.next()) { 2000 for(alarm=list.first();alarm;alarm=list.next()) {
1997 alarm->toggleAlarm(); 2001 alarm->toggleAlarm();
1998 } 2002 }
1999 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 2003 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
2000 mClickedItem->paintMe( true ); 2004 mClickedItem->paintMe( true );
2001 mClickedItem->repaint( false ); 2005 mClickedItem->repaint( false );
2002} 2006}
2003 2007
2004/* 2008/*
2005 Calculates the minimum width 2009 Calculates the minimum width
2006*/ 2010*/
2007int KOAgenda::minimumWidth() const 2011int KOAgenda::minimumWidth() const
2008{ 2012{
2009 // TODO:: develop a way to dynamically determine the minimum width 2013 // TODO:: develop a way to dynamically determine the minimum width
2010 int min = 100; 2014 int min = 100;
2011 2015
2012 return min; 2016 return min;
2013} 2017}
2014 2018
2015void KOAgenda::updateConfig() 2019void KOAgenda::updateConfig()
2016{ 2020{
2017 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor) 2021 if ( viewport()->backgroundColor() != KOPrefs::instance()->mAgendaBgColor)
2018 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor); 2022 viewport()->setBackgroundColor(KOPrefs::instance()->mAgendaBgColor);
2019 if ( mAllDayMode ) { 2023 if ( mAllDayMode ) {
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 0e3aed8..86cf2f4 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -1,306 +1,307 @@
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 KOAGENDA_H 23#ifndef KOAGENDA_H
24#define KOAGENDA_H 24#define KOAGENDA_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qtimer.h> 27#include <qtimer.h>
28#include <qmemarray.h> 28#include <qmemarray.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qpixmap.h> 30#include <qpixmap.h>
31#include <qguardedptr.h> 31#include <qguardedptr.h>
32 32
33#include "koagendaitem.h" 33#include "koagendaitem.h"
34#include "koeventview.h" 34#include "koeventview.h"
35 35
36class QPopupMenu; 36class QPopupMenu;
37class QTime; 37class QTime;
38class KConfig; 38class KConfig;
39class QFrame; 39class QFrame;
40class KOAgenda; 40class KOAgenda;
41class KCal::Event; 41class KCal::Event;
42class KCal::Todo; 42class KCal::Todo;
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46class MarcusBains : public QFrame { 46class MarcusBains : public QFrame {
47 Q_OBJECT 47 Q_OBJECT
48 public: 48 public:
49 MarcusBains(KOAgenda *agenda=0,const char *name=0); 49 MarcusBains(KOAgenda *agenda=0,const char *name=0);
50 virtual ~MarcusBains(); 50 virtual ~MarcusBains();
51 51
52 public slots: 52 public slots:
53 void updateLocation(bool recalculate=false); 53 void updateLocation(bool recalculate=false);
54 void updateLoc(); 54 void updateLoc();
55 55
56 private: 56 private:
57 int todayColumn(); 57 int todayColumn();
58 QTimer *minutes; 58 QTimer *minutes;
59 QLabel *mTimeBox; 59 QLabel *mTimeBox;
60 KOAgenda *agenda; 60 KOAgenda *agenda;
61 QTime oldTime; 61 QTime oldTime;
62 int oldToday; 62 int oldToday;
63}; 63};
64 64
65 65
66class KOAgenda : public QScrollView 66class KOAgenda : public QScrollView
67{ 67{
68 Q_OBJECT 68 Q_OBJECT
69 public: 69 public:
70 enum MouseActionType { NOP, MOVE, SELECT, 70 enum MouseActionType { NOP, MOVE, SELECT,
71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 71 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
72 72
73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 73 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
74 const char * name=0, WFlags f=0 ); 74 const char * name=0, WFlags f=0 );
75 KOAgenda ( int columns, QWidget * parent=0, 75 KOAgenda ( int columns, QWidget * parent=0,
76 const char * name=0, WFlags f=0 ); 76 const char * name=0, WFlags f=0 );
77 virtual ~KOAgenda(); 77 virtual ~KOAgenda();
78 bool mInvalidPixmap; 78 bool mInvalidPixmap;
79 79
80 Incidence *selectedIncidence() const; 80 Incidence *selectedIncidence() const;
81 QDate selectedIncidenceDate() const; 81 QDate selectedIncidenceDate() const;
82 82
83 virtual bool eventFilter ( QObject *, QEvent * ); 83 virtual bool eventFilter ( QObject *, QEvent * );
84 84
85 void contentsToGrid (int x, int y, int& gx, int& gy); 85 void contentsToGrid (int x, int y, int& gx, int& gy);
86 void gridToContents (int gx, int gy, int& x, int& y); 86 void gridToContents (int gx, int gy, int& x, int& y);
87 87
88 int timeToY (const QTime &time); 88 int timeToY (const QTime &time);
89 QTime gyToTime (int y); 89 QTime gyToTime (int y);
90 90
91 void setStartHour(int startHour); 91 void setStartHour(int startHour);
92 92
93 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 93 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
94 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 94 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
95 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 95 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
96 int YTop,int YBottom); 96 int YTop,int YBottom);
97 97
98 void changeColumns(int columns); 98 void changeColumns(int columns);
99 99
100 int columns() { return mColumns; } 100 int columns() { return mColumns; }
101 int rows() { return mRows; } 101 int rows() { return mRows; }
102 102
103 int gridSpacingX() const { return mGridSpacingX; } 103 int gridSpacingX() const { return mGridSpacingX; }
104 int gridSpacingY() const { return mGridSpacingY; } 104 int gridSpacingY() const { return mGridSpacingY; }
105 105
106// virtual QSizePolicy sizePolicy() const; 106// virtual QSizePolicy sizePolicy() const;
107 107
108 void clear(); 108 void clear();
109 109
110 void clearSelection(); 110 void clearSelection();
111 void hideUnused(); 111 void hideUnused();
112 112
113 /** Calculates the minimum width */ 113 /** Calculates the minimum width */
114 virtual int minimumWidth() const; 114 virtual int minimumWidth() const;
115 /** Update configuration from preference settings */ 115 /** Update configuration from preference settings */
116 void updateConfig(); 116 void updateConfig();
117 117
118 void checkScrollBoundaries(); 118 void checkScrollBoundaries();
119 119
120 void setHolidayMask(QMemArray<bool> *); 120 void setHolidayMask(QMemArray<bool> *);
121 void setDateList(const DateList &selectedDates); 121 void setDateList(const DateList &selectedDates);
122 DateList dateList() const; 122 DateList dateList() const;
123 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 123 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
124 void finishUpdate(); 124 void finishUpdate();
125 void printSelection(); 125 void printSelection();
126 void storePosition(); 126 void storePosition();
127 void restorePosition(); 127 void restorePosition();
128 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } 128 void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; }
129 void shrinkPixmap(); 129 void shrinkPixmap();
130 QTime getEndTime();
130 131
131 public slots: 132 public slots:
132 void slotContentMove(int,int); 133 void slotContentMove(int,int);
133 void categoryChanged(Incidence * inc); 134 void categoryChanged(Incidence * inc);
134 void slotClearSelection(); 135 void slotClearSelection();
135 void popupMenu(); 136 void popupMenu();
136 void newItem( int ); 137 void newItem( int );
137 void moveChild( QWidget *, int, int ); 138 void moveChild( QWidget *, int, int );
138 void scrollUp(); 139 void scrollUp();
139 void scrollDown(); 140 void scrollDown();
140 void updateTodo( Todo * t, int , bool ); 141 void updateTodo( Todo * t, int , bool );
141 void popupAlarm(); 142 void popupAlarm();
142 143
143 void checkScrollBoundaries(int); 144 void checkScrollBoundaries(int);
144 145
145 /** Deselect selected items. This function does not emit any signals. */ 146 /** Deselect selected items. This function does not emit any signals. */
146 void deselectItem(); 147 void deselectItem();
147 /** Select item. If the argument is 0, the currently selected item gets 148 /** Select item. If the argument is 0, the currently selected item gets
148 deselected. This function emits the itemSelected(bool) signal to inform 149 deselected. This function emits the itemSelected(bool) signal to inform
149 about selection/deseelction of events. */ 150 about selection/deseelction of events. */
150 void selectItem(KOAgendaItem *); 151 void selectItem(KOAgendaItem *);
151 void finishResize(); 152 void finishResize();
152 153
153 signals: 154 signals:
154 void signalClearSelection(); 155 void signalClearSelection();
155 void showDateView( int, int); 156 void showDateView( int, int);
156 void newEventSignal(); 157 void newEventSignal();
157 void newEventSignal(int gx,int gy); 158 void newEventSignal(int gx,int gy);
158 void newTodoSignal(int gx,int gy); 159 void newTodoSignal(int gx,int gy);
159 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 160 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
160 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 161 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
161 void newStartSelectSignal(); 162 void newStartSelectSignal();
162 void showIncidenceSignal(Incidence *); 163 void showIncidenceSignal(Incidence *);
163 void editIncidenceSignal(Incidence *); 164 void editIncidenceSignal(Incidence *);
164 void deleteIncidenceSignal(Incidence *); 165 void deleteIncidenceSignal(Incidence *);
165 void showIncidencePopupSignal(Incidence *); 166 void showIncidencePopupSignal(Incidence *);
166 167
167 void itemModified(KOAgendaItem *item, int ); 168 void itemModified(KOAgendaItem *item, int );
168 void incidenceSelected(Incidence *); 169 void incidenceSelected(Incidence *);
169 170
170 void lowerYChanged(int); 171 void lowerYChanged(int);
171 void upperYChanged(int); 172 void upperYChanged(int);
172 173
173 void startDragSignal(Incidence *); 174 void startDragSignal(Incidence *);
174 void addToCalSignal(Incidence *, Incidence *); 175 void addToCalSignal(Incidence *, Incidence *);
175 void resizedSignal(); 176 void resizedSignal();
176 void updateViewSignal(); 177 void updateViewSignal();
177 void sendPing(); 178 void sendPing();
178 179
179 protected: 180 protected:
180 KOEventPopupMenu * mAllAgendaPopup; 181 KOEventPopupMenu * mAllAgendaPopup;
181 QPainter mPixPainter; 182 QPainter mPixPainter;
182 QPixmap mPaintPixmap; 183 QPixmap mPaintPixmap;
183 QPixmap mHighlightPixmap; 184 QPixmap mHighlightPixmap;
184 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 185 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
185 virtual void resizeEvent ( QResizeEvent * ); 186 virtual void resizeEvent ( QResizeEvent * );
186 187
187 /** Handles mouse events. Called from eventFilter */ 188 /** Handles mouse events. Called from eventFilter */
188 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 189 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
189 190
190 /** Start selecting time span. */ 191 /** Start selecting time span. */
191 void startSelectAction(QPoint viewportPos); 192 void startSelectAction(QPoint viewportPos);
192 193
193 /** Select time span. */ 194 /** Select time span. */
194 void performSelectAction(QPoint viewportPos); 195 void performSelectAction(QPoint viewportPos);
195 196
196 /** Emd selecting time span. */ 197 /** Emd selecting time span. */
197 void endSelectAction( bool emitNewEvent = false ); 198 void endSelectAction( bool emitNewEvent = false );
198 199
199 /** Start moving/resizing agenda item */ 200 /** Start moving/resizing agenda item */
200 void startItemAction(QPoint viewportPos); 201 void startItemAction(QPoint viewportPos);
201 202
202 /** Move/resize agenda item */ 203 /** Move/resize agenda item */
203 void performItemAction(QPoint viewportPos); 204 void performItemAction(QPoint viewportPos);
204 205
205 /** End moving/resizing agenda item */ 206 /** End moving/resizing agenda item */
206 void endItemAction(); 207 void endItemAction();
207 208
208 /** Set cursor, when no item action is in progress */ 209 /** Set cursor, when no item action is in progress */
209 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 210 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
210 211
211 /** Place agenda item in agenda and adjust other cells if necessary */ 212 /** Place agenda item in agenda and adjust other cells if necessary */
212 void placeSubCells(KOAgendaItem *placeItem); 213 void placeSubCells(KOAgendaItem *placeItem);
213 214
214 /** Process the keyevent, including the ignored keyevents of eventwidgets. 215 /** Process the keyevent, including the ignored keyevents of eventwidgets.
215 * Implements pgup/pgdn and cursor key navigation in the view. 216 * Implements pgup/pgdn and cursor key navigation in the view.
216 */ 217 */
217 void keyPressEvent( QKeyEvent * ); 218 void keyPressEvent( QKeyEvent * );
218 219
219 void calculateWorkingHours(); 220 void calculateWorkingHours();
220 221
221 virtual void contentsMousePressEvent ( QMouseEvent * ); 222 virtual void contentsMousePressEvent ( QMouseEvent * );
222 223
223 private: 224 private:
224 void init(); 225 void init();
225 void marcus_bains(); 226 void marcus_bains();
226 bool mAllDayMode; 227 bool mAllDayMode;
227 bool blockResize; 228 bool blockResize;
228 bool mLeftMouseDown; 229 bool mLeftMouseDown;
229 KOAgendaItem *mPopupItem; 230 KOAgendaItem *mPopupItem;
230 QTimer* mPopupTimer; 231 QTimer* mPopupTimer;
231 int mPopupKind; 232 int mPopupKind;
232 QPoint mPopupPos; 233 QPoint mPopupPos;
233 QTimer mResizeTimer; 234 QTimer mResizeTimer;
234 double mContentPosition; 235 double mContentPosition;
235 236
236 // Width and height of agenda cells 237 // Width and height of agenda cells
237 int mGridSpacingX; 238 int mGridSpacingX;
238 int mGridSpacingY; 239 int mGridSpacingY;
239 240
240 // size of border, where mouse action will resize the KOAgendaItem 241 // size of border, where mouse action will resize the KOAgendaItem
241 int mResizeBorderWidth; 242 int mResizeBorderWidth;
242 243
243 // size of border, where mouse mve will cause a scroll of the agenda 244 // size of border, where mouse mve will cause a scroll of the agenda
244 int mScrollBorderWidth; 245 int mScrollBorderWidth;
245 int mScrollDelay; 246 int mScrollDelay;
246 int mScrollOffset; 247 int mScrollOffset;
247 248
248 QTimer mScrollUpTimer; 249 QTimer mScrollUpTimer;
249 QTimer mScrollDownTimer; 250 QTimer mScrollDownTimer;
250 251
251 // Number of Columns/Rows of agenda grid 252 // Number of Columns/Rows of agenda grid
252 int mColumns; 253 int mColumns;
253 int mRows; 254 int mRows;
254 255
255 // Cells to store Move and Resize coordiantes 256 // Cells to store Move and Resize coordiantes
256 int mStartCellX; 257 int mStartCellX;
257 int mStartCellY; 258 int mStartCellY;
258 int mCurrentCellX; 259 int mCurrentCellX;
259 int mCurrentCellY; 260 int mCurrentCellY;
260 261
261 // Working Hour coordiantes 262 // Working Hour coordiantes
262 bool mWorkingHoursEnable; 263 bool mWorkingHoursEnable;
263 int mWorkingHoursYTop; 264 int mWorkingHoursYTop;
264 int mWorkingHoursYBottom; 265 int mWorkingHoursYBottom;
265 266
266 // Selection 267 // Selection
267 int mSelectionCellX; 268 int mSelectionCellX;
268 int mSelectionYTop; 269 int mSelectionYTop;
269 int mSelectionHeight; 270 int mSelectionHeight;
270 271
271 // List of dates to be displayed 272 // List of dates to be displayed
272 DateList mSelectedDates; 273 DateList mSelectedDates;
273 274
274 // The KOAgendaItem, which has been right-clicked last 275 // The KOAgendaItem, which has been right-clicked last
275 KOAgendaItem *mClickedItem; 276 KOAgendaItem *mClickedItem;
276 277
277 // The KOAgendaItem, which is being moved/resized 278 // The KOAgendaItem, which is being moved/resized
278 QGuardedPtr<KOAgendaItem> mActionItem; 279 QGuardedPtr<KOAgendaItem> mActionItem;
279 280
280 // Currently selected item 281 // Currently selected item
281 QGuardedPtr<KOAgendaItem> mSelectedItem; 282 QGuardedPtr<KOAgendaItem> mSelectedItem;
282 283
283 // The Marcus Bains Line widget. 284 // The Marcus Bains Line widget.
284 MarcusBains *mMarcusBains; 285 MarcusBains *mMarcusBains;
285 void computeSizes(); 286 void computeSizes();
286 287
287 MouseActionType mActionType; 288 MouseActionType mActionType;
288 289
289 bool mItemMoved; 290 bool mItemMoved;
290 291
291 // List of all Items contained in agenda 292 // List of all Items contained in agenda
292 QPtrList<KOAgendaItem> mItems; 293 QPtrList<KOAgendaItem> mItems;
293 QPtrList<KOAgendaItem> mUnusedItems; 294 QPtrList<KOAgendaItem> mUnusedItems;
294 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); 295 KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport);
295 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems 296 QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems
296 QPopupMenu *mNewItemPopup; 297 QPopupMenu *mNewItemPopup;
297 298
298 int mOldLowerScrollValue; 299 int mOldLowerScrollValue;
299 int mOldUpperScrollValue; 300 int mOldUpperScrollValue;
300 KOAgendaItem * getItemForTodo ( Todo * todo ); 301 KOAgendaItem * getItemForTodo ( Todo * todo );
301 QMemArray<bool> *mHolidayMask; 302 QMemArray<bool> *mHolidayMask;
302 int mCurPixWid; 303 int mCurPixWid;
303 int mCurPixHei; 304 int mCurPixHei;
304}; 305};
305 306
306#endif // KOAGENDA_H 307#endif // KOAGENDA_H
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 53bbe28..b5a59af 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1459,771 +1459,774 @@ void KOMonthView::switchView()
1459 mWidStack->raiseWidget( mWeekView ); 1459 mWidStack->raiseWidget( mWeekView );
1460 else 1460 else
1461 mWidStack->raiseWidget( mMonthView ); 1461 mWidStack->raiseWidget( mMonthView );
1462 clPending = false; 1462 clPending = false;
1463} 1463}
1464 1464
1465int KOMonthView::maxDatesHint() 1465int KOMonthView::maxDatesHint()
1466{ 1466{
1467 return mNumCells; 1467 return mNumCells;
1468} 1468}
1469 1469
1470int KOMonthView::currentDateCount() 1470int KOMonthView::currentDateCount()
1471{ 1471{
1472 return mNumCells; 1472 return mNumCells;
1473} 1473}
1474 1474
1475QPtrList<Incidence> KOMonthView::selectedIncidences() 1475QPtrList<Incidence> KOMonthView::selectedIncidences()
1476{ 1476{
1477 QPtrList<Incidence> selected; 1477 QPtrList<Incidence> selected;
1478 1478
1479 if ( mSelectedCell ) { 1479 if ( mSelectedCell ) {
1480 Incidence *incidence = mSelectedCell->selectedIncidence(); 1480 Incidence *incidence = mSelectedCell->selectedIncidence();
1481 if ( incidence ) selected.append( incidence ); 1481 if ( incidence ) selected.append( incidence );
1482 } 1482 }
1483 1483
1484 return selected; 1484 return selected;
1485} 1485}
1486 1486
1487DateList KOMonthView::selectedDates() 1487DateList KOMonthView::selectedDates()
1488{ 1488{
1489 DateList selected; 1489 DateList selected;
1490 1490
1491 if ( mSelectedCell ) { 1491 if ( mSelectedCell ) {
1492 QDate qd = mSelectedCell->selectedIncidenceDate(); 1492 QDate qd = mSelectedCell->selectedIncidenceDate();
1493 if ( qd.isValid() ) selected.append( qd ); 1493 if ( qd.isValid() ) selected.append( qd );
1494 } 1494 }
1495 1495
1496 return selected; 1496 return selected;
1497} 1497}
1498#if 0 1498#if 0
1499void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1499void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1500 const QDate &td) 1500 const QDate &td)
1501{ 1501{
1502#ifndef KORG_NOPRINTER 1502#ifndef KORG_NOPRINTER
1503 calPrinter->preview(CalPrinter::Month, fd, td); 1503 calPrinter->preview(CalPrinter::Month, fd, td);
1504#endif 1504#endif
1505} 1505}
1506#endif 1506#endif
1507void KOMonthView::updateConfig() 1507void KOMonthView::updateConfig()
1508{ 1508{
1509 1509
1510 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1510 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1511 1511
1512 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1512 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1513 mWeekStartsMonday = true; 1513 mWeekStartsMonday = true;
1514 } 1514 }
1515 QFontMetrics fontmetric(mDayLabels[0]->font()); 1515 QFontMetrics fontmetric(mDayLabels[0]->font());
1516 mWidthLongDayLabel = 0; 1516 mWidthLongDayLabel = 0;
1517 1517
1518 for (int i = 0; i < 7; i++) { 1518 for (int i = 0; i < 7; i++) {
1519 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1519 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1520 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1520 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1521 } 1521 }
1522 bool temp = mShowSatSunComp ; 1522 bool temp = mShowSatSunComp ;
1523 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1523 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1524 if ( ! mShowWeekView ) { 1524 if ( ! mShowWeekView ) {
1525 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1525 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1526 computeLayout(); 1526 computeLayout();
1527 } else 1527 } else
1528 doComputeLayoutWeek(); 1528 doComputeLayoutWeek();
1529 updateDayLabels(); 1529 updateDayLabels();
1530 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1530 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1531 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1531 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1532 //resizeEvent( 0 ); 1532 //resizeEvent( 0 );
1533 for (uint i = 0; i < mCells.count(); ++i) { 1533 for (uint i = 0; i < mCells.count(); ++i) {
1534 mCells[i]->updateConfig(); 1534 mCells[i]->updateConfig();
1535 } 1535 }
1536 1536
1537 for (uint i = 0; i < mCellsW.count(); ++i) { 1537 for (uint i = 0; i < mCellsW.count(); ++i) {
1538 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1538 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1539 } 1539 }
1540#ifdef DESKTOP_VERSION 1540#ifdef DESKTOP_VERSION
1541 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1541 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1542#endif 1542#endif
1543 updateView(); 1543 updateView();
1544} 1544}
1545 1545
1546void KOMonthView::updateDayLabels() 1546void KOMonthView::updateDayLabels()
1547{ 1547{
1548 1548
1549 QPtrVector<QLabel> *mDayLabelsT; 1549 QPtrVector<QLabel> *mDayLabelsT;
1550 1550
1551 mDayLabelsT = &mDayLabelsW; 1551 mDayLabelsT = &mDayLabelsW;
1552 for (int i = 0; i < 7; i++) { 1552 for (int i = 0; i < 7; i++) {
1553 { 1553 {
1554 bool show = mShortDayLabelsW; 1554 bool show = mShortDayLabelsW;
1555 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1555 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1556 show = true; 1556 show = true;
1557 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1557 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1558 } 1558 }
1559 } 1559 }
1560 mDayLabelsT = &mDayLabels; 1560 mDayLabelsT = &mDayLabels;
1561 for (int i = 0; i < 7; i++) { 1561 for (int i = 0; i < 7; i++) {
1562 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1562 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1563 bool show = mShortDayLabelsM; 1563 bool show = mShortDayLabelsM;
1564 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1564 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1565 show = true; 1565 show = true;
1566 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1566 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1567 } else { 1567 } else {
1568 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1568 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1569 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1569 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1570 1570
1571 } 1571 }
1572 } 1572 }
1573 1573
1574} 1574}
1575 1575
1576void KOMonthView::clearList() 1576void KOMonthView::clearList()
1577{ 1577{
1578 unsigned int i; 1578 unsigned int i;
1579 for( i = 0; i < mCells.size(); ++i ) { 1579 for( i = 0; i < mCells.size(); ++i ) {
1580 mCells[i]->clear(); 1580 mCells[i]->clear();
1581 } 1581 }
1582 for( i = 0; i < mCellsW.size(); ++i ) { 1582 for( i = 0; i < mCellsW.size(); ++i ) {
1583 mCellsW[i]->clear(); 1583 mCellsW[i]->clear();
1584 } 1584 }
1585} 1585}
1586void KOMonthView::showDates(const QDate &start, const QDate &) 1586void KOMonthView::showDates(const QDate &start, const QDate &)
1587{ 1587{
1588 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1588 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1589 1589
1590 QPtrVector<MonthViewCell> *cells; 1590 QPtrVector<MonthViewCell> *cells;
1591 QPtrVector<QLabel> *dayLabels; 1591 QPtrVector<QLabel> *dayLabels;
1592 QPtrVector<KOWeekButton> *weekLabels; 1592 QPtrVector<KOWeekButton> *weekLabels;
1593 uint weekNum = 6; 1593 uint weekNum = 6;
1594 mStartDate = start; 1594 mStartDate = start;
1595 if ( mShowWeekView ) { 1595 if ( mShowWeekView ) {
1596 weekNum = 1; 1596 weekNum = 1;
1597 cells = &mCellsW; 1597 cells = &mCellsW;
1598 dayLabels = &mDayLabelsW; 1598 dayLabels = &mDayLabelsW;
1599 weekLabels = &mWeekLabelsW; 1599 weekLabels = &mWeekLabelsW;
1600 if ( !KGlobal::locale()->weekStartsMonday() ) { 1600 if ( !KGlobal::locale()->weekStartsMonday() ) {
1601 mStartDate = mStartDate.addDays( 1 ); 1601 mStartDate = mStartDate.addDays( 1 );
1602 } 1602 }
1603 } else { 1603 } else {
1604 cells = &mCells; 1604 cells = &mCells;
1605 dayLabels = &mDayLabels; 1605 dayLabels = &mDayLabels;
1606 weekLabels = &mWeekLabels; 1606 weekLabels = &mWeekLabels;
1607 } 1607 }
1608 1608
1609 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1609 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1610 1610
1611 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1611 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1612 mWeekStartsMonday = true; 1612 mWeekStartsMonday = true;
1613 } 1613 }
1614 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1614 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1615 1615
1616 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1616 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1617 mStartDate = mStartDate.addDays( -1 ); 1617 mStartDate = mStartDate.addDays( -1 );
1618 } 1618 }
1619 uint i; 1619 uint i;
1620 for( i = 0; i < (*cells).size(); ++i ) { 1620 for( i = 0; i < (*cells).size(); ++i ) {
1621 QDate date = mStartDate.addDays( i ); 1621 QDate date = mStartDate.addDays( i );
1622 (*cells)[i]->setDate( date ); 1622 (*cells)[i]->setDate( date );
1623 1623
1624#ifndef KORG_NOPLUGINS 1624#ifndef KORG_NOPLUGINS
1625 // add holiday, if present 1625 // add holiday, if present
1626 QString hstring(KOCore::self()->holiday(date)); 1626 QString hstring(KOCore::self()->holiday(date));
1627 (*cells)[i]->setHoliday( hstring ); 1627 (*cells)[i]->setHoliday( hstring );
1628#endif 1628#endif
1629 1629
1630 } 1630 }
1631 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1631 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1632 for( i = 0; i < weekNum; ++i ) { 1632 for( i = 0; i < weekNum; ++i ) {
1633 int wno; 1633 int wno;
1634 // remember, according to ISO 8601, the first week of the year is the 1634 // remember, according to ISO 8601, the first week of the year is the
1635 // first week that contains a thursday. Thus we must subtract off 4, 1635 // first week that contains a thursday. Thus we must subtract off 4,
1636 // not just 1. 1636 // not just 1.
1637 int dayOfYear = date.dayOfYear(); 1637 int dayOfYear = date.dayOfYear();
1638 if (dayOfYear % 7 != 0) 1638 if (dayOfYear % 7 != 0)
1639 wno = dayOfYear / 7 + 1; 1639 wno = dayOfYear / 7 + 1;
1640 else 1640 else
1641 wno =dayOfYear / 7; 1641 wno =dayOfYear / 7;
1642 (*weekLabels)[i]->setWeekNum( wno ); 1642 (*weekLabels)[i]->setWeekNum( wno );
1643 date = date.addDays( 7 ); 1643 date = date.addDays( 7 );
1644 } 1644 }
1645 updateView(); 1645 updateView();
1646} 1646}
1647 1647
1648void KOMonthView::showEvents(QPtrList<Event>) 1648void KOMonthView::showEvents(QPtrList<Event>)
1649{ 1649{
1650 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1650 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1651} 1651}
1652 1652
1653void KOMonthView::changeEventDisplay(Event *, int) 1653void KOMonthView::changeEventDisplay(Event *, int)
1654{ 1654{
1655 // this should be re-written to be much more efficient, but this 1655 // this should be re-written to be much more efficient, but this
1656 // quick-and-dirty-hack gets the job done for right now. 1656 // quick-and-dirty-hack gets the job done for right now.
1657 //qDebug("KOMonthView::changeEventDisplay "); 1657 //qDebug("KOMonthView::changeEventDisplay ");
1658 updateView(); 1658 updateView();
1659} 1659}
1660 1660
1661void KOMonthView::updateView() 1661void KOMonthView::updateView()
1662{ 1662{
1663 1663
1664 if ( !updatePossible ) 1664 if ( !updatePossible )
1665 return; 1665 return;
1666 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1666 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1667 //QTime ti; 1667 //QTime ti;
1668 //ti.start(); 1668 //ti.start();
1669 clearSelection(); 1669 clearSelection();
1670 QPtrVector<MonthViewCell> *cells; 1670 QPtrVector<MonthViewCell> *cells;
1671 if ( mShowWeekView ) { 1671 if ( mShowWeekView ) {
1672 cells = &mCellsW; 1672 cells = &mCellsW;
1673 } else { 1673 } else {
1674 cells = &mCells; 1674 cells = &mCells;
1675 } 1675 }
1676#if 1 1676#if 1
1677 int i; 1677 int i;
1678 int timeSpan = (*cells).size()-1; 1678 int timeSpan = (*cells).size()-1;
1679 if ( KOPrefs::instance()->mMonthViewWeek ) 1679 if ( KOPrefs::instance()->mMonthViewWeek )
1680 timeSpan = 6; 1680 timeSpan = 6;
1681 for( i = 0; i < timeSpan + 1; ++i ) { 1681 for( i = 0; i < timeSpan + 1; ++i ) {
1682 (*cells)[i]->startUpdateCell(); 1682 (*cells)[i]->startUpdateCell();
1683 } 1683 }
1684 1684
1685 QPtrList<Event> events = calendar()->events(); 1685 QPtrList<Event> events = calendar()->events();
1686 Event *event; 1686 Event *event;
1687 QDateTime dt; 1687 QDateTime dt;
1688 QDate endDate = mStartDate.addDays( timeSpan ); 1688 QDate endDate = mStartDate.addDays( timeSpan );
1689 for( event = events.first(); event; event = events.next() ) { // for event 1689 for( event = events.first(); event; event = events.next() ) { // for event
1690 if ( event->doesRecur() ) { 1690 if ( event->doesRecur() ) {
1691 bool last; 1691 bool last;
1692 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1692 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1693 QDateTime incidenceEnd; 1693 QDateTime incidenceEnd;
1694 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1694 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1695 bool invalid = false; 1695 bool invalid = false;
1696 while( true ) { 1696 while( true ) {
1697 if ( incidenceStart.isValid() ) { 1697 if ( incidenceStart.isValid() ) {
1698 incidenceEnd = incidenceStart.addDays( eventlen ); 1698 incidenceEnd = incidenceStart.addDays( eventlen );
1699 int st = incidenceStart.date().daysTo( endDate ); 1699 int st = incidenceStart.date().daysTo( endDate );
1700 if ( st >= 0 ) { // start before timeend 1700 if ( st >= 0 ) { // start before timeend
1701 int end = mStartDate.daysTo( incidenceEnd.date() ); 1701 int end = mStartDate.daysTo( incidenceEnd.date() );
1702 if ( end >= 0 ) { // end after timestart --- got one! 1702 if ( end >= 0 ) { // end after timestart --- got one!
1703 //normalize 1703 //normalize
1704 st = timeSpan - st; 1704 st = timeSpan - st;
1705 if ( st < 0 ) st = 0; 1705 if ( st < 0 ) st = 0;
1706 if ( end > timeSpan ) end = timeSpan; 1706 if ( end > timeSpan ) end = timeSpan;
1707 int iii; 1707 int iii;
1708 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1708 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1709 for ( iii = st;iii<= end;++iii) 1709 for ( iii = st;iii<= end;++iii)
1710 (*cells)[iii]->insertEvent( event ); 1710 (*cells)[iii]->insertEvent( event );
1711 } 1711 }
1712 } 1712 }
1713 } else { 1713 } else {
1714 if ( invalid ) 1714 if ( invalid )
1715 break; 1715 break;
1716 invalid = true; 1716 invalid = true;
1717 //qDebug("invalid %s", event->summary().latin1()); 1717 //qDebug("invalid %s", event->summary().latin1());
1718 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1718 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1719 } 1719 }
1720 if ( last ) 1720 if ( last )
1721 break; 1721 break;
1722 bool ok; 1722 bool ok;
1723 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1723 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1724 if ( ! ok ) 1724 if ( ! ok )
1725 break; 1725 break;
1726 if ( incidenceStart.date() > endDate ) 1726 if ( incidenceStart.date() > endDate )
1727 break; 1727 break;
1728 } 1728 }
1729 } else { // no recur 1729 } else { // no recur
1730 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1730 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1731 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1731 if ( event->uid().left(15) == QString("last-syncEvent-") )
1732 continue; 1732 continue;
1733 int st = event->dtStart().date().daysTo( endDate ); 1733 int st = event->dtStart().date().daysTo( endDate );
1734 if ( st >= 0 ) { // start before timeend 1734 if ( st >= 0 ) { // start before timeend
1735 int end = mStartDate.daysTo( event->dtEnd().date() ); 1735 int end = mStartDate.daysTo( event->dtEnd().date() );
1736 if ( end >= 0 ) { // end after timestart --- got one! 1736 if ( end >= 0 ) { // end after timestart --- got one!
1737 //normalize 1737 //normalize
1738 st = timeSpan - st; 1738 st = timeSpan - st;
1739 if ( st < 0 ) st = 0; 1739 if ( st < 0 ) st = 0;
1740 if ( end > timeSpan ) end = timeSpan; 1740 if ( end > timeSpan ) end = timeSpan;
1741 int iii; 1741 int iii;
1742 for ( iii = st;iii<= end;++iii) 1742 for ( iii = st;iii<= end;++iii)
1743 (*cells)[iii]->insertEvent( event ); 1743 (*cells)[iii]->insertEvent( event );
1744 } 1744 }
1745 } 1745 }
1746 } 1746 }
1747 } 1747 }
1748 // insert due todos 1748 // insert due todos
1749 QPtrList<Todo> todos = calendar()->todos( ); 1749 QPtrList<Todo> todos = calendar()->todos( );
1750 Todo *todo; 1750 Todo *todo;
1751 for(todo = todos.first(); todo; todo = todos.next()) { 1751 for(todo = todos.first(); todo; todo = todos.next()) {
1752 //insertTodo( todo ); 1752 //insertTodo( todo );
1753 if ( todo->hasDueDate() ) { 1753 if ( todo->hasDueDate() ) {
1754 int day = mStartDate.daysTo( todo->dtDue().date() ); 1754 int day = mStartDate.daysTo( todo->dtDue().date() );
1755 if ( day >= 0 && day < timeSpan + 1) { 1755 if ( day >= 0 && day < timeSpan + 1) {
1756 (*cells)[day]->insertTodo( todo ); 1756 (*cells)[day]->insertTodo( todo );
1757 } 1757 }
1758 } 1758 }
1759 } 1759 }
1760 1760
1761 for( i = 0; i < timeSpan+1; ++i ) { 1761 for( i = 0; i < timeSpan+1; ++i ) {
1762 (*cells)[i]->finishUpdateCell(); 1762 (*cells)[i]->finishUpdateCell();
1763 } 1763 }
1764 processSelectionChange(); 1764 processSelectionChange();
1765 //qApp->processEvents(); 1765 //qApp->processEvents();
1766 for( i = 0; i < timeSpan+1; ++i ) { 1766 for( i = 0; i < timeSpan+1; ++i ) {
1767 //(*cells)[i]->repaintfinishUpdateCell(); 1767 //(*cells)[i]->repaintfinishUpdateCell();
1768 QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); 1768 QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) );
1769 } 1769 }
1770 setKeyBFocus(); 1770 setKeyBFocus();
1771#else 1771#else
1772 // old code 1772 // old code
1773 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1773 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1774 int i; 1774 int i;
1775 for( i = 0; i < (*cells).count(); ++i ) { 1775 for( i = 0; i < (*cells).count(); ++i ) {
1776 (*cells)[i]->updateCell(); 1776 (*cells)[i]->updateCell();
1777 } 1777 }
1778 1778
1779 //qDebug("KOMonthView::updateView() "); 1779 //qDebug("KOMonthView::updateView() ");
1780 processSelectionChange(); 1780 processSelectionChange();
1781 // qDebug("---------------------------------------------------------------------+ "); 1781 // qDebug("---------------------------------------------------------------------+ ");
1782 (*cells)[0]->setFocus(); 1782 (*cells)[0]->setFocus();
1783#endif 1783#endif
1784 1784
1785 //qDebug("update time %d ", ti.elapsed()); 1785 //qDebug("update time %d ", ti.elapsed());
1786} 1786}
1787 1787
1788void KOMonthView::setKeyBoardFocus() 1788void KOMonthView::setKeyBoardFocus()
1789{ 1789{
1790 //qDebug("KOMonthView::setKeyBoardFocus() "); 1790 //qDebug("KOMonthView::setKeyBoardFocus() ");
1791 bool shootAgain = false; 1791 bool shootAgain = false;
1792 if ( mShowWeekView ) { 1792 if ( mShowWeekView ) {
1793 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1793 shootAgain = !mWeekLabelsW[1]->hasFocus();
1794 mWeekLabelsW[1]->setFocus(); 1794 mWeekLabelsW[1]->setFocus();
1795 } 1795 }
1796 else { 1796 else {
1797 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1797 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1798 mWeekLabels[mNumWeeks]->setFocus(); 1798 mWeekLabels[mNumWeeks]->setFocus();
1799 } 1799 }
1800 --mKBFcounter; 1800 --mKBFcounter;
1801 if ( shootAgain && mKBFcounter > 0 ) { 1801 if ( shootAgain && mKBFcounter > 0 ) {
1802 QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); 1802 QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) );
1803 } 1803 }
1804} 1804}
1805void KOMonthView::setKeyBFocus() 1805void KOMonthView::setKeyBFocus()
1806{ 1806{
1807 //qDebug("KOMonthView::setKeyBFocus() "); 1807 //qDebug("KOMonthView::setKeyBFocus() ");
1808 mKBFcounter = 10; 1808 mKBFcounter = 10;
1809 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1809 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1810} 1810}
1811void KOMonthView::resizeEvent(QResizeEvent * e) 1811void KOMonthView::resizeEvent(QResizeEvent * e)
1812{ 1812{
1813 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1813 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1814 if ( isVisible() ) { 1814 if ( isVisible() ) {
1815 //qDebug("KOMonthView::isVisible "); 1815 //qDebug("KOMonthView::isVisible ");
1816 slotComputeLayout(); 1816 slotComputeLayout();
1817 } else 1817 } else
1818 mComputeLayoutTimer->start( 100 ); 1818 mComputeLayoutTimer->start( 100 );
1819 if ( e ) 1819 if ( e )
1820 KOEventView::resizeEvent( e ); 1820 KOEventView::resizeEvent( e );
1821} 1821}
1822 1822
1823void KOMonthView::slotComputeLayout() 1823void KOMonthView::slotComputeLayout()
1824{ 1824{
1825 mComputeLayoutTimer->stop(); 1825 mComputeLayoutTimer->stop();
1826 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); 1826 //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
1827 computeLayout(); 1827 computeLayout();
1828 clPending = true; 1828 clPending = true;
1829 setKeyBFocus(); 1829 setKeyBFocus();
1830} 1830}
1831 1831
1832void KOMonthView::doComputeLayoutWeek() 1832void KOMonthView::doComputeLayoutWeek()
1833{ 1833{
1834 1834
1835 int daysToShow; 1835 int daysToShow;
1836 bool combinedSatSun = false; 1836 bool combinedSatSun = false;
1837 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1837 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1838 daysToShow = 6; 1838 daysToShow = 6;
1839 combinedSatSun = true; 1839 combinedSatSun = true;
1840 } 1840 }
1841 int wid = width();//e 1841 int wid = width();//e
1842 int hei = height()-1-mNavigatorBar->height(); 1842 int hei = height()-1-mNavigatorBar->height();
1843#ifdef DESKTOP_VERSION
1843 if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { 1844 if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) {
1844 daysToShow = 2; 1845 daysToShow = 2;
1845 } else { 1846 } else
1847#endif
1848 {
1846 if ( wid < hei ) 1849 if ( wid < hei )
1847 daysToShow = 2; 1850 daysToShow = 2;
1848 else 1851 else
1849 daysToShow = 3; 1852 daysToShow = 3;
1850 } 1853 }
1851 bool landscape = (daysToShow == 3); 1854 bool landscape = (daysToShow == 3);
1852 mShowSatSunComp = true; 1855 mShowSatSunComp = true;
1853 combinedSatSun = true; 1856 combinedSatSun = true;
1854 1857
1855 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1858 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1856 QFontMetrics fm ( mWeekLabels[0]->font() ); 1859 QFontMetrics fm ( mWeekLabels[0]->font() );
1857 int weeklabelwid = fm.width( "888" ); 1860 int weeklabelwid = fm.width( "888" );
1858 wid -= weeklabelwid; 1861 wid -= weeklabelwid;
1859 1862
1860 int colWid = wid / daysToShow; 1863 int colWid = wid / daysToShow;
1861 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1864 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1862 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1865 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1863 int colModulo = wid % daysToShow; 1866 int colModulo = wid % daysToShow;
1864 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1867 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1865 //qDebug("rowmod %d ", rowModulo); 1868 //qDebug("rowmod %d ", rowModulo);
1866 int i; 1869 int i;
1867 int x,y,w,h; 1870 int x,y,w,h;
1868 x= 0; 1871 x= 0;
1869 y= 0; 1872 y= 0;
1870 w = colWid; 1873 w = colWid;
1871 h = dayLabelHei ; 1874 h = dayLabelHei ;
1872 for ( i = 0; i < 7; i++) { 1875 for ( i = 0; i < 7; i++) {
1873 if ( i && !( i % daysToShow) && i < 6) { 1876 if ( i && !( i % daysToShow) && i < 6) {
1874 y += hei/(5-daysToShow); 1877 y += hei/(5-daysToShow);
1875 x = 0; 1878 x = 0;
1876 w = colWid; 1879 w = colWid;
1877 } 1880 }
1878 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1881 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1879 ++w; 1882 ++w;
1880 } 1883 }
1881 int xC,yC,wC,hC; 1884 int xC,yC,wC,hC;
1882 if ( i >= 5 ) { 1885 if ( i >= 5 ) {
1883 int wi = width() - x - weeklabelwid; 1886 int wi = width() - x - weeklabelwid;
1884 if ( i == 5 ) { 1887 if ( i == 5 ) {
1885 xC = x+weeklabelwid; 1888 xC = x+weeklabelwid;
1886 yC = y; 1889 yC = y;
1887 wC = wi/2+wi%2; 1890 wC = wi/2+wi%2;
1888 hC = h; 1891 hC = h;
1889 } else { 1892 } else {
1890 xC = x+weeklabelwid; 1893 xC = x+weeklabelwid;
1891 yC = y; 1894 yC = y;
1892 wC = wi; 1895 wC = wi;
1893 hC = h; 1896 hC = h;
1894 } 1897 }
1895 x = x - w + wi - (wi/2 ); 1898 x = x - w + wi - (wi/2 );
1896 } 1899 }
1897 else { 1900 else {
1898 int wi = w; 1901 int wi = w;
1899 if ( !(( i+1) % daysToShow)) { 1902 if ( !(( i+1) % daysToShow)) {
1900 wi = width() - x - weeklabelwid; 1903 wi = width() - x - weeklabelwid;
1901 } 1904 }
1902 xC = x+weeklabelwid; 1905 xC = x+weeklabelwid;
1903 yC = y; 1906 yC = y;
1904 wC = wi; 1907 wC = wi;
1905 hC = h; 1908 hC = h;
1906 } 1909 }
1907 mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC); 1910 mDayLabelsW[mapWeekLayout(i,landscape)]->setGeometry( xC,yC,wC,hC);
1908 1911
1909 1912
1910 x += w; 1913 x += w;
1911 } 1914 }
1912 x= 0; 1915 x= 0;
1913 y= dayLabelHei; 1916 y= dayLabelHei;
1914 w = colWid; 1917 w = colWid;
1915 h = cellHei; 1918 h = cellHei;
1916 int max = 0; 1919 int max = 0;
1917 int w_count = mCellsW.count(); 1920 int w_count = mCellsW.count();
1918 for ( i = 0; i < w_count; ++i) { 1921 for ( i = 0; i < w_count; ++i) {
1919 if ( i > 6 ) { 1922 if ( i > 6 ) {
1920 mCellsW[i]->hide(); 1923 mCellsW[i]->hide();
1921 continue; 1924 continue;
1922 } 1925 }
1923 1926
1924 w = colWid; 1927 w = colWid;
1925 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1928 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1926 ++w; 1929 ++w;
1927 } 1930 }
1928 if ( i == (daysToShow-1-rowModulo)*7) 1931 if ( i == (daysToShow-1-rowModulo)*7)
1929 ++h; 1932 ++h;
1930 1933
1931 int xC,yC,wC,hC; 1934 int xC,yC,wC,hC;
1932 if ( i >= 5 ) { 1935 if ( i >= 5 ) {
1933 if ( i ==5 ) { 1936 if ( i ==5 ) {
1934 max = h/2; 1937 max = h/2;
1935 xC = x+weeklabelwid; 1938 xC = x+weeklabelwid;
1936 yC = y; 1939 yC = y;
1937 wC = w; 1940 wC = w;
1938 hC = max; 1941 hC = max;
1939 x -= w ;y += h/2; 1942 x -= w ;y += h/2;
1940 } else { 1943 } else {
1941 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1944 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1942 ++w; 1945 ++w;
1943 } 1946 }
1944 max = h-h/2; 1947 max = h-h/2;
1945 xC = x+weeklabelwid; 1948 xC = x+weeklabelwid;
1946 yC = y; 1949 yC = y;
1947 wC = w; 1950 wC = w;
1948 hC = max; 1951 hC = max;
1949 y -= h/2; 1952 y -= h/2;
1950 } 1953 }
1951 } else { 1954 } else {
1952 max = h; 1955 max = h;
1953 xC = x+weeklabelwid; 1956 xC = x+weeklabelwid;
1954 yC = y; 1957 yC = y;
1955 wC = w; 1958 wC = w;
1956 hC = h; 1959 hC = h;
1957 } 1960 }
1958 mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC ); 1961 mCellsW[mapWeekLayout(i,landscape)]->setGeometry ( xC,yC,wC,hC );
1959 1962
1960 1963
1961 x += w; 1964 x += w;
1962 if ( x + w/2 > wid ) { 1965 if ( x + w/2 > wid ) {
1963 x = 0; 1966 x = 0;
1964 y += h+dayLabelHei ; 1967 y += h+dayLabelHei ;
1965 } 1968 }
1966 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 ); 1969 //mCellsW[i]->dateLabel()->setMaximumHeight( max - mCellsW[i]->lineWidth()*2 );
1967 } 1970 }
1968 y= dayLabelHei; 1971 y= dayLabelHei;
1969 h = cellHei ; 1972 h = cellHei ;
1970 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1973 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1971 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1974 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1972 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1975 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1973 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1976 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1974 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1977 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1975 updateDayLabels(); 1978 updateDayLabels();
1976 //bool forceUpdate = !updatePossible; 1979 //bool forceUpdate = !updatePossible;
1977 updatePossible = true; 1980 updatePossible = true;
1978 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1981 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1979 //if ( forceUpdate ) 1982 //if ( forceUpdate )
1980 // updateView(); 1983 // updateView();
1981} 1984}
1982void KOMonthView::computeLayoutWeek() 1985void KOMonthView::computeLayoutWeek()
1983{ 1986{
1984 static int lastWid = 0; 1987 static int lastWid = 0;
1985 static int lastHei = 0; 1988 static int lastHei = 0;
1986 int tWid = topLevelWidget()->size().width(); 1989 int tWid = topLevelWidget()->size().width();
1987 int tHei = topLevelWidget()->size().height(); 1990 int tHei = topLevelWidget()->size().height();
1988 int wid = width();//e 1991 int wid = width();//e
1989 int hei = height()-1-mNavigatorBar->height(); 1992 int hei = height()-1-mNavigatorBar->height();
1990 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1993 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1991 return; 1994 return;
1992 1995
1993 if ( lastWid == width() && lastHei == height() ) { 1996 if ( lastWid == width() && lastHei == height() ) {
1994 //qDebug("KOListWeekView::No compute layout needed "); 1997 //qDebug("KOListWeekView::No compute layout needed ");
1995 return; 1998 return;
1996 } 1999 }
1997 lastWid = width(); 2000 lastWid = width();
1998 lastHei = height(); 2001 lastHei = height();
1999 doComputeLayoutWeek(); 2002 doComputeLayoutWeek();
2000} 2003}
2001int KOMonthView::mapWeekLayout( int index, bool landscape ) 2004int KOMonthView::mapWeekLayout( int index, bool landscape )
2002{ 2005{
2003 if ( KOPrefs::instance()->mMonthViewWeekRowlayout ) 2006 if ( KOPrefs::instance()->mMonthViewWeekRowlayout )
2004 return index; 2007 return index;
2005 int diff = 0; 2008 int diff = 0;
2006 if ( !landscape ) diff = 1; 2009 if ( !landscape ) diff = 1;
2007 switch( index ) { 2010 switch( index ) {
2008 case 0: 2011 case 0:
2009 case 5: 2012 case 5:
2010 case 6: 2013 case 6:
2011 return index; 2014 return index;
2012 break; 2015 break;
2013 case 1: 2016 case 1:
2014 return 2+diff; 2017 return 2+diff;
2015 break; 2018 break;
2016 case 2: 2019 case 2:
2017 return 4-(3*diff); 2020 return 4-(3*diff);
2018 break; 2021 break;
2019 case 3: 2022 case 3:
2020 return 1+(3*diff); 2023 return 1+(3*diff);
2021 break; 2024 break;
2022 case 4: 2025 case 4:
2023 return 3-diff; 2026 return 3-diff;
2024 break; 2027 break;
2025 default: 2028 default:
2026 qDebug("KO: Error in mapping week layout "); 2029 qDebug("KO: Error in mapping week layout ");
2027 return index; 2030 return index;
2028 break; 2031 break;
2029 } 2032 }
2030 return index; 2033 return index;
2031} 2034}
2032void KOMonthView::computeLayout() 2035void KOMonthView::computeLayout()
2033{ 2036{
2034 2037
2035 2038
2036 static int lastWid = 0; 2039 static int lastWid = 0;
2037 static int lastHei = 0; 2040 static int lastHei = 0;
2038 2041
2039 if ( mShowWeekView ){ 2042 if ( mShowWeekView ){
2040 computeLayoutWeek(); 2043 computeLayoutWeek();
2041 return; 2044 return;
2042 } 2045 }
2043 int daysToShow = 7; 2046 int daysToShow = 7;
2044 bool combinedSatSun = false; 2047 bool combinedSatSun = false;
2045 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 2048 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
2046 daysToShow = 6; 2049 daysToShow = 6;
2047 combinedSatSun = true; 2050 combinedSatSun = true;
2048 } 2051 }
2049 int tWid = topLevelWidget()->size().width(); 2052 int tWid = topLevelWidget()->size().width();
2050 int tHei = topLevelWidget()->size().height(); 2053 int tHei = topLevelWidget()->size().height();
2051 2054
2052 int wid = width();//e 2055 int wid = width();//e
2053 int hei = height()-1-mNavigatorBar->height(); 2056 int hei = height()-1-mNavigatorBar->height();
2054 2057
2055 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 2058 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
2056 return; 2059 return;
2057 } 2060 }
2058 if ( lastWid == width() && lastHei == height() ){ 2061 if ( lastWid == width() && lastHei == height() ){
2059 //qDebug("KOMonthview::No compute layout needed "); 2062 //qDebug("KOMonthview::No compute layout needed ");
2060 return; 2063 return;
2061 } 2064 }
2062 2065
2063 lastWid = width(); 2066 lastWid = width();
2064 lastHei = height(); 2067 lastHei = height();
2065 //qDebug("KOMonthView::computeLayout() MMM ------------------- "); 2068 //qDebug("KOMonthView::computeLayout() MMM ------------------- ");
2066 QFontMetrics fm ( mWeekLabels[0]->font() ); 2069 QFontMetrics fm ( mWeekLabels[0]->font() );
2067 int weeklabelwid = fm.width( "888" ); 2070 int weeklabelwid = fm.width( "888" );
2068 wid -= weeklabelwid; 2071 wid -= weeklabelwid;
2069 2072
2070 int colWid = wid / daysToShow; 2073 int colWid = wid / daysToShow;
2071 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 2074 int dayLabelHei = mDayLabels[0]->sizeHint().height();
2072 int cellHei = (hei - dayLabelHei) /6; 2075 int cellHei = (hei - dayLabelHei) /6;
2073 int colModulo = wid % daysToShow; 2076 int colModulo = wid % daysToShow;
2074 int rowModulo = (hei- dayLabelHei) % 6; 2077 int rowModulo = (hei- dayLabelHei) % 6;
2075 //qDebug("rowmod %d ", rowModulo); 2078 //qDebug("rowmod %d ", rowModulo);
2076 int i; 2079 int i;
2077 int x,y,w,h; 2080 int x,y,w,h;
2078 x= 0; 2081 x= 0;
2079 y= 0; 2082 y= 0;
2080 w = colWid; 2083 w = colWid;
2081 h = dayLabelHei ; 2084 h = dayLabelHei ;
2082 for ( i = 0; i < 7; i++) { 2085 for ( i = 0; i < 7; i++) {
2083 if ( i == daysToShow-colModulo ) 2086 if ( i == daysToShow-colModulo )
2084 ++w; 2087 ++w;
2085 if ( combinedSatSun ) { 2088 if ( combinedSatSun ) {
2086 if ( i >= daysToShow-1 ) { 2089 if ( i >= daysToShow-1 ) {
2087 2090
2088 if ( i == 6 ) 2091 if ( i == 6 )
2089 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h); 2092 mDayLabels[i]->setGeometry( x+weeklabelwid,y,width()-x-weeklabelwid,h);
2090 else 2093 else
2091 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 2094 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
2092 x -= w/2 ; 2095 x -= w/2 ;
2093 } 2096 }
2094 else 2097 else
2095 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 2098 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
2096 } else 2099 } else
2097 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 2100 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
2098 x += w; 2101 x += w;
2099 } 2102 }
2100 x= 0; 2103 x= 0;
2101 y= dayLabelHei; 2104 y= dayLabelHei;
2102 w = colWid; 2105 w = colWid;
2103 h = cellHei ; 2106 h = cellHei ;
2104 int max = 0; 2107 int max = 0;
2105 int mc_count = mCells.count(); 2108 int mc_count = mCells.count();
2106 for ( i = 0; i < mc_count; ++i) { 2109 for ( i = 0; i < mc_count; ++i) {
2107 //qDebug("iii %d ", i); 2110 //qDebug("iii %d ", i);
2108 w = colWid; 2111 w = colWid;
2109 if ( ((i) % 7) >= 7-colModulo ) { 2112 if ( ((i) % 7) >= 7-colModulo ) {
2110 ++w; 2113 ++w;
2111 } 2114 }
2112 if ( i == (6-rowModulo)*7) 2115 if ( i == (6-rowModulo)*7)
2113 ++h; 2116 ++h;
2114 if ( combinedSatSun ) { 2117 if ( combinedSatSun ) {
2115 if ( (i)%7 >= daysToShow-1 ) { 2118 if ( (i)%7 >= daysToShow-1 ) {
2116 if ( (i)%7 == daysToShow-1 ) { 2119 if ( (i)%7 == daysToShow-1 ) {
2117 w = width()-x-weeklabelwid; 2120 w = width()-x-weeklabelwid;
2118 max = h/2; 2121 max = h/2;
2119 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 2122 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
2120 x -= w ;y += h/2; 2123 x -= w ;y += h/2;
2121 } else { 2124 } else {
2122 w = width()-x-weeklabelwid; 2125 w = width()-x-weeklabelwid;
2123 max = h-h/2; 2126 max = h-h/2;
2124 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max ); 2127 mCells[i]->setGeometry ( x+weeklabelwid,y,w,max );
2125 y -= h/2; 2128 y -= h/2;
2126 } 2129 }
2127 } else { 2130 } else {
2128 max = h; 2131 max = h;
2129 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 2132 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
2130 } 2133 }
2131 2134
2132 } 2135 }
2133 else { 2136 else {
2134 max = h; 2137 max = h;
2135 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 2138 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
2136 } 2139 }
2137 x += w; 2140 x += w;
2138 if ( x + w/2 > wid ) { 2141 if ( x + w/2 > wid ) {
2139 x = 0; 2142 x = 0;
2140 y += h; 2143 y += h;
2141 } 2144 }
2142 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 ); 2145 //mCells[i]->dateLabel()->setMaximumHeight( max- mCells[i]->lineWidth()*2 );
2143 } 2146 }
2144 y= dayLabelHei; 2147 y= dayLabelHei;
2145 h = cellHei ; 2148 h = cellHei ;
2146 for ( i = 0; i < 6; i++) { 2149 for ( i = 0; i < 6; i++) {
2147 if ( i == (6-rowModulo)) 2150 if ( i == (6-rowModulo))
2148 ++h; 2151 ++h;
2149 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 2152 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
2150 y += h; 2153 y += h;
2151 } 2154 }
2152 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 2155 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
2153 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 2156 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
2154 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 2157 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
2155 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 2158 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
2156 updateDayLabels(); 2159 updateDayLabels();
2157 //bool forceUpdate = !updatePossible; 2160 //bool forceUpdate = !updatePossible;
2158 updatePossible = true; 2161 updatePossible = true;
2159 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 2162 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
2160} 2163}
2161 2164
2162void KOMonthView::showContextMenu( Incidence *incidence ) 2165void KOMonthView::showContextMenu( Incidence *incidence )
2163{ 2166{
2164 if( incidence ) 2167 if( incidence )
2165 mContextMenu->showIncidencePopup(incidence); 2168 mContextMenu->showIncidencePopup(incidence);
2166 else { 2169 else {
2167 //qDebug("KOMonthView::showContextMenu "); 2170 //qDebug("KOMonthView::showContextMenu ");
2168 mNewItemMenu->popup(QCursor::pos()); 2171 mNewItemMenu->popup(QCursor::pos());
2169 } 2172 }
2170 /* 2173 /*
2171 if( incidence && incidence->typeID() == eventID ) { 2174 if( incidence && incidence->typeID() == eventID ) {
2172 Event *event = static_cast<Event *>(incidence); 2175 Event *event = static_cast<Event *>(incidence);
2173 mContextMenu->showEventPopup(event); 2176 mContextMenu->showEventPopup(event);
2174 } else { 2177 } else {
2175 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 2178 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
2176 } 2179 }
2177 */ 2180 */
2178} 2181}
2179MonthViewCell * KOMonthView::selectedCell( ) 2182MonthViewCell * KOMonthView::selectedCell( )
2180{ 2183{
2181 return mSelectedCell; 2184 return mSelectedCell;
2182} 2185}
2183void KOMonthView::setSelectedCell( MonthViewCell *cell ) 2186void KOMonthView::setSelectedCell( MonthViewCell *cell )
2184{ 2187{
2185 //qDebug("KOMonthView::setSelectedCell %d", cell); 2188 //qDebug("KOMonthView::setSelectedCell %d", cell);
2186 if ( mSelectedCell && mSelectedCell != cell ) { 2189 if ( mSelectedCell && mSelectedCell != cell ) {
2187 MonthViewCell * mvc = mSelectedCell; 2190 MonthViewCell * mvc = mSelectedCell;
2188 mSelectedCell = cell; 2191 mSelectedCell = cell;
2189 mvc->deselect(); 2192 mvc->deselect();
2190 } else 2193 } else
2191 mSelectedCell = cell; 2194 mSelectedCell = cell;
2192 // if ( mSelectedCell ) 2195 // if ( mSelectedCell )
2193 // mSelectedCell->select(); 2196 // mSelectedCell->select();
2194 if ( !mSelectedCell ) 2197 if ( !mSelectedCell )
2195 emit incidenceSelected( 0 ); 2198 emit incidenceSelected( 0 );
2196 else 2199 else
2197 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 2200 emit incidenceSelected( mSelectedCell->selectedIncidence() );
2198} 2201}
2199 2202
2200void KOMonthView::processSelectionChange() 2203void KOMonthView::processSelectionChange()
2201{ 2204{
2202 QPtrList<Incidence> incidences = selectedIncidences(); 2205 QPtrList<Incidence> incidences = selectedIncidences();
2203 if (incidences.count() > 0) { 2206 if (incidences.count() > 0) {
2204 emit incidenceSelected( incidences.first() ); 2207 emit incidenceSelected( incidences.first() );
2205 } else { 2208 } else {
2206 emit incidenceSelected( 0 ); 2209 emit incidenceSelected( 0 );
2207 clearSelection(); 2210 clearSelection();
2208 } 2211 }
2209} 2212}
2210 2213
2211void KOMonthView::clearSelection() 2214void KOMonthView::clearSelection()
2212{ 2215{
2213 if ( mSelectedCell ) { 2216 if ( mSelectedCell ) {
2214 mSelectedCell->deselect(); 2217 mSelectedCell->deselect();
2215 mSelectedCell = 0; 2218 mSelectedCell = 0;
2216 } 2219 }
2217} 2220}
2218 2221
2219void KOMonthView::keyReleaseEvent ( QKeyEvent * e) 2222void KOMonthView::keyReleaseEvent ( QKeyEvent * e)
2220{ 2223{
2221 if ( !e->isAutoRepeat() ) { 2224 if ( !e->isAutoRepeat() ) {
2222 mFlagKeyPressed = false; 2225 mFlagKeyPressed = false;
2223 } 2226 }
2224} 2227}
2225 2228
2226void KOMonthView::keyPressEvent ( QKeyEvent * e ) 2229void KOMonthView::keyPressEvent ( QKeyEvent * e )
2227{ 2230{
2228 2231
2229 qApp->processEvents(); 2232 qApp->processEvents();