-rw-r--r-- | korganizer/koagendaitem.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 82d1eab..b30ad75 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -316,392 +316,392 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint ) pa.begin( paintPixSel() ); } else { if ( mAllDay ) pa.begin( paintPixAllday() ); else pa.begin( paintPix() ); } int x, yy, w, h; float nfh = 7.0; x = pos().x(); w = width(); h = height (); if ( mAllDay ) yy = y(); else yy = mCellYTop * ( height() / cellHeight() ); xPaintCoord= x; yPaintCoord = yy; wPaintCoord = width(); hPaintCoord = height(); //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); if ( paint == 0 ) paint = &pa; bool horLayout = ( w < h ); int maxhei = mFontPixelSize+4; if ( horLayout ) maxhei += AGENDA_ICON_SIZE -4; bool small = ( h < maxhei ); if ( ! small ) paint->setFont(KOPrefs::instance()->mAgendaViewFont); else { QFont f = KOPrefs::instance()->mAgendaViewFont; f.setBold( false ); int fh = f.pointSize(); nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; if ( nfh < 6 ) nfh = 6; f.setPointSize( nfh ); paint->setFont(f); } paint->fillRect ( x, yy, w, h, mBackgroundColor ); static const QPixmap completedPxmp = SmallIcon("greenhook16"); static const QPixmap overduePxmp = SmallIcon("redcross16"); if ( mIncidence->type() == "Todo" ) { Todo* tempTodo = static_cast<Todo*>(mIncidence); int xx = pos().x()+(width()-completedPxmp.width()-3 ); int yyy = yy+3; if ( tempTodo->isCompleted() ) paint->drawPixmap ( xx, yyy, completedPxmp ); else { paint->drawPixmap ( xx, yyy, overduePxmp ); } } bool addIcon = false; if ( ! small || w > 3 * h || h > 3* w ) addIcon = updateIcons( paint, horLayout ); qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); if ( ! small ) { x += 3; yy += 3;w -= 6; h-= 5; } else { x += 2; yy += 1;w -= 4; h-= 4; if ( nfh < 6.01 ) { yy -= 2; h += 4; } else if ( nfh < h -2 ) ++yy; } int align; #ifndef DESKTOP_VERSION align = ( AlignLeft|WordBreak|AlignTop); #else align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); #endif if ( addIcon ) { if ( ! horLayout ) { x += AGENDA_ICON_SIZE+3; w -= (AGENDA_ICON_SIZE+3); } else { yy+= AGENDA_ICON_SIZE+2; h -=(AGENDA_ICON_SIZE+3); } } int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); if ( colsum < 250 ) paint->setPen ( white); if ( x < 0 ) { w = w+x-3; x = 3; if ( w > parentWidget()->width() ){ w = parentWidget()->width() - 6; #ifndef DESKTOP_VERSION align = ( AlignHCenter|WordBreak|AlignTop); #else align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); #endif } } QRect dr; if ( w + x > parentWidget()->width() ) w = parentWidget()->width()-x; paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); //qDebug("%d %d %d %d ", x, yy, w, h ); if ( mIncidence->cancelled() ){ if ( ! small ) { QFontMetrics fm ( paint->font() ); paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); } } pa.end(); } void KOAgendaItem::resizePixmap( int w , int h ) { paintPix()->resize( w, h ); paintPixSel()->resize( w, h ); } QPixmap * KOAgendaItem::paintPix() { static QPixmap* mPaintPix = 0; if ( ! mPaintPix ) mPaintPix = new QPixmap(1,1); return mPaintPix ; } QPixmap * KOAgendaItem::paintPixAllday() { static QPixmap* mPaintPixA = 0; if ( ! mPaintPixA ) mPaintPixA = new QPixmap(1,1); return mPaintPixA ; } QPixmap * KOAgendaItem::paintPixSel() { static QPixmap* mPaintPixSel = 0; if ( ! mPaintPixSel ) mPaintPixSel = new QPixmap(1,1); return mPaintPixSel ; } void KOAgendaItem::paintEvent ( QPaintEvent *e ) { if ( globalFlagBlockAgendaItemPaint ) return; if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) return; int yy; if ( mAllDay ) yy = y(); else yy = mCellYTop * ( height() / cellHeight() ); int xx = x(); if ( xPaintCoord != xx || yPaintCoord != yy || wPaintCoord != width() || hPaintCoord != height()) { xPaintCoord= xx; yPaintCoord = yy; wPaintCoord = width(); hPaintCoord = height(); globalFlagBlockAgendaItemUpdate = 0; paintMe( mSelected ); //qDebug("calling paintMe "); globalFlagBlockAgendaItemUpdate = 1; } int rx, ry, rw, rh; rx = e->rect().x(); ry = e->rect().y(); rw = e->rect().width(); rh = e->rect().height(); //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); QPixmap* paintFrom ; if ( mSelected ) { paintFrom = paintPixSel(); } else { if ( mAllDay ) paintFrom = paintPixAllday(); else paintFrom = paintPix(); } xx += rx; if ( xx < 0 ) { rw = rw + xx; rx -= xx; xx = 0; if ( rw <= 1 ) { - qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); + //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); return; } } if ( paintFrom->width() < xx+rw ) { rw = paintFrom->width() - xx; if ( rw <= 1 ) { - qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); + //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); return; } } //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); } void KOAgendaItem::computeText() { mDisplayedText = mIncidence->summary(); if ( (mIncidence->type() == "Todo") ) { if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; else if ( !(mIncidence->doesFloat())) mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; } } else { if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; if ( mAllDay ) { if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; } } } if ( !mIncidence->location().isEmpty() ) { if ( mAllDay ) mDisplayedText += " ("; else mDisplayedText += "\n("; mDisplayedText += mIncidence->location() +")"; } QString tipText = mIncidence->summary(); if ( !mIncidence->doesFloat() ) { if ( mIncidence->type() == "Event" ) { if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); } else { tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); } } else if ( mIncidence->type() == "Todo" ) { if (mIncidence->hasStartDate()) tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); if (((Todo*)mIncidence)->hasDueDate()) tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); } } else if ( mIncidence->type() == "Todo" ) { if (mIncidence->hasStartDate()) tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); if (((Todo*)mIncidence)->hasDueDate()) tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); } if (!mIncidence->location().isEmpty()) { tipText += "\n"+i18n("Location: ")+mIncidence->location(); } QToolTip::add(this,tipText,toolTipGroup(),""); } void KOAgendaItem::updateItem() { computeText(); //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); paintMe( mSelected ); repaint( false); } void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) { //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); paintMe( mSelected ); repaint( false ); } /* Return height of item in units of agenda cells */ int KOAgendaItem::cellHeight() { int ret = mCellYBottom - mCellYTop + 1; if ( ret <= 0 ) { ret = 1; mCellYBottom = 0; mCellYTop = 0; } return ret; } /* Return height of item in units of agenda cells */ int KOAgendaItem::cellWidth() { return mCellXWidth - mCellX + 1; } void KOAgendaItem::setItemDate(QDate qd) { mDate = qd; } void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) { mCellX = X; mCellYTop = YTop; mCellYBottom = YBottom; } void KOAgendaItem::setCellXWidth(int xwidth) { mCellXWidth = xwidth; } void KOAgendaItem::setCellX(int XLeft, int XRight) { mCellX = XLeft; mCellXWidth = XRight; } void KOAgendaItem::setCellY(int YTop, int YBottom) { mCellYTop = YTop; mCellYBottom = YBottom; } void KOAgendaItem::setSubCell(int subCell) { mSubCell = subCell; } void KOAgendaItem::setSubCells(int subCells) { mSubCells = subCells; } void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, KOAgendaItem *last) { mFirstMultiItem = first; mNextMultiItem = next; mLastMultiItem = last; } void KOAgendaItem::startMove() { mStartCellX = mCellX; mStartCellXWidth = mCellXWidth; mStartCellYTop = mCellYTop; mStartCellYBottom = mCellYBottom; } void KOAgendaItem::resetMove() { mCellX = mStartCellX; mCellXWidth = mStartCellXWidth; mCellYTop = mStartCellYTop; mCellYBottom = mStartCellYBottom; } void KOAgendaItem::moveRelative(int dx, int dy) { int newX = cellX() + dx; int newXWidth = cellXWidth() + dx; int newYTop = cellYTop() + dy; int newYBottom = cellYBottom() + dy; setCellXY(newX,newYTop,newYBottom); setCellXWidth(newXWidth); } void KOAgendaItem::expandTop(int dy) { int newYTop = cellYTop() + dy; int newYBottom = cellYBottom(); if (newYTop > newYBottom) newYTop = newYBottom; setCellY(newYTop, newYBottom); } void KOAgendaItem::expandBottom(int dy) { int newYTop = cellYTop(); int newYBottom = cellYBottom() + dy; if (newYBottom < newYTop) newYBottom = newYTop; |