summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index db66413..8448a4c 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1499 +1,1499 @@
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 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 428 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
429 429
430 // Create event context menu for all day agenda 430 // Create event context menu for all day agenda
431 mAllDayAgendaPopup = eventPopup(); 431 mAllDayAgendaPopup = eventPopup();
432 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 432 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
433 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 433 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
434 434
435 // Create agenda frame 435 // Create agenda frame
436 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 436 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
437 // QHBox *agendaFrame = new QHBox(splitterAgenda); 437 // QHBox *agendaFrame = new QHBox(splitterAgenda);
438 438
439 // create event indicator bars 439 // create event indicator bars
440 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 440 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
441 agendaLayout->addWidget(mEventIndicatorTop,0,1); 441 agendaLayout->addWidget(mEventIndicatorTop,0,1);
442 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 442 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
443 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 443 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
444 agendaFrame); 444 agendaFrame);
445 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 445 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
446 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 446 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
447 agendaLayout->addWidget(dummyAgendaRight,0,2); 447 agendaLayout->addWidget(dummyAgendaRight,0,2);
448 448
449 // Create time labels 449 // Create time labels
450 mTimeLabels = new TimeLabels(24,agendaFrame); 450 mTimeLabels = new TimeLabels(24,agendaFrame);
451 agendaLayout->addWidget(mTimeLabels,1,0); 451 agendaLayout->addWidget(mTimeLabels,1,0);
452 connect(mTimeLabels,SIGNAL( scaleChanged()), 452 connect(mTimeLabels,SIGNAL( scaleChanged()),
453 this,SLOT(updateConfig())); 453 this,SLOT(updateConfig()));
454 454
455 // Create agenda 455 // Create agenda
456 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 456 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
457 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 457 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
458 agendaLayout->setColStretch(1,1); 458 agendaLayout->setColStretch(1,1);
459 mAgenda->setFocusPolicy(NoFocus); 459 mAgenda->setFocusPolicy(NoFocus);
460 // Create event context menu for agenda 460 // Create event context menu for agenda
461 mAgendaPopup = eventPopup(); 461 mAgendaPopup = eventPopup();
462 462
463 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 463 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
464 i18n("Toggle Alarm"),mAgenda, 464 i18n("Toggle Alarm"),mAgenda,
465 SLOT(popupAlarm()),true); 465 SLOT(popupAlarm()),true);
466 466
467 467
468 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 468 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
469 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 469 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
470 470
471 // make connections between dependent widgets 471 // make connections between dependent widgets
472 mTimeLabels->setAgenda(mAgenda); 472 mTimeLabels->setAgenda(mAgenda);
473 473
474 // Update widgets to reflect user preferences 474 // Update widgets to reflect user preferences
475 // updateConfig(); 475 // updateConfig();
476 476
477 // createDayLabels(); 477 // createDayLabels();
478 478
479 // these blank widgets make the All Day Event box line up with the agenda 479 // these blank widgets make the All Day Event box line up with the agenda
480 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 480 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
481 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 481 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
482 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 482 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
483 483
484 // Scrolling 484 // Scrolling
485 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 485 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
486 mTimeLabels, SLOT(positionChanged())); 486 mTimeLabels, SLOT(positionChanged()));
487 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 487 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
488 SLOT(setContentsPos(int))); 488 SLOT(setContentsPos(int)));
489 489
490 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 490 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
491 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 491 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
492 492
493 // Create/Show/Edit/Delete Event 493 // Create/Show/Edit/Delete Event
494 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 494 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
495 SLOT(newEvent(int,int))); 495 SLOT(newEvent(int,int)));
496 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 496 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
497 SLOT(newTodo(int,int))); 497 SLOT(newTodo(int,int)));
498 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 498 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
499 SLOT(newEvent(int,int,int,int))); 499 SLOT(newEvent(int,int,int,int)));
500 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 500 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
501 SLOT(newEventAllDay(int,int))); 501 SLOT(newEventAllDay(int,int)));
502 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 502 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
503 SLOT(newTodoAllDay(int,int))); 503 SLOT(newTodoAllDay(int,int)));
504 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 504 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
505 SLOT(newEventAllDay(int,int))); 505 SLOT(newEventAllDay(int,int)));
506 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 506 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
507 SLOT(newTimeSpanSelected(int,int,int,int))); 507 SLOT(newTimeSpanSelected(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 508 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
509 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 509 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
510 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 510 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
511 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 511 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
512 512
513 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 513 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
514 SIGNAL(editIncidenceSignal(Incidence *))); 514 SIGNAL(editIncidenceSignal(Incidence *)));
515 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 515 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
516 SIGNAL(editIncidenceSignal(Incidence *))); 516 SIGNAL(editIncidenceSignal(Incidence *)));
517 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 517 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
518 SIGNAL(showIncidenceSignal(Incidence *))); 518 SIGNAL(showIncidenceSignal(Incidence *)));
519 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 519 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
520 SIGNAL(showIncidenceSignal(Incidence *))); 520 SIGNAL(showIncidenceSignal(Incidence *)));
521 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 521 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
522 SIGNAL(deleteIncidenceSignal(Incidence *))); 522 SIGNAL(deleteIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 523 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
524 SIGNAL(deleteIncidenceSignal(Incidence *))); 524 SIGNAL(deleteIncidenceSignal(Incidence *)));
525 525
526 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 526 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
527 SLOT(updateEventDates(KOAgendaItem *, int ))); 527 SLOT(updateEventDates(KOAgendaItem *, int )));
528 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 528 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
529 SLOT(updateEventDates(KOAgendaItem *, int))); 529 SLOT(updateEventDates(KOAgendaItem *, int)));
530 530
531 // event indicator update 531 // event indicator update
532 connect(mAgenda,SIGNAL(lowerYChanged(int)), 532 connect(mAgenda,SIGNAL(lowerYChanged(int)),
533 SLOT(updateEventIndicatorTop(int))); 533 SLOT(updateEventIndicatorTop(int)));
534 connect(mAgenda,SIGNAL(upperYChanged(int)), 534 connect(mAgenda,SIGNAL(upperYChanged(int)),
535 SLOT(updateEventIndicatorBottom(int))); 535 SLOT(updateEventIndicatorBottom(int)));
536 // drag signals 536 // drag signals
537 /* 537 /*
538 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 538 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
539 SLOT(startDrag(Event *))); 539 SLOT(startDrag(Event *)));
540 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 540 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
541 SLOT(startDrag(Event *))); 541 SLOT(startDrag(Event *)));
542 */ 542 */
543 // synchronize selections 543 // synchronize selections
544 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 544 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
545 mAllDayAgenda, SLOT( deselectItem() ) ); 545 mAllDayAgenda, SLOT( deselectItem() ) );
546 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 546 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
547 mAgenda, SLOT( deselectItem() ) ); 547 mAgenda, SLOT( deselectItem() ) );
548 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 548 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
549 SIGNAL( incidenceSelected( Incidence * ) ) ); 549 SIGNAL( incidenceSelected( Incidence * ) ) );
550 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 550 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
551 SIGNAL( incidenceSelected( Incidence * ) ) ); 551 SIGNAL( incidenceSelected( Incidence * ) ) );
552 connect( mAgenda, SIGNAL( resizedSignal() ), 552 connect( mAgenda, SIGNAL( resizedSignal() ),
553 SLOT( updateConfig( ) ) ); 553 SLOT( updateConfig( ) ) );
554 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 554 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
555 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 555 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
556 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 556 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
557 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 557 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
558 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 558 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
559 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 559 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
560 560
561 561
562} 562}
563 563
564void KOAgendaView::toggleAllDay() 564void KOAgendaView::toggleAllDay()
565{ 565{
566 if ( mSplitterAgenda->firstHandle() ) 566 if ( mSplitterAgenda->firstHandle() )
567 mSplitterAgenda->firstHandle()->toggle(); 567 mSplitterAgenda->firstHandle()->toggle();
568} 568}
569void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 569void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
570{ 570{
571 calendar()->addIncidence( inc ); 571 calendar()->addIncidence( inc );
572 572
573 if ( incOld ) { 573 if ( incOld ) {
574 if ( incOld->type() == "Todo" ) 574 if ( incOld->type() == "Todo" )
575 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 575 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
576 else 576 else
577 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 577 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
578 } 578 }
579 579
580} 580}
581 581
582KOAgendaView::~KOAgendaView() 582KOAgendaView::~KOAgendaView()
583{ 583{
584 delete mAgendaPopup; 584 delete mAgendaPopup;
585 delete mAllDayAgendaPopup; 585 delete mAllDayAgendaPopup;
586 delete KOAgendaItem::paintPix(); 586 delete KOAgendaItem::paintPix();
587 delete KOAgendaItem::paintPixSel(); 587 delete KOAgendaItem::paintPixSel();
588} 588}
589void KOAgendaView::resizeEvent( QResizeEvent* e ) 589void KOAgendaView::resizeEvent( QResizeEvent* e )
590{ 590{
591 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 591 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
592 bool uc = false; 592 bool uc = false;
593 int ow = e->oldSize().width(); 593 int ow = e->oldSize().width();
594 int oh = e->oldSize().height(); 594 int oh = e->oldSize().height();
595 int w = e->size().width(); 595 int w = e->size().width();
596 int h = e->size().height(); 596 int h = e->size().height();
597 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 597 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
598 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 598 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
599 uc = true; 599 uc = true;
600 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 600 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
601 } 601 }
602 mUpcomingWidth = e->size().width() ; 602 mUpcomingWidth = e->size().width() ;
603 if ( mBlockUpdating || uc ) { 603 if ( mBlockUpdating || uc ) {
604 mBlockUpdating = false; 604 mBlockUpdating = false;
605 //mAgenda->setMinimumSize(800 , 600 ); 605 //mAgenda->setMinimumSize(800 , 600 );
606 //qDebug("mAgenda->resize+++++++++++++++ "); 606 //qDebug("mAgenda->resize+++++++++++++++ ");
607 updateConfig(); 607 updateConfig();
608 //qDebug("KOAgendaView::Updating now possible "); 608 //qDebug("KOAgendaView::Updating now possible ");
609 } else 609 } else
610 createDayLabels(); 610 createDayLabels();
611 //qDebug("resizeEvent end "); 611 //qDebug("resizeEvent end ");
612 612
613} 613}
614void KOAgendaView::slotDaylabelClicked( int num ) 614void KOAgendaView::slotDaylabelClicked( int num )
615{ 615{
616 616
617 QDate firstDate = mSelectedDates.first(); 617 QDate firstDate = mSelectedDates.first();
618 if ( num == -1 ) 618 if ( num == -1 )
619 emit showDateView( 6, firstDate ); 619 emit showDateView( 6, firstDate );
620 else if (num >= 0 ) { 620 else if (num >= 0 ) {
621 if ( mSelectedDates.count() == 1) 621 if ( mSelectedDates.count() == 1)
622 emit showDateView( 9, firstDate.addDays( num ) ); 622 emit showDateView( 9, firstDate.addDays( num ) );
623 else 623 else
624 emit showDateView( 3, firstDate.addDays( num ) ); 624 emit showDateView( 3, firstDate.addDays( num ) );
625 } 625 }
626 else 626 else
627 showDateView( 10, firstDate.addDays(1) ); 627 showDateView( 10, firstDate.addDays(1) );
628} 628}
629 629
630KOAgendaButton* KOAgendaView::getNewDaylabel() 630KOAgendaButton* KOAgendaView::getNewDaylabel()
631{ 631{
632 632
633 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 633 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
634 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 634 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
635 mDayLabelsList.append( dayLabel ); 635 mDayLabelsList.append( dayLabel );
636 mLayoutDayLabels->addWidget(dayLabel); 636 mLayoutDayLabels->addWidget(dayLabel);
637 return dayLabel ; 637 return dayLabel ;
638} 638}
639 639
640void KOAgendaView::createDayLabels() 640void KOAgendaView::createDayLabels()
641{ 641{
642 642
643 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 643 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
644 // qDebug(" KOAgendaView::createDayLabels() blocked "); 644 // qDebug(" KOAgendaView::createDayLabels() blocked ");
645 return; 645 return;
646 646
647 } 647 }
648 int newHight; 648 int newHight;
649 649
650 // ### Before deleting and recreating we could check if mSelectedDates changed... 650 // ### Before deleting and recreating we could check if mSelectedDates changed...
651 // It would remove some flickering and gain speed (since this is called by 651 // It would remove some flickering and gain speed (since this is called by
652 // each updateView() call) 652 // each updateView() call)
653 653
654 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 654 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
655 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 655 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
656 if ( maxWid < 0 ) 656 if ( maxWid < 0 )
657 maxWid = 20; 657 maxWid = 20;
658 658
659 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 659 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
660 QFontMetrics fm ( dlf ); 660 QFontMetrics fm ( dlf );
661 int selCount = mSelectedDates.count(); 661 int selCount = mSelectedDates.count();
662 QString dayTest = "Mon 20"; 662 QString dayTest = "Mon 20";
663 //QString dayTest = "Mon 20"; 663 //QString dayTest = "Mon 20";
664 int wid = fm.width( dayTest ); 664 int wid = fm.width( dayTest );
665 //maxWid -= ( selCount * 3 ); //working for QLabels 665 //maxWid -= ( selCount * 3 ); //working for QLabels
666 maxWid -= ( selCount * 3 ); //working for QPushButton 666 maxWid -= ( selCount * 3 ); //working for QPushButton
667 if ( maxWid < 0 ) 667 if ( maxWid < 0 )
668 maxWid = 20; 668 maxWid = 20;
669 int needWid = wid * selCount; 669 int needWid = wid * selCount;
670 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 670 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
671 //if ( needWid > maxWid ) 671 //if ( needWid > maxWid )
672 // qDebug("DAYLABELS TOOOOOOO BIG "); 672 // qDebug("DAYLABELS TOOOOOOO BIG ");
673 while ( needWid > maxWid ) { 673 while ( needWid > maxWid ) {
674 dayTest = dayTest.left( dayTest.length() - 1 ); 674 dayTest = dayTest.left( dayTest.length() - 1 );
675 wid = fm.width( dayTest ); 675 wid = fm.width( dayTest );
676 needWid = wid * selCount; 676 needWid = wid * selCount;
677 } 677 }
678 int maxLen = dayTest.length(); 678 int maxLen = dayTest.length();
679 int fontPoint = dlf.pointSize(); 679 int fontPoint = dlf.pointSize();
680 if ( maxLen < 2 ) { 680 if ( maxLen < 2 ) {
681 int fontPoint = dlf.pointSize(); 681 int fontPoint = dlf.pointSize();
682 while ( fontPoint > 4 ) { 682 while ( fontPoint > 4 ) {
683 --fontPoint; 683 --fontPoint;
684 dlf.setPointSize( fontPoint ); 684 dlf.setPointSize( fontPoint );
685 QFontMetrics f( dlf ); 685 QFontMetrics f( dlf );
686 wid = f.width( "30" ); 686 wid = f.width( "30" );
687 needWid = wid * selCount; 687 needWid = wid * selCount;
688 if ( needWid < maxWid ) 688 if ( needWid < maxWid )
689 break; 689 break;
690 } 690 }
691 maxLen = 2; 691 maxLen = 2;
692 } 692 }
693 //qDebug("Max len %d ", dayTest.length() ); 693 //qDebug("Max len %d ", dayTest.length() );
694 694
695 QFontMetrics tempF( dlf ); 695 QFontMetrics tempF( dlf );
696 newHight = tempF.height(); 696 newHight = tempF.height();
697 mDayLabels->setFont( dlf ); 697 mDayLabels->setFont( dlf );
698 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 698 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
699 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 699 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
700 //mLayoutDayLabels->addSpacing( 2 ); 700 //mLayoutDayLabels->addSpacing( 2 );
701 // QFont lFont = dlf; 701 // QFont lFont = dlf;
702 bool appendLabels = false; 702 bool appendLabels = false;
703 KOAgendaButton *dayLabel; 703 KOAgendaButton *dayLabel;
704 dayLabel = mDayLabelsList.first(); 704 dayLabel = mDayLabelsList.first();
705 if ( !dayLabel ) { 705 if ( !dayLabel ) {
706 appendLabels = true; 706 appendLabels = true;
707 dayLabel = getNewDaylabel(); 707 dayLabel = getNewDaylabel();
708 } 708 }
709 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 709 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
710 dayLabel->setFont( dlf ); 710 dayLabel->setFont( dlf );
711 dayLabel->setNum( -1 ); 711 dayLabel->setNum( -1 );
712 //dayLabel->setAlignment(QLabel::AlignHCenter); 712 //dayLabel->setAlignment(QLabel::AlignHCenter);
713 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 713 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
714 dayLabel->show(); 714 dayLabel->show();
715 DateList::ConstIterator dit; 715 DateList::ConstIterator dit;
716 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 716 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
717 int counter = -1; 717 int counter = -1;
718 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 718 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
719 ++counter; 719 ++counter;
720 QDate date = *dit; 720 QDate date = *dit;
721 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 721 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
722 if ( ! appendLabels ) { 722 if ( ! appendLabels ) {
723 dayLabel = mDayLabelsList.next(); 723 dayLabel = mDayLabelsList.next();
724 if ( !dayLabel ) 724 if ( !dayLabel )
725 appendLabels = true; 725 appendLabels = true;
726 } 726 }
727 if ( appendLabels ) { 727 if ( appendLabels ) {
728 dayLabel = getNewDaylabel(); 728 dayLabel = getNewDaylabel();
729 } 729 }
730 dayLabel->setMinimumWidth( 1 ); 730 dayLabel->setMinimumWidth( 1 );
731 dayLabel->setMaximumWidth( 1024 ); 731 dayLabel->setMaximumWidth( 10240 );
732 dayLabel->setFont( dlf ); 732 dayLabel->setFont( dlf );
733 dayLabel->show(); 733 dayLabel->show();
734 dayLabel->setNum( counter ); 734 dayLabel->setNum( counter );
735 QString str; 735 QString str;
736 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 736 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
737 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 737 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
738 switch ( maxLen ) { 738 switch ( maxLen ) {
739 case 2: 739 case 2:
740 str = QString::number( date.day() ); 740 str = QString::number( date.day() );
741 break; 741 break;
742 742
743 case 3: 743 case 3:
744 str = dayName.left( 1 ) +QString::number( date.day()); 744 str = dayName.left( 1 ) +QString::number( date.day());
745 745
746 break; 746 break;
747 case 4: 747 case 4:
748 str = dayName.left( 1 ) + " " +QString::number( date.day()); 748 str = dayName.left( 1 ) + " " +QString::number( date.day());
749 749
750 break; 750 break;
751 case 5: 751 case 5:
752 str = dayName.left( 2 ) + " " +QString::number( date.day()); 752 str = dayName.left( 2 ) + " " +QString::number( date.day());
753 753
754 break; 754 break;
755 case 6: 755 case 6:
756 str = dayName.left( 3 ) + " " +QString::number( date.day()); 756 str = dayName.left( 3 ) + " " +QString::number( date.day());
757 break; 757 break;
758 758
759 default: 759 default:
760 break; 760 break;
761 } 761 }
762 if ( oneday ) { 762 if ( oneday ) {
763 QString addString; 763 QString addString;
764 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 764 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
765 addString = i18n("Today"); 765 addString = i18n("Today");
766 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 766 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
767 addString = i18n("Tomorrow"); 767 addString = i18n("Tomorrow");
768 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 768 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
769 addString = i18n("Yesterday"); 769 addString = i18n("Yesterday");
770 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 770 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
771 addString = i18n("Day before yesterday"); 771 addString = i18n("Day before yesterday");
772 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 772 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
773 addString = i18n("Day after tomorrow"); 773 addString = i18n("Day after tomorrow");
774 if ( !addString.isEmpty() ) { 774 if ( !addString.isEmpty() ) {
775 str = addString+", " + str; 775 str = addString+", " + str;
776 } 776 }
777 } 777 }
778 dayLabel->setText(str); 778 dayLabel->setText(str);
779 //dayLabel->setAlignment(QLabel::AlignHCenter); 779 //dayLabel->setAlignment(QLabel::AlignHCenter);
780 if (date == QDate::currentDate()) { 780 if (date == QDate::currentDate()) {
781 QFont bFont = dlf; 781 QFont bFont = dlf;
782 bFont.setBold( true ); 782 bFont.setBold( true );
783 dayLabel->setFont(bFont); 783 dayLabel->setFont(bFont);
784 } 784 }
785 //dayLayout->addWidget(dayLabel); 785 //dayLayout->addWidget(dayLabel);
786 786
787#ifndef KORG_NOPLUGINS 787#ifndef KORG_NOPLUGINS
788 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 788 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
789 CalendarDecoration *it; 789 CalendarDecoration *it;
790 for(it = cds.first(); it; it = cds.next()) { 790 for(it = cds.first(); it; it = cds.next()) {
791 QString text = it->shortText( date ); 791 QString text = it->shortText( date );
792 if ( !text.isEmpty() ) { 792 if ( !text.isEmpty() ) {
793 QLabel *label = new QLabel(text,mDayLabels); 793 QLabel *label = new QLabel(text,mDayLabels);
794 label->setAlignment(AlignCenter); 794 label->setAlignment(AlignCenter);
795 dayLayout->addWidget(label); 795 dayLayout->addWidget(label);
796 } 796 }
797 } 797 }
798 798
799 for(it = cds.first(); it; it = cds.next()) { 799 for(it = cds.first(); it; it = cds.next()) {
800 QWidget *wid = it->smallWidget(mDayLabels,date); 800 QWidget *wid = it->smallWidget(mDayLabels,date);
801 if ( wid ) { 801 if ( wid ) {
802 // wid->setHeight(20); 802 // wid->setHeight(20);
803 dayLayout->addWidget(wid); 803 dayLayout->addWidget(wid);
804 } 804 }
805 } 805 }
806#endif 806#endif
807 } 807 }
808 if ( ! appendLabels ) { 808 if ( ! appendLabels ) {
809 dayLabel = mDayLabelsList.next(); 809 dayLabel = mDayLabelsList.next();
810 if ( !dayLabel ) 810 if ( !dayLabel )
811 appendLabels = true; 811 appendLabels = true;
812 } 812 }
813 if ( appendLabels ) { 813 if ( appendLabels ) {
814 dayLabel = getNewDaylabel(); 814 dayLabel = getNewDaylabel();
815 } 815 }
816 //dayLabel->hide();//test only 816 //dayLabel->hide();//test only
817 817
818 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 818 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
819 if ( offset < 0 ) offset = 0; 819 if ( offset < 0 ) offset = 0;
820 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 820 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
821 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); 821 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
822 dayLabel->setFont( dlf ); 822 dayLabel->setFont( dlf );
823 dayLabel->show(); 823 dayLabel->show();
824 dayLabel->setNum( -2 ); 824 dayLabel->setNum( -2 );
825 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 825 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
826 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 826 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
827 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 827 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
828 if ( !appendLabels ) { 828 if ( !appendLabels ) {
829 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
830 while ( dayLabel ) { 830 while ( dayLabel ) {
831 //qDebug("!dayLabel %d",dayLabel ); 831 //qDebug("!dayLabel %d",dayLabel );
832 dayLabel->hide(); 832 dayLabel->hide();
833 dayLabel = mDayLabelsList.next(); 833 dayLabel = mDayLabelsList.next();
834 } 834 }
835 } 835 }
836 //mDayLabelsFrame->show(); 836 //mDayLabelsFrame->show();
837 //mDayLabels->show(); 837 //mDayLabels->show();
838 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 838 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
839 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 839 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
840 mDayLabelsFrame->setFixedHeight( newHight ); 840 mDayLabelsFrame->setFixedHeight( newHight );
841} 841}
842 842
843int KOAgendaView::maxDatesHint() 843int KOAgendaView::maxDatesHint()
844{ 844{
845 // Not sure about the max number of events, so return 0 for now. 845 // Not sure about the max number of events, so return 0 for now.
846 return 0; 846 return 0;
847} 847}
848 848
849int KOAgendaView::currentDateCount() 849int KOAgendaView::currentDateCount()
850{ 850{
851 return mSelectedDates.count(); 851 return mSelectedDates.count();
852} 852}
853 853
854QPtrList<Incidence> KOAgendaView::selectedIncidences() 854QPtrList<Incidence> KOAgendaView::selectedIncidences()
855{ 855{
856 QPtrList<Incidence> selected; 856 QPtrList<Incidence> selected;
857 Incidence *incidence; 857 Incidence *incidence;
858 858
859 incidence = mAgenda->selectedIncidence(); 859 incidence = mAgenda->selectedIncidence();
860 if (incidence) selected.append(incidence); 860 if (incidence) selected.append(incidence);
861 861
862 incidence = mAllDayAgenda->selectedIncidence(); 862 incidence = mAllDayAgenda->selectedIncidence();
863 if (incidence) selected.append(incidence); 863 if (incidence) selected.append(incidence);
864 864
865 return selected; 865 return selected;
866} 866}
867 867
868DateList KOAgendaView::selectedDates() 868DateList KOAgendaView::selectedDates()
869{ 869{
870 DateList selected; 870 DateList selected;
871 QDate qd; 871 QDate qd;
872 872
873 qd = mAgenda->selectedIncidenceDate(); 873 qd = mAgenda->selectedIncidenceDate();
874 if (qd.isValid()) selected.append(qd); 874 if (qd.isValid()) selected.append(qd);
875 875
876 qd = mAllDayAgenda->selectedIncidenceDate(); 876 qd = mAllDayAgenda->selectedIncidenceDate();
877 if (qd.isValid()) selected.append(qd); 877 if (qd.isValid()) selected.append(qd);
878 878
879 return selected; 879 return selected;
880} 880}
881 881
882 882
883void KOAgendaView::updateView() 883void KOAgendaView::updateView()
884{ 884{
885 if ( mBlockUpdating ) 885 if ( mBlockUpdating )
886 return; 886 return;
887 // kdDebug() << "KOAgendaView::updateView()" << endl; 887 // kdDebug() << "KOAgendaView::updateView()" << endl;
888 fillAgenda(); 888 fillAgenda();
889 889
890} 890}
891 891
892 892
893/* 893/*
894 Update configuration settings for the agenda view. This method is not 894 Update configuration settings for the agenda view. This method is not
895 complete. 895 complete.
896*/ 896*/
897void KOAgendaView::updateConfig() 897void KOAgendaView::updateConfig()
898{ 898{
899 if ( mBlockUpdating ) 899 if ( mBlockUpdating )
900 return; 900 return;
901 901
902 902
903 903
904 // update config for children 904 // update config for children
905 mTimeLabels->updateConfig(); 905 mTimeLabels->updateConfig();
906 mAgenda->storePosition(); 906 mAgenda->storePosition();
907 mAgenda->updateConfig(); 907 mAgenda->updateConfig();
908 mAllDayAgenda->updateConfig(); 908 mAllDayAgenda->updateConfig();
909 // widget synchronization 909 // widget synchronization
910 //TODO: find a better way, maybe signal/slot 910 //TODO: find a better way, maybe signal/slot
911 mTimeLabels->positionChanged(); 911 mTimeLabels->positionChanged();
912 912
913 // for some reason, this needs to be called explicitly 913 // for some reason, this needs to be called explicitly
914 mTimeLabels->repaint(); 914 mTimeLabels->repaint();
915 915
916 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 916 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
917 917
918 // ToolTips displaying summary of events 918 // ToolTips displaying summary of events
919 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 919 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
920 ->mEnableToolTips); 920 ->mEnableToolTips);
921 921
922 //setHolidayMasks(); 922 //setHolidayMasks();
923 923
924 //createDayLabels(); called by via updateView(); 924 //createDayLabels(); called by via updateView();
925 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 925 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
926 updateView(); 926 updateView();
927 mAgenda->restorePosition(); 927 mAgenda->restorePosition();
928} 928}
929 929
930 930
931void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 931void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
932{ 932{
933 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 933 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
934 //qDebug("KOAgendaView::updateEventDates "); 934 //qDebug("KOAgendaView::updateEventDates ");
935 QDateTime startDt,endDt; 935 QDateTime startDt,endDt;
936 QDate startDate; 936 QDate startDate;
937 int lenInSecs; 937 int lenInSecs;
938 // if ( type == KOAgenda::RESIZETOP ) 938 // if ( type == KOAgenda::RESIZETOP )
939 // qDebug("RESIZETOP "); 939 // qDebug("RESIZETOP ");
940 // if ( type == KOAgenda::RESIZEBOTTOM ) 940 // if ( type == KOAgenda::RESIZEBOTTOM )
941 // qDebug("RESIZEBOTTOM "); 941 // qDebug("RESIZEBOTTOM ");
942 // if ( type == KOAgenda::MOVE ) 942 // if ( type == KOAgenda::MOVE )
943 // qDebug("MOVE "); 943 // qDebug("MOVE ");
944 if ( item->incidence()->type() == "Event" ) { 944 if ( item->incidence()->type() == "Event" ) {
945 startDt =item->incidence()->dtStart(); 945 startDt =item->incidence()->dtStart();
946 endDt = item->incidence()->dtEnd(); 946 endDt = item->incidence()->dtEnd();
947 lenInSecs = startDt.secsTo( endDt ); 947 lenInSecs = startDt.secsTo( endDt );
948 } 948 }
949 949
950 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 950 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
951 951
952 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 952 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
953 startDate = mSelectedDates[item->mLastMoveXPos]; 953 startDate = mSelectedDates[item->mLastMoveXPos];
954 } else { 954 } else {
955 if (item->cellX() < 0) { 955 if (item->cellX() < 0) {
956 startDate = (mSelectedDates.first()).addDays(item->cellX()); 956 startDate = (mSelectedDates.first()).addDays(item->cellX());
957 } else { 957 } else {
958 startDate = mSelectedDates[item->cellX()]; 958 startDate = mSelectedDates[item->cellX()];
959 } 959 }
960 } 960 }
961 startDt.setDate(startDate); 961 startDt.setDate(startDate);
962 962
963 if (item->incidence()->doesFloat()) { 963 if (item->incidence()->doesFloat()) {
964 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 964 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
965 } else { 965 } else {
966 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 966 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
967 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 967 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
968 if ( item->incidence()->type() == "Event" ) { 968 if ( item->incidence()->type() == "Event" ) {
969 if ( type == KOAgenda::MOVE ) { 969 if ( type == KOAgenda::MOVE ) {
970 endDt = startDt.addSecs(lenInSecs); 970 endDt = startDt.addSecs(lenInSecs);
971 971
972 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 972 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
973 if (item->lastMultiItem()) { 973 if (item->lastMultiItem()) {
974 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 974 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
975 endDt.setDate(startDate. 975 endDt.setDate(startDate.
976 addDays(item->lastMultiItem()->cellX() - item->cellX())); 976 addDays(item->lastMultiItem()->cellX() - item->cellX()));
977 } else { 977 } else {
978 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 978 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
979 endDt.setDate(startDate); 979 endDt.setDate(startDate);
980 } 980 }
981 } 981 }
982 } else { 982 } else {
983 // todo 983 // todo
984 if (item->lastMultiItem()) { 984 if (item->lastMultiItem()) {
985 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 985 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
986 endDt.setDate(startDate. 986 endDt.setDate(startDate.
987 addDays(item->lastMultiItem()->cellX() - item->cellX())); 987 addDays(item->lastMultiItem()->cellX() - item->cellX()));
988 } else { 988 } else {
989 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 989 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
990 if ( item->cellYBottom() > 0 ) 990 if ( item->cellYBottom() > 0 )
991 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 991 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
992 else 992 else
993 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 993 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
994 endDt.setDate(startDate); 994 endDt.setDate(startDate);
995 } 995 }
996 } 996 }
997 } 997 }
998 if ( item->incidence()->type() == "Event" ) { 998 if ( item->incidence()->type() == "Event" ) {
999 item->incidence()->setDtStart(startDt); 999 item->incidence()->setDtStart(startDt);
1000 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1000 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1001 } else if ( item->incidence()->type() == "Todo" ) { 1001 } else if ( item->incidence()->type() == "Todo" ) {
1002 Todo* to = static_cast<Todo*>(item->incidence()); 1002 Todo* to = static_cast<Todo*>(item->incidence());
1003 1003
1004 to->setDtDue(endDt); 1004 to->setDtDue(endDt);
1005 if ( to->hasStartDate() ) { 1005 if ( to->hasStartDate() ) {
1006 if (to->dtStart() >= to->dtDue() ) 1006 if (to->dtStart() >= to->dtDue() )
1007 to->setDtStart(to->dtDue().addDays( -2 )); 1007 to->setDtStart(to->dtDue().addDays( -2 ));
1008 } 1008 }
1009 1009
1010 } 1010 }
1011 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1011 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1012 item->incidence()->setRevision(item->incidence()->revision()+1); 1012 item->incidence()->setRevision(item->incidence()->revision()+1);
1013 item->setItemDate(startDt.date()); 1013 item->setItemDate(startDt.date());
1014 //item->updateItem(); 1014 //item->updateItem();
1015 if ( item->incidence()->type() == "Todo" ) { 1015 if ( item->incidence()->type() == "Todo" ) {
1016 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1016 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1017 1017
1018 } 1018 }
1019 else 1019 else
1020 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1020 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1021 item->updateItem(); 1021 item->updateItem();
1022} 1022}
1023 1023
1024void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1024void KOAgendaView::showDates( const QDate &start, const QDate &end )
1025{ 1025{
1026 // kdDebug() << "KOAgendaView::selectDates" << endl; 1026 // kdDebug() << "KOAgendaView::selectDates" << endl;
1027 1027
1028 mSelectedDates.clear(); 1028 mSelectedDates.clear();
1029 // qDebug("KOAgendaView::showDates "); 1029 // qDebug("KOAgendaView::showDates ");
1030 QDate d = start; 1030 QDate d = start;
1031 while (d <= end) { 1031 while (d <= end) {
1032 mSelectedDates.append(d); 1032 mSelectedDates.append(d);
1033 d = d.addDays( 1 ); 1033 d = d.addDays( 1 );
1034 } 1034 }
1035 1035
1036 // and update the view 1036 // and update the view
1037 fillAgenda(); 1037 fillAgenda();
1038} 1038}
1039 1039
1040 1040
1041void KOAgendaView::showEvents(QPtrList<Event>) 1041void KOAgendaView::showEvents(QPtrList<Event>)
1042{ 1042{
1043 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1043 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1044} 1044}
1045 1045
1046void KOAgendaView::changeEventDisplay(Event *, int) 1046void KOAgendaView::changeEventDisplay(Event *, int)
1047{ 1047{
1048 // qDebug("KOAgendaView::changeEventDisplay "); 1048 // qDebug("KOAgendaView::changeEventDisplay ");
1049 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1049 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1050 // this should be re-written to be MUCH smarter. Right now we 1050 // this should be re-written to be MUCH smarter. Right now we
1051 // are just playing dumb. 1051 // are just playing dumb.
1052 fillAgenda(); 1052 fillAgenda();
1053} 1053}
1054 1054
1055void KOAgendaView::fillAgenda(const QDate &) 1055void KOAgendaView::fillAgenda(const QDate &)
1056{ 1056{
1057 // qDebug("KOAgendaView::fillAgenda "); 1057 // qDebug("KOAgendaView::fillAgenda ");
1058 fillAgenda(); 1058 fillAgenda();
1059} 1059}
1060 1060
1061void KOAgendaView::fillAgenda() 1061void KOAgendaView::fillAgenda()
1062{ 1062{
1063 if ( globalFlagBlockStartup ) 1063 if ( globalFlagBlockStartup )
1064 return; 1064 return;
1065 if ( globalFlagBlockAgenda == 1 ) 1065 if ( globalFlagBlockAgenda == 1 )
1066 return; 1066 return;
1067 //if ( globalFlagBlockAgenda == 2 ) 1067 //if ( globalFlagBlockAgenda == 2 )
1068 //globalFlagBlockAgenda = 0; 1068 //globalFlagBlockAgenda = 0;
1069 // globalFlagBlockPainting = false; 1069 // globalFlagBlockPainting = false;
1070 if ( globalFlagBlockAgenda == 0 ) 1070 if ( globalFlagBlockAgenda == 0 )
1071 globalFlagBlockAgenda = 1; 1071 globalFlagBlockAgenda = 1;
1072 // clearView(); 1072 // clearView();
1073 //qDebug("fillAgenda()++++ "); 1073 //qDebug("fillAgenda()++++ ");
1074 globalFlagBlockAgendaItemPaint = 1; 1074 globalFlagBlockAgendaItemPaint = 1;
1075 1075
1076 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1076 mAllDayAgenda->changeColumns(mSelectedDates.count());
1077 mAgenda->changeColumns(mSelectedDates.count()); 1077 mAgenda->changeColumns(mSelectedDates.count());
1078 qApp->processEvents(); 1078 qApp->processEvents();
1079 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1079 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1080 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1080 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1081 setHolidayMasks(); 1081 setHolidayMasks();
1082 1082
1083 //mAgenda->hideUnused(); 1083 //mAgenda->hideUnused();
1084 //mAllDayAgenda->hideUnused(); 1084 //mAllDayAgenda->hideUnused();
1085 1085
1086 // mAgenda->blockNextRepaint( false ); 1086 // mAgenda->blockNextRepaint( false );
1087 // mAgenda->viewport()->repaint(); 1087 // mAgenda->viewport()->repaint();
1088 // mAgenda->blockNextRepaint( true ); 1088 // mAgenda->blockNextRepaint( true );
1089 mMinY.resize(mSelectedDates.count()); 1089 mMinY.resize(mSelectedDates.count());
1090 mMaxY.resize(mSelectedDates.count()); 1090 mMaxY.resize(mSelectedDates.count());
1091 1091
1092 QPtrList<Event> dayEvents; 1092 QPtrList<Event> dayEvents;
1093 1093
1094 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1094 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1095 // Therefore, gtodoset all of them. 1095 // Therefore, gtodoset all of them.
1096 QPtrList<Todo> todos = calendar()->todos(); 1096 QPtrList<Todo> todos = calendar()->todos();
1097 1097
1098 mAgenda->setDateList(mSelectedDates); 1098 mAgenda->setDateList(mSelectedDates);
1099 1099
1100 QDate today = QDate::currentDate(); 1100 QDate today = QDate::currentDate();
1101 1101
1102 DateList::ConstIterator dit; 1102 DateList::ConstIterator dit;
1103 int curCol = 0; 1103 int curCol = 0;
1104 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1104 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1105 QDate currentDate = *dit; 1105 QDate currentDate = *dit;
1106 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1106 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1107 // << endl; 1107 // << endl;
1108 1108
1109 dayEvents = calendar()->events(currentDate,true); 1109 dayEvents = calendar()->events(currentDate,true);
1110 1110
1111 // Default values, which can never be reached 1111 // Default values, which can never be reached
1112 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1112 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1113 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1113 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1114 1114
1115 unsigned int numEvent; 1115 unsigned int numEvent;
1116 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1116 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1117 Event *event = dayEvents.at(numEvent); 1117 Event *event = dayEvents.at(numEvent);
1118 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1118 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1119 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1119 if ( event->uid().left(15) == QString("last-syncEvent-") )
1120 continue; 1120 continue;
1121 // kdDebug() << " Event: " << event->summary() << endl; 1121 // kdDebug() << " Event: " << event->summary() << endl;
1122 1122
1123 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1123 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1124 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1124 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1125 1125
1126 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1126 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1127 1127
1128 if (event->doesFloat()) { 1128 if (event->doesFloat()) {
1129 if (event->recurrence()->doesRecur()) { 1129 if (event->recurrence()->doesRecur()) {
1130 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1130 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1131 } else { 1131 } else {
1132 if (beginX <= 0 && curCol == 0) { 1132 if (beginX <= 0 && curCol == 0) {
1133 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1133 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1134 } else if (beginX == curCol) { 1134 } else if (beginX == curCol) {
1135 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1135 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1136 } 1136 }
1137 } 1137 }
1138 } else if (event->isMultiDay()) { 1138 } else if (event->isMultiDay()) {
1139 if ( event->doesRecur () ) { 1139 if ( event->doesRecur () ) {
1140 QDate dateit = currentDate; 1140 QDate dateit = currentDate;
1141 int count = 0; 1141 int count = 0;
1142 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1142 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1143 while (! event->recursOn( dateit ) && count <= max ) { 1143 while (! event->recursOn( dateit ) && count <= max ) {
1144 ++count; 1144 ++count;
1145 dateit = dateit.addDays( -1 ); 1145 dateit = dateit.addDays( -1 );
1146 } 1146 }
1147 bool ok; 1147 bool ok;
1148 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1148 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1149 if ( ok ) 1149 if ( ok )
1150 { 1150 {
1151 int secs = event->dtStart().secsTo( event->dtEnd() ); 1151 int secs = event->dtStart().secsTo( event->dtEnd() );
1152 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1152 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1153 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1153 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1154 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1154 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1155 1155
1156 } 1156 }
1157 } 1157 }
1158 int startY = mAgenda->timeToY(event->dtStart().time()); 1158 int startY = mAgenda->timeToY(event->dtStart().time());
1159 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1159 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1160 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1160 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1161 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1161 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1162 //qDebug("insert!!! "); 1162 //qDebug("insert!!! ");
1163 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1163 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1164 } 1164 }
1165 if (beginX == curCol) { 1165 if (beginX == curCol) {
1166 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1166 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1167 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1167 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1168 } else if (endX == curCol) { 1168 } else if (endX == curCol) {
1169 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1169 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1170 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1170 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1171 } else { 1171 } else {
1172 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1172 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1173 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1173 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1174 } 1174 }
1175 } else { 1175 } else {
1176 int startY = mAgenda->timeToY(event->dtStart().time()); 1176 int startY = mAgenda->timeToY(event->dtStart().time());
1177 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1177 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1178 if (endY < startY) endY = startY; 1178 if (endY < startY) endY = startY;
1179 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1179 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1180 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1180 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1181 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1181 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1182 } 1182 }
1183 } 1183 }
1184 // ---------- [display Todos -------------- 1184 // ---------- [display Todos --------------
1185 unsigned int numTodo; 1185 unsigned int numTodo;
1186 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1186 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1187 Todo *todo = todos.at(numTodo); 1187 Todo *todo = todos.at(numTodo);
1188 1188
1189 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1189 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1190 1190
1191 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1191 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1192 // Already completed items can be displayed on their original due date 1192 // Already completed items can be displayed on their original due date
1193 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1193 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1194 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1194 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1195 bool fillIn = false; 1195 bool fillIn = false;
1196 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1196 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1197 fillIn = true; 1197 fillIn = true;
1198 if ( ! fillIn && !todo->hasCompletedDate() ) 1198 if ( ! fillIn && !todo->hasCompletedDate() )
1199 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1199 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1200 if ( fillIn ) { 1200 if ( fillIn ) {
1201 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1201 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1202 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1202 if ( KOPrefs::instance()->mShowTodoInAgenda )
1203 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1203 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1204 } 1204 }
1205 else { 1205 else {
1206 QDateTime dt; 1206 QDateTime dt;
1207 if ( todo->hasCompletedDate() ) 1207 if ( todo->hasCompletedDate() )
1208 dt = todo->completed(); 1208 dt = todo->completed();
1209 else 1209 else
1210 dt = todo->dtDue();; 1210 dt = todo->dtDue();;
1211 1211
1212 1212
1213 int endY = mAgenda->timeToY(dt.time()) - 1; 1213 int endY = mAgenda->timeToY(dt.time()) - 1;
1214 int hi = (18/KOPrefs::instance()->mHourSize); 1214 int hi = (18/KOPrefs::instance()->mHourSize);
1215 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1215 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1216 int startY = endY -hi; 1216 int startY = endY -hi;
1217 1217
1218 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1218 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1219 1219
1220 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1220 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1221 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1221 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1222 } 1222 }
1223 } 1223 }
1224 } 1224 }
1225 // ---------- display Todos] -------------- 1225 // ---------- display Todos] --------------
1226 1226
1227 ++curCol; 1227 ++curCol;
1228 } 1228 }
1229 mAgenda->hideUnused(); 1229 mAgenda->hideUnused();
1230 mAllDayAgenda->hideUnused(); 1230 mAllDayAgenda->hideUnused();
1231 mAgenda->checkScrollBoundaries(); 1231 mAgenda->checkScrollBoundaries();
1232 1232
1233 deleteSelectedDateTime(); 1233 deleteSelectedDateTime();
1234 1234
1235 createDayLabels(); 1235 createDayLabels();
1236 emit incidenceSelected( 0 ); 1236 emit incidenceSelected( 0 );
1237 1237
1238 if ( globalFlagBlockAgenda == 2 ) { 1238 if ( globalFlagBlockAgenda == 2 ) {
1239 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1239 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1240 setStartHour( KOPrefs::instance()->mDayBegins ); 1240 setStartHour( KOPrefs::instance()->mDayBegins );
1241 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1241 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1242 setStartHour( QTime::currentTime ().hour() ); 1242 setStartHour( QTime::currentTime ().hour() );
1243 // qApp->processEvents(); 1243 // qApp->processEvents();
1244 } 1244 }
1245 qApp->processEvents(); 1245 qApp->processEvents();
1246 //qDebug("qApp->processEvents(); END "); 1246 //qDebug("qApp->processEvents(); END ");
1247 globalFlagBlockAgenda = 0; 1247 globalFlagBlockAgenda = 0;
1248 1248
1249 // mAgenda->hideUnused(); 1249 // mAgenda->hideUnused();
1250 //mAllDayAgenda->hideUnused(); 1250 //mAllDayAgenda->hideUnused();
1251 mAllDayAgenda->drawContentsToPainter(); 1251 mAllDayAgenda->drawContentsToPainter();
1252 mAgenda->drawContentsToPainter(); 1252 mAgenda->drawContentsToPainter();
1253 repaintAgenda(); 1253 repaintAgenda();
1254 // mAgenda->finishUpdate(); 1254 // mAgenda->finishUpdate();
1255 //mAllDayAgenda->finishUpdate(); 1255 //mAllDayAgenda->finishUpdate();
1256 1256
1257 // repaintAgenda(); 1257 // repaintAgenda();
1258 //qApp->processEvents(); 1258 //qApp->processEvents();
1259 // globalFlagBlockAgenda = 0; 1259 // globalFlagBlockAgenda = 0;
1260} 1260}
1261void KOAgendaView::repaintAgenda() 1261void KOAgendaView::repaintAgenda()
1262{ 1262{
1263 // mAllDayAgenda->drawContentsToPainter(); 1263 // mAllDayAgenda->drawContentsToPainter();
1264// mAllDayAgenda->viewport()->repaint( false ); 1264// mAllDayAgenda->viewport()->repaint( false );
1265// mAgenda->drawContentsToPainter(); 1265// mAgenda->drawContentsToPainter();
1266// mAgenda->viewport()->repaint( false ); 1266// mAgenda->viewport()->repaint( false );
1267// qApp->processEvents(); 1267// qApp->processEvents();
1268 1268
1269 //qDebug("KOAgendaView::repaintAgenda() "); 1269 //qDebug("KOAgendaView::repaintAgenda() ");
1270 //qApp->processEvents(); 1270 //qApp->processEvents();
1271 mAgenda->viewport()->repaint( false ); 1271 mAgenda->viewport()->repaint( false );
1272 mAllDayAgenda->viewport()->repaint( false ); 1272 mAllDayAgenda->viewport()->repaint( false );
1273 mAgenda->finishUpdate(); 1273 mAgenda->finishUpdate();
1274 mAllDayAgenda->finishUpdate(); 1274 mAllDayAgenda->finishUpdate();
1275} 1275}
1276 1276
1277 1277
1278void KOAgendaView::clearView() 1278void KOAgendaView::clearView()
1279{ 1279{
1280 // kdDebug() << "ClearView" << endl; 1280 // kdDebug() << "ClearView" << endl;
1281 mAllDayAgenda->clear(); 1281 mAllDayAgenda->clear();
1282 mAgenda->clear(); 1282 mAgenda->clear();
1283} 1283}
1284 1284
1285void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1285void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1286 const QDate &td) 1286 const QDate &td)
1287{ 1287{
1288#ifndef KORG_NOPRINTER 1288#ifndef KORG_NOPRINTER
1289 if (fd == td) 1289 if (fd == td)
1290 calPrinter->preview(CalPrinter::Day, fd, td); 1290 calPrinter->preview(CalPrinter::Day, fd, td);
1291 else 1291 else
1292 calPrinter->preview(CalPrinter::Week, fd, td); 1292 calPrinter->preview(CalPrinter::Week, fd, td);
1293#endif 1293#endif
1294} 1294}
1295 1295
1296// void KOAgendaView::updateMovedTodo() 1296// void KOAgendaView::updateMovedTodo()
1297// { 1297// {
1298// // updateConfig(); 1298// // updateConfig();
1299// // emit updateTodoViews(); 1299// // emit updateTodoViews();
1300// } 1300// }
1301 1301
1302void KOAgendaView::newEvent(int gx, int gy) 1302void KOAgendaView::newEvent(int gx, int gy)
1303{ 1303{
1304 if (!mSelectedDates.count()) return; 1304 if (!mSelectedDates.count()) return;
1305 1305
1306 QDate day = mSelectedDates[gx]; 1306 QDate day = mSelectedDates[gx];
1307 1307
1308 QTime time = mAgenda->gyToTime(gy); 1308 QTime time = mAgenda->gyToTime(gy);
1309 QDateTime dt(day,time); 1309 QDateTime dt(day,time);
1310 // if ( dt < QDateTime::currentDateTime () ) 1310 // if ( dt < QDateTime::currentDateTime () )
1311 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1311 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1312 emit newEventSignal(dt); 1312 emit newEventSignal(dt);
1313} 1313}
1314 1314
1315void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1315void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1316{ 1316{
1317 if (!mSelectedDates.count()) return; 1317 if (!mSelectedDates.count()) return;
1318 1318
1319 QDate dayStart = mSelectedDates[gxStart]; 1319 QDate dayStart = mSelectedDates[gxStart];
1320 QDate dayEnd = mSelectedDates[gxEnd]; 1320 QDate dayEnd = mSelectedDates[gxEnd];
1321 1321
1322 QTime timeStart = mAgenda->gyToTime(gyStart); 1322 QTime timeStart = mAgenda->gyToTime(gyStart);
1323 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1323 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1324 1324
1325 QDateTime dtStart(dayStart,timeStart); 1325 QDateTime dtStart(dayStart,timeStart);
1326 QDateTime dtEnd(dayEnd,timeEnd); 1326 QDateTime dtEnd(dayEnd,timeEnd);
1327 1327
1328 emit newEventSignal(dtStart,dtEnd); 1328 emit newEventSignal(dtStart,dtEnd);
1329} 1329}
1330 1330
1331void KOAgendaView::newEventAllDay(int gx, int ) 1331void KOAgendaView::newEventAllDay(int gx, int )
1332{ 1332{
1333 if (!mSelectedDates.count()) return; 1333 if (!mSelectedDates.count()) return;
1334 1334
1335 QDate day = mSelectedDates[gx]; 1335 QDate day = mSelectedDates[gx];
1336 1336
1337 emit newEventSignal(day); 1337 emit newEventSignal(day);
1338} 1338}
1339void KOAgendaView::newTodoAllDay(int gx, int ) 1339void KOAgendaView::newTodoAllDay(int gx, int )
1340{ 1340{
1341 if (!mSelectedDates.count()) return; 1341 if (!mSelectedDates.count()) return;
1342 1342
1343 QDateTime day (mSelectedDates[gx] ); 1343 QDateTime day (mSelectedDates[gx] );
1344 emit newTodoSignal(day, true); 1344 emit newTodoSignal(day, true);
1345} 1345}
1346void KOAgendaView::newTodo(int gx, int gy ) 1346void KOAgendaView::newTodo(int gx, int gy )
1347{ 1347{
1348 if (!mSelectedDates.count()) return; 1348 if (!mSelectedDates.count()) return;
1349 QDate dayStart = mSelectedDates[gx]; 1349 QDate dayStart = mSelectedDates[gx];
1350 QTime timeStart = mAgenda->gyToTime(gy); 1350 QTime timeStart = mAgenda->gyToTime(gy);
1351 QDateTime dt (dayStart,timeStart); 1351 QDateTime dt (dayStart,timeStart);
1352 emit newTodoSignal( dt, false ); 1352 emit newTodoSignal( dt, false );
1353} 1353}
1354 1354
1355void KOAgendaView::updateEventIndicatorTop(int newY) 1355void KOAgendaView::updateEventIndicatorTop(int newY)
1356{ 1356{
1357 uint i; 1357 uint i;
1358 for(i=0;i<mMinY.size();++i) { 1358 for(i=0;i<mMinY.size();++i) {
1359 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1359 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1360 else mEventIndicatorTop->enableColumn(i,false); 1360 else mEventIndicatorTop->enableColumn(i,false);
1361 } 1361 }
1362 1362
1363 mEventIndicatorTop->update(); 1363 mEventIndicatorTop->update();
1364} 1364}
1365 1365
1366void KOAgendaView::updateEventIndicatorBottom(int newY) 1366void KOAgendaView::updateEventIndicatorBottom(int newY)
1367{ 1367{
1368 uint i; 1368 uint i;
1369 for(i=0;i<mMaxY.size();++i) { 1369 for(i=0;i<mMaxY.size();++i) {
1370 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1370 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1371 else mEventIndicatorBottom->enableColumn(i,false); 1371 else mEventIndicatorBottom->enableColumn(i,false);
1372 } 1372 }
1373 1373
1374 mEventIndicatorBottom->update(); 1374 mEventIndicatorBottom->update();
1375} 1375}
1376 1376
1377void KOAgendaView::startDrag(Event *event) 1377void KOAgendaView::startDrag(Event *event)
1378{ 1378{
1379#ifndef KORG_NODND 1379#ifndef KORG_NODND
1380 DndFactory factory( calendar() ); 1380 DndFactory factory( calendar() );
1381 ICalDrag *vd = factory.createDrag(event,this); 1381 ICalDrag *vd = factory.createDrag(event,this);
1382 if (vd->drag()) { 1382 if (vd->drag()) {
1383 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1383 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1384 } 1384 }
1385#endif 1385#endif
1386} 1386}
1387 1387
1388void KOAgendaView::readSettings() 1388void KOAgendaView::readSettings()
1389{ 1389{
1390 readSettings(KOGlobals::config()); 1390 readSettings(KOGlobals::config());
1391} 1391}
1392 1392
1393void KOAgendaView::readSettings(KConfig *config) 1393void KOAgendaView::readSettings(KConfig *config)
1394{ 1394{
1395 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1395 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1396 1396
1397 config->setGroup("Views"); 1397 config->setGroup("Views");
1398 1398
1399 //#ifndef KORG_NOSPLITTER 1399 //#ifndef KORG_NOSPLITTER
1400 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1400 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1401 if (sizes.count() == 2) { 1401 if (sizes.count() == 2) {
1402 if ( sizes[0] < 20 ) { 1402 if ( sizes[0] < 20 ) {
1403 sizes[1] = sizes[1] +20 - sizes[0]; 1403 sizes[1] = sizes[1] +20 - sizes[0];
1404 sizes[0] = 20; 1404 sizes[0] = 20;
1405 } 1405 }
1406 mSplitterAgenda->setSizes(sizes); 1406 mSplitterAgenda->setSizes(sizes);
1407 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1407 // qDebug("read %d %d ",sizes[0],sizes[1] );
1408 } 1408 }
1409 //#endif 1409 //#endif
1410 1410
1411 // updateConfig(); 1411 // updateConfig();
1412} 1412}
1413 1413
1414void KOAgendaView::writeSettings(KConfig *config) 1414void KOAgendaView::writeSettings(KConfig *config)
1415{ 1415{
1416 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1416 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1417 1417
1418 config->setGroup("Views"); 1418 config->setGroup("Views");
1419 1419
1420 //#ifndef KORG_NOSPLITTER 1420 //#ifndef KORG_NOSPLITTER
1421 QValueList<int> list = mSplitterAgenda->sizes(); 1421 QValueList<int> list = mSplitterAgenda->sizes();
1422 config->writeEntry("Separator AgendaView",list); 1422 config->writeEntry("Separator AgendaView",list);
1423 //qDebug("write %d %d ", list[0],list[1] ); 1423 //qDebug("write %d %d ", list[0],list[1] );
1424 //#endif 1424 //#endif
1425} 1425}
1426 1426
1427void KOAgendaView::setHolidayMasks() 1427void KOAgendaView::setHolidayMasks()
1428{ 1428{
1429 mHolidayMask.resize(mSelectedDates.count()); 1429 mHolidayMask.resize(mSelectedDates.count());
1430 1430
1431 uint i; 1431 uint i;
1432 for(i=0;i<mSelectedDates.count();++i) { 1432 for(i=0;i<mSelectedDates.count();++i) {
1433 QDate date = mSelectedDates[i]; 1433 QDate date = mSelectedDates[i];
1434 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1434 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1435 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1435 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1436 bool showHoliday = false; 1436 bool showHoliday = false;
1437 if ( KOPrefs::instance()->mExcludeHolidays ) { 1437 if ( KOPrefs::instance()->mExcludeHolidays ) {
1438 QPtrList<Event> events = calendar()->events( date, true ); 1438 QPtrList<Event> events = calendar()->events( date, true );
1439 Event *event; 1439 Event *event;
1440 for( event = events.first(); event; event = events.next() ) { 1440 for( event = events.first(); event; event = events.next() ) {
1441 if ( event->categories().contains("Holiday") || 1441 if ( event->categories().contains("Holiday") ||
1442 event->categories().contains(i18n("Holiday"))) { 1442 event->categories().contains(i18n("Holiday"))) {
1443 showHoliday = true; 1443 showHoliday = true;
1444 break; 1444 break;
1445 } 1445 }
1446 } 1446 }
1447 1447
1448 } 1448 }
1449 1449
1450#ifndef KORG_NOPLUGINS 1450#ifndef KORG_NOPLUGINS
1451 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1451 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1452 !KOCore::self()->holiday(date).isEmpty(); 1452 !KOCore::self()->holiday(date).isEmpty();
1453#endif 1453#endif
1454 bool showDay = showSaturday || showSunday || showHoliday; 1454 bool showDay = showSaturday || showSunday || showHoliday;
1455 1455
1456 if (showDay) { 1456 if (showDay) {
1457 mHolidayMask.at(i) = true; 1457 mHolidayMask.at(i) = true;
1458 } else { 1458 } else {
1459 mHolidayMask.at(i) = false; 1459 mHolidayMask.at(i) = false;
1460 } 1460 }
1461 } 1461 }
1462 1462
1463 mAgenda->setHolidayMask(&mHolidayMask); 1463 mAgenda->setHolidayMask(&mHolidayMask);
1464 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1464 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1465} 1465}
1466 1466
1467void KOAgendaView::setContentsPos(int y) 1467void KOAgendaView::setContentsPos(int y)
1468{ 1468{
1469 mAgenda->setContentsPos(0,y); 1469 mAgenda->setContentsPos(0,y);
1470} 1470}
1471 1471
1472void KOAgendaView::setExpandedButton( bool expanded ) 1472void KOAgendaView::setExpandedButton( bool expanded )
1473{ 1473{
1474 if ( expanded ) { 1474 if ( expanded ) {
1475 mExpandButton->setPixmap( mExpandedPixmap ); 1475 mExpandButton->setPixmap( mExpandedPixmap );
1476 } else { 1476 } else {
1477 mExpandButton->setPixmap( mNotExpandedPixmap ); 1477 mExpandButton->setPixmap( mNotExpandedPixmap );
1478 } 1478 }
1479} 1479}
1480 1480
1481void KOAgendaView::clearSelection() 1481void KOAgendaView::clearSelection()
1482{ 1482{
1483 mAgenda->deselectItem(); 1483 mAgenda->deselectItem();
1484 mAllDayAgenda->deselectItem(); 1484 mAllDayAgenda->deselectItem();
1485} 1485}
1486 1486
1487void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1487void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1488 int gxEnd, int gyEnd) 1488 int gxEnd, int gyEnd)
1489{ 1489{
1490 mTimeSpanInAllDay = true; 1490 mTimeSpanInAllDay = true;
1491 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1491 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1492} 1492}
1493 1493
1494 1494
1495 1495
1496 1496
1497void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1497void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1498 int gxEnd, int gyEnd) 1498 int gxEnd, int gyEnd)
1499{ 1499{