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