summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (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
@@ -309,19 +309,22 @@ void MonthViewItem::paint(QPainter *p)
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 ) {
@@ -337,36 +340,40 @@ int MonthViewItem::width(const QListBox *lb) const
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 );
@@ -414,23 +421,26 @@ void MonthViewCell::setPrimary( bool 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) {
@@ -672,12 +682,13 @@ void MonthViewCell::finishUpdateCell()
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;
@@ -732,14 +743,22 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
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
@@ -778,25 +797,28 @@ void MonthViewCell::deselect()
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