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