summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaitem.cpp
authorzautrix <zautrix>2005-06-08 10:34:22 (UTC)
committer zautrix <zautrix>2005-06-08 10:34:22 (UTC)
commit793d117812b4da36c9c11d90cccba347cbc6e208 (patch) (unidiff)
tree5bc77e2b7a32a541c2a3b3c3d6d50f873216deef /korganizer/koagendaitem.cpp
parent39d84e2fc3099bd5d7596e8be5dc6783826cec01 (diff)
downloadkdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.zip
kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.gz
kdepimpi-793d117812b4da36c9c11d90cccba347cbc6e208.tar.bz2
changed incidence type to a faster access method
Diffstat (limited to 'korganizer/koagendaitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index df2e478..5a3c4d2 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -85,67 +85,67 @@ KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool
85 init ( incidence, qd ); 85 init ( incidence, qd );
86 //setMouseTracking(true); 86 //setMouseTracking(true);
87 //setAcceptDrops(true); 87 //setAcceptDrops(true);
88 xPaintCoord = -1; 88 xPaintCoord = -1;
89 yPaintCoord = -1; 89 yPaintCoord = -1;
90} 90}
91QString KOAgendaItem::getWhatsThisText() 91QString KOAgendaItem::getWhatsThisText()
92{ 92{
93 if ( mIncidence ) 93 if ( mIncidence )
94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence, 94 return KIncidenceFormatter::instance()->getFormattedText( mIncidence,
95 KOPrefs::instance()->mWTshowDetails, 95 KOPrefs::instance()->mWTshowDetails,
96 KOPrefs::instance()->mWTshowCreated, 96 KOPrefs::instance()->mWTshowCreated,
97 KOPrefs::instance()->mWTshowChanged); 97 KOPrefs::instance()->mWTshowChanged);
98 return "KOAgendaItem::getWhatsThisText()::internal error"; 98 return "KOAgendaItem::getWhatsThisText()::internal error";
99} 99}
100void KOAgendaItem::init ( Incidence *incidence, QDate qd ) 100void KOAgendaItem::init ( Incidence *incidence, QDate qd )
101{ 101{
102 mIncidence = incidence; 102 mIncidence = incidence;
103 mDate = qd; 103 mDate = qd;
104 mFirstMultiItem = 0; 104 mFirstMultiItem = 0;
105 mNextMultiItem = 0; 105 mNextMultiItem = 0;
106 mLastMultiItem = 0; 106 mLastMultiItem = 0;
107 computeText(); 107 computeText();
108 108
109 if ( (incidence->type() == "Todo") && 109 if ( (incidence->typeID() == todoID ) &&
110 ( !((static_cast<Todo*>(incidence))->isCompleted()) && 110 ( !((static_cast<Todo*>(incidence))->isCompleted()) &&
111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) { 111 ((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date()) 112 if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ; 113 mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
114 else 114 else
115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor; 115 mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
116 } 116 }
117 else { 117 else {
118 QStringList categories = mIncidence->categories(); 118 QStringList categories = mIncidence->categories();
119 QString cat = categories.first(); 119 QString cat = categories.first();
120 if (cat.isEmpty()) { 120 if (cat.isEmpty()) {
121 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) 121 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) )
122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 122 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
123 else 123 else
124 mBackgroundColor =KOPrefs::instance()->mEventColor; 124 mBackgroundColor =KOPrefs::instance()->mEventColor;
125 } else { 125 } else {
126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat); 126 mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
127 if ( (incidence->type() == "Todo") &&((static_cast<Todo*>(incidence))->isCompleted()) ) { 127 if ( (incidence->typeID() == todoID ) &&((static_cast<Todo*>(incidence))->isCompleted()) ) {
128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor ) 128 if ( mBackgroundColor == KOPrefs::instance()->mEventColor )
129 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor; 129 mBackgroundColor =KOPrefs::instance()->mTodoDoneColor;
130 } 130 }
131 } 131 }
132 132
133 } 133 }
134 mColorGroup = QColorGroup( mBackgroundColor.light(), 134 mColorGroup = QColorGroup( mBackgroundColor.light(),
135 mBackgroundColor.dark(),mBackgroundColor.light(), 135 mBackgroundColor.dark(),mBackgroundColor.light(),
136 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ; 136 mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
137 setBackgroundColor( mBackgroundColor ); 137 setBackgroundColor( mBackgroundColor );
138 138
139 mConflictItems.clear(); 139 mConflictItems.clear();
140 setCellXY(0,0,1); 140 setCellXY(0,0,1);
141 setCellXWidth(0); 141 setCellXWidth(0);
142 setSubCell(0); 142 setSubCell(0);
143 setSubCells(1); 143 setSubCells(1);
144 setMultiItem(0,0,0); 144 setMultiItem(0,0,0);
145 startMove(); 145 startMove();
146 mSelected = true; 146 mSelected = true;
147 select(false); 147 select(false);
148 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont); 148 QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
149 mFontPixelSize = fontinf.height();; 149 mFontPixelSize = fontinf.height();;
150 hide(); 150 hide();
151 xPaintCoord = -1; 151 xPaintCoord = -1;
@@ -338,49 +338,49 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
338 hPaintCoord = height(); 338 hPaintCoord = height();
339 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 339 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
340 if ( paint == 0 ) 340 if ( paint == 0 )
341 paint = &pa; 341 paint = &pa;
342 bool horLayout = ( w < h ); 342 bool horLayout = ( w < h );
343 int maxhei = mFontPixelSize+4; 343 int maxhei = mFontPixelSize+4;
344 if ( horLayout ) 344 if ( horLayout )
345 maxhei += AGENDA_ICON_SIZE -4; 345 maxhei += AGENDA_ICON_SIZE -4;
346 bool small = ( h < maxhei ); 346 bool small = ( h < maxhei );
347 if ( ! small ) 347 if ( ! small )
348 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 348 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
349 else { 349 else {
350 QFont f = KOPrefs::instance()->mAgendaViewFont; 350 QFont f = KOPrefs::instance()->mAgendaViewFont;
351 f.setBold( false ); 351 f.setBold( false );
352 int fh = f.pointSize(); 352 int fh = f.pointSize();
353 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 353 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
354 if ( nfh < 6 ) 354 if ( nfh < 6 )
355 nfh = 6; 355 nfh = 6;
356 f.setPointSize( nfh ); 356 f.setPointSize( nfh );
357 paint->setFont(f); 357 paint->setFont(f);
358 } 358 }
359 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 359 paint->fillRect ( x, yy, w, h, mBackgroundColor );
360 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 360 static const QPixmap completedPxmp = SmallIcon("greenhook16");
361 static const QPixmap overduePxmp = SmallIcon("redcross16"); 361 static const QPixmap overduePxmp = SmallIcon("redcross16");
362 if ( mIncidence->type() == "Todo" ) { 362 if ( mIncidence->typeID() == todoID ) {
363 Todo* tempTodo = static_cast<Todo*>(mIncidence); 363 Todo* tempTodo = static_cast<Todo*>(mIncidence);
364 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 364 int xx = pos().x()+(width()-completedPxmp.width()-3 );
365 int yyy = yy+3; 365 int yyy = yy+3;
366 if ( tempTodo->isCompleted() ) 366 if ( tempTodo->isCompleted() )
367 paint->drawPixmap ( xx, yyy, completedPxmp ); 367 paint->drawPixmap ( xx, yyy, completedPxmp );
368 else { 368 else {
369 paint->drawPixmap ( xx, yyy, overduePxmp ); 369 paint->drawPixmap ( xx, yyy, overduePxmp );
370 370
371 } 371 }
372 } 372 }
373 bool addIcon = false; 373 bool addIcon = false;
374 if ( ! small || w > 3 * h || h > 3* w ) 374 if ( ! small || w > 3 * h || h > 3* w )
375 addIcon = updateIcons( paint, horLayout ); 375 addIcon = updateIcons( paint, horLayout );
376 376
377 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 377 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
378 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 378 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
379 if ( ! small ) { 379 if ( ! small ) {
380 x += 3; yy += 3;w -= 6; h-= 5; 380 x += 3; yy += 3;w -= 6; h-= 5;
381 } else { 381 } else {
382 x += 2; yy += 1;w -= 4; h-= 4; 382 x += 2; yy += 1;w -= 4; h-= 4;
383 if ( nfh < 6.01 ) { 383 if ( nfh < 6.01 ) {
384 yy -= 2; 384 yy -= 2;
385 h += 4; 385 h += 4;
386 } 386 }
@@ -519,97 +519,97 @@ void KOAgendaItem::paintEvent ( QPaintEvent *e )
519 xx += rx; 519 xx += rx;
520 520
521 if ( xx < 0 ) { 521 if ( xx < 0 ) {
522 rw = rw + xx; 522 rw = rw + xx;
523 rx -= xx; 523 rx -= xx;
524 xx = 0; 524 xx = 0;
525 if ( rw <= 1 ) { 525 if ( rw <= 1 ) {
526 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 526 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
527 return; 527 return;
528 } 528 }
529 } 529 }
530 if ( paintFrom->width() < xx+rw ) { 530 if ( paintFrom->width() < xx+rw ) {
531 rw = paintFrom->width() - xx; 531 rw = paintFrom->width() - xx;
532 if ( rw <= 1 ) { 532 if ( rw <= 1 ) {
533 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 533 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
534 return; 534 return;
535 } 535 }
536 } 536 }
537 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 537 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
538 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); 538 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
539} 539}
540void KOAgendaItem::computeText() 540void KOAgendaItem::computeText()
541{ 541{
542 mDisplayedText = mIncidence->summary(); 542 mDisplayedText = mIncidence->summary();
543 if ( (mIncidence->type() == "Todo") ) { 543 if ( (mIncidence->typeID() == todoID ) ) {
544 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 544 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
545 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 545 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
546 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 546 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
547 else if ( !(mIncidence->doesFloat())) 547 else if ( !(mIncidence->doesFloat()))
548 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 548 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
549 } 549 }
550 } else { 550 } else {
551 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 551 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
552 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 552 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
553 553
554 if ( mAllDay ) { 554 if ( mAllDay ) {
555 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 555 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
556 if ( mIncidence->doesRecur() ) { 556 if ( mIncidence->doesRecur() ) {
557 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 557 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
558 } else { 558 } else {
559 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 559 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
560 } 560 }
561 } 561 }
562 } 562 }
563 } 563 }
564 564
565 if ( !mIncidence->location().isEmpty() ) { 565 if ( !mIncidence->location().isEmpty() ) {
566 if ( mAllDay ) 566 if ( mAllDay )
567 mDisplayedText += " ("; 567 mDisplayedText += " (";
568 else 568 else
569 mDisplayedText += "\n("; 569 mDisplayedText += "\n(";
570 mDisplayedText += mIncidence->location() +")"; 570 mDisplayedText += mIncidence->location() +")";
571 } 571 }
572#ifdef DESKTOP_VERSION 572#ifdef DESKTOP_VERSION
573 QString tipText = mIncidence->summary(); 573 QString tipText = mIncidence->summary();
574 if ( !mIncidence->doesFloat() ) { 574 if ( !mIncidence->doesFloat() ) {
575 if ( mIncidence->type() == "Event" ) { 575 if ( mIncidence->typeID() == eventID ) {
576 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 576 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
577 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 577 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
578 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 578 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
579 } 579 }
580 else { 580 else {
581 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 581 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
582 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 582 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
583 } 583 }
584 } 584 }
585 else if ( mIncidence->type() == "Todo" ) { 585 else if ( mIncidence->typeID() == todoID ) {
586 if (mIncidence->hasStartDate()) 586 if (mIncidence->hasStartDate())
587 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 587 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
588 if (((Todo*)mIncidence)->hasDueDate()) 588 if (((Todo*)mIncidence)->hasDueDate())
589 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 589 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
590 } 590 }
591 } else if ( mIncidence->type() == "Todo" ) { 591 } else if ( mIncidence->typeID() == todoID ) {
592 if (mIncidence->hasStartDate()) 592 if (mIncidence->hasStartDate())
593 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 593 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
594 if (((Todo*)mIncidence)->hasDueDate()) 594 if (((Todo*)mIncidence)->hasDueDate())
595 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 595 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
596 } 596 }
597 597
598 if (!mIncidence->location().isEmpty()) { 598 if (!mIncidence->location().isEmpty()) {
599 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 599 tipText += "\n"+i18n("Location: ")+mIncidence->location();
600 } 600 }
601 QToolTip::add(this,tipText,toolTipGroup(),""); 601 QToolTip::add(this,tipText,toolTipGroup(),"");
602#endif 602#endif
603} 603}
604void KOAgendaItem::updateItem() 604void KOAgendaItem::updateItem()
605{ 605{
606 computeText(); 606 computeText();
607 607
608 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 608 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
609 paintMe( mSelected ); 609 paintMe( mSelected );
610 repaint( false); 610 repaint( false);
611} 611}
612 612
613void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 613void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
614{ 614{
615 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 615 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());