summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index d7ea4d4..e029fdb 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1193 +1,1195 @@
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 setMinimumHeight(mPixmap.height());
271 setMaximumHeight(0);
272 else
273 setMinimumHeight(mPixmap.height());
274} 271}
275 272
276EventIndicator::~EventIndicator() 273EventIndicator::~EventIndicator()
277{ 274{
278} 275}
279 276
280void EventIndicator::drawContents(QPainter *p) 277void EventIndicator::drawContents(QPainter *p)
281{ 278{
282 279
283 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 280 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
284 KDGanttSplitterHandle* han = 0; 281 KDGanttSplitterHandle* han = 0;
285 if ( mPaintWidget ) 282 if ( mPaintWidget )
286 han = mPaintWidget->firstHandle(); 283 han = mPaintWidget->firstHandle();
287 if ( ! han ) { 284 if ( ! han ) {
288 int i; 285 int i;
289 for(i=0;i<mColumns;++i) { 286 for(i=0;i<mColumns;++i) {
290 if (mEnabled[i]) { 287 if (mEnabled[i]) {
291 int cellWidth = contentsRect().right()/mColumns; 288 int cellWidth = contentsRect().right()/mColumns;
292 int xOffset = KOGlobals::self()->reverseLayout() ? 289 int xOffset = KOGlobals::self()->reverseLayout() ?
293 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 290 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
294 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 291 i*cellWidth + (cellWidth -mPixmap.width()) /2;
295 p->drawPixmap(QPoint(xOffset,0),mPixmap); 292 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
296 } 293 }
297 } 294 }
298 } else { 295 } else {
299 han->repaint(); 296 han->repaint();
300 //mPaintWidget->setBackgroundColor( red ); 297 //mPaintWidget->setBackgroundColor( red );
301 298
302 QPainter pa( han ); 299 QPainter pa( han );
303 int i; 300 int i;
304 bool setColor = false; 301 bool setColor = false;
305 for(i=0;i<mColumns;++i) { 302 for(i=0;i<mColumns;++i) {
306 if (mEnabled[i]) { 303 if (mEnabled[i]) {
307 setColor = true; 304 setColor = true;
308 305
309 int cellWidth = contentsRect().right()/mColumns; 306 int cellWidth = contentsRect().right()/mColumns;
310 int xOffset = KOGlobals::self()->reverseLayout() ? 307 int xOffset = KOGlobals::self()->reverseLayout() ?
311 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 308 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
312 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 309 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
313 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 310 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
314 //qDebug("222draw pix %d ",xOffset ); 311 //qDebug("222draw pix %d ",xOffset );
315 312
316 } 313 }
317 314
318 } 315 }
319 pa.end(); 316 pa.end();
320 317
321 } 318 }
322} 319}
323 320
324void EventIndicator::setXOffset( int x ) 321void EventIndicator::setXOffset( int x )
325{ 322{
326 mXOffset = x; 323 mXOffset = x;
327} 324}
328void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 325void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
329{ 326{
330 mPaintWidget = w; 327 mPaintWidget = w;
328 setMaximumHeight(0);
329 setMinimumHeight(0);
331} 330}
332void EventIndicator::changeColumns(int columns) 331void EventIndicator::changeColumns(int columns)
333{ 332{
334 mColumns = columns; 333 mColumns = columns;
335 mEnabled.resize(mColumns); 334 mEnabled.resize(mColumns);
336 335
337 update(); 336 update();
338} 337}
339 338
340void EventIndicator::enableColumn(int column, bool enable) 339void EventIndicator::enableColumn(int column, bool enable)
341{ 340{
342 mEnabled[column] = enable; 341 mEnabled[column] = enable;
343} 342}
344 343
345 344
346//////////////////////////////////////////////////////////////////////////// 345////////////////////////////////////////////////////////////////////////////
347//////////////////////////////////////////////////////////////////////////// 346////////////////////////////////////////////////////////////////////////////
348//////////////////////////////////////////////////////////////////////////// 347////////////////////////////////////////////////////////////////////////////
349 348
350KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 349KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
351 KOEventView (cal,parent,name) 350 KOEventView (cal,parent,name)
352{ 351{
353 mBlockUpdating = true; 352 mBlockUpdating = true;
354 mStartHour = 8; 353 mStartHour = 8;
355 mSelectedDates.append(QDate::currentDate()); 354 mSelectedDates.append(QDate::currentDate());
356 355
357 mLayoutDayLabels = 0; 356 mLayoutDayLabels = 0;
358 mDayLabelsFrame = 0; 357 mDayLabelsFrame = 0;
359 mDayLabels = 0; 358 mDayLabels = 0;
360 bool isRTL = KOGlobals::self()->reverseLayout(); 359 bool isRTL = KOGlobals::self()->reverseLayout();
361 360
362 if ( KOPrefs::instance()->mVerticalScreen ) { 361 if ( KOPrefs::instance()->mVerticalScreen ) {
363 mExpandedPixmap = SmallIcon( "1downarrow" ); 362 mExpandedPixmap = SmallIcon( "1downarrow" );
364 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 363 mNotExpandedPixmap = SmallIcon( "1uparrow" );
365 } else { 364 } else {
366 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 365 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
367 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 366 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
368 } 367 }
369 368
370 QBoxLayout *topLayout = new QVBoxLayout(this); 369 QBoxLayout *topLayout = new QVBoxLayout(this);
371 370
372 // Create day name labels for agenda columns 371 // Create day name labels for agenda columns
373 // Create agenda splitter 372 // Create agenda splitter
374 373
375 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 374 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
376 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 375 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
377 topLayout->addWidget( mSplitterAgenda ); 376 topLayout->addWidget( mSplitterAgenda );
378 mAllDayFrame = new QHBox(mSplitterAgenda); 377 mAllDayFrame = new QHBox(mSplitterAgenda);
379 mAllDayFrame->setFocusPolicy(NoFocus); 378 mAllDayFrame->setFocusPolicy(NoFocus);
380 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 379 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
381 agendaFrame->setFocusPolicy(NoFocus); 380 agendaFrame->setFocusPolicy(NoFocus);
382 381
383 // Create all-day agenda widget 382 // Create all-day agenda widget
384 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 383 mDummyAllDayLeft = new QVBox( mAllDayFrame );
385 384
386 mExpandButton = new QPushButton(mDummyAllDayLeft); 385 mExpandButton = new QPushButton(mDummyAllDayLeft);
387 mExpandButton->setPixmap( mNotExpandedPixmap ); 386 mExpandButton->setPixmap( mNotExpandedPixmap );
388 int widebut = mExpandButton->sizeHint().width(); 387 int widebut = mExpandButton->sizeHint().width();
389 if ( QApplication::desktop()->width() < 480 ) 388 if ( QApplication::desktop()->width() < 480 )
390 widebut = widebut*2; 389 widebut = widebut*2;
391 else 390 else
392 widebut = (widebut*3) / 2; 391 widebut = (widebut*3) / 2;
393 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 392 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
394 // QSizePolicy::Fixed ) ); 393 // QSizePolicy::Fixed ) );
395 mExpandButton->setFixedSize( widebut, widebut); 394 mExpandButton->setFixedSize( widebut, widebut);
396 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 395 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
397 mExpandButton->setFocusPolicy(NoFocus); 396 mExpandButton->setFocusPolicy(NoFocus);
398 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 397 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
399 mAllDayAgenda->setFocusPolicy(NoFocus); 398 mAllDayAgenda->setFocusPolicy(NoFocus);
400 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 399 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
401 400
402 // Create event context menu for all day agenda 401 // Create event context menu for all day agenda
403 mAllDayAgendaPopup = eventPopup(); 402 mAllDayAgendaPopup = eventPopup();
404 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 403 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
405 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 404 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
406 405
407 // Create agenda frame 406 // Create agenda frame
408 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 407 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
409 // QHBox *agendaFrame = new QHBox(splitterAgenda); 408 // QHBox *agendaFrame = new QHBox(splitterAgenda);
410 409
411 // create event indicator bars 410 // create event indicator bars
412 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 411 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
413 agendaLayout->addWidget(mEventIndicatorTop,0,1); 412#ifndef DESKTOP_VERSION
414 413 // FIX
414 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
415#endif
415 mDayLabelsFrame = new QHBox(agendaFrame); 416 mDayLabelsFrame = new QHBox(agendaFrame);
416 //topLayout->addWidget(mDayLabelsFrame); 417 //topLayout->addWidget(mDayLabelsFrame);
417 mDayLabels = new QFrame (mDayLabelsFrame); 418 mDayLabels = new QFrame (mDayLabelsFrame);
418 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 419 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
419 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,1,1,0,2); 420 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
420 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 421 agendaLayout->addWidget(mEventIndicatorTop,1,1);
422
421 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 423 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
422 agendaFrame); 424 agendaFrame);
423 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 425 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
424 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 426 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
425 agendaLayout->addWidget(dummyAgendaRight,0,2); 427 agendaLayout->addWidget(dummyAgendaRight,1,2);
426 428
427 // Create time labels 429 // Create time labels
428 mTimeLabels = new TimeLabels(24,agendaFrame); 430 mTimeLabels = new TimeLabels(24,agendaFrame);
429 agendaLayout->addWidget(mTimeLabels,2,0); 431 agendaLayout->addWidget(mTimeLabels,2,0);
430 connect(mTimeLabels,SIGNAL( scaleChanged()), 432 connect(mTimeLabels,SIGNAL( scaleChanged()),
431 this,SLOT(updateConfig())); 433 this,SLOT(updateConfig()));
432 434
433 // Create agenda 435 // Create agenda
434 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 436 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
435 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 437 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
436 agendaLayout->setColStretch(1,1); 438 agendaLayout->setColStretch(1,1);
437 mAgenda->setFocusPolicy(NoFocus); 439 mAgenda->setFocusPolicy(NoFocus);
438 // Create event context menu for agenda 440 // Create event context menu for agenda
439 mAgendaPopup = eventPopup(); 441 mAgendaPopup = eventPopup();
440 442
441 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 443 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
442 i18n("Toggle Alarm"),mAgenda, 444 i18n("Toggle Alarm"),mAgenda,
443 SLOT(popupAlarm()),true); 445 SLOT(popupAlarm()),true);
444 446
445 447
446 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 448 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
447 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 449 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
448 450
449 // make connections between dependent widgets 451 // make connections between dependent widgets
450 mTimeLabels->setAgenda(mAgenda); 452 mTimeLabels->setAgenda(mAgenda);
451 453
452 // Update widgets to reflect user preferences 454 // Update widgets to reflect user preferences
453 // updateConfig(); 455 // updateConfig();
454 456
455 // createDayLabels(); 457 // createDayLabels();
456 458
457 // these blank widgets make the All Day Event box line up with the agenda 459 // these blank widgets make the All Day Event box line up with the agenda
458 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 460 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
459 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 461 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
460 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 462 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
461 463
462 // Scrolling 464 // Scrolling
463 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 465 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
464 mTimeLabels, SLOT(positionChanged())); 466 mTimeLabels, SLOT(positionChanged()));
465 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 467 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
466 SLOT(setContentsPos(int))); 468 SLOT(setContentsPos(int)));
467 469
468 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 470 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
469 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 471 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
470 472
471 // Create/Show/Edit/Delete Event 473 // Create/Show/Edit/Delete Event
472 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 474 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
473 SLOT(newEvent(int,int))); 475 SLOT(newEvent(int,int)));
474 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 476 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
475 SLOT(newTodo(int,int))); 477 SLOT(newTodo(int,int)));
476 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 478 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
477 SLOT(newEvent(int,int,int,int))); 479 SLOT(newEvent(int,int,int,int)));
478 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 480 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
479 SLOT(newEventAllDay(int,int))); 481 SLOT(newEventAllDay(int,int)));
480 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 482 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
481 SLOT(newTodoAllDay(int,int))); 483 SLOT(newTodoAllDay(int,int)));
482 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 484 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
483 SLOT(newEventAllDay(int,int))); 485 SLOT(newEventAllDay(int,int)));
484 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 486 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
485 SLOT(newTimeSpanSelected(int,int,int,int))); 487 SLOT(newTimeSpanSelected(int,int,int,int)));
486 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 488 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
487 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 489 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
488 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 490 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
489 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 491 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
490 492
491 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 493 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
492 SIGNAL(editIncidenceSignal(Incidence *))); 494 SIGNAL(editIncidenceSignal(Incidence *)));
493 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 495 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
494 SIGNAL(editIncidenceSignal(Incidence *))); 496 SIGNAL(editIncidenceSignal(Incidence *)));
495 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 497 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
496 SIGNAL(showIncidenceSignal(Incidence *))); 498 SIGNAL(showIncidenceSignal(Incidence *)));
497 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 499 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
498 SIGNAL(showIncidenceSignal(Incidence *))); 500 SIGNAL(showIncidenceSignal(Incidence *)));
499 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 501 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
500 SIGNAL(deleteIncidenceSignal(Incidence *))); 502 SIGNAL(deleteIncidenceSignal(Incidence *)));
501 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 503 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
502 SIGNAL(deleteIncidenceSignal(Incidence *))); 504 SIGNAL(deleteIncidenceSignal(Incidence *)));
503 505
504 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 506 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
505 SLOT(updateEventDates(KOAgendaItem *, int ))); 507 SLOT(updateEventDates(KOAgendaItem *, int )));
506 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 508 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
507 SLOT(updateEventDates(KOAgendaItem *, int))); 509 SLOT(updateEventDates(KOAgendaItem *, int)));
508 510
509 // event indicator update 511 // event indicator update
510 connect(mAgenda,SIGNAL(lowerYChanged(int)), 512 connect(mAgenda,SIGNAL(lowerYChanged(int)),
511 SLOT(updateEventIndicatorTop(int))); 513 SLOT(updateEventIndicatorTop(int)));
512 connect(mAgenda,SIGNAL(upperYChanged(int)), 514 connect(mAgenda,SIGNAL(upperYChanged(int)),
513 SLOT(updateEventIndicatorBottom(int))); 515 SLOT(updateEventIndicatorBottom(int)));
514 // drag signals 516 // drag signals
515 /* 517 /*
516 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 518 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
517 SLOT(startDrag(Event *))); 519 SLOT(startDrag(Event *)));
518 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 520 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
519 SLOT(startDrag(Event *))); 521 SLOT(startDrag(Event *)));
520 */ 522 */
521 // synchronize selections 523 // synchronize selections
522 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 524 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
523 mAllDayAgenda, SLOT( deselectItem() ) ); 525 mAllDayAgenda, SLOT( deselectItem() ) );
524 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 526 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
525 mAgenda, SLOT( deselectItem() ) ); 527 mAgenda, SLOT( deselectItem() ) );
526 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 528 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
527 SIGNAL( incidenceSelected( Incidence * ) ) ); 529 SIGNAL( incidenceSelected( Incidence * ) ) );
528 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 530 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
529 SIGNAL( incidenceSelected( Incidence * ) ) ); 531 SIGNAL( incidenceSelected( Incidence * ) ) );
530 connect( mAgenda, SIGNAL( resizedSignal() ), 532 connect( mAgenda, SIGNAL( resizedSignal() ),
531 SLOT( updateConfig( ) ) ); 533 SLOT( updateConfig( ) ) );
532 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 534 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
533 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 535 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
534 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 536 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
535 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 537 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
536 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 538 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
537 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 539 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
538 540
539 541
540} 542}
541 543
542void KOAgendaView::toggleAllDay() 544void KOAgendaView::toggleAllDay()
543{ 545{
544 if ( mSplitterAgenda->firstHandle() ) 546 if ( mSplitterAgenda->firstHandle() )
545 mSplitterAgenda->firstHandle()->toggle(); 547 mSplitterAgenda->firstHandle()->toggle();
546} 548}
547void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 549void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
548{ 550{
549 calendar()->addIncidence( inc ); 551 calendar()->addIncidence( inc );
550 552
551 if ( incOld ) { 553 if ( incOld ) {
552 if ( incOld->type() == "Todo" ) 554 if ( incOld->type() == "Todo" )
553 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 555 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
554 else 556 else
555 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 557 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
556 } 558 }
557 559
558} 560}
559 561
560KOAgendaView::~KOAgendaView() 562KOAgendaView::~KOAgendaView()
561{ 563{
562 delete mAgendaPopup; 564 delete mAgendaPopup;
563 delete mAllDayAgendaPopup; 565 delete mAllDayAgendaPopup;
564 delete KOAgendaItem::paintPix(); 566 delete KOAgendaItem::paintPix();
565 delete KOAgendaItem::paintPixSel(); 567 delete KOAgendaItem::paintPixSel();
566} 568}
567void KOAgendaView::resizeEvent( QResizeEvent* e ) 569void KOAgendaView::resizeEvent( QResizeEvent* e )
568{ 570{
569 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 571 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
570 bool uc = false; 572 bool uc = false;
571 int ow = e->oldSize().width(); 573 int ow = e->oldSize().width();
572 int oh = e->oldSize().height(); 574 int oh = e->oldSize().height();
573 int w = e->size().width(); 575 int w = e->size().width();
574 int h = e->size().height(); 576 int h = e->size().height();
575 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 577 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
576 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 578 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
577 uc = true; 579 uc = true;
578 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 580 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
579 } 581 }
580 mUpcomingWidth = e->size().width() ; 582 mUpcomingWidth = e->size().width() ;
581 if ( mBlockUpdating || uc ) { 583 if ( mBlockUpdating || uc ) {
582 mBlockUpdating = false; 584 mBlockUpdating = false;
583 //mAgenda->setMinimumSize(800 , 600 ); 585 //mAgenda->setMinimumSize(800 , 600 );
584 //qDebug("mAgenda->resize+++++++++++++++ "); 586 //qDebug("mAgenda->resize+++++++++++++++ ");
585 updateConfig(); 587 updateConfig();
586 //qDebug("KOAgendaView::Updating now possible "); 588 //qDebug("KOAgendaView::Updating now possible ");
587 } else 589 } else
588 createDayLabels(); 590 createDayLabels();
589 //qDebug("resizeEvent end "); 591 //qDebug("resizeEvent end ");
590 592
591} 593}
592void KOAgendaView::slotDaylabelClicked( int num ) 594void KOAgendaView::slotDaylabelClicked( int num )
593{ 595{
594 596
595 QDate firstDate = mSelectedDates.first(); 597 QDate firstDate = mSelectedDates.first();
596 if ( num == -1 ) 598 if ( num == -1 )
597 emit showDateView( 6, firstDate ); 599 emit showDateView( 6, firstDate );
598 else if (num >= 0 ) { 600 else if (num >= 0 ) {
599 if ( mSelectedDates.count() == 1) 601 if ( mSelectedDates.count() == 1)
600 emit showDateView( 9, firstDate.addDays( num ) ); 602 emit showDateView( 9, firstDate.addDays( num ) );
601 else 603 else
602 emit showDateView( 3, firstDate.addDays( num ) ); 604 emit showDateView( 3, firstDate.addDays( num ) );
603 } 605 }
604 else 606 else
605 showDateView( 10, firstDate.addDays(1) ); 607 showDateView( 10, firstDate.addDays(1) );
606} 608}
607 609
608KOAgendaButton* KOAgendaView::getNewDaylabel() 610KOAgendaButton* KOAgendaView::getNewDaylabel()
609{ 611{
610 612
611 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 613 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
612 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 614 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
613 mDayLabelsList.append( dayLabel ); 615 mDayLabelsList.append( dayLabel );
614 mLayoutDayLabels->addWidget(dayLabel); 616 mLayoutDayLabels->addWidget(dayLabel);
615 return dayLabel ; 617 return dayLabel ;
616} 618}
617 619
618void KOAgendaView::createDayLabels() 620void KOAgendaView::createDayLabels()
619{ 621{
620 622
621 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 623 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
622 // qDebug(" KOAgendaView::createDayLabels() blocked "); 624 // qDebug(" KOAgendaView::createDayLabels() blocked ");
623 return; 625 return;
624 626
625 } 627 }
626 int newHight; 628 int newHight;
627 629
628 // ### Before deleting and recreating we could check if mSelectedDates changed... 630 // ### Before deleting and recreating we could check if mSelectedDates changed...
629 // It would remove some flickering and gain speed (since this is called by 631 // It would remove some flickering and gain speed (since this is called by
630 // each updateView() call) 632 // each updateView() call)
631 633
632 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 634 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
633 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 635 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
634 if ( maxWid < 0 ) 636 if ( maxWid < 0 )
635 maxWid = 20; 637 maxWid = 20;
636 638
637 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 639 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
638 QFontMetrics fm ( dlf ); 640 QFontMetrics fm ( dlf );
639 int selCount = mSelectedDates.count(); 641 int selCount = mSelectedDates.count();
640 QString dayTest = "Mon 20"; 642 QString dayTest = "Mon 20";
641 //QString dayTest = "Mon 20"; 643 //QString dayTest = "Mon 20";
642 int wid = fm.width( dayTest ); 644 int wid = fm.width( dayTest );
643 //maxWid -= ( selCount * 3 ); //working for QLabels 645 //maxWid -= ( selCount * 3 ); //working for QLabels
644 maxWid -= ( selCount * 3 ); //working for QPushButton 646 maxWid -= ( selCount * 3 ); //working for QPushButton
645 if ( maxWid < 0 ) 647 if ( maxWid < 0 )
646 maxWid = 20; 648 maxWid = 20;
647 int needWid = wid * selCount; 649 int needWid = wid * selCount;
648 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 650 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
649 //if ( needWid > maxWid ) 651 //if ( needWid > maxWid )
650 // qDebug("DAYLABELS TOOOOOOO BIG "); 652 // qDebug("DAYLABELS TOOOOOOO BIG ");
651 while ( needWid > maxWid ) { 653 while ( needWid > maxWid ) {
652 dayTest = dayTest.left( dayTest.length() - 1 ); 654 dayTest = dayTest.left( dayTest.length() - 1 );
653 wid = fm.width( dayTest ); 655 wid = fm.width( dayTest );
654 needWid = wid * selCount; 656 needWid = wid * selCount;
655 } 657 }
656 int maxLen = dayTest.length(); 658 int maxLen = dayTest.length();
657 int fontPoint = dlf.pointSize(); 659 int fontPoint = dlf.pointSize();
658 if ( maxLen < 2 ) { 660 if ( maxLen < 2 ) {
659 int fontPoint = dlf.pointSize(); 661 int fontPoint = dlf.pointSize();
660 while ( fontPoint > 4 ) { 662 while ( fontPoint > 4 ) {
661 --fontPoint; 663 --fontPoint;
662 dlf.setPointSize( fontPoint ); 664 dlf.setPointSize( fontPoint );
663 QFontMetrics f( dlf ); 665 QFontMetrics f( dlf );
664 wid = f.width( "30" ); 666 wid = f.width( "30" );
665 needWid = wid * selCount; 667 needWid = wid * selCount;
666 if ( needWid < maxWid ) 668 if ( needWid < maxWid )
667 break; 669 break;
668 } 670 }
669 maxLen = 2; 671 maxLen = 2;
670 } 672 }
671 //qDebug("Max len %d ", dayTest.length() ); 673 //qDebug("Max len %d ", dayTest.length() );
672 674
673 QFontMetrics tempF( dlf ); 675 QFontMetrics tempF( dlf );
674 newHight = tempF.height(); 676 newHight = tempF.height();
675 mDayLabels->setFont( dlf ); 677 mDayLabels->setFont( dlf );
676 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 678 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
677 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 679 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
678 //mLayoutDayLabels->addSpacing( 2 ); 680 //mLayoutDayLabels->addSpacing( 2 );
679 // QFont lFont = dlf; 681 // QFont lFont = dlf;
680 bool appendLabels = false; 682 bool appendLabels = false;
681 KOAgendaButton *dayLabel; 683 KOAgendaButton *dayLabel;
682 dayLabel = mDayLabelsList.first(); 684 dayLabel = mDayLabelsList.first();
683 if ( !dayLabel ) { 685 if ( !dayLabel ) {
684 appendLabels = true; 686 appendLabels = true;
685 dayLabel = getNewDaylabel(); 687 dayLabel = getNewDaylabel();
686 } 688 }
687 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 689 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
688 dayLabel->setFont( dlf ); 690 dayLabel->setFont( dlf );
689 dayLabel->setNum( -1 ); 691 dayLabel->setNum( -1 );
690 //dayLabel->setAlignment(QLabel::AlignHCenter); 692 //dayLabel->setAlignment(QLabel::AlignHCenter);
691 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 693 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
692 dayLabel->show(); 694 dayLabel->show();
693 DateList::ConstIterator dit; 695 DateList::ConstIterator dit;
694 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 696 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
695 int counter = -1; 697 int counter = -1;
696 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 698 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
697 ++counter; 699 ++counter;
698 QDate date = *dit; 700 QDate date = *dit;
699 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 701 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
700 if ( ! appendLabels ) { 702 if ( ! appendLabels ) {
701 dayLabel = mDayLabelsList.next(); 703 dayLabel = mDayLabelsList.next();
702 if ( !dayLabel ) 704 if ( !dayLabel )
703 appendLabels = true; 705 appendLabels = true;
704 } 706 }
705 if ( appendLabels ) { 707 if ( appendLabels ) {
706 dayLabel = getNewDaylabel(); 708 dayLabel = getNewDaylabel();
707 } 709 }
708 dayLabel->setMinimumWidth( 1 ); 710 dayLabel->setMinimumWidth( 1 );
709 dayLabel->setMaximumWidth( 10240 ); 711 dayLabel->setMaximumWidth( 10240 );
710 dayLabel->setFont( dlf ); 712 dayLabel->setFont( dlf );
711 dayLabel->show(); 713 dayLabel->show();
712 dayLabel->setNum( counter ); 714 dayLabel->setNum( counter );
713 QString str; 715 QString str;
714 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 716 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
715 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 717 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
716 switch ( maxLen ) { 718 switch ( maxLen ) {
717 case 2: 719 case 2:
718 str = QString::number( date.day() ); 720 str = QString::number( date.day() );
719 break; 721 break;
720 722
721 case 3: 723 case 3:
722 str = dayName.left( 1 ) +QString::number( date.day()); 724 str = dayName.left( 1 ) +QString::number( date.day());
723 725
724 break; 726 break;
725 case 4: 727 case 4:
726 str = dayName.left( 1 ) + " " +QString::number( date.day()); 728 str = dayName.left( 1 ) + " " +QString::number( date.day());
727 729
728 break; 730 break;
729 case 5: 731 case 5:
730 str = dayName.left( 2 ) + " " +QString::number( date.day()); 732 str = dayName.left( 2 ) + " " +QString::number( date.day());
731 733
732 break; 734 break;
733 case 6: 735 case 6:
734 str = dayName.left( 3 ) + " " +QString::number( date.day()); 736 str = dayName.left( 3 ) + " " +QString::number( date.day());
735 break; 737 break;
736 738
737 default: 739 default:
738 break; 740 break;
739 } 741 }
740 if ( oneday ) { 742 if ( oneday ) {
741 QString addString; 743 QString addString;
742 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 744 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
743 addString = i18n("Today"); 745 addString = i18n("Today");
744 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 746 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
745 addString = i18n("Tomorrow"); 747 addString = i18n("Tomorrow");
746 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 748 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
747 addString = i18n("Yesterday"); 749 addString = i18n("Yesterday");
748 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 750 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
749 addString = i18n("Day before yesterday"); 751 addString = i18n("Day before yesterday");
750 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 752 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
751 addString = i18n("Day after tomorrow"); 753 addString = i18n("Day after tomorrow");
752 if ( !addString.isEmpty() ) { 754 if ( !addString.isEmpty() ) {
753 str = addString+", " + str; 755 str = addString+", " + str;
754 } 756 }
755 } 757 }
756 dayLabel->setText(str); 758 dayLabel->setText(str);
757 //dayLabel->setAlignment(QLabel::AlignHCenter); 759 //dayLabel->setAlignment(QLabel::AlignHCenter);
758 if (date == QDate::currentDate()) { 760 if (date == QDate::currentDate()) {
759 QFont bFont = dlf; 761 QFont bFont = dlf;
760 bFont.setBold( true ); 762 bFont.setBold( true );
761 dayLabel->setFont(bFont); 763 dayLabel->setFont(bFont);
762 } 764 }
763 //dayLayout->addWidget(dayLabel); 765 //dayLayout->addWidget(dayLabel);
764 766
765#ifndef KORG_NOPLUGINS 767#ifndef KORG_NOPLUGINS
766 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 768 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
767 CalendarDecoration *it; 769 CalendarDecoration *it;
768 for(it = cds.first(); it; it = cds.next()) { 770 for(it = cds.first(); it; it = cds.next()) {
769 QString text = it->shortText( date ); 771 QString text = it->shortText( date );
770 if ( !text.isEmpty() ) { 772 if ( !text.isEmpty() ) {
771 QLabel *label = new QLabel(text,mDayLabels); 773 QLabel *label = new QLabel(text,mDayLabels);
772 label->setAlignment(AlignCenter); 774 label->setAlignment(AlignCenter);
773 dayLayout->addWidget(label); 775 dayLayout->addWidget(label);
774 } 776 }
775 } 777 }
776 778
777 for(it = cds.first(); it; it = cds.next()) { 779 for(it = cds.first(); it; it = cds.next()) {
778 QWidget *wid = it->smallWidget(mDayLabels,date); 780 QWidget *wid = it->smallWidget(mDayLabels,date);
779 if ( wid ) { 781 if ( wid ) {
780 // wid->setHeight(20); 782 // wid->setHeight(20);
781 dayLayout->addWidget(wid); 783 dayLayout->addWidget(wid);
782 } 784 }
783 } 785 }
784#endif 786#endif
785 } 787 }
786 if ( ! appendLabels ) { 788 if ( ! appendLabels ) {
787 dayLabel = mDayLabelsList.next(); 789 dayLabel = mDayLabelsList.next();
788 if ( !dayLabel ) 790 if ( !dayLabel )
789 appendLabels = true; 791 appendLabels = true;
790 } 792 }
791 if ( appendLabels ) { 793 if ( appendLabels ) {
792 dayLabel = getNewDaylabel(); 794 dayLabel = getNewDaylabel();
793 } 795 }
794 //dayLabel->hide();//test only 796 //dayLabel->hide();//test only
795 797
796 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 798 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
797 if ( offset < 0 ) offset = 0; 799 if ( offset < 0 ) offset = 0;
798 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 800 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
799 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); 801 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
800 dayLabel->setFont( dlf ); 802 dayLabel->setFont( dlf );
801 dayLabel->show(); 803 dayLabel->show();
802 dayLabel->setNum( -2 ); 804 dayLabel->setNum( -2 );
803 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 805 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
804 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 806 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
805 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 807 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
806 if ( !appendLabels ) { 808 if ( !appendLabels ) {
807 dayLabel = mDayLabelsList.next(); 809 dayLabel = mDayLabelsList.next();
808 while ( dayLabel ) { 810 while ( dayLabel ) {
809 //qDebug("!dayLabel %d",dayLabel ); 811 //qDebug("!dayLabel %d",dayLabel );
810 dayLabel->hide(); 812 dayLabel->hide();
811 dayLabel = mDayLabelsList.next(); 813 dayLabel = mDayLabelsList.next();
812 } 814 }
813 } 815 }
814 //mDayLabelsFrame->show(); 816 //mDayLabelsFrame->show();
815 //mDayLabels->show(); 817 //mDayLabels->show();
816 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 818 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
817 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 819 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
818 mDayLabelsFrame->setFixedHeight( newHight ); 820 mDayLabelsFrame->setFixedHeight( newHight );
819} 821}
820 822
821int KOAgendaView::maxDatesHint() 823int KOAgendaView::maxDatesHint()
822{ 824{
823 // Not sure about the max number of events, so return 0 for now. 825 // Not sure about the max number of events, so return 0 for now.
824 return 0; 826 return 0;
825} 827}
826 828
827int KOAgendaView::currentDateCount() 829int KOAgendaView::currentDateCount()
828{ 830{
829 return mSelectedDates.count(); 831 return mSelectedDates.count();
830} 832}
831 833
832QPtrList<Incidence> KOAgendaView::selectedIncidences() 834QPtrList<Incidence> KOAgendaView::selectedIncidences()
833{ 835{
834 QPtrList<Incidence> selected; 836 QPtrList<Incidence> selected;
835 Incidence *incidence; 837 Incidence *incidence;
836 838
837 incidence = mAgenda->selectedIncidence(); 839 incidence = mAgenda->selectedIncidence();
838 if (incidence) selected.append(incidence); 840 if (incidence) selected.append(incidence);
839 841
840 incidence = mAllDayAgenda->selectedIncidence(); 842 incidence = mAllDayAgenda->selectedIncidence();
841 if (incidence) selected.append(incidence); 843 if (incidence) selected.append(incidence);
842 844
843 return selected; 845 return selected;
844} 846}
845 847
846DateList KOAgendaView::selectedDates() 848DateList KOAgendaView::selectedDates()
847{ 849{
848 DateList selected; 850 DateList selected;
849 QDate qd; 851 QDate qd;
850 852
851 qd = mAgenda->selectedIncidenceDate(); 853 qd = mAgenda->selectedIncidenceDate();
852 if (qd.isValid()) selected.append(qd); 854 if (qd.isValid()) selected.append(qd);
853 855
854 qd = mAllDayAgenda->selectedIncidenceDate(); 856 qd = mAllDayAgenda->selectedIncidenceDate();
855 if (qd.isValid()) selected.append(qd); 857 if (qd.isValid()) selected.append(qd);
856 858
857 return selected; 859 return selected;
858} 860}
859 861
860 862
861void KOAgendaView::updateView() 863void KOAgendaView::updateView()
862{ 864{
863 if ( mBlockUpdating ) 865 if ( mBlockUpdating )
864 return; 866 return;
865 // kdDebug() << "KOAgendaView::updateView()" << endl; 867 // kdDebug() << "KOAgendaView::updateView()" << endl;
866 fillAgenda(); 868 fillAgenda();
867 869
868} 870}
869 871
870 872
871/* 873/*
872 Update configuration settings for the agenda view. This method is not 874 Update configuration settings for the agenda view. This method is not
873 complete. 875 complete.
874*/ 876*/
875void KOAgendaView::updateConfig() 877void KOAgendaView::updateConfig()
876{ 878{
877 if ( mBlockUpdating ) 879 if ( mBlockUpdating )
878 return; 880 return;
879 881
880 882
881 883
882 // update config for children 884 // update config for children
883 mTimeLabels->updateConfig(); 885 mTimeLabels->updateConfig();
884 mAgenda->storePosition(); 886 mAgenda->storePosition();
885 mAgenda->updateConfig(); 887 mAgenda->updateConfig();
886 mAllDayAgenda->updateConfig(); 888 mAllDayAgenda->updateConfig();
887 // widget synchronization 889 // widget synchronization
888 //TODO: find a better way, maybe signal/slot 890 //TODO: find a better way, maybe signal/slot
889 mTimeLabels->positionChanged(); 891 mTimeLabels->positionChanged();
890 892
891 // for some reason, this needs to be called explicitly 893 // for some reason, this needs to be called explicitly
892 mTimeLabels->repaint(); 894 mTimeLabels->repaint();
893 895
894 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 896 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
895 897
896 // ToolTips displaying summary of events 898 // ToolTips displaying summary of events
897 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 899 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
898 ->mEnableToolTips); 900 ->mEnableToolTips);
899 901
900 //setHolidayMasks(); 902 //setHolidayMasks();
901 903
902 //createDayLabels(); called by via updateView(); 904 //createDayLabels(); called by via updateView();
903 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 905 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
904 updateView(); 906 updateView();
905 mAgenda->restorePosition(); 907 mAgenda->restorePosition();
906} 908}
907 909
908 910
909void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 911void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
910{ 912{
911 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 913 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
912 //qDebug("KOAgendaView::updateEventDates "); 914 //qDebug("KOAgendaView::updateEventDates ");
913 QDateTime startDt,endDt; 915 QDateTime startDt,endDt;
914 QDate startDate; 916 QDate startDate;
915 int lenInSecs; 917 int lenInSecs;
916 // if ( type == KOAgenda::RESIZETOP ) 918 // if ( type == KOAgenda::RESIZETOP )
917 // qDebug("RESIZETOP "); 919 // qDebug("RESIZETOP ");
918 // if ( type == KOAgenda::RESIZEBOTTOM ) 920 // if ( type == KOAgenda::RESIZEBOTTOM )
919 // qDebug("RESIZEBOTTOM "); 921 // qDebug("RESIZEBOTTOM ");
920 // if ( type == KOAgenda::MOVE ) 922 // if ( type == KOAgenda::MOVE )
921 // qDebug("MOVE "); 923 // qDebug("MOVE ");
922 if ( item->incidence()->type() == "Event" ) { 924 if ( item->incidence()->type() == "Event" ) {
923 startDt =item->incidence()->dtStart(); 925 startDt =item->incidence()->dtStart();
924 endDt = item->incidence()->dtEnd(); 926 endDt = item->incidence()->dtEnd();
925 lenInSecs = startDt.secsTo( endDt ); 927 lenInSecs = startDt.secsTo( endDt );
926 } 928 }
927 929
928 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 930 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
929 931
930 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 932 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
931 startDate = mSelectedDates[item->mLastMoveXPos]; 933 startDate = mSelectedDates[item->mLastMoveXPos];
932 } else { 934 } else {
933 if (item->cellX() < 0) { 935 if (item->cellX() < 0) {
934 startDate = (mSelectedDates.first()).addDays(item->cellX()); 936 startDate = (mSelectedDates.first()).addDays(item->cellX());
935 } else { 937 } else {
936 startDate = mSelectedDates[item->cellX()]; 938 startDate = mSelectedDates[item->cellX()];
937 } 939 }
938 } 940 }
939 startDt.setDate(startDate); 941 startDt.setDate(startDate);
940 942
941 if (item->incidence()->doesFloat()) { 943 if (item->incidence()->doesFloat()) {
942 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 944 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
943 } else { 945 } else {
944 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 946 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
945 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 947 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
946 if ( item->incidence()->type() == "Event" ) { 948 if ( item->incidence()->type() == "Event" ) {
947 if ( type == KOAgenda::MOVE ) { 949 if ( type == KOAgenda::MOVE ) {
948 endDt = startDt.addSecs(lenInSecs); 950 endDt = startDt.addSecs(lenInSecs);
949 951
950 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 952 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
951 if (item->lastMultiItem()) { 953 if (item->lastMultiItem()) {
952 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 954 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
953 endDt.setDate(startDate. 955 endDt.setDate(startDate.
954 addDays(item->lastMultiItem()->cellX() - item->cellX())); 956 addDays(item->lastMultiItem()->cellX() - item->cellX()));
955 } else { 957 } else {
956 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 958 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
957 endDt.setDate(startDate); 959 endDt.setDate(startDate);
958 } 960 }
959 } 961 }
960 } else { 962 } else {
961 // todo 963 // todo
962 if (item->lastMultiItem()) { 964 if (item->lastMultiItem()) {
963 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 965 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
964 endDt.setDate(startDate. 966 endDt.setDate(startDate.
965 addDays(item->lastMultiItem()->cellX() - item->cellX())); 967 addDays(item->lastMultiItem()->cellX() - item->cellX()));
966 } else { 968 } else {
967 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 969 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
968 if ( item->cellYBottom() > 0 ) 970 if ( item->cellYBottom() > 0 )
969 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 971 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
970 else 972 else
971 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 973 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
972 endDt.setDate(startDate); 974 endDt.setDate(startDate);
973 } 975 }
974 } 976 }
975 } 977 }
976 if ( item->incidence()->type() == "Event" ) { 978 if ( item->incidence()->type() == "Event" ) {
977 item->incidence()->setDtStart(startDt); 979 item->incidence()->setDtStart(startDt);
978 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 980 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
979 } else if ( item->incidence()->type() == "Todo" ) { 981 } else if ( item->incidence()->type() == "Todo" ) {
980 Todo* to = static_cast<Todo*>(item->incidence()); 982 Todo* to = static_cast<Todo*>(item->incidence());
981 983
982 to->setDtDue(endDt); 984 to->setDtDue(endDt);
983 if ( to->hasStartDate() ) { 985 if ( to->hasStartDate() ) {
984 if (to->dtStart() >= to->dtDue() ) 986 if (to->dtStart() >= to->dtDue() )
985 to->setDtStart(to->dtDue().addDays( -2 )); 987 to->setDtStart(to->dtDue().addDays( -2 ));
986 } 988 }
987 989
988 } 990 }
989 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 991 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
990 item->incidence()->setRevision(item->incidence()->revision()+1); 992 item->incidence()->setRevision(item->incidence()->revision()+1);
991 item->setItemDate(startDt.date()); 993 item->setItemDate(startDt.date());
992 //item->updateItem(); 994 //item->updateItem();
993 if ( item->incidence()->type() == "Todo" ) { 995 if ( item->incidence()->type() == "Todo" ) {
994 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 996 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
995 997
996 } 998 }
997 else 999 else
998 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1000 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
999 item->updateItem(); 1001 item->updateItem();
1000} 1002}
1001 1003
1002void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1004void KOAgendaView::showDates( const QDate &start, const QDate &end )
1003{ 1005{
1004 // kdDebug() << "KOAgendaView::selectDates" << endl; 1006 // kdDebug() << "KOAgendaView::selectDates" << endl;
1005 1007
1006 mSelectedDates.clear(); 1008 mSelectedDates.clear();
1007 // qDebug("KOAgendaView::showDates "); 1009 // qDebug("KOAgendaView::showDates ");
1008 QDate d = start; 1010 QDate d = start;
1009 while (d <= end) { 1011 while (d <= end) {
1010 mSelectedDates.append(d); 1012 mSelectedDates.append(d);
1011 d = d.addDays( 1 ); 1013 d = d.addDays( 1 );
1012 } 1014 }
1013 1015
1014 // and update the view 1016 // and update the view
1015 fillAgenda(); 1017 fillAgenda();
1016} 1018}
1017 1019
1018 1020
1019void KOAgendaView::showEvents(QPtrList<Event>) 1021void KOAgendaView::showEvents(QPtrList<Event>)
1020{ 1022{
1021 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1023 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1022} 1024}
1023 1025
1024void KOAgendaView::changeEventDisplay(Event *, int) 1026void KOAgendaView::changeEventDisplay(Event *, int)
1025{ 1027{
1026 // qDebug("KOAgendaView::changeEventDisplay "); 1028 // qDebug("KOAgendaView::changeEventDisplay ");
1027 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1029 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1028 // this should be re-written to be MUCH smarter. Right now we 1030 // this should be re-written to be MUCH smarter. Right now we
1029 // are just playing dumb. 1031 // are just playing dumb.
1030 fillAgenda(); 1032 fillAgenda();
1031} 1033}
1032 1034
1033void KOAgendaView::fillAgenda(const QDate &) 1035void KOAgendaView::fillAgenda(const QDate &)
1034{ 1036{
1035 // qDebug("KOAgendaView::fillAgenda "); 1037 // qDebug("KOAgendaView::fillAgenda ");
1036 fillAgenda(); 1038 fillAgenda();
1037} 1039}
1038 1040
1039void KOAgendaView::fillAgenda() 1041void KOAgendaView::fillAgenda()
1040{ 1042{
1041 if ( globalFlagBlockStartup ) 1043 if ( globalFlagBlockStartup )
1042 return; 1044 return;
1043 if ( globalFlagBlockAgenda == 1 ) 1045 if ( globalFlagBlockAgenda == 1 )
1044 return; 1046 return;
1045 //if ( globalFlagBlockAgenda == 2 ) 1047 //if ( globalFlagBlockAgenda == 2 )
1046 //globalFlagBlockAgenda = 0; 1048 //globalFlagBlockAgenda = 0;
1047 // globalFlagBlockPainting = false; 1049 // globalFlagBlockPainting = false;
1048 if ( globalFlagBlockAgenda == 0 ) 1050 if ( globalFlagBlockAgenda == 0 )
1049 globalFlagBlockAgenda = 1; 1051 globalFlagBlockAgenda = 1;
1050 // clearView(); 1052 // clearView();
1051 //qDebug("fillAgenda()++++ "); 1053 //qDebug("fillAgenda()++++ ");
1052 globalFlagBlockAgendaItemPaint = 1; 1054 globalFlagBlockAgendaItemPaint = 1;
1053 1055
1054 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1056 mAllDayAgenda->changeColumns(mSelectedDates.count());
1055 mAgenda->changeColumns(mSelectedDates.count()); 1057 mAgenda->changeColumns(mSelectedDates.count());
1056 qApp->processEvents(); 1058 qApp->processEvents();
1057 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1059 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1058 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1060 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1059 setHolidayMasks(); 1061 setHolidayMasks();
1060 1062
1061 //mAgenda->hideUnused(); 1063 //mAgenda->hideUnused();
1062 //mAllDayAgenda->hideUnused(); 1064 //mAllDayAgenda->hideUnused();
1063 1065
1064 // mAgenda->blockNextRepaint( false ); 1066 // mAgenda->blockNextRepaint( false );
1065 // mAgenda->viewport()->repaint(); 1067 // mAgenda->viewport()->repaint();
1066 // mAgenda->blockNextRepaint( true ); 1068 // mAgenda->blockNextRepaint( true );
1067 mMinY.resize(mSelectedDates.count()); 1069 mMinY.resize(mSelectedDates.count());
1068 mMaxY.resize(mSelectedDates.count()); 1070 mMaxY.resize(mSelectedDates.count());
1069 1071
1070 QPtrList<Event> dayEvents; 1072 QPtrList<Event> dayEvents;
1071 1073
1072 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1074 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1073 // Therefore, gtodoset all of them. 1075 // Therefore, gtodoset all of them.
1074 QPtrList<Todo> todos = calendar()->todos(); 1076 QPtrList<Todo> todos = calendar()->todos();
1075 1077
1076 mAgenda->setDateList(mSelectedDates); 1078 mAgenda->setDateList(mSelectedDates);
1077 1079
1078 QDate today = QDate::currentDate(); 1080 QDate today = QDate::currentDate();
1079 1081
1080 DateList::ConstIterator dit; 1082 DateList::ConstIterator dit;
1081 int curCol = 0; 1083 int curCol = 0;
1082 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1084 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1083 QDate currentDate = *dit; 1085 QDate currentDate = *dit;
1084 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1086 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1085 // << endl; 1087 // << endl;
1086 1088
1087 dayEvents = calendar()->events(currentDate,true); 1089 dayEvents = calendar()->events(currentDate,true);
1088 1090
1089 // Default values, which can never be reached 1091 // Default values, which can never be reached
1090 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1092 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1091 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1093 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1092 1094
1093 unsigned int numEvent; 1095 unsigned int numEvent;
1094 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1096 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1095 Event *event = dayEvents.at(numEvent); 1097 Event *event = dayEvents.at(numEvent);
1096 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1098 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1097 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1099 if ( event->uid().left(15) == QString("last-syncEvent-") )
1098 continue; 1100 continue;
1099 // kdDebug() << " Event: " << event->summary() << endl; 1101 // kdDebug() << " Event: " << event->summary() << endl;
1100 1102
1101 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1103 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1102 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1104 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1103 1105
1104 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1106 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1105 1107
1106 if (event->doesFloat()) { 1108 if (event->doesFloat()) {
1107 if (event->recurrence()->doesRecur()) { 1109 if (event->recurrence()->doesRecur()) {
1108 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1110 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1109 } else { 1111 } else {
1110 if (beginX <= 0 && curCol == 0) { 1112 if (beginX <= 0 && curCol == 0) {
1111 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1113 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1112 } else if (beginX == curCol) { 1114 } else if (beginX == curCol) {
1113 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1115 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1114 } 1116 }
1115 } 1117 }
1116 } else if (event->isMultiDay()) { 1118 } else if (event->isMultiDay()) {
1117 if ( event->doesRecur () ) { 1119 if ( event->doesRecur () ) {
1118 QDate dateit = currentDate; 1120 QDate dateit = currentDate;
1119 int count = 0; 1121 int count = 0;
1120 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1122 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1121 while (! event->recursOn( dateit ) && count <= max ) { 1123 while (! event->recursOn( dateit ) && count <= max ) {
1122 ++count; 1124 ++count;
1123 dateit = dateit.addDays( -1 ); 1125 dateit = dateit.addDays( -1 );
1124 } 1126 }
1125 bool ok; 1127 bool ok;
1126 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1128 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1127 if ( ok ) 1129 if ( ok )
1128 { 1130 {
1129 int secs = event->dtStart().secsTo( event->dtEnd() ); 1131 int secs = event->dtStart().secsTo( event->dtEnd() );
1130 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1132 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1131 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1133 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1132 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1134 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1133 1135
1134 } 1136 }
1135 } 1137 }
1136 int startY = mAgenda->timeToY(event->dtStart().time()); 1138 int startY = mAgenda->timeToY(event->dtStart().time());
1137 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1139 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1138 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1140 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1139 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1141 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1140 //qDebug("insert!!! "); 1142 //qDebug("insert!!! ");
1141 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1143 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1142 } 1144 }
1143 if (beginX == curCol) { 1145 if (beginX == curCol) {
1144 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1146 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1145 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1147 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1146 } else if (endX == curCol) { 1148 } else if (endX == curCol) {
1147 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1149 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1148 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1150 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1149 } else { 1151 } else {
1150 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1152 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1151 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1153 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1152 } 1154 }
1153 } else { 1155 } else {
1154 int startY = mAgenda->timeToY(event->dtStart().time()); 1156 int startY = mAgenda->timeToY(event->dtStart().time());
1155 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1157 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1156 if (endY < startY) endY = startY; 1158 if (endY < startY) endY = startY;
1157 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1159 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1158 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1160 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1159 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1161 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1160 } 1162 }
1161 } 1163 }
1162 // ---------- [display Todos -------------- 1164 // ---------- [display Todos --------------
1163 unsigned int numTodo; 1165 unsigned int numTodo;
1164 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1166 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1165 Todo *todo = todos.at(numTodo); 1167 Todo *todo = todos.at(numTodo);
1166 1168
1167 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1169 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1168 1170
1169 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1171 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1170 // Already completed items can be displayed on their original due date 1172 // Already completed items can be displayed on their original due date
1171 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1173 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1172 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1174 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1173 bool fillIn = false; 1175 bool fillIn = false;
1174 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1176 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1175 fillIn = true; 1177 fillIn = true;
1176 if ( ! fillIn && !todo->hasCompletedDate() ) 1178 if ( ! fillIn && !todo->hasCompletedDate() )
1177 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1179 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1178 if ( fillIn ) { 1180 if ( fillIn ) {
1179 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1181 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1180 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1182 if ( KOPrefs::instance()->mShowTodoInAgenda )
1181 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1183 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1182 } 1184 }
1183 else { 1185 else {
1184 QDateTime dt; 1186 QDateTime dt;
1185 if ( todo->hasCompletedDate() ) 1187 if ( todo->hasCompletedDate() )
1186 dt = todo->completed(); 1188 dt = todo->completed();
1187 else 1189 else
1188 dt = todo->dtDue();; 1190 dt = todo->dtDue();;
1189 1191
1190 1192
1191 int endY = mAgenda->timeToY(dt.time()) - 1; 1193 int endY = mAgenda->timeToY(dt.time()) - 1;
1192 int hi = (18/KOPrefs::instance()->mHourSize); 1194 int hi = (18/KOPrefs::instance()->mHourSize);
1193 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1195 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);