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