summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaview.cpp
Unidiff
Diffstat (limited to 'korganizer/koagendaview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp78
1 files changed, 45 insertions, 33 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 6e65a03..87993ae 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,564 +1,576 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <q3hbox.h>
25#include <qvbox.h> 25#include <q3vbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <q3frame.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <q3popupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39#include <QDesktopWidget>
40//Added by qt3to4:
41#include <QResizeEvent>
42#include <QPixmap>
43#include <QMouseEvent>
44#include <Q3GridLayout>
45#include <Q3ValueList>
46#include <QKeyEvent>
47#include <Q3HBoxLayout>
48#include <Q3VBoxLayout>
49#include <QPaintEvent>
50#include <Q3PtrList>
39 51
40#include <kapplication.h> 52#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 53#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 54#include <kdebug.h>
43#include <kstandarddirs.h> 55#include <kstandarddirs.h>
44#include <kiconloader.h> 56#include <kiconloader.h>
45#include <klocale.h> 57#include <klocale.h>
46#include <kconfig.h> 58#include <kconfig.h>
47#include <kglobal.h> 59#include <kglobal.h>
48#include "calendarview.h" 60#include "calendarview.h"
49#include "koviewmanager.h" 61#include "koviewmanager.h"
50 62
51#include <libkcal/calendar.h> 63#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 64#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 65#include <libkcal/dndfactory.h>
54 66
55#include <kcalendarsystem.h> 67#include <kcalendarsystem.h>
56 68
57#include "koglobals.h" 69#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 70#ifndef KORG_NOPLUGINS
59#include "kocore.h" 71#include "kocore.h"
60#endif 72#endif
61#include "koprefs.h" 73#include "koprefs.h"
62#include "koagenda.h" 74#include "koagenda.h"
63#include "koagendaitem.h" 75#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 76#ifndef KORG_NOPRINTER
65#include "calprinter.h" 77#include "calprinter.h"
66#endif 78#endif
67 79
68#include "koagendaview.h" 80#include "koagendaview.h"
69//#include "koagendaview.moc" 81//#include "koagendaview.moc"
70 82
71//extern bool globalFlagBlockPainting; 83//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 84extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 85extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 86extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 87extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 88extern int globalFlagBlockLabel;
77using namespace KOrg; 89using namespace KOrg;
78 90
79#define IDLETIMEOUT 45 91#define IDLETIMEOUT 45
80 92
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 93TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,Qt::WFlags f) :
82 QScrollView(parent,name,f) 94 Q3ScrollView(parent,name,f)
83{ 95{
84 myPix.resize( 1, 1 ); 96 myPix.resize( 1, 1 );
85 mRows = rows; 97 mRows = rows;
86 98
87 mRedrawNeeded = true; 99 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 100 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 101 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 102
91 enableClipper(true); 103 enableClipper(true);
92 104
93 setHScrollBarMode(AlwaysOff); 105 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 106 setVScrollBarMode(AlwaysOff);
95 107
96 resizeContents(50,mRows * mCellHeight); 108 resizeContents(50,mRows * mCellHeight);
97 109
98 viewport()->setBackgroundMode( PaletteBackground ); 110 viewport()->setBackgroundMode( Qt::PaletteBackground );
99} 111}
100 112
101void TimeLabels::setCellHeight(int height) 113void TimeLabels::setCellHeight(int height)
102{ 114{
103 mCellHeight = height; 115 mCellHeight = height;
104} 116}
105 117
106/* 118/*
107 Optimization so that only the "dirty" portion of the scroll view 119 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 120 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 121*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 122void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 123{
112 124
113 cx = contentsX() + frameWidth()*2; 125 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 126 cw = contentsWidth() ;
115 // end of workaround 127 // end of workaround
116 128
117 int cell = ((int)(cy/mCellHeight)); 129 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 130 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 131 QFontMetrics fm = fontMetrics();
120 QString hour; 132 QString hour;
121 QString suffix = "am"; 133 QString suffix = "am";
122 int timeHeight = fm.ascent(); 134 int timeHeight = fm.ascent();
123 QFont nFont = font(); 135 QFont nFont = font();
124 p->setFont( font()); 136 p->setFont( font());
125 137
126 if (!KGlobal::locale()->use12Clock()) { 138 if (!KGlobal::locale()->use12Clock()) {
127 suffix = "00"; 139 suffix = "00";
128 } else 140 } else
129 if (cell > 11) suffix = "pm"; 141 if (cell > 11) suffix = "pm";
130 142
131 if ( timeHeight > mCellHeight ) { 143 if ( timeHeight > mCellHeight ) {
132 timeHeight = mCellHeight-1; 144 timeHeight = mCellHeight-1;
133 int pointS = nFont.pointSize(); 145 int pointS = nFont.pointSize();
134 while ( pointS > 4 ) { 146 while ( pointS > 4 ) {
135 nFont.setPointSize( pointS ); 147 nFont.setPointSize( pointS );
136 fm = QFontMetrics( nFont ); 148 fm = QFontMetrics( nFont );
137 if ( fm.ascent() < mCellHeight ) 149 if ( fm.ascent() < mCellHeight )
138 break; 150 break;
139 -- pointS; 151 -- pointS;
140 } 152 }
141 fm = QFontMetrics( nFont ); 153 fm = QFontMetrics( nFont );
142 timeHeight = fm.ascent(); 154 timeHeight = fm.ascent();
143 } 155 }
144 //timeHeight -= (timeHeight/4-2); 156 //timeHeight -= (timeHeight/4-2);
145 QFont sFont = nFont; 157 QFont sFont = nFont;
146 sFont.setPointSize( sFont.pointSize()/2 ); 158 sFont.setPointSize( sFont.pointSize()/2 );
147 QFontMetrics fmS( sFont ); 159 QFontMetrics fmS( sFont );
148 int sHei = fmS.ascent() ; 160 int sHei = fmS.ascent() ;
149 //sHei -= (sHei/4-2); 161 //sHei -= (sHei/4-2);
150 int startW = mMiniWidth - frameWidth()-2 ; 162 int startW = mMiniWidth - frameWidth()-2 ;
151 int tw2 = fmS.width(suffix); 163 int tw2 = fmS.width(suffix);
152 timeHeight = (timeHeight-1) /2 -1; 164 timeHeight = (timeHeight-1) /2 -1;
153 //testline 165 //testline
154 //p->drawLine(0,0,0,contentsHeight()); 166 //p->drawLine(0,0,0,contentsHeight());
155 while (y < cy + ch+mCellHeight) { 167 while (y < cy + ch+mCellHeight) {
156 p->drawLine(startW-tw2+1 ,y,cw+2,y); 168 p->drawLine(startW-tw2+1 ,y,cw+2,y);
157 hour.setNum(cell); 169 hour.setNum(cell);
158 // handle 24h and am/pm time formats 170 // handle 24h and am/pm time formats
159 if (KGlobal::locale()->use12Clock()) { 171 if (KGlobal::locale()->use12Clock()) {
160 if (cell == 12) suffix = "pm"; 172 if (cell == 12) suffix = "pm";
161 if (cell == 0) hour.setNum(12); 173 if (cell == 0) hour.setNum(12);
162 if (cell > 12) hour.setNum(cell - 12); 174 if (cell > 12) hour.setNum(cell - 12);
163 } 175 }
164 176
165 // center and draw the time label 177 // center and draw the time label
166 int timeWidth = fm.width(hour); 178 int timeWidth = fm.width(hour);
167 int offset = startW - timeWidth - tw2 -1 ; 179 int offset = startW - timeWidth - tw2 -1 ;
168 p->setFont( nFont ); 180 p->setFont( nFont );
169 p->drawText( offset, y+ timeHeight, hour); 181 p->drawText( offset, y+ timeHeight, hour);
170 p->setFont( sFont ); 182 p->setFont( sFont );
171 offset = startW - tw2; 183 offset = startW - tw2;
172 p->drawText( offset, y -1, suffix); 184 p->drawText( offset, y -1, suffix);
173 185
174 // increment indices 186 // increment indices
175 y += mCellHeight; 187 y += mCellHeight;
176 cell++; 188 cell++;
177 } 189 }
178 190
179 191
180 192
181 193
182} 194}
183 195
184/** 196/**
185 Calculates the minimum width. 197 Calculates the minimum width.
186*/ 198*/
187int TimeLabels::minimumWidth() const 199int TimeLabels::minimumWidth() const
188{ 200{
189 return mMiniWidth; 201 return mMiniWidth;
190} 202}
191 203
192/** updates widget's internal state */ 204/** updates widget's internal state */
193void TimeLabels::updateConfig() 205void TimeLabels::updateConfig()
194{ 206{
195 mRedrawNeeded = true; 207 mRedrawNeeded = true;
196 // set the font 208 // set the font
197 // config->setGroup("Fonts"); 209 // config->setGroup("Fonts");
198 // QFont font = config->readFontEntry("TimeBar Font"); 210 // QFont font = config->readFontEntry("TimeBar Font");
199 setFont(KOPrefs::instance()->mTimeBarFont); 211 setFont(KOPrefs::instance()->mTimeBarFont);
200 QString test = "20"; 212 QString test = "20";
201 if (KGlobal::locale()->use12Clock()) 213 if (KGlobal::locale()->use12Clock())
202 test = "12"; 214 test = "12";
203 mMiniWidth = fontMetrics().width(test); 215 mMiniWidth = fontMetrics().width(test);
204 if (KGlobal::locale()->use12Clock()) 216 if (KGlobal::locale()->use12Clock())
205 test = "pm"; 217 test = "pm";
206 else { 218 else {
207 test = "00"; 219 test = "00";
208 } 220 }
209 QFont sFont = font(); 221 QFont sFont = font();
210 sFont.setPointSize( sFont.pointSize()/2 ); 222 sFont.setPointSize( sFont.pointSize()/2 );
211 QFontMetrics fmS( sFont ); 223 QFontMetrics fmS( sFont );
212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; 224 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 // update geometry restrictions based on new settings 225 // update geometry restrictions based on new settings
214 setFixedWidth( mMiniWidth ); 226 setFixedWidth( mMiniWidth );
215 227
216 // update HourSize 228 // update HourSize
217 mCellHeight = KOPrefs::instance()->mHourSize*4; 229 mCellHeight = KOPrefs::instance()->mHourSize*4;
218 resizeContents(mMiniWidth,mRows * mCellHeight+1); 230 resizeContents(mMiniWidth,mRows * mCellHeight+1);
219} 231}
220 232
221/** update time label positions */ 233/** update time label positions */
222void TimeLabels::positionChanged() 234void TimeLabels::positionChanged()
223{ 235{
224 int adjustment = mAgenda->contentsY(); 236 int adjustment = mAgenda->contentsY();
225 setContentsPos(0, adjustment); 237 setContentsPos(0, adjustment);
226} 238}
227 239
228/** */ 240/** */
229void TimeLabels::setAgenda(KOAgenda* agenda) 241void TimeLabels::setAgenda(KOAgenda* agenda)
230{ 242{
231 mAgenda = agenda; 243 mAgenda = agenda;
232} 244}
233 245
234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 246void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
235{ 247{
236 mMouseDownY = e->pos().y(); 248 mMouseDownY = e->pos().y();
237 mOrgCap = topLevelWidget()->caption(); 249 mOrgCap = topLevelWidget()->caption();
238} 250}
239 251
240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 252void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
241{ 253{
242 int diff = mMouseDownY - e->pos().y(); 254 int diff = mMouseDownY - e->pos().y();
243 if ( diff < 10 && diff > -10 ) 255 if ( diff < 10 && diff > -10 )
244 return; 256 return;
245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 257 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
246 if ( tSize < 4 ) 258 if ( tSize < 4 )
247 tSize = 4; 259 tSize = 4;
248 if ( tSize > 22 ) 260 if ( tSize > 22 )
249 tSize = 22; 261 tSize = 22;
250 tSize = (tSize-2)/2; 262 tSize = (tSize-2)/2;
251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 263 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
252 264
253} 265}
254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 266void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
255{ 267{
256 topLevelWidget()->setCaption( mOrgCap ); 268 topLevelWidget()->setCaption( mOrgCap );
257 int diff = mMouseDownY - e->pos().y(); 269 int diff = mMouseDownY - e->pos().y();
258 if ( diff < 10 && diff > -10 ) 270 if ( diff < 10 && diff > -10 )
259 return; 271 return;
260 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 272 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
261 if ( tSize < 4 ) 273 if ( tSize < 4 )
262 tSize = 4; 274 tSize = 4;
263 if ( tSize > 22 ) 275 if ( tSize > 22 )
264 tSize = 22; 276 tSize = 22;
265 tSize = (tSize/2)*2; 277 tSize = (tSize/2)*2;
266 if ( tSize == KOPrefs::instance()->mHourSize ) 278 if ( tSize == KOPrefs::instance()->mHourSize )
267 return; 279 return;
268 KOPrefs::instance()->mHourSize = tSize; 280 KOPrefs::instance()->mHourSize = tSize;
269 emit scaleChanged(); 281 emit scaleChanged();
270} 282}
271 283
272/** This is called in response to repaint() */ 284/** This is called in response to repaint() */
273void TimeLabels::paintEvent(QPaintEvent*) 285void TimeLabels::paintEvent(QPaintEvent*)
274{ 286{
275 287
276 // kdDebug() << "paintevent..." << endl; 288 // kdDebug() << "paintevent..." << endl;
277 // this is another hack! 289 // this is another hack!
278 // QPainter painter(this); 290 // QPainter painter(this);
279 //QString c 291 //QString c
280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 292 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
281} 293}
282 294
283//////////////////////////////////////////////////////////////////////////// 295////////////////////////////////////////////////////////////////////////////
284 296
285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 297EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
286 : QFrame(parent,name) 298 : Q3Frame(parent,name)
287{ 299{
288 mColumns = 1; 300 mColumns = 1;
289 mTopBox = 0; 301 mTopBox = 0;
290 mLocation = loc; 302 mLocation = loc;
291 mTopLayout = 0; 303 mTopLayout = 0;
292 mPaintWidget = 0; 304 mPaintWidget = 0;
293 mXOffset = 0; 305 mXOffset = 0;
294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 306 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
295 else mPixmap = SmallIcon("1downarrow"); 307 else mPixmap = SmallIcon("1downarrow");
296 mEnabled.resize(mColumns); 308 mEnabled.resize(mColumns);
297 mEnabled.fill( false ); 309 mEnabled.fill( false );
298 setMinimumHeight(mPixmap.height()); 310 setMinimumHeight(mPixmap.height());
299} 311}
300 312
301EventIndicator::~EventIndicator() 313EventIndicator::~EventIndicator()
302{ 314{
303} 315}
304 316
305void EventIndicator::drawContents(QPainter *p) 317void EventIndicator::drawContents(QPainter *p)
306{ 318{
307 319
308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 320 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
309 KDGanttSplitterHandle* han = 0; 321 KDGanttSplitterHandle* han = 0;
310 if ( mPaintWidget ) 322 if ( mPaintWidget )
311 han = mPaintWidget->firstHandle(); 323 han = mPaintWidget->firstHandle();
312 if ( ! han ) { 324 if ( ! han ) {
313 int i; 325 int i;
314 for(i=0;i<mColumns;++i) { 326 for(i=0;i<mColumns;++i) {
315 if (mEnabled[i]) { 327 if (mEnabled[i]) {
316 int cellWidth = contentsRect().right()/mColumns; 328 int cellWidth = contentsRect().right()/mColumns;
317 int xOffset = KOGlobals::self()->reverseLayout() ? 329 int xOffset = KOGlobals::self()->reverseLayout() ?
318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 330 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
319 i*cellWidth + (cellWidth -mPixmap.width()) /2; 331 i*cellWidth + (cellWidth -mPixmap.width()) /2;
320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 332 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
321 } 333 }
322 } 334 }
323 } else { 335 } else {
324 han->repaint(); 336 han->repaint();
325 //mPaintWidget->setBackgroundColor( red ); 337 //mPaintWidget->setBackgroundColor( red );
326 338
327 QPainter pa( han ); 339 QPainter pa( han );
328 int i; 340 int i;
329 bool setColor = false; 341 bool setColor = false;
330 for(i=0;i<mColumns;++i) { 342 for(i=0;i<mColumns;++i) {
331 if (mEnabled[i]) { 343 if (mEnabled[i]) {
332 setColor = true; 344 setColor = true;
333 345
334 int cellWidth = contentsRect().right()/mColumns; 346 int cellWidth = contentsRect().right()/mColumns;
335 int xOffset = KOGlobals::self()->reverseLayout() ? 347 int xOffset = KOGlobals::self()->reverseLayout() ?
336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 348 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
337 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 349 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 350 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
339 //qDebug("222draw pix %d ",xOffset ); 351 //qDebug("222draw pix %d ",xOffset );
340 352
341 } 353 }
342 354
343 } 355 }
344 pa.end(); 356 pa.end();
345 357
346 } 358 }
347} 359}
348 360
349void EventIndicator::setXOffset( int x ) 361void EventIndicator::setXOffset( int x )
350{ 362{
351 mXOffset = x; 363 mXOffset = x;
352} 364}
353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 365void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
354{ 366{
355 mPaintWidget = w; 367 mPaintWidget = w;
356 setMaximumHeight(0); 368 setMaximumHeight(0);
357 setMinimumHeight(0); 369 setMinimumHeight(0);
358} 370}
359void EventIndicator::changeColumns(int columns) 371void EventIndicator::changeColumns(int columns)
360{ 372{
361 mColumns = columns; 373 mColumns = columns;
362 mEnabled.resize(mColumns); 374 mEnabled.resize(mColumns);
363 375
364 update(); 376 update();
365} 377}
366 378
367void EventIndicator::enableColumn(int column, bool enable) 379void EventIndicator::enableColumn(int column, bool enable)
368{ 380{
369 mEnabled[column] = enable; 381 mEnabled[column] = enable;
370} 382}
371 383
372 384
373//////////////////////////////////////////////////////////////////////////// 385////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 386////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 387////////////////////////////////////////////////////////////////////////////
376 388
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 389KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 390 KOEventView (cal,parent,name)
379{ 391{
380 flag_blockfillAgenda = false; 392 flag_blockfillAgenda = false;
381 mBlockUpdating = true; 393 mBlockUpdating = true;
382 mStartHour = 8; 394 mStartHour = 8;
383 mSelectedDates.append(QDate::currentDate()); 395 mSelectedDates.append(QDate::currentDate());
384 396
385 mLayoutDayLabels = 0; 397 mLayoutDayLabels = 0;
386 mDayLabelsFrame = 0; 398 mDayLabelsFrame = 0;
387 mDayLabels = 0; 399 mDayLabels = 0;
388 bool isRTL = KOGlobals::self()->reverseLayout(); 400 bool isRTL = KOGlobals::self()->reverseLayout();
389 QPixmap expandPix; 401 QPixmap expandPix;
390 if ( KOPrefs::instance()->mVerticalScreen ) { 402 if ( KOPrefs::instance()->mVerticalScreen ) {
391 expandPix = SmallIcon( "1updownarrow" ); 403 expandPix = SmallIcon( "1updownarrow" );
392 } else { 404 } else {
393 expandPix = SmallIcon("1leftrightarrow" ); 405 expandPix = SmallIcon("1leftrightarrow" );
394 } 406 }
395 407
396 QBoxLayout *topLayout = new QVBoxLayout(this); 408 Q3BoxLayout *topLayout = new Q3VBoxLayout(this);
397 409
398 // Create day name labels for agenda columns 410 // Create day name labels for agenda columns
399 // Create agenda splitter 411 // Create agenda splitter
400 412
401 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 413 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
402 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 414 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
403 topLayout->addWidget( mSplitterAgenda ); 415 topLayout->addWidget( mSplitterAgenda );
404 mAllDayFrame = new QHBox(mSplitterAgenda); 416 mAllDayFrame = new Q3HBox(mSplitterAgenda);
405 mAllDayFrame->setFocusPolicy(NoFocus); 417 mAllDayFrame->setFocusPolicy(Qt::NoFocus);
406 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 418 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
407 agendaFrame->setFocusPolicy(NoFocus); 419 agendaFrame->setFocusPolicy(Qt::NoFocus);
408 420
409 // Create all-day agenda widget 421 // Create all-day agenda widget
410 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 422 mDummyAllDayLeft = new Q3VBox( mAllDayFrame );
411 423
412 mExpandButton = new QPushButton(mDummyAllDayLeft); 424 mExpandButton = new QPushButton(mDummyAllDayLeft);
413 mExpandButton->setPixmap( expandPix ); 425 mExpandButton->setPixmap( expandPix );
414 int widebut = mExpandButton->sizeHint().width()+4; 426 int widebut = mExpandButton->sizeHint().width()+4;
415 int heibut = mExpandButton->sizeHint().height()+4; 427 int heibut = mExpandButton->sizeHint().height()+4;
416 if ( heibut > widebut ) 428 if ( heibut > widebut )
417 widebut = heibut ; 429 widebut = heibut ;
418 430
419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 431 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
420 // QSizePolicy::Fixed ) ); 432 // QSizePolicy::Fixed ) );
421 mExpandButton->setFixedSize( widebut, widebut); 433 mExpandButton->setFixedSize( widebut, widebut);
422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 434 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
423 mExpandButton->setFocusPolicy(NoFocus); 435 mExpandButton->setFocusPolicy(Qt::NoFocus);
424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 436 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
425 mAllDayAgenda->setFocusPolicy(NoFocus); 437 mAllDayAgenda->setFocusPolicy(Qt::NoFocus);
426 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 438 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
427 439
428 // Create event context menu for all day agenda 440 // Create event context menu for all day agenda
429 //mAllDayAgendaPopup = eventPopup(); 441 //mAllDayAgendaPopup = eventPopup();
430 442
431 // Create agenda frame 443 // Create agenda frame
432 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 444 Q3GridLayout *agendaLayout = new Q3GridLayout(agendaFrame,4,3);
433 // QHBox *agendaFrame = new QHBox(splitterAgenda); 445 // QHBox *agendaFrame = new QHBox(splitterAgenda);
434 446
435 // create event indicator bars 447 // create event indicator bars
436 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 448 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
437#ifndef DESKTOP_VERSION 449#ifndef DESKTOP_VERSION
438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 450 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
439#endif 451#endif
440 mDayLabelsFrame = new QHBox(agendaFrame); 452 mDayLabelsFrame = new Q3HBox(agendaFrame);
441 //topLayout->addWidget(mDayLabelsFrame); 453 //topLayout->addWidget(mDayLabelsFrame);
442 mDayLabels = new QFrame (mDayLabelsFrame); 454 mDayLabels = new Q3Frame (mDayLabelsFrame);
443 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 455 mLayoutDayLabels = new Q3HBoxLayout(mDayLabels);
444 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 456 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
445 agendaLayout->addWidget(mEventIndicatorTop,1,1); 457 agendaLayout->addWidget(mEventIndicatorTop,1,1);
446 458
447 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 459 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
448 agendaFrame); 460 agendaFrame);
449 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 461 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
450 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 462 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
451 agendaLayout->addWidget(dummyAgendaRight,1,2); 463 agendaLayout->addWidget(dummyAgendaRight,1,2);
452 464
453 // Create time labels 465 // Create time labels
454 mTimeLabels = new TimeLabels(24,agendaFrame); 466 mTimeLabels = new TimeLabels(24,agendaFrame);
455 agendaLayout->addWidget(mTimeLabels,2,0); 467 agendaLayout->addWidget(mTimeLabels,2,0);
456 connect(mTimeLabels,SIGNAL( scaleChanged()), 468 connect(mTimeLabels,SIGNAL( scaleChanged()),
457 this,SLOT(updateConfig())); 469 this,SLOT(updateConfig()));
458 470
459 // Create agenda 471 // Create agenda
460 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 472 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
461 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 473 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
462 agendaLayout->setColStretch(1,1); 474 agendaLayout->setColStretch(1,1);
463 mAgenda->setFocusPolicy(NoFocus); 475 mAgenda->setFocusPolicy(Qt::NoFocus);
464 // Create event context menu for agenda 476 // Create event context menu for agenda
465 mAllAgendaPopup = eventPopup(); 477 mAllAgendaPopup = eventPopup();
466 478
467#if 0 479#if 0
468 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 480 mAllAgendaPopup->addAdditionalItem(QIcon(SmallIcon("bell")),
469 i18n("Toggle Alarm"),mAgenda, 481 i18n("Toggle Alarm"),mAgenda,
470 SLOT(popupAlarm()),true); 482 SLOT(popupAlarm()),true);
471 483
472#endif 484#endif
473 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 485 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
474 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 486 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
475 487
476 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 488 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
477 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 489 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
478 490
479 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)), 491 connect(mAllAgendaPopup,SIGNAL(categoryChanged(Incidence *)),
480 this,SLOT(categoryChanged(Incidence *))); 492 this,SLOT(categoryChanged(Incidence *)));
481 493
482 494
483 mAgenda->setPopup( mAllAgendaPopup ); 495 mAgenda->setPopup( mAllAgendaPopup );
484 mAllDayAgenda->setPopup( mAllAgendaPopup ); 496 mAllDayAgenda->setPopup( mAllAgendaPopup );
485 // make connections between dependent widgets 497 // make connections between dependent widgets
486 mTimeLabels->setAgenda(mAgenda); 498 mTimeLabels->setAgenda(mAgenda);
487 499
488 // Update widgets to reflect user preferences 500 // Update widgets to reflect user preferences
489 // updateConfig(); 501 // updateConfig();
490 502
491 // createDayLabels(); 503 // createDayLabels();
492 504
493 // these blank widgets make the All Day Event box line up with the agenda 505 // these blank widgets make the All Day Event box line up with the agenda
494 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 506 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
495 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 507 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
496 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 508 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
497 509
498 // Scrolling 510 // Scrolling
499 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 511 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
500 mTimeLabels, SLOT(positionChanged())); 512 mTimeLabels, SLOT(positionChanged()));
501 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 513 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
502 SLOT(setContentsPos(int))); 514 SLOT(setContentsPos(int)));
503 515
504 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 516 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
505 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 517 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
506 518
507 // Create/Show/Edit/Delete Event 519 // Create/Show/Edit/Delete Event
508 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 520 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
509 SLOT(newEvent(int,int))); 521 SLOT(newEvent(int,int)));
510 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 522 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
511 SLOT(newTodo(int,int))); 523 SLOT(newTodo(int,int)));
512 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 524 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
513 SLOT(newEvent(int,int,int,int))); 525 SLOT(newEvent(int,int,int,int)));
514 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 526 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
515 SLOT(newEventAllDay(int,int))); 527 SLOT(newEventAllDay(int,int)));
516 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 528 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
517 SLOT(newTodoAllDay(int,int))); 529 SLOT(newTodoAllDay(int,int)));
518 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 530 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
519 SLOT(newEventAllDay(int,int))); 531 SLOT(newEventAllDay(int,int)));
520 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 532 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
521 SLOT(newTimeSpanSelected(int,int,int,int))); 533 SLOT(newTimeSpanSelected(int,int,int,int)));
522 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 534 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
523 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 535 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
524 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 536 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
525 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 537 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
526 538
527 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 539 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
528 SIGNAL(editIncidenceSignal(Incidence *))); 540 SIGNAL(editIncidenceSignal(Incidence *)));
529 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 541 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
530 SIGNAL(editIncidenceSignal(Incidence *))); 542 SIGNAL(editIncidenceSignal(Incidence *)));
531 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 543 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
532 SIGNAL(showIncidenceSignal(Incidence *))); 544 SIGNAL(showIncidenceSignal(Incidence *)));
533 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 545 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
534 SIGNAL(showIncidenceSignal(Incidence *))); 546 SIGNAL(showIncidenceSignal(Incidence *)));
535 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 547 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
536 SIGNAL(deleteIncidenceSignal(Incidence *))); 548 SIGNAL(deleteIncidenceSignal(Incidence *)));
537 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 549 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
538 SIGNAL(deleteIncidenceSignal(Incidence *))); 550 SIGNAL(deleteIncidenceSignal(Incidence *)));
539 551
540 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 552 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
541 SLOT(updateEventDates(KOAgendaItem *, int ))); 553 SLOT(updateEventDates(KOAgendaItem *, int )));
542 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 554 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
543 SLOT(updateEventDates(KOAgendaItem *, int))); 555 SLOT(updateEventDates(KOAgendaItem *, int)));
544 556
545 // event indicator update 557 // event indicator update
546 connect(mAgenda,SIGNAL(lowerYChanged(int)), 558 connect(mAgenda,SIGNAL(lowerYChanged(int)),
547 SLOT(updateEventIndicatorTop(int))); 559 SLOT(updateEventIndicatorTop(int)));
548 connect(mAgenda,SIGNAL(upperYChanged(int)), 560 connect(mAgenda,SIGNAL(upperYChanged(int)),
549 SLOT(updateEventIndicatorBottom(int))); 561 SLOT(updateEventIndicatorBottom(int)));
550 // drag signals 562 // drag signals
551 /* 563 /*
552 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 564 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
553 SLOT(startDrag(Event *))); 565 SLOT(startDrag(Event *)));
554 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 566 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
555 SLOT(startDrag(Event *))); 567 SLOT(startDrag(Event *)));
556 */ 568 */
557 // synchronize selections 569 // synchronize selections
558 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 570 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
559 mAllDayAgenda, SLOT( deselectItem() ) ); 571 mAllDayAgenda, SLOT( deselectItem() ) );
560 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 572 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
561 mAgenda, SLOT( deselectItem() ) ); 573 mAgenda, SLOT( deselectItem() ) );
562 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 574 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
563 SIGNAL( incidenceSelected( Incidence * ) ) ); 575 SIGNAL( incidenceSelected( Incidence * ) ) );
564 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 576 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
@@ -825,575 +837,575 @@ void KOAgendaView::createDayLabels()
825 837
826 default: 838 default:
827 break; 839 break;
828 } 840 }
829 if ( oneday ) { 841 if ( oneday ) {
830 QString addString; 842 QString addString;
831 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 843 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
832 addString = i18n("Today"); 844 addString = i18n("Today");
833 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 845 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
834 addString = i18n("Tomorrow"); 846 addString = i18n("Tomorrow");
835 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 847 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
836 addString = i18n("Yesterday"); 848 addString = i18n("Yesterday");
837 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 849 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
838 addString = i18n("Day before yesterday"); 850 addString = i18n("Day before yesterday");
839 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 851 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
840 addString = i18n("Day after tomorrow"); 852 addString = i18n("Day after tomorrow");
841 if ( !addString.isEmpty() ) { 853 if ( !addString.isEmpty() ) {
842 if ( QApplication::desktop()->width() < 640 ) 854 if ( QApplication::desktop()->width() < 640 )
843 str = addString+", " + str; 855 str = addString+", " + str;
844 else 856 else
845 str = addString+", "+ KGlobal::locale()->formatDate( date, false); 857 str = addString+", "+ KGlobal::locale()->formatDate( date, false);
846 } else { 858 } else {
847 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 859 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
848 } 860 }
849 } 861 }
850 dayLabel->setText(str); 862 dayLabel->setText(str);
851 //dayLabel->setAlignment(QLabel::AlignHCenter); 863 //dayLabel->setAlignment(QLabel::AlignHCenter);
852 if (date == QDate::currentDate()) { 864 if (date == QDate::currentDate()) {
853 QFont bFont = dlf; 865 QFont bFont = dlf;
854 bFont.setBold( true ); 866 bFont.setBold( true );
855 dayLabel->setFont(bFont); 867 dayLabel->setFont(bFont);
856 } 868 }
857 //dayLayout->addWidget(dayLabel); 869 //dayLayout->addWidget(dayLabel);
858 870
859#ifndef KORG_NOPLUGINS 871#ifndef KORG_NOPLUGINS
860 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 872 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
861 CalendarDecoration *it; 873 CalendarDecoration *it;
862 for(it = cds.first(); it; it = cds.next()) { 874 for(it = cds.first(); it; it = cds.next()) {
863 QString text = it->shortText( date ); 875 QString text = it->shortText( date );
864 if ( !text.isEmpty() ) { 876 if ( !text.isEmpty() ) {
865 QLabel *label = new QLabel(text,mDayLabels); 877 QLabel *label = new QLabel(text,mDayLabels);
866 label->setAlignment(AlignCenter); 878 label->setAlignment(AlignCenter);
867 dayLayout->addWidget(label); 879 dayLayout->addWidget(label);
868 } 880 }
869 } 881 }
870 882
871 for(it = cds.first(); it; it = cds.next()) { 883 for(it = cds.first(); it; it = cds.next()) {
872 QWidget *wid = it->smallWidget(mDayLabels,date); 884 QWidget *wid = it->smallWidget(mDayLabels,date);
873 if ( wid ) { 885 if ( wid ) {
874 // wid->setHeight(20); 886 // wid->setHeight(20);
875 dayLayout->addWidget(wid); 887 dayLayout->addWidget(wid);
876 } 888 }
877 } 889 }
878#endif 890#endif
879 } 891 }
880 if ( ! appendLabels ) { 892 if ( ! appendLabels ) {
881 dayLabel = mDayLabelsList.next(); 893 dayLabel = mDayLabelsList.next();
882 if ( !dayLabel ) 894 if ( !dayLabel )
883 appendLabels = true; 895 appendLabels = true;
884 } 896 }
885 if ( appendLabels ) { 897 if ( appendLabels ) {
886 dayLabel = getNewDaylabel(); 898 dayLabel = getNewDaylabel();
887 } 899 }
888 //dayLabel->hide();//test only 900 //dayLabel->hide();//test only
889 901
890 dayLabel->setText(">"); 902 dayLabel->setText(">");
891 dayLabel->setFont( dlf ); 903 dayLabel->setFont( dlf );
892 dayLabel->setAutoRepeat( true ); 904 dayLabel->setAutoRepeat( true );
893 dayLabel->show(); 905 dayLabel->show();
894 dayLabel->setNum( -2 ); 906 dayLabel->setNum( -2 );
895 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 907 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
896 908
897 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 909 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
898 if ( !appendLabels ) { 910 if ( !appendLabels ) {
899 dayLabel = mDayLabelsList.next(); 911 dayLabel = mDayLabelsList.next();
900 while ( dayLabel ) { 912 while ( dayLabel ) {
901 //qDebug("!dayLabel %d",dayLabel ); 913 //qDebug("!dayLabel %d",dayLabel );
902 dayLabel->hide(); 914 dayLabel->hide();
903 dayLabel = mDayLabelsList.next(); 915 dayLabel = mDayLabelsList.next();
904 } 916 }
905 } 917 }
906 918
907 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 919 mDayLabelsFrame->setFixedHeight( newHight + 4 );
908} 920}
909 921
910int KOAgendaView::maxDatesHint() 922int KOAgendaView::maxDatesHint()
911{ 923{
912 // Not sure about the max number of events, so return 0 for now. 924 // Not sure about the max number of events, so return 0 for now.
913 return 0; 925 return 0;
914} 926}
915 927
916int KOAgendaView::currentDateCount() 928int KOAgendaView::currentDateCount()
917{ 929{
918 return mSelectedDates.count(); 930 return mSelectedDates.count();
919} 931}
920 932
921QPtrList<Incidence> KOAgendaView::selectedIncidences() 933Q3PtrList<Incidence> KOAgendaView::selectedIncidences()
922{ 934{
923 QPtrList<Incidence> selected; 935 Q3PtrList<Incidence> selected;
924 Incidence *incidence; 936 Incidence *incidence;
925 937
926 incidence = mAgenda->selectedIncidence(); 938 incidence = mAgenda->selectedIncidence();
927 if (incidence) selected.append(incidence); 939 if (incidence) selected.append(incidence);
928 940
929 incidence = mAllDayAgenda->selectedIncidence(); 941 incidence = mAllDayAgenda->selectedIncidence();
930 if (incidence) selected.append(incidence); 942 if (incidence) selected.append(incidence);
931 943
932 return selected; 944 return selected;
933} 945}
934 946
935DateList KOAgendaView::selectedDates() 947DateList KOAgendaView::selectedDates()
936{ 948{
937 DateList selected; 949 DateList selected;
938 QDate qd; 950 QDate qd;
939 951
940 qd = mAgenda->selectedIncidenceDate(); 952 qd = mAgenda->selectedIncidenceDate();
941 if (qd.isValid()) selected.append(qd); 953 if (qd.isValid()) selected.append(qd);
942 954
943 qd = mAllDayAgenda->selectedIncidenceDate(); 955 qd = mAllDayAgenda->selectedIncidenceDate();
944 if (qd.isValid()) selected.append(qd); 956 if (qd.isValid()) selected.append(qd);
945 957
946 return selected; 958 return selected;
947} 959}
948 960
949 961
950void KOAgendaView::updateView() 962void KOAgendaView::updateView()
951{ 963{
952 if ( mBlockUpdating ) 964 if ( mBlockUpdating )
953 return; 965 return;
954 // kdDebug() << "KOAgendaView::updateView()" << endl; 966 // kdDebug() << "KOAgendaView::updateView()" << endl;
955 fillAgenda(); 967 fillAgenda();
956 968
957} 969}
958 970
959 971
960/* 972/*
961 Update configuration settings for the agenda view. This method is not 973 Update configuration settings for the agenda view. This method is not
962 complete. 974 complete.
963*/ 975*/
964void KOAgendaView::updateConfig() 976void KOAgendaView::updateConfig()
965{ 977{
966 if ( mBlockUpdating ) 978 if ( mBlockUpdating )
967 return; 979 return;
968 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 980 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
969 int old = KOPrefs::instance()->mHourSize; 981 int old = KOPrefs::instance()->mHourSize;
970 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 982 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
971 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 983 //qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
972 } 984 }
973 985
974 986
975 // update config for children 987 // update config for children
976 mTimeLabels->updateConfig(); 988 mTimeLabels->updateConfig();
977 mAgenda->storePosition(); 989 mAgenda->storePosition();
978 mAgenda->updateConfig(); 990 mAgenda->updateConfig();
979 mAllDayAgenda->updateConfig(); 991 mAllDayAgenda->updateConfig();
980 // widget synchronization 992 // widget synchronization
981 //TODO: find a better way, maybe signal/slot 993 //TODO: find a better way, maybe signal/slot
982 mTimeLabels->positionChanged(); 994 mTimeLabels->positionChanged();
983 995
984 // for some reason, this needs to be called explicitly 996 // for some reason, this needs to be called explicitly
985 mTimeLabels->repaint(); 997 mTimeLabels->repaint();
986 998
987 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 999 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
988 1000
989 // ToolTips displaying summary of events 1001 // ToolTips displaying summary of events
990 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 1002 /* TODO:hacker: KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
991 ->mEnableToolTips); 1003 ->mEnableToolTips); */
992 1004
993 //setHolidayMasks(); 1005 //setHolidayMasks();
994 1006
995 //createDayLabels(); called by via updateView(); 1007 //createDayLabels(); called by via updateView();
996 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 1008 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
997 updateView(); 1009 updateView();
998 mAgenda->restorePosition(); 1010 mAgenda->restorePosition();
999} 1011}
1000 1012
1001 1013
1002void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 1014void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
1003{ 1015{
1004 1016
1005 1017
1006 int xxx = item->cellX(); 1018 int xxx = item->cellX();
1007 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() ); 1019 //qDebug("KOAgendaView::updateEventDates %d %d %d %d %d", xxx, mMinY.at(xxx),mMaxY.at(xxx),item->cellYTop(),item->cellYBottom() );
1008 if ( xxx >= 0 && xxx < mMinY.count() && !item->isAllDay() ) { 1020 if ( xxx >= 0 && xxx < mMinY.count() && !item->isAllDay() ) {
1009 if ( mMinY.at(xxx) > item->cellYTop() ) 1021 if ( mMinY.at(xxx) > item->cellYTop() )
1010 mMinY.at(xxx) = item->cellYTop(); 1022 mMinY.at(xxx) = item->cellYTop();
1011 if ( mMaxY.at(xxx) < item->cellYBottom() ) 1023 if ( mMaxY.at(xxx) < item->cellYBottom() )
1012 mMaxY.at(xxx) = item->cellYBottom(); 1024 mMaxY.at(xxx) = item->cellYBottom();
1013 } 1025 }
1014 QDateTime startDt,endDt; 1026 QDateTime startDt,endDt;
1015 QDate startDate; 1027 QDate startDate;
1016 int lenInSecs; 1028 int lenInSecs;
1017 // if ( type == KOAgenda::RESIZETOP ) 1029 // if ( type == KOAgenda::RESIZETOP )
1018 // qDebug("RESIZETOP "); 1030 // qDebug("RESIZETOP ");
1019 // if ( type == KOAgenda::RESIZEBOTTOM ) 1031 // if ( type == KOAgenda::RESIZEBOTTOM )
1020 // qDebug("RESIZEBOTTOM "); 1032 // qDebug("RESIZEBOTTOM ");
1021 // if ( type == KOAgenda::MOVE ) 1033 // if ( type == KOAgenda::MOVE )
1022 // qDebug("MOVE "); 1034 // qDebug("MOVE ");
1023 if ( item->incidence()->typeID() == eventID ) { 1035 if ( item->incidence()->typeID() == eventID ) {
1024 startDt =item->incidence()->dtStart(); 1036 startDt =item->incidence()->dtStart();
1025 endDt = item->incidence()->dtEnd(); 1037 endDt = item->incidence()->dtEnd();
1026 lenInSecs = startDt.secsTo( endDt ); 1038 lenInSecs = startDt.secsTo( endDt );
1027 } 1039 }
1028 1040
1029 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 1041 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
1030 1042
1031 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) { 1043 if ( item->incidence()->typeID()== todoID && item->mLastMoveXPos > 0 ) {
1032 startDate = mSelectedDates[item->mLastMoveXPos]; 1044 startDate = mSelectedDates[item->mLastMoveXPos];
1033 } else { 1045 } else {
1034 if (item->cellX() < 0) { 1046 if (item->cellX() < 0) {
1035 startDate = (mSelectedDates.first()).addDays(item->cellX()); 1047 startDate = (mSelectedDates.first()).addDays(item->cellX());
1036 } else { 1048 } else {
1037 startDate = mSelectedDates[item->cellX()]; 1049 startDate = mSelectedDates[item->cellX()];
1038 } 1050 }
1039 } 1051 }
1040 startDt.setDate(startDate); 1052 startDt.setDate(startDate);
1041 1053
1042 if (item->incidence()->doesFloat()) { 1054 if (item->incidence()->doesFloat()) {
1043 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 1055 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
1044 } else { 1056 } else {
1045 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 1057 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
1046 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 1058 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
1047 if ( item->incidence()->typeID() == eventID ) { 1059 if ( item->incidence()->typeID() == eventID ) {
1048 if ( type == KOAgenda::MOVE ) { 1060 if ( type == KOAgenda::MOVE ) {
1049 endDt = startDt.addSecs(lenInSecs); 1061 endDt = startDt.addSecs(lenInSecs);
1050 1062
1051 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 1063 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
1052 if (item->lastMultiItem()) { 1064 if (item->lastMultiItem()) {
1053 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1065 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1054 endDt.setDate(startDate. 1066 endDt.setDate(startDate.
1055 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1067 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1056 } else { 1068 } else {
1057 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1069 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1058 endDt.setDate(startDate); 1070 endDt.setDate(startDate);
1059 } 1071 }
1060 } 1072 }
1061 } else { 1073 } else {
1062 // todo 1074 // todo
1063 if (item->lastMultiItem()) { 1075 if (item->lastMultiItem()) {
1064 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1076 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1065 endDt.setDate(startDate. 1077 endDt.setDate(startDate.
1066 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1078 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1067 } else { 1079 } else {
1068 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1080 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1069 if ( item->cellYBottom() > 0 ) 1081 if ( item->cellYBottom() > 0 )
1070 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1082 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1071 else 1083 else
1072 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1084 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1073 endDt.setDate(startDate); 1085 endDt.setDate(startDate);
1074 } 1086 }
1075 } 1087 }
1076 } 1088 }
1077 if ( item->incidence()->typeID() == eventID ) { 1089 if ( item->incidence()->typeID() == eventID ) {
1078 item->incidence()->setDtStart(startDt); 1090 item->incidence()->setDtStart(startDt);
1079 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1091 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1080 } else if ( item->incidence()->typeID() == todoID ) { 1092 } else if ( item->incidence()->typeID() == todoID ) {
1081 Todo* to = static_cast<Todo*>(item->incidence()); 1093 Todo* to = static_cast<Todo*>(item->incidence());
1082 1094
1083 to->setDtDue(endDt); 1095 to->setDtDue(endDt);
1084 if ( to->hasStartDate() ) { 1096 if ( to->hasStartDate() ) {
1085 if (to->dtStart() >= to->dtDue() ) 1097 if (to->dtStart() >= to->dtDue() )
1086 to->setDtStart(to->dtDue().addDays( -2 )); 1098 to->setDtStart(to->dtDue().addDays( -2 ));
1087 } 1099 }
1088 1100
1089 } 1101 }
1090 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1102 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1091 item->incidence()->setRevision(item->incidence()->revision()+1); 1103 item->incidence()->setRevision(item->incidence()->revision()+1);
1092 item->setItemDate(startDt.date()); 1104 item->setItemDate(startDt.date());
1093 //item->updateItem(); 1105 //item->updateItem();
1094 if ( item->incidence()->typeID() == todoID ) { 1106 if ( item->incidence()->typeID() == todoID ) {
1095 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1107 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1096 1108
1097 } 1109 }
1098 else 1110 else
1099 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1111 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1100 item->updateItem(); 1112 item->updateItem();
1101} 1113}
1102 1114
1103void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1115void KOAgendaView::showDates( const QDate &start, const QDate &end )
1104{ 1116{
1105 // kdDebug() << "KOAgendaView::selectDates" << endl; 1117 // kdDebug() << "KOAgendaView::selectDates" << endl;
1106 1118
1107 mSelectedDates.clear(); 1119 mSelectedDates.clear();
1108 // qDebug("KOAgendaView::showDates "); 1120 // qDebug("KOAgendaView::showDates ");
1109 QDate d = start; 1121 QDate d = start;
1110 while (d <= end) { 1122 while (d <= end) {
1111 mSelectedDates.append(d); 1123 mSelectedDates.append(d);
1112 d = d.addDays( 1 ); 1124 d = d.addDays( 1 );
1113 } 1125 }
1114 1126
1115 // and update the view 1127 // and update the view
1116 fillAgenda(); 1128 fillAgenda();
1117} 1129}
1118 1130
1119 1131
1120void KOAgendaView::showEvents(QPtrList<Event>) 1132void KOAgendaView::showEvents(Q3PtrList<Event>)
1121{ 1133{
1122 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1134 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1123} 1135}
1124 1136
1125void KOAgendaView::changeEventDisplay(Event *, int) 1137void KOAgendaView::changeEventDisplay(Event *, int)
1126{ 1138{
1127 // qDebug("KOAgendaView::changeEventDisplay "); 1139 // qDebug("KOAgendaView::changeEventDisplay ");
1128 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1140 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1129 // this should be re-written to be MUCH smarter. Right now we 1141 // this should be re-written to be MUCH smarter. Right now we
1130 // are just playing dumb. 1142 // are just playing dumb.
1131 fillAgenda(); 1143 fillAgenda();
1132} 1144}
1133 1145
1134void KOAgendaView::fillAgenda(const QDate &) 1146void KOAgendaView::fillAgenda(const QDate &)
1135{ 1147{
1136 // qDebug("KOAgendaView::fillAgenda "); 1148 // qDebug("KOAgendaView::fillAgenda ");
1137 fillAgenda(); 1149 fillAgenda();
1138} 1150}
1139 1151
1140void KOAgendaView::fillAgenda() 1152void KOAgendaView::fillAgenda()
1141{ 1153{
1142 if ( globalFlagBlockStartup ) 1154 if ( globalFlagBlockStartup )
1143 return; 1155 return;
1144 if ( globalFlagBlockAgenda == 1 ) 1156 if ( globalFlagBlockAgenda == 1 )
1145 return; 1157 return;
1146 if ( flag_blockfillAgenda ) 1158 if ( flag_blockfillAgenda )
1147 return; 1159 return;
1148 flag_blockfillAgenda = true; 1160 flag_blockfillAgenda = true;
1149 //if ( globalFlagBlockAgenda == 2 ) 1161 //if ( globalFlagBlockAgenda == 2 )
1150 //globalFlagBlockAgenda = 0; 1162 //globalFlagBlockAgenda = 0;
1151 // globalFlagBlockPainting = false; 1163 // globalFlagBlockPainting = false;
1152 if ( globalFlagBlockAgenda == 0 ) 1164 if ( globalFlagBlockAgenda == 0 )
1153 globalFlagBlockAgenda = 1; 1165 globalFlagBlockAgenda = 1;
1154 // clearView(); 1166 // clearView();
1155 //qDebug("fillAgenda()++++ "); 1167 //qDebug("fillAgenda()++++ ");
1156 globalFlagBlockAgendaItemPaint = 1; 1168 globalFlagBlockAgendaItemPaint = 1;
1157 1169
1158 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1170 mAllDayAgenda->changeColumns(mSelectedDates.count());
1159 mAgenda->changeColumns(mSelectedDates.count()); 1171 mAgenda->changeColumns(mSelectedDates.count());
1160 qApp->processEvents(); 1172 qApp->processEvents();
1161 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1173 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1162 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1174 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1163 setHolidayMasks(); 1175 setHolidayMasks();
1164 1176
1165 mMinY.resize(mSelectedDates.count()); 1177 mMinY.resize(mSelectedDates.count());
1166 mMaxY.resize(mSelectedDates.count()); 1178 mMaxY.resize(mSelectedDates.count());
1167 1179
1168 QPtrList<Event> dayEvents; 1180 Q3PtrList<Event> dayEvents;
1169 1181
1170 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1182 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1171 // Therefore, gtodoset all of them. 1183 // Therefore, gtodoset all of them.
1172 QPtrList<Todo> todos = calendar()->todos(); 1184 Q3PtrList<Todo> todos = calendar()->todos();
1173 1185
1174 mAgenda->setDateList(mSelectedDates); 1186 mAgenda->setDateList(mSelectedDates);
1175 1187
1176 QDate today = QDate::currentDate(); 1188 QDate today = QDate::currentDate();
1177 1189
1178 DateList::ConstIterator dit; 1190 DateList::ConstIterator dit;
1179 int curCol = 0; 1191 int curCol = 0;
1180 int maxCol = mSelectedDates.count()-1; 1192 int maxCol = mSelectedDates.count()-1;
1181 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1193 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1182 QDate currentDate = *dit; 1194 QDate currentDate = *dit;
1183 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1195 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1184 // << endl; 1196 // << endl;
1185 1197
1186 dayEvents = calendar()->events(currentDate,false); 1198 dayEvents = calendar()->events(currentDate,false);
1187 1199
1188 // Default values, which can never be reached 1200 // Default values, which can never be reached
1189 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1201 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1190 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1202 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1191 1203
1192 unsigned int numEvent; 1204 unsigned int numEvent;
1193 //qDebug("+++++NUMEVENT %d", dayEvents.count()); 1205 //qDebug("+++++NUMEVENT %d", dayEvents.count());
1194 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1206 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1195 Event *event = dayEvents.at(numEvent); 1207 Event *event = dayEvents.at(numEvent);
1196 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1208 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1197 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1209 if ( event->uid().left(15) == QString("last-syncEvent-") )
1198 continue; 1210 continue;
1199 // kdDebug() << " Event: " << event->summary() << endl; 1211 // kdDebug() << " Event: " << event->summary() << endl;
1200 1212
1201 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1213 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1202 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1214 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1203 1215
1204 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1216 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1205 1217
1206 if (event->doesFloat()) { 1218 if (event->doesFloat()) {
1207 if (event->doesRecur()) { 1219 if (event->doesRecur()) {
1208 if (event->isMultiDay() ) { 1220 if (event->isMultiDay() ) {
1209 endX = endX - beginX;// endX is now number of days 1221 endX = endX - beginX;// endX is now number of days
1210 if ( event->recursOn( currentDate ) ) { 1222 if ( event->recursOn( currentDate ) ) {
1211 endX += curCol; 1223 endX += curCol;
1212 beginX = curCol; 1224 beginX = curCol;
1213 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1225 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1214 } else { 1226 } else {
1215 //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1()); 1227 //qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1());
1216 if ( curCol == maxCol && maxCol+1 < endX ) { 1228 if ( curCol == maxCol && maxCol+1 < endX ) {
1217 int i; 1229 int i;
1218 for ( i = 1; i< endX; ++i ) { 1230 for ( i = 1; i< endX; ++i ) {
1219 if ( event->recursOn( currentDate.addDays( -i ) ) ) 1231 if ( event->recursOn( currentDate.addDays( -i ) ) )
1220 break; 1232 break;
1221 } 1233 }
1222 if ( i > maxCol ) { 1234 if ( i > maxCol ) {
1223 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1235 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1224 //qDebug("BINGO "); 1236 //qDebug("BINGO ");
1225 } 1237 }
1226 1238
1227 } else { 1239 } else {
1228 QDate dateit = currentDate.addDays( -endX ); 1240 QDate dateit = currentDate.addDays( -endX );
1229 if ( event->recursOn( dateit ) ) { 1241 if ( event->recursOn( dateit ) ) {
1230 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() ); 1242 //qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
1231 if ( curCol-endX < 0 ) { 1243 if ( curCol-endX < 0 ) {
1232 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol); 1244 mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
1233 } 1245 }
1234 } 1246 }
1235 } 1247 }
1236 } 1248 }
1237 } else { 1249 } else {
1238 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1250 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1239 } 1251 }
1240 } else { 1252 } else {
1241 if (beginX <= 0 && curCol == 0) { 1253 if (beginX <= 0 && curCol == 0) {
1242 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1254 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1243 } else if (beginX == curCol) { 1255 } else if (beginX == curCol) {
1244 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1256 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1245 } 1257 }
1246 } 1258 }
1247 } else if (event->isMultiDay()) { 1259 } else if (event->isMultiDay()) {
1248 if ( event->doesRecur () ) { 1260 if ( event->doesRecur () ) {
1249 QDate dateit = currentDate; 1261 QDate dateit = currentDate;
1250 int count = 0; 1262 int count = 0;
1251 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1263 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1252 while (! event->recursOn( dateit ) && count <= max ) { 1264 while (! event->recursOn( dateit ) && count <= max ) {
1253 ++count; 1265 ++count;
1254 dateit = dateit.addDays( -1 ); 1266 dateit = dateit.addDays( -1 );
1255 } 1267 }
1256 bool ok; 1268 bool ok;
1257 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1269 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1258 if ( ok ) 1270 if ( ok )
1259 { 1271 {
1260 int secs = event->dtStart().secsTo( event->dtEnd() ); 1272 int secs = event->dtStart().secsTo( event->dtEnd() );
1261 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1273 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1262 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1274 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1263 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1275 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1264 1276
1265 } 1277 }
1266 } 1278 }
1267 int startY = mAgenda->timeToY(event->dtStart().time()); 1279 int startY = mAgenda->timeToY(event->dtStart().time());
1268 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1280 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1269 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1281 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1270 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1282 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1271 //qDebug("insert!!! "); 1283 //qDebug("insert!!! ");
1272 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1284 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1273 } 1285 }
1274 if (beginX == curCol) { 1286 if (beginX == curCol) {
1275 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1287 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1276 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1288 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1277 } else if (endX == curCol) { 1289 } else if (endX == curCol) {
1278 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1290 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1279 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1291 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1280 } else { 1292 } else {
1281 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1293 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1282 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1294 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1283 } 1295 }
1284 } else { 1296 } else {
1285 int startY = mAgenda->timeToY(event->dtStart().time()); 1297 int startY = mAgenda->timeToY(event->dtStart().time());
1286 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1298 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1287 if (endY < startY) endY = startY; 1299 if (endY < startY) endY = startY;
1288 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1300 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1289 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1301 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1290 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1302 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1291 } 1303 }
1292 } 1304 }
1293 // ---------- [display Todos -------------- 1305 // ---------- [display Todos --------------
1294 unsigned int numTodo; 1306 unsigned int numTodo;
1295 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1307 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1296 Todo *todo = todos.at(numTodo); 1308 Todo *todo = todos.at(numTodo);
1297 1309
1298 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1310 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1299 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue; 1311 if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda ) continue;
1300 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1312 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1301 // Already completed items can be displayed on their original due date 1313 // Already completed items can be displayed on their original due date
1302 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1314 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1303 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1315 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < (QDateTime)today) && KOPrefs::instance()->mShowTodoInAgenda;
1304 bool fillIn = false; 1316 bool fillIn = false;
1305 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1317 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1306 fillIn = true; 1318 fillIn = true;
1307 if ( ! fillIn && !todo->hasCompletedDate() ) 1319 if ( ! fillIn && !todo->hasCompletedDate() )
1308 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1320 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1309 if ( fillIn ) { 1321 if ( fillIn ) {
1310 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1322 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1311 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1323 if ( KOPrefs::instance()->mShowTodoInAgenda )
1312 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1324 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1313 } 1325 }
1314 else { 1326 else {
1315 QDateTime dt; 1327 QDateTime dt;
1316 if ( todo->hasCompletedDate() ) 1328 if ( todo->hasCompletedDate() )
1317 dt = todo->completed(); 1329 dt = todo->completed();
1318 else 1330 else
1319 dt = todo->dtDue();; 1331 dt = todo->dtDue();;
1320 1332
1321 1333
1322 int endY = mAgenda->timeToY(dt.time()) - 1; 1334 int endY = mAgenda->timeToY(dt.time()) - 1;
1323 int hi = (18/KOPrefs::instance()->mHourSize); 1335 int hi = (18/KOPrefs::instance()->mHourSize);
1324 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1336 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1325 int startY = endY -hi; 1337 int startY = endY -hi;
1326 1338
1327 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1339 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1328 1340
1329 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1341 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1330 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1342 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1331 } 1343 }
1332 } 1344 }
1333 } 1345 }
1334 // ---------- display Todos] -------------- 1346 // ---------- display Todos] --------------
1335 1347
1336 ++curCol; 1348 ++curCol;
1337 } 1349 }
1338 mAgenda->hideUnused(); 1350 mAgenda->hideUnused();
1339 mAllDayAgenda->hideUnused(); 1351 mAllDayAgenda->hideUnused();
1340 mAgenda->checkScrollBoundaries(); 1352 mAgenda->checkScrollBoundaries();
1341 deleteSelectedDateTime(); 1353 deleteSelectedDateTime();
1342 createDayLabels(); 1354 createDayLabels();
1343 emit incidenceSelected( 0 ); 1355 emit incidenceSelected( 0 );
1344 1356
1345 if ( globalFlagBlockAgenda == 2 ) { 1357 if ( globalFlagBlockAgenda == 2 ) {
1346 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1358 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1347 setStartHour( KOPrefs::instance()->mDayBegins ); 1359 setStartHour( KOPrefs::instance()->mDayBegins );
1348 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1360 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1349 setStartHour( QTime::currentTime ().hour() ); 1361 setStartHour( QTime::currentTime ().hour() );
1350 } 1362 }
1351 qApp->processEvents(); 1363 qApp->processEvents();
1352 globalFlagBlockAgenda = 0; 1364 globalFlagBlockAgenda = 0;
1353 mAllDayAgenda->drawContentsToPainter(); 1365 mAllDayAgenda->drawContentsToPainter();
1354 mAgenda->drawContentsToPainter(); 1366 mAgenda->drawContentsToPainter();
1355 repaintAgenda(); 1367 repaintAgenda();
1356 startIdleTimeout(); 1368 startIdleTimeout();
1357 flag_blockfillAgenda = false; 1369 flag_blockfillAgenda = false;
1358} 1370}
1359void KOAgendaView::repaintAgenda() 1371void KOAgendaView::repaintAgenda()
1360{ 1372{
1361 mAgenda->viewport()->repaint( false ); 1373 mAgenda->viewport()->repaint( false );
1362 mAllDayAgenda->viewport()->repaint( false ); 1374 mAllDayAgenda->viewport()->repaint( false );
1363 mAgenda->finishUpdate(); 1375 mAgenda->finishUpdate();
1364 mAllDayAgenda->finishUpdate(); 1376 mAllDayAgenda->finishUpdate();
1365} 1377}
1366 1378
1367 1379
1368void KOAgendaView::clearView() 1380void KOAgendaView::clearView()
1369{ 1381{
1370 mAllDayAgenda->clear(); 1382 mAllDayAgenda->clear();
1371 mAgenda->clear(); 1383 mAgenda->clear();
1372} 1384}
1373void KOAgendaView::clearList() 1385void KOAgendaView::clearList()
1374{ 1386{
1375 clearView(); 1387 clearView();
1376 mAllDayAgenda->hideUnused(); 1388 mAllDayAgenda->hideUnused();
1377 mAgenda->hideUnused(); 1389 mAgenda->hideUnused();
1378} 1390}
1379 1391
1380void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1392void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1381 const QDate &td) 1393 const QDate &td)
1382{ 1394{
1383#ifndef KORG_NOPRINTER 1395#ifndef KORG_NOPRINTER
1384 if (fd == td) 1396 if (fd == td)
1385 calPrinter->preview(CalPrinter::Day, fd, td); 1397 calPrinter->preview(CalPrinter::Day, fd, td);
1386 else 1398 else
1387 calPrinter->preview(CalPrinter::Week, fd, td); 1399 calPrinter->preview(CalPrinter::Week, fd, td);
1388#endif 1400#endif
1389} 1401}
1390 1402
1391// void KOAgendaView::updateMovedTodo() 1403// void KOAgendaView::updateMovedTodo()
1392// { 1404// {
1393// // updateConfig(); 1405// // updateConfig();
1394// // emit updateTodoViews(); 1406// // emit updateTodoViews();
1395// } 1407// }
1396 1408
1397void KOAgendaView::slotShowDateView( int mode , int d ) 1409void KOAgendaView::slotShowDateView( int mode , int d )
1398{ 1410{
1399 if ( d >= mSelectedDates.count() ) { 1411 if ( d >= mSelectedDates.count() ) {
@@ -1410,283 +1422,283 @@ void KOAgendaView::newEvent(int gx, int gy)
1410 if (!mSelectedDates.count()) return; 1422 if (!mSelectedDates.count()) return;
1411 1423
1412 QDate day = mSelectedDates[gx]; 1424 QDate day = mSelectedDates[gx];
1413 1425
1414 QTime time = mAgenda->gyToTime(gy); 1426 QTime time = mAgenda->gyToTime(gy);
1415 QDateTime dt(day,time); 1427 QDateTime dt(day,time);
1416 // if ( dt < QDateTime::currentDateTime () ) 1428 // if ( dt < QDateTime::currentDateTime () )
1417 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1429 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1418 emit newEventSignal(dt); 1430 emit newEventSignal(dt);
1419} 1431}
1420 1432
1421void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1433void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1422{ 1434{
1423 if (!mSelectedDates.count()) return; 1435 if (!mSelectedDates.count()) return;
1424 1436
1425 QDate dayStart = mSelectedDates[gxStart]; 1437 QDate dayStart = mSelectedDates[gxStart];
1426 QDate dayEnd = mSelectedDates[gxEnd]; 1438 QDate dayEnd = mSelectedDates[gxEnd];
1427 1439
1428 QTime timeStart = mAgenda->gyToTime(gyStart); 1440 QTime timeStart = mAgenda->gyToTime(gyStart);
1429 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1441 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1430 1442
1431 QDateTime dtStart(dayStart,timeStart); 1443 QDateTime dtStart(dayStart,timeStart);
1432 QDateTime dtEnd(dayEnd,timeEnd); 1444 QDateTime dtEnd(dayEnd,timeEnd);
1433 1445
1434 emit newEventSignal(dtStart,dtEnd); 1446 emit newEventSignal(dtStart,dtEnd);
1435} 1447}
1436 1448
1437void KOAgendaView::newEventAllDay(int gx, int ) 1449void KOAgendaView::newEventAllDay(int gx, int )
1438{ 1450{
1439 if (!mSelectedDates.count()) return; 1451 if (!mSelectedDates.count()) return;
1440 1452
1441 QDate day = mSelectedDates[gx]; 1453 QDate day = mSelectedDates[gx];
1442 1454
1443 emit newEventSignal(day); 1455 emit newEventSignal(day);
1444} 1456}
1445void KOAgendaView::newTodoAllDay(int gx, int ) 1457void KOAgendaView::newTodoAllDay(int gx, int )
1446{ 1458{
1447 if (!mSelectedDates.count()) return; 1459 if (!mSelectedDates.count()) return;
1448 1460
1449 QDateTime day (mSelectedDates[gx] ); 1461 QDateTime day (mSelectedDates[gx] );
1450 emit newTodoSignal(day, true); 1462 emit newTodoSignal(day, true);
1451} 1463}
1452void KOAgendaView::newTodo(int gx, int gy ) 1464void KOAgendaView::newTodo(int gx, int gy )
1453{ 1465{
1454 if (!mSelectedDates.count()) return; 1466 if (!mSelectedDates.count()) return;
1455 QDate dayStart = mSelectedDates[gx]; 1467 QDate dayStart = mSelectedDates[gx];
1456 QTime timeStart = mAgenda->gyToTime(gy); 1468 QTime timeStart = mAgenda->gyToTime(gy);
1457 QDateTime dt (dayStart,timeStart); 1469 QDateTime dt (dayStart,timeStart);
1458 emit newTodoSignal( dt, false ); 1470 emit newTodoSignal( dt, false );
1459} 1471}
1460 1472
1461void KOAgendaView::updateEventIndicatorTop(int newY) 1473void KOAgendaView::updateEventIndicatorTop(int newY)
1462{ 1474{
1463 uint i; 1475 uint i;
1464 for(i=0;i<mMinY.size();++i) { 1476 for(i=0;i<mMinY.size();++i) {
1465 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1477 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1466 else mEventIndicatorTop->enableColumn(i,false); 1478 else mEventIndicatorTop->enableColumn(i,false);
1467 } 1479 }
1468 1480
1469 mEventIndicatorTop->update(); 1481 mEventIndicatorTop->update();
1470} 1482}
1471 1483
1472void KOAgendaView::updateEventIndicatorBottom(int newY) 1484void KOAgendaView::updateEventIndicatorBottom(int newY)
1473{ 1485{
1474 uint i; 1486 uint i;
1475 for(i=0;i<mMaxY.size();++i) { 1487 for(i=0;i<mMaxY.size();++i) {
1476 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1488 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1477 else mEventIndicatorBottom->enableColumn(i,false); 1489 else mEventIndicatorBottom->enableColumn(i,false);
1478 } 1490 }
1479 1491
1480 mEventIndicatorBottom->update(); 1492 mEventIndicatorBottom->update();
1481} 1493}
1482 1494
1483void KOAgendaView::startDrag(Event *event) 1495void KOAgendaView::startDrag(Event *event)
1484{ 1496{
1485#ifndef KORG_NODND 1497#ifndef KORG_NODND
1486 DndFactory factory( calendar() ); 1498 DndFactory factory( calendar() );
1487 ICalDrag *vd = factory.createDrag(event,this); 1499 ICalDrag *vd = factory.createDrag(event,this);
1488 if (vd->drag()) { 1500 if (vd->drag()) {
1489 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1501 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1490 } 1502 }
1491#endif 1503#endif
1492} 1504}
1493 1505
1494void KOAgendaView::readSettings() 1506void KOAgendaView::readSettings()
1495{ 1507{
1496 readSettings(KOGlobals::config()); 1508 readSettings(KOGlobals::config());
1497} 1509}
1498 1510
1499void KOAgendaView::readSettings(KConfig *config) 1511void KOAgendaView::readSettings(KConfig *config)
1500{ 1512{
1501 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1513 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1502 1514
1503 config->setGroup("Views"); 1515 config->setGroup("Views");
1504 1516
1505 //#ifndef KORG_NOSPLITTER 1517 //#ifndef KORG_NOSPLITTER
1506 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1518 Q3ValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1507 if (sizes.count() == 2) { 1519 if (sizes.count() == 2) {
1508 if ( sizes[0] < 20 ) { 1520 if ( sizes[0] < 20 ) {
1509 sizes[1] = sizes[1] +20 - sizes[0]; 1521 sizes[1] = sizes[1] +20 - sizes[0];
1510 sizes[0] = 20; 1522 sizes[0] = 20;
1511 } 1523 }
1512 mSplitterAgenda->setSizes(sizes); 1524 mSplitterAgenda->setSizes(sizes);
1513 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1525 // qDebug("read %d %d ",sizes[0],sizes[1] );
1514 } 1526 }
1515 //#endif 1527 //#endif
1516 1528
1517 // updateConfig(); 1529 // updateConfig();
1518} 1530}
1519 1531
1520void KOAgendaView::writeSettings(KConfig *config) 1532void KOAgendaView::writeSettings(KConfig *config)
1521{ 1533{
1522 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1534 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1523 1535
1524 config->setGroup("Views"); 1536 config->setGroup("Views");
1525 1537
1526 //#ifndef KORG_NOSPLITTER 1538 //#ifndef KORG_NOSPLITTER
1527 QValueList<int> list = mSplitterAgenda->sizes(); 1539 Q3ValueList<int> list = mSplitterAgenda->sizes();
1528 config->writeEntry("Separator AgendaView",list); 1540 config->writeEntry("Separator AgendaView",list);
1529 //qDebug("write %d %d ", list[0],list[1] ); 1541 //qDebug("write %d %d ", list[0],list[1] );
1530 //#endif 1542 //#endif
1531} 1543}
1532 1544
1533void KOAgendaView::setHolidayMasks() 1545void KOAgendaView::setHolidayMasks()
1534{ 1546{
1535 mHolidayMask.resize(mSelectedDates.count()); 1547 mHolidayMask.resize(mSelectedDates.count());
1536 1548
1537 uint i; 1549 uint i;
1538 for(i=0;i<mSelectedDates.count();++i) { 1550 for(i=0;i<mSelectedDates.count();++i) {
1539 QDate date = mSelectedDates[i]; 1551 QDate date = mSelectedDates[i];
1540 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1552 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1541 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1553 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1542 bool showHoliday = false; 1554 bool showHoliday = false;
1543 if ( KOPrefs::instance()->mExcludeHolidays ) { 1555 if ( KOPrefs::instance()->mExcludeHolidays ) {
1544 QPtrList<Event> events = calendar()->events( date, true ); 1556 Q3PtrList<Event> events = calendar()->events( date, true );
1545 Event *event; 1557 Event *event;
1546 for( event = events.first(); event; event = events.next() ) { 1558 for( event = events.first(); event; event = events.next() ) {
1547 if ( event->isHoliday()) { 1559 if ( event->isHoliday()) {
1548 showHoliday = true; 1560 showHoliday = true;
1549 break; 1561 break;
1550 } 1562 }
1551 } 1563 }
1552 1564
1553 } 1565 }
1554 1566
1555#ifndef KORG_NOPLUGINS 1567#ifndef KORG_NOPLUGINS
1556 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1568 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1557 !KOCore::self()->holiday(date).isEmpty(); 1569 !KOCore::self()->holiday(date).isEmpty();
1558#endif 1570#endif
1559 bool showDay = showSaturday || showSunday || showHoliday; 1571 bool showDay = showSaturday || showSunday || showHoliday;
1560 1572
1561 if (showDay) { 1573 if (showDay) {
1562 mHolidayMask.at(i) = true; 1574 mHolidayMask.at(i) = true;
1563 } else { 1575 } else {
1564 mHolidayMask.at(i) = false; 1576 mHolidayMask.at(i) = false;
1565 } 1577 }
1566 } 1578 }
1567 1579
1568 mAgenda->setHolidayMask(&mHolidayMask); 1580 mAgenda->setHolidayMask(&mHolidayMask);
1569 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1581 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1570} 1582}
1571 1583
1572void KOAgendaView::setContentsPos(int y) 1584void KOAgendaView::setContentsPos(int y)
1573{ 1585{
1574 mAgenda->setContentsPos(0,y); 1586 mAgenda->setContentsPos(0,y);
1575} 1587}
1576 1588
1577void KOAgendaView::clearSelection() 1589void KOAgendaView::clearSelection()
1578{ 1590{
1579 mAgenda->deselectItem(); 1591 mAgenda->deselectItem();
1580 mAllDayAgenda->deselectItem(); 1592 mAllDayAgenda->deselectItem();
1581} 1593}
1582 1594
1583void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1595void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1584 int gxEnd, int gyEnd) 1596 int gxEnd, int gyEnd)
1585{ 1597{
1586 mTimeSpanInAllDay = true; 1598 mTimeSpanInAllDay = true;
1587 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1599 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1588} 1600}
1589 1601
1590 1602
1591 1603
1592 1604
1593void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1605void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1594 int gxEnd, int gyEnd) 1606 int gxEnd, int gyEnd)
1595{ 1607{
1596 if (!mSelectedDates.count()) return; 1608 if (!mSelectedDates.count()) return;
1597 1609
1598 QDate dayStart = mSelectedDates[gxStart]; 1610 QDate dayStart = mSelectedDates[gxStart];
1599 QDate dayEnd = mSelectedDates[gxEnd]; 1611 QDate dayEnd = mSelectedDates[gxEnd];
1600 1612
1601 QTime timeStart = mAgenda->gyToTime(gyStart); 1613 QTime timeStart = mAgenda->gyToTime(gyStart);
1602 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1614 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1603 1615
1604 QDateTime dtStart(dayStart,timeStart); 1616 QDateTime dtStart(dayStart,timeStart);
1605 QDateTime dtEnd(dayEnd,timeEnd); 1617 QDateTime dtEnd(dayEnd,timeEnd);
1606 1618
1607 mTimeSpanBegin = dtStart; 1619 mTimeSpanBegin = dtStart;
1608 mTimeSpanEnd = dtEnd; 1620 mTimeSpanEnd = dtEnd;
1609 1621
1610} 1622}
1611 1623
1612void KOAgendaView::deleteSelectedDateTime() 1624void KOAgendaView::deleteSelectedDateTime()
1613{ 1625{
1614 mTimeSpanBegin.setDate(QDate()); 1626 mTimeSpanBegin.setDate(QDate());
1615 mTimeSpanEnd.setDate(QDate()); 1627 mTimeSpanEnd.setDate(QDate());
1616 mTimeSpanInAllDay = false; 1628 mTimeSpanInAllDay = false;
1617} 1629}
1618 1630
1619void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1631void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1620{ 1632{
1621 e->ignore(); 1633 e->ignore();
1622} 1634}
1623 1635
1624void KOAgendaView::scrollOneHourUp() 1636void KOAgendaView::scrollOneHourUp()
1625{ 1637{
1626 1638
1627 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1639 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1628} 1640}
1629void KOAgendaView::scrollOneHourDown() 1641void KOAgendaView::scrollOneHourDown()
1630{ 1642{
1631 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1643 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1632} 1644}
1633 1645
1634void KOAgendaView::setStartHour( int h ) 1646void KOAgendaView::setStartHour( int h )
1635{ 1647{
1636 mAgenda->setStartHour( h ); 1648 mAgenda->setStartHour( h );
1637 1649
1638} 1650}
1639void KOAgendaView::setInitStartHour() 1651void KOAgendaView::setInitStartHour()
1640{ 1652{
1641 1653
1642 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1654 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1643 setStartHour( QTime::currentTime ().hour() ); 1655 setStartHour( QTime::currentTime ().hour() );
1644 else 1656 else
1645 setStartHour( KOPrefs::instance()->mDayBegins ); 1657 setStartHour( KOPrefs::instance()->mDayBegins );
1646 1658
1647} 1659}
1648 1660
1649 1661
1650void KOAgendaView::updateTodo( Todo * t, int ) 1662void KOAgendaView::updateTodo( Todo * t, int )
1651{ 1663{
1652 if ( !isVisible() ) 1664 if ( !isVisible() )
1653 return; 1665 return;
1654 bool remove = false; 1666 bool remove = false;
1655 bool removeAD = false; 1667 bool removeAD = false;
1656 QDate da; 1668 QDate da;
1657 if ( t->hasCompletedDate() ) 1669 if ( t->hasCompletedDate() )
1658 da = t->completed().date(); 1670 da = t->completed().date();
1659 else 1671 else
1660 da = t->dtDue().date(); 1672 da = t->dtDue().date();
1661 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1673 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1662 remove = true; 1674 remove = true;
1663 removeAD = true; 1675 removeAD = true;
1664 } 1676 }
1665 else { 1677 else {
1666 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1678 bool overdue = (!t->isCompleted()) && (t->dtDue() < (QDateTime)QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1667 if ( overdue && 1679 if ( overdue &&
1668 QDate::currentDate() >= mSelectedDates.first() && 1680 QDate::currentDate() >= mSelectedDates.first() &&
1669 QDate::currentDate() <= mSelectedDates.last()) { 1681 QDate::currentDate() <= mSelectedDates.last()) {
1670 removeAD = false; 1682 removeAD = false;
1671 remove = true; 1683 remove = true;
1672 } 1684 }
1673 else { 1685 else {
1674 1686
1675 if ( da < mSelectedDates.first() || 1687 if ( da < mSelectedDates.first() ||
1676 da > mSelectedDates.last() ) { 1688 da > mSelectedDates.last() ) {
1677 remove = true; 1689 remove = true;
1678 removeAD = true; 1690 removeAD = true;
1679 } else { 1691 } else {
1680 remove = t->doesFloat() && !t->hasCompletedDate(); 1692 remove = t->doesFloat() && !t->hasCompletedDate();
1681 removeAD = !remove; 1693 removeAD = !remove;
1682 } 1694 }
1683 } 1695 }
1684 } 1696 }
1685 int days = mSelectedDates.first().daysTo( da ); 1697 int days = mSelectedDates.first().daysTo( da );
1686 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1698 //qDebug("daysto %d %d %d", days, remove,removeAD );
1687 mAgenda->updateTodo( t , days, remove); 1699 mAgenda->updateTodo( t , days, remove);
1688 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1700 if ( KOPrefs::instance()->mShowTodoInAgenda )
1689 mAllDayAgenda->updateTodo( t , days, removeAD); 1701 mAllDayAgenda->updateTodo( t , days, removeAD);
1690 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1702 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1691 1703
1692} 1704}