author | zautrix <zautrix> | 2005-08-17 13:06:53 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-17 13:06:53 (UTC) |
commit | 4b66565ed2db51bc636b7b4c12f19f036d9b80f3 (patch) (side-by-side diff) | |
tree | 402372be9f52835e15757a51c18cfc46d47c8953 /korganizer/koagendaitem.cpp | |
parent | 31393a99cd2b190e62a7a09a7739a14af83936d1 (diff) | |
download | kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.zip kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.tar.gz kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.tar.bz2 |
allday agenda item fix
-rw-r--r-- | korganizer/koagendaitem.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 49ad9b8..7a685d8 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -467,384 +467,402 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint ) } } pa.end(); } QPixmap * KOAgendaItem::paintPix() { static QPixmap* mPaintPix = 0; if ( ! mPaintPix ) { int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height(); mPaintPix = new QPixmap(w,h); } return mPaintPix ; } QPixmap * KOAgendaItem::paintPixAllday() { static QPixmap* mPaintPixA = 0; if ( ! mPaintPixA ) { int w = QApplication::desktop()->width(); int h = QApplication::desktop()->height()/5; mPaintPixA = new QPixmap(w,h); } return mPaintPixA ; } void KOAgendaItem::repaintItem() { globalFlagBlockAgendaItemPaint = 0; globalFlagBlockAgenda = 0; repaint( false ); } 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; if ( mSelected ) return; } 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 ) { paintMe( mSelected ); return; } 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()); return; } } if ( paintFrom->width() < xx+rw ) { rw = paintFrom->width() - xx; if ( rw <= 1 ) { //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->typeID() == todoID ) ) { 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() ) { if ( mIncidence->doesRecur() ) { mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; } else { 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() +")"; } #ifdef DESKTOP_VERSION QString tipText = mIncidence->summary(); if ( !mIncidence->doesFloat() ) { if ( mIncidence->typeID() == eventID ) { 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->typeID() == todoID ) { 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->typeID() == todoID ) { 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(),""); #endif } 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; } - +// it may be that allday agenda items have a needed width > 32000 +// this code is to fix this problem +int KOAgendaItem::resizeMe( int grid, int wid, int hei ) +{ + int diff = 0; + if ( mCellX < -3 && mAllDay ) { + diff = (mCellX + 3) * -grid; + //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); + if ( diff >= wid ) { + // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); + //diff = 0; + } + } + if ( wid == width() || diff >= wid ) + resize( wid, hei ); + else + resize( wid - diff, hei ); + return diff; +} /* 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; setCellY(newYTop, newYBottom); } void KOAgendaItem::expandLeft(int dx) { int newX = cellX() + dx; int newXWidth = cellXWidth(); if (newX > newXWidth) newX = newXWidth; setCellX(newX,newXWidth); } void KOAgendaItem::expandRight(int dx) { int newX = cellX(); int newXWidth = cellXWidth() + dx; if (newXWidth < newX) newXWidth = newX; setCellX(newX,newXWidth); } QToolTipGroup *KOAgendaItem::toolTipGroup() { if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); return mToolTipGroup; } void KOAgendaItem::dragEnterEvent( QDragEnterEvent *e ) { #ifndef KORG_NODND if ( ICalDrag::canDecode( e ) || VCalDrag::canDecode( e ) || !QTextDrag::canDecode( e ) ) { e->ignore(); return; } e->accept(); #endif } void KOAgendaItem::dropEvent( QDropEvent *e ) { #ifndef KORG_NODND QString text; if(QTextDrag::decode(e,text)) { kdDebug() << "Dropped : " << text << endl; QStringList emails = QStringList::split(",",text); for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { kdDebug() << " Email: " << (*it) << endl; int pos = (*it).find("<"); QString name = (*it).left(pos); QString email = (*it).mid(pos); if (!email.isEmpty()) { mIncidence->addAttendee(new Attendee(name,email)); } } } #endif } QPtrList<KOAgendaItem> KOAgendaItem::conflictItems() { return mConflictItems; } void KOAgendaItem::setConflictItems(QPtrList<KOAgendaItem> ci) { mConflictItems = ci; KOAgendaItem *item; for ( item=mConflictItems.first(); item != 0; item=mConflictItems.next() ) { item->addConflictItem(this); } } void KOAgendaItem::addConflictItem(KOAgendaItem *ci) { if (mConflictItems.find(ci)<0) mConflictItems.append(ci); } bool KOAgendaItem::checkLayout() { if ( !mConflictItems.count() ) return true; int max = 0; KOAgendaItem *item; for ( item=mConflictItems.first(); item != 0; item=mConflictItems.next() ) { if ( item->subCells() > max ) max = item->subCells(); } if ( max > subCells() ) { setSubCells( max ); return false; } return true; } |