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