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