26 #include <tqtooltip.h>
27 #include <tqdragobject.h>
28 #include <tqpainter.h>
30 #include <kiconloader.h>
32 #include <tdelocale.h>
33 #include <kwordwrap.h>
34 #include <tdemessagebox.h>
36 #include <libkcal/icaldrag.h>
37 #include <libkcal/vcaldrag.h>
38 #include <libtdepim/kvcarddrag.h>
39 #include <libemailfunctions/email.h>
41 #include <tdeabc/addressee.h>
42 #include <tdeabc/vcardconverter.h>
46 #include "koglobals.h"
48 #include "koincidencetooltip.h"
49 #include "koagendaitem.h"
50 #include "koagendaitem.moc"
54 TQToolTipGroup *KOAgendaItem::mToolTipGroup = 0;
56 TQPixmap *KOAgendaItem::alarmPxmp = 0;
57 TQPixmap *KOAgendaItem::recurPxmp = 0;
58 TQPixmap *KOAgendaItem::readonlyPxmp = 0;
59 TQPixmap *KOAgendaItem::replyPxmp = 0;
60 TQPixmap *KOAgendaItem::groupPxmp = 0;
61 TQPixmap *KOAgendaItem::groupPxmpTentative = 0;
62 TQPixmap *KOAgendaItem::organizerPxmp = 0;
67 const TQDate &qd, TQWidget *parent,
68 int itemPos,
int itemCount,
69 const char *name, WFlags f ) :
70 TQWidget( parent, name, f ), mCalendar( calendar ), mIncidence( incidence ), mDate( qd ),
71 mLabelText( mIncidence->summary() ), mIconAlarm( false ),
72 mIconRecur( false ), mIconReadonly( false ), mIconReply( false ),
73 mIconGroup( false ), mIconGroupTentative( false ), mIconOrganizer( false ),
74 mSpecialEvent( false ),
75 mItemPos( itemPos ), mItemCount( itemCount ),
76 mMultiItemInfo( 0 ), mStartMoveInfo( 0 )
78 setBackgroundMode( TQt::NoBackground );
82 setMouseTracking(
true );
83 mResourceColor = TQColor();
91 setAcceptDrops(
true );
94 void KOAgendaItem::updateIcons()
96 if ( !mIncidence )
return;
97 mIconReadonly = mIncidence->isReadOnly();
98 mIconRecur = mIncidence->doesRecur();
99 mIconAlarm = mIncidence->isAlarmEnabled();
100 if ( mIncidence->attendeeCount() > 1 ) {
101 if ( KOPrefs::instance()->thatIsMe( mIncidence->organizer().email() ) ) {
104 mIconGroupTentative =
false;
105 mIconOrganizer =
true;
107 Attendee *me = mIncidence->attendeeByMails( KOPrefs::instance()->allEmails() );
109 if ( me->
status() == Attendee::NeedsAction && me->
RSVP() ) {
112 mIconGroupTentative =
false;
113 mIconOrganizer =
false;
114 }
else if ( me->
status() == Attendee::Tentative ) {
117 mIconGroupTentative =
true;
118 mIconOrganizer =
false;
122 mIconGroupTentative =
false;
123 mIconOrganizer =
false;
128 mIconGroupTentative =
false;
129 mIconOrganizer =
false;
137 void KOAgendaItem::select(
bool selected )
139 if ( mSelected == selected )
return;
140 mSelected = selected;
145 bool KOAgendaItem::dissociateFromMultiItem()
147 if ( !isMultiItem() )
return false;
148 KOAgendaItem *firstItem = firstMultiItem();
149 if ( firstItem ==
this ) firstItem = nextMultiItem();
150 KOAgendaItem *lastItem = lastMultiItem();
151 if ( lastItem ==
this ) lastItem = prevMultiItem();
153 KOAgendaItem *prevItem = prevMultiItem();
154 KOAgendaItem *nextItem = nextMultiItem();
157 prevItem->setMultiItem( firstItem,
158 prevItem->prevMultiItem(),
159 nextItem, lastItem );
162 nextItem->setMultiItem( firstItem, prevItem,
163 nextItem->prevMultiItem(),
166 delete mMultiItemInfo;
171 bool KOAgendaItem::setIncidence(
Incidence *i )
181 int KOAgendaItem::cellHeight()
const
183 return mCellYBottom - mCellYTop + 1;
189 int KOAgendaItem::cellWidth()
const
191 return mCellXRight - mCellXLeft + 1;
194 void KOAgendaItem::setItemDate(
const TQDate &qd )
199 void KOAgendaItem::setCellXY(
int X,
int YTop,
int YBottom )
203 mCellYBottom = YBottom;
206 void KOAgendaItem::setCellXRight(
int xright )
208 mCellXRight = xright;
211 void KOAgendaItem::setCellX(
int XLeft,
int XRight )
214 mCellXRight = XRight;
217 void KOAgendaItem::setCellY(
int YTop,
int YBottom )
220 mCellYBottom = YBottom;
223 void KOAgendaItem::setMultiItem( KOAgendaItem *first, KOAgendaItem *prev,
224 KOAgendaItem *next, KOAgendaItem *last )
226 if ( !mMultiItemInfo ) {
227 mMultiItemInfo =
new MultiItemInfo;
229 mMultiItemInfo->mFirstMultiItem = first;
230 mMultiItemInfo->mPrevMultiItem = prev;
231 mMultiItemInfo->mNextMultiItem = next;
232 mMultiItemInfo->mLastMultiItem = last;
234 bool KOAgendaItem::isMultiItem()
236 return mMultiItemInfo;
238 KOAgendaItem* KOAgendaItem::prependMoveItem(KOAgendaItem* e)
242 KOAgendaItem*first=0, *last=0;
244 first=mMultiItemInfo->mFirstMultiItem;
245 last=mMultiItemInfo->mLastMultiItem;
247 if (!first) first=
this;
248 if (!last) last=
this;
250 e->setMultiItem(0, 0, first, last);
251 first->setMultiItem(e, e, first->nextMultiItem(), first->lastMultiItem() );
253 KOAgendaItem*tmp=first->nextMultiItem();
255 tmp->setMultiItem( e, tmp->prevMultiItem(), tmp->nextMultiItem(), tmp->lastMultiItem() );
256 tmp = tmp->nextMultiItem();
259 if ( mStartMoveInfo && !e->moveInfo() ) {
260 e->mStartMoveInfo=
new MultiItemInfo( *mStartMoveInfo );
263 e->moveInfo()->mPrevMultiItem = 0;
264 e->moveInfo()->mNextMultiItem = first;
267 if (first && first->moveInfo()) {
268 first->moveInfo()->mPrevMultiItem = e;
273 KOAgendaItem* KOAgendaItem::appendMoveItem(KOAgendaItem* e)
277 KOAgendaItem*first=0, *last=0;
279 first=mMultiItemInfo->mFirstMultiItem;
280 last=mMultiItemInfo->mLastMultiItem;
282 if (!first) first=
this;
283 if (!last) last=
this;
285 e->setMultiItem( first, last, 0, 0 );
286 KOAgendaItem*tmp=first;
289 tmp->setMultiItem(tmp->firstMultiItem(), tmp->prevMultiItem(), tmp->nextMultiItem(), e);
290 tmp = tmp->nextMultiItem();
292 last->setMultiItem( last->firstMultiItem(), last->prevMultiItem(), e, e);
294 if ( mStartMoveInfo && !e->moveInfo() ) {
295 e->mStartMoveInfo=
new MultiItemInfo( *mStartMoveInfo );
298 e->moveInfo()->mPrevMultiItem = last;
299 e->moveInfo()->mNextMultiItem = 0;
301 if (last && last->moveInfo()) {
302 last->moveInfo()->mNextMultiItem = e;
307 KOAgendaItem* KOAgendaItem::removeMoveItem(KOAgendaItem* e)
310 KOAgendaItem *first = mMultiItemInfo->mFirstMultiItem;
311 KOAgendaItem *next, *prev;
312 KOAgendaItem *last = mMultiItemInfo->mLastMultiItem;
313 if (!first) first =
this;
314 if (!last) last =
this;
316 first = first->nextMultiItem();
317 first->setMultiItem( 0, 0, first->nextMultiItem(), first->lastMultiItem() );
320 last=last->prevMultiItem();
321 last->setMultiItem( last->firstMultiItem(), last->prevMultiItem(), 0, 0 );
324 KOAgendaItem *tmp = first;
326 delete mMultiItemInfo;
331 next = tmp->nextMultiItem();
332 prev = tmp->prevMultiItem();
334 next = next->nextMultiItem();
337 prev = prev->prevMultiItem();
339 tmp->setMultiItem((tmp==first)?0:first, (tmp==prev)?0:prev, (tmp==next)?0:next, (tmp==last)?0:last);
340 tmp = tmp->nextMultiItem();
348 void KOAgendaItem::startMove()
350 KOAgendaItem* first =
this;
351 if ( isMultiItem() && mMultiItemInfo->mFirstMultiItem ) {
352 first=mMultiItemInfo->mFirstMultiItem;
354 first->startMovePrivate();
357 void KOAgendaItem::startMovePrivate()
359 mStartMoveInfo =
new MultiItemInfo;
360 mStartMoveInfo->mStartCellXLeft = mCellXLeft;
361 mStartMoveInfo->mStartCellXRight = mCellXRight;
362 mStartMoveInfo->mStartCellYTop = mCellYTop;
363 mStartMoveInfo->mStartCellYBottom = mCellYBottom;
364 if (mMultiItemInfo) {
365 mStartMoveInfo->mFirstMultiItem = mMultiItemInfo->mFirstMultiItem;
366 mStartMoveInfo->mLastMultiItem = mMultiItemInfo->mLastMultiItem;
367 mStartMoveInfo->mPrevMultiItem = mMultiItemInfo->mPrevMultiItem;
368 mStartMoveInfo->mNextMultiItem = mMultiItemInfo->mNextMultiItem;
370 mStartMoveInfo->mFirstMultiItem = 0;
371 mStartMoveInfo->mLastMultiItem = 0;
372 mStartMoveInfo->mPrevMultiItem = 0;
373 mStartMoveInfo->mNextMultiItem = 0;
375 if ( isMultiItem() && mMultiItemInfo->mNextMultiItem )
377 mMultiItemInfo->mNextMultiItem->startMovePrivate();
381 void KOAgendaItem::resetMove()
383 if ( mStartMoveInfo ) {
384 if ( mStartMoveInfo->mFirstMultiItem ) {
385 mStartMoveInfo->mFirstMultiItem->resetMovePrivate();
392 void KOAgendaItem::resetMovePrivate()
394 if (mStartMoveInfo) {
395 mCellXLeft = mStartMoveInfo->mStartCellXLeft;
396 mCellXRight = mStartMoveInfo->mStartCellXRight;
397 mCellYTop = mStartMoveInfo->mStartCellYTop;
398 mCellYBottom = mStartMoveInfo->mStartCellYBottom;
403 if ( mMultiItemInfo ) {
405 mMultiItemInfo->mFirstMultiItem = mStartMoveInfo->mFirstMultiItem;
406 mMultiItemInfo->mPrevMultiItem = mStartMoveInfo->mPrevMultiItem;
407 mMultiItemInfo->mNextMultiItem = mStartMoveInfo->mNextMultiItem;
408 mMultiItemInfo->mLastMultiItem = mStartMoveInfo->mLastMultiItem;
410 if ( !mStartMoveInfo->mFirstMultiItem ) {
412 KOAgendaItem*toDel=mStartMoveInfo->mPrevMultiItem;
413 KOAgendaItem*nowDel=0L;
416 if (nowDel->moveInfo()) {
417 toDel=nowDel->moveInfo()->mPrevMultiItem;
419 emit removeAgendaItem( nowDel );
421 mMultiItemInfo->mFirstMultiItem = 0L;
422 mMultiItemInfo->mPrevMultiItem = 0L;
424 if ( !mStartMoveInfo->mLastMultiItem ) {
426 KOAgendaItem*toDel=mStartMoveInfo->mNextMultiItem;
427 KOAgendaItem*nowDel=0L;
430 if (nowDel->moveInfo()) {
431 toDel=nowDel->moveInfo()->mNextMultiItem;
433 emit removeAgendaItem( nowDel );
435 mMultiItemInfo->mLastMultiItem = 0L;
436 mMultiItemInfo->mNextMultiItem = 0L;
439 if ( mStartMoveInfo->mFirstMultiItem==0 && mStartMoveInfo->mLastMultiItem==0 ) {
441 delete mMultiItemInfo;
445 delete mStartMoveInfo;
448 emit showAgendaItem(
this );
449 if ( nextMultiItem() ) {
450 nextMultiItem()->resetMovePrivate();
454 void KOAgendaItem::endMove()
456 KOAgendaItem*first=firstMultiItem();
457 if (!first) first=
this;
458 first->endMovePrivate();
461 void KOAgendaItem::endMovePrivate()
463 if ( mStartMoveInfo ) {
465 if ( !firstMultiItem() || firstMultiItem()==
this ) {
466 KOAgendaItem*toDel=mStartMoveInfo->mPrevMultiItem;
467 KOAgendaItem*nowDel = 0;
470 if (nowDel->moveInfo()) {
471 toDel=nowDel->moveInfo()->mPrevMultiItem;
473 emit removeAgendaItem( nowDel );
477 if ( !lastMultiItem() || lastMultiItem()==
this ) {
478 KOAgendaItem*toDel=mStartMoveInfo->mNextMultiItem;
479 KOAgendaItem*nowDel = 0;
482 if (nowDel->moveInfo()) {
483 toDel=nowDel->moveInfo()->mNextMultiItem;
485 emit removeAgendaItem( nowDel );
489 delete mStartMoveInfo;
491 if ( nextMultiItem() )
492 nextMultiItem()->endMovePrivate();
496 void KOAgendaItem::moveRelative(
int dx,
int dy)
498 int newXLeft = cellXLeft() + dx;
499 int newXRight = cellXRight() + dx;
500 int newYTop = cellYTop() + dy;
501 int newYBottom = cellYBottom() + dy;
502 setCellXY(newXLeft,newYTop,newYBottom);
503 setCellXRight(newXRight);
506 void KOAgendaItem::expandTop(
int dy)
508 int newYTop = cellYTop() + dy;
509 int newYBottom = cellYBottom();
510 if (newYTop > newYBottom) newYTop = newYBottom;
511 setCellY(newYTop, newYBottom);
514 void KOAgendaItem::expandBottom(
int dy)
516 int newYTop = cellYTop();
517 int newYBottom = cellYBottom() + dy;
518 if (newYBottom < newYTop) newYBottom = newYTop;
519 setCellY(newYTop, newYBottom);
522 void KOAgendaItem::expandLeft(
int dx)
524 int newXLeft = cellXLeft() + dx;
525 int newXRight = cellXRight();
526 if ( newXLeft > newXRight ) newXLeft = newXRight;
527 setCellX( newXLeft, newXRight );
530 void KOAgendaItem::expandRight(
int dx)
532 int newXLeft = cellXLeft();
533 int newXRight = cellXRight() + dx;
534 if ( newXRight < newXLeft ) newXRight = newXLeft;
535 setCellX( newXLeft, newXRight );
538 TQToolTipGroup *KOAgendaItem::toolTipGroup()
540 if (!mToolTipGroup) mToolTipGroup =
new TQToolTipGroup(0);
541 return mToolTipGroup;
544 void KOAgendaItem::dragEnterEvent( TQDragEnterEvent *e )
547 if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) ) {
551 if ( KVCardDrag::canDecode( e ) || TQTextDrag::canDecode( e ) )
558 void KOAgendaItem::addAttendee(
const TQString &newAttendee )
560 kdDebug(5850) <<
" Email: " << newAttendee << endl;
561 TQString name, email;
562 KPIM::getNameAndMail( newAttendee, name, email );
563 if ( !( name.isEmpty() && email.isEmpty() ) ) {
564 mIncidence->addAttendee(
new Attendee(name,email));
565 KMessageBox::information(
this, i18n(
"Attendee \"%1\" added to the calendar item \"%2\"").arg(KPIM::normalizedAddress(name, email, TQString())).arg(text()), i18n(
"Attendee added"),
"AttendeeDroppedAdded" );
570 void KOAgendaItem::dropEvent( TQDropEvent *e )
576 bool decoded = TQTextDrag::decode( e, text );
577 if( decoded && text.startsWith(
"file:" ) ) {
578 mIncidence->addAttachment(
new Attachment( text ) );
583 TDEABC::Addressee::List list;
584 if ( KVCardDrag::decode( e, list ) ) {
585 TDEABC::Addressee::List::Iterator it;
586 for ( it = list.begin(); it != list.end(); ++it ) {
587 TQString em( (*it).fullEmail() );
588 if ( em.isEmpty() ) {
589 em = (*it).realName();
596 kdDebug(5850) <<
"Dropped : " << text << endl;
598 TQStringList emails = TQStringList::split(
",", text );
599 for( TQStringList::ConstIterator it = emails.begin(); it != emails.end();
610 TQPtrList<KOAgendaItem> KOAgendaItem::conflictItems()
612 return mConflictItems;
615 void KOAgendaItem::setConflictItems( TQPtrList<KOAgendaItem> ci )
619 for ( item = mConflictItems.first(); item != 0;
620 item = mConflictItems.next() ) {
621 item->addConflictItem(
this );
625 void KOAgendaItem::addConflictItem( KOAgendaItem *ci )
627 if ( mConflictItems.find( ci ) < 0 ) mConflictItems.append( ci );
630 TQString KOAgendaItem::label()
const
635 bool KOAgendaItem::overlaps( KOrg::CellItem *o )
const
637 KOAgendaItem *other =
static_cast<KOAgendaItem *
>( o );
639 if ( cellXLeft() <= other->cellXRight() &&
640 cellXRight() >= other->cellXLeft() ) {
641 if ( ( cellYTop() <= other->cellYBottom() ) &&
642 ( cellYBottom() >= other->cellYTop() ) ) {
650 void KOAgendaItem::paintFrame( TQPainter *p,
const TQColor &color )
652 TQColor oldpen(p->pen().color());
654 p->drawRect( 0, 0, width(), height() );
655 p->drawRect( 1, 1, width() - 2, height() - 2 );
659 static void conditionalPaint( TQPainter *p,
bool cond,
int &x,
int ft,
660 const TQPixmap &pxmp )
664 p->drawPixmap( x, ft, pxmp );
665 x += pxmp.width() + ft;
668 void KOAgendaItem::paintEventIcon( TQPainter *p,
int &x,
int ft )
670 if ( !mIncidence )
return;
672 if ( mIncidence->type() ==
"Event" ) {
674 if ( mIncidence->customProperty(
"KABC",
"BIRTHDAY" ) ==
"YES" ) {
675 mSpecialEvent =
true;
676 if ( mIncidence->customProperty(
"KABC",
"ANNIVERSARY" ) ==
"YES" ) {
677 eventPxmp = KOGlobals::self()->smallIcon(
"calendaranniversary" );
679 eventPxmp = KOGlobals::self()->smallIcon(
"calendarbirthday" );
681 conditionalPaint( p,
true, x, ft, eventPxmp );
688 void KOAgendaItem::paintTodoIcon( TQPainter *p,
int &x,
int ft )
690 if ( !mIncidence )
return;
691 static const TQPixmap todoPxmp =
692 KOGlobals::self()->smallIcon(
"todo" );
693 static const TQPixmap completedPxmp =
694 KOGlobals::self()->smallIcon(
"checkedbox" );
695 if ( mIncidence->type() !=
"Todo" )
697 bool b = (
static_cast<Todo *
>( mIncidence ) )->isCompleted();
698 conditionalPaint( p, !b, x, ft, todoPxmp );
699 conditionalPaint( p, b, x, ft, completedPxmp );
702 void KOAgendaItem::paintAlarmIcon( TQPainter *p,
int &x,
int ft )
704 if (!mIconAlarm)
return;
708 if ( visibleRect().height() - ft < alarmPxmp->height() )
709 y -= ( alarmPxmp->height() - visibleRect().height() - ft );
710 p->drawPixmap( x, y, *alarmPxmp );
711 x += alarmPxmp->width() + ft;
714 void KOAgendaItem::paintIcons( TQPainter *p,
int &x,
int ft )
716 paintEventIcon( p, x, ft );
717 paintTodoIcon( p, x, ft );
718 if ( !mSpecialEvent ) {
719 paintAlarmIcon( p, x, ft );
721 conditionalPaint( p, mIconRecur && !mSpecialEvent, x, ft, *recurPxmp );
722 conditionalPaint( p, mIconReadonly && !mSpecialEvent, x, ft, *readonlyPxmp );
723 conditionalPaint( p, mIconReply, x, ft, *replyPxmp );
724 conditionalPaint( p, mIconGroup, x, ft, *groupPxmp );
725 conditionalPaint( p, mIconGroupTentative, x, ft, *groupPxmpTentative );
726 conditionalPaint( p, mIconOrganizer, x, ft, *organizerPxmp );
729 void KOAgendaItem::paintEvent( TQPaintEvent *ev )
737 if ( !mIncidence )
return;
739 TQRect visRect = visibleRect();
743 if ( ev->rect() != visRect && visRect.isValid() && ev->rect().isValid() ) {
750 const int margin = 1 + ft;
758 alarmPxmp =
new TQPixmap( KOGlobals::self()->smallIcon(
"bell") );
759 recurPxmp =
new TQPixmap( KOGlobals::self()->smallIcon(
"recur") );
760 readonlyPxmp =
new TQPixmap( KOGlobals::self()->smallIcon(
"readonlyevent") );
761 replyPxmp =
new TQPixmap( KOGlobals::self()->smallIcon(
"mail-reply-sender") );
762 groupPxmp =
new TQPixmap( KOGlobals::self()->smallIcon(
"groupevent") );
763 groupPxmpTentative =
new TQPixmap( KOGlobals::self()->smallIcon(
"groupeventtentative") );
764 organizerPxmp =
new TQPixmap( KOGlobals::self()->smallIcon(
"organizer") );
768 if ( mIncidence->type() ==
"Todo" ) {
769 if (
static_cast<Todo*
>(mIncidence)->isOverdue() )
770 bgColor = KOPrefs::instance()->todoOverdueColor();
771 else if (
static_cast<Todo*
>(mIncidence)->dtDue().date() ==
772 TQDateTime::currentDateTime().date() )
773 bgColor = KOPrefs::instance()->todoDueTodayColor();
776 TQColor categoryColor;
777 TQStringList categories = mIncidence->categories();
778 TQString cat = categories.first();
780 categoryColor = KOPrefs::instance()->unsetCategoryColor();
782 categoryColor = *(KOPrefs::instance()->categoryColor(cat));
784 TQColor resourceColor = mResourceColor;
785 if ( !resourceColor.isValid() )
786 resourceColor = categoryColor;
789 if ( KOPrefs::instance()->agendaViewColors() == KOPrefs::ResourceOnly ||
790 KOPrefs::instance()->agendaViewColors() == KOPrefs::CategoryInsideResourceOutside ) {
791 frameColor = bgColor.isValid() ? bgColor : resourceColor;
793 frameColor = bgColor.isValid() ? bgColor : categoryColor;
796 if ( !bgColor.isValid() ) {
797 if ( KOPrefs::instance()->agendaViewColors() == KOPrefs::ResourceOnly ||
798 KOPrefs::instance()->agendaViewColors() == KOPrefs::ResourceInsideCategoryOutside ) {
799 bgColor = resourceColor;
801 bgColor = categoryColor;
805 if ( cat.isEmpty() &&
806 KOPrefs::instance()->agendaViewColors() == KOPrefs::ResourceInsideCategoryOutside ) {
807 frameColor = bgColor;
810 if ( cat.isEmpty() &&
811 KOPrefs::instance()->agendaViewColors() == KOPrefs::CategoryInsideResourceOutside ) {
812 bgColor = frameColor;
816 frameColor = TQColor( 85 + frameColor.red() * 2/3,
817 85 + frameColor.green() * 2/3,
818 85 + frameColor.blue() * 2/3 );
820 frameColor = frameColor.dark( 115 );
822 TQColor textColor = getTextColor(bgColor);
823 p.setPen( textColor );
824 p.setBackgroundColor( bgColor );
825 p.setFont(KOPrefs::instance()->mAgendaViewFont);
826 TQFontMetrics fm = p.fontMetrics();
828 int singleLineHeight = fm.boundingRect( mLabelText ).height();
830 p.eraseRect( 0, 0, width(), height() );
831 paintFrame( &p, frameColor );
838 if ( !isMultiItem() ) {
839 shortH = TDEGlobal::locale()->formatTime(mIncidence->dtStart().time());
840 if (mIncidence->type() !=
"Todo")
841 longH = i18n(
"%1 - %2").arg(shortH)
842 .arg(TDEGlobal::locale()->formatTime(mIncidence->dtEnd().time()));
845 }
else if ( !mMultiItemInfo->mFirstMultiItem ) {
846 shortH = TDEGlobal::locale()->formatTime(mIncidence->dtStart().time());
849 shortH = TDEGlobal::locale()->formatTime(mIncidence->dtEnd().time());
850 longH = i18n(
"- %1").arg(shortH);
853 KWordWrap *ww = KWordWrap::formatText( fm,
854 TQRect(0, 0, width() - (2 * margin), -1),
857 int th = ww->boundingRect().height();
860 int hlHeight = TQMAX(fm.boundingRect(longH).height(),
861 TQMAX(alarmPxmp->height(), TQMAX(recurPxmp->height(),
862 TQMAX(readonlyPxmp->height(), TQMAX(replyPxmp->height(),
863 TQMAX(groupPxmp->height(), organizerPxmp->height()))))));
865 bool completelyRenderable = th < (height() - 2 * ft - 2 - hlHeight);
873 paintTodoIcon( &p, x, ft );
878 if ( (2 * singleLineHeight) > (height() - 2 * margin) ) {
879 int x = margin, txtWidth;
881 if ( mIncidence->doesFloat() ) {
883 paintIcons( &p, x, ft );
884 txtWidth = visRect.right() - margin - x;
887 paintIcons( &p, x, ft );
888 txtWidth = width() - margin - x;
891 int y = ((height() - 2 * ft - singleLineHeight) / 2) + fm.ascent();
892 KWordWrap::drawFadeoutText( &p, x, y,
893 txtWidth, mLabelText );
899 if ( ((!completelyRenderable) && ((height() - (2 * margin)) <= (5 * singleLineHeight)) ) ||
900 (isMultiItem() && mMultiItemInfo->mNextMultiItem && mMultiItemInfo->mFirstMultiItem) ) {
901 int x = margin, txtWidth;
903 if ( mIncidence->doesFloat() ) {
905 paintIcons( &p, x, ft );
906 txtWidth = visRect.right() - margin - x;
909 paintIcons( &p, x, ft );
910 txtWidth = width() - margin - x;
913 ww = KWordWrap::formatText( fm,
914 TQRect( 0, 0, txtWidth,
915 (height() - (2 * margin)) ),
920 ww->drawText( &p, x, margin, TQt::AlignHCenter | KWordWrap::FadeOut );
927 int y = 2 * ft + hlHeight;
928 if ( completelyRenderable )
929 y += (height() - (2 * ft) - margin - hlHeight - th) / 2;
931 int x = margin, txtWidth, hTxtWidth, eventX;
933 if ( mIncidence->doesFloat() ) {
936 if ( (mIncidence->type() !=
"Todo") &&
937 (mIncidence->dtStart() != mIncidence->dtEnd()) ) {
940 .arg(TDEGlobal::locale()->formatDate(mIncidence->dtStart().date()))
941 .arg(TDEGlobal::locale()->formatDate(mIncidence->dtEnd().date()));
944 p.fillRect( 0, 0, width(), (ft/2) + margin + hlHeight,
945 TQBrush( frameColor ) );
950 txtWidth = visRect.right() - margin - x;
951 paintIcons( &p, x, ft );
952 hTxtWidth = visRect.right() - margin - x;
956 p.fillRect( 0, 0, width(), (ft/2) + margin + hlHeight,
957 TQBrush( frameColor ) );
959 txtWidth = width() - margin - x;
961 paintIcons( &p, x, ft );
962 hTxtWidth = width() - margin - x;
966 int hw = fm.boundingRect( longH ).width();
967 if ( hw > hTxtWidth ) {
969 hw = fm.boundingRect( shortH ).width();
971 x += (hTxtWidth - hw) / 2;
974 x += (hTxtWidth - hw) / 2;
976 p.setBackgroundColor( frameColor );
977 p.setPen( getTextColor( frameColor ) );
978 KWordWrap::drawFadeoutText( &p, x, ft + fm.ascent(), hTxtWidth, headline );
981 ww = KWordWrap::formatText( fm,
982 TQRect( 0, 0, txtWidth, height() - margin - y ),
986 p.setBackgroundColor( bgColor );
987 p.setPen( textColor );
988 TQString ws = ww->wrappedString();
989 if ( ws.left( ws.length()-1 ).find(
'\n' ) >= 0 )
990 ww->drawText( &p, eventX, y,
991 TQt::AlignAuto | KWordWrap::FadeOut );
993 ww->drawText( &p, eventX + (txtWidth-ww->boundingRect().width()-2*margin)/2,
994 y, TQt::AlignHCenter | KWordWrap::FadeOut );