summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-25 02:15:46 (UTC)
committer zautrix <zautrix>2005-03-25 02:15:46 (UTC)
commit658354b7112aff72f0fadd924c82b977d803bc27 (patch) (unidiff)
treeda728354015340c16466fbfb3c851d96d6d95196
parent7c2e130ddd194f1c4b5365af6999a27c08232f4b (diff)
downloadkdepimpi-658354b7112aff72f0fadd924c82b977d803bc27.zip
kdepimpi-658354b7112aff72f0fadd924c82b977d803bc27.tar.gz
kdepimpi-658354b7112aff72f0fadd924c82b977d803bc27.tar.bz2
fixes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/komonthview.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 8ee5bc3..050bfb9 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -267,212 +267,222 @@ void MonthViewItem::paint(QPainter *p)
267 if ( mMultiday == 1 ) { 267 if ( mMultiday == 1 ) {
268 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 268 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
269 269
270 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 270 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
271 } 271 }
272 if ( mMultiday == 3 ) { 272 if ( mMultiday == 3 ) {
273 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 273 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
274 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 274 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
275 275
276 } 276 }
277 x += sizeM/2 + 1; 277 x += sizeM/2 + 1;
278 x += sizeM + 1; 278 x += sizeM + 1;
279 } 279 }
280 280
281 if ( mIncidence->type() == "Todo" ){ 281 if ( mIncidence->type() == "Todo" ){
282 Todo* td = ( Todo* ) mIncidence; 282 Todo* td = ( Todo* ) mIncidence;
283 if ( td->isCompleted() ) { 283 if ( td->isCompleted() ) {
284 int half = size/2; 284 int half = size/2;
285 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 285 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
286 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 286 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
287 x += half+half + 4; 287 x += half+half + 4;
288 288
289 } else { 289 } else {
290 int val = td->percentComplete()/20; 290 int val = td->percentComplete()/20;
291 p->fillRect ( x+1, y-1, val ,size+2,Qt::black ); 291 p->fillRect ( x+1, y-1, val ,size+2,Qt::black );
292 p->drawRect ( x, y-1,7,size+2); 292 p->drawRect ( x, y-1,7,size+2);
293 x += size + 3; 293 x += size + 3;
294 } 294 }
295 } 295 }
296 QFontMetrics fm = p->fontMetrics(); 296 QFontMetrics fm = p->fontMetrics();
297 int yPos; 297 int yPos;
298 int pmheight = size; 298 int pmheight = size;
299 if( pmheight < fm.height() ) 299 if( pmheight < fm.height() )
300 yPos = fm.ascent() + fm.leading()/2; 300 yPos = fm.ascent() + fm.leading()/2;
301 else 301 else
302 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 302 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
303 p->setPen( palette().color( QPalette::Normal, sel ? \ 303 p->setPen( palette().color( QPalette::Normal, sel ? \
304 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 304 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
305 p->drawText( x, yPos, text() ); 305 p->drawText( x, yPos, text() );
306 if ( mIncidence->cancelled() ) { 306 if ( mIncidence->cancelled() ) {
307 int wid = fm.width( text() ); 307 int wid = fm.width( text() );
308 p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 ); 308 p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 );
309 } 309 }
310 310
311} 311}
312 312
313int MonthViewItem::height(const QListBox *lb) const 313int MonthViewItem::height(const QListBox *lb) const
314{ 314{
315 int ret = 10;
315 if ( lb ) 316 if ( lb )
316 return lb->fontMetrics().lineSpacing()+1; 317 ret = lb->fontMetrics().lineSpacing()+1;
317 return 10; 318 return ret;
318} 319}
319 320
320int MonthViewItem::width(const QListBox *lb) const 321int MonthViewItem::width(const QListBox *lb) const
321{ 322{
323
324 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
322 int size = PIXMAP_SIZE; 325 int size = PIXMAP_SIZE;
323 if ( QApplication::desktop()->width() < 300 ) 326 if ( QApplication::desktop()->width() < 300 )
324 size = 3; 327 size = 3;
325 int x = 1; 328 int x = 1;
326 if ( KOPrefs::instance()->mMonthShowIcons ) { 329 if ( KOPrefs::instance()->mMonthShowIcons ) {
327 if ( mInfo ) { 330 if ( mInfo ) {
328 x += size + 1; 331 x += size + 1;
329 } 332 }
330 if( mRecur ) { 333 if( mRecur ) {
331 x += size+1; 334 x += size+1;
332 } 335 }
333 if( mAlarm ) { 336 if( mAlarm ) {
334 x += size+1; 337 x += size+1;
335 } 338 }
336 if( mReply ) { 339 if( mReply ) {
337 x += size+1; 340 x += size+1;
338 } 341 }
339 } 342 }
340 if( mMultiday ) { 343 if( mMultiday ) {
341 x += size+1+2+size/2; 344 x += size+1+2+size/2;
342 } 345 }
343
344 return( x + lb->fontMetrics().width( text() ) + 1 ); 346 return( x + lb->fontMetrics().width( text() ) + 1 );
345} 347}
348 if ( ! lb )
349 return 10;
350 //qDebug("ret wid %d ", lb->width());
351 return lb->width();
352}
346 353
347 354
348MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 355MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
349 : QWidget( par ), 356 : QWidget( par ),
350 mMonthView( parent ) 357 mMonthView( parent )
351{ 358{
352 359
353 QVBoxLayout *topLayout = new QVBoxLayout( this ); 360 //QVBoxLayout *topLayout = new QVBoxLayout( this );
354 361
355 // mLabel = new QLabel( this );QPushButton 362 // mLabel = new QLabel( this );QPushButton
356 mLabel = new QPushButton( this ); 363 mLabel = new QPushButton( this );
357 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 364 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
358 //mLabel->setLineWidth( 1 ); 365 //mLabel->setLineWidth( 1 );
359 //mLabel->setAlignment( AlignCenter ); 366 //mLabel->setAlignment( AlignCenter );
360 mLabel->setFlat( true ); 367 mLabel->setFlat( true );
361 mLabel->setFocusPolicy(NoFocus); 368 mLabel->setFocusPolicy(NoFocus);
362 mItemList = new KNoScrollListBox( this ); 369 mItemList = new KNoScrollListBox( this );
363 mItemList->setMinimumSize( 10, 10 ); 370 mItemList->setMinimumSize( 10, 10 );
364 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 371 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
365 mItemList->setLineWidth( 1 ); 372 mItemList->setLineWidth( 1 );
366 topLayout->addWidget( mItemList ); 373 //topLayout->addWidget( mItemList );
367 mLabel->raise(); 374 mLabel->raise();
368 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 375 // QColor( 0,0,255 ) QColor( 160,1600,255 )
369 mStandardPalette = palette(); 376 mStandardPalette = palette();
370 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 377 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
371 378
372 enableScrollBars( false ); 379 enableScrollBars( false );
373 updateConfig(); 380 updateConfig();
374 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 381 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
375 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 382 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
376 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 383 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
377 SLOT( defaultAction( QListBoxItem * ) ) ); 384 SLOT( defaultAction( QListBoxItem * ) ) );
378 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 385 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
379 const QPoint &) ), 386 const QPoint &) ),
380 SLOT( contextMenu( QListBoxItem * ) ) ); 387 SLOT( contextMenu( QListBoxItem * ) ) );
381 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 388 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
382 SLOT( selection( QListBoxItem * ) ) ); 389 SLOT( selection( QListBoxItem * ) ) );
383 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 390 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
384 SLOT( cellClicked( QListBoxItem * ) ) ); 391 SLOT( cellClicked( QListBoxItem * ) ) );
385 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 392 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
386 SLOT( selection( QListBoxItem * ) ) ); 393 SLOT( selection( QListBoxItem * ) ) );
387} 394}
388#ifdef DESKTOP_VERSION 395#ifdef DESKTOP_VERSION
389QToolTipGroup *MonthViewCell::toolTipGroup() 396QToolTipGroup *MonthViewCell::toolTipGroup()
390{ 397{
391 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 398 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
392 return mToolTipGroup; 399 return mToolTipGroup;
393} 400}
394#endif 401#endif
395 402
396void MonthViewCell::setDate( const QDate &date ) 403void MonthViewCell::setDate( const QDate &date )
397{ 404{
398 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 405 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
399 mDate = date; 406 mDate = date;
400 407
401 408
402 409
403 //resizeEvent( 0 ); 410 //resizeEvent( 0 );
404} 411}
405 412
406QDate MonthViewCell::date() const 413QDate MonthViewCell::date() const
407{ 414{
408 return mDate; 415 return mDate;
409} 416}
410 417
411void MonthViewCell::setPrimary( bool primary ) 418void MonthViewCell::setPrimary( bool primary )
412{ 419{
413 mPrimary = primary; 420 mPrimary = primary;
414 //setMyPalette(); 421 //setMyPalette();
415} 422}
416void MonthViewCell::setMyPalette() 423void MonthViewCell::setMyPalette()
417{ 424{
418 425
419 if ( mHoliday) { 426 if ( mHoliday) {
420 setPalette( mHolidayPalette ); 427 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
428 mItemList->setPalette( mHolidayPalette );
421 } else { 429 } else {
422 if ( mPrimary ) { 430 if ( mPrimary ) {
423 setPalette( mPrimaryPalette ); 431 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
432 mItemList->setPalette( mPrimaryPalette );
424 } else { 433 } else {
425 setPalette( mNonPrimaryPalette ); 434 mItemList->setPalette( mNonPrimaryPalette );
435 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
426 } 436 }
427 } 437 }
428 QPalette pal = palette(); 438 //QPalette pal = palette();
429 439
430 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 440 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
431} 441}
432QPalette MonthViewCell::getPalette () 442QPalette MonthViewCell::getPalette ()
433{ 443{
434 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 444 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
435 return mStandardPalette; 445 return mStandardPalette;
436 if ( mHoliday) { 446 if ( mHoliday) {
437 return mHolidayPalette ; 447 return mHolidayPalette ;
438 } else { 448 } else {
439 if ( mPrimary ) { 449 if ( mPrimary ) {
440 return mPrimaryPalette ; 450 return mPrimaryPalette ;
441 } 451 }
442 } 452 }
443 return mNonPrimaryPalette; 453 return mNonPrimaryPalette;
444} 454}
445bool MonthViewCell::isPrimary() const 455bool MonthViewCell::isPrimary() const
446{ 456{
447 return mPrimary; 457 return mPrimary;
448} 458}
449 459
450void MonthViewCell::setHoliday( bool holiday ) 460void MonthViewCell::setHoliday( bool holiday )
451{ 461{
452 mHoliday = holiday; 462 mHoliday = holiday;
453 //setMyPalette(); 463 //setMyPalette();
454} 464}
455 465
456void MonthViewCell::setHoliday( const QString &holiday ) 466void MonthViewCell::setHoliday( const QString &holiday )
457{ 467{
458 mHolidayString = holiday; 468 mHolidayString = holiday;
459 469
460 if ( !holiday.isEmpty() ) { 470 if ( !holiday.isEmpty() ) {
461 setHoliday( true ); 471 setHoliday( true );
462 } 472 }
463} 473}
464void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 474void MonthViewCell::keyPressEvent ( QKeyEvent * e )
465{ 475{
466 476
467 e->ignore(); 477 e->ignore();
468 478
469} 479}
470 480
471void MonthViewCell::startUpdateCell() 481void MonthViewCell::startUpdateCell()
472{ 482{
473 483
474 mItemList->setFocusPolicy(NoFocus); 484 mItemList->setFocusPolicy(NoFocus);
475 if ( !mMonthView->isUpdatePossible() ) 485 if ( !mMonthView->isUpdatePossible() )
476 return; 486 return;
477 487
478 /* 488 /*
@@ -630,215 +640,227 @@ void MonthViewCell::insertTodo(Todo *todo)
630 if (cat.isEmpty()) { 640 if (cat.isEmpty()) {
631 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 641 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
632 } else { 642 } else {
633 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 643 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
634 } 644 }
635 645
636 } else { 646 } else {
637 if (cat.isEmpty()) { 647 if (cat.isEmpty()) {
638 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 648 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
639 } else { 649 } else {
640 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 650 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
641 } 651 }
642 } 652 }
643 653
644 } else { 654 } else {
645 pal = mStandardPalette ; 655 pal = mStandardPalette ;
646 } 656 }
647 item->setPalette( pal ); 657 item->setPalette( pal );
648 item->setRecur( todo->recurrence()->doesRecur() ); 658 item->setRecur( todo->recurrence()->doesRecur() );
649 item->setAlarm( todo->isAlarmEnabled() ); 659 item->setAlarm( todo->isAlarmEnabled() );
650 item->setMoreInfo( todo->description().length() > 0 ); 660 item->setMoreInfo( todo->description().length() > 0 );
651 mItemList->insertItem( item ); 661 mItemList->insertItem( item );
652 mToolTip.append( text ); 662 mToolTip.append( text );
653} 663}
654void MonthViewCell::finishUpdateCell() 664void MonthViewCell::finishUpdateCell()
655{ 665{
656#ifdef DESKTOP_VERSION 666#ifdef DESKTOP_VERSION
657 if (mToolTip.count() > 0 ) { 667 if (mToolTip.count() > 0 ) {
658 mToolTip.sort(); 668 mToolTip.sort();
659 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 669 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
660 } 670 }
661#endif 671#endif
662 mItemList->sort(); 672 mItemList->sort();
663 //setMyPalette(); 673 //setMyPalette();
664 setMyPalette(); 674 setMyPalette();
665 QString text; 675 QString text;
666 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 676 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
667 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 677 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
668 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 678 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
669 mLabel->resize( mLabelBigSize ); 679 mLabel->resize( mLabelBigSize );
670 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 680 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
671 } else { 681 } else {
672 mLabel->resize( mLabelSize ); 682 mLabel->resize( mLabelSize );
673 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 683 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
674 } 684 }
675 685
676 mLabel->setText( text ); 686 mLabel->setText( text );
677 resizeEvent( 0 ); 687 resizeEvent( 0 );
688
678} 689}
679void MonthViewCell::updateCell() 690void MonthViewCell::updateCell()
680{ 691{
681 //qDebug("MonthViewCell::updateCell() "); 692 //qDebug("MonthViewCell::updateCell() ");
682 if ( !mMonthView->isUpdatePossible() ) 693 if ( !mMonthView->isUpdatePossible() )
683 return; 694 return;
684 startUpdateCell(); 695 startUpdateCell();
685 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 696 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
686 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 697 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
687 Event *event; 698 Event *event;
688 for( event = events.first(); event; event = events.next() ) { // for event 699 for( event = events.first(); event; event = events.next() ) { // for event
689 insertEvent(event); 700 insertEvent(event);
690 } 701 }
691 // insert due todos 702 // insert due todos
692 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 703 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
693 Todo *todo; 704 Todo *todo;
694 for(todo = todos.first(); todo; todo = todos.next()) { 705 for(todo = todos.first(); todo; todo = todos.next()) {
695 insertTodo( todo ); 706 insertTodo( todo );
696 } 707 }
697 finishUpdateCell(); 708 finishUpdateCell();
698 // if ( isVisible()) 709 // if ( isVisible())
699 //qApp->processEvents(); 710 //qApp->processEvents();
700} 711}
701 712
702void MonthViewCell::updateConfig( bool bigFont ) // = false 713void MonthViewCell::updateConfig( bool bigFont ) // = false
703{ 714{
704 715
705 if ( bigFont ) { 716 if ( bigFont ) {
706 QFont fo = KOPrefs::instance()->mMonthViewFont; 717 QFont fo = KOPrefs::instance()->mMonthViewFont;
707 int ps = fo.pointSize() + 2; 718 int ps = fo.pointSize() + 2;
708 if ( ps < 18 ) 719 if ( ps < 18 )
709 ps += 2; 720 ps += 2;
710 fo.setPointSize( ps ); 721 fo.setPointSize( ps );
711 setFont( fo ); 722 setFont( fo );
712 } else 723 } else
713 setFont( KOPrefs::instance()->mMonthViewFont ); 724 setFont( KOPrefs::instance()->mMonthViewFont );
714 725
715 QFontMetrics fm( font() ); 726 QFontMetrics fm( font() );
716 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 727 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
717 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 728 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
718 mHolidayPalette = mStandardPalette; 729 mHolidayPalette = mStandardPalette;
719 mPrimaryPalette = mStandardPalette; 730 mPrimaryPalette = mStandardPalette;
720 mNonPrimaryPalette = mStandardPalette; 731 mNonPrimaryPalette = mStandardPalette;
721 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 732 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
722 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 733 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
723 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 734 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
724 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 735 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
725 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 736 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
726 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 737 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
727 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 738 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
728 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 739 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
729 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 740 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
730 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 741 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
731 } 742 }
732 //updateCell(); 743 //updateCell();
733} 744}
734 745
735void MonthViewCell::enableScrollBars( bool enabled ) 746void MonthViewCell::enableScrollBars( bool enabled )
736{ 747{
737 if ( enabled ) { 748 if ( enabled ) {
738 mItemList->setVScrollBarMode(QScrollView::Auto); 749 //mItemList->setVScrollBarMode(QScrollView::Auto);
739 mItemList->setHScrollBarMode(QScrollView::Auto); 750 mItemList->setHScrollBarMode(QScrollView::Auto);
751 QListBoxItem *fi = mItemList->firstItem ();
752 if (fi ) {
753 int hei = mItemList->numRows () * fi->height(mItemList);
754 if ( hei < height() - mItemList->horizontalScrollBar()->height () )
755 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
756 else
757 mItemList->setVScrollBarMode(QScrollView::Auto);
758 }
740 } else { 759 } else {
741 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 760 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
742 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 761 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
743 } 762 }
744} 763}
745 764
746Incidence *MonthViewCell::selectedIncidence() 765Incidence *MonthViewCell::selectedIncidence()
747{ 766{
748 int index = mItemList->currentItem(); 767 int index = mItemList->currentItem();
749 if ( index < 0 ) return 0; 768 if ( index < 0 ) return 0;
750 769
751 MonthViewItem *item = 770 MonthViewItem *item =
752 static_cast<MonthViewItem *>( mItemList->item( index ) ); 771 static_cast<MonthViewItem *>( mItemList->item( index ) );
753 772
754 if ( !item ) return 0; 773 if ( !item ) return 0;
755 774
756 return item->incidence(); 775 return item->incidence();
757} 776}
758 777
759QDate MonthViewCell::selectedIncidenceDate() 778QDate MonthViewCell::selectedIncidenceDate()
760{ 779{
761 QDate qd; 780 QDate qd;
762 int index = mItemList->currentItem(); 781 int index = mItemList->currentItem();
763 if ( index < 0 ) return qd; 782 if ( index < 0 ) return qd;
764 783
765 MonthViewItem *item = 784 MonthViewItem *item =
766 static_cast<MonthViewItem *>( mItemList->item( index ) ); 785 static_cast<MonthViewItem *>( mItemList->item( index ) );
767 786
768 if ( !item ) return qd; 787 if ( !item ) return qd;
769 788
770 return item->incidenceDate(); 789 return item->incidenceDate();
771} 790}
772 791
773void MonthViewCell::deselect() 792void MonthViewCell::deselect()
774{ 793{
775 mItemList->clearSelection(); 794 mItemList->clearSelection();
776 enableScrollBars( false ); 795 enableScrollBars( false );
777 // updateCell(); 796 // updateCell();
778} 797}
779void MonthViewCell::select() 798void MonthViewCell::select()
780{ 799{
781 ;// updateCell(); 800 ;// updateCell();
782} 801}
783 802
784void MonthViewCell::resizeEvent ( QResizeEvent * ) 803void MonthViewCell::resizeEvent ( QResizeEvent * e )
785{ 804{
786 if ( !mMonthView->isUpdatePossible() ) 805 if ( !mMonthView->isUpdatePossible() )
787 return; 806 return;
788 807 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
808 deselect();
789 int size = height() - mLabel->height() - 2; 809 int size = height() - mLabel->height() - 2;
790 if ( size > 0 ) 810 if ( size > 0 )
791 mItemList->verticalScrollBar()->setMaximumHeight( size ); 811 mItemList->verticalScrollBar()->setMaximumHeight( size );
792 size = width() - mLabel->width() -2; 812 size = width() - mLabel->width() -2;
793 if ( size > 0 ) 813 if ( size > 0 )
794 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 814 mItemList->horizontalScrollBar()->setMaximumWidth( size );
795 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 815 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
796 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 816 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
817 mItemList->resize ( width(), height () );
818
797} 819}
798 820
799void MonthViewCell::defaultAction( QListBoxItem *item ) 821void MonthViewCell::defaultAction( QListBoxItem *item )
800{ 822{
801 if ( !item ) return; 823 if ( !item ) return;
802 824
803 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 825 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
804 Incidence *incidence = eventItem->incidence(); 826 Incidence *incidence = eventItem->incidence();
805 if ( incidence ) mMonthView->defaultAction( incidence ); 827 if ( incidence ) mMonthView->defaultAction( incidence );
806} 828}
807void MonthViewCell::showDay() 829void MonthViewCell::showDay()
808{ 830{
809 emit showDaySignal( date() ); 831 emit showDaySignal( date() );
810} 832}
811void MonthViewCell::newEvent() 833void MonthViewCell::newEvent()
812{ 834{
813 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 835 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
814 emit newEventSignal( dt ); 836 emit newEventSignal( dt );
815} 837}
816void MonthViewCell::cellClicked( QListBoxItem *item ) 838void MonthViewCell::cellClicked( QListBoxItem *item )
817{ 839{
818 static QListBoxItem * lastClicked = 0; 840 static QListBoxItem * lastClicked = 0;
819 if ( item == 0 ) { 841 if ( item == 0 ) {
820 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 842 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
821 emit newEventSignal( dt ); 843 emit newEventSignal( dt );
822 return; 844 return;
823 } 845 }
824 /* 846 /*
825 if ( lastClicked ) 847 if ( lastClicked )
826 if ( ! item ) { 848 if ( ! item ) {
827 if ( lastClicked->listBox() != item->listBox() ) 849 if ( lastClicked->listBox() != item->listBox() )
828 lastClicked->listBox()->clearSelection(); 850 lastClicked->listBox()->clearSelection();
829 } 851 }
830 */ 852 */
831 853
832 mMonthView->setSelectedCell( this ); 854 mMonthView->setSelectedCell( this );
833 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 855 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
834 select(); 856 select();
835} 857}
836 858
837void MonthViewCell::contextMenu( QListBoxItem *item ) 859void MonthViewCell::contextMenu( QListBoxItem *item )
838{ 860{
839 if ( !item ) return; 861 if ( !item ) return;
840 862
841 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 863 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
842 Incidence *incidence = eventItem->incidence(); 864 Incidence *incidence = eventItem->incidence();
843 if ( incidence ) mMonthView->showContextMenu( incidence ); 865 if ( incidence ) mMonthView->showContextMenu( incidence );
844} 866}