summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp18
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/komonthview.cpp11
-rw-r--r--korganizer/koviewmanager.cpp2
4 files changed, 27 insertions, 5 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index d4ff77a..aed9bae 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -44,769 +44,785 @@
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 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); 428 QVBox *dummyAllDayRight = new QVBox(mAllDayFrame);
429
430 QPushButton *dummyAllDayRightB = new QPushButton(dummyAllDayRight);
431 QLabel * dummyAllDayRightL = new QLabel ( dummyAllDayRight );
432
433 dummyAllDayRightB->setFlat( true );
434 dummyAllDayRightB->setFocusPolicy(NoFocus);
435 // dummyAllDayRightB->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
436 //dummyAllDayRightB->setFixedHeight( dummyAllDayRightB->sizeHint().height()/2 );
437 QPopupMenu * wpo = new QPopupMenu (this);
438 wpo->insertItem( i18n("W#"), 0 );
439 int i;
440 for ( i = 1; i < 54; i++ )
441 wpo->insertItem( QString::number( i ),i );
442 dummyAllDayRightB->setPopup( wpo );
443
444 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
429 445
430 // Create event context menu for all day agenda 446 // Create event context menu for all day agenda
431 mAllDayAgendaPopup = eventPopup(); 447 mAllDayAgendaPopup = eventPopup();
432 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 448 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
433 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 449 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
434 450
435 // Create agenda frame 451 // Create agenda frame
436 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 452 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
437 // QHBox *agendaFrame = new QHBox(splitterAgenda); 453 // QHBox *agendaFrame = new QHBox(splitterAgenda);
438 454
439 // create event indicator bars 455 // create event indicator bars
440 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 456 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
441 agendaLayout->addWidget(mEventIndicatorTop,0,1); 457 agendaLayout->addWidget(mEventIndicatorTop,0,1);
442 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 458 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
443 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 459 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
444 agendaFrame); 460 agendaFrame);
445 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 461 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
446 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 462 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
447 agendaLayout->addWidget(dummyAgendaRight,0,2); 463 agendaLayout->addWidget(dummyAgendaRight,0,2);
448 464
449 // Create time labels 465 // Create time labels
450 mTimeLabels = new TimeLabels(24,agendaFrame); 466 mTimeLabels = new TimeLabels(24,agendaFrame);
451 agendaLayout->addWidget(mTimeLabels,1,0); 467 agendaLayout->addWidget(mTimeLabels,1,0);
452 connect(mTimeLabels,SIGNAL( scaleChanged()), 468 connect(mTimeLabels,SIGNAL( scaleChanged()),
453 this,SLOT(updateConfig())); 469 this,SLOT(updateConfig()));
454 470
455 // Create agenda 471 // Create agenda
456 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 472 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
457 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 473 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
458 agendaLayout->setColStretch(1,1); 474 agendaLayout->setColStretch(1,1);
459 mAgenda->setFocusPolicy(NoFocus); 475 mAgenda->setFocusPolicy(NoFocus);
460 // Create event context menu for agenda 476 // Create event context menu for agenda
461 mAgendaPopup = eventPopup(); 477 mAgendaPopup = eventPopup();
462 478
463 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 479 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
464 i18n("Toggle Alarm"),mAgenda, 480 i18n("Toggle Alarm"),mAgenda,
465 SLOT(popupAlarm()),true); 481 SLOT(popupAlarm()),true);
466 482
467 483
468 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 484 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
469 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 485 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
470 486
471 // make connections between dependent widgets 487 // make connections between dependent widgets
472 mTimeLabels->setAgenda(mAgenda); 488 mTimeLabels->setAgenda(mAgenda);
473 489
474 // Update widgets to reflect user preferences 490 // Update widgets to reflect user preferences
475 // updateConfig(); 491 // updateConfig();
476 492
477 // createDayLabels(); 493 // createDayLabels();
478 494
479 // these blank widgets make the All Day Event box line up with the agenda 495 // these blank widgets make the All Day Event box line up with the agenda
480 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 496 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
481 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 497 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
482 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 498 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
483 499
484 // Scrolling 500 // Scrolling
485 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 501 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
486 mTimeLabels, SLOT(positionChanged())); 502 mTimeLabels, SLOT(positionChanged()));
487 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 503 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
488 SLOT(setContentsPos(int))); 504 SLOT(setContentsPos(int)));
489 505
490 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 506 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
491 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 507 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
492 508
493 // Create/Show/Edit/Delete Event 509 // Create/Show/Edit/Delete Event
494 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 510 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
495 SLOT(newEvent(int,int))); 511 SLOT(newEvent(int,int)));
496 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 512 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
497 SLOT(newTodo(int,int))); 513 SLOT(newTodo(int,int)));
498 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 514 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
499 SLOT(newEvent(int,int,int,int))); 515 SLOT(newEvent(int,int,int,int)));
500 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 516 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
501 SLOT(newEventAllDay(int,int))); 517 SLOT(newEventAllDay(int,int)));
502 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 518 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
503 SLOT(newTodoAllDay(int,int))); 519 SLOT(newTodoAllDay(int,int)));
504 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 520 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
505 SLOT(newEventAllDay(int,int))); 521 SLOT(newEventAllDay(int,int)));
506 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 522 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
507 SLOT(newTimeSpanSelected(int,int,int,int))); 523 SLOT(newTimeSpanSelected(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 524 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
509 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 525 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
510 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 526 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
511 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 527 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
512 528
513 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 529 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
514 SIGNAL(editIncidenceSignal(Incidence *))); 530 SIGNAL(editIncidenceSignal(Incidence *)));
515 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 531 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
516 SIGNAL(editIncidenceSignal(Incidence *))); 532 SIGNAL(editIncidenceSignal(Incidence *)));
517 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 533 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
518 SIGNAL(showIncidenceSignal(Incidence *))); 534 SIGNAL(showIncidenceSignal(Incidence *)));
519 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 535 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
520 SIGNAL(showIncidenceSignal(Incidence *))); 536 SIGNAL(showIncidenceSignal(Incidence *)));
521 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 537 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
522 SIGNAL(deleteIncidenceSignal(Incidence *))); 538 SIGNAL(deleteIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 539 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
524 SIGNAL(deleteIncidenceSignal(Incidence *))); 540 SIGNAL(deleteIncidenceSignal(Incidence *)));
525 541
526 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 542 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
527 SLOT(updateEventDates(KOAgendaItem *, int ))); 543 SLOT(updateEventDates(KOAgendaItem *, int )));
528 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 544 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
529 SLOT(updateEventDates(KOAgendaItem *, int))); 545 SLOT(updateEventDates(KOAgendaItem *, int)));
530 546
531 // event indicator update 547 // event indicator update
532 connect(mAgenda,SIGNAL(lowerYChanged(int)), 548 connect(mAgenda,SIGNAL(lowerYChanged(int)),
533 SLOT(updateEventIndicatorTop(int))); 549 SLOT(updateEventIndicatorTop(int)));
534 connect(mAgenda,SIGNAL(upperYChanged(int)), 550 connect(mAgenda,SIGNAL(upperYChanged(int)),
535 SLOT(updateEventIndicatorBottom(int))); 551 SLOT(updateEventIndicatorBottom(int)));
536 // drag signals 552 // drag signals
537 /* 553 /*
538 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 554 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
539 SLOT(startDrag(Event *))); 555 SLOT(startDrag(Event *)));
540 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 556 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
541 SLOT(startDrag(Event *))); 557 SLOT(startDrag(Event *)));
542 */ 558 */
543 // synchronize selections 559 // synchronize selections
544 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 560 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
545 mAllDayAgenda, SLOT( deselectItem() ) ); 561 mAllDayAgenda, SLOT( deselectItem() ) );
546 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 562 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
547 mAgenda, SLOT( deselectItem() ) ); 563 mAgenda, SLOT( deselectItem() ) );
548 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 564 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
549 SIGNAL( incidenceSelected( Incidence * ) ) ); 565 SIGNAL( incidenceSelected( Incidence * ) ) );
550 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 566 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
551 SIGNAL( incidenceSelected( Incidence * ) ) ); 567 SIGNAL( incidenceSelected( Incidence * ) ) );
552 connect( mAgenda, SIGNAL( resizedSignal() ), 568 connect( mAgenda, SIGNAL( resizedSignal() ),
553 SLOT( updateConfig( ) ) ); 569 SLOT( updateConfig( ) ) );
554 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 570 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
555 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 571 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
556 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 572 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
557 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 573 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
558 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 574 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
559 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 575 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
560 576
561 577
562} 578}
563 579
564void KOAgendaView::toggleAllDay() 580void KOAgendaView::toggleAllDay()
565{ 581{
566 if ( mSplitterAgenda->firstHandle() ) 582 if ( mSplitterAgenda->firstHandle() )
567 mSplitterAgenda->firstHandle()->toggle(); 583 mSplitterAgenda->firstHandle()->toggle();
568} 584}
569void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 585void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
570{ 586{
571 calendar()->addIncidence( inc ); 587 calendar()->addIncidence( inc );
572 588
573 if ( incOld ) { 589 if ( incOld ) {
574 if ( incOld->type() == "Todo" ) 590 if ( incOld->type() == "Todo" )
575 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 591 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
576 else 592 else
577 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 593 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
578 } 594 }
579 595
580} 596}
581 597
582KOAgendaView::~KOAgendaView() 598KOAgendaView::~KOAgendaView()
583{ 599{
584 delete mAgendaPopup; 600 delete mAgendaPopup;
585 delete mAllDayAgendaPopup; 601 delete mAllDayAgendaPopup;
586 delete KOAgendaItem::paintPix(); 602 delete KOAgendaItem::paintPix();
587 delete KOAgendaItem::paintPixSel(); 603 delete KOAgendaItem::paintPixSel();
588} 604}
589void KOAgendaView::resizeEvent( QResizeEvent* e ) 605void KOAgendaView::resizeEvent( QResizeEvent* e )
590{ 606{
591 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 607 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
592 bool uc = false; 608 bool uc = false;
593 int ow = e->oldSize().width(); 609 int ow = e->oldSize().width();
594 int oh = e->oldSize().height(); 610 int oh = e->oldSize().height();
595 int w = e->size().width(); 611 int w = e->size().width();
596 int h = e->size().height(); 612 int h = e->size().height();
597 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 613 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
598 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 614 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
599 uc = true; 615 uc = true;
600 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 616 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
601 } 617 }
602 mUpcomingWidth = e->size().width() ; 618 mUpcomingWidth = e->size().width() ;
603 if ( mBlockUpdating || uc ) { 619 if ( mBlockUpdating || uc ) {
604 mBlockUpdating = false; 620 mBlockUpdating = false;
605 //mAgenda->setMinimumSize(800 , 600 ); 621 //mAgenda->setMinimumSize(800 , 600 );
606 //qDebug("mAgenda->resize+++++++++++++++ "); 622 //qDebug("mAgenda->resize+++++++++++++++ ");
607 updateConfig(); 623 updateConfig();
608 //qDebug("KOAgendaView::Updating now possible "); 624 //qDebug("KOAgendaView::Updating now possible ");
609 } else 625 } else
610 createDayLabels(); 626 createDayLabels();
611 //qDebug("resizeEvent end "); 627 //qDebug("resizeEvent end ");
612 628
613} 629}
614void KOAgendaView::slotDaylabelClicked( int num ) 630void KOAgendaView::slotDaylabelClicked( int num )
615{ 631{
616 632
617 QDate firstDate = mSelectedDates.first(); 633 QDate firstDate = mSelectedDates.first();
618 if ( num == -1 ) 634 if ( num == -1 )
619 emit showDateView( 6, firstDate ); 635 emit showDateView( 6, firstDate );
620 else if (num >= 0 ) { 636 else if (num >= 0 ) {
621 if ( mSelectedDates.count() == 1) 637 if ( mSelectedDates.count() == 1)
622 emit showDateView( 9, firstDate.addDays( num ) ); 638 emit showDateView( 9, firstDate.addDays( num ) );
623 else 639 else
624 emit showDateView( 3, firstDate.addDays( num ) ); 640 emit showDateView( 3, firstDate.addDays( num ) );
625 } 641 }
626 else 642 else
627 showDateView( 10, firstDate.addDays(1) ); 643 showDateView( 10, firstDate.addDays(1) );
628} 644}
629 645
630KOAgendaButton* KOAgendaView::getNewDaylabel() 646KOAgendaButton* KOAgendaView::getNewDaylabel()
631{ 647{
632 648
633 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 649 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
634 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 650 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
635 mDayLabelsList.append( dayLabel ); 651 mDayLabelsList.append( dayLabel );
636 mLayoutDayLabels->addWidget(dayLabel); 652 mLayoutDayLabels->addWidget(dayLabel);
637 return dayLabel ; 653 return dayLabel ;
638} 654}
639 655
640void KOAgendaView::createDayLabels() 656void KOAgendaView::createDayLabels()
641{ 657{
642 658
643 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 659 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
644 // qDebug(" KOAgendaView::createDayLabels() blocked "); 660 // qDebug(" KOAgendaView::createDayLabels() blocked ");
645 return; 661 return;
646 662
647 } 663 }
648 int newHight; 664 int newHight;
649 665
650 // ### Before deleting and recreating we could check if mSelectedDates changed... 666 // ### Before deleting and recreating we could check if mSelectedDates changed...
651 // It would remove some flickering and gain speed (since this is called by 667 // It would remove some flickering and gain speed (since this is called by
652 // each updateView() call) 668 // each updateView() call)
653 669
654 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 670 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
655 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 671 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
656 if ( maxWid < 0 ) 672 if ( maxWid < 0 )
657 maxWid = 20; 673 maxWid = 20;
658 674
659 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 675 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
660 QFontMetrics fm ( dlf ); 676 QFontMetrics fm ( dlf );
661 int selCount = mSelectedDates.count(); 677 int selCount = mSelectedDates.count();
662 QString dayTest = "Mon 20"; 678 QString dayTest = "Mon 20";
663 //QString dayTest = "Mon 20"; 679 //QString dayTest = "Mon 20";
664 int wid = fm.width( dayTest ); 680 int wid = fm.width( dayTest );
665 //maxWid -= ( selCount * 3 ); //working for QLabels 681 //maxWid -= ( selCount * 3 ); //working for QLabels
666 maxWid -= ( selCount * 3 ); //working for QPushButton 682 maxWid -= ( selCount * 3 ); //working for QPushButton
667 if ( maxWid < 0 ) 683 if ( maxWid < 0 )
668 maxWid = 20; 684 maxWid = 20;
669 int needWid = wid * selCount; 685 int needWid = wid * selCount;
670 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 686 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
671 //if ( needWid > maxWid ) 687 //if ( needWid > maxWid )
672 // qDebug("DAYLABELS TOOOOOOO BIG "); 688 // qDebug("DAYLABELS TOOOOOOO BIG ");
673 while ( needWid > maxWid ) { 689 while ( needWid > maxWid ) {
674 dayTest = dayTest.left( dayTest.length() - 1 ); 690 dayTest = dayTest.left( dayTest.length() - 1 );
675 wid = fm.width( dayTest ); 691 wid = fm.width( dayTest );
676 needWid = wid * selCount; 692 needWid = wid * selCount;
677 } 693 }
678 int maxLen = dayTest.length(); 694 int maxLen = dayTest.length();
679 int fontPoint = dlf.pointSize(); 695 int fontPoint = dlf.pointSize();
680 if ( maxLen < 2 ) { 696 if ( maxLen < 2 ) {
681 int fontPoint = dlf.pointSize(); 697 int fontPoint = dlf.pointSize();
682 while ( fontPoint > 4 ) { 698 while ( fontPoint > 4 ) {
683 --fontPoint; 699 --fontPoint;
684 dlf.setPointSize( fontPoint ); 700 dlf.setPointSize( fontPoint );
685 QFontMetrics f( dlf ); 701 QFontMetrics f( dlf );
686 wid = f.width( "30" ); 702 wid = f.width( "30" );
687 needWid = wid * selCount; 703 needWid = wid * selCount;
688 if ( needWid < maxWid ) 704 if ( needWid < maxWid )
689 break; 705 break;
690 } 706 }
691 maxLen = 2; 707 maxLen = 2;
692 } 708 }
693 //qDebug("Max len %d ", dayTest.length() ); 709 //qDebug("Max len %d ", dayTest.length() );
694 710
695 QFontMetrics tempF( dlf ); 711 QFontMetrics tempF( dlf );
696 newHight = tempF.height(); 712 newHight = tempF.height();
697 mDayLabels->setFont( dlf ); 713 mDayLabels->setFont( dlf );
698 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 714 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
699 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 715 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
700 //mLayoutDayLabels->addSpacing( 2 ); 716 //mLayoutDayLabels->addSpacing( 2 );
701 // QFont lFont = dlf; 717 // QFont lFont = dlf;
702 bool appendLabels = false; 718 bool appendLabels = false;
703 KOAgendaButton *dayLabel; 719 KOAgendaButton *dayLabel;
704 dayLabel = mDayLabelsList.first(); 720 dayLabel = mDayLabelsList.first();
705 if ( !dayLabel ) { 721 if ( !dayLabel ) {
706 appendLabels = true; 722 appendLabels = true;
707 dayLabel = getNewDaylabel(); 723 dayLabel = getNewDaylabel();
708 } 724 }
709 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 725 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
710 dayLabel->setFont( dlf ); 726 dayLabel->setFont( dlf );
711 dayLabel->setNum( -1 ); 727 dayLabel->setNum( -1 );
712 //dayLabel->setAlignment(QLabel::AlignHCenter); 728 //dayLabel->setAlignment(QLabel::AlignHCenter);
713 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 729 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
714 dayLabel->show(); 730 dayLabel->show();
715 DateList::ConstIterator dit; 731 DateList::ConstIterator dit;
716 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 732 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
717 int counter = -1; 733 int counter = -1;
718 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 734 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
719 ++counter; 735 ++counter;
720 QDate date = *dit; 736 QDate date = *dit;
721 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 737 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
722 if ( ! appendLabels ) { 738 if ( ! appendLabels ) {
723 dayLabel = mDayLabelsList.next(); 739 dayLabel = mDayLabelsList.next();
724 if ( !dayLabel ) 740 if ( !dayLabel )
725 appendLabels = true; 741 appendLabels = true;
726 } 742 }
727 if ( appendLabels ) { 743 if ( appendLabels ) {
728 dayLabel = getNewDaylabel(); 744 dayLabel = getNewDaylabel();
729 } 745 }
730 dayLabel->setMinimumWidth( 1 ); 746 dayLabel->setMinimumWidth( 1 );
731 dayLabel->setMaximumWidth( 1024 ); 747 dayLabel->setMaximumWidth( 1024 );
732 dayLabel->setFont( dlf ); 748 dayLabel->setFont( dlf );
733 dayLabel->show(); 749 dayLabel->show();
734 dayLabel->setNum( counter ); 750 dayLabel->setNum( counter );
735 QString str; 751 QString str;
736 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 752 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
737 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 753 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
738 switch ( maxLen ) { 754 switch ( maxLen ) {
739 case 2: 755 case 2:
740 str = QString::number( date.day() ); 756 str = QString::number( date.day() );
741 break; 757 break;
742 758
743 case 3: 759 case 3:
744 str = dayName.left( 1 ) +QString::number( date.day()); 760 str = dayName.left( 1 ) +QString::number( date.day());
745 761
746 break; 762 break;
747 case 4: 763 case 4:
748 str = dayName.left( 1 ) + " " +QString::number( date.day()); 764 str = dayName.left( 1 ) + " " +QString::number( date.day());
749 765
750 break; 766 break;
751 case 5: 767 case 5:
752 str = dayName.left( 2 ) + " " +QString::number( date.day()); 768 str = dayName.left( 2 ) + " " +QString::number( date.day());
753 769
754 break; 770 break;
755 case 6: 771 case 6:
756 str = dayName.left( 3 ) + " " +QString::number( date.day()); 772 str = dayName.left( 3 ) + " " +QString::number( date.day());
757 break; 773 break;
758 774
759 default: 775 default:
760 break; 776 break;
761 } 777 }
762 if ( oneday ) { 778 if ( oneday ) {
763 QString addString; 779 QString addString;
764 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 780 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
765 addString = i18n("Today"); 781 addString = i18n("Today");
766 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 782 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
767 addString = i18n("Tomorrow"); 783 addString = i18n("Tomorrow");
768 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 784 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
769 addString = i18n("Yesterday"); 785 addString = i18n("Yesterday");
770 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
771 addString = i18n("Day before yesterday"); 787 addString = i18n("Day before yesterday");
772 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
773 addString = i18n("Day after tomorrow"); 789 addString = i18n("Day after tomorrow");
774 if ( !addString.isEmpty() ) { 790 if ( !addString.isEmpty() ) {
775 str = addString+", " + str; 791 str = addString+", " + str;
776 } 792 }
777 } 793 }
778 dayLabel->setText(str); 794 dayLabel->setText(str);
779 //dayLabel->setAlignment(QLabel::AlignHCenter); 795 //dayLabel->setAlignment(QLabel::AlignHCenter);
780 if (date == QDate::currentDate()) { 796 if (date == QDate::currentDate()) {
781 QFont bFont = dlf; 797 QFont bFont = dlf;
782 bFont.setBold( true ); 798 bFont.setBold( true );
783 dayLabel->setFont(bFont); 799 dayLabel->setFont(bFont);
784 } 800 }
785 //dayLayout->addWidget(dayLabel); 801 //dayLayout->addWidget(dayLabel);
786 802
787#ifndef KORG_NOPLUGINS 803#ifndef KORG_NOPLUGINS
788 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 804 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
789 CalendarDecoration *it; 805 CalendarDecoration *it;
790 for(it = cds.first(); it; it = cds.next()) { 806 for(it = cds.first(); it; it = cds.next()) {
791 QString text = it->shortText( date ); 807 QString text = it->shortText( date );
792 if ( !text.isEmpty() ) { 808 if ( !text.isEmpty() ) {
793 QLabel *label = new QLabel(text,mDayLabels); 809 QLabel *label = new QLabel(text,mDayLabels);
794 label->setAlignment(AlignCenter); 810 label->setAlignment(AlignCenter);
795 dayLayout->addWidget(label); 811 dayLayout->addWidget(label);
796 } 812 }
797 } 813 }
798 814
799 for(it = cds.first(); it; it = cds.next()) { 815 for(it = cds.first(); it; it = cds.next()) {
800 QWidget *wid = it->smallWidget(mDayLabels,date); 816 QWidget *wid = it->smallWidget(mDayLabels,date);
801 if ( wid ) { 817 if ( wid ) {
802 // wid->setHeight(20); 818 // wid->setHeight(20);
803 dayLayout->addWidget(wid); 819 dayLayout->addWidget(wid);
804 } 820 }
805 } 821 }
806#endif 822#endif
807 } 823 }
808 if ( ! appendLabels ) { 824 if ( ! appendLabels ) {
809 dayLabel = mDayLabelsList.next(); 825 dayLabel = mDayLabelsList.next();
810 if ( !dayLabel ) 826 if ( !dayLabel )
811 appendLabels = true; 827 appendLabels = true;
812 } 828 }
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index e9e85cc..4a058ce 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,289 +1,290 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,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#ifndef KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qksplitter.h> 31#include <qksplitter.h>
32#else 32#else
33#include <qsplitter.h> 33#include <qsplitter.h>
34#endif 34#endif
35#include <qmemarray.h> 35#include <qmemarray.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48 48
49class KOAgendaButton : public QPushButton 49class KOAgendaButton : public QPushButton
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) : 53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name ) 54 QPushButton( parent, name )
55 { 55 {
56 mNum = -3; 56 mNum = -3;
57 setFlat( true ); 57 setFlat( true );
58 setFocusPolicy(NoFocus); 58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); 59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) ); 60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 }; 61 };
62 62
63 QSize sizeHint () const { return QSize( 5,5) ;} 63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; } 64 void setNum( int n) { mNum = n; }
65private slots: 65private slots:
66 void bClicked() {emit numClicked( mNum);} 66 void bClicked() {emit numClicked( mNum);}
67signals: 67signals:
68 void numClicked( int ); 68 void numClicked( int );
69private: 69private:
70 int mNum; 70 int mNum;
71}; 71};
72 72
73class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
74 Q_OBJECT 74 Q_OBJECT
75 public: 75 public:
76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
77 77
78 void setCellHeight(int height); 78 void setCellHeight(int height);
79 79
80 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
81 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
82 82
83 /** updates widget's internal state */ 83 /** updates widget's internal state */
84 void updateConfig(); 84 void updateConfig();
85 85
86 /** */ 86 /** */
87 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
88 88
89 /** */ 89 /** */
90 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
91 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
92 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
93 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
94 94
95 public slots: 95 public slots:
96 /** update time label positions */ 96 /** update time label positions */
97 void positionChanged(); 97 void positionChanged();
98 signals: 98 signals:
99 void scaleChanged(); 99 void scaleChanged();
100 protected: 100 protected:
101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
102 102
103 private: 103 private:
104 int mMouseDownY; 104 int mMouseDownY;
105 QString mOrgCap; 105 QString mOrgCap;
106 int mRows; 106 int mRows;
107 int mCellHeight; 107 int mCellHeight;
108 108
109 /** */ 109 /** */
110 KOAgenda* mAgenda; 110 KOAgenda* mAgenda;
111}; 111};
112 112
113class EventIndicator : public QFrame { 113class EventIndicator : public QFrame {
114 Q_OBJECT 114 Q_OBJECT
115 public: 115 public:
116 enum Location { Top, Bottom }; 116 enum Location { Top, Bottom };
117 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 117 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
118 virtual ~EventIndicator(); 118 virtual ~EventIndicator();
119 119
120 void changeColumns(int columns); 120 void changeColumns(int columns);
121 void setPaintWidget( KDGanttMinimizeSplitter* ); 121 void setPaintWidget( KDGanttMinimizeSplitter* );
122 void setXOffset( int ); 122 void setXOffset( int );
123 void enableColumn(int column, bool enable); 123 void enableColumn(int column, bool enable);
124 124
125 protected: 125 protected:
126 void drawContents(QPainter *); 126 void drawContents(QPainter *);
127 127
128 private: 128 private:
129 int mXOffset; 129 int mXOffset;
130 KDGanttMinimizeSplitter* mPaintWidget; 130 KDGanttMinimizeSplitter* mPaintWidget;
131 int mColumns; 131 int mColumns;
132 QHBox *mTopBox; 132 QHBox *mTopBox;
133 QBoxLayout *mTopLayout; 133 QBoxLayout *mTopLayout;
134 Location mLocation; 134 Location mLocation;
135 QPixmap mPixmap; 135 QPixmap mPixmap;
136 QMemArray<bool> mEnabled; 136 QMemArray<bool> mEnabled;
137}; 137};
138 138
139/** 139/**
140 KOAgendaView is the agenda-like view used to display events in an one or 140 KOAgendaView is the agenda-like view used to display events in an one or
141 multi-day view. 141 multi-day view.
142*/ 142*/
143class KOAgendaView : public KOEventView { 143class KOAgendaView : public KOEventView {
144 Q_OBJECT 144 Q_OBJECT
145 public: 145 public:
146 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 146 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
147 virtual ~KOAgendaView(); 147 virtual ~KOAgendaView();
148 void setStartHour( int ); 148 void setStartHour( int );
149 void toggleAllDay(); 149 void toggleAllDay();
150 150
151 151
152 /** Returns maximum number of days supported by the koagendaview */ 152 /** Returns maximum number of days supported by the koagendaview */
153 virtual int maxDatesHint(); 153 virtual int maxDatesHint();
154 154
155 /** Returns number of currently shown dates. */ 155 /** Returns number of currently shown dates. */
156 virtual int currentDateCount(); 156 virtual int currentDateCount();
157 157
158 /** returns the currently selected events */ 158 /** returns the currently selected events */
159 virtual QPtrList<Incidence> selectedIncidences(); 159 virtual QPtrList<Incidence> selectedIncidences();
160 160
161 /** returns the currently selected events */ 161 /** returns the currently selected events */
162 virtual DateList selectedDates(); 162 virtual DateList selectedDates();
163 163
164 /** Remove all events from view */ 164 /** Remove all events from view */
165 void clearView(); 165 void clearView();
166 KOAgenda *agenda() { return mAgenda;} 166 KOAgenda *agenda() { return mAgenda;}
167 virtual void printPreview(CalPrinter *calPrinter, 167 virtual void printPreview(CalPrinter *calPrinter,
168 const QDate &, const QDate &); 168 const QDate &, const QDate &);
169 169
170 /** start-datetime of selection */ 170 /** start-datetime of selection */
171 QDateTime selectionStart() {return mTimeSpanBegin;} 171 QDateTime selectionStart() {return mTimeSpanBegin;}
172 /** end-datetime of selection */ 172 /** end-datetime of selection */
173 QDateTime selectionEnd() {return mTimeSpanEnd;} 173 QDateTime selectionEnd() {return mTimeSpanEnd;}
174 /** returns true if selection is for whole day */ 174 /** returns true if selection is for whole day */
175 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 175 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
176 /** make selected start/end invalid */ 176 /** make selected start/end invalid */
177 void deleteSelectedDateTime(); 177 void deleteSelectedDateTime();
178 void repaintAgenda(); 178 void repaintAgenda();
179 public slots: 179 public slots:
180 virtual void updateView(); 180 virtual void updateView();
181 virtual void updateConfig(); 181 virtual void updateConfig();
182 virtual void showDates(const QDate &start, const QDate &end); 182 virtual void showDates(const QDate &start, const QDate &end);
183 virtual void showEvents(QPtrList<Event> eventList); 183 virtual void showEvents(QPtrList<Event> eventList);
184 184
185 void updateTodo( Todo *, int ); 185 void updateTodo( Todo *, int );
186 void changeEventDisplay(Event *, int); 186 void changeEventDisplay(Event *, int);
187 187
188 void clearSelection(); 188 void clearSelection();
189 189
190 void newTodo(int gx,int gy); 190 void newTodo(int gx,int gy);
191 void newEvent(int gx,int gy); 191 void newEvent(int gx,int gy);
192 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 192 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
193 void newEventAllDay(int gx, int gy); 193 void newEventAllDay(int gx, int gy);
194 void newTodoAllDay(int gx, int gy); 194 void newTodoAllDay(int gx, int gy);
195 195
196 void startDrag(Event *); 196 void startDrag(Event *);
197 197
198 void readSettings(); 198 void readSettings();
199 void readSettings(KConfig *); 199 void readSettings(KConfig *);
200 void writeSettings(KConfig *); 200 void writeSettings(KConfig *);
201 201
202 void setContentsPos(int y); 202 void setContentsPos(int y);
203 203
204 void setExpandedButton( bool expanded ); 204 void setExpandedButton( bool expanded );
205 void scrollOneHourUp(); 205 void scrollOneHourUp();
206 void scrollOneHourDown(); 206 void scrollOneHourDown();
207 void addToCalSlot(Incidence *, Incidence *); 207 void addToCalSlot(Incidence *, Incidence *);
208 208
209 signals: 209 signals:
210 void showDateView( int, QDate ); 210 void showDateView( int, QDate );
211 void newTodoSignal( QDateTime ,bool ); 211 void newTodoSignal( QDateTime ,bool );
212 void toggleExpand(); 212 void toggleExpand();
213 void selectWeekNum( int );
213 void todoMoved( Todo *, int ); 214 void todoMoved( Todo *, int );
214 void incidenceChanged(Incidence * , int ); 215 void incidenceChanged(Incidence * , int );
215 // void cloneIncidenceSignal(Incidence *); 216 // void cloneIncidenceSignal(Incidence *);
216 217
217 protected: 218 protected:
218 KOAgendaButton* getNewDaylabel(); 219 KOAgendaButton* getNewDaylabel();
219 bool mBlockUpdating; 220 bool mBlockUpdating;
220 int mUpcomingWidth; 221 int mUpcomingWidth;
221 /** Fill agenda beginning with date startDate */ 222 /** Fill agenda beginning with date startDate */
222 void fillAgenda(const QDate &startDate); 223 void fillAgenda(const QDate &startDate);
223 void resizeEvent( QResizeEvent* e ); 224 void resizeEvent( QResizeEvent* e );
224 /** Fill agenda using the current set value for the start date */ 225 /** Fill agenda using the current set value for the start date */
225 void fillAgenda(); 226 void fillAgenda();
226 227
227 /** Create labels for the selected dates. */ 228 /** Create labels for the selected dates. */
228 void createDayLabels(); 229 void createDayLabels();
229 230
230 /** 231 /**
231 Set the masks on the agenda widgets indicating, which days are holidays. 232 Set the masks on the agenda widgets indicating, which days are holidays.
232 */ 233 */
233 void setHolidayMasks(); 234 void setHolidayMasks();
234 235
235 protected slots: 236 protected slots:
236 void slotDaylabelClicked( int ); 237 void slotDaylabelClicked( int );
237 /** Update event belonging to agenda item */ 238 /** Update event belonging to agenda item */
238 void updateEventDates(KOAgendaItem *item, int mode = -1); 239 void updateEventDates(KOAgendaItem *item, int mode = -1);
239 //void updateMovedTodo(); 240 //void updateMovedTodo();
240 241
241 void updateEventIndicatorTop(int newY); 242 void updateEventIndicatorTop(int newY);
242 void updateEventIndicatorBottom(int newY); 243 void updateEventIndicatorBottom(int newY);
243 244
244 /** Updates data for selected timespan */ 245 /** Updates data for selected timespan */
245 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 246 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
246 /** Updates data for selected timespan for all day event*/ 247 /** Updates data for selected timespan for all day event*/
247 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 248 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
248 249
249 private: 250 private:
250 // view widgets 251 // view widgets
251 QFrame *mDayLabels; 252 QFrame *mDayLabels;
252 QHBox *mDayLabelsFrame; 253 QHBox *mDayLabelsFrame;
253 QBoxLayout *mLayoutDayLabels; 254 QBoxLayout *mLayoutDayLabels;
254 QFrame *mAllDayFrame; 255 QFrame *mAllDayFrame;
255 KOAgenda *mAllDayAgenda; 256 KOAgenda *mAllDayAgenda;
256 KOAgenda *mAgenda; 257 KOAgenda *mAgenda;
257 TimeLabels *mTimeLabels; 258 TimeLabels *mTimeLabels;
258 QWidget *mDummyAllDayLeft; 259 QWidget *mDummyAllDayLeft;
259 260
260 KDGanttMinimizeSplitter* mSplitterAgenda; 261 KDGanttMinimizeSplitter* mSplitterAgenda;
261 QPushButton *mExpandButton; 262 QPushButton *mExpandButton;
262 263
263 DateList mSelectedDates; // List of dates to be displayed 264 DateList mSelectedDates; // List of dates to be displayed
264 int mViewType; 265 int mViewType;
265 266
266 bool mWeekStartsMonday; 267 bool mWeekStartsMonday;
267 int mStartHour; 268 int mStartHour;
268 269
269 KOEventPopupMenu *mAgendaPopup; 270 KOEventPopupMenu *mAgendaPopup;
270 KOEventPopupMenu *mAllDayAgendaPopup; 271 KOEventPopupMenu *mAllDayAgendaPopup;
271 272
272 EventIndicator *mEventIndicatorTop; 273 EventIndicator *mEventIndicatorTop;
273 EventIndicator *mEventIndicatorBottom; 274 EventIndicator *mEventIndicatorBottom;
274 275
275 QMemArray<int> mMinY; 276 QMemArray<int> mMinY;
276 QMemArray<int> mMaxY; 277 QMemArray<int> mMaxY;
277 278
278 QMemArray<bool> mHolidayMask; 279 QMemArray<bool> mHolidayMask;
279 280
280 QPixmap mExpandedPixmap; 281 QPixmap mExpandedPixmap;
281 QPixmap mNotExpandedPixmap; 282 QPixmap mNotExpandedPixmap;
282 QPtrList<KOAgendaButton> mDayLabelsList; 283 QPtrList<KOAgendaButton> mDayLabelsList;
283 QDateTime mTimeSpanBegin; 284 QDateTime mTimeSpanBegin;
284 QDateTime mTimeSpanEnd; 285 QDateTime mTimeSpanEnd;
285 bool mTimeSpanInAllDay; 286 bool mTimeSpanInAllDay;
286 void keyPressEvent ( QKeyEvent * e ); 287 void keyPressEvent ( QKeyEvent * e );
287}; 288};
288 289
289#endif // KOAGENDAVIEW_H 290#endif // KOAGENDAVIEW_H
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index f2cfb75..ab96786 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -528,784 +528,787 @@ void MonthViewCell::insertEvent(Event *event)
528 mItemList->insertItem( item ); 528 mItemList->insertItem( item );
529 mToolTip += "\n"; 529 mToolTip += "\n";
530} 530}
531void MonthViewCell::insertTodo(Todo *todo) 531void MonthViewCell::insertTodo(Todo *todo)
532{ 532{
533 QString text; 533 QString text;
534 if (todo->hasDueDate()) { 534 if (todo->hasDueDate()) {
535 if (!todo->doesFloat()) { 535 if (!todo->doesFloat()) {
536 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 536 text += KGlobal::locale()->formatTime(todo->dtDue().time());
537 text += " "; 537 text += " ";
538 } 538 }
539 } 539 }
540 text += i18n("To-Do: %1").arg(todo->summary()); 540 text += i18n("To-Do: %1").arg(todo->summary());
541 541
542 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 542 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
543 //item->setPalette( mStandardPalette ); 543 //item->setPalette( mStandardPalette );
544 QPalette pal; 544 QPalette pal;
545 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 545 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
546 QStringList categories = todo->categories(); 546 QStringList categories = todo->categories();
547 QString cat = categories.first(); 547 QString cat = categories.first();
548 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 548 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
549 pal = getPalette(); 549 pal = getPalette();
550 if (cat.isEmpty()) { 550 if (cat.isEmpty()) {
551 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 551 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
552 } else { 552 } else {
553 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 553 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
554 } 554 }
555 555
556 } else { 556 } else {
557 if (cat.isEmpty()) { 557 if (cat.isEmpty()) {
558 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 558 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
559 } else { 559 } else {
560 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 560 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
561 } 561 }
562 } 562 }
563 563
564 } else { 564 } else {
565 pal = mStandardPalette ; 565 pal = mStandardPalette ;
566 } 566 }
567 item->setPalette( pal ); 567 item->setPalette( pal );
568 mItemList->insertItem( item ); 568 mItemList->insertItem( item );
569 mToolTip += text+"\n"; 569 mToolTip += text+"\n";
570} 570}
571void MonthViewCell::finishUpdateCell() 571void MonthViewCell::finishUpdateCell()
572{ 572{
573#ifdef DESKTOP_VERSION 573#ifdef DESKTOP_VERSION
574 if (mToolTip != "") 574 if (mToolTip != "")
575 QToolTip::add(this,mToolTip,toolTipGroup(),""); 575 QToolTip::add(this,mToolTip,toolTipGroup(),"");
576#endif 576#endif
577 mItemList->sort(); 577 mItemList->sort();
578 //setMyPalette(); 578 //setMyPalette();
579 setMyPalette(); 579 setMyPalette();
580 QString text; 580 QString text;
581 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 581 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
582 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 582 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
583 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 583 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
584 mLabel->resize( mLabelBigSize ); 584 mLabel->resize( mLabelBigSize );
585 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 585 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
586 } else { 586 } else {
587 mLabel->resize( mLabelSize ); 587 mLabel->resize( mLabelSize );
588 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 588 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
589 } 589 }
590 590
591 mLabel->setText( text ); 591 mLabel->setText( text );
592 resizeEvent( 0 ); 592 resizeEvent( 0 );
593} 593}
594void MonthViewCell::updateCell() 594void MonthViewCell::updateCell()
595{ 595{
596 if ( !mMonthView->isUpdatePossible() ) 596 if ( !mMonthView->isUpdatePossible() )
597 return; 597 return;
598 startUpdateCell(); 598 startUpdateCell();
599 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 599 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
600 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 600 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
601 Event *event; 601 Event *event;
602 for( event = events.first(); event; event = events.next() ) { // for event 602 for( event = events.first(); event; event = events.next() ) { // for event
603 insertEvent(event); 603 insertEvent(event);
604 } 604 }
605 // insert due todos 605 // insert due todos
606 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 606 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
607 Todo *todo; 607 Todo *todo;
608 for(todo = todos.first(); todo; todo = todos.next()) { 608 for(todo = todos.first(); todo; todo = todos.next()) {
609 insertTodo( todo ); 609 insertTodo( todo );
610 } 610 }
611 finishUpdateCell(); 611 finishUpdateCell();
612 // if ( isVisible()) 612 // if ( isVisible())
613 //qApp->processEvents(); 613 //qApp->processEvents();
614} 614}
615 615
616void MonthViewCell::updateConfig() 616void MonthViewCell::updateConfig()
617{ 617{
618 setFont( KOPrefs::instance()->mMonthViewFont ); 618 setFont( KOPrefs::instance()->mMonthViewFont );
619 619
620 QFontMetrics fm( font() ); 620 QFontMetrics fm( font() );
621 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 621 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
622 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 622 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
623 mHolidayPalette = mStandardPalette; 623 mHolidayPalette = mStandardPalette;
624 mPrimaryPalette = mStandardPalette; 624 mPrimaryPalette = mStandardPalette;
625 mNonPrimaryPalette = mStandardPalette; 625 mNonPrimaryPalette = mStandardPalette;
626 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 626 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
627 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 627 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
628 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 628 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
629 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 629 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
630 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 630 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
631 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 631 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
632 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 632 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
633 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 633 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
634 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 634 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
635 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 635 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
636 } 636 }
637 //updateCell(); 637 //updateCell();
638} 638}
639 639
640void MonthViewCell::enableScrollBars( bool enabled ) 640void MonthViewCell::enableScrollBars( bool enabled )
641{ 641{
642 if ( enabled ) { 642 if ( enabled ) {
643 mItemList->setVScrollBarMode(QScrollView::Auto); 643 mItemList->setVScrollBarMode(QScrollView::Auto);
644 mItemList->setHScrollBarMode(QScrollView::Auto); 644 mItemList->setHScrollBarMode(QScrollView::Auto);
645 } else { 645 } else {
646 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 646 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
647 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 647 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
648 } 648 }
649} 649}
650 650
651Incidence *MonthViewCell::selectedIncidence() 651Incidence *MonthViewCell::selectedIncidence()
652{ 652{
653 int index = mItemList->currentItem(); 653 int index = mItemList->currentItem();
654 if ( index < 0 ) return 0; 654 if ( index < 0 ) return 0;
655 655
656 MonthViewItem *item = 656 MonthViewItem *item =
657 static_cast<MonthViewItem *>( mItemList->item( index ) ); 657 static_cast<MonthViewItem *>( mItemList->item( index ) );
658 658
659 if ( !item ) return 0; 659 if ( !item ) return 0;
660 660
661 return item->incidence(); 661 return item->incidence();
662} 662}
663 663
664QDate MonthViewCell::selectedIncidenceDate() 664QDate MonthViewCell::selectedIncidenceDate()
665{ 665{
666 QDate qd; 666 QDate qd;
667 int index = mItemList->currentItem(); 667 int index = mItemList->currentItem();
668 if ( index < 0 ) return qd; 668 if ( index < 0 ) return qd;
669 669
670 MonthViewItem *item = 670 MonthViewItem *item =
671 static_cast<MonthViewItem *>( mItemList->item( index ) ); 671 static_cast<MonthViewItem *>( mItemList->item( index ) );
672 672
673 if ( !item ) return qd; 673 if ( !item ) return qd;
674 674
675 return item->incidenceDate(); 675 return item->incidenceDate();
676} 676}
677 677
678void MonthViewCell::deselect() 678void MonthViewCell::deselect()
679{ 679{
680 mItemList->clearSelection(); 680 mItemList->clearSelection();
681 enableScrollBars( false ); 681 enableScrollBars( false );
682 // updateCell(); 682 // updateCell();
683} 683}
684void MonthViewCell::select() 684void MonthViewCell::select()
685{ 685{
686 ;// updateCell(); 686 ;// updateCell();
687} 687}
688 688
689void MonthViewCell::resizeEvent ( QResizeEvent * ) 689void MonthViewCell::resizeEvent ( QResizeEvent * )
690{ 690{
691 if ( !mMonthView->isUpdatePossible() ) 691 if ( !mMonthView->isUpdatePossible() )
692 return; 692 return;
693 693
694 int size = height() - mLabel->height() - 2; 694 int size = height() - mLabel->height() - 2;
695 if ( size > 0 ) 695 if ( size > 0 )
696 mItemList->verticalScrollBar()->setMaximumHeight( size ); 696 mItemList->verticalScrollBar()->setMaximumHeight( size );
697 size = width() - mLabel->width() -2; 697 size = width() - mLabel->width() -2;
698 if ( size > 0 ) 698 if ( size > 0 )
699 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 699 mItemList->horizontalScrollBar()->setMaximumWidth( size );
700 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 700 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
701 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 701 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
702} 702}
703 703
704void MonthViewCell::defaultAction( QListBoxItem *item ) 704void MonthViewCell::defaultAction( QListBoxItem *item )
705{ 705{
706 if ( !item ) return; 706 if ( !item ) return;
707 707
708 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 708 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
709 Incidence *incidence = eventItem->incidence(); 709 Incidence *incidence = eventItem->incidence();
710 if ( incidence ) mMonthView->defaultAction( incidence ); 710 if ( incidence ) mMonthView->defaultAction( incidence );
711} 711}
712void MonthViewCell::showDay() 712void MonthViewCell::showDay()
713{ 713{
714 emit showDaySignal( date() ); 714 emit showDaySignal( date() );
715} 715}
716void MonthViewCell::newEvent() 716void MonthViewCell::newEvent()
717{ 717{
718 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 718 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
719 emit newEventSignal( dt ); 719 emit newEventSignal( dt );
720} 720}
721void MonthViewCell::cellClicked( QListBoxItem *item ) 721void MonthViewCell::cellClicked( QListBoxItem *item )
722{ 722{
723 static QListBoxItem * lastClicked = 0; 723 static QListBoxItem * lastClicked = 0;
724 if ( item == 0 ) { 724 if ( item == 0 ) {
725 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 725 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
726 emit newEventSignal( dt ); 726 emit newEventSignal( dt );
727 return; 727 return;
728 } 728 }
729 /* 729 /*
730 if ( lastClicked ) 730 if ( lastClicked )
731 if ( ! item ) { 731 if ( ! item ) {
732 if ( lastClicked->listBox() != item->listBox() ) 732 if ( lastClicked->listBox() != item->listBox() )
733 lastClicked->listBox()->clearSelection(); 733 lastClicked->listBox()->clearSelection();
734 } 734 }
735 */ 735 */
736 736
737 mMonthView->setSelectedCell( this ); 737 mMonthView->setSelectedCell( this );
738 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 738 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
739 select(); 739 select();
740} 740}
741 741
742void MonthViewCell::contextMenu( QListBoxItem *item ) 742void MonthViewCell::contextMenu( QListBoxItem *item )
743{ 743{
744 if ( !item ) return; 744 if ( !item ) return;
745 745
746 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 746 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
747 Incidence *incidence = eventItem->incidence(); 747 Incidence *incidence = eventItem->incidence();
748 if ( incidence ) mMonthView->showContextMenu( incidence ); 748 if ( incidence ) mMonthView->showContextMenu( incidence );
749} 749}
750 750
751void MonthViewCell::selection( QListBoxItem *item ) 751void MonthViewCell::selection( QListBoxItem *item )
752{ 752{
753 if ( !item ) return; 753 if ( !item ) return;
754 754
755 mMonthView->setSelectedCell( this ); 755 mMonthView->setSelectedCell( this );
756} 756}
757 757
758 758
759// ******************************************************************************* 759// *******************************************************************************
760// ******************************************************************************* 760// *******************************************************************************
761// ******************************************************************************* 761// *******************************************************************************
762 762
763 763
764KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 764KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
765 : KOEventView( calendar, parent, name ), 765 : KOEventView( calendar, parent, name ),
766 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 766 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
767 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 767 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
768{ 768{
769 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 769 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
770 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 770 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
771 if ( mShowWeekView ) 771 if ( mShowWeekView )
772 mWeekStartsMonday = true; 772 mWeekStartsMonday = true;
773 updatePossible = false; 773 updatePossible = false;
774 mCells.setAutoDelete( true ); 774 mCells.setAutoDelete( true );
775 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 775 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
776 // mDayLayout = new QGridLayout( this ); 776 // mDayLayout = new QGridLayout( this );
777 // create the day of the week labels (Sun, Mon, etc) and add them to 777 // create the day of the week labels (Sun, Mon, etc) and add them to
778 // the layout. 778 // the layout.
779 mDayLabels.resize( mDaysPerWeek ); 779 mDayLabels.resize( mDaysPerWeek );
780 QFont bfont = font(); 780 QFont bfont = font();
781 if ( QApplication::desktop()->width() < 650 ) { 781 if ( QApplication::desktop()->width() < 650 ) {
782 bfont.setPointSize( bfont.pointSize() - 2 ); 782 bfont.setPointSize( bfont.pointSize() - 2 );
783 } 783 }
784 bfont.setBold( true ); 784 bfont.setBold( true );
785 int i; 785 int i;
786 786
787 for( i = 0; i < mDaysPerWeek; i++ ) { 787 for( i = 0; i < mDaysPerWeek; i++ ) {
788 QLabel *label = new QLabel( this ); 788 QLabel *label = new QLabel( this );
789 label->setFont(bfont); 789 label->setFont(bfont);
790 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 790 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
791 label->setLineWidth(1); 791 label->setLineWidth(1);
792 label->setAlignment(AlignCenter); 792 label->setAlignment(AlignCenter);
793 mDayLabels.insert( i, label ); 793 mDayLabels.insert( i, label );
794 } 794 }
795 795
796 bfont.setBold( false ); 796 bfont.setBold( false );
797 mWeekLabels.resize( mNumWeeks+1 ); 797 mWeekLabels.resize( mNumWeeks+1 );
798 for( i = 0; i < mNumWeeks+1; i++ ) { 798 for( i = 0; i < mNumWeeks+1; i++ ) {
799 KOWeekButton *label = new KOWeekButton( this ); 799 KOWeekButton *label = new KOWeekButton( this );
800 label->setFont(bfont); 800 label->setFont(bfont);
801 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 801 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
802 label->setFlat(true); 802 label->setFlat(true);
803 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 803 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
804 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 804 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
805 //label->setLineWidth(1); 805 //label->setLineWidth(1);
806 //label->setAlignment(AlignCenter); 806 //label->setAlignment(AlignCenter);
807 mWeekLabels.insert( i, label ); 807 mWeekLabels.insert( i, label );
808 } 808 }
809 mWeekLabels[mNumWeeks]->setText( i18n("")); 809 mWeekLabels[mNumWeeks]->setText( i18n(""));
810 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 810 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
811 int row, col; 811 int row, col;
812 QPopupMenu * wpo = new QPopupMenu (this); 812 QPopupMenu * wpo = new QPopupMenu (this);
813 wpo->insertItem( i18n("W#"), 0 ); 813 wpo->insertItem( i18n("W#"), 0 );
814 for ( i = 1; i < 54; i++ ) 814 for ( i = 1; i < 54; i++ )
815 wpo->insertItem( i18n("%1").arg(i), i ); 815 wpo->insertItem( i18n("%1").arg(i), i );
816 mWeekLabels[mNumWeeks]->setPopup( wpo ); 816 mWeekLabels[mNumWeeks]->setPopup( wpo );
817 mCells.resize( mNumCells ); 817 mCells.resize( mNumCells );
818 for( row = 0; row < mNumWeeks; ++row ) { 818 for( row = 0; row < mNumWeeks; ++row ) {
819 for( col = 0; col < mDaysPerWeek; ++col ) { 819 for( col = 0; col < mDaysPerWeek; ++col ) {
820 MonthViewCell *cell = new MonthViewCell( this ); 820 MonthViewCell *cell = new MonthViewCell( this );
821 mCells.insert( row * mDaysPerWeek + col, cell ); 821 mCells.insert( row * mDaysPerWeek + col, cell );
822 822
823 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 823 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
824 SLOT( defaultAction( Incidence * ) ) ); 824 SLOT( defaultAction( Incidence * ) ) );
825 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 825 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
826 SIGNAL( newEventSignal( QDateTime ) ) ); 826 SIGNAL( newEventSignal( QDateTime ) ) );
827 connect( cell, SIGNAL( showDaySignal( QDate ) ), 827 connect( cell, SIGNAL( showDaySignal( QDate ) ),
828 SIGNAL( showDaySignal( QDate ) ) ); 828 SIGNAL( showDaySignal( QDate ) ) );
829 } 829 }
830 } 830 }
831 831
832 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 832 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
833 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); 833 connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) );
834 mContextMenu = eventPopup(); 834 mContextMenu = eventPopup();
835 // updateConfig(); //useless here 835 // updateConfig(); //useless here
836 836
837 emit incidenceSelected( 0 ); 837 emit incidenceSelected( 0 );
838} 838}
839 839
840KOMonthView::~KOMonthView() 840KOMonthView::~KOMonthView()
841{ 841{
842 delete mContextMenu; 842 delete mContextMenu;
843} 843}
844void KOMonthView::selectDateWeekNum ( int ) 844void KOMonthView::selectDateWeekNum ( int )
845{ 845{
846 846
847} 847}
848void KOMonthView::selectInternalWeekNum ( int n ) 848void KOMonthView::selectInternalWeekNum ( int n )
849{ 849{
850 emit selectWeekNum ( n ); 850 emit selectWeekNum ( n );
851 switchView(); 851 switchView();
852} 852}
853 853
854void KOMonthView::switchView() 854void KOMonthView::switchView()
855{ 855{
856 if ( selectedCell( ) ) 856 if ( selectedCell( ) )
857 selectedCell()->deselect(); 857 selectedCell()->deselect();
858 mShowWeekView = !mShowWeekView; 858 mShowWeekView = !mShowWeekView;
859 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 859 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
860 //emit showNavigator( !mShowWeekView ); 860 //emit showNavigator( !mShowWeekView );
861 computeLayout(); 861 computeLayout();
862 updateConfig(); 862 updateConfig();
863} 863}
864 864
865int KOMonthView::maxDatesHint() 865int KOMonthView::maxDatesHint()
866{ 866{
867 return mNumCells; 867 return mNumCells;
868} 868}
869 869
870int KOMonthView::currentDateCount() 870int KOMonthView::currentDateCount()
871{ 871{
872 return mNumCells; 872 return mNumCells;
873} 873}
874 874
875QPtrList<Incidence> KOMonthView::selectedIncidences() 875QPtrList<Incidence> KOMonthView::selectedIncidences()
876{ 876{
877 QPtrList<Incidence> selected; 877 QPtrList<Incidence> selected;
878 878
879 if ( mSelectedCell ) { 879 if ( mSelectedCell ) {
880 Incidence *incidence = mSelectedCell->selectedIncidence(); 880 Incidence *incidence = mSelectedCell->selectedIncidence();
881 if ( incidence ) selected.append( incidence ); 881 if ( incidence ) selected.append( incidence );
882 } 882 }
883 883
884 return selected; 884 return selected;
885} 885}
886 886
887DateList KOMonthView::selectedDates() 887DateList KOMonthView::selectedDates()
888{ 888{
889 DateList selected; 889 DateList selected;
890 890
891 if ( mSelectedCell ) { 891 if ( mSelectedCell ) {
892 QDate qd = mSelectedCell->selectedIncidenceDate(); 892 QDate qd = mSelectedCell->selectedIncidenceDate();
893 if ( qd.isValid() ) selected.append( qd ); 893 if ( qd.isValid() ) selected.append( qd );
894 } 894 }
895 895
896 return selected; 896 return selected;
897} 897}
898 898
899void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 899void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
900 const QDate &td) 900 const QDate &td)
901{ 901{
902#ifndef KORG_NOPRINTER 902#ifndef KORG_NOPRINTER
903 calPrinter->preview(CalPrinter::Month, fd, td); 903 calPrinter->preview(CalPrinter::Month, fd, td);
904#endif 904#endif
905} 905}
906 906
907void KOMonthView::updateConfig() 907void KOMonthView::updateConfig()
908{ 908{
909 909
910 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 910 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
911 911
912 if ( mShowWeekView ) 912 if ( mShowWeekView ) {
913 mWeekStartsMonday = true; 913 mWeekStartsMonday = true;
914 }
914 QFontMetrics fontmetric(mDayLabels[0]->font()); 915 QFontMetrics fontmetric(mDayLabels[0]->font());
915 mWidthLongDayLabel = 0; 916 mWidthLongDayLabel = 0;
916 917
917 for (int i = 0; i < 7; i++) { 918 for (int i = 0; i < 7; i++) {
918 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 919 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
919 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 920 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
920 } 921 }
921 bool temp = mShowSatSunComp ; 922 bool temp = mShowSatSunComp ;
922 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 923 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
923 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 924 if ( ! mShowWeekView ) {
924 computeLayout(); 925 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
926 computeLayout();
927 }
925 updateDayLabels(); 928 updateDayLabels();
926 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 929 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
927 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 930 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
928 //resizeEvent( 0 ); 931 //resizeEvent( 0 );
929 for (uint i = 0; i < mCells.count(); ++i) { 932 for (uint i = 0; i < mCells.count(); ++i) {
930 mCells[i]->updateConfig(); 933 mCells[i]->updateConfig();
931 } 934 }
932#ifdef DESKTOP_VERSION 935#ifdef DESKTOP_VERSION
933 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 936 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
934#endif 937#endif
935 updateView(); 938 updateView();
936} 939}
937 940
938void KOMonthView::updateDayLabels() 941void KOMonthView::updateDayLabels()
939{ 942{
940 943
941 for (int i = 0; i < 7; i++) { 944 for (int i = 0; i < 7; i++) {
942 if (mWeekStartsMonday) { 945 if (mWeekStartsMonday) {
943 bool show = mShortDayLabels; 946 bool show = mShortDayLabels;
944 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 947 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
945 show = true; 948 show = true;
946 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 949 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
947 } else { 950 } else {
948 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 951 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
949 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 952 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
950 953
951 } 954 }
952 } 955 }
953} 956}
954 957
955void KOMonthView::showDates(const QDate &start, const QDate &) 958void KOMonthView::showDates(const QDate &start, const QDate &)
956{ 959{
957 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 960 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
958 961
959 962
960 mStartDate = start; 963 mStartDate = start;
961 964
962 int startWeekDay = mWeekStartsMonday ? 1 : 7; 965 int startWeekDay = mWeekStartsMonday ? 1 : 7;
963 966
964 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 967 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
965 mStartDate = mStartDate.addDays( -1 ); 968 mStartDate = mStartDate.addDays( -1 );
966 } 969 }
967 970
968 bool primary = false; 971 bool primary = false;
969 uint i; 972 uint i;
970 for( i = 0; i < mCells.size(); ++i ) { 973 for( i = 0; i < mCells.size(); ++i ) {
971 QDate date = mStartDate.addDays( i ); 974 QDate date = mStartDate.addDays( i );
972 mCells[i]->setDate( date ); 975 mCells[i]->setDate( date );
973 976
974#ifndef KORG_NOPLUGINS 977#ifndef KORG_NOPLUGINS
975 // add holiday, if present 978 // add holiday, if present
976 QString hstring(KOCore::self()->holiday(date)); 979 QString hstring(KOCore::self()->holiday(date));
977 mCells[i]->setHoliday( hstring ); 980 mCells[i]->setHoliday( hstring );
978#endif 981#endif
979 982
980 } 983 }
981 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 984 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
982 for( i = 0; i < 6; ++i ) { 985 for( i = 0; i < 6; ++i ) {
983 int wno; 986 int wno;
984 // remember, according to ISO 8601, the first week of the year is the 987 // remember, according to ISO 8601, the first week of the year is the
985 // first week that contains a thursday. Thus we must subtract off 4, 988 // first week that contains a thursday. Thus we must subtract off 4,
986 // not just 1. 989 // not just 1.
987 int dayOfYear = date.dayOfYear(); 990 int dayOfYear = date.dayOfYear();
988 if (dayOfYear % 7 != 0) 991 if (dayOfYear % 7 != 0)
989 wno = dayOfYear / 7 + 1; 992 wno = dayOfYear / 7 + 1;
990 else 993 else
991 wno =dayOfYear / 7; 994 wno =dayOfYear / 7;
992 mWeekLabels[i]->setWeekNum( wno ); 995 mWeekLabels[i]->setWeekNum( wno );
993 date = date.addDays( 7 ); 996 date = date.addDays( 7 );
994 } 997 }
995 updateView(); 998 updateView();
996} 999}
997 1000
998void KOMonthView::showEvents(QPtrList<Event>) 1001void KOMonthView::showEvents(QPtrList<Event>)
999{ 1002{
1000 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1003 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1001} 1004}
1002 1005
1003void KOMonthView::changeEventDisplay(Event *, int) 1006void KOMonthView::changeEventDisplay(Event *, int)
1004{ 1007{
1005 // this should be re-written to be much more efficient, but this 1008 // this should be re-written to be much more efficient, but this
1006 // quick-and-dirty-hack gets the job done for right now. 1009 // quick-and-dirty-hack gets the job done for right now.
1007 updateView(); 1010 updateView();
1008} 1011}
1009 1012
1010void KOMonthView::updateView() 1013void KOMonthView::updateView()
1011{ 1014{
1012 1015
1013 if ( !updatePossible ) 1016 if ( !updatePossible )
1014 return; 1017 return;
1015 //QTime ti; 1018 //QTime ti;
1016 //ti.start(); 1019 //ti.start();
1017#if 1 1020#if 1
1018 int i; 1021 int i;
1019 int timeSpan = mCells.size()-1; 1022 int timeSpan = mCells.size()-1;
1020 if ( KOPrefs::instance()->mMonthViewWeek ) 1023 if ( KOPrefs::instance()->mMonthViewWeek )
1021 timeSpan = 6; 1024 timeSpan = 6;
1022 for( i = 0; i < timeSpan + 1; ++i ) { 1025 for( i = 0; i < timeSpan + 1; ++i ) {
1023 mCells[i]->startUpdateCell(); 1026 mCells[i]->startUpdateCell();
1024 } 1027 }
1025 1028
1026 QPtrList<Event> events = calendar()->events(); 1029 QPtrList<Event> events = calendar()->events();
1027 Event *event; 1030 Event *event;
1028 QDateTime dt; 1031 QDateTime dt;
1029 bool ok; 1032 bool ok;
1030 QDate endDate = mStartDate.addDays( timeSpan ); 1033 QDate endDate = mStartDate.addDays( timeSpan );
1031 for( event = events.first(); event; event = events.next() ) { // for event 1034 for( event = events.first(); event; event = events.next() ) { // for event
1032 if ( event->doesRecur() ) { 1035 if ( event->doesRecur() ) {
1033 bool last; 1036 bool last;
1034 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1037 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1035 QDateTime incidenceEnd; 1038 QDateTime incidenceEnd;
1036 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1039 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1037 bool invalid = false; 1040 bool invalid = false;
1038 while( true ) { 1041 while( true ) {
1039 if ( incidenceStart.isValid() ) { 1042 if ( incidenceStart.isValid() ) {
1040 incidenceEnd = incidenceStart.addDays( eventlen ); 1043 incidenceEnd = incidenceStart.addDays( eventlen );
1041 int st = incidenceStart.date().daysTo( endDate ); 1044 int st = incidenceStart.date().daysTo( endDate );
1042 if ( st >= 0 ) { // start before timeend 1045 if ( st >= 0 ) { // start before timeend
1043 int end = mStartDate.daysTo( incidenceEnd.date() ); 1046 int end = mStartDate.daysTo( incidenceEnd.date() );
1044 if ( end >= 0 ) { // end after timestart --- got one! 1047 if ( end >= 0 ) { // end after timestart --- got one!
1045 //normalize 1048 //normalize
1046 st = timeSpan - st; 1049 st = timeSpan - st;
1047 if ( st < 0 ) st = 0; 1050 if ( st < 0 ) st = 0;
1048 if ( end > timeSpan ) end = timeSpan; 1051 if ( end > timeSpan ) end = timeSpan;
1049 int iii; 1052 int iii;
1050 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1053 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1051 for ( iii = st;iii<= end;++iii) 1054 for ( iii = st;iii<= end;++iii)
1052 mCells[iii]->insertEvent( event ); 1055 mCells[iii]->insertEvent( event );
1053 } 1056 }
1054 } 1057 }
1055 } else { 1058 } else {
1056 if ( invalid ) 1059 if ( invalid )
1057 break; 1060 break;
1058 invalid = true; 1061 invalid = true;
1059 //qDebug("invalid %s", event->summary().latin1()); 1062 //qDebug("invalid %s", event->summary().latin1());
1060 incidenceStart = QDateTime( mStartDate ); 1063 incidenceStart = QDateTime( mStartDate );
1061 } 1064 }
1062 if ( last ) 1065 if ( last )
1063 break; 1066 break;
1064 bool ok; 1067 bool ok;
1065 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1068 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1066 if ( ! ok ) 1069 if ( ! ok )
1067 break; 1070 break;
1068 if ( incidenceStart.date() > endDate ) 1071 if ( incidenceStart.date() > endDate )
1069 break; 1072 break;
1070 } 1073 }
1071 } else { // no recur 1074 } else { // no recur
1072 int st = event->dtStart().date().daysTo( endDate ); 1075 int st = event->dtStart().date().daysTo( endDate );
1073 if ( st >= 0 ) { // start before timeend 1076 if ( st >= 0 ) { // start before timeend
1074 int end = mStartDate.daysTo( event->dtEnd().date() ); 1077 int end = mStartDate.daysTo( event->dtEnd().date() );
1075 if ( end >= 0 ) { // end after timestart --- got one! 1078 if ( end >= 0 ) { // end after timestart --- got one!
1076 //normalize 1079 //normalize
1077 st = timeSpan - st; 1080 st = timeSpan - st;
1078 if ( st < 0 ) st = 0; 1081 if ( st < 0 ) st = 0;
1079 if ( end > timeSpan ) end = timeSpan; 1082 if ( end > timeSpan ) end = timeSpan;
1080 int iii; 1083 int iii;
1081 for ( iii = st;iii<= end;++iii) 1084 for ( iii = st;iii<= end;++iii)
1082 mCells[iii]->insertEvent( event ); 1085 mCells[iii]->insertEvent( event );
1083 } 1086 }
1084 } 1087 }
1085 } 1088 }
1086 } 1089 }
1087 // insert due todos 1090 // insert due todos
1088 QPtrList<Todo> todos = calendar()->todos( ); 1091 QPtrList<Todo> todos = calendar()->todos( );
1089 Todo *todo; 1092 Todo *todo;
1090 for(todo = todos.first(); todo; todo = todos.next()) { 1093 for(todo = todos.first(); todo; todo = todos.next()) {
1091 //insertTodo( todo ); 1094 //insertTodo( todo );
1092 if ( todo->hasDueDate() ) { 1095 if ( todo->hasDueDate() ) {
1093 int day = mStartDate.daysTo( todo->dtDue().date() ); 1096 int day = mStartDate.daysTo( todo->dtDue().date() );
1094 if ( day >= 0 && day < timeSpan + 1) { 1097 if ( day >= 0 && day < timeSpan + 1) {
1095 mCells[day]->insertTodo( todo ); 1098 mCells[day]->insertTodo( todo );
1096 } 1099 }
1097 } 1100 }
1098 } 1101 }
1099 1102
1100 for( i = 0; i < timeSpan+1; ++i ) { 1103 for( i = 0; i < timeSpan+1; ++i ) {
1101 mCells[i]->finishUpdateCell(); 1104 mCells[i]->finishUpdateCell();
1102 } 1105 }
1103 processSelectionChange(); 1106 processSelectionChange();
1104 mCells[0]->setFocus(); 1107 mCells[0]->setFocus();
1105 1108
1106 1109
1107#else 1110#else
1108 // old code 1111 // old code
1109 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1112 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1110 int i; 1113 int i;
1111 for( i = 0; i < mCells.count(); ++i ) { 1114 for( i = 0; i < mCells.count(); ++i ) {
1112 mCells[i]->updateCell(); 1115 mCells[i]->updateCell();
1113 } 1116 }
1114 1117
1115 //qDebug("KOMonthView::updateView() "); 1118 //qDebug("KOMonthView::updateView() ");
1116 processSelectionChange(); 1119 processSelectionChange();
1117 // qDebug("---------------------------------------------------------------------+ "); 1120 // qDebug("---------------------------------------------------------------------+ ");
1118 mCells[0]->setFocus(); 1121 mCells[0]->setFocus();
1119#endif 1122#endif
1120 1123
1121 //qDebug("update time %d ", ti.elapsed()); 1124 //qDebug("update time %d ", ti.elapsed());
1122} 1125}
1123 1126
1124void KOMonthView::resizeEvent(QResizeEvent * e) 1127void KOMonthView::resizeEvent(QResizeEvent * e)
1125{ 1128{
1126 computeLayout(); 1129 computeLayout();
1127 mCells[0]->setFocus(); 1130 mCells[0]->setFocus();
1128} 1131}
1129void KOMonthView::computeLayoutWeek() 1132void KOMonthView::computeLayoutWeek()
1130{ 1133{
1131 1134
1132 int daysToShow; 1135 int daysToShow;
1133 bool combinedSatSun = false; 1136 bool combinedSatSun = false;
1134 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1137 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1135 daysToShow = 6; 1138 daysToShow = 6;
1136 combinedSatSun = true; 1139 combinedSatSun = true;
1137 } 1140 }
1138 int tWid = topLevelWidget()->size().width(); 1141 int tWid = topLevelWidget()->size().width();
1139 int tHei = topLevelWidget()->size().height(); 1142 int tHei = topLevelWidget()->size().height();
1140 1143
1141 int wid = size().width();//e 1144 int wid = size().width();//e
1142 int hei = size().height()-1; 1145 int hei = size().height()-1;
1143 1146
1144 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1147 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1145 return; 1148 return;
1146 1149
1147 if ( wid < hei ) 1150 if ( wid < hei )
1148 daysToShow = 2; 1151 daysToShow = 2;
1149 else 1152 else
1150 daysToShow = 3; 1153 daysToShow = 3;
1151 mShowSatSunComp = true; 1154 mShowSatSunComp = true;
1152 combinedSatSun = true; 1155 combinedSatSun = true;
1153 1156
1154 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1157 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1155 QFontMetrics fm ( mWeekLabels[0]->font() ); 1158 QFontMetrics fm ( mWeekLabels[0]->font() );
1156 int weeklabelwid = fm.width( "888" ); 1159 int weeklabelwid = fm.width( "888" );
1157 wid -= weeklabelwid; 1160 wid -= weeklabelwid;
1158 1161
1159 int colWid = wid / daysToShow; 1162 int colWid = wid / daysToShow;
1160 int lastCol = wid - ( colWid*6 ); 1163 int lastCol = wid - ( colWid*6 );
1161 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1164 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1162 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1165 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1163 int colModulo = wid % daysToShow; 1166 int colModulo = wid % daysToShow;
1164 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1167 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1165 //qDebug("rowmod %d ", rowModulo); 1168 //qDebug("rowmod %d ", rowModulo);
1166 int i; 1169 int i;
1167 int x,y,w,h; 1170 int x,y,w,h;
1168 x= 0; 1171 x= 0;
1169 y= 0; 1172 y= 0;
1170 w = colWid; 1173 w = colWid;
1171 h = dayLabelHei ; 1174 h = dayLabelHei ;
1172 for ( i = 0; i < 7; i++) { 1175 for ( i = 0; i < 7; i++) {
1173 if ( i && !( i % daysToShow) && i < 6) { 1176 if ( i && !( i % daysToShow) && i < 6) {
1174 y += hei/(5-daysToShow); 1177 y += hei/(5-daysToShow);
1175 x = 0; 1178 x = 0;
1176 w = colWid; 1179 w = colWid;
1177 } 1180 }
1178 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1181 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1179 ++w; 1182 ++w;
1180 } 1183 }
1181 if ( i >= 5 ) { 1184 if ( i >= 5 ) {
1182 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1185 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1183 x -= (w/2 ); 1186 x -= (w/2 );
1184 } 1187 }
1185 else 1188 else
1186 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1189 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1187 x += w; 1190 x += w;
1188 } 1191 }
1189 x= 0; 1192 x= 0;
1190 y= dayLabelHei; 1193 y= dayLabelHei;
1191 w = colWid; 1194 w = colWid;
1192 h = cellHei; 1195 h = cellHei;
1193 for ( i = 0; i < mCells.count(); ++i) { 1196 for ( i = 0; i < mCells.count(); ++i) {
1194 if ( i > 6 ) { 1197 if ( i > 6 ) {
1195 mCells[i]->hide(); 1198 mCells[i]->hide();
1196 continue; 1199 continue;
1197 } 1200 }
1198 1201
1199 w = colWid; 1202 w = colWid;
1200 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1203 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1201 ++w; 1204 ++w;
1202 } 1205 }
1203 if ( i == (daysToShow-1-rowModulo)*7) 1206 if ( i == (daysToShow-1-rowModulo)*7)
1204 ++h; 1207 ++h;
1205 1208
1206 if ( i >= 5 ) { 1209 if ( i >= 5 ) {
1207 if ( i ==5 ) { 1210 if ( i ==5 ) {
1208 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1211 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1209 x -= w ;y += h/2; 1212 x -= w ;y += h/2;
1210 } else { 1213 } else {
1211 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1214 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1212 ++w; 1215 ++w;
1213 } 1216 }
1214 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1217 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1215 y -= h/2; 1218 y -= h/2;
1216 } 1219 }
1217 } else 1220 } else
1218 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1221 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1219 1222
1220 1223
1221 x += w; 1224 x += w;
1222 if ( x + w/2 > wid ) { 1225 if ( x + w/2 > wid ) {
1223 x = 0; 1226 x = 0;
1224 y += h+dayLabelHei ; 1227 y += h+dayLabelHei ;
1225 } 1228 }
1226 } 1229 }
1227 y= dayLabelHei; 1230 y= dayLabelHei;
1228 h = cellHei ; 1231 h = cellHei ;
1229 mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1232 mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1230 for ( i = 1; i < 6; i++) { 1233 for ( i = 1; i < 6; i++) {
1231 mWeekLabels[i]->hide(); 1234 mWeekLabels[i]->hide();
1232 } 1235 }
1233 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1236 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1234 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1237 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1235 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1238 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1236 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1239 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1237 updateDayLabels(); 1240 updateDayLabels();
1238 bool forceUpdate = !updatePossible; 1241 bool forceUpdate = !updatePossible;
1239 updatePossible = true; 1242 updatePossible = true;
1240 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1243 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1241 if ( forceUpdate ) 1244 if ( forceUpdate )
1242 updateView(); 1245 updateView();
1243} 1246}
1244void KOMonthView::computeLayout() 1247void KOMonthView::computeLayout()
1245{ 1248{
1246 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 1249 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
1247 // note this only changes the text if the requested size crosses the 1250 // note this only changes the text if the requested size crosses the
1248 // threshold between big enough to support the full name and not big 1251 // threshold between big enough to support the full name and not big
1249 // enough. 1252 // enough.
1250 if ( mShowWeekView ){ 1253 if ( mShowWeekView ){
1251 computeLayoutWeek(); 1254 computeLayoutWeek();
1252 return; 1255 return;
1253 } 1256 }
1254 int daysToShow = 7; 1257 int daysToShow = 7;
1255 bool combinedSatSun = false; 1258 bool combinedSatSun = false;
1256 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1259 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1257 daysToShow = 6; 1260 daysToShow = 6;
1258 combinedSatSun = true; 1261 combinedSatSun = true;
1259 } 1262 }
1260 int tWid = topLevelWidget()->size().width(); 1263 int tWid = topLevelWidget()->size().width();
1261 int tHei = topLevelWidget()->size().height(); 1264 int tHei = topLevelWidget()->size().height();
1262 1265
1263 int wid = size().width();//e 1266 int wid = size().width();//e
1264 int hei = size().height()-1; 1267 int hei = size().height()-1;
1265 1268
1266 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1269 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1267 return; 1270 return;
1268 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1271 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1269 QFontMetrics fm ( mWeekLabels[0]->font() ); 1272 QFontMetrics fm ( mWeekLabels[0]->font() );
1270 int weeklabelwid = fm.width( "888" ); 1273 int weeklabelwid = fm.width( "888" );
1271 wid -= weeklabelwid; 1274 wid -= weeklabelwid;
1272 1275
1273 int colWid = wid / daysToShow; 1276 int colWid = wid / daysToShow;
1274 int lastCol = wid - ( colWid*6 ); 1277 int lastCol = wid - ( colWid*6 );
1275 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1278 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1276 int cellHei = (hei - dayLabelHei) /6; 1279 int cellHei = (hei - dayLabelHei) /6;
1277 int colModulo = wid % daysToShow; 1280 int colModulo = wid % daysToShow;
1278 int rowModulo = (hei- dayLabelHei) % 6; 1281 int rowModulo = (hei- dayLabelHei) % 6;
1279 //qDebug("rowmod %d ", rowModulo); 1282 //qDebug("rowmod %d ", rowModulo);
1280 int i; 1283 int i;
1281 int x,y,w,h; 1284 int x,y,w,h;
1282 x= 0; 1285 x= 0;
1283 y= 0; 1286 y= 0;
1284 w = colWid; 1287 w = colWid;
1285 h = dayLabelHei ; 1288 h = dayLabelHei ;
1286 for ( i = 0; i < 7; i++) { 1289 for ( i = 0; i < 7; i++) {
1287 if ( i == daysToShow-colModulo ) 1290 if ( i == daysToShow-colModulo )
1288 ++w; 1291 ++w;
1289 if ( combinedSatSun ) { 1292 if ( combinedSatSun ) {
1290 if ( i >= daysToShow-1 ) { 1293 if ( i >= daysToShow-1 ) {
1291 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1294 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1292 x -= w/2 ; 1295 x -= w/2 ;
1293 } 1296 }
1294 else 1297 else
1295 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1298 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1296 } else 1299 } else
1297 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1300 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1298 x += w; 1301 x += w;
1299 } 1302 }
1300 x= 0; 1303 x= 0;
1301 y= dayLabelHei; 1304 y= dayLabelHei;
1302 w = colWid; 1305 w = colWid;
1303 h = cellHei ; 1306 h = cellHei ;
1304 for ( i = 0; i < mCells.count(); ++i) { 1307 for ( i = 0; i < mCells.count(); ++i) {
1305 mCells[i]->show(); 1308 mCells[i]->show();
1306 w = colWid; 1309 w = colWid;
1307 if ( ((i) % 7) >= 7-colModulo ) { 1310 if ( ((i) % 7) >= 7-colModulo ) {
1308 ++w; 1311 ++w;
1309 } 1312 }
1310 if ( i == (6-rowModulo)*7) 1313 if ( i == (6-rowModulo)*7)
1311 ++h; 1314 ++h;
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index ca3de59..a74c5fe 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -26,637 +26,639 @@
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 64
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") showMonthView(); 91 else if (view == "Month") showMonthView();
92 else if (view == "List") showListView(); 92 else if (view == "List") showListView();
93 else if (view == "Journal") showJournalView(); 93 else if (view == "Journal") showJournalView();
94 else if (view == "TimeSpan") showTimeSpanView(); 94 else if (view == "TimeSpan") showTimeSpanView();
95 else if (view == "Todo") showTodoView(); 95 else if (view == "Todo") showTodoView();
96 else { 96 else {
97 showAgendaView(); 97 showAgendaView();
98 } 98 }
99} 99}
100 100
101void KOViewManager::showDateView( int view, QDate date) 101void KOViewManager::showDateView( int view, QDate date)
102{ 102{
103 static int lastMode = 0; 103 static int lastMode = 0;
104 static int lastCount = 0; 104 static int lastCount = 0;
105 static bool lastNDMode = false; 105 static bool lastNDMode = false;
106 static QDate lastDate; 106 static QDate lastDate;
107 //qDebug("date %d %s", view, date.toString().latin1()); 107 //qDebug("date %d %s", view, date.toString().latin1());
108 108
109 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 109 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
110 bool savemFlagShowNextxDays = mFlagShowNextxDays; 110 bool savemFlagShowNextxDays = mFlagShowNextxDays;
111 mFlagShowNextxDays = false; 111 mFlagShowNextxDays = false;
112 if ( view == 3 ) { 112 if ( view == 3 ) {
113 //mCurrentAgendaView = 1 ; 113 //mCurrentAgendaView = 1 ;
114 lastDate = mMainView->dateNavigator()->selectedDates().first(); 114 lastDate = mMainView->dateNavigator()->selectedDates().first();
115 lastCount = mMainView->dateNavigator()->selectedDates().count(); 115 lastCount = mMainView->dateNavigator()->selectedDates().count();
116 lastNDMode = savemFlagShowNextxDays; 116 lastNDMode = savemFlagShowNextxDays;
117 mMainView->showDay( date ); 117 mMainView->showDay( date );
118 } else if (view == 4 ) { 118 } else if (view == 4 ) {
119 mCurrentAgendaView = 7 ; 119 mCurrentAgendaView = 7 ;
120 mMainView->dateNavigator()->selectDates( date, 7 ); 120 mMainView->dateNavigator()->selectDates( date, 7 );
121 } else if (view == 5 ) { 121 } else if (view == 5 ) {
122 mCurrentAgendaView = 14 ; 122 mCurrentAgendaView = 14 ;
123 mMainView->dateNavigator()->selectDates( date, 14); 123 mMainView->dateNavigator()->selectDates( date, 14);
124 } else if (view == 6 ) { 124 } else if (view == 6 ) {
125 mMainView->dateNavigator()->selectDates( date, 7 ); 125 mMainView->dateNavigator()->selectDates( date, 7 );
126 showMonthView(); 126 showMonthView();
127 } else if (view == 7 ) { 127 } else if (view == 7 ) {
128 mMainView->dateNavigator()->selectDate( date ); 128 mMainView->dateNavigator()->selectDate( date );
129 showJournalView(); 129 showJournalView();
130 } else if (view == 8 ) { 130 } else if (view == 8 ) {
131 globalFlagBlockAgenda = 1; 131 globalFlagBlockAgenda = 1;
132 if ( mCurrentAgendaView != 3 ) 132 if ( mCurrentAgendaView != 3 )
133 mCurrentAgendaView = -1; 133 mCurrentAgendaView = -1;
134 showAgendaView(KOPrefs::instance()->mFullViewMonth); 134 showAgendaView(KOPrefs::instance()->mFullViewMonth);
135 globalFlagBlockAgenda = 2; 135 globalFlagBlockAgenda = 2;
136 mMainView->dateNavigator()->selectDates( date , 136 mMainView->dateNavigator()->selectDates( date ,
137 KOPrefs::instance()->mNextXDays ); 137 KOPrefs::instance()->mNextXDays );
138 mFlagShowNextxDays = true; 138 mFlagShowNextxDays = true;
139 mCurrentAgendaView = 3 ; 139 mCurrentAgendaView = 3 ;
140 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 140 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
141 if ( lastMode ) { 141 if ( lastMode ) {
142 mCurrentAgendaView = lastCount ; 142 mCurrentAgendaView = lastCount ;
143 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 143 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
144 mFlagShowNextxDays = lastNDMode; 144 mFlagShowNextxDays = lastNDMode;
145 if ( mFlagShowNextxDays ) { 145 if ( mFlagShowNextxDays ) {
146 mCurrentAgendaView = 3 ; 146 mCurrentAgendaView = 3 ;
147 } 147 }
148 } else 148 } else
149 showWeekView(); 149 showWeekView();
150 } else if (view == 10) { 150 } else if (view == 10) {
151 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 151 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
152 } 152 }
153 lastMode = view; 153 lastMode = view;
154} 154}
155 155
156 156
157 157
158void KOViewManager::writeSettings(KConfig *config) 158void KOViewManager::writeSettings(KConfig *config)
159{ 159{
160 config->setGroup("General"); 160 config->setGroup("General");
161 161
162 QString view; 162 QString view;
163 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 163 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
164 else if (mCurrentView == mMonthView) view = "Month"; 164 else if (mCurrentView == mMonthView) view = "Month";
165 else if (mCurrentView == mListView) view = "List"; 165 else if (mCurrentView == mListView) view = "List";
166 else if (mCurrentView == mJournalView) view = "Journal"; 166 else if (mCurrentView == mJournalView) view = "Journal";
167 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 167 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
168 else if (mCurrentView == mTodoView) view = "Todo"; 168 else if (mCurrentView == mTodoView) view = "Todo";
169 else view = "Agenda"; 169 else view = "Agenda";
170 170
171 config->writeEntry("Current View",view); 171 config->writeEntry("Current View",view);
172 172
173 if (mAgendaView) { 173 if (mAgendaView) {
174 mAgendaView->writeSettings(config); 174 mAgendaView->writeSettings(config);
175 } 175 }
176 if (mTimeSpanView) { 176 if (mTimeSpanView) {
177 mTimeSpanView->writeSettings(config); 177 mTimeSpanView->writeSettings(config);
178 } 178 }
179 if (mListView) { 179 if (mListView) {
180 mListView->writeSettings(config); 180 mListView->writeSettings(config);
181 } 181 }
182 if (mTodoView) { 182 if (mTodoView) {
183 mTodoView->saveLayout(config,"Todo View"); 183 mTodoView->saveLayout(config,"Todo View");
184 } 184 }
185} 185}
186 186
187void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 187void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
188{ 188{
189 189
190 //mFlagShowNextxDays = false; 190 //mFlagShowNextxDays = false;
191 //if(view == mCurrentView) return; 191 //if(view == mCurrentView) return;
192 if ( view == 0 ) { 192 if ( view == 0 ) {
193 view = mCurrentView; 193 view = mCurrentView;
194 if ( view == 0 ) 194 if ( view == 0 )
195 return; 195 return;
196 } 196 }
197 bool full = fullScreen; 197 bool full = fullScreen;
198 if(view == mCurrentView && view != mWhatsNextView ) { 198 if(view == mCurrentView && view != mWhatsNextView ) {
199 if ( mCurrentAgendaView < 0 ) 199 if ( mCurrentAgendaView < 0 )
200 return; 200 return;
201 full = mMainView->leftFrame()->isVisible(); 201 full = mMainView->leftFrame()->isVisible();
202 } else { 202 } else {
203 mCurrentView = view; 203 mCurrentView = view;
204 // bool full = fullScreen; 204 // bool full = fullScreen;
205 bool isFull = !mMainView->leftFrame()->isVisible(); 205 bool isFull = !mMainView->leftFrame()->isVisible();
206 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 206 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
207 full = true; 207 full = true;
208 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 208 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
209 full = false; 209 full = false;
210 } 210 }
211 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 211 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
212 //raiseCurrentView( full ); 212 //raiseCurrentView( full );
213 mMainView->processIncidenceSelection( 0 ); 213 mMainView->processIncidenceSelection( 0 );
214 //mMainView->updateView(); 214 //mMainView->updateView();
215 raiseCurrentView( full, true ); 215 raiseCurrentView( full, true );
216 mMainView->adaptNavigationUnits(); 216 mMainView->adaptNavigationUnits();
217} 217}
218 218
219void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 219void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
220{ 220{
221 mCurrentAgendaView = 0; 221 mCurrentAgendaView = 0;
222 int wid = mMainView->width() ; 222 int wid = mMainView->width() ;
223 int hei = mMainView->height(); 223 int hei = mMainView->height();
224 if ( mCurrentView == mMonthView ) { 224 if ( mCurrentView == mMonthView ) {
225 if ( true /* !KOPrefs::instance()->mMonthViewWeek*/ ) { 225 if ( true /* !KOPrefs::instance()->mMonthViewWeek*/ ) {
226 mMainView->navigatorBar()->show(); 226 mMainView->navigatorBar()->show();
227 hei -= mMainView->navigatorBar()->sizeHint().height(); 227 hei -= mMainView->navigatorBar()->sizeHint().height();
228 } 228 }
229 //mMainView->navigatorBar()->hide(); 229 //mMainView->navigatorBar()->hide();
230 } else { 230 } else {
231 mMainView->navigatorBar()->hide(); 231 mMainView->navigatorBar()->hide();
232 } 232 }
233 if ( fullScreen ) { 233 if ( fullScreen ) {
234 mMainView->leftFrame()->hide(); 234 mMainView->leftFrame()->hide();
235 } else { 235 } else {
236 mMainView->leftFrame()->show(); 236 mMainView->leftFrame()->show();
237 if ( KOPrefs::instance()->mVerticalScreen ) 237 if ( KOPrefs::instance()->mVerticalScreen )
238 hei -= mMainView->leftFrame()->height(); 238 hei -= mMainView->leftFrame()->height();
239 else 239 else
240 wid -= mMainView->leftFrame()->width(); 240 wid -= mMainView->leftFrame()->width();
241 } 241 }
242 emit signalFullScreen( !fullScreen ); 242 emit signalFullScreen( !fullScreen );
243 if ( callUpdateView ) 243 if ( callUpdateView )
244 mMainView->updateView(); 244 mMainView->updateView();
245 245
246 if ( globalFlagBlockAgenda == 5 ) { 246 if ( globalFlagBlockAgenda == 5 ) {
247 globalFlagBlockAgenda = 4; 247 globalFlagBlockAgenda = 4;
248 globalFlagBlockAgendaItemPaint = 1; 248 globalFlagBlockAgendaItemPaint = 1;
249 } 249 }
250 mMainView->viewStack()->raiseWidget(mCurrentView); 250 mMainView->viewStack()->raiseWidget(mCurrentView);
251 if ( globalFlagBlockAgenda == 4 ) { 251 if ( globalFlagBlockAgenda == 4 ) {
252 if ( mCurrentView == mAgendaView ) { 252 if ( mCurrentView == mAgendaView ) {
253 //globalFlagBlockAgenda =1 ; 253 //globalFlagBlockAgenda =1 ;
254 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 254 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
255 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 255 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
256 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 256 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
257 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 257 mAgendaView->setStartHour( QTime::currentTime ().hour() );
258 qApp->processEvents(); 258 qApp->processEvents();
259 //qDebug("qApp->processEvents() "); 259 //qDebug("qApp->processEvents() ");
260 globalFlagBlockAgenda = 0; 260 globalFlagBlockAgenda = 0;
261 mAgendaView->repaintAgenda(); 261 mAgendaView->repaintAgenda();
262 262
263 } 263 }
264 globalFlagBlockAgenda = 0; 264 globalFlagBlockAgenda = 0;
265 } 265 }
266 emit signalAgendaView( mCurrentView == mAgendaView ); 266 emit signalAgendaView( mCurrentView == mAgendaView );
267 //qDebug("raiseCurrentView ende "); 267 //qDebug("raiseCurrentView ende ");
268 268
269} 269}
270 270
271void KOViewManager::updateView() 271void KOViewManager::updateView()
272{ 272{
273 // qDebug("KOViewManager::updateView() "); 273 // qDebug("KOViewManager::updateView() ");
274 // if we are updating mTodoView, we get endless recursion 274 // if we are updating mTodoView, we get endless recursion
275 if ( mTodoView == mCurrentView ) 275 if ( mTodoView == mCurrentView )
276 return; 276 return;
277 if ( mCurrentView ) mCurrentView->updateView(); 277 if ( mCurrentView ) mCurrentView->updateView();
278 278
279} 279}
280 280
281void KOViewManager::updateView(const QDate &start, const QDate &end) 281void KOViewManager::updateView(const QDate &start, const QDate &end)
282{ 282{
283 // kdDebug() << "KOViewManager::updateView()" << endl; 283 // kdDebug() << "KOViewManager::updateView()" << endl;
284 284
285 if (mCurrentView) mCurrentView->showDates(start, end); 285 if (mCurrentView) mCurrentView->showDates(start, end);
286 286
287 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 287 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
288} 288}
289 289
290 290
291void KOViewManager::updateWNview() 291void KOViewManager::updateWNview()
292{ 292{
293 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 293 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
294 mWhatsNextView->updateView(); 294 mWhatsNextView->updateView();
295 295
296} 296}
297void KOViewManager::showWhatsNextView() 297void KOViewManager::showWhatsNextView()
298{ 298{
299 if (!mWhatsNextView) { 299 if (!mWhatsNextView) {
300 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 300 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
301 "KOViewManager::WhatsNextView"); 301 "KOViewManager::WhatsNextView");
302 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 302 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
303 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 303 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
304 addView(mWhatsNextView); 304 addView(mWhatsNextView);
305 connect(this, SIGNAL( printWNV() ), 305 connect(this, SIGNAL( printWNV() ),
306 mWhatsNextView, SLOT( printMe() ) ); 306 mWhatsNextView, SLOT( printMe() ) );
307 } 307 }
308 globalFlagBlockAgenda = 1; 308 globalFlagBlockAgenda = 1;
309 showView(mWhatsNextView, true ); 309 showView(mWhatsNextView, true );
310 //mWhatsNextView->updateView(); 310 //mWhatsNextView->updateView();
311 311
312} 312}
313 313
314void KOViewManager::showListView() 314void KOViewManager::showListView()
315{ 315{
316 if (!mListView) { 316 if (!mListView) {
317 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 317 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
318 addView(mListView); 318 addView(mListView);
319 319
320 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 320 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
321 mMainView, SLOT(showIncidence(Incidence *))); 321 mMainView, SLOT(showIncidence(Incidence *)));
322 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 322 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
323 mMainView, SLOT(editIncidence(Incidence *))); 323 mMainView, SLOT(editIncidence(Incidence *)));
324 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 324 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
325 mMainView, SLOT(deleteIncidence(Incidence *))); 325 mMainView, SLOT(deleteIncidence(Incidence *)));
326 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 326 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
327 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 327 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
328 connect( mListView, SIGNAL( signalNewEvent() ), 328 connect( mListView, SIGNAL( signalNewEvent() ),
329 mMainView, SLOT( newEvent() ) ); 329 mMainView, SLOT( newEvent() ) );
330 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 330 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
331 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 331 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
332 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 332 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
333 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 333 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
334 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 334 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
335 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 335 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
336 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 336 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
337 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 337 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
338 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 338 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
339 } 339 }
340 // bool temp = mFlagShowNextxDays; 340 // bool temp = mFlagShowNextxDays;
341 //globalFlagBlockPainting = true; 341 //globalFlagBlockPainting = true;
342 globalFlagBlockAgenda = 1; 342 globalFlagBlockAgenda = 1;
343 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 343 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
344 mMainView->setBlockShowDates( true ); 344 mMainView->setBlockShowDates( true );
345 mMainView->dateNavigator()->selectMonth(); 345 mMainView->dateNavigator()->selectMonth();
346 mMainView->setBlockShowDates( false ); 346 mMainView->setBlockShowDates( false );
347 } 347 }
348 showView(mListView, KOPrefs::instance()->mFullViewTodo); 348 showView(mListView, KOPrefs::instance()->mFullViewTodo);
349 //mFlagShowNextxDays = temp; 349 //mFlagShowNextxDays = temp;
350} 350}
351 351
352void KOViewManager::showAgendaView( bool fullScreen ) 352void KOViewManager::showAgendaView( bool fullScreen )
353{ 353{
354 354
355 mMainView->dialogManager()->hideSearchDialog(); 355 mMainView->dialogManager()->hideSearchDialog();
356 // qDebug("KOViewManager::showAgendaView "); 356 // qDebug("KOViewManager::showAgendaView ");
357 bool full; 357 bool full;
358 full = fullScreen; 358 full = fullScreen;
359 if (!mAgendaView) { 359 if (!mAgendaView) {
360 full = false; 360 full = false;
361 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 361 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
362 addView(mAgendaView); 362 addView(mAgendaView);
363#ifndef DESKTOP_VERSION 363#ifndef DESKTOP_VERSION
364 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 364 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
365#endif 365#endif
366 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 366 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
367 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 367 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
368 368
369 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 369 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
370 370
371 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 371 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
372 372
373 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 373 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
374 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 374 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
375 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 375 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
376 mMainView, SLOT(newEvent(QDateTime))); 376 mMainView, SLOT(newEvent(QDateTime)));
377 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 377 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
378 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 378 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
379 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 379 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
380 mMainView, SLOT(newEvent(QDate))); 380 mMainView, SLOT(newEvent(QDate)));
381 381
382 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 382 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
383 mMainView, SLOT(editIncidence(Incidence *))); 383 mMainView, SLOT(editIncidence(Incidence *)));
384 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 384 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
385 mMainView, SLOT(showIncidence(Incidence *))); 385 mMainView, SLOT(showIncidence(Incidence *)));
386 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 386 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
387 mMainView, SLOT(deleteIncidence(Incidence *))); 387 mMainView, SLOT(deleteIncidence(Incidence *)));
388 388
389 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 389 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
390 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 390 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
391 391
392 connect(mAgendaView, SIGNAL( toggleExpand() ), 392 connect(mAgendaView, SIGNAL( toggleExpand() ),
393 mMainView, SLOT( toggleExpand() ) ); 393 mMainView, SLOT( toggleExpand() ) );
394 394
395 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 395 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
396 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 396 mAgendaView, SLOT( setExpandedButton( bool ) ) );
397 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 397 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
398 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 398 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
399 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 399 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
400 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 400 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
401 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 401 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
402 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 402 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
403 SLOT( updateTodo( Todo *, int ) ) ); 403 SLOT( updateTodo( Todo *, int ) ) );
404 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 404 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
405 mMainView, SIGNAL( todoModified( Todo *, int ))); 405 mMainView, SIGNAL( todoModified( Todo *, int )));
406 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 406 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
407 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 407 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
408 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 408 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
409 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 409 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
410 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
411 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
410 mAgendaView->readSettings(); 412 mAgendaView->readSettings();
411 mAgendaView->updateConfig(); 413 mAgendaView->updateConfig();
412 } 414 }
413 415
414 showView( mAgendaView, full); 416 showView( mAgendaView, full);
415 417
416} 418}
417 419
418void KOViewManager::showDayView() 420void KOViewManager::showDayView()
419{ 421{
420 mFlagShowNextxDays = false; 422 mFlagShowNextxDays = false;
421 globalFlagBlockLabel = 1; 423 globalFlagBlockLabel = 1;
422 globalFlagBlockAgenda = 1; 424 globalFlagBlockAgenda = 1;
423 if ( mCurrentAgendaView != 1 ) 425 if ( mCurrentAgendaView != 1 )
424 mCurrentAgendaView = -1; 426 mCurrentAgendaView = -1;
425 showAgendaView(); 427 showAgendaView();
426 qApp->processEvents(); 428 qApp->processEvents();
427 globalFlagBlockAgenda = 2; 429 globalFlagBlockAgenda = 2;
428 globalFlagBlockLabel = 0; 430 globalFlagBlockLabel = 0;
429 mMainView->dateNavigator()->selectDates( 1 ); 431 mMainView->dateNavigator()->selectDates( 1 );
430 mCurrentAgendaView = 1 ; 432 mCurrentAgendaView = 1 ;
431 433
432} 434}
433 435
434void KOViewManager::showWorkWeekView() 436void KOViewManager::showWorkWeekView()
435{ 437{
436 mFlagShowNextxDays = false; 438 mFlagShowNextxDays = false;
437 globalFlagBlockAgenda = 1; 439 globalFlagBlockAgenda = 1;
438 globalFlagBlockLabel = 1; 440 globalFlagBlockLabel = 1;
439 if ( mCurrentAgendaView != 5 ) 441 if ( mCurrentAgendaView != 5 )
440 mCurrentAgendaView = -1; 442 mCurrentAgendaView = -1;
441 showAgendaView(); 443 showAgendaView();
442 qApp->processEvents(); 444 qApp->processEvents();
443 globalFlagBlockAgenda = 2; 445 globalFlagBlockAgenda = 2;
444 globalFlagBlockLabel = 0; 446 globalFlagBlockLabel = 0;
445 mMainView->dateNavigator()->selectWorkWeek(); 447 mMainView->dateNavigator()->selectWorkWeek();
446 mCurrentAgendaView = 5 ; 448 mCurrentAgendaView = 5 ;
447 449
448} 450}
449 451
450void KOViewManager::showWeekView() 452void KOViewManager::showWeekView()
451{ 453{
452 /* 454 /*
453 globalFlagBlockAgenda = 2; 455 globalFlagBlockAgenda = 2;
454 qDebug("4globalFlagBlockAgenda = 2; "); 456 qDebug("4globalFlagBlockAgenda = 2; ");
455 //globalFlagBlockPainting = true; 457 //globalFlagBlockPainting = true;
456 mMainView->dateNavigator()->selectWeek(); 458 mMainView->dateNavigator()->selectWeek();
457 showAgendaView(); 459 showAgendaView();
458 */ 460 */
459 461
460 462
461 mFlagShowNextxDays = false; 463 mFlagShowNextxDays = false;
462 globalFlagBlockAgenda = 1; 464 globalFlagBlockAgenda = 1;
463 globalFlagBlockLabel = 1; 465 globalFlagBlockLabel = 1;
464 if ( mCurrentAgendaView != 7 ) 466 if ( mCurrentAgendaView != 7 )
465 mCurrentAgendaView = -1; 467 mCurrentAgendaView = -1;
466 showAgendaView(); 468 showAgendaView();
467 qApp->processEvents(); 469 qApp->processEvents();
468 globalFlagBlockAgenda = 2; 470 globalFlagBlockAgenda = 2;
469 globalFlagBlockLabel = 0; 471 globalFlagBlockLabel = 0;
470 mMainView->dateNavigator()->selectWeek(); 472 mMainView->dateNavigator()->selectWeek();
471 mCurrentAgendaView = 7 ; 473 mCurrentAgendaView = 7 ;
472} 474}
473 475
474void KOViewManager::showNextXView() 476void KOViewManager::showNextXView()
475{ 477{
476 478
477 globalFlagBlockAgenda = 1; 479 globalFlagBlockAgenda = 1;
478 if ( mCurrentAgendaView != 3 ) 480 if ( mCurrentAgendaView != 3 )
479 mCurrentAgendaView = -1; 481 mCurrentAgendaView = -1;
480 showAgendaView(KOPrefs::instance()->mFullViewMonth); 482 showAgendaView(KOPrefs::instance()->mFullViewMonth);
481 globalFlagBlockAgenda = 2; 483 globalFlagBlockAgenda = 2;
482 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 484 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
483 KOPrefs::instance()->mNextXDays ); 485 KOPrefs::instance()->mNextXDays );
484 mFlagShowNextxDays = true; 486 mFlagShowNextxDays = true;
485 mCurrentAgendaView = 3 ; 487 mCurrentAgendaView = 3 ;
486} 488}
487bool KOViewManager::showsNextDays() 489bool KOViewManager::showsNextDays()
488{ 490{
489 return mFlagShowNextxDays; 491 return mFlagShowNextxDays;
490} 492}
491void KOViewManager::showMonthView() 493void KOViewManager::showMonthView()
492{ 494{
493 if (!mMonthView) { 495 if (!mMonthView) {
494 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 496 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
495 497
496 addView(mMonthView); 498 addView(mMonthView);
497 // mMonthView->show(); 499 // mMonthView->show();
498 // SIGNALS/SLOTS FOR MONTH VIEW 500 // SIGNALS/SLOTS FOR MONTH VIEW
499 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 501 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
500 mMainView, SLOT(newEvent(QDateTime))); 502 mMainView, SLOT(newEvent(QDateTime)));
501 503
502 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 504 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
503 mMainView, SLOT(showIncidence(Incidence *))); 505 mMainView, SLOT(showIncidence(Incidence *)));
504 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 506 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
505 mMainView, SLOT(editIncidence(Incidence *))); 507 mMainView, SLOT(editIncidence(Incidence *)));
506 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 508 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
507 mMainView, SLOT(deleteIncidence(Incidence *))); 509 mMainView, SLOT(deleteIncidence(Incidence *)));
508 510
509 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 511 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
510 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 512 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
511 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 513 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
512 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 514 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
513 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 515 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
514 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 516 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
515 517
516 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 518 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
517 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 519 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
518 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 520 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
519 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 521 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
520 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 522 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
521 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 523 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
522 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 524 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
523 mMainView, SLOT ( showDay( QDate ) ) ); 525 mMainView, SLOT ( showDay( QDate ) ) );
524 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 526 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
525 connect( mMonthView, SIGNAL(nextMonth() ), 527 connect( mMonthView, SIGNAL(nextMonth() ),
526 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); 528 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) );
527 connect( mMonthView, SIGNAL(prevMonth() ), 529 connect( mMonthView, SIGNAL(prevMonth() ),
528 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 530 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) );
529 connect( mMonthView, SIGNAL( showNavigator(bool) ), 531 connect( mMonthView, SIGNAL( showNavigator(bool) ),
530 mMainView, SLOT ( showNavigatorBar(bool) ) ); 532 mMainView, SLOT ( showNavigatorBar(bool) ) );
531 } 533 }
532 534
533 globalFlagBlockAgenda = 1; 535 globalFlagBlockAgenda = 1;
534 //mFlagShowNextxDays = false; 536 //mFlagShowNextxDays = false;
535 // if(mMonthView == mCurrentView) return; 537 // if(mMonthView == mCurrentView) return;
536 if ( KOPrefs::instance()->mMonthViewWeek ) 538 if ( KOPrefs::instance()->mMonthViewWeek )
537 mMainView->dateNavigator()->selectWeek(); 539 mMainView->dateNavigator()->selectWeek();
538 else 540 else
539 mMainView->dateNavigator()->selectMonth(); 541 mMainView->dateNavigator()->selectMonth();
540 542
541 showView(mMonthView, true ); 543 showView(mMonthView, true );
542 544
543} 545}
544 546
545void KOViewManager::showTodoView() 547void KOViewManager::showTodoView()
546{ 548{
547 //mFlagShowNextxDays = false; 549 //mFlagShowNextxDays = false;
548 if ( !mTodoView ) { 550 if ( !mTodoView ) {
549 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 551 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
550 "KOViewManager::TodoView" ); 552 "KOViewManager::TodoView" );
551 553
552 addView( mTodoView ); 554 addView( mTodoView );
553 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 555 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
554 556
555 // SIGNALS/SLOTS FOR TODO VIEW 557 // SIGNALS/SLOTS FOR TODO VIEW
556 connect( mTodoView, SIGNAL( newTodoSignal() ), 558 connect( mTodoView, SIGNAL( newTodoSignal() ),
557 mMainView, SLOT( newTodo() ) ); 559 mMainView, SLOT( newTodo() ) );
558 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 560 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
559 mMainView, SLOT( newSubTodo( Todo *) ) ); 561 mMainView, SLOT( newSubTodo( Todo *) ) );
560 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 562 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
561 mMainView, SLOT( showTodo( Todo * ) ) ); 563 mMainView, SLOT( showTodo( Todo * ) ) );
562 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 564 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
563 mMainView, SLOT( editTodo( Todo * ) ) ); 565 mMainView, SLOT( editTodo( Todo * ) ) );
564 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 566 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
565 mMainView, SLOT( deleteTodo( Todo * ) ) ); 567 mMainView, SLOT( deleteTodo( Todo * ) ) );
566 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 568 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
567 mMainView, SLOT( purgeCompleted() ) ); 569 mMainView, SLOT( purgeCompleted() ) );
568 570
569 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 571 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
570 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 572 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
571 573
572 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 574 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
573 SLOT( updateConfig() ) ); 575 SLOT( updateConfig() ) );
574 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 576 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
575 SLOT( updateTodo( Todo *, int ) ) ); 577 SLOT( updateTodo( Todo *, int ) ) );
576 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 578 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
577 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 579 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
578 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 580 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
579 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 581 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
580 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 582 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
581 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 583 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
582 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 584 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
583 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 585 mMainView, SLOT ( todo_unsub( Todo * ) ) );
584 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 586 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
585 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 587 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
586 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 588 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
587 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 589 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
588 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 590 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
589 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 591 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
590 KConfig *config = KOGlobals::config(); 592 KConfig *config = KOGlobals::config();
591 mTodoView->restoreLayout(config,"Todo View"); 593 mTodoView->restoreLayout(config,"Todo View");
592 mTodoView->setNavigator( mMainView->dateNavigator() ); 594 mTodoView->setNavigator( mMainView->dateNavigator() );
593 } 595 }
594 596
595 globalFlagBlockAgenda = 1; 597 globalFlagBlockAgenda = 1;
596 showView( mTodoView, true ); 598 showView( mTodoView, true );
597 599
598} 600}
599 601
600void KOViewManager::showJournalView() 602void KOViewManager::showJournalView()
601{ 603{
602 //mFlagShowNextxDays = false; 604 //mFlagShowNextxDays = false;
603 if (!mJournalView) { 605 if (!mJournalView) {
604 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 606 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
605 "KOViewManager::JournalView"); 607 "KOViewManager::JournalView");
606 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 608 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
607 SLOT( updateConfig() ) ); 609 SLOT( updateConfig() ) );
608 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 610 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
609 addView(mJournalView); 611 addView(mJournalView);
610 } 612 }
611 613
612 showView(mJournalView); 614 showView(mJournalView);
613 mMainView->dateNavigator()->selectDates( 1 ); 615 mMainView->dateNavigator()->selectDates( 1 );
614} 616}
615 617
616void KOViewManager::showTimeSpanView() 618void KOViewManager::showTimeSpanView()
617{ 619{
618 //mFlagShowNextxDays = false; 620 //mFlagShowNextxDays = false;
619 if (!mTimeSpanView) { 621 if (!mTimeSpanView) {
620 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 622 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
621 "KOViewManager::TimeSpanView"); 623 "KOViewManager::TimeSpanView");
622 addView(mTimeSpanView); 624 addView(mTimeSpanView);
623 625
624 mTimeSpanView->readSettings(); 626 mTimeSpanView->readSettings();
625 } 627 }
626 628
627 showView(mTimeSpanView); 629 showView(mTimeSpanView);
628} 630}
629 631
630Incidence *KOViewManager::currentSelection() 632Incidence *KOViewManager::currentSelection()
631{ 633{
632 if (!mCurrentView) return 0; 634 if (!mCurrentView) return 0;
633 if ( mCurrentView == mListView ) { 635 if ( mCurrentView == mListView ) {
634 if ( mListView->currentItem() ) 636 if ( mListView->currentItem() )
635 return mListView->currentItem(); 637 return mListView->currentItem();
636 } 638 }
637 return mCurrentView->selectedIncidences().first(); 639 return mCurrentView->selectedIncidences().first();
638} 640}
639 641
640QDate KOViewManager::currentSelectionDate() 642QDate KOViewManager::currentSelectionDate()
641{ 643{
642 QDate qd; 644 QDate qd;
643 if (mCurrentView) { 645 if (mCurrentView) {
644 DateList qvl = mCurrentView->selectedDates(); 646 DateList qvl = mCurrentView->selectedDates();
645 if (!qvl.isEmpty()) qd = qvl.first(); 647 if (!qvl.isEmpty()) qd = qvl.first();
646 } 648 }
647 return qd; 649 return qd;
648} 650}
649 651
650void KOViewManager::addView(KOrg::BaseView *view) 652void KOViewManager::addView(KOrg::BaseView *view)
651{ 653{
652#if QT_VERSION >= 0x030000 654#if QT_VERSION >= 0x030000
653 mMainView->viewStack()->addWidget( view ); 655 mMainView->viewStack()->addWidget( view );
654#else 656#else
655 mMainView->viewStack()->addWidget( view, 1 ); 657 mMainView->viewStack()->addWidget( view, 1 );
656#endif 658#endif
657} 659}
658 660
659void KOViewManager::setDocumentId( const QString &id ) 661void KOViewManager::setDocumentId( const QString &id )
660{ 662{
661 if (mTodoView) mTodoView->setDocumentId( id ); 663 if (mTodoView) mTodoView->setDocumentId( id );
662} 664}