summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
Unidiff
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp14
1 files changed, 1 insertions, 13 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 2b7e41f..843526d 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -242,119 +242,115 @@ void KNoScrollListBox::oneDown()
242 emit nextCell(); 242 emit nextCell();
243 } else { 243 } else {
244 resetOnFocusIn = false; 244 resetOnFocusIn = false;
245 setCurrentItem((currentItem()+1)%count()); 245 setCurrentItem((currentItem()+1)%count());
246 if(!itemVisible(currentItem())) { 246 if(!itemVisible(currentItem())) {
247 if(currentItem() == 0) { 247 if(currentItem() == 0) {
248 setTopItem(0); 248 setTopItem(0);
249 } else { 249 } else {
250 setTopItem(topItem()+1); 250 setTopItem(topItem()+1);
251 } 251 }
252 } 252 }
253 } 253 }
254 } 254 }
255} 255}
256void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 256void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
257{ 257{
258 switch(e->key()) { 258 switch(e->key()) {
259 case Key_Shift: 259 case Key_Shift:
260 emit shiftUp(); 260 emit shiftUp();
261 break; 261 break;
262 default: 262 default:
263 break; 263 break;
264 } 264 }
265} 265}
266 266
267void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 267void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
268{ 268{
269 QListBox::mousePressEvent(e); 269 QListBox::mousePressEvent(e);
270 270
271 if(e->button() == RightButton) { 271 if(e->button() == RightButton) {
272 emit rightClick(); 272 emit rightClick();
273 } 273 }
274} 274}
275 275
276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
277 : QListBoxItem() 277 : QListBoxItem()
278{ 278{
279 mblockRepaint = true; 279 mblockRepaint = true;
280 setText( s ); 280 setText( s );
281 mMultiday = 0; 281 mMultiday = 0;
282 mIncidence = incidence; 282 mIncidence = incidence;
283 mDate = qd; 283 mDate = qd;
284 mRecur = false; 284 mRecur = false;
285 mAlarm = false; 285 mAlarm = false;
286 mReply = false; 286 mReply = false;
287 mInfo = false; 287 mInfo = false;
288 mdayPos = 0; 288 mdayPos = 0;
289 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 289 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
290 //qDebug("NEWWWWWWWWWWWWW ");
291} 290}
292void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 291void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
293{ 292{
294 setText( s ); 293 setText( s );
295 mMultiday = 0; 294 mMultiday = 0;
296 mIncidence = incidence; 295 mIncidence = incidence;
297 mDate = qd; 296 mDate = qd;
298 mRecur = false; 297 mRecur = false;
299 mAlarm = false; 298 mAlarm = false;
300 mReply = false; 299 mReply = false;
301 mInfo = false; 300 mInfo = false;
302 mdayPos = 0; 301 mdayPos = 0;
303 //qDebug("recucleeeeeeeeeeeeeeeee ");
304} 302}
305 303
306void MonthViewItem::paint(QPainter *p) 304void MonthViewItem::paint(QPainter *p)
307{ 305{
308 if ( mblockRepaint ) { 306 if ( mblockRepaint ) {
309 //qDebug("block ");
310 return; 307 return;
311 } 308 }
312 //qDebug("NON block ");
313#if QT_VERSION >= 0x030000 309#if QT_VERSION >= 0x030000
314 bool sel = isSelected(); 310 bool sel = isSelected();
315#else 311#else
316 bool sel = selected(); 312 bool sel = selected();
317#endif 313#endif
318 314
319 315
320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 316 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
321 { 317 {
322 p->setBackgroundColor( palette().color( QPalette::Normal, \ 318 p->setBackgroundColor( palette().color( QPalette::Normal, \
323 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 319 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 320 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
325 } 321 }
326 int x = 1; 322 int x = 1;
327 //int y = 3;//(height() - mRecurPixmap.height()) /2; 323 //int y = 3;//(height() - mRecurPixmap.height()) /2;
328 int size = PIXMAP_SIZE; 324 int size = PIXMAP_SIZE;
329 if ( QApplication::desktop()->width() < 300 ) 325 if ( QApplication::desktop()->width() < 300 )
330 size = 3; 326 size = 3;
331 int heihei = height( listBox () ); 327 int heihei = height( listBox () );
332 int y = (heihei - size -1 ) /2; 328 int y = (heihei - size -1 ) /2;
333 329
334 if ( KOPrefs::instance()->mMonthShowIcons ) { 330 if ( KOPrefs::instance()->mMonthShowIcons ) {
335 if ( mInfo ) { 331 if ( mInfo ) {
336 p->fillRect ( x, y,size,size, Qt::darkGreen ); 332 p->fillRect ( x, y,size,size, Qt::darkGreen );
337 x += size + 1; 333 x += size + 1;
338 } 334 }
339 if ( mRecur ) { 335 if ( mRecur ) {
340 p->fillRect ( x, y,size,size, Qt::blue ); 336 p->fillRect ( x, y,size,size, Qt::blue );
341 x += size + 1; 337 x += size + 1;
342 } 338 }
343 if ( mAlarm ) { 339 if ( mAlarm ) {
344 p->fillRect ( x, y,size,size, Qt::red ); 340 p->fillRect ( x, y,size,size, Qt::red );
345 x += size + 1; 341 x += size + 1;
346 } 342 }
347 if ( mReply ) { 343 if ( mReply ) {
348 p->fillRect ( x, y,size,size, Qt::yellow ); 344 p->fillRect ( x, y,size,size, Qt::yellow );
349 x += size + 1; 345 x += size + 1;
350 } 346 }
351 } 347 }
352 if ( mMultiday ) { 348 if ( mMultiday ) {
353 int yyy = y+(size/2); 349 int yyy = y+(size/2);
354 int sizeM = size+2; 350 int sizeM = size+2;
355 p->setBrush( QBrush::SolidPattern ); 351 p->setBrush( QBrush::SolidPattern );
356 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 352 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
357 if ( mMultiday == 2 || mMultiday == 3 ) { 353 if ( mMultiday == 2 || mMultiday == 3 ) {
358 QPointArray pa ( 3 ); 354 QPointArray pa ( 3 );
359 pa.setPoint (0, x, yyy ); 355 pa.setPoint (0, x, yyy );
360 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 356 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
@@ -415,97 +411,96 @@ void MonthViewItem::paint(QPainter *p)
415 } else { 411 } else {
416 QString pText = text(); 412 QString pText = text();
417 if( pText.mid(2,1) == ":" ) 413 if( pText.mid(2,1) == ":" )
418 pText = pText.mid( 6 ); 414 pText = pText.mid( 6 );
419 p->drawText( x, yPos, pText ); 415 p->drawText( x, yPos, pText );
420 if ( mIncidence->cancelled() ) { 416 if ( mIncidence->cancelled() ) {
421 int wid = fm.width( pText ); 417 int wid = fm.width( pText );
422 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 418 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
423 } 419 }
424 } 420 }
425} 421}
426 422
427int MonthViewItem::height(const QListBox *lb) const 423int MonthViewItem::height(const QListBox *lb) const
428{ 424{
429 int ret = 10; 425 int ret = 10;
430 if ( lb ) 426 if ( lb )
431 ret = lb->fontMetrics().lineSpacing()+1; 427 ret = lb->fontMetrics().lineSpacing()+1;
432 return ret; 428 return ret;
433} 429}
434 430
435int MonthViewItem::width(const QListBox *lb) const 431int MonthViewItem::width(const QListBox *lb) const
436{ 432{
437 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 433 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
438 int size = PIXMAP_SIZE; 434 int size = PIXMAP_SIZE;
439 if ( QApplication::desktop()->width() < 300 ) 435 if ( QApplication::desktop()->width() < 300 )
440 size = 3; 436 size = 3;
441 int x = 1; 437 int x = 1;
442 if ( KOPrefs::instance()->mMonthShowIcons ) { 438 if ( KOPrefs::instance()->mMonthShowIcons ) {
443 if ( mInfo ) { 439 if ( mInfo ) {
444 x += size + 1; 440 x += size + 1;
445 } 441 }
446 if( mRecur ) { 442 if( mRecur ) {
447 x += size+1; 443 x += size+1;
448 } 444 }
449 if( mAlarm ) { 445 if( mAlarm ) {
450 x += size+1; 446 x += size+1;
451 } 447 }
452 if( mReply ) { 448 if( mReply ) {
453 x += size+1; 449 x += size+1;
454 } 450 }
455 } 451 }
456 if( mMultiday ) { 452 if( mMultiday ) {
457 x += size+1+2+size/2; 453 x += size+1+2+size/2;
458 } 454 }
459 return( x + lb->fontMetrics().width( text() ) + 1 ); 455 return( x + lb->fontMetrics().width( text() ) + 1 );
460 } 456 }
461 if ( ! lb ) 457 if ( ! lb )
462 return 10; 458 return 10;
463 //qDebug("ret wid %d ", lb->width());
464 return lb->width(); 459 return lb->width();
465} 460}
466 461
467 462
468MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 463MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
469 : KNoScrollListBox( par ), 464 : KNoScrollListBox( par ),
470 mMonthView( parent ) 465 mMonthView( parent )
471{ 466{
472 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 467 //QVBoxLayout *topLayout = new QVBoxLayout( this );
473 currentPalette = 0; 468 currentPalette = 0;
474 // mLabel = new QLabel( this );QPushButton 469 // mLabel = new QLabel( this );QPushButton
475 mLabel = new QPushButton( this ); 470 mLabel = new QPushButton( this );
476 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 471 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
477 //mLabel->setLineWidth( 1 ); 472 //mLabel->setLineWidth( 1 );
478 //mLabel->setAlignment( AlignCenter ); 473 //mLabel->setAlignment( AlignCenter );
479 mLabel->setFlat( true ); 474 mLabel->setFlat( true );
480 mLabel->setFocusPolicy(NoFocus); 475 mLabel->setFocusPolicy(NoFocus);
481 //mItemList = new KNoScrollListBox( this ); 476 //mItemList = new KNoScrollListBox( this );
482 setMinimumSize( 10, 10 ); 477 setMinimumSize( 10, 10 );
483 setFrameStyle( QFrame::Panel | QFrame::Plain ); 478 setFrameStyle( QFrame::Panel | QFrame::Plain );
484 setLineWidth( 1 ); 479 setLineWidth( 1 );
485 //topLayout->addWidget( mItemList ); 480 //topLayout->addWidget( mItemList );
486 mLabel->raise(); 481 mLabel->raise();
487 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 482 // QColor( 0,0,255 ) QColor( 160,1600,255 )
488 mStandardPalette = palette(); 483 mStandardPalette = palette();
489 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 484 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
490 485
491 enableScrollBars( false ); 486 enableScrollBars( false );
492 updateConfig(); 487 updateConfig();
493 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 488 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
494 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 489 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
495 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 490 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
496 SLOT( defaultAction( QListBoxItem * ) ) ); 491 SLOT( defaultAction( QListBoxItem * ) ) );
497 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 492 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
498 const QPoint &) ), 493 const QPoint &) ),
499 SLOT( contextMenu( QListBoxItem * ) ) ); 494 SLOT( contextMenu( QListBoxItem * ) ) );
500 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 495 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
501 SLOT( selection( QListBoxItem * ) ) ); 496 SLOT( selection( QListBoxItem * ) ) );
502 497
503 /* 498 /*
504 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 499 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
505 SLOT( selection( QListBoxItem * ) ) ); 500 SLOT( selection( QListBoxItem * ) ) );
506 */ 501 */
507} 502}
508#ifdef DESKTOP_VERSION 503#ifdef DESKTOP_VERSION
509QToolTipGroup *MonthViewCell::toolTipGroup() 504QToolTipGroup *MonthViewCell::toolTipGroup()
510{ 505{
511 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 506 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
@@ -567,102 +562,97 @@ QPalette MonthViewCell::getPalette ()
567{ 562{
568 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 563 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
569 return mStandardPalette; 564 return mStandardPalette;
570 if ( mHoliday) { 565 if ( mHoliday) {
571 return mHolidayPalette ; 566 return mHolidayPalette ;
572 } else { 567 } else {
573 if ( mPrimary ) { 568 if ( mPrimary ) {
574 return mPrimaryPalette ; 569 return mPrimaryPalette ;
575 } 570 }
576 } 571 }
577 return mNonPrimaryPalette; 572 return mNonPrimaryPalette;
578} 573}
579bool MonthViewCell::isPrimary() const 574bool MonthViewCell::isPrimary() const
580{ 575{
581 return mPrimary; 576 return mPrimary;
582} 577}
583 578
584void MonthViewCell::setHoliday( bool holiday ) 579void MonthViewCell::setHoliday( bool holiday )
585{ 580{
586 mHoliday = holiday; 581 mHoliday = holiday;
587 //setMyPalette(); 582 //setMyPalette();
588} 583}
589 584
590void MonthViewCell::setHoliday( const QString &holiday ) 585void MonthViewCell::setHoliday( const QString &holiday )
591{ 586{
592 mHolidayString = holiday; 587 mHolidayString = holiday;
593 588
594 if ( !holiday.isEmpty() ) { 589 if ( !holiday.isEmpty() ) {
595 setHoliday( true ); 590 setHoliday( true );
596 } 591 }
597} 592}
598 593
599void MonthViewCell::startUpdateCell() 594void MonthViewCell::startUpdateCell()
600{ 595{
601 mdayCount = 0; 596 mdayCount = 0;
602 setFocusPolicy(NoFocus); 597 setFocusPolicy(NoFocus);
603 if ( !mMonthView->isUpdatePossible() ) 598 if ( !mMonthView->isUpdatePossible() )
604 return; 599 return;
605 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 600 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
606 while ( mitem ) { 601 while ( mitem ) {
607 mitem->setBlockRepaint( true ); 602 mitem->setBlockRepaint( true );
608 mitem = (MonthViewItem *)mitem->next(); 603 mitem = (MonthViewItem *)mitem->next();
609 } 604 }
610 if ( mAvailItemList.count() > 20 ) { 605 if ( mAvailItemList.count() > 20 ) {
611 mAvailItemList.setAutoDelete( true ); 606 mAvailItemList.setAutoDelete( true );
612 mAvailItemList.clear(); 607 mAvailItemList.clear();
613 mAvailItemList.setAutoDelete( false ); 608 mAvailItemList.setAutoDelete( false );
614 } 609 }
615 /* 610
616 if ( !isVisible() ){
617 return;
618 }
619 */
620 // qDebug("MonthViewCell::updateCell() ");
621 setPrimary( mDate.month()%2 ); 611 setPrimary( mDate.month()%2 );
622 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 612 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
623 if ( mDate == QDate::currentDate() ) { 613 if ( mDate == QDate::currentDate() ) {
624 setLineWidth( 3 ); 614 setLineWidth( 3 );
625 } else { 615 } else {
626 setLineWidth( 1 ); 616 setLineWidth( 1 );
627 } 617 }
628 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 618 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
629 //clear(); 619 //clear();
630 while ( CurrentAvailItem ) { 620 while ( CurrentAvailItem ) {
631 MonthViewItem *item = CurrentAvailItem; 621 MonthViewItem *item = CurrentAvailItem;
632 CurrentAvailItem = (MonthViewItem *)item->next(); 622 CurrentAvailItem = (MonthViewItem *)item->next();
633 mAvailItemList.append( item ); 623 mAvailItemList.append( item );
634 takeItem ( item ); 624 takeItem ( item );
635 } 625 }
636 626
637#ifdef DESKTOP_VERSION 627#ifdef DESKTOP_VERSION
638 QToolTip::remove(this); 628 QToolTip::remove(this);
639#endif 629#endif
640 mToolTip.clear(); 630 mToolTip.clear();
641 //qApp->processEvents(); 631 //qApp->processEvents();
642#if 0 632#if 0
643 if ( !mHolidayString.isEmpty() ) { 633 if ( !mHolidayString.isEmpty() ) {
644 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 634 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
645 item->setPalette( mHolidayPalette ); 635 item->setPalette( mHolidayPalette );
646 insertItem( item ); 636 insertItem( item );
647 mToolTip.append ( mHolidayString ); 637 mToolTip.append ( mHolidayString );
648 } 638 }
649#endif 639#endif
650} 640}
651 641
652int MonthViewCell::insertEvent(Event *event) 642int MonthViewCell::insertEvent(Event *event)
653{ 643{
654 bool useToolTips = true; 644 bool useToolTips = true;
655#ifndef DESKTOP_VERSION 645#ifndef DESKTOP_VERSION
656 useToolTips = false; 646 useToolTips = false;
657#endif 647#endif
658 QString mToolTipText; 648 QString mToolTipText;
659 setFocusPolicy(WheelFocus); 649 setFocusPolicy(WheelFocus);
660 if ( !(event->doesRecur() == Recurrence::rNone) ) { 650 if ( !(event->doesRecur() == Recurrence::rNone) ) {
661 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 651 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
662 return mdayCount; 652 return mdayCount;
663 else 653 else
664 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 654 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
665 return mdayCount; 655 return mdayCount;
666 } 656 }
667 657
668 if ( event->isHoliday()) { 658 if ( event->isHoliday()) {
@@ -826,97 +816,96 @@ void MonthViewCell::insertTodo(Todo *todo)
826 if (cat.isEmpty()) { 816 if (cat.isEmpty()) {
827 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 817 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
828 } else { 818 } else {
829 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 819 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
830 } 820 }
831 } 821 }
832 822
833 } else { 823 } else {
834 pal = mStandardPalette ; 824 pal = mStandardPalette ;
835 } 825 }
836 item->setPalette( pal ); 826 item->setPalette( pal );
837 item->setRecur( todo->recurrence()->doesRecur() ); 827 item->setRecur( todo->recurrence()->doesRecur() );
838 item->setAlarm( todo->isAlarmEnabled() ); 828 item->setAlarm( todo->isAlarmEnabled() );
839 item->setMoreInfo( todo->description().length() > 0 ); 829 item->setMoreInfo( todo->description().length() > 0 );
840 insertItem( item , count()); 830 insertItem( item , count());
841#ifdef DESKTOP_VERSION 831#ifdef DESKTOP_VERSION
842 mToolTip.append( text ); 832 mToolTip.append( text );
843#endif 833#endif
844} 834}
845void MonthViewCell::repaintfinishUpdateCell() 835void MonthViewCell::repaintfinishUpdateCell()
846{ 836{
847 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 837 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
848 while ( mitem ) { 838 while ( mitem ) {
849 mitem->setBlockRepaint( false ); 839 mitem->setBlockRepaint( false );
850 updateItem ( mitem ); 840 updateItem ( mitem );
851 mitem = (MonthViewItem *)mitem->next(); 841 mitem = (MonthViewItem *)mitem->next();
852 } 842 }
853} 843}
854void MonthViewCell::finishUpdateCell() 844void MonthViewCell::finishUpdateCell()
855{ 845{
856 846
857 847
858 848
859#ifdef DESKTOP_VERSION 849#ifdef DESKTOP_VERSION
860 if (mToolTip.count() > 0 ) { 850 if (mToolTip.count() > 0 ) {
861 mToolTip.sort(); 851 mToolTip.sort();
862 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 852 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
863 } 853 }
864#endif 854#endif
865 //sort(); 855 //sort();
866 //setMyPalette(); 856 //setMyPalette();
867 setMyPalette(); 857 setMyPalette();
868 858
869 resizeEvent( 0 ); 859 resizeEvent( 0 );
870 860
871} 861}
872void MonthViewCell::updateCell() 862void MonthViewCell::updateCell()
873{ 863{
874 //qDebug("MonthViewCell::updateCell() ");
875 if ( !mMonthView->isUpdatePossible() ) 864 if ( !mMonthView->isUpdatePossible() )
876 return; 865 return;
877 startUpdateCell(); 866 startUpdateCell();
878 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 867 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
879 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 868 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
880 Event *event; 869 Event *event;
881 for( event = events.first(); event; event = events.next() ) { // for event 870 for( event = events.first(); event; event = events.next() ) { // for event
882 insertEvent(event); 871 insertEvent(event);
883 } 872 }
884 // insert due todos 873 // insert due todos
885 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 874 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
886 Todo *todo; 875 Todo *todo;
887 for(todo = todos.first(); todo; todo = todos.next()) { 876 for(todo = todos.first(); todo; todo = todos.next()) {
888 insertTodo( todo ); 877 insertTodo( todo );
889 } 878 }
890 finishUpdateCell(); 879 finishUpdateCell();
891 // if ( isVisible()) 880 // if ( isVisible())
892 //qApp->processEvents(); 881 //qApp->processEvents();
893} 882}
894 883
895void MonthViewCell::updateConfig( bool bigFont ) // = false 884void MonthViewCell::updateConfig( bool bigFont ) // = false
896{ 885{
897 886
898 if ( bigFont ) { 887 if ( bigFont ) {
899 QFont fo = KOPrefs::instance()->mMonthViewFont; 888 QFont fo = KOPrefs::instance()->mMonthViewFont;
900 int ps = fo.pointSize() + 2; 889 int ps = fo.pointSize() + 2;
901 if ( ps < 18 ) 890 if ( ps < 18 )
902 ps += 2; 891 ps += 2;
903 fo.setPointSize( ps ); 892 fo.setPointSize( ps );
904 setFont( fo ); 893 setFont( fo );
905 } else 894 } else
906 setFont( KOPrefs::instance()->mMonthViewFont ); 895 setFont( KOPrefs::instance()->mMonthViewFont );
907 896
908 QFontMetrics fm( font() ); 897 QFontMetrics fm( font() );
909 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 898 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
910 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 899 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
911 mHolidayPalette = mStandardPalette; 900 mHolidayPalette = mStandardPalette;
912 mPrimaryPalette = mStandardPalette; 901 mPrimaryPalette = mStandardPalette;
913 mNonPrimaryPalette = mStandardPalette; 902 mNonPrimaryPalette = mStandardPalette;
914 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 903 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
915 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 904 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
916 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 905 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
917 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 906 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
918 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 907 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
919 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 908 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
920 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 909 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
921 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 910 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
922 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 911 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
@@ -1008,97 +997,96 @@ void MonthViewCell::resizeEvent ( QResizeEvent * e )
1008 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 997 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
1009 mLabel->resize( mLabelBigSize ); 998 mLabel->resize( mLabelBigSize );
1010 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 999 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1011 } else { 1000 } else {
1012 mLabel->resize( mLabelSize ); 1001 mLabel->resize( mLabelSize );
1013 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1002 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1014 } 1003 }
1015 mLabel->setText( text ); 1004 mLabel->setText( text );
1016 1005
1017 int size = height() - mLabel->height() - lineWidth()-1; 1006 int size = height() - mLabel->height() - lineWidth()-1;
1018 //qDebug("LW %d ", lineWidth()); 1007 //qDebug("LW %d ", lineWidth());
1019 if ( size > 0 ) 1008 if ( size > 0 )
1020 verticalScrollBar()->setMaximumHeight( size ); 1009 verticalScrollBar()->setMaximumHeight( size );
1021 size = width() - mLabel->width() -lineWidth()-1; 1010 size = width() - mLabel->width() -lineWidth()-1;
1022 if ( size > 0 ) 1011 if ( size > 0 )
1023 horizontalScrollBar()->setMaximumWidth( size ); 1012 horizontalScrollBar()->setMaximumWidth( size );
1024 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1013 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1025 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1014 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1026 // mItemList->resize ( width(), height () ); 1015 // mItemList->resize ( width(), height () );
1027 if ( e ) 1016 if ( e )
1028 KNoScrollListBox::resizeEvent ( e ); 1017 KNoScrollListBox::resizeEvent ( e );
1029} 1018}
1030 1019
1031void MonthViewCell::defaultAction( QListBoxItem *item ) 1020void MonthViewCell::defaultAction( QListBoxItem *item )
1032{ 1021{
1033 1022
1034 if ( !item ) { 1023 if ( !item ) {
1035 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1024 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1036 emit newEventSignal( dt ); 1025 emit newEventSignal( dt );
1037 return; 1026 return;
1038 } 1027 }
1039 1028
1040 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1029 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1041 Incidence *incidence = eventItem->incidence(); 1030 Incidence *incidence = eventItem->incidence();
1042 if ( incidence ) mMonthView->defaultAction( incidence ); 1031 if ( incidence ) mMonthView->defaultAction( incidence );
1043} 1032}
1044void MonthViewCell::showDay() 1033void MonthViewCell::showDay()
1045{ 1034{
1046 emit showDaySignal( date() ); 1035 emit showDaySignal( date() );
1047} 1036}
1048void MonthViewCell::newEvent() 1037void MonthViewCell::newEvent()
1049{ 1038{
1050 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1039 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1051 emit newEventSignal( dt ); 1040 emit newEventSignal( dt );
1052} 1041}
1053void MonthViewCell::cellClicked( QListBoxItem *item ) 1042void MonthViewCell::cellClicked( QListBoxItem *item )
1054{ 1043{
1055 mMonthView->setSelectedCell( this ); 1044 mMonthView->setSelectedCell( this );
1056 qDebug("CELL ");
1057 if ( item == 0 ) { 1045 if ( item == 0 ) {
1058 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1046 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1059 emit newEventSignal( dt ); 1047 emit newEventSignal( dt );
1060 return; 1048 return;
1061 } 1049 }
1062 1050
1063} 1051}
1064 1052
1065void MonthViewCell::contextMenu( QListBoxItem *item ) 1053void MonthViewCell::contextMenu( QListBoxItem *item )
1066{ 1054{
1067 mMonthView->setPopupCell( this ); 1055 mMonthView->setPopupCell( this );
1068 if ( !item ) { 1056 if ( !item ) {
1069 mMonthView->showContextMenu( 0 ); 1057 mMonthView->showContextMenu( 0 );
1070 return; 1058 return;
1071 } 1059 }
1072 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1060 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1073 Incidence *incidence = eventItem->incidence(); 1061 Incidence *incidence = eventItem->incidence();
1074 if ( incidence ) mMonthView->showContextMenu( incidence ); 1062 if ( incidence ) mMonthView->showContextMenu( incidence );
1075} 1063}
1076 1064
1077void MonthViewCell::selection( QListBoxItem *item ) 1065void MonthViewCell::selection( QListBoxItem *item )
1078{ 1066{
1079 if ( !item ) return; 1067 if ( !item ) return;
1080 1068
1081 mMonthView->setSelectedCell( this ); 1069 mMonthView->setSelectedCell( this );
1082} 1070}
1083 1071
1084 1072
1085// ******************************************************************************* 1073// *******************************************************************************
1086// ******************************************************************************* 1074// *******************************************************************************
1087// ******************************************************************************* 1075// *******************************************************************************
1088 1076
1089 1077
1090KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1078KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1091 : KOEventView( calendar, parent, name ), 1079 : KOEventView( calendar, parent, name ),
1092 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1080 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1093 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1081 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1094{ 1082{
1095 mFlagKeyPressed = false; 1083 mFlagKeyPressed = false;
1096 mShortDayLabelsM = false; 1084 mShortDayLabelsM = false;
1097 mShortDayLabelsW = false; 1085 mShortDayLabelsW = false;
1098 skipResize = false; 1086 skipResize = false;
1099 clPending = true; 1087 clPending = true;
1100 mPopupCell = 0; 1088 mPopupCell = 0;
1101 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1089 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1102 mWidStack = new QWidgetStack( this ); 1090 mWidStack = new QWidgetStack( this );
1103 QVBoxLayout* hb = new QVBoxLayout( this ); 1091 QVBoxLayout* hb = new QVBoxLayout( this );
1104 mMonthView = new QWidget( mWidStack ); 1092 mMonthView = new QWidget( mWidStack );