summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-28 09:52:05 (UTC)
committer zautrix <zautrix>2005-06-28 09:52:05 (UTC)
commitc26c9e0aa8c8a3b1d3e8dba018d56dbdb67c65b4 (patch) (unidiff)
tree432c39b8c65277964b9e62ee98eeeb92e3006ba2
parent4385e73c51688f0b8b21bfe061c04a6c42e92701 (diff)
downloadkdepimpi-c26c9e0aa8c8a3b1d3e8dba018d56dbdb67c65b4.zip
kdepimpi-c26c9e0aa8c8a3b1d3e8dba018d56dbdb67c65b4.tar.gz
kdepimpi-c26c9e0aa8c8a3b1d3e8dba018d56dbdb67c65b4.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp65
-rw-r--r--korganizer/komonthview.h4
2 files changed, 54 insertions, 15 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 1c2d6a2..264cf28 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -349,104 +349,117 @@ void MonthViewItem::paint(QPainter *p)
349 349
350 if ( mIncidence->calID() > 1 ) { 350 if ( mIncidence->calID() > 1 ) {
351 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); 351 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
352 p->drawRect ( x, y-2,size,size+4); 352 p->drawRect ( x, y-2,size,size+4);
353 x += size + 1; 353 x += size + 1;
354 } 354 }
355 if ( KOPrefs::instance()->mMonthShowIcons ) { 355 if ( KOPrefs::instance()->mMonthShowIcons ) {
356 if ( mInfo ) { 356 if ( mInfo ) {
357 p->fillRect ( x, y,size,size, Qt::darkGreen ); 357 p->fillRect ( x, y,size,size, Qt::darkGreen );
358 x += size + 1; 358 x += size + 1;
359 } 359 }
360 if ( mRecur ) { 360 if ( mRecur ) {
361 p->fillRect ( x, y,size,size, Qt::blue ); 361 p->fillRect ( x, y,size,size, Qt::blue );
362 x += size + 1; 362 x += size + 1;
363 } 363 }
364 if ( mAlarm ) { 364 if ( mAlarm ) {
365 p->fillRect ( x, y,size,size, Qt::red ); 365 p->fillRect ( x, y,size,size, Qt::red );
366 x += size + 1; 366 x += size + 1;
367 } 367 }
368 if ( mReply ) { 368 if ( mReply ) {
369 p->fillRect ( x, y,size,size, Qt::yellow ); 369 p->fillRect ( x, y,size,size, Qt::yellow );
370 x += size + 1; 370 x += size + 1;
371 } 371 }
372 } 372 }
373
374
375
376
377 if ( sel ) p->setPen( Qt::white );
378 else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) );
379
380#if 0
381 p->setPen( palette().color( QPalette::Normal, sel ? \
382 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
383#endif
384 QColor textColor = p->pen().color();
385
386
373 if ( mMultiday ) { 387 if ( mMultiday ) {
374 int yyy = y+(size/2); 388 int yyy = y+(size/2);
375 int sizeM = size+2; 389 int sizeM = size+2;
376 p->setBrush( QBrush( p->pen().color() ) ); 390 p->setBrush( QBrush( textColor ) );
377 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 391 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
378 if ( mMultiday == 2 || mMultiday == 3 ) { 392 if ( mMultiday == 2 || mMultiday == 3 ) {
379 QPointArray pa ( 3 ); 393 QPointArray pa ( 3 );
380 pa.setPoint (0, x, yyy ); 394 pa.setPoint (0, x, yyy );
381 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 395 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
382 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 396 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
383 p->drawPolygon( pa ); 397 p->drawPolygon( pa );
384 } 398 }
385 if ( mMultiday == 2 || mMultiday == 1 ) { 399 if ( mMultiday == 2 || mMultiday == 1 ) {
386 QPointArray pa ( 3 ); 400 QPointArray pa ( 3 );
387 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 401 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
388 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 402 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
389 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 403 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
390 p->drawPolygon( pa ); 404 p->drawPolygon( pa );
391 } 405 }
392 if ( mMultiday == 1 ) { 406 if ( mMultiday == 1 ) {
393 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 407 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
394 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 408 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
395 } 409 }
396 if ( mMultiday == 3 ) { 410 if ( mMultiday == 3 ) {
397 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 411 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
398 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 412 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
399 413
400 } 414 }
401 x += sizeM/2 + 1; 415 x += sizeM/2 + 1;
402 x += sizeM + 1; 416 x += sizeM + 1;
403 } 417 }
404 418
405 if ( mIncidence->typeID() == todoID ){ 419 if ( mIncidence->typeID() == todoID ){
406 Todo* td = ( Todo* ) mIncidence; 420 Todo* td = ( Todo* ) mIncidence;
407 if ( td->isCompleted() ) { 421 if ( td->isCompleted() ) {
408 int half = size/2; 422 int half = size/2;
409 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 423 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
410 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 424 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
411 x += half+half + 4; 425 x += half+half + 4;
412 426
413 } else { 427 } else {
414 int val = td->percentComplete()/20; 428 int val = td->percentComplete()/20;
415 p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() ); 429 p->fillRect ( x+1, y-2, val ,size+4,textColor );
416 p->drawRect ( x, y-2,7,size+4); 430 p->drawRect ( x, y-2,7,size+4);
417 x += size + 3; 431 x += size + 3;
418 } 432 }
419 } 433 }
420 QFontMetrics fm = p->fontMetrics(); 434 QFontMetrics fm = p->fontMetrics();
421 int yPos; 435 int yPos;
422 int pmheight = size; 436 int pmheight = size;
423 if( pmheight < fm.height() ) 437 if( pmheight < fm.height() )
424 yPos = fm.ascent() + fm.leading()/2; 438 yPos = fm.ascent() + fm.leading()/2;
425 else 439 else
426 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 440 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
427 p->setPen( palette().color( QPalette::Normal, sel ? \ 441
428 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
429 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 442 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
430 p->drawText( x, yPos, text() ); 443 p->drawText( x, yPos, text() );
431 if ( mIncidence->cancelled() ) { 444 if ( mIncidence->cancelled() ) {
432 int wid = fm.width( text() ); 445 int wid = fm.width( text() );
433 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 446 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
434 } 447 }
435 } else { 448 } else {
436 QString pText = text(); 449 QString pText = text();
437 if( pText.mid(2,1) == ":" ) 450 if( pText.mid(2,1) == ":" )
438 pText = pText.mid( 6 ); 451 pText = pText.mid( 6 );
439 p->drawText( x, yPos, pText ); 452 p->drawText( x, yPos, pText );
440 if ( mIncidence->cancelled() ) { 453 if ( mIncidence->cancelled() ) {
441 int wid = fm.width( pText ); 454 int wid = fm.width( pText );
442 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 455 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
443 } 456 }
444 } 457 }
445} 458}
446 459
447int MonthViewItem::height(const QListBox *lb) const 460int MonthViewItem::height(const QListBox *lb) const
448{ 461{
449 int ret = 10; 462 int ret = 10;
450 if ( lb ) 463 if ( lb )
451 ret = lb->fontMetrics().lineSpacing()+1; 464 ret = lb->fontMetrics().lineSpacing()+1;
452 return ret; 465 return ret;
@@ -596,49 +609,49 @@ QPalette MonthViewCell::getPalette ()
596 return mNonPrimaryPalette; 609 return mNonPrimaryPalette;
597} 610}
598bool MonthViewCell::isPrimary() const 611bool MonthViewCell::isPrimary() const
599{ 612{
600 return mPrimary; 613 return mPrimary;
601} 614}
602 615
603void MonthViewCell::setHoliday( bool holiday ) 616void MonthViewCell::setHoliday( bool holiday )
604{ 617{
605 mHoliday = holiday; 618 mHoliday = holiday;
606 //setMyPalette(); 619 //setMyPalette();
607} 620}
608 621
609void MonthViewCell::setHoliday( const QString &holiday ) 622void MonthViewCell::setHoliday( const QString &holiday )
610{ 623{
611 mHolidayString = holiday; 624 mHolidayString = holiday;
612 625
613 if ( !holiday.isEmpty() ) { 626 if ( !holiday.isEmpty() ) {
614 setHoliday( true ); 627 setHoliday( true );
615 } 628 }
616} 629}
617 630
618void MonthViewCell::startUpdateCell() 631void MonthViewCell::startUpdateCell()
619{ 632{
620 633 blockSignals( true );
621 mdayCount = 0; 634 mdayCount = 0;
622 setFocusPolicy(NoFocus); 635 setFocusPolicy(NoFocus);
623 if ( !mMonthView->isUpdatePossible() ) 636 if ( !mMonthView->isUpdatePossible() )
624 return; 637 return;
625 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 638 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
626 while ( mitem ) { 639 while ( mitem ) {
627 mitem->setBlockRepaint( true ); 640 mitem->setBlockRepaint( true );
628 mitem = (MonthViewItem *)mitem->next(); 641 mitem = (MonthViewItem *)mitem->next();
629 } 642 }
630 if ( mAvailItemList.count() > 20 ) { 643 if ( mAvailItemList.count() > 20 ) {
631 mAvailItemList.setAutoDelete( true ); 644 mAvailItemList.setAutoDelete( true );
632 mAvailItemList.clear(); 645 mAvailItemList.clear();
633 mAvailItemList.setAutoDelete( false ); 646 mAvailItemList.setAutoDelete( false );
634 clear(); 647 clear();
635 } 648 }
636 649
637 setPrimary( mDate.month()%2 ); 650 setPrimary( mDate.month()%2 );
638 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 651 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
639 if ( mDate == QDate::currentDate() ) { 652 if ( mDate == QDate::currentDate() ) {
640 setLineWidth( 3 ); 653 setLineWidth( 3 );
641 } else { 654 } else {
642 setLineWidth( 1 ); 655 setLineWidth( 1 );
643 } 656 }
644 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 657 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
@@ -860,48 +873,49 @@ void MonthViewCell::insertTodo(Todo *todo)
860 } 873 }
861 } 874 }
862 875
863 } else { 876 } else {
864 pal = mStandardPalette ; 877 pal = mStandardPalette ;
865 } 878 }
866 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); 879 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor);
867 item->setPalette( pal ); 880 item->setPalette( pal );
868 item->setRecur( todo->recurrence()->doesRecur() ); 881 item->setRecur( todo->recurrence()->doesRecur() );
869 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); 882 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
870 item->setMoreInfo( todo->description().length() > 0 ); 883 item->setMoreInfo( todo->description().length() > 0 );
871 insertItem( item , count()); 884 insertItem( item , count());
872#ifdef DESKTOP_VERSION 885#ifdef DESKTOP_VERSION
873 mToolTip.append( text ); 886 mToolTip.append( text );
874#endif 887#endif
875} 888}
876void MonthViewCell::repaintfinishUpdateCell() 889void MonthViewCell::repaintfinishUpdateCell()
877{ 890{
878 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 891 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
879 while ( mitem ) { 892 while ( mitem ) {
880 mitem->setBlockRepaint( false ); 893 mitem->setBlockRepaint( false );
881 updateItem ( mitem ); 894 updateItem ( mitem );
882 mitem = (MonthViewItem *)mitem->next(); 895 mitem = (MonthViewItem *)mitem->next();
883 } 896 }
897 blockSignals( false );
884} 898}
885void MonthViewCell::finishUpdateCell() 899void MonthViewCell::finishUpdateCell()
886{ 900{
887 901
888 902
889 903
890#ifdef DESKTOP_VERSION 904#ifdef DESKTOP_VERSION
891 if (mToolTip.count() > 0 ) { 905 if (mToolTip.count() > 0 ) {
892 mToolTip.sort(); 906 mToolTip.sort();
893 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 907 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
894 } 908 }
895#endif 909#endif
896 //sort(); 910 //sort();
897 //setMyPalette(); 911 //setMyPalette();
898 setMyPalette(); 912 setMyPalette();
899 913
900 resizeEvent( 0 ); 914 resizeEvent( 0 );
901 915
902} 916}
903void MonthViewCell::updateCell() 917void MonthViewCell::updateCell()
904{ 918{
905 if ( !mMonthView->isUpdatePossible() ) 919 if ( !mMonthView->isUpdatePossible() )
906 return; 920 return;
907 startUpdateCell(); 921 startUpdateCell();
@@ -1005,57 +1019,56 @@ QDate MonthViewCell::selectedIncidenceDate()
1005 if ( index < 0 ) return qd; 1019 if ( index < 0 ) return qd;
1006 return mDate; 1020 return mDate;
1007} 1021}
1008 1022
1009void MonthViewCell::deselect() 1023void MonthViewCell::deselect()
1010{ 1024{
1011 clearSelection(); 1025 clearSelection();
1012 enableScrollBars( false ); 1026 enableScrollBars( false );
1013 // updateCell(); 1027 // updateCell();
1014} 1028}
1015void MonthViewCell::select() 1029void MonthViewCell::select()
1016{ 1030{
1017 ;// updateCell(); 1031 ;// updateCell();
1018} 1032}
1019 1033
1020void MonthViewCell::resizeEvent ( QResizeEvent * e ) 1034void MonthViewCell::resizeEvent ( QResizeEvent * e )
1021{ 1035{
1022 if ( !mMonthView->isUpdatePossible() ) 1036 if ( !mMonthView->isUpdatePossible() )
1023 return; 1037 return;
1024 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 1038 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
1025 deselect(); 1039 deselect();
1026 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 1040 mLabel->setMaximumHeight( height() - lineWidth()*2 );
1027 1041
1028 QString text; 1042 QString text;
1029 mLabel->setText( text ); 1043 //mLabel->setText( text );
1030 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 1044 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1031 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1045 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1032 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 1046 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() );
1033 mLabel->resize( mLabelBigSize ); 1047 mLabel->resize( mLabelBigSize );
1034 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1035 } else { 1048 } else {
1036 mLabel->resize( mLabelSize ); 1049 mLabel->resize( mLabelSize );
1037 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1050 text = QString::number( mDate.day() );
1038 } 1051 }
1039 mLabel->setText( text ); 1052 mLabel->setText( text );
1040 1053
1041 int size = height() - mLabel->height() - lineWidth()-1; 1054 int size = height() - mLabel->height() - lineWidth()-1;
1042 //qDebug("LW %d ", lineWidth()); 1055 //qDebug("LW %d ", lineWidth());
1043 if ( size > 0 ) 1056 if ( size > 0 )
1044 verticalScrollBar()->setMaximumHeight( size ); 1057 verticalScrollBar()->setMaximumHeight( size );
1045 size = width() - mLabel->width() -lineWidth()-1; 1058 size = width() - mLabel->width() -lineWidth()-1;
1046 if ( size > 0 ) 1059 if ( size > 0 )
1047 horizontalScrollBar()->setMaximumWidth( size ); 1060 horizontalScrollBar()->setMaximumWidth( size );
1048 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1061 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1049 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1062 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1050 // mItemList->resize ( width(), height () ); 1063 // mItemList->resize ( width(), height () );
1051 if ( e ) 1064 if ( e )
1052 KNoScrollListBox::resizeEvent ( e ); 1065 KNoScrollListBox::resizeEvent ( e );
1053} 1066}
1054 1067
1055void MonthViewCell::defaultAction( QListBoxItem *item ) 1068void MonthViewCell::defaultAction( QListBoxItem *item )
1056{ 1069{
1057 1070
1058 if ( !item ) { 1071 if ( !item ) {
1059 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1072 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1060 emit newEventSignal( dt ); 1073 emit newEventSignal( dt );
1061 return; 1074 return;
@@ -1316,95 +1329,120 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1316 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1329 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1317 1330
1318 1331
1319#ifndef DESKTOP_VERSION 1332#ifndef DESKTOP_VERSION
1320 resize( QApplication::desktop()->size() ); 1333 resize( QApplication::desktop()->size() );
1321#else 1334#else
1322 resize(640, 480 ); 1335 resize(640, 480 );
1323 updatePossible = true; 1336 updatePossible = true;
1324#endif 1337#endif
1325 computeLayout(); 1338 computeLayout();
1326 1339
1327 if ( mShowWeekView ) 1340 if ( mShowWeekView )
1328 mWidStack->raiseWidget( mWeekView ); 1341 mWidStack->raiseWidget( mWeekView );
1329 else 1342 else
1330 mWidStack->raiseWidget( mMonthView ); 1343 mWidStack->raiseWidget( mMonthView );
1331} 1344}
1332 1345
1333KOMonthView::~KOMonthView() 1346KOMonthView::~KOMonthView()
1334{ 1347{
1335 delete mContextMenu; 1348 delete mContextMenu;
1336} 1349}
1337 1350
1338void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) 1351void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday )
1339{ 1352{
1340 qDebug("11 KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
1341 static Incidence * lastInc = 0; 1353 static Incidence * lastInc = 0;
1342 static MonthViewCell * lastCell = 0; 1354 static MonthViewCell * lastCell = 0;
1343 1355
1344 if ( lastInc == inc && lastCell == mc ) 1356 if ( lastInc == inc && lastCell == mc )
1345 return; 1357 return;
1346 lastInc = inc; 1358 lastInc = inc;
1347 lastCell = mc; 1359 lastCell = mc;
1348 qDebug("222 KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); 1360 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
1349 1361
1350 bool weekview = false; 1362 bool weekview = false;
1351 int index = 0; 1363 int index = 0;
1352 for (uint i = 0; i < mCellsW.count(); ++i) { 1364 for (uint i = 0; i < mCellsW.count(); ++i) {
1353 if ( mCellsW[i] == mc ) { 1365 if ( mCellsW[i] == mc ) {
1354 weekview = true; 1366 weekview = true;
1355 index = i; 1367 index = i;
1356 break; 1368 break;
1357 } 1369 }
1358 } 1370 }
1359 QPtrVector<MonthViewCell> *cells; 1371 QPtrVector<MonthViewCell> *cells;
1360 if ( weekview ) 1372 if ( weekview )
1361 cells = &mCellsW; 1373 cells = &mCellsW;
1362 else { 1374 else {
1363 for (uint i = 0; i < mCells.count(); ++i) { 1375 for (uint i = 0; i < mCells.count(); ++i) {
1364 if ( mCells[i] == mc ) { 1376 if ( mCells[i] == mc ) {
1365 index = i; 1377 index = i;
1366 break; 1378 break;
1367 } 1379 }
1368 } 1380 }
1369 cells = &mCells; 1381 cells = &mCells;
1370 } 1382 }
1371 for (uint i = 0; i < (*cells).count(); ++i) { 1383 for (uint i = 0; i < (*cells).count(); ++i) {
1372 (*cells)[i]->deHighLight(); 1384 (*cells)[i]->deHighLight();
1373 } 1385 }
1374 if ( ! inc ) 1386 if ( ! inc )
1375 return; 1387 return;
1388
1389 int count = (*cells).count();
1390 bool goLeft = (mday > 1 && index > 0);
1391 bool goRight = (mday < 3 && mday > 0 && index < count -1);
1392 for (uint iii = 1; iii < count; ++iii) {
1393 if ( goLeft ) {
1394 int left = index - iii;
1395 if ( left >= 0 ) {
1396 if ( (*cells)[(uint)left]->doHighLight(inc) )
1397 goLeft = false;
1398 } else
1399 goLeft = false;
1400 }
1401 if ( goRight ) {
1402 int right = index + iii;
1403 if ( right < count ) {
1404 if ( (*cells)[right]->doHighLight(inc) )
1405 goRight = false;
1406
1407 } else
1408 goRight = false;
1409 }
1410
1411 }
1412#if 0
1376 if ( mday > 1 && index > 0 ) 1413 if ( mday > 1 && index > 0 )
1377 for (int i = index-1; i >= 0; --i) { 1414 for (int i = index-1; i >= 0; --i) {
1378 //qDebug("index %d iii %d ", index, i); 1415 //qDebug("index %d iii %d ", index, i);
1379 if ( (*cells)[(uint)i]->doHighLight(inc) ) 1416 if ( (*cells)[(uint)i]->doHighLight(inc) )
1380 break; 1417 break;
1381 } 1418 }
1382 if ( mday < 3 && mday > 0 && index < (*cells).count()-1) 1419 if ( mday < 3 && mday > 0 && index < (*cells).count()-1)
1383 for (uint i = index+1; i < (*cells).count(); ++i) { 1420 for (uint i = index+1; i < (*cells).count(); ++i) {
1384 if ( (*cells)[i]->doHighLight(inc) ) 1421 if ( (*cells)[i]->doHighLight(inc) )
1385 break; 1422 break;
1386 } 1423 }
1424#endif
1387 1425
1388} 1426}
1389void KOMonthView::selectInternalWeekNum ( int n ) 1427void KOMonthView::selectInternalWeekNum ( int n )
1390{ 1428{
1391 switchView(); 1429 switchView();
1392 if ( !KOPrefs::instance()->mMonthViewWeek ) 1430 if ( !KOPrefs::instance()->mMonthViewWeek )
1393 emit selectMonth (); 1431 emit selectMonth ();
1394 else 1432 else
1395 emit selectWeekNum ( n ); 1433 emit selectWeekNum ( n );
1396} 1434}
1397 1435
1398int KOMonthView::currentWeek() 1436int KOMonthView::currentWeek()
1399{ 1437{
1400 if ( mShowWeekView ) 1438 if ( mShowWeekView )
1401 return mWeekLabelsW[0]->getWeekNum(); 1439 return mWeekLabelsW[0]->getWeekNum();
1402 return mWeekLabels[0]->getWeekNum(); 1440 return mWeekLabels[0]->getWeekNum();
1403} 1441}
1404void KOMonthView::switchView() 1442void KOMonthView::switchView()
1405{ 1443{
1406 if ( selectedCell( ) ) 1444 if ( selectedCell( ) )
1407 selectedCell()->deselect(); 1445 selectedCell()->deselect();
1408 mShowWeekView = !mShowWeekView; 1446 mShowWeekView = !mShowWeekView;
1409 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1447 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1410 if ( clPending ) { 1448 if ( clPending ) {
@@ -1700,49 +1738,50 @@ void KOMonthView::updateView()
1700 (*cells)[iii]->insertEvent( event ); 1738 (*cells)[iii]->insertEvent( event );
1701 } 1739 }
1702 } 1740 }
1703 } 1741 }
1704 } 1742 }
1705 // insert due todos 1743 // insert due todos
1706 QPtrList<Todo> todos = calendar()->todos( ); 1744 QPtrList<Todo> todos = calendar()->todos( );
1707 Todo *todo; 1745 Todo *todo;
1708 for(todo = todos.first(); todo; todo = todos.next()) { 1746 for(todo = todos.first(); todo; todo = todos.next()) {
1709 //insertTodo( todo ); 1747 //insertTodo( todo );
1710 if ( todo->hasDueDate() ) { 1748 if ( todo->hasDueDate() ) {
1711 int day = mStartDate.daysTo( todo->dtDue().date() ); 1749 int day = mStartDate.daysTo( todo->dtDue().date() );
1712 if ( day >= 0 && day < timeSpan + 1) { 1750 if ( day >= 0 && day < timeSpan + 1) {
1713 (*cells)[day]->insertTodo( todo ); 1751 (*cells)[day]->insertTodo( todo );
1714 } 1752 }
1715 } 1753 }
1716 } 1754 }
1717 1755
1718 for( i = 0; i < timeSpan+1; ++i ) { 1756 for( i = 0; i < timeSpan+1; ++i ) {
1719 (*cells)[i]->finishUpdateCell(); 1757 (*cells)[i]->finishUpdateCell();
1720 } 1758 }
1721 processSelectionChange(); 1759 processSelectionChange();
1722 //qApp->processEvents(); 1760 //qApp->processEvents();
1723 for( i = 0; i < timeSpan+1; ++i ) { 1761 for( i = 0; i < timeSpan+1; ++i ) {
1724 (*cells)[i]->repaintfinishUpdateCell(); 1762 //(*cells)[i]->repaintfinishUpdateCell();
1763 QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) );
1725 } 1764 }
1726 setKeyBFocus(); 1765 setKeyBFocus();
1727#else 1766#else
1728 // old code 1767 // old code
1729 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1768 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1730 int i; 1769 int i;
1731 for( i = 0; i < (*cells).count(); ++i ) { 1770 for( i = 0; i < (*cells).count(); ++i ) {
1732 (*cells)[i]->updateCell(); 1771 (*cells)[i]->updateCell();
1733 } 1772 }
1734 1773
1735 //qDebug("KOMonthView::updateView() "); 1774 //qDebug("KOMonthView::updateView() ");
1736 processSelectionChange(); 1775 processSelectionChange();
1737 // qDebug("---------------------------------------------------------------------+ "); 1776 // qDebug("---------------------------------------------------------------------+ ");
1738 (*cells)[0]->setFocus(); 1777 (*cells)[0]->setFocus();
1739#endif 1778#endif
1740 1779
1741 //qDebug("update time %d ", ti.elapsed()); 1780 //qDebug("update time %d ", ti.elapsed());
1742} 1781}
1743 1782
1744void KOMonthView::setKeyBoardFocus() 1783void KOMonthView::setKeyBoardFocus()
1745{ 1784{
1746 //qDebug("KOMonthView::setKeyBoardFocus() "); 1785 //qDebug("KOMonthView::setKeyBoardFocus() ");
1747 bool shootAgain = false; 1786 bool shootAgain = false;
1748 if ( mShowWeekView ) { 1787 if ( mShowWeekView ) {
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 0f3aa54..0bd6b1c 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -146,77 +146,77 @@ class MonthViewItem: public QListBoxItem
146}; 146};
147 147
148 148
149class KOMonthView; 149class KOMonthView;
150 150
151class MonthViewCell : public KNoScrollListBox 151class MonthViewCell : public KNoScrollListBox
152{ 152{
153 Q_OBJECT 153 Q_OBJECT
154 public: 154 public:
155 MonthViewCell(KOMonthView *,QWidget* ); 155 MonthViewCell(KOMonthView *,QWidget* );
156 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 156 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
157 157
158 void setDate( const QDate & ); 158 void setDate( const QDate & );
159 QDate date() const; 159 QDate date() const;
160 160
161 void setPrimary( bool ); 161 void setPrimary( bool );
162 bool isPrimary() const; 162 bool isPrimary() const;
163 163
164 void setHoliday( bool ); 164 void setHoliday( bool );
165 void setHoliday( const QString & ); 165 void setHoliday( const QString & );
166 166
167 void updateCell(); 167 void updateCell();
168 void startUpdateCell(); 168 void startUpdateCell();
169 void finishUpdateCell(); 169 void finishUpdateCell();
170 void repaintfinishUpdateCell();
171 int insertEvent(Event *); 170 int insertEvent(Event *);
172 void insertTodo(Todo *); 171 void insertTodo(Todo *);
173 172
174 void updateConfig( bool bigFont = false ); 173 void updateConfig( bool bigFont = false );
175 174
176 void enableScrollBars( bool ); 175 void enableScrollBars( bool );
177 176
178 Incidence *selectedIncidence(); 177 Incidence *selectedIncidence();
179 QDate selectedIncidenceDate(); 178 QDate selectedIncidenceDate();
180 QPushButton * dateLabel() { return mLabel; } 179 QPushButton * dateLabel() { return mLabel; }
181 void deHighLight();
182 bool doHighLight( Incidence *); 180 bool doHighLight( Incidence *);
183 void deselect(); 181 void deselect();
184 void select(); 182 void select();
185#ifdef DESKTOP_VERSION 183#ifdef DESKTOP_VERSION
186 static QToolTipGroup *toolTipGroup(); 184 static QToolTipGroup *toolTipGroup();
187#endif 185#endif
188 signals: 186 signals:
189 void defaultAction( Incidence * ); 187 void defaultAction( Incidence * );
190 void newEventSignal( QDateTime ); 188 void newEventSignal( QDateTime );
191 void showDaySignal( QDate ); 189 void showDaySignal( QDate );
192 190
193 protected: 191 protected:
194 QStringList mToolTip; 192 QStringList mToolTip;
195 void resizeEvent( QResizeEvent * ); 193 void resizeEvent( QResizeEvent * );
196 194
197public slots: 195public slots:
198 void showDay(); 196 void showDay();
197 void deHighLight();
198 void repaintfinishUpdateCell();
199 protected slots: 199 protected slots:
200 void defaultAction( QListBoxItem * ); 200 void defaultAction( QListBoxItem * );
201 void contextMenu( QListBoxItem * ); 201 void contextMenu( QListBoxItem * );
202 void selection( QListBoxItem * ); 202 void selection( QListBoxItem * );
203 void cellClicked( QListBoxItem * ); 203 void cellClicked( QListBoxItem * );
204 void newEvent(); 204 void newEvent();
205 205
206 private: 206 private:
207 int mdayCount; 207 int mdayCount;
208 QPtrList <MonthViewItem> mAvailItemList; 208 QPtrList <MonthViewItem> mAvailItemList;
209 KOMonthView *mMonthView; 209 KOMonthView *mMonthView;
210 int currentPalette; 210 int currentPalette;
211 211
212 QDate mDate; 212 QDate mDate;
213 bool mPrimary; 213 bool mPrimary;
214 bool mHoliday; 214 bool mHoliday;
215 QString mHolidayString; 215 QString mHolidayString;
216 216
217 //QLabel *mLabel; 217 //QLabel *mLabel;
218 QPushButton *mLabel; 218 QPushButton *mLabel;
219 //QListBox *mItemList; 219 //QListBox *mItemList;
220#ifdef DESKTOP_VERSION 220#ifdef DESKTOP_VERSION
221 static QToolTipGroup *mToolTipGroup; 221 static QToolTipGroup *mToolTipGroup;
222#endif 222#endif