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