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