summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp44
-rw-r--r--korganizer/koagendaview.h3
-rw-r--r--korganizer/koviewmanager.cpp9
3 files changed, 47 insertions, 9 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 8e9add3..d43712f 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -228,951 +228,981 @@ void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
228 int diff = mMouseDownY - e->pos().y(); 228 int diff = mMouseDownY - e->pos().y();
229 if ( diff < 10 && diff > -10 ) 229 if ( diff < 10 && diff > -10 )
230 return; 230 return;
231 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 231 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
232 if ( tSize < 4 ) 232 if ( tSize < 4 )
233 tSize = 4; 233 tSize = 4;
234 if ( tSize > 22 ) 234 if ( tSize > 22 )
235 tSize = 22; 235 tSize = 22;
236 tSize = (tSize/2)*2; 236 tSize = (tSize/2)*2;
237 if ( tSize == KOPrefs::instance()->mHourSize ) 237 if ( tSize == KOPrefs::instance()->mHourSize )
238 return; 238 return;
239 KOPrefs::instance()->mHourSize = tSize; 239 KOPrefs::instance()->mHourSize = tSize;
240 emit scaleChanged(); 240 emit scaleChanged();
241} 241}
242 242
243/** This is called in response to repaint() */ 243/** This is called in response to repaint() */
244void TimeLabels::paintEvent(QPaintEvent*) 244void TimeLabels::paintEvent(QPaintEvent*)
245{ 245{
246 246
247 // kdDebug() << "paintevent..." << endl; 247 // kdDebug() << "paintevent..." << endl;
248 // this is another hack! 248 // this is another hack!
249 // QPainter painter(this); 249 // QPainter painter(this);
250 //QString c 250 //QString c
251 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 251 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
252} 252}
253 253
254//////////////////////////////////////////////////////////////////////////// 254////////////////////////////////////////////////////////////////////////////
255 255
256EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 256EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
257 : QFrame(parent,name) 257 : QFrame(parent,name)
258{ 258{
259 mColumns = 1; 259 mColumns = 1;
260 mTopBox = 0; 260 mTopBox = 0;
261 mLocation = loc; 261 mLocation = loc;
262 mTopLayout = 0; 262 mTopLayout = 0;
263 mPaintWidget = 0; 263 mPaintWidget = 0;
264 mXOffset = 0; 264 mXOffset = 0;
265 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 265 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
266 else mPixmap = SmallIcon("1downarrow"); 266 else mPixmap = SmallIcon("1downarrow");
267 mEnabled.resize(mColumns); 267 mEnabled.resize(mColumns);
268 if (mLocation == Top) 268 if (mLocation == Top)
269 setMaximumHeight(0); 269 setMaximumHeight(0);
270 else 270 else
271 setMinimumHeight(mPixmap.height()); 271 setMinimumHeight(mPixmap.height());
272} 272}
273 273
274EventIndicator::~EventIndicator() 274EventIndicator::~EventIndicator()
275{ 275{
276} 276}
277 277
278void EventIndicator::drawContents(QPainter *p) 278void EventIndicator::drawContents(QPainter *p)
279{ 279{
280 280
281 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 281 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
282 KDGanttSplitterHandle* han = 0; 282 KDGanttSplitterHandle* han = 0;
283 if ( mPaintWidget ) 283 if ( mPaintWidget )
284 han = mPaintWidget->firstHandle(); 284 han = mPaintWidget->firstHandle();
285 if ( ! han ) { 285 if ( ! han ) {
286 int i; 286 int i;
287 for(i=0;i<mColumns;++i) { 287 for(i=0;i<mColumns;++i) {
288 if (mEnabled[i]) { 288 if (mEnabled[i]) {
289 int cellWidth = contentsRect().right()/mColumns; 289 int cellWidth = contentsRect().right()/mColumns;
290 int xOffset = KOGlobals::self()->reverseLayout() ? 290 int xOffset = KOGlobals::self()->reverseLayout() ?
291 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 291 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
292 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 292 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
293 p->drawPixmap(QPoint(xOffset,0),mPixmap); 293 p->drawPixmap(QPoint(xOffset,0),mPixmap);
294 } 294 }
295 } 295 }
296 } else { 296 } else {
297 han->repaint(); 297 han->repaint();
298 //mPaintWidget->setBackgroundColor( red ); 298 //mPaintWidget->setBackgroundColor( red );
299 299
300 QPainter pa( han ); 300 QPainter pa( han );
301 int i; 301 int i;
302 bool setColor = false; 302 bool setColor = false;
303 for(i=0;i<mColumns;++i) { 303 for(i=0;i<mColumns;++i) {
304 if (mEnabled[i]) { 304 if (mEnabled[i]) {
305 setColor = true; 305 setColor = true;
306 306
307 int cellWidth = contentsRect().right()/mColumns; 307 int cellWidth = contentsRect().right()/mColumns;
308 int xOffset = KOGlobals::self()->reverseLayout() ? 308 int xOffset = KOGlobals::self()->reverseLayout() ?
309 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 309 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
310 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 310 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
311 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 311 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
312 //qDebug("222draw pix %d ",xOffset ); 312 //qDebug("222draw pix %d ",xOffset );
313 313
314 } 314 }
315 315
316 } 316 }
317 pa.end(); 317 pa.end();
318 318
319 } 319 }
320} 320}
321 321
322void EventIndicator::setXOffset( int x ) 322void EventIndicator::setXOffset( int x )
323{ 323{
324 mXOffset = x; 324 mXOffset = x;
325} 325}
326void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 326void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
327{ 327{
328 mPaintWidget = w; 328 mPaintWidget = w;
329} 329}
330void EventIndicator::changeColumns(int columns) 330void EventIndicator::changeColumns(int columns)
331{ 331{
332 mColumns = columns; 332 mColumns = columns;
333 mEnabled.resize(mColumns); 333 mEnabled.resize(mColumns);
334 334
335 update(); 335 update();
336} 336}
337 337
338void EventIndicator::enableColumn(int column, bool enable) 338void EventIndicator::enableColumn(int column, bool enable)
339{ 339{
340 mEnabled[column] = enable; 340 mEnabled[column] = enable;
341} 341}
342 342
343 343
344//////////////////////////////////////////////////////////////////////////// 344////////////////////////////////////////////////////////////////////////////
345//////////////////////////////////////////////////////////////////////////// 345////////////////////////////////////////////////////////////////////////////
346//////////////////////////////////////////////////////////////////////////// 346////////////////////////////////////////////////////////////////////////////
347 347
348KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 348KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
349 KOEventView (cal,parent,name) 349 KOEventView (cal,parent,name)
350{ 350{
351 mBlockUpdating = true; 351 mBlockUpdating = true;
352 mStartHour = 8; 352 mStartHour = 8;
353 mSelectedDates.append(QDate::currentDate()); 353 mSelectedDates.append(QDate::currentDate());
354 354
355 mLayoutDayLabels = 0; 355 mLayoutDayLabels = 0;
356 mDayLabelsFrame = 0; 356 mDayLabelsFrame = 0;
357 mDayLabels = 0; 357 mDayLabels = 0;
358 bool isRTL = KOGlobals::self()->reverseLayout(); 358 bool isRTL = KOGlobals::self()->reverseLayout();
359 359
360 if ( KOPrefs::instance()->mVerticalScreen ) { 360 if ( KOPrefs::instance()->mVerticalScreen ) {
361 mExpandedPixmap = SmallIcon( "1downarrow" ); 361 mExpandedPixmap = SmallIcon( "1downarrow" );
362 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 362 mNotExpandedPixmap = SmallIcon( "1uparrow" );
363 } else { 363 } else {
364 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 364 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
365 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 365 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
366 } 366 }
367 367
368 QBoxLayout *topLayout = new QVBoxLayout(this); 368 QBoxLayout *topLayout = new QVBoxLayout(this);
369 369
370 // Create day name labels for agenda columns 370 // Create day name labels for agenda columns
371 mDayLabelsFrame = new QHBox(this); 371 mDayLabelsFrame = new QHBox(this);
372 topLayout->addWidget(mDayLabelsFrame); 372 topLayout->addWidget(mDayLabelsFrame);
373 mDayLabels = new QFrame (mDayLabelsFrame); 373 mDayLabels = new QFrame (mDayLabelsFrame);
374 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 374 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
375 // Create agenda splitter 375 // Create agenda splitter
376#ifndef KORG_NOSPLITTER 376#ifndef KORG_NOSPLITTER
377 mSplitterAgenda = new QSplitter(Vertical,this); 377 mSplitterAgenda = new QSplitter(Vertical,this);
378 topLayout->addWidget(mSplitterAgenda); 378 topLayout->addWidget(mSplitterAgenda);
379 mSplitterAgenda->setOpaqueResize(); 379 mSplitterAgenda->setOpaqueResize();
380 380
381 mAllDayFrame = new QHBox(mSplitterAgenda); 381 mAllDayFrame = new QHBox(mSplitterAgenda);
382 382
383 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 383 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
384#else 384#else
385#if 0 385#if 0
386 QWidget *mainBox = new QWidget( this ); 386 QWidget *mainBox = new QWidget( this );
387 topLayout->addWidget( mainBox ); 387 topLayout->addWidget( mainBox );
388 QBoxLayout *mainLayout = new QVBoxLayout(mainBox); 388 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
389 mAllDayFrame = new QHBox(mainBox); 389 mAllDayFrame = new QHBox(mainBox);
390 mainLayout->addWidget(mAllDayFrame); 390 mainLayout->addWidget(mAllDayFrame);
391 mainLayout->setStretchFactor( mAllDayFrame, 0 ); 391 mainLayout->setStretchFactor( mAllDayFrame, 0 );
392 mAllDayFrame->setFocusPolicy(NoFocus); 392 mAllDayFrame->setFocusPolicy(NoFocus);
393 QWidget *agendaFrame = new QWidget(mainBox); 393 QWidget *agendaFrame = new QWidget(mainBox);
394 mainLayout->addWidget(agendaFrame); 394 mainLayout->addWidget(agendaFrame);
395 mainLayout->setStretchFactor( agendaFrame, 10 ); 395 mainLayout->setStretchFactor( agendaFrame, 10 );
396 396
397 agendaFrame->setFocusPolicy(NoFocus); 397 agendaFrame->setFocusPolicy(NoFocus);
398#endif 398#endif
399 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 399 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
400 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 400 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
401 topLayout->addWidget( mSplitterAgenda ); 401 topLayout->addWidget( mSplitterAgenda );
402 mAllDayFrame = new QHBox(mSplitterAgenda); 402 mAllDayFrame = new QHBox(mSplitterAgenda);
403 mAllDayFrame->setFocusPolicy(NoFocus); 403 mAllDayFrame->setFocusPolicy(NoFocus);
404 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 404 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
405 agendaFrame->setFocusPolicy(NoFocus); 405 agendaFrame->setFocusPolicy(NoFocus);
406 406
407#endif 407#endif
408 408
409 // Create all-day agenda widget 409 // Create all-day agenda widget
410 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 410 mDummyAllDayLeft = new QVBox( mAllDayFrame );
411 411
412 mExpandButton = new QPushButton(mDummyAllDayLeft); 412 mExpandButton = new QPushButton(mDummyAllDayLeft);
413 mExpandButton->setPixmap( mNotExpandedPixmap ); 413 mExpandButton->setPixmap( mNotExpandedPixmap );
414 int widebut = mExpandButton->sizeHint().width(); 414 int widebut = mExpandButton->sizeHint().width();
415 if ( QApplication::desktop()->width() < 480 ) 415 if ( QApplication::desktop()->width() < 480 )
416 widebut = widebut*2; 416 widebut = widebut*2;
417 else 417 else
418 widebut = (widebut*3) / 2; 418 widebut = (widebut*3) / 2;
419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 419 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
420 // QSizePolicy::Fixed ) ); 420 // QSizePolicy::Fixed ) );
421 mExpandButton->setFixedSize( widebut, widebut); 421 mExpandButton->setFixedSize( widebut, widebut);
422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 422 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
423 mExpandButton->setFocusPolicy(NoFocus); 423 mExpandButton->setFocusPolicy(NoFocus);
424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 424 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
425 mAllDayAgenda->setFocusPolicy(NoFocus); 425 mAllDayAgenda->setFocusPolicy(NoFocus);
426 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); 426 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame);
427 427
428 // Create event context menu for all day agenda 428 // Create event context menu for all day agenda
429 mAllDayAgendaPopup = eventPopup(); 429 mAllDayAgendaPopup = eventPopup();
430 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 430 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
431 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 431 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
432 432
433 // Create agenda frame 433 // Create agenda frame
434 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 434 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
435 // QHBox *agendaFrame = new QHBox(splitterAgenda); 435 // QHBox *agendaFrame = new QHBox(splitterAgenda);
436 436
437 // create event indicator bars 437 // create event indicator bars
438 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 438 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
439 agendaLayout->addWidget(mEventIndicatorTop,0,1); 439 agendaLayout->addWidget(mEventIndicatorTop,0,1);
440 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 440 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
441 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 441 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
442 agendaFrame); 442 agendaFrame);
443 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 443 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
444 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 444 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
445 agendaLayout->addWidget(dummyAgendaRight,0,2); 445 agendaLayout->addWidget(dummyAgendaRight,0,2);
446 446
447 // Create time labels 447 // Create time labels
448 mTimeLabels = new TimeLabels(24,agendaFrame); 448 mTimeLabels = new TimeLabels(24,agendaFrame);
449 agendaLayout->addWidget(mTimeLabels,1,0); 449 agendaLayout->addWidget(mTimeLabels,1,0);
450 connect(mTimeLabels,SIGNAL( scaleChanged()), 450 connect(mTimeLabels,SIGNAL( scaleChanged()),
451 this,SLOT(updateConfig())); 451 this,SLOT(updateConfig()));
452 452
453 // Create agenda 453 // Create agenda
454 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 454 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
455 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 455 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
456 agendaLayout->setColStretch(1,1); 456 agendaLayout->setColStretch(1,1);
457 mAgenda->setFocusPolicy(NoFocus); 457 mAgenda->setFocusPolicy(NoFocus);
458 // Create event context menu for agenda 458 // Create event context menu for agenda
459 mAgendaPopup = eventPopup(); 459 mAgendaPopup = eventPopup();
460 460
461 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 461 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
462 i18n("Toggle Alarm"),mAgenda, 462 i18n("Toggle Alarm"),mAgenda,
463 SLOT(popupAlarm()),true); 463 SLOT(popupAlarm()),true);
464 464
465 465
466 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 466 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
467 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 467 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
468 468
469 // make connections between dependent widgets 469 // make connections between dependent widgets
470 mTimeLabels->setAgenda(mAgenda); 470 mTimeLabels->setAgenda(mAgenda);
471 471
472 // Update widgets to reflect user preferences 472 // Update widgets to reflect user preferences
473 // updateConfig(); 473 // updateConfig();
474 474
475 // createDayLabels(); 475 // createDayLabels();
476 476
477 // these blank widgets make the All Day Event box line up with the agenda 477 // these blank widgets make the All Day Event box line up with the agenda
478 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 478 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
479 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 479 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
480 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 480 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
481 481
482 // Scrolling 482 // Scrolling
483 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 483 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
484 mTimeLabels, SLOT(positionChanged())); 484 mTimeLabels, SLOT(positionChanged()));
485 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 485 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
486 SLOT(setContentsPos(int))); 486 SLOT(setContentsPos(int)));
487 487
488 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 488 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
489 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 489 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate )));
490 490
491 // Create/Show/Edit/Delete Event 491 // Create/Show/Edit/Delete Event
492 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 492 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
493 SLOT(newEvent(int,int))); 493 SLOT(newEvent(int,int)));
494 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 494 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
495 SLOT(newTodo(int,int))); 495 SLOT(newTodo(int,int)));
496 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 496 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
497 SLOT(newEvent(int,int,int,int))); 497 SLOT(newEvent(int,int,int,int)));
498 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 498 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
499 SLOT(newEventAllDay(int,int))); 499 SLOT(newEventAllDay(int,int)));
500 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 500 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
501 SLOT(newTodoAllDay(int,int))); 501 SLOT(newTodoAllDay(int,int)));
502 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 502 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
503 SLOT(newEventAllDay(int,int))); 503 SLOT(newEventAllDay(int,int)));
504 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 504 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
505 SLOT(newTimeSpanSelected(int,int,int,int))); 505 SLOT(newTimeSpanSelected(int,int,int,int)));
506 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 506 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
507 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 507 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
508 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 508 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
509 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 509 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
510 510
511 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 511 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
512 SIGNAL(editIncidenceSignal(Incidence *))); 512 SIGNAL(editIncidenceSignal(Incidence *)));
513 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 513 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
514 SIGNAL(editIncidenceSignal(Incidence *))); 514 SIGNAL(editIncidenceSignal(Incidence *)));
515 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 515 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
516 SIGNAL(showIncidenceSignal(Incidence *))); 516 SIGNAL(showIncidenceSignal(Incidence *)));
517 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 517 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
518 SIGNAL(showIncidenceSignal(Incidence *))); 518 SIGNAL(showIncidenceSignal(Incidence *)));
519 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 519 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
520 SIGNAL(deleteIncidenceSignal(Incidence *))); 520 SIGNAL(deleteIncidenceSignal(Incidence *)));
521 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 521 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
522 SIGNAL(deleteIncidenceSignal(Incidence *))); 522 SIGNAL(deleteIncidenceSignal(Incidence *)));
523 523
524 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 524 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
525 SLOT(updateEventDates(KOAgendaItem *, int ))); 525 SLOT(updateEventDates(KOAgendaItem *, int )));
526 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 526 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
527 SLOT(updateEventDates(KOAgendaItem *, int))); 527 SLOT(updateEventDates(KOAgendaItem *, int)));
528 528
529 // event indicator update 529 // event indicator update
530 connect(mAgenda,SIGNAL(lowerYChanged(int)), 530 connect(mAgenda,SIGNAL(lowerYChanged(int)),
531 SLOT(updateEventIndicatorTop(int))); 531 SLOT(updateEventIndicatorTop(int)));
532 connect(mAgenda,SIGNAL(upperYChanged(int)), 532 connect(mAgenda,SIGNAL(upperYChanged(int)),
533 SLOT(updateEventIndicatorBottom(int))); 533 SLOT(updateEventIndicatorBottom(int)));
534 // drag signals 534 // drag signals
535 /* 535 /*
536 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 536 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
537 SLOT(startDrag(Event *))); 537 SLOT(startDrag(Event *)));
538 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 538 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
539 SLOT(startDrag(Event *))); 539 SLOT(startDrag(Event *)));
540 */ 540 */
541 // synchronize selections 541 // synchronize selections
542 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 542 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
543 mAllDayAgenda, SLOT( deselectItem() ) ); 543 mAllDayAgenda, SLOT( deselectItem() ) );
544 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 544 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
545 mAgenda, SLOT( deselectItem() ) ); 545 mAgenda, SLOT( deselectItem() ) );
546 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 546 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
547 SIGNAL( incidenceSelected( Incidence * ) ) ); 547 SIGNAL( incidenceSelected( Incidence * ) ) );
548 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 548 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
549 SIGNAL( incidenceSelected( Incidence * ) ) ); 549 SIGNAL( incidenceSelected( Incidence * ) ) );
550 connect( mAgenda, SIGNAL( resizedSignal() ), 550 connect( mAgenda, SIGNAL( resizedSignal() ),
551 SLOT( updateConfig( ) ) ); 551 SLOT( updateConfig( ) ) );
552 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 552 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
553 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 553 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
554 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 554 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
555 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 555 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
556 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 556 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
557 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 557 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
558 558
559 559
560} 560}
561 561
562void KOAgendaView::toggleAllDay() 562void KOAgendaView::toggleAllDay()
563{ 563{
564 if ( mSplitterAgenda->firstHandle() ) 564 if ( mSplitterAgenda->firstHandle() )
565 mSplitterAgenda->firstHandle()->toggle(); 565 mSplitterAgenda->firstHandle()->toggle();
566} 566}
567void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 567void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
568{ 568{
569 calendar()->addIncidence( inc ); 569 calendar()->addIncidence( inc );
570 570
571 if ( incOld ) { 571 if ( incOld ) {
572 if ( incOld->type() == "Todo" ) 572 if ( incOld->type() == "Todo" )
573 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 573 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
574 else 574 else
575 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 575 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
576 } 576 }
577 577
578} 578}
579 579
580KOAgendaView::~KOAgendaView() 580KOAgendaView::~KOAgendaView()
581{ 581{
582 delete mAgendaPopup; 582 delete mAgendaPopup;
583 delete mAllDayAgendaPopup; 583 delete mAllDayAgendaPopup;
584 delete KOAgendaItem::paintPix(); 584 delete KOAgendaItem::paintPix();
585 delete KOAgendaItem::paintPixSel(); 585 delete KOAgendaItem::paintPixSel();
586} 586}
587void KOAgendaView::resizeEvent( QResizeEvent* e ) 587void KOAgendaView::resizeEvent( QResizeEvent* e )
588{ 588{
589 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 589 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
590 bool uc = false; 590 bool uc = false;
591 int ow = e->oldSize().width(); 591 int ow = e->oldSize().width();
592 int oh = e->oldSize().height(); 592 int oh = e->oldSize().height();
593 int w = e->size().width(); 593 int w = e->size().width();
594 int h = e->size().height(); 594 int h = e->size().height();
595 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 595 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
596 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 596 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
597 uc = true; 597 uc = true;
598 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 598 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
599 } 599 }
600 mUpcomingWidth = e->size().width() ; 600 mUpcomingWidth = e->size().width() ;
601 if ( mBlockUpdating || uc ) { 601 if ( mBlockUpdating || uc ) {
602 mBlockUpdating = false; 602 mBlockUpdating = false;
603 //mAgenda->setMinimumSize(800 , 600 ); 603 //mAgenda->setMinimumSize(800 , 600 );
604 //qDebug("mAgenda->resize+++++++++++++++ "); 604 //qDebug("mAgenda->resize+++++++++++++++ ");
605 updateConfig(); 605 updateConfig();
606 //qDebug("KOAgendaView::Updating now possible "); 606 //qDebug("KOAgendaView::Updating now possible ");
607 } else 607 } else
608 createDayLabels(); 608 createDayLabels();
609 //qDebug("resizeEvent end "); 609 //qDebug("resizeEvent end ");
610 610
611} 611}
612void KOAgendaView::slotDaylabelClicked()
613{
614 QString cap = ((QPushButton*) sender() )->caption();
615
616 QDate firstDate = mSelectedDates.first();
617 if ( cap == "0" )
618 emit showDateView( 6, firstDate );
619 else if ( cap != "last" ) {
620 if ( mSelectedDates.count() == 1)
621 emit showDateView( 9, firstDate.addDays( cap.toInt()-1 ) );
622 else
623 emit showDateView( 3, firstDate.addDays( cap.toInt()-1 ) );
624 }
625 else
626 showDateView( 10, firstDate.addDays(1 ) );
627}
612void KOAgendaView::createDayLabels() 628void KOAgendaView::createDayLabels()
613{ 629{
614 630
615 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 631 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
616 // qDebug(" KOAgendaView::createDayLabels() blocked "); 632 // qDebug(" KOAgendaView::createDayLabels() blocked ");
617 return; 633 return;
618 634
619 } 635 }
620 int newHight; 636 int newHight;
621 637
622 // ### Before deleting and recreating we could check if mSelectedDates changed... 638 // ### Before deleting and recreating we could check if mSelectedDates changed...
623 // It would remove some flickering and gain speed (since this is called by 639 // It would remove some flickering and gain speed (since this is called by
624 // each updateView() call) 640 // each updateView() call)
625 641
626 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 642 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
627 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 643 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
628 if ( maxWid < 0 ) 644 if ( maxWid < 0 )
629 maxWid = 20; 645 maxWid = 20;
630 646
631 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 647 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
632 QFontMetrics fm ( dlf ); 648 QFontMetrics fm ( dlf );
633 int selCount = mSelectedDates.count(); 649 int selCount = mSelectedDates.count();
634 QString dayTest = "Mon 20"; 650 QString dayTest = "Mon 20";
635 int wid = fm.width( dayTest ); 651 int wid = fm.width( dayTest );
636 maxWid -= ( selCount * 3 ); 652 maxWid -= ( selCount * 3 );
637 if ( maxWid < 0 ) 653 if ( maxWid < 0 )
638 maxWid = 20; 654 maxWid = 20;
639 int needWid = wid * selCount; 655 int needWid = wid * selCount;
640 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 656 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
641 //if ( needWid > maxWid ) 657 //if ( needWid > maxWid )
642 // qDebug("DAYLABELS TOOOOOOO BIG "); 658 // qDebug("DAYLABELS TOOOOOOO BIG ");
643 while ( needWid > maxWid ) { 659 while ( needWid > maxWid ) {
644 dayTest = dayTest.left( dayTest.length() - 1 ); 660 dayTest = dayTest.left( dayTest.length() - 1 );
645 wid = fm.width( dayTest ); 661 wid = fm.width( dayTest );
646 needWid = wid * selCount; 662 needWid = wid * selCount;
647 } 663 }
648 int maxLen = dayTest.length(); 664 int maxLen = dayTest.length();
649 int fontPoint = dlf.pointSize(); 665 int fontPoint = dlf.pointSize();
650 if ( maxLen < 2 ) { 666 if ( maxLen < 2 ) {
651 int fontPoint = dlf.pointSize(); 667 int fontPoint = dlf.pointSize();
652 while ( fontPoint > 4 ) { 668 while ( fontPoint > 4 ) {
653 --fontPoint; 669 --fontPoint;
654 dlf.setPointSize( fontPoint ); 670 dlf.setPointSize( fontPoint );
655 QFontMetrics f( dlf ); 671 QFontMetrics f( dlf );
656 wid = f.width( "20" ); 672 wid = f.width( "20" );
657 needWid = wid * selCount; 673 needWid = wid * selCount;
658 if ( needWid < maxWid ) 674 if ( needWid < maxWid )
659 break; 675 break;
660 } 676 }
661 maxLen = 2; 677 maxLen = 2;
662 } 678 }
663 //qDebug("Max len %d ", dayTest.length() ); 679 //qDebug("Max len %d ", dayTest.length() );
664 680
665 QFontMetrics tempF( dlf ); 681 QFontMetrics tempF( dlf );
666 newHight = tempF.height(); 682 newHight = tempF.height();
667 mDayLabels->setFont( dlf ); 683 mDayLabels->setFont( dlf );
668 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 684 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
669 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 685 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
670 //mLayoutDayLabels->addSpacing( 2 ); 686 //mLayoutDayLabels->addSpacing( 2 );
671 // QFont lFont = dlf; 687 // QFont lFont = dlf;
672 bool appendLabels = false; 688 bool appendLabels = false;
673 QLabel *dayLabel; 689 QPushButton *dayLabel;
674 dayLabel = mDayLabelsList.first(); 690 dayLabel = mDayLabelsList.first();
675 if ( !dayLabel ) { 691 if ( !dayLabel ) {
676 appendLabels = true; 692 appendLabels = true;
677 dayLabel = new QLabel(mDayLabels); 693 dayLabel = new QPushButton(mDayLabels);
694 dayLabel->setFlat( true );
695 connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) );
696 dayLabel->setFocusPolicy(NoFocus);
678 mDayLabelsList.append( dayLabel ); 697 mDayLabelsList.append( dayLabel );
679 mLayoutDayLabels->addWidget(dayLabel); 698 mLayoutDayLabels->addWidget(dayLabel);
680 } 699 }
681 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 700 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
682 dayLabel->setFont( dlf ); 701 dayLabel->setFont( dlf );
683 dayLabel->setAlignment(QLabel::AlignHCenter); 702 dayLabel->setCaption("0");
703 //dayLabel->setAlignment(QLabel::AlignHCenter);
684 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 704 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
685 dayLabel->show(); 705 dayLabel->show();
686 DateList::ConstIterator dit; 706 DateList::ConstIterator dit;
687 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 707 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
708 int counter = 0;
688 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 709 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
710 ++counter;
689 QDate date = *dit; 711 QDate date = *dit;
690 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 712 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
691 if ( ! appendLabels ) { 713 if ( ! appendLabels ) {
692 dayLabel = mDayLabelsList.next(); 714 dayLabel = mDayLabelsList.next();
693 if ( !dayLabel ) 715 if ( !dayLabel )
694 appendLabels = true; 716 appendLabels = true;
695 } 717 }
696 if ( appendLabels ) { 718 if ( appendLabels ) {
697 dayLabel = new QLabel(mDayLabels); 719 dayLabel = new QPushButton(mDayLabels);
720 dayLabel->setFlat( true );
721 connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) );
722 dayLabel->setFocusPolicy(NoFocus);
698 mDayLabelsList.append( dayLabel ); 723 mDayLabelsList.append( dayLabel );
699 mLayoutDayLabels->addWidget(dayLabel); 724 mLayoutDayLabels->addWidget(dayLabel);
700 } 725 }
701 dayLabel->setMinimumWidth( 1 ); 726 dayLabel->setMinimumWidth( 1 );
702 dayLabel->setMaximumWidth( 2048 ); 727 dayLabel->setMaximumWidth( 2048 );
703 dayLabel->setFont( dlf ); 728 dayLabel->setFont( dlf );
704 dayLabel->show(); 729 dayLabel->show();
730 dayLabel->setCaption(QString::number( counter ));
705 QString str; 731 QString str;
706 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 732 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
707 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 733 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
708 switch ( maxLen ) { 734 switch ( maxLen ) {
709 case 2: 735 case 2:
710 str = QString::number( date.day() ); 736 str = QString::number( date.day() );
711 break; 737 break;
712 738
713 case 3: 739 case 3:
714 str = dayName.left( 1 ) +QString::number( date.day()); 740 str = dayName.left( 1 ) +QString::number( date.day());
715 741
716 break; 742 break;
717 case 4: 743 case 4:
718 str = dayName.left( 1 ) + " " +QString::number( date.day()); 744 str = dayName.left( 1 ) + " " +QString::number( date.day());
719 745
720 break; 746 break;
721 case 5: 747 case 5:
722 str = dayName.left( 2 ) + " " +QString::number( date.day()); 748 str = dayName.left( 2 ) + " " +QString::number( date.day());
723 749
724 break; 750 break;
725 case 6: 751 case 6:
726 str = dayName.left( 3 ) + " " +QString::number( date.day()); 752 str = dayName.left( 3 ) + " " +QString::number( date.day());
727 break; 753 break;
728 754
729 default: 755 default:
730 break; 756 break;
731 } 757 }
732 if ( oneday ) { 758 if ( oneday ) {
733 QString addString; 759 QString addString;
734 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 760 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
735 addString = i18n("Today"); 761 addString = i18n("Today");
736 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 762 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
737 addString = i18n("Tomorrow"); 763 addString = i18n("Tomorrow");
738 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 764 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
739 addString = i18n("Yesterday"); 765 addString = i18n("Yesterday");
740 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 766 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
741 addString = i18n("Day before yesterday"); 767 addString = i18n("Day before yesterday");
742 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 768 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
743 addString = i18n("Day after tomorrow"); 769 addString = i18n("Day after tomorrow");
744 if ( !addString.isEmpty() ) { 770 if ( !addString.isEmpty() ) {
745 str = addString+", " + str; 771 str = addString+", " + str;
746 } 772 }
747 } 773 }
748 dayLabel->setText(str); 774 dayLabel->setText(str);
749 dayLabel->setAlignment(QLabel::AlignHCenter); 775 //dayLabel->setAlignment(QLabel::AlignHCenter);
750 if (date == QDate::currentDate()) { 776 if (date == QDate::currentDate()) {
751 QFont bFont = dlf; 777 QFont bFont = dlf;
752 bFont.setBold( true ); 778 bFont.setBold( true );
753 dayLabel->setFont(bFont); 779 dayLabel->setFont(bFont);
754 } 780 }
755 //dayLayout->addWidget(dayLabel); 781 //dayLayout->addWidget(dayLabel);
756 782
757#ifndef KORG_NOPLUGINS 783#ifndef KORG_NOPLUGINS
758 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 784 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
759 CalendarDecoration *it; 785 CalendarDecoration *it;
760 for(it = cds.first(); it; it = cds.next()) { 786 for(it = cds.first(); it; it = cds.next()) {
761 QString text = it->shortText( date ); 787 QString text = it->shortText( date );
762 if ( !text.isEmpty() ) { 788 if ( !text.isEmpty() ) {
763 QLabel *label = new QLabel(text,mDayLabels); 789 QLabel *label = new QLabel(text,mDayLabels);
764 label->setAlignment(AlignCenter); 790 label->setAlignment(AlignCenter);
765 dayLayout->addWidget(label); 791 dayLayout->addWidget(label);
766 } 792 }
767 } 793 }
768 794
769 for(it = cds.first(); it; it = cds.next()) { 795 for(it = cds.first(); it; it = cds.next()) {
770 QWidget *wid = it->smallWidget(mDayLabels,date); 796 QWidget *wid = it->smallWidget(mDayLabels,date);
771 if ( wid ) { 797 if ( wid ) {
772 // wid->setHeight(20); 798 // wid->setHeight(20);
773 dayLayout->addWidget(wid); 799 dayLayout->addWidget(wid);
774 } 800 }
775 } 801 }
776#endif 802#endif
777 } 803 }
778 if ( ! appendLabels ) { 804 if ( ! appendLabels ) {
779 dayLabel = mDayLabelsList.next(); 805 dayLabel = mDayLabelsList.next();
780 if ( !dayLabel ) 806 if ( !dayLabel )
781 appendLabels = true; 807 appendLabels = true;
782 } 808 }
783 if ( appendLabels ) { 809 if ( appendLabels ) {
784 dayLabel = new QLabel(mDayLabels); 810 dayLabel = new QPushButton(mDayLabels);
811 dayLabel->setFlat( true );
812 connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) );
813 dayLabel->setFocusPolicy(NoFocus);
785 mDayLabelsList.append( dayLabel ); 814 mDayLabelsList.append( dayLabel );
786 mLayoutDayLabels->addWidget(dayLabel); 815 mLayoutDayLabels->addWidget(dayLabel);
787 } 816 }
788 //dayLabel->hide();//test only 817 //dayLabel->hide();//test only
789 818
790 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 819 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
791 if ( offset < 0 ) offset = 0; 820 if ( offset < 0 ) offset = 0;
792 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 821 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
793 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); 822 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
794 dayLabel->show(); 823 dayLabel->show();
824 dayLabel->setCaption("last");
795 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 825 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
796 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 826 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
797 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 827 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
798 if ( !appendLabels ) { 828 if ( !appendLabels ) {
799 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
800 while ( dayLabel ) { 830 while ( dayLabel ) {
801 //qDebug("!dayLabel %d",dayLabel ); 831 //qDebug("!dayLabel %d",dayLabel );
802 dayLabel->hide(); 832 dayLabel->hide();
803 dayLabel = mDayLabelsList.next(); 833 dayLabel = mDayLabelsList.next();
804 } 834 }
805 } 835 }
806 //mDayLabelsFrame->show(); 836 //mDayLabelsFrame->show();
807 //mDayLabels->show(); 837 //mDayLabels->show();
808 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 838 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
809 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 839 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
810 mDayLabelsFrame->setFixedHeight( newHight ); 840 mDayLabelsFrame->setFixedHeight( newHight );
811} 841}
812 842
813int KOAgendaView::maxDatesHint() 843int KOAgendaView::maxDatesHint()
814{ 844{
815 // Not sure about the max number of events, so return 0 for now. 845 // Not sure about the max number of events, so return 0 for now.
816 return 0; 846 return 0;
817} 847}
818 848
819int KOAgendaView::currentDateCount() 849int KOAgendaView::currentDateCount()
820{ 850{
821 return mSelectedDates.count(); 851 return mSelectedDates.count();
822} 852}
823 853
824QPtrList<Incidence> KOAgendaView::selectedIncidences() 854QPtrList<Incidence> KOAgendaView::selectedIncidences()
825{ 855{
826 QPtrList<Incidence> selected; 856 QPtrList<Incidence> selected;
827 Incidence *incidence; 857 Incidence *incidence;
828 858
829 incidence = mAgenda->selectedIncidence(); 859 incidence = mAgenda->selectedIncidence();
830 if (incidence) selected.append(incidence); 860 if (incidence) selected.append(incidence);
831 861
832 incidence = mAllDayAgenda->selectedIncidence(); 862 incidence = mAllDayAgenda->selectedIncidence();
833 if (incidence) selected.append(incidence); 863 if (incidence) selected.append(incidence);
834 864
835 return selected; 865 return selected;
836} 866}
837 867
838DateList KOAgendaView::selectedDates() 868DateList KOAgendaView::selectedDates()
839{ 869{
840 DateList selected; 870 DateList selected;
841 QDate qd; 871 QDate qd;
842 872
843 qd = mAgenda->selectedIncidenceDate(); 873 qd = mAgenda->selectedIncidenceDate();
844 if (qd.isValid()) selected.append(qd); 874 if (qd.isValid()) selected.append(qd);
845 875
846 qd = mAllDayAgenda->selectedIncidenceDate(); 876 qd = mAllDayAgenda->selectedIncidenceDate();
847 if (qd.isValid()) selected.append(qd); 877 if (qd.isValid()) selected.append(qd);
848 878
849 return selected; 879 return selected;
850} 880}
851 881
852 882
853void KOAgendaView::updateView() 883void KOAgendaView::updateView()
854{ 884{
855 if ( mBlockUpdating ) 885 if ( mBlockUpdating )
856 return; 886 return;
857 // kdDebug() << "KOAgendaView::updateView()" << endl; 887 // kdDebug() << "KOAgendaView::updateView()" << endl;
858 fillAgenda(); 888 fillAgenda();
859 889
860} 890}
861 891
862 892
863/* 893/*
864 Update configuration settings for the agenda view. This method is not 894 Update configuration settings for the agenda view. This method is not
865 complete. 895 complete.
866*/ 896*/
867void KOAgendaView::updateConfig() 897void KOAgendaView::updateConfig()
868{ 898{
869 if ( mBlockUpdating ) 899 if ( mBlockUpdating )
870 return; 900 return;
871 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 901 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
872 902
873 // update config for children 903 // update config for children
874 mTimeLabels->updateConfig(); 904 mTimeLabels->updateConfig();
875 mAgenda->storePosition(); 905 mAgenda->storePosition();
876 mAgenda->updateConfig(); 906 mAgenda->updateConfig();
877 mAllDayAgenda->updateConfig(); 907 mAllDayAgenda->updateConfig();
878 // widget synchronization 908 // widget synchronization
879 //TODO: find a better way, maybe signal/slot 909 //TODO: find a better way, maybe signal/slot
880 mTimeLabels->positionChanged(); 910 mTimeLabels->positionChanged();
881 911
882 // for some reason, this needs to be called explicitly 912 // for some reason, this needs to be called explicitly
883 mTimeLabels->repaint(); 913 mTimeLabels->repaint();
884 914
885 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 915 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
886 916
887 // ToolTips displaying summary of events 917 // ToolTips displaying summary of events
888 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 918 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
889 ->mEnableToolTips); 919 ->mEnableToolTips);
890 920
891 //setHolidayMasks(); 921 //setHolidayMasks();
892 922
893 //createDayLabels(); called by via updateView(); 923 //createDayLabels(); called by via updateView();
894 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 924 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
895 updateView(); 925 updateView();
896 mAgenda->restorePosition(); 926 mAgenda->restorePosition();
897} 927}
898 928
899 929
900void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 930void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
901{ 931{
902 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 932 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
903 //qDebug("KOAgendaView::updateEventDates "); 933 //qDebug("KOAgendaView::updateEventDates ");
904 QDateTime startDt,endDt; 934 QDateTime startDt,endDt;
905 QDate startDate; 935 QDate startDate;
906 int lenInSecs; 936 int lenInSecs;
907 // if ( type == KOAgenda::RESIZETOP ) 937 // if ( type == KOAgenda::RESIZETOP )
908 // qDebug("RESIZETOP "); 938 // qDebug("RESIZETOP ");
909 // if ( type == KOAgenda::RESIZEBOTTOM ) 939 // if ( type == KOAgenda::RESIZEBOTTOM )
910 // qDebug("RESIZEBOTTOM "); 940 // qDebug("RESIZEBOTTOM ");
911 // if ( type == KOAgenda::MOVE ) 941 // if ( type == KOAgenda::MOVE )
912 // qDebug("MOVE "); 942 // qDebug("MOVE ");
913 if ( item->incidence()->type() == "Event" ) { 943 if ( item->incidence()->type() == "Event" ) {
914 startDt =item->incidence()->dtStart(); 944 startDt =item->incidence()->dtStart();
915 endDt = item->incidence()->dtEnd(); 945 endDt = item->incidence()->dtEnd();
916 lenInSecs = startDt.secsTo( endDt ); 946 lenInSecs = startDt.secsTo( endDt );
917 } 947 }
918 948
919 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 949 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
920 950
921 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 951 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
922 startDate = mSelectedDates[item->mLastMoveXPos]; 952 startDate = mSelectedDates[item->mLastMoveXPos];
923 } else { 953 } else {
924 if (item->cellX() < 0) { 954 if (item->cellX() < 0) {
925 startDate = (mSelectedDates.first()).addDays(item->cellX()); 955 startDate = (mSelectedDates.first()).addDays(item->cellX());
926 } else { 956 } else {
927 startDate = mSelectedDates[item->cellX()]; 957 startDate = mSelectedDates[item->cellX()];
928 } 958 }
929 } 959 }
930 startDt.setDate(startDate); 960 startDt.setDate(startDate);
931 961
932 if (item->incidence()->doesFloat()) { 962 if (item->incidence()->doesFloat()) {
933 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 963 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
934 } else { 964 } else {
935 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 965 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
936 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 966 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
937 if ( item->incidence()->type() == "Event" ) { 967 if ( item->incidence()->type() == "Event" ) {
938 if ( type == KOAgenda::MOVE ) { 968 if ( type == KOAgenda::MOVE ) {
939 endDt = startDt.addSecs(lenInSecs); 969 endDt = startDt.addSecs(lenInSecs);
940 970
941 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 971 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
942 if (item->lastMultiItem()) { 972 if (item->lastMultiItem()) {
943 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 973 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
944 endDt.setDate(startDate. 974 endDt.setDate(startDate.
945 addDays(item->lastMultiItem()->cellX() - item->cellX())); 975 addDays(item->lastMultiItem()->cellX() - item->cellX()));
946 } else { 976 } else {
947 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 977 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
948 endDt.setDate(startDate); 978 endDt.setDate(startDate);
949 } 979 }
950 } 980 }
951 } else { 981 } else {
952 // todo 982 // todo
953 qDebug("tooooodoooooo "); 983 qDebug("tooooodoooooo ");
954 if (item->lastMultiItem()) { 984 if (item->lastMultiItem()) {
955 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 985 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
956 endDt.setDate(startDate. 986 endDt.setDate(startDate.
957 addDays(item->lastMultiItem()->cellX() - item->cellX())); 987 addDays(item->lastMultiItem()->cellX() - item->cellX()));
958 } else { 988 } else {
959 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 989 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
960 if ( item->cellYBottom() > 0 ) 990 if ( item->cellYBottom() > 0 )
961 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 991 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
962 else 992 else
963 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 993 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
964 endDt.setDate(startDate); 994 endDt.setDate(startDate);
965 } 995 }
966 } 996 }
967 } 997 }
968 998
969 qDebug("to888"); 999 qDebug("to888");
970 if ( item->incidence()->type() == "Event" ) { 1000 if ( item->incidence()->type() == "Event" ) {
971 item->incidence()->setDtStart(startDt); 1001 item->incidence()->setDtStart(startDt);
972 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1002 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
973 } else if ( item->incidence()->type() == "Todo" ) { 1003 } else if ( item->incidence()->type() == "Todo" ) {
974 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 1004 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
975 } 1005 }
976 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1006 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
977 item->incidence()->setRevision(item->incidence()->revision()+1); 1007 item->incidence()->setRevision(item->incidence()->revision()+1);
978 item->setItemDate(startDt.date()); 1008 item->setItemDate(startDt.date());
979 //item->updateItem(); 1009 //item->updateItem();
980 if ( item->incidence()->type() == "Todo" ) { 1010 if ( item->incidence()->type() == "Todo" ) {
981 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1011 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
982 1012
983 } 1013 }
984 else 1014 else
985 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1015 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
986 item->updateItem(); 1016 item->updateItem();
987} 1017}
988 1018
989void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1019void KOAgendaView::showDates( const QDate &start, const QDate &end )
990{ 1020{
991 // kdDebug() << "KOAgendaView::selectDates" << endl; 1021 // kdDebug() << "KOAgendaView::selectDates" << endl;
992 1022
993 mSelectedDates.clear(); 1023 mSelectedDates.clear();
994 // qDebug("KOAgendaView::showDates "); 1024 // qDebug("KOAgendaView::showDates ");
995 QDate d = start; 1025 QDate d = start;
996 while (d <= end) { 1026 while (d <= end) {
997 mSelectedDates.append(d); 1027 mSelectedDates.append(d);
998 d = d.addDays( 1 ); 1028 d = d.addDays( 1 );
999 } 1029 }
1000 1030
1001 // and update the view 1031 // and update the view
1002 fillAgenda(); 1032 fillAgenda();
1003} 1033}
1004 1034
1005 1035
1006void KOAgendaView::showEvents(QPtrList<Event>) 1036void KOAgendaView::showEvents(QPtrList<Event>)
1007{ 1037{
1008 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1038 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1009} 1039}
1010 1040
1011void KOAgendaView::changeEventDisplay(Event *, int) 1041void KOAgendaView::changeEventDisplay(Event *, int)
1012{ 1042{
1013 // qDebug("KOAgendaView::changeEventDisplay "); 1043 // qDebug("KOAgendaView::changeEventDisplay ");
1014 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1044 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1015 // this should be re-written to be MUCH smarter. Right now we 1045 // this should be re-written to be MUCH smarter. Right now we
1016 // are just playing dumb. 1046 // are just playing dumb.
1017 fillAgenda(); 1047 fillAgenda();
1018} 1048}
1019 1049
1020void KOAgendaView::fillAgenda(const QDate &) 1050void KOAgendaView::fillAgenda(const QDate &)
1021{ 1051{
1022 // qDebug("KOAgendaView::fillAgenda "); 1052 // qDebug("KOAgendaView::fillAgenda ");
1023 fillAgenda(); 1053 fillAgenda();
1024} 1054}
1025 1055
1026void KOAgendaView::fillAgenda() 1056void KOAgendaView::fillAgenda()
1027{ 1057{
1028 if ( globalFlagBlockStartup ) 1058 if ( globalFlagBlockStartup )
1029 return; 1059 return;
1030 if ( globalFlagBlockAgenda == 1 ) 1060 if ( globalFlagBlockAgenda == 1 )
1031 return; 1061 return;
1032 //if ( globalFlagBlockAgenda == 2 ) 1062 //if ( globalFlagBlockAgenda == 2 )
1033 //globalFlagBlockAgenda = 0; 1063 //globalFlagBlockAgenda = 0;
1034 // globalFlagBlockPainting = false; 1064 // globalFlagBlockPainting = false;
1035 if ( globalFlagBlockAgenda == 0 ) 1065 if ( globalFlagBlockAgenda == 0 )
1036 globalFlagBlockAgenda = 1; 1066 globalFlagBlockAgenda = 1;
1037 // clearView(); 1067 // clearView();
1038 //qDebug("fillAgenda()++++ "); 1068 //qDebug("fillAgenda()++++ ");
1039 globalFlagBlockAgendaItemPaint = 1; 1069 globalFlagBlockAgendaItemPaint = 1;
1040 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1070 mAllDayAgenda->changeColumns(mSelectedDates.count());
1041 mAgenda->changeColumns(mSelectedDates.count()); 1071 mAgenda->changeColumns(mSelectedDates.count());
1042 qApp->processEvents(); 1072 qApp->processEvents();
1043 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1073 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1044 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1074 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1045 setHolidayMasks(); 1075 setHolidayMasks();
1046 1076
1047 //mAgenda->hideUnused(); 1077 //mAgenda->hideUnused();
1048 //mAllDayAgenda->hideUnused(); 1078 //mAllDayAgenda->hideUnused();
1049 1079
1050 // mAgenda->blockNextRepaint( false ); 1080 // mAgenda->blockNextRepaint( false );
1051 // mAgenda->viewport()->repaint(); 1081 // mAgenda->viewport()->repaint();
1052 // mAgenda->blockNextRepaint( true ); 1082 // mAgenda->blockNextRepaint( true );
1053 mMinY.resize(mSelectedDates.count()); 1083 mMinY.resize(mSelectedDates.count());
1054 mMaxY.resize(mSelectedDates.count()); 1084 mMaxY.resize(mSelectedDates.count());
1055 1085
1056 QPtrList<Event> dayEvents; 1086 QPtrList<Event> dayEvents;
1057 1087
1058 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1088 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1059 // Therefore, gtodoset all of them. 1089 // Therefore, gtodoset all of them.
1060 QPtrList<Todo> todos = calendar()->todos(); 1090 QPtrList<Todo> todos = calendar()->todos();
1061 1091
1062 mAgenda->setDateList(mSelectedDates); 1092 mAgenda->setDateList(mSelectedDates);
1063 1093
1064 QDate today = QDate::currentDate(); 1094 QDate today = QDate::currentDate();
1065 1095
1066 DateList::ConstIterator dit; 1096 DateList::ConstIterator dit;
1067 int curCol = 0; 1097 int curCol = 0;
1068 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1098 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1069 QDate currentDate = *dit; 1099 QDate currentDate = *dit;
1070 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1100 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1071 // << endl; 1101 // << endl;
1072 1102
1073 dayEvents = calendar()->events(currentDate,true); 1103 dayEvents = calendar()->events(currentDate,true);
1074 1104
1075 // Default values, which can never be reached 1105 // Default values, which can never be reached
1076 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1106 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1077 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1107 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1078 1108
1079 unsigned int numEvent; 1109 unsigned int numEvent;
1080 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1110 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1081 Event *event = dayEvents.at(numEvent); 1111 Event *event = dayEvents.at(numEvent);
1082 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1112 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1083 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1113 if ( event->uid().left(15) == QString("last-syncEvent-") )
1084 continue; 1114 continue;
1085 // kdDebug() << " Event: " << event->summary() << endl; 1115 // kdDebug() << " Event: " << event->summary() << endl;
1086 1116
1087 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1117 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1088 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1118 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1089 1119
1090 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1120 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1091 1121
1092 if (event->doesFloat()) { 1122 if (event->doesFloat()) {
1093 if (event->recurrence()->doesRecur()) { 1123 if (event->recurrence()->doesRecur()) {
1094 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1124 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1095 } else { 1125 } else {
1096 if (beginX <= 0 && curCol == 0) { 1126 if (beginX <= 0 && curCol == 0) {
1097 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1127 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1098 } else if (beginX == curCol) { 1128 } else if (beginX == curCol) {
1099 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1129 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1100 } 1130 }
1101 } 1131 }
1102 } else if (event->isMultiDay()) { 1132 } else if (event->isMultiDay()) {
1103 if ( event->doesRecur () ) { 1133 if ( event->doesRecur () ) {
1104 QDate dateit = currentDate; 1134 QDate dateit = currentDate;
1105 int count = 0; 1135 int count = 0;
1106 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1136 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1107 while (! event->recursOn( dateit ) && count <= max ) { 1137 while (! event->recursOn( dateit ) && count <= max ) {
1108 ++count; 1138 ++count;
1109 dateit = dateit.addDays( -1 ); 1139 dateit = dateit.addDays( -1 );
1110 } 1140 }
1111 bool ok; 1141 bool ok;
1112 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1142 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1113 if ( ok ) 1143 if ( ok )
1114 { 1144 {
1115 int secs = event->dtStart().secsTo( event->dtEnd() ); 1145 int secs = event->dtStart().secsTo( event->dtEnd() );
1116 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1146 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1117 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1147 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1118 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1148 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1119 1149
1120 } 1150 }
1121 } 1151 }
1122 int startY = mAgenda->timeToY(event->dtStart().time()); 1152 int startY = mAgenda->timeToY(event->dtStart().time());
1123 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1153 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1124 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1154 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1125 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1155 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1126 //qDebug("insert!!! "); 1156 //qDebug("insert!!! ");
1127 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1157 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1128 } 1158 }
1129 if (beginX == curCol) { 1159 if (beginX == curCol) {
1130 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1160 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1131 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1161 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1132 } else if (endX == curCol) { 1162 } else if (endX == curCol) {
1133 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1163 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1134 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1164 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1135 } else { 1165 } else {
1136 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1166 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1137 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1167 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1138 } 1168 }
1139 } else { 1169 } else {
1140 int startY = mAgenda->timeToY(event->dtStart().time()); 1170 int startY = mAgenda->timeToY(event->dtStart().time());
1141 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1171 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1142 if (endY < startY) endY = startY; 1172 if (endY < startY) endY = startY;
1143 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1173 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1144 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1174 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1145 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1175 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1146 } 1176 }
1147 } 1177 }
1148 // ---------- [display Todos -------------- 1178 // ---------- [display Todos --------------
1149 unsigned int numTodo; 1179 unsigned int numTodo;
1150 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1180 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1151 Todo *todo = todos.at(numTodo); 1181 Todo *todo = todos.at(numTodo);
1152 1182
1153 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1183 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1154 1184
1155 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1185 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1156 // Already completed items can be displayed on their original due date 1186 // Already completed items can be displayed on their original due date
1157 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1187 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1158 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1188 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1159 bool fillIn = false; 1189 bool fillIn = false;
1160 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1190 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1161 fillIn = true; 1191 fillIn = true;
1162 if ( ! fillIn && !todo->hasCompletedDate() ) 1192 if ( ! fillIn && !todo->hasCompletedDate() )
1163 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1193 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1164 if ( fillIn ) { 1194 if ( fillIn ) {
1165 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1195 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1166 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1196 if ( KOPrefs::instance()->mShowTodoInAgenda )
1167 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1197 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1168 } 1198 }
1169 else { 1199 else {
1170 QDateTime dt; 1200 QDateTime dt;
1171 if ( todo->hasCompletedDate() ) 1201 if ( todo->hasCompletedDate() )
1172 dt = todo->completed(); 1202 dt = todo->completed();
1173 else 1203 else
1174 dt = todo->dtDue();; 1204 dt = todo->dtDue();;
1175 1205
1176 1206
1177 int endY = mAgenda->timeToY(dt.time()) - 1; 1207 int endY = mAgenda->timeToY(dt.time()) - 1;
1178 int hi = (18/KOPrefs::instance()->mHourSize); 1208 int hi = (18/KOPrefs::instance()->mHourSize);
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 7774fbe..fd0a7af 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,262 +1,263 @@
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 <qlayout.h> 28#include <qlayout.h>
29#ifndef DESKTOP_VERSION 29#ifndef DESKTOP_VERSION
30#include <qksplitter.h> 30#include <qksplitter.h>
31#else 31#else
32#include <qsplitter.h> 32#include <qsplitter.h>
33#endif 33#endif
34#include <qmemarray.h> 34#include <qmemarray.h>
35 35
36#include "koeventview.h" 36#include "koeventview.h"
37 37
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;
48class TimeLabels : public QScrollView { 48class TimeLabels : public QScrollView {
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
52 52
53 void setCellHeight(int height); 53 void setCellHeight(int height);
54 54
55 /** Calculates the minimum width */ 55 /** Calculates the minimum width */
56 virtual int minimumWidth() const; 56 virtual int minimumWidth() const;
57 57
58 /** updates widget's internal state */ 58 /** updates widget's internal state */
59 void updateConfig(); 59 void updateConfig();
60 60
61 /** */ 61 /** */
62 void setAgenda(KOAgenda* agenda); 62 void setAgenda(KOAgenda* agenda);
63 63
64 /** */ 64 /** */
65 virtual void paintEvent(QPaintEvent* e); 65 virtual void paintEvent(QPaintEvent* e);
66 void contentsMousePressEvent ( QMouseEvent * ) ; 66 void contentsMousePressEvent ( QMouseEvent * ) ;
67 void contentsMouseReleaseEvent ( QMouseEvent * ); 67 void contentsMouseReleaseEvent ( QMouseEvent * );
68 void contentsMouseMoveEvent ( QMouseEvent * ); 68 void contentsMouseMoveEvent ( QMouseEvent * );
69 69
70 public slots: 70 public slots:
71 /** update time label positions */ 71 /** update time label positions */
72 void positionChanged(); 72 void positionChanged();
73 signals: 73 signals:
74 void scaleChanged(); 74 void scaleChanged();
75 protected: 75 protected:
76 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 76 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
77 77
78 private: 78 private:
79 int mMouseDownY; 79 int mMouseDownY;
80 QString mOrgCap; 80 QString mOrgCap;
81 int mRows; 81 int mRows;
82 int mCellHeight; 82 int mCellHeight;
83 83
84 /** */ 84 /** */
85 KOAgenda* mAgenda; 85 KOAgenda* mAgenda;
86}; 86};
87 87
88class EventIndicator : public QFrame { 88class EventIndicator : public QFrame {
89 Q_OBJECT 89 Q_OBJECT
90 public: 90 public:
91 enum Location { Top, Bottom }; 91 enum Location { Top, Bottom };
92 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 92 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
93 virtual ~EventIndicator(); 93 virtual ~EventIndicator();
94 94
95 void changeColumns(int columns); 95 void changeColumns(int columns);
96 void setPaintWidget( KDGanttMinimizeSplitter* ); 96 void setPaintWidget( KDGanttMinimizeSplitter* );
97 void setXOffset( int ); 97 void setXOffset( int );
98 void enableColumn(int column, bool enable); 98 void enableColumn(int column, bool enable);
99 99
100 protected: 100 protected:
101 void drawContents(QPainter *); 101 void drawContents(QPainter *);
102 102
103 private: 103 private:
104 int mXOffset; 104 int mXOffset;
105 KDGanttMinimizeSplitter* mPaintWidget; 105 KDGanttMinimizeSplitter* mPaintWidget;
106 int mColumns; 106 int mColumns;
107 QHBox *mTopBox; 107 QHBox *mTopBox;
108 QBoxLayout *mTopLayout; 108 QBoxLayout *mTopLayout;
109 Location mLocation; 109 Location mLocation;
110 QPixmap mPixmap; 110 QPixmap mPixmap;
111 QMemArray<bool> mEnabled; 111 QMemArray<bool> mEnabled;
112}; 112};
113 113
114/** 114/**
115 KOAgendaView is the agenda-like view used to display events in an one or 115 KOAgendaView is the agenda-like view used to display events in an one or
116 multi-day view. 116 multi-day view.
117*/ 117*/
118class KOAgendaView : public KOEventView { 118class KOAgendaView : public KOEventView {
119 Q_OBJECT 119 Q_OBJECT
120 public: 120 public:
121 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 121 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
122 virtual ~KOAgendaView(); 122 virtual ~KOAgendaView();
123 void setStartHour( int ); 123 void setStartHour( int );
124 void toggleAllDay(); 124 void toggleAllDay();
125 125
126 126
127 /** Returns maximum number of days supported by the koagendaview */ 127 /** Returns maximum number of days supported by the koagendaview */
128 virtual int maxDatesHint(); 128 virtual int maxDatesHint();
129 129
130 /** Returns number of currently shown dates. */ 130 /** Returns number of currently shown dates. */
131 virtual int currentDateCount(); 131 virtual int currentDateCount();
132 132
133 /** returns the currently selected events */ 133 /** returns the currently selected events */
134 virtual QPtrList<Incidence> selectedIncidences(); 134 virtual QPtrList<Incidence> selectedIncidences();
135 135
136 /** returns the currently selected events */ 136 /** returns the currently selected events */
137 virtual DateList selectedDates(); 137 virtual DateList selectedDates();
138 138
139 /** Remove all events from view */ 139 /** Remove all events from view */
140 void clearView(); 140 void clearView();
141 KOAgenda *agenda() { return mAgenda;} 141 KOAgenda *agenda() { return mAgenda;}
142 virtual void printPreview(CalPrinter *calPrinter, 142 virtual void printPreview(CalPrinter *calPrinter,
143 const QDate &, const QDate &); 143 const QDate &, const QDate &);
144 144
145 /** start-datetime of selection */ 145 /** start-datetime of selection */
146 QDateTime selectionStart() {return mTimeSpanBegin;} 146 QDateTime selectionStart() {return mTimeSpanBegin;}
147 /** end-datetime of selection */ 147 /** end-datetime of selection */
148 QDateTime selectionEnd() {return mTimeSpanEnd;} 148 QDateTime selectionEnd() {return mTimeSpanEnd;}
149 /** returns true if selection is for whole day */ 149 /** returns true if selection is for whole day */
150 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 150 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
151 /** make selected start/end invalid */ 151 /** make selected start/end invalid */
152 void deleteSelectedDateTime(); 152 void deleteSelectedDateTime();
153 void repaintAgenda(); 153 void repaintAgenda();
154 public slots: 154 public slots:
155 virtual void updateView(); 155 virtual void updateView();
156 virtual void updateConfig(); 156 virtual void updateConfig();
157 virtual void showDates(const QDate &start, const QDate &end); 157 virtual void showDates(const QDate &start, const QDate &end);
158 virtual void showEvents(QPtrList<Event> eventList); 158 virtual void showEvents(QPtrList<Event> eventList);
159 159
160 void updateTodo( Todo *, int ); 160 void updateTodo( Todo *, int );
161 void changeEventDisplay(Event *, int); 161 void changeEventDisplay(Event *, int);
162 162
163 void clearSelection(); 163 void clearSelection();
164 164
165 void newTodo(int gx,int gy); 165 void newTodo(int gx,int gy);
166 void newEvent(int gx,int gy); 166 void newEvent(int gx,int gy);
167 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 167 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
168 void newEventAllDay(int gx, int gy); 168 void newEventAllDay(int gx, int gy);
169 void newTodoAllDay(int gx, int gy); 169 void newTodoAllDay(int gx, int gy);
170 170
171 void startDrag(Event *); 171 void startDrag(Event *);
172 172
173 void readSettings(); 173 void readSettings();
174 void readSettings(KConfig *); 174 void readSettings(KConfig *);
175 void writeSettings(KConfig *); 175 void writeSettings(KConfig *);
176 176
177 void setContentsPos(int y); 177 void setContentsPos(int y);
178 178
179 void setExpandedButton( bool expanded ); 179 void setExpandedButton( bool expanded );
180 void scrollOneHourUp(); 180 void scrollOneHourUp();
181 void scrollOneHourDown(); 181 void scrollOneHourDown();
182 void addToCalSlot(Incidence *, Incidence *); 182 void addToCalSlot(Incidence *, Incidence *);
183 183
184 signals: 184 signals:
185 void showDateView( int, QDate ); 185 void showDateView( int, QDate );
186 void newTodoSignal( QDateTime ,bool ); 186 void newTodoSignal( QDateTime ,bool );
187 void toggleExpand(); 187 void toggleExpand();
188 void todoMoved( Todo *, int ); 188 void todoMoved( Todo *, int );
189 void incidenceChanged(Incidence * , int ); 189 void incidenceChanged(Incidence * , int );
190 // void cloneIncidenceSignal(Incidence *); 190 // void cloneIncidenceSignal(Incidence *);
191 191
192 protected: 192 protected:
193 bool mBlockUpdating; 193 bool mBlockUpdating;
194 int mUpcomingWidth; 194 int mUpcomingWidth;
195 /** Fill agenda beginning with date startDate */ 195 /** Fill agenda beginning with date startDate */
196 void fillAgenda(const QDate &startDate); 196 void fillAgenda(const QDate &startDate);
197 void resizeEvent( QResizeEvent* e ); 197 void resizeEvent( QResizeEvent* e );
198 /** Fill agenda using the current set value for the start date */ 198 /** Fill agenda using the current set value for the start date */
199 void fillAgenda(); 199 void fillAgenda();
200 200
201 /** Create labels for the selected dates. */ 201 /** Create labels for the selected dates. */
202 void createDayLabels(); 202 void createDayLabels();
203 203
204 /** 204 /**
205 Set the masks on the agenda widgets indicating, which days are holidays. 205 Set the masks on the agenda widgets indicating, which days are holidays.
206 */ 206 */
207 void setHolidayMasks(); 207 void setHolidayMasks();
208 208
209 protected slots: 209 protected slots:
210 void slotDaylabelClicked();
210 /** Update event belonging to agenda item */ 211 /** Update event belonging to agenda item */
211 void updateEventDates(KOAgendaItem *item, int mode = -1); 212 void updateEventDates(KOAgendaItem *item, int mode = -1);
212 //void updateMovedTodo(); 213 //void updateMovedTodo();
213 214
214 void updateEventIndicatorTop(int newY); 215 void updateEventIndicatorTop(int newY);
215 void updateEventIndicatorBottom(int newY); 216 void updateEventIndicatorBottom(int newY);
216 217
217 /** Updates data for selected timespan */ 218 /** Updates data for selected timespan */
218 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 219 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
219 /** Updates data for selected timespan for all day event*/ 220 /** Updates data for selected timespan for all day event*/
220 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 221 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
221 222
222 private: 223 private:
223 // view widgets 224 // view widgets
224 QFrame *mDayLabels; 225 QFrame *mDayLabels;
225 QHBox *mDayLabelsFrame; 226 QHBox *mDayLabelsFrame;
226 QBoxLayout *mLayoutDayLabels; 227 QBoxLayout *mLayoutDayLabels;
227 QFrame *mAllDayFrame; 228 QFrame *mAllDayFrame;
228 KOAgenda *mAllDayAgenda; 229 KOAgenda *mAllDayAgenda;
229 KOAgenda *mAgenda; 230 KOAgenda *mAgenda;
230 TimeLabels *mTimeLabels; 231 TimeLabels *mTimeLabels;
231 QWidget *mDummyAllDayLeft; 232 QWidget *mDummyAllDayLeft;
232 233
233 KDGanttMinimizeSplitter* mSplitterAgenda; 234 KDGanttMinimizeSplitter* mSplitterAgenda;
234 QPushButton *mExpandButton; 235 QPushButton *mExpandButton;
235 236
236 DateList mSelectedDates; // List of dates to be displayed 237 DateList mSelectedDates; // List of dates to be displayed
237 int mViewType; 238 int mViewType;
238 239
239 bool mWeekStartsMonday; 240 bool mWeekStartsMonday;
240 int mStartHour; 241 int mStartHour;
241 242
242 KOEventPopupMenu *mAgendaPopup; 243 KOEventPopupMenu *mAgendaPopup;
243 KOEventPopupMenu *mAllDayAgendaPopup; 244 KOEventPopupMenu *mAllDayAgendaPopup;
244 245
245 EventIndicator *mEventIndicatorTop; 246 EventIndicator *mEventIndicatorTop;
246 EventIndicator *mEventIndicatorBottom; 247 EventIndicator *mEventIndicatorBottom;
247 248
248 QMemArray<int> mMinY; 249 QMemArray<int> mMinY;
249 QMemArray<int> mMaxY; 250 QMemArray<int> mMaxY;
250 251
251 QMemArray<bool> mHolidayMask; 252 QMemArray<bool> mHolidayMask;
252 253
253 QPixmap mExpandedPixmap; 254 QPixmap mExpandedPixmap;
254 QPixmap mNotExpandedPixmap; 255 QPixmap mNotExpandedPixmap;
255 QPtrList<QLabel> mDayLabelsList; 256 QPtrList<QPushButton> mDayLabelsList;
256 QDateTime mTimeSpanBegin; 257 QDateTime mTimeSpanBegin;
257 QDateTime mTimeSpanEnd; 258 QDateTime mTimeSpanEnd;
258 bool mTimeSpanInAllDay; 259 bool mTimeSpanInAllDay;
259 void keyPressEvent ( QKeyEvent * e ); 260 void keyPressEvent ( QKeyEvent * e );
260}; 261};
261 262
262#endif // KOAGENDAVIEW_H 263#endif // KOAGENDAVIEW_H
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index db23882..30f5fb1 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,522 +1,529 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
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
101 101
102void KOViewManager::showDateView( int view, QDate date) 102void KOViewManager::showDateView( int view, QDate date)
103{ 103{
104 104
105 //qDebug("date %d %s", view, date.toString().latin1()); 105 //qDebug("date %d %s", view, date.toString().latin1());
106#if 0 106#if 0
107 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 107 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
108 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); 108 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 );
109 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); 109 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 );
110 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); 110 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 );
111 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 111 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
112#endif 112#endif
113 if ( view == 3 ) { 113 if ( view == 3 ) {
114 //mCurrentAgendaView = 1 ;
114 mMainView->showDay( date ); 115 mMainView->showDay( date );
115 } else if (view == 4 ) { 116 } else if (view == 4 ) {
117 mCurrentAgendaView = 7 ;
116 mMainView->dateNavigator()->selectDates( date, 7 ); 118 mMainView->dateNavigator()->selectDates( date, 7 );
117 } else if (view == 5 ) { 119 } else if (view == 5 ) {
120 mCurrentAgendaView = 14 ;
118 mMainView->dateNavigator()->selectDates( date, 14); 121 mMainView->dateNavigator()->selectDates( date, 14);
119 } else if (view == 6 ) { 122 } else if (view == 6 ) {
120 mMainView->dateNavigator()->blockSignals( true ); 123 mMainView->dateNavigator()->blockSignals( true );
121 showMonthView(); 124 showMonthView();
122 mMainView->dateNavigator()->selectMonthByDate( date ); 125 mMainView->dateNavigator()->selectMonthByDate( date );
123 mMainView->dateNavigator()->blockSignals( false ); 126 mMainView->dateNavigator()->blockSignals( false );
124 mMainView->dateNavigator()->selectDate( date ); 127 mMainView->dateNavigator()->selectDate( date );
125 } else if (view == 7 ) { 128 } else if (view == 7 ) {
126 mMainView->dateNavigator()->selectDate( date ); 129 mMainView->dateNavigator()->selectDate( date );
127 showJournalView(); 130 showJournalView();
128 } else if (view == 8 ) { 131 } else if (view == 8 ) {
129 globalFlagBlockAgenda = 1; 132 globalFlagBlockAgenda = 1;
130 if ( mCurrentAgendaView != 3 ) 133 if ( mCurrentAgendaView != 3 )
131 mCurrentAgendaView = -1; 134 mCurrentAgendaView = -1;
132 showAgendaView(KOPrefs::instance()->mFullViewMonth); 135 showAgendaView(KOPrefs::instance()->mFullViewMonth);
133 globalFlagBlockAgenda = 2; 136 globalFlagBlockAgenda = 2;
134 mMainView->dateNavigator()->selectDates( date , 137 mMainView->dateNavigator()->selectDates( date ,
135 KOPrefs::instance()->mNextXDays ); 138 KOPrefs::instance()->mNextXDays );
136 mFlagShowNextxDays = true; 139 mFlagShowNextxDays = true;
137 mCurrentAgendaView = 3 ; 140 mCurrentAgendaView = 3 ;
138 } 141 } if (view == 9) {
142 showWeekView();
143 } else if (view == 10) {
144 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
145 }
139 146
140#if 0 147#if 0
141 dateNavigator()->blockSignals( true ); 148 dateNavigator()->blockSignals( true );
142 dateNavigator()->selectDate( d ); 149 dateNavigator()->selectDate( d );
143 dateNavigator()->blockSignals( false ); 150 dateNavigator()->blockSignals( false );
144 mViewManager->showDayView(); 151 mViewManager->showDayView();
145#endif 152#endif
146 153
147} 154}
148 155
149 156
150 157
151void KOViewManager::writeSettings(KConfig *config) 158void KOViewManager::writeSettings(KConfig *config)
152{ 159{
153 config->setGroup("General"); 160 config->setGroup("General");
154 161
155 QString view; 162 QString view;
156 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 163 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
157 else if (mCurrentView == mMonthView) view = "Month"; 164 else if (mCurrentView == mMonthView) view = "Month";
158 else if (mCurrentView == mListView) view = "List"; 165 else if (mCurrentView == mListView) view = "List";
159 else if (mCurrentView == mJournalView) view = "Journal"; 166 else if (mCurrentView == mJournalView) view = "Journal";
160 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 167 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
161 else if (mCurrentView == mTodoView) view = "Todo"; 168 else if (mCurrentView == mTodoView) view = "Todo";
162 else view = "Agenda"; 169 else view = "Agenda";
163 170
164 config->writeEntry("Current View",view); 171 config->writeEntry("Current View",view);
165 172
166 if (mAgendaView) { 173 if (mAgendaView) {
167 mAgendaView->writeSettings(config); 174 mAgendaView->writeSettings(config);
168 } 175 }
169 if (mTimeSpanView) { 176 if (mTimeSpanView) {
170 mTimeSpanView->writeSettings(config); 177 mTimeSpanView->writeSettings(config);
171 } 178 }
172 if (mListView) { 179 if (mListView) {
173 mListView->writeSettings(config); 180 mListView->writeSettings(config);
174 } 181 }
175 if (mTodoView) { 182 if (mTodoView) {
176 mTodoView->saveLayout(config,"Todo View"); 183 mTodoView->saveLayout(config,"Todo View");
177 } 184 }
178} 185}
179 186
180void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 187void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
181{ 188{
182 189
183 //mFlagShowNextxDays = false; 190 //mFlagShowNextxDays = false;
184 //if(view == mCurrentView) return; 191 //if(view == mCurrentView) return;
185 if ( view == 0 ) { 192 if ( view == 0 ) {
186 view = mCurrentView; 193 view = mCurrentView;
187 if ( view == 0 ) 194 if ( view == 0 )
188 return; 195 return;
189 } 196 }
190 bool full = fullScreen; 197 bool full = fullScreen;
191 if(view == mCurrentView && view != mWhatsNextView ) { 198 if(view == mCurrentView && view != mWhatsNextView ) {
192 if ( mCurrentAgendaView < 0 ) 199 if ( mCurrentAgendaView < 0 )
193 return; 200 return;
194 full = mMainView->leftFrame()->isVisible(); 201 full = mMainView->leftFrame()->isVisible();
195 } else { 202 } else {
196 mCurrentView = view; 203 mCurrentView = view;
197 // bool full = fullScreen; 204 // bool full = fullScreen;
198 bool isFull = !mMainView->leftFrame()->isVisible(); 205 bool isFull = !mMainView->leftFrame()->isVisible();
199 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 206 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
200 full = true; 207 full = true;
201 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 208 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
202 full = false; 209 full = false;
203 } 210 }
204 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 211 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
205 //raiseCurrentView( full ); 212 //raiseCurrentView( full );
206 mMainView->processIncidenceSelection( 0 ); 213 mMainView->processIncidenceSelection( 0 );
207 //mMainView->updateView(); 214 //mMainView->updateView();
208 raiseCurrentView( full, true ); 215 raiseCurrentView( full, true );
209 mMainView->adaptNavigationUnits(); 216 mMainView->adaptNavigationUnits();
210} 217}
211 218
212void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 219void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
213{ 220{
214 mCurrentAgendaView = 0; 221 mCurrentAgendaView = 0;
215 int wid = mMainView->width() ; 222 int wid = mMainView->width() ;
216 int hei = mMainView->height(); 223 int hei = mMainView->height();
217 if ( mCurrentView == mMonthView ) { 224 if ( mCurrentView == mMonthView ) {
218 mMainView->navigatorBar()->show(); 225 mMainView->navigatorBar()->show();
219 hei -= mMainView->navigatorBar()->sizeHint().height(); 226 hei -= mMainView->navigatorBar()->sizeHint().height();
220 //mMainView->navigatorBar()->hide(); 227 //mMainView->navigatorBar()->hide();
221 } else { 228 } else {
222 mMainView->navigatorBar()->hide(); 229 mMainView->navigatorBar()->hide();
223 } 230 }
224 if ( fullScreen ) { 231 if ( fullScreen ) {
225 mMainView->leftFrame()->hide(); 232 mMainView->leftFrame()->hide();
226 } else { 233 } else {
227 mMainView->leftFrame()->show(); 234 mMainView->leftFrame()->show();
228 if ( KOPrefs::instance()->mVerticalScreen ) 235 if ( KOPrefs::instance()->mVerticalScreen )
229 hei -= mMainView->leftFrame()->height(); 236 hei -= mMainView->leftFrame()->height();
230 else 237 else
231 wid -= mMainView->leftFrame()->width(); 238 wid -= mMainView->leftFrame()->width();
232 } 239 }
233 emit signalFullScreen( !fullScreen ); 240 emit signalFullScreen( !fullScreen );
234 if ( callUpdateView ) 241 if ( callUpdateView )
235 mMainView->updateView(); 242 mMainView->updateView();
236 243
237 if ( globalFlagBlockAgenda == 5 ) { 244 if ( globalFlagBlockAgenda == 5 ) {
238 globalFlagBlockAgenda = 4; 245 globalFlagBlockAgenda = 4;
239 globalFlagBlockAgendaItemPaint = 1; 246 globalFlagBlockAgendaItemPaint = 1;
240 } 247 }
241 mMainView->viewStack()->raiseWidget(mCurrentView); 248 mMainView->viewStack()->raiseWidget(mCurrentView);
242 if ( globalFlagBlockAgenda == 4 ) { 249 if ( globalFlagBlockAgenda == 4 ) {
243 if ( mCurrentView == mAgendaView ) { 250 if ( mCurrentView == mAgendaView ) {
244 //globalFlagBlockAgenda =1 ; 251 //globalFlagBlockAgenda =1 ;
245 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 252 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
246 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 253 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
247 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 254 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
248 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 255 mAgendaView->setStartHour( QTime::currentTime ().hour() );
249 qApp->processEvents(); 256 qApp->processEvents();
250 //qDebug("qApp->processEvents() "); 257 //qDebug("qApp->processEvents() ");
251 globalFlagBlockAgenda = 0; 258 globalFlagBlockAgenda = 0;
252 mAgendaView->repaintAgenda(); 259 mAgendaView->repaintAgenda();
253 260
254 } 261 }
255 globalFlagBlockAgenda = 0; 262 globalFlagBlockAgenda = 0;
256 } 263 }
257 emit signalAgendaView( mCurrentView == mAgendaView ); 264 emit signalAgendaView( mCurrentView == mAgendaView );
258 //qDebug("raiseCurrentView ende "); 265 //qDebug("raiseCurrentView ende ");
259 266
260} 267}
261 268
262void KOViewManager::updateView() 269void KOViewManager::updateView()
263{ 270{
264 // qDebug("KOViewManager::updateView() "); 271 // qDebug("KOViewManager::updateView() ");
265 // if we are updating mTodoView, we get endless recursion 272 // if we are updating mTodoView, we get endless recursion
266 if ( mTodoView == mCurrentView ) 273 if ( mTodoView == mCurrentView )
267 return; 274 return;
268 if ( mCurrentView ) mCurrentView->updateView(); 275 if ( mCurrentView ) mCurrentView->updateView();
269 276
270} 277}
271 278
272void KOViewManager::updateView(const QDate &start, const QDate &end) 279void KOViewManager::updateView(const QDate &start, const QDate &end)
273{ 280{
274 // kdDebug() << "KOViewManager::updateView()" << endl; 281 // kdDebug() << "KOViewManager::updateView()" << endl;
275 282
276 if (mCurrentView) mCurrentView->showDates(start, end); 283 if (mCurrentView) mCurrentView->showDates(start, end);
277 284
278 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 285 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
279} 286}
280 287
281 288
282void KOViewManager::updateWNview() 289void KOViewManager::updateWNview()
283{ 290{
284 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 291 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
285 mWhatsNextView->updateView(); 292 mWhatsNextView->updateView();
286 293
287} 294}
288void KOViewManager::showWhatsNextView() 295void KOViewManager::showWhatsNextView()
289{ 296{
290 if (!mWhatsNextView) { 297 if (!mWhatsNextView) {
291 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 298 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
292 "KOViewManager::WhatsNextView"); 299 "KOViewManager::WhatsNextView");
293 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 300 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
294 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 301 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
295 addView(mWhatsNextView); 302 addView(mWhatsNextView);
296 connect(this, SIGNAL( printWNV() ), 303 connect(this, SIGNAL( printWNV() ),
297 mWhatsNextView, SLOT( printMe() ) ); 304 mWhatsNextView, SLOT( printMe() ) );
298 } 305 }
299 globalFlagBlockAgenda = 1; 306 globalFlagBlockAgenda = 1;
300 showView(mWhatsNextView, true ); 307 showView(mWhatsNextView, true );
301 //mWhatsNextView->updateView(); 308 //mWhatsNextView->updateView();
302 309
303} 310}
304 311
305void KOViewManager::showListView() 312void KOViewManager::showListView()
306{ 313{
307 if (!mListView) { 314 if (!mListView) {
308 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 315 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
309 addView(mListView); 316 addView(mListView);
310 317
311 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 318 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
312 mMainView, SLOT(showIncidence(Incidence *))); 319 mMainView, SLOT(showIncidence(Incidence *)));
313 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 320 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
314 mMainView, SLOT(editIncidence(Incidence *))); 321 mMainView, SLOT(editIncidence(Incidence *)));
315 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 322 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
316 mMainView, SLOT(deleteIncidence(Incidence *))); 323 mMainView, SLOT(deleteIncidence(Incidence *)));
317 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 324 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
318 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 325 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
319 connect( mListView, SIGNAL( signalNewEvent() ), 326 connect( mListView, SIGNAL( signalNewEvent() ),
320 mMainView, SLOT( newEvent() ) ); 327 mMainView, SLOT( newEvent() ) );
321 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 328 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
322 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 329 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
323 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 330 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
324 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 331 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
325 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 332 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
326 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 333 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
327 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 334 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
328 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 335 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
329 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 336 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
330 } 337 }
331 // bool temp = mFlagShowNextxDays; 338 // bool temp = mFlagShowNextxDays;
332 //globalFlagBlockPainting = true; 339 //globalFlagBlockPainting = true;
333 globalFlagBlockAgenda = 1; 340 globalFlagBlockAgenda = 1;
334 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 341 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
335 mMainView->setBlockShowDates( true ); 342 mMainView->setBlockShowDates( true );
336 mMainView->dateNavigator()->selectMonth(); 343 mMainView->dateNavigator()->selectMonth();
337 mMainView->setBlockShowDates( false ); 344 mMainView->setBlockShowDates( false );
338 } 345 }
339 showView(mListView, KOPrefs::instance()->mFullViewTodo); 346 showView(mListView, KOPrefs::instance()->mFullViewTodo);
340 //mFlagShowNextxDays = temp; 347 //mFlagShowNextxDays = temp;
341} 348}
342 349
343void KOViewManager::showAgendaView( bool fullScreen ) 350void KOViewManager::showAgendaView( bool fullScreen )
344{ 351{
345 352
346 mMainView->dialogManager()->hideSearchDialog(); 353 mMainView->dialogManager()->hideSearchDialog();
347 // qDebug("KOViewManager::showAgendaView "); 354 // qDebug("KOViewManager::showAgendaView ");
348 bool full; 355 bool full;
349 full = fullScreen; 356 full = fullScreen;
350 if (!mAgendaView) { 357 if (!mAgendaView) {
351 full = false; 358 full = false;
352 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 359 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
353 addView(mAgendaView); 360 addView(mAgendaView);
354#ifndef DESKTOP_VERSION 361#ifndef DESKTOP_VERSION
355 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 362 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
356#endif 363#endif
357 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 364 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
358 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 365 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
359 366
360 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 367 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
361 368
362 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 369 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
363 370
364 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 371 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
365 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 372 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
366 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 373 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
367 mMainView, SLOT(newEvent(QDateTime))); 374 mMainView, SLOT(newEvent(QDateTime)));
368 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 375 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
369 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 376 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
370 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 377 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
371 mMainView, SLOT(newEvent(QDate))); 378 mMainView, SLOT(newEvent(QDate)));
372 379
373 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 380 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
374 mMainView, SLOT(editIncidence(Incidence *))); 381 mMainView, SLOT(editIncidence(Incidence *)));
375 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 382 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
376 mMainView, SLOT(showIncidence(Incidence *))); 383 mMainView, SLOT(showIncidence(Incidence *)));
377 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 384 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
378 mMainView, SLOT(deleteIncidence(Incidence *))); 385 mMainView, SLOT(deleteIncidence(Incidence *)));
379 386
380 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 387 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
381 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 388 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
382 389
383 connect(mAgendaView, SIGNAL( toggleExpand() ), 390 connect(mAgendaView, SIGNAL( toggleExpand() ),
384 mMainView, SLOT( toggleExpand() ) ); 391 mMainView, SLOT( toggleExpand() ) );
385 392
386 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 393 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
387 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 394 mAgendaView, SLOT( setExpandedButton( bool ) ) );
388 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 395 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
389 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 396 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
390 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 397 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
391 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 398 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
392 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 399 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
393 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 400 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
394 SLOT( updateTodo( Todo *, int ) ) ); 401 SLOT( updateTodo( Todo *, int ) ) );
395 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 402 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
396 mMainView, SIGNAL( todoModified( Todo *, int ))); 403 mMainView, SIGNAL( todoModified( Todo *, int )));
397 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 404 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
398 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 405 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
399 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 406 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
400 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 407 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
401 mAgendaView->readSettings(); 408 mAgendaView->readSettings();
402 mAgendaView->updateConfig(); 409 mAgendaView->updateConfig();
403 } 410 }
404 411
405 showView( mAgendaView, full); 412 showView( mAgendaView, full);
406 413
407} 414}
408 415
409void KOViewManager::showDayView() 416void KOViewManager::showDayView()
410{ 417{
411 mFlagShowNextxDays = false; 418 mFlagShowNextxDays = false;
412 globalFlagBlockLabel = 1; 419 globalFlagBlockLabel = 1;
413 globalFlagBlockAgenda = 1; 420 globalFlagBlockAgenda = 1;
414 if ( mCurrentAgendaView != 1 ) 421 if ( mCurrentAgendaView != 1 )
415 mCurrentAgendaView = -1; 422 mCurrentAgendaView = -1;
416 showAgendaView(); 423 showAgendaView();
417 qApp->processEvents(); 424 qApp->processEvents();
418 globalFlagBlockAgenda = 2; 425 globalFlagBlockAgenda = 2;
419 globalFlagBlockLabel = 0; 426 globalFlagBlockLabel = 0;
420 mMainView->dateNavigator()->selectDates( 1 ); 427 mMainView->dateNavigator()->selectDates( 1 );
421 mCurrentAgendaView = 1 ; 428 mCurrentAgendaView = 1 ;
422 429
423} 430}
424 431
425void KOViewManager::showWorkWeekView() 432void KOViewManager::showWorkWeekView()
426{ 433{
427 mFlagShowNextxDays = false; 434 mFlagShowNextxDays = false;
428 globalFlagBlockAgenda = 1; 435 globalFlagBlockAgenda = 1;
429 globalFlagBlockLabel = 1; 436 globalFlagBlockLabel = 1;
430 if ( mCurrentAgendaView != 5 ) 437 if ( mCurrentAgendaView != 5 )
431 mCurrentAgendaView = -1; 438 mCurrentAgendaView = -1;
432 showAgendaView(); 439 showAgendaView();
433 qApp->processEvents(); 440 qApp->processEvents();
434 globalFlagBlockAgenda = 2; 441 globalFlagBlockAgenda = 2;
435 globalFlagBlockLabel = 0; 442 globalFlagBlockLabel = 0;
436 mMainView->dateNavigator()->selectWorkWeek(); 443 mMainView->dateNavigator()->selectWorkWeek();
437 mCurrentAgendaView = 5 ; 444 mCurrentAgendaView = 5 ;
438 445
439} 446}
440 447
441void KOViewManager::showWeekView() 448void KOViewManager::showWeekView()
442{ 449{
443 /* 450 /*
444 globalFlagBlockAgenda = 2; 451 globalFlagBlockAgenda = 2;
445 qDebug("4globalFlagBlockAgenda = 2; "); 452 qDebug("4globalFlagBlockAgenda = 2; ");
446 //globalFlagBlockPainting = true; 453 //globalFlagBlockPainting = true;
447 mMainView->dateNavigator()->selectWeek(); 454 mMainView->dateNavigator()->selectWeek();
448 showAgendaView(); 455 showAgendaView();
449 */ 456 */
450 457
451 458
452 mFlagShowNextxDays = false; 459 mFlagShowNextxDays = false;
453 globalFlagBlockAgenda = 1; 460 globalFlagBlockAgenda = 1;
454 globalFlagBlockLabel = 1; 461 globalFlagBlockLabel = 1;
455 if ( mCurrentAgendaView != 7 ) 462 if ( mCurrentAgendaView != 7 )
456 mCurrentAgendaView = -1; 463 mCurrentAgendaView = -1;
457 showAgendaView(); 464 showAgendaView();
458 qApp->processEvents(); 465 qApp->processEvents();
459 globalFlagBlockAgenda = 2; 466 globalFlagBlockAgenda = 2;
460 globalFlagBlockLabel = 0; 467 globalFlagBlockLabel = 0;
461 mMainView->dateNavigator()->selectWeek(); 468 mMainView->dateNavigator()->selectWeek();
462 mCurrentAgendaView = 7 ; 469 mCurrentAgendaView = 7 ;
463} 470}
464 471
465void KOViewManager::showNextXView() 472void KOViewManager::showNextXView()
466{ 473{
467 474
468 globalFlagBlockAgenda = 1; 475 globalFlagBlockAgenda = 1;
469 if ( mCurrentAgendaView != 3 ) 476 if ( mCurrentAgendaView != 3 )
470 mCurrentAgendaView = -1; 477 mCurrentAgendaView = -1;
471 showAgendaView(KOPrefs::instance()->mFullViewMonth); 478 showAgendaView(KOPrefs::instance()->mFullViewMonth);
472 globalFlagBlockAgenda = 2; 479 globalFlagBlockAgenda = 2;
473 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 480 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
474 KOPrefs::instance()->mNextXDays ); 481 KOPrefs::instance()->mNextXDays );
475 mFlagShowNextxDays = true; 482 mFlagShowNextxDays = true;
476 mCurrentAgendaView = 3 ; 483 mCurrentAgendaView = 3 ;
477} 484}
478bool KOViewManager::showsNextDays() 485bool KOViewManager::showsNextDays()
479{ 486{
480 return mFlagShowNextxDays; 487 return mFlagShowNextxDays;
481} 488}
482void KOViewManager::showMonthView() 489void KOViewManager::showMonthView()
483{ 490{
484 if (!mMonthView) { 491 if (!mMonthView) {
485 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 492 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
486 493
487 addView(mMonthView); 494 addView(mMonthView);
488 // mMonthView->show(); 495 // mMonthView->show();
489 // SIGNALS/SLOTS FOR MONTH VIEW 496 // SIGNALS/SLOTS FOR MONTH VIEW
490 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 497 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
491 mMainView, SLOT(newEvent(QDateTime))); 498 mMainView, SLOT(newEvent(QDateTime)));
492 499
493 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 500 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
494 mMainView, SLOT(showIncidence(Incidence *))); 501 mMainView, SLOT(showIncidence(Incidence *)));
495 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 502 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
496 mMainView, SLOT(editIncidence(Incidence *))); 503 mMainView, SLOT(editIncidence(Incidence *)));
497 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 504 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
498 mMainView, SLOT(deleteIncidence(Incidence *))); 505 mMainView, SLOT(deleteIncidence(Incidence *)));
499 506
500 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 507 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
501 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 508 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
502 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 509 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
503 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 510 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
504 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 511 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
505 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 512 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
506 513
507 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 514 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
508 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 515 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
509 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 516 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
510 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 517 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
511 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 518 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
512 mMainView, SLOT ( selectWeekNum( int ) ) ); 519 mMainView, SLOT ( selectWeekNum( int ) ) );
513 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 520 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
514 mMainView, SLOT ( showDay( QDate ) ) ); 521 mMainView, SLOT ( showDay( QDate ) ) );
515 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 522 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
516 connect( mMonthView, SIGNAL(nextMonth() ), 523 connect( mMonthView, SIGNAL(nextMonth() ),
517 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); 524 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) );
518 connect( mMonthView, SIGNAL(prevMonth() ), 525 connect( mMonthView, SIGNAL(prevMonth() ),
519 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 526 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) );
520 mMonthView->updateConfig(); 527 mMonthView->updateConfig();
521 } 528 }
522 529