-rw-r--r-- | korganizer/koagendaview.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 8d32152..95388ef 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp | |||
@@ -316,548 +316,550 @@ void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) | |||
316 | mMouseDownY = e->pos().y(); | 316 | mMouseDownY = e->pos().y(); |
317 | mOrgCap = topLevelWidget()->caption(); | 317 | mOrgCap = topLevelWidget()->caption(); |
318 | } | 318 | } |
319 | 319 | ||
320 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) | 320 | void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) |
321 | { | 321 | { |
322 | int diff = mMouseDownY - e->pos().y(); | 322 | int diff = mMouseDownY - e->pos().y(); |
323 | if ( diff < 10 && diff > -10 ) | 323 | if ( diff < 10 && diff > -10 ) |
324 | return; | 324 | return; |
325 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; | 325 | int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; |
326 | if ( tSize < 4 ) | 326 | if ( tSize < 4 ) |
327 | tSize = 4; | 327 | tSize = 4; |
328 | if ( tSize > 22 ) | 328 | if ( tSize > 22 ) |
329 | tSize = 22; | 329 | tSize = 22; |
330 | tSize = (tSize-2)/2; | 330 | tSize = (tSize-2)/2; |
331 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); | 331 | topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); |
332 | 332 | ||
333 | } | 333 | } |
334 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) | 334 | void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) |
335 | { | 335 | { |
336 | topLevelWidget()->setCaption( mOrgCap ); | 336 | topLevelWidget()->setCaption( mOrgCap ); |
337 | int diff = mMouseDownY - e->pos().y(); | 337 | int diff = mMouseDownY - e->pos().y(); |
338 | if ( diff < 10 && diff > -10 ) | 338 | if ( diff < 10 && diff > -10 ) |
339 | return; | 339 | return; |
340 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); | 340 | int tSize = KOPrefs::instance()->mHourSize + (diff/10); |
341 | if ( tSize < 4 ) | 341 | if ( tSize < 4 ) |
342 | tSize = 4; | 342 | tSize = 4; |
343 | if ( tSize > 22 ) | 343 | if ( tSize > 22 ) |
344 | tSize = 22; | 344 | tSize = 22; |
345 | tSize = (tSize/2)*2; | 345 | tSize = (tSize/2)*2; |
346 | if ( tSize == KOPrefs::instance()->mHourSize ) | 346 | if ( tSize == KOPrefs::instance()->mHourSize ) |
347 | return; | 347 | return; |
348 | KOPrefs::instance()->mHourSize = tSize; | 348 | KOPrefs::instance()->mHourSize = tSize; |
349 | emit scaleChanged(); | 349 | emit scaleChanged(); |
350 | } | 350 | } |
351 | 351 | ||
352 | /** This is called in response to repaint() */ | 352 | /** This is called in response to repaint() */ |
353 | void TimeLabels::paintEvent(QPaintEvent*) | 353 | void TimeLabels::paintEvent(QPaintEvent*) |
354 | { | 354 | { |
355 | 355 | ||
356 | // kdDebug() << "paintevent..." << endl; | 356 | // kdDebug() << "paintevent..." << endl; |
357 | // this is another hack! | 357 | // this is another hack! |
358 | // QPainter painter(this); | 358 | // QPainter painter(this); |
359 | //QString c | 359 | //QString c |
360 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); | 360 | repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); |
361 | } | 361 | } |
362 | 362 | ||
363 | //////////////////////////////////////////////////////////////////////////// | 363 | //////////////////////////////////////////////////////////////////////////// |
364 | 364 | ||
365 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) | 365 | EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) |
366 | : QFrame(parent,name) | 366 | : QFrame(parent,name) |
367 | { | 367 | { |
368 | mColumns = 1; | 368 | mColumns = 1; |
369 | mTopBox = 0; | 369 | mTopBox = 0; |
370 | mLocation = loc; | 370 | mLocation = loc; |
371 | mTopLayout = 0; | 371 | mTopLayout = 0; |
372 | mPaintWidget = 0; | 372 | mPaintWidget = 0; |
373 | mXOffset = 0; | 373 | mXOffset = 0; |
374 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); | 374 | if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); |
375 | else mPixmap = SmallIcon("1downarrow"); | 375 | else mPixmap = SmallIcon("1downarrow"); |
376 | mEnabled.resize(mColumns); | 376 | mEnabled.resize(mColumns); |
377 | mEnabled.fill( false ); | 377 | mEnabled.fill( false ); |
378 | setMinimumHeight(mPixmap.height()); | 378 | setMinimumHeight(mPixmap.height()); |
379 | } | 379 | } |
380 | 380 | ||
381 | EventIndicator::~EventIndicator() | 381 | EventIndicator::~EventIndicator() |
382 | { | 382 | { |
383 | } | 383 | } |
384 | 384 | ||
385 | void EventIndicator::drawContents(QPainter *p) | 385 | void EventIndicator::drawContents(QPainter *p) |
386 | { | 386 | { |
387 | 387 | ||
388 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; | 388 | // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; |
389 | KDGanttSplitterHandle* han = 0; | 389 | KDGanttSplitterHandle* han = 0; |
390 | if ( mPaintWidget ) | 390 | if ( mPaintWidget ) |
391 | han = mPaintWidget->firstHandle(); | 391 | han = mPaintWidget->firstHandle(); |
392 | if ( ! han ) { | 392 | if ( ! han ) { |
393 | int i; | 393 | int i; |
394 | for(i=0;i<mColumns;++i) { | 394 | for(i=0;i<mColumns;++i) { |
395 | if (mEnabled[i]) { | 395 | if (mEnabled[i]) { |
396 | int cellWidth = contentsRect().right()/mColumns; | 396 | int cellWidth = contentsRect().right()/mColumns; |
397 | int xOffset = KOGlobals::self()->reverseLayout() ? | 397 | int xOffset = KOGlobals::self()->reverseLayout() ? |
398 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : | 398 | (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : |
399 | i*cellWidth + (cellWidth -mPixmap.width()) /2; | 399 | i*cellWidth + (cellWidth -mPixmap.width()) /2; |
400 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); | 400 | p->drawPixmap(QPoint(1+xOffset,0),mPixmap); |
401 | } | 401 | } |
402 | } | 402 | } |
403 | } else { | 403 | } else { |
404 | han->repaint(); | 404 | han->repaint(); |
405 | //mPaintWidget->setBackgroundColor( red ); | 405 | //mPaintWidget->setBackgroundColor( red ); |
406 | 406 | ||
407 | QPainter pa( han ); | 407 | QPainter pa( han ); |
408 | int i; | 408 | int i; |
409 | bool setColor = false; | 409 | bool setColor = false; |
410 | for(i=0;i<mColumns;++i) { | 410 | for(i=0;i<mColumns;++i) { |
411 | if (mEnabled[i]) { | 411 | if (mEnabled[i]) { |
412 | setColor = true; | 412 | setColor = true; |
413 | 413 | ||
414 | int cellWidth = contentsRect().right()/mColumns; | 414 | int cellWidth = contentsRect().right()/mColumns; |
415 | int xOffset = KOGlobals::self()->reverseLayout() ? | 415 | int xOffset = KOGlobals::self()->reverseLayout() ? |
416 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : | 416 | (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : |
417 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; | 417 | i*cellWidth + cellWidth/2 -mPixmap.width()/2; |
418 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); | 418 | pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); |
419 | //qDebug("222draw pix %d ",xOffset ); | 419 | //qDebug("222draw pix %d ",xOffset ); |
420 | 420 | ||
421 | } | 421 | } |
422 | 422 | ||
423 | } | 423 | } |
424 | pa.end(); | 424 | pa.end(); |
425 | 425 | ||
426 | } | 426 | } |
427 | } | 427 | } |
428 | 428 | ||
429 | void EventIndicator::setXOffset( int x ) | 429 | void EventIndicator::setXOffset( int x ) |
430 | { | 430 | { |
431 | mXOffset = x; | 431 | mXOffset = x; |
432 | } | 432 | } |
433 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) | 433 | void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) |
434 | { | 434 | { |
435 | mPaintWidget = w; | 435 | mPaintWidget = w; |
436 | setMaximumHeight(0); | 436 | setMaximumHeight(0); |
437 | setMinimumHeight(0); | 437 | setMinimumHeight(0); |
438 | } | 438 | } |
439 | void EventIndicator::changeColumns(int columns) | 439 | void EventIndicator::changeColumns(int columns) |
440 | { | 440 | { |
441 | mColumns = columns; | 441 | mColumns = columns; |
442 | mEnabled.resize(mColumns); | 442 | mEnabled.resize(mColumns); |
443 | 443 | ||
444 | update(); | 444 | update(); |
445 | } | 445 | } |
446 | 446 | ||
447 | void EventIndicator::enableColumn(int column, bool enable) | 447 | void EventIndicator::enableColumn(int column, bool enable) |
448 | { | 448 | { |
449 | mEnabled[column] = enable; | 449 | mEnabled[column] = enable; |
450 | } | 450 | } |
451 | 451 | ||
452 | 452 | ||
453 | //////////////////////////////////////////////////////////////////////////// | 453 | //////////////////////////////////////////////////////////////////////////// |
454 | //////////////////////////////////////////////////////////////////////////// | 454 | //////////////////////////////////////////////////////////////////////////// |
455 | //////////////////////////////////////////////////////////////////////////// | 455 | //////////////////////////////////////////////////////////////////////////// |
456 | 456 | ||
457 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : | 457 | KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : |
458 | KOEventView (cal,parent,name) | 458 | KOEventView (cal,parent,name) |
459 | { | 459 | { |
460 | mBlockUpdating = true; | 460 | mBlockUpdating = true; |
461 | mStartHour = 8; | 461 | mStartHour = 8; |
462 | mSelectedDates.append(QDate::currentDate()); | 462 | mSelectedDates.append(QDate::currentDate()); |
463 | 463 | ||
464 | mLayoutDayLabels = 0; | 464 | mLayoutDayLabels = 0; |
465 | mDayLabelsFrame = 0; | 465 | mDayLabelsFrame = 0; |
466 | mDayLabels = 0; | 466 | mDayLabels = 0; |
467 | bool isRTL = KOGlobals::self()->reverseLayout(); | 467 | bool isRTL = KOGlobals::self()->reverseLayout(); |
468 | QPixmap expandPix; | 468 | QPixmap expandPix; |
469 | if ( KOPrefs::instance()->mVerticalScreen ) { | 469 | if ( KOPrefs::instance()->mVerticalScreen ) { |
470 | expandPix = SmallIcon( "1updownarrow" ); | 470 | expandPix = SmallIcon( "1updownarrow" ); |
471 | } else { | 471 | } else { |
472 | expandPix = SmallIcon("1leftrightarrow" ); | 472 | expandPix = SmallIcon("1leftrightarrow" ); |
473 | } | 473 | } |
474 | 474 | ||
475 | QBoxLayout *topLayout = new QVBoxLayout(this); | 475 | QBoxLayout *topLayout = new QVBoxLayout(this); |
476 | 476 | ||
477 | // Create day name labels for agenda columns | 477 | // Create day name labels for agenda columns |
478 | // Create agenda splitter | 478 | // Create agenda splitter |
479 | 479 | ||
480 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); | 480 | mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); |
481 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); | 481 | mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); |
482 | topLayout->addWidget( mSplitterAgenda ); | 482 | topLayout->addWidget( mSplitterAgenda ); |
483 | mAllDayFrame = new QHBox(mSplitterAgenda); | 483 | mAllDayFrame = new QHBox(mSplitterAgenda); |
484 | mAllDayFrame->setFocusPolicy(NoFocus); | 484 | mAllDayFrame->setFocusPolicy(NoFocus); |
485 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); | 485 | QWidget *agendaFrame = new QWidget(mSplitterAgenda); |
486 | agendaFrame->setFocusPolicy(NoFocus); | 486 | agendaFrame->setFocusPolicy(NoFocus); |
487 | 487 | ||
488 | // Create all-day agenda widget | 488 | // Create all-day agenda widget |
489 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); | 489 | mDummyAllDayLeft = new QVBox( mAllDayFrame ); |
490 | 490 | ||
491 | mExpandButton = new QPushButton(mDummyAllDayLeft); | 491 | mExpandButton = new QPushButton(mDummyAllDayLeft); |
492 | mExpandButton->setPixmap( expandPix ); | 492 | mExpandButton->setPixmap( expandPix ); |
493 | int widebut = mExpandButton->sizeHint().width()+4; | 493 | int widebut = mExpandButton->sizeHint().width()+4; |
494 | int heibut = mExpandButton->sizeHint().height()+4; | 494 | int heibut = mExpandButton->sizeHint().height()+4; |
495 | if ( heibut > widebut ) | 495 | if ( heibut > widebut ) |
496 | widebut = heibut ; | 496 | widebut = heibut ; |
497 | 497 | ||
498 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, | 498 | //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, |
499 | // QSizePolicy::Fixed ) ); | 499 | // QSizePolicy::Fixed ) ); |
500 | mExpandButton->setFixedSize( widebut, widebut); | 500 | mExpandButton->setFixedSize( widebut, widebut); |
501 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); | 501 | connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); |
502 | mExpandButton->setFocusPolicy(NoFocus); | 502 | mExpandButton->setFocusPolicy(NoFocus); |
503 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); | 503 | mAllDayAgenda = new KOAgenda(1,mAllDayFrame); |
504 | mAllDayAgenda->setFocusPolicy(NoFocus); | 504 | mAllDayAgenda->setFocusPolicy(NoFocus); |
505 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); | 505 | QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); |
506 | 506 | ||
507 | // Create event context menu for all day agenda | 507 | // Create event context menu for all day agenda |
508 | mAllDayAgendaPopup = eventPopup(); | 508 | //mAllDayAgendaPopup = eventPopup(); |
509 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | ||
510 | mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | ||
511 | 509 | ||
512 | // Create agenda frame | 510 | // Create agenda frame |
513 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); | 511 | QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); |
514 | // QHBox *agendaFrame = new QHBox(splitterAgenda); | 512 | // QHBox *agendaFrame = new QHBox(splitterAgenda); |
515 | 513 | ||
516 | // create event indicator bars | 514 | // create event indicator bars |
517 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); | 515 | mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); |
518 | #ifndef DESKTOP_VERSION | 516 | #ifndef DESKTOP_VERSION |
519 | // FIX | 517 | // FIX |
520 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); | 518 | mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); |
521 | #endif | 519 | #endif |
522 | mDayLabelsFrame = new QHBox(agendaFrame); | 520 | mDayLabelsFrame = new QHBox(agendaFrame); |
523 | //topLayout->addWidget(mDayLabelsFrame); | 521 | //topLayout->addWidget(mDayLabelsFrame); |
524 | mDayLabels = new QFrame (mDayLabelsFrame); | 522 | mDayLabels = new QFrame (mDayLabelsFrame); |
525 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); | 523 | mLayoutDayLabels = new QHBoxLayout(mDayLabels); |
526 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); | 524 | agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); |
527 | agendaLayout->addWidget(mEventIndicatorTop,1,1); | 525 | agendaLayout->addWidget(mEventIndicatorTop,1,1); |
528 | 526 | ||
529 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, | 527 | mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, |
530 | agendaFrame); | 528 | agendaFrame); |
531 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); | 529 | agendaLayout->addWidget(mEventIndicatorBottom,3,1); |
532 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); | 530 | QWidget *dummyAgendaRight = new QWidget(agendaFrame); |
533 | agendaLayout->addWidget(dummyAgendaRight,1,2); | 531 | agendaLayout->addWidget(dummyAgendaRight,1,2); |
534 | 532 | ||
535 | // Create time labels | 533 | // Create time labels |
536 | mTimeLabels = new TimeLabels(24,agendaFrame); | 534 | mTimeLabels = new TimeLabels(24,agendaFrame); |
537 | agendaLayout->addWidget(mTimeLabels,2,0); | 535 | agendaLayout->addWidget(mTimeLabels,2,0); |
538 | connect(mTimeLabels,SIGNAL( scaleChanged()), | 536 | connect(mTimeLabels,SIGNAL( scaleChanged()), |
539 | this,SLOT(updateConfig())); | 537 | this,SLOT(updateConfig())); |
540 | 538 | ||
541 | // Create agenda | 539 | // Create agenda |
542 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); | 540 | mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); |
543 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); | 541 | agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); |
544 | agendaLayout->setColStretch(1,1); | 542 | agendaLayout->setColStretch(1,1); |
545 | mAgenda->setFocusPolicy(NoFocus); | 543 | mAgenda->setFocusPolicy(NoFocus); |
546 | // Create event context menu for agenda | 544 | // Create event context menu for agenda |
547 | mAgendaPopup = eventPopup(); | 545 | mAllAgendaPopup = eventPopup(); |
548 | 546 | ||
549 | mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), | 547 | mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), |
550 | i18n("Toggle Alarm"),mAgenda, | 548 | i18n("Toggle Alarm"),mAgenda, |
551 | SLOT(popupAlarm()),true); | 549 | SLOT(popupAlarm()),true); |
552 | 550 | ||
553 | 551 | ||
554 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | 552 | connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), |
555 | mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | 553 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); |
556 | 554 | ||
555 | connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), | ||
556 | mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); | ||
557 | mAgenda->setPopup( mAllAgendaPopup ); | ||
558 | mAllDayAgenda->setPopup( mAllAgendaPopup ); | ||
557 | // make connections between dependent widgets | 559 | // make connections between dependent widgets |
558 | mTimeLabels->setAgenda(mAgenda); | 560 | mTimeLabels->setAgenda(mAgenda); |
559 | 561 | ||
560 | // Update widgets to reflect user preferences | 562 | // Update widgets to reflect user preferences |
561 | // updateConfig(); | 563 | // updateConfig(); |
562 | 564 | ||
563 | // createDayLabels(); | 565 | // createDayLabels(); |
564 | 566 | ||
565 | // these blank widgets make the All Day Event box line up with the agenda | 567 | // these blank widgets make the All Day Event box line up with the agenda |
566 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 568 | dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
567 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); | 569 | dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); |
568 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); | 570 | mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); |
569 | 571 | ||
570 | // Scrolling | 572 | // Scrolling |
571 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), | 573 | connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), |
572 | mTimeLabels, SLOT(positionChanged())); | 574 | mTimeLabels, SLOT(positionChanged())); |
573 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), | 575 | connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), |
574 | SLOT(setContentsPos(int))); | 576 | SLOT(setContentsPos(int))); |
575 | 577 | ||
576 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); | 578 | connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); |
577 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); | 579 | connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); |
578 | 580 | ||
579 | // Create/Show/Edit/Delete Event | 581 | // Create/Show/Edit/Delete Event |
580 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), | 582 | connect(mAgenda,SIGNAL(newEventSignal(int,int)), |
581 | SLOT(newEvent(int,int))); | 583 | SLOT(newEvent(int,int))); |
582 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), | 584 | connect(mAgenda,SIGNAL(newTodoSignal(int,int)), |
583 | SLOT(newTodo(int,int))); | 585 | SLOT(newTodo(int,int))); |
584 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 586 | connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
585 | SLOT(newEvent(int,int,int,int))); | 587 | SLOT(newEvent(int,int,int,int))); |
586 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), | 588 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), |
587 | SLOT(newEventAllDay(int,int))); | 589 | SLOT(newEventAllDay(int,int))); |
588 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), | 590 | connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), |
589 | SLOT(newTodoAllDay(int,int))); | 591 | SLOT(newTodoAllDay(int,int))); |
590 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), | 592 | connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), |
591 | SLOT(newEventAllDay(int,int))); | 593 | SLOT(newEventAllDay(int,int))); |
592 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 594 | connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
593 | SLOT(newTimeSpanSelected(int,int,int,int))); | 595 | SLOT(newTimeSpanSelected(int,int,int,int))); |
594 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), | 596 | connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), |
595 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); | 597 | SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); |
596 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 598 | connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
597 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); | 599 | connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); |
598 | 600 | ||
599 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 601 | connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
600 | SIGNAL(editIncidenceSignal(Incidence *))); | 602 | SIGNAL(editIncidenceSignal(Incidence *))); |
601 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), | 603 | connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), |
602 | SIGNAL(editIncidenceSignal(Incidence *))); | 604 | SIGNAL(editIncidenceSignal(Incidence *))); |
603 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 605 | connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
604 | SIGNAL(showIncidenceSignal(Incidence *))); | 606 | SIGNAL(showIncidenceSignal(Incidence *))); |
605 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), | 607 | connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), |
606 | SIGNAL(showIncidenceSignal(Incidence *))); | 608 | SIGNAL(showIncidenceSignal(Incidence *))); |
607 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 609 | connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
608 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 610 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
609 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), | 611 | connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), |
610 | SIGNAL(deleteIncidenceSignal(Incidence *))); | 612 | SIGNAL(deleteIncidenceSignal(Incidence *))); |
611 | 613 | ||
612 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 614 | connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
613 | SLOT(updateEventDates(KOAgendaItem *, int ))); | 615 | SLOT(updateEventDates(KOAgendaItem *, int ))); |
614 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), | 616 | connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), |
615 | SLOT(updateEventDates(KOAgendaItem *, int))); | 617 | SLOT(updateEventDates(KOAgendaItem *, int))); |
616 | 618 | ||
617 | // event indicator update | 619 | // event indicator update |
618 | connect(mAgenda,SIGNAL(lowerYChanged(int)), | 620 | connect(mAgenda,SIGNAL(lowerYChanged(int)), |
619 | SLOT(updateEventIndicatorTop(int))); | 621 | SLOT(updateEventIndicatorTop(int))); |
620 | connect(mAgenda,SIGNAL(upperYChanged(int)), | 622 | connect(mAgenda,SIGNAL(upperYChanged(int)), |
621 | SLOT(updateEventIndicatorBottom(int))); | 623 | SLOT(updateEventIndicatorBottom(int))); |
622 | // drag signals | 624 | // drag signals |
623 | /* | 625 | /* |
624 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), | 626 | connect(mAgenda,SIGNAL(startDragSignal(Event *)), |
625 | SLOT(startDrag(Event *))); | 627 | SLOT(startDrag(Event *))); |
626 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), | 628 | connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), |
627 | SLOT(startDrag(Event *))); | 629 | SLOT(startDrag(Event *))); |
628 | */ | 630 | */ |
629 | // synchronize selections | 631 | // synchronize selections |
630 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 632 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
631 | mAllDayAgenda, SLOT( deselectItem() ) ); | 633 | mAllDayAgenda, SLOT( deselectItem() ) ); |
632 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 634 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
633 | mAgenda, SLOT( deselectItem() ) ); | 635 | mAgenda, SLOT( deselectItem() ) ); |
634 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 636 | connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
635 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 637 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
636 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), | 638 | connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), |
637 | SIGNAL( incidenceSelected( Incidence * ) ) ); | 639 | SIGNAL( incidenceSelected( Incidence * ) ) ); |
638 | connect( mAgenda, SIGNAL( resizedSignal() ), | 640 | connect( mAgenda, SIGNAL( resizedSignal() ), |
639 | SLOT( updateConfig( ) ) ); | 641 | SLOT( updateConfig( ) ) ); |
640 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), | 642 | connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), |
641 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); | 643 | SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); |
642 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), | 644 | connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), |
643 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); | 645 | SLOT( addToCalSlot(Incidence * , Incidence *) ) ); |
644 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 646 | // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
645 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); | 647 | //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); |
646 | 648 | ||
647 | 649 | ||
648 | } | 650 | } |
649 | 651 | ||
650 | void KOAgendaView::toggleAllDay() | 652 | void KOAgendaView::toggleAllDay() |
651 | { | 653 | { |
652 | if ( mSplitterAgenda->firstHandle() ) | 654 | if ( mSplitterAgenda->firstHandle() ) |
653 | mSplitterAgenda->firstHandle()->toggle(); | 655 | mSplitterAgenda->firstHandle()->toggle(); |
654 | } | 656 | } |
655 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) | 657 | void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) |
656 | { | 658 | { |
657 | calendar()->addIncidence( inc ); | 659 | calendar()->addIncidence( inc ); |
658 | 660 | ||
659 | if ( incOld ) { | 661 | if ( incOld ) { |
660 | if ( incOld->type() == "Todo" ) | 662 | if ( incOld->type() == "Todo" ) |
661 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); | 663 | emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); |
662 | else | 664 | else |
663 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); | 665 | emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); |
664 | } | 666 | } |
665 | 667 | ||
666 | } | 668 | } |
667 | 669 | ||
668 | KOAgendaView::~KOAgendaView() | 670 | KOAgendaView::~KOAgendaView() |
669 | { | 671 | { |
670 | delete mAgendaPopup; | 672 | delete mAllAgendaPopup; |
671 | delete mAllDayAgendaPopup; | 673 | //delete mAllDayAgendaPopup; |
672 | delete KOAgendaItem::paintPix(); | 674 | delete KOAgendaItem::paintPix(); |
673 | delete KOAgendaItem::paintPixSel(); | 675 | delete KOAgendaItem::paintPixSel(); |
674 | } | 676 | } |
675 | void KOAgendaView::resizeEvent( QResizeEvent* e ) | 677 | void KOAgendaView::resizeEvent( QResizeEvent* e ) |
676 | { | 678 | { |
677 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); | 679 | //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); |
678 | bool uc = false; | 680 | bool uc = false; |
679 | int ow = e->oldSize().width(); | 681 | int ow = e->oldSize().width(); |
680 | int oh = e->oldSize().height(); | 682 | int oh = e->oldSize().height(); |
681 | int w = e->size().width(); | 683 | int w = e->size().width(); |
682 | int h = e->size().height(); | 684 | int h = e->size().height(); |
683 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { | 685 | if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { |
684 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) | 686 | if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) |
685 | uc = true; | 687 | uc = true; |
686 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); | 688 | //qDebug("view changed %d %d %d %d ", ow, oh , w , h); |
687 | } | 689 | } |
688 | mUpcomingWidth = e->size().width() ; | 690 | mUpcomingWidth = e->size().width() ; |
689 | if ( mBlockUpdating || uc ) { | 691 | if ( mBlockUpdating || uc ) { |
690 | mBlockUpdating = false; | 692 | mBlockUpdating = false; |
691 | //mAgenda->setMinimumSize(800 , 600 ); | 693 | //mAgenda->setMinimumSize(800 , 600 ); |
692 | //qDebug("mAgenda->resize+++++++++++++++ "); | 694 | //qDebug("mAgenda->resize+++++++++++++++ "); |
693 | updateConfig(); | 695 | updateConfig(); |
694 | //qDebug("KOAgendaView::Updating now possible "); | 696 | //qDebug("KOAgendaView::Updating now possible "); |
695 | } else | 697 | } else |
696 | createDayLabels(); | 698 | createDayLabels(); |
697 | //qDebug("resizeEvent end "); | 699 | //qDebug("resizeEvent end "); |
698 | 700 | ||
699 | } | 701 | } |
700 | void KOAgendaView::slotDaylabelClicked( int num ) | 702 | void KOAgendaView::slotDaylabelClicked( int num ) |
701 | { | 703 | { |
702 | 704 | ||
703 | QDate firstDate = mSelectedDates.first(); | 705 | QDate firstDate = mSelectedDates.first(); |
704 | if ( num == -1 ) | 706 | if ( num == -1 ) |
705 | emit showDateView( 6, firstDate ); | 707 | emit showDateView( 6, firstDate ); |
706 | else if (num >= 0 ) { | 708 | else if (num >= 0 ) { |
707 | if ( mSelectedDates.count() == 1) | 709 | if ( mSelectedDates.count() == 1) |
708 | emit showDateView( 9, firstDate.addDays( num ) ); | 710 | emit showDateView( 9, firstDate.addDays( num ) ); |
709 | else | 711 | else |
710 | emit showDateView( 3, firstDate.addDays( num ) ); | 712 | emit showDateView( 3, firstDate.addDays( num ) ); |
711 | } | 713 | } |
712 | else | 714 | else |
713 | showDateView( 10, firstDate.addDays(1) ); | 715 | showDateView( 10, firstDate.addDays(1) ); |
714 | } | 716 | } |
715 | 717 | ||
716 | KOAgendaButton* KOAgendaView::getNewDaylabel() | 718 | KOAgendaButton* KOAgendaView::getNewDaylabel() |
717 | { | 719 | { |
718 | 720 | ||
719 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); | 721 | KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); |
720 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); | 722 | connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); |
721 | mDayLabelsList.append( dayLabel ); | 723 | mDayLabelsList.append( dayLabel ); |
722 | mLayoutDayLabels->addWidget(dayLabel); | 724 | mLayoutDayLabels->addWidget(dayLabel); |
723 | return dayLabel ; | 725 | return dayLabel ; |
724 | } | 726 | } |
725 | 727 | ||
726 | void KOAgendaView::createDayLabels() | 728 | void KOAgendaView::createDayLabels() |
727 | { | 729 | { |
728 | 730 | ||
729 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { | 731 | if ( mBlockUpdating || globalFlagBlockLabel == 1) { |
730 | // qDebug(" KOAgendaView::createDayLabels() blocked "); | 732 | // qDebug(" KOAgendaView::createDayLabels() blocked "); |
731 | return; | 733 | return; |
732 | 734 | ||
733 | } | 735 | } |
734 | int newHight; | 736 | int newHight; |
735 | 737 | ||
736 | // ### Before deleting and recreating we could check if mSelectedDates changed... | 738 | // ### Before deleting and recreating we could check if mSelectedDates changed... |
737 | // It would remove some flickering and gain speed (since this is called by | 739 | // It would remove some flickering and gain speed (since this is called by |
738 | // each updateView() call) | 740 | // each updateView() call) |
739 | 741 | ||
740 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; | 742 | int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; |
741 | if ( QApplication::desktop()->width() <= 320 ) | 743 | if ( QApplication::desktop()->width() <= 320 ) |
742 | maxWid -= 10; | 744 | maxWid -= 10; |
743 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); | 745 | mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); |
744 | if ( maxWid < 0 ) | 746 | if ( maxWid < 0 ) |
745 | maxWid = 20; | 747 | maxWid = 20; |
746 | 748 | ||
747 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; | 749 | QFont dlf = KOPrefs::instance()->mTimeLabelsFont; |
748 | QFontMetrics fm ( dlf ); | 750 | QFontMetrics fm ( dlf ); |
749 | int selCount = mSelectedDates.count(); | 751 | int selCount = mSelectedDates.count(); |
750 | QString dayTest = "Mon 20"; | 752 | QString dayTest = "Mon 20"; |
751 | //QString dayTest = "Mon 20"; | 753 | //QString dayTest = "Mon 20"; |
752 | int wid = fm.width( dayTest ); | 754 | int wid = fm.width( dayTest ); |
753 | //maxWid -= ( selCount * 3 ); //working for QLabels | 755 | //maxWid -= ( selCount * 3 ); //working for QLabels |
754 | maxWid -= ( selCount * 3 ); //working for QPushButton | 756 | maxWid -= ( selCount * 3 ); //working for QPushButton |
755 | if ( maxWid < 0 ) | 757 | if ( maxWid < 0 ) |
756 | maxWid = 20; | 758 | maxWid = 20; |
757 | int needWid = wid * selCount; | 759 | int needWid = wid * selCount; |
758 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); | 760 | //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); |
759 | //if ( needWid > maxWid ) | 761 | //if ( needWid > maxWid ) |
760 | // qDebug("DAYLABELS TOOOOOOO BIG "); | 762 | // qDebug("DAYLABELS TOOOOOOO BIG "); |
761 | while ( needWid > maxWid ) { | 763 | while ( needWid > maxWid ) { |
762 | dayTest = dayTest.left( dayTest.length() - 1 ); | 764 | dayTest = dayTest.left( dayTest.length() - 1 ); |
763 | wid = fm.width( dayTest ); | 765 | wid = fm.width( dayTest ); |
764 | needWid = wid * selCount; | 766 | needWid = wid * selCount; |
765 | } | 767 | } |
766 | int maxLen = dayTest.length(); | 768 | int maxLen = dayTest.length(); |
767 | int fontPoint = dlf.pointSize(); | 769 | int fontPoint = dlf.pointSize(); |
768 | if ( maxLen < 2 ) { | 770 | if ( maxLen < 2 ) { |
769 | int fontPoint = dlf.pointSize(); | 771 | int fontPoint = dlf.pointSize(); |
770 | while ( fontPoint > 4 ) { | 772 | while ( fontPoint > 4 ) { |
771 | --fontPoint; | 773 | --fontPoint; |
772 | dlf.setPointSize( fontPoint ); | 774 | dlf.setPointSize( fontPoint ); |
773 | QFontMetrics f( dlf ); | 775 | QFontMetrics f( dlf ); |
774 | wid = f.width( "30" ); | 776 | wid = f.width( "30" ); |
775 | needWid = wid * selCount; | 777 | needWid = wid * selCount; |
776 | if ( needWid < maxWid ) | 778 | if ( needWid < maxWid ) |
777 | break; | 779 | break; |
778 | } | 780 | } |
779 | maxLen = 2; | 781 | maxLen = 2; |
780 | } | 782 | } |
781 | //qDebug("Max len %d ", dayTest.length() ); | 783 | //qDebug("Max len %d ", dayTest.length() ); |
782 | 784 | ||
783 | QFontMetrics tempF( dlf ); | 785 | QFontMetrics tempF( dlf ); |
784 | newHight = tempF.height(); | 786 | newHight = tempF.height(); |
785 | mDayLabels->setFont( dlf ); | 787 | mDayLabels->setFont( dlf ); |
786 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; | 788 | // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; |
787 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); | 789 | // mLayoutDayLabels->addSpacing(mTimeLabels->width()); |
788 | //mLayoutDayLabels->addSpacing( 2 ); | 790 | //mLayoutDayLabels->addSpacing( 2 ); |
789 | // QFont lFont = dlf; | 791 | // QFont lFont = dlf; |
790 | bool appendLabels = false; | 792 | bool appendLabels = false; |
791 | KOAgendaButton *dayLabel; | 793 | KOAgendaButton *dayLabel; |
792 | dayLabel = mDayLabelsList.first(); | 794 | dayLabel = mDayLabelsList.first(); |
793 | if ( !dayLabel ) { | 795 | if ( !dayLabel ) { |
794 | appendLabels = true; | 796 | appendLabels = true; |
795 | dayLabel = getNewDaylabel(); | 797 | dayLabel = getNewDaylabel(); |
796 | } | 798 | } |
797 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); | 799 | dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); |
798 | dayLabel->setFont( dlf ); | 800 | dayLabel->setFont( dlf ); |
799 | dayLabel->setNum( -1 ); | 801 | dayLabel->setNum( -1 ); |
800 | //dayLabel->setAlignment(QLabel::AlignHCenter); | 802 | //dayLabel->setAlignment(QLabel::AlignHCenter); |
801 | #if 0 | 803 | #if 0 |
802 | if ( QApplication::desktop()->width() <= 320 ) | 804 | if ( QApplication::desktop()->width() <= 320 ) |
803 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); | 805 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); |
804 | else | 806 | else |
805 | #endif | 807 | #endif |
806 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); | 808 | dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); |
807 | dayLabel->show(); | 809 | dayLabel->show(); |
808 | DateList::ConstIterator dit; | 810 | DateList::ConstIterator dit; |
809 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); | 811 | bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); |
810 | int counter = -1; | 812 | int counter = -1; |
811 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { | 813 | for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { |
812 | ++counter; | 814 | ++counter; |
813 | QDate date = *dit; | 815 | QDate date = *dit; |
814 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); | 816 | // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); |
815 | if ( ! appendLabels ) { | 817 | if ( ! appendLabels ) { |
816 | dayLabel = mDayLabelsList.next(); | 818 | dayLabel = mDayLabelsList.next(); |
817 | if ( !dayLabel ) | 819 | if ( !dayLabel ) |
818 | appendLabels = true; | 820 | appendLabels = true; |
819 | } | 821 | } |
820 | if ( appendLabels ) { | 822 | if ( appendLabels ) { |
821 | dayLabel = getNewDaylabel(); | 823 | dayLabel = getNewDaylabel(); |
822 | } | 824 | } |
823 | dayLabel->setMinimumWidth( 1 ); | 825 | dayLabel->setMinimumWidth( 1 ); |
824 | dayLabel->setMaximumWidth( 10240 ); | 826 | dayLabel->setMaximumWidth( 10240 ); |
825 | dayLabel->setFont( dlf ); | 827 | dayLabel->setFont( dlf ); |
826 | dayLabel->show(); | 828 | dayLabel->show(); |
827 | dayLabel->setAutoRepeat( false ); | 829 | dayLabel->setAutoRepeat( false ); |
828 | dayLabel->setNum( counter ); | 830 | dayLabel->setNum( counter ); |
829 | QString str; | 831 | QString str; |
830 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); | 832 | int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); |
831 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); | 833 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); |
832 | switch ( maxLen ) { | 834 | switch ( maxLen ) { |
833 | case 2: | 835 | case 2: |
834 | str = QString::number( date.day() ); | 836 | str = QString::number( date.day() ); |
835 | break; | 837 | break; |
836 | 838 | ||
837 | case 3: | 839 | case 3: |
838 | str = dayName.left( 1 ) +QString::number( date.day()); | 840 | str = dayName.left( 1 ) +QString::number( date.day()); |
839 | 841 | ||
840 | break; | 842 | break; |
841 | case 4: | 843 | case 4: |
842 | str = dayName.left( 1 ) + " " +QString::number( date.day()); | 844 | str = dayName.left( 1 ) + " " +QString::number( date.day()); |
843 | 845 | ||
844 | break; | 846 | break; |
845 | case 5: | 847 | case 5: |
846 | str = dayName.left( 2 ) + " " +QString::number( date.day()); | 848 | str = dayName.left( 2 ) + " " +QString::number( date.day()); |
847 | 849 | ||
848 | break; | 850 | break; |
849 | case 6: | 851 | case 6: |
850 | str = dayName.left( 3 ) + " " +QString::number( date.day()); | 852 | str = dayName.left( 3 ) + " " +QString::number( date.day()); |
851 | break; | 853 | break; |
852 | 854 | ||
853 | default: | 855 | default: |
854 | break; | 856 | break; |
855 | } | 857 | } |
856 | if ( oneday ) { | 858 | if ( oneday ) { |
857 | QString addString; | 859 | QString addString; |
858 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) | 860 | if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) |
859 | addString = i18n("Today"); | 861 | addString = i18n("Today"); |
860 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 862 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
861 | addString = i18n("Tomorrow"); | 863 | addString = i18n("Tomorrow"); |
862 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 864 | else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
863 | addString = i18n("Yesterday"); | 865 | addString = i18n("Yesterday"); |