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