-rw-r--r-- | korganizer/koagenda.cpp | 42 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 20 | ||||
-rw-r--r-- | korganizer/koagendaitem.h | 1 |
3 files changed, 44 insertions, 19 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 88f5d99..796d633 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -958,8 +958,8 @@ void KOAgenda::performItemAction(QPoint viewportPos) int x,y; gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); - moveItem->resize(mGridSpacingX * moveItem->cellWidth(), + int diff = moveItem->resizeMe(mGridSpacingX, mGridSpacingX* moveItem->cellWidth(), mGridSpacingY * moveItem->cellHeight()); moveItem->raise(); - moveChild(moveItem,x,y); + moveChild(moveItem,x+diff,y); moveItem = moveItem->nextMultiItem(); } @@ -983,14 +983,15 @@ void KOAgenda::performItemAction(QPoint viewportPos) if (mCurrentCellX <= mActionItem->cellXWidth()) { mActionItem->expandLeft(gx - mCurrentCellX); - mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), - mActionItem->height()); + int diff = mActionItem->resizeMe(mGridSpacingX , + mGridSpacingX * mActionItem->cellWidth(), + mActionItem->height()); int x,y; gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); - moveChild(mActionItem,x,childY(mActionItem)); + moveChild(mActionItem,x+diff,childY(mActionItem)); } } else if (mActionType == RESIZERIGHT) { if (mCurrentCellX >= mActionItem->cellX()) { mActionItem->expandRight(gx - mCurrentCellX); - mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), + mActionItem->resizeMe(mGridSpacingX, mGridSpacingX * mActionItem->cellWidth(), mActionItem->height()); } @@ -1218,6 +1219,7 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) item=conflictItems.next() ) { item->setSubCells(maxSubCells); + int diff = 0; if (mAllDayMode) { - item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); + diff = item->resizeMe( mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth); } else { item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); @@ -1230,5 +1232,5 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) x += item->subCell() * newSubCellWidth; } - moveChild(item,x,y); + moveChild(item,x+diff,y); // qDebug("moveChild %s %d %d ", item->incidence()->summary().latin1() ,x,y); //item->updateItem(); @@ -1244,6 +1246,7 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) if ( item2->subCells() != maxSubCells) { item2->setSubCells(maxSubCells); + int diff = 0; if (mAllDayMode) { - item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); + diff = item2->resizeMe(mGridSpacingX, item2->cellWidth() * mGridSpacingX, newSubCellWidth); } else { item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); @@ -1256,5 +1259,5 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) x += item2->subCell() * newSubCellWidth; } - moveChild(item2,x,y); + moveChild(item2,x+diff,y); //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); } @@ -1265,9 +1268,10 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) placeItem->setSubCell(0); placeItem->setSubCells(1); - if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); + int diff = 0; + if (mAllDayMode) diff = placeItem->resizeMe( mGridSpacingX, placeItem->width(),mGridSpacingY); else placeItem->resize(mGridSpacingX,placeItem->height()); int x,y; gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); - moveChild(placeItem,x,y); + moveChild(placeItem,x+diff,y); } placeItem->setConflictItems(conflictItems); @@ -1396,9 +1400,10 @@ void KOAgenda::finishUpdate() //qDebug(" conflictitem found "); int newSubCellWidth; + int diff = 0; if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells(); else newSubCellWidth = mGridSpacingX / item->subCells(); if (mAllDayMode) { - item->resize(item->cellWidth() * mGridSpacingX, newSubCellWidth); + diff = item->resizeMe(mGridSpacingX, item->cellWidth() * mGridSpacingX, newSubCellWidth); } else { item->resize(newSubCellWidth, item->cellHeight() * mGridSpacingY); @@ -1411,5 +1416,5 @@ void KOAgenda::finishUpdate() x += item->subCell() * newSubCellWidth; } - moveChild(item,x,y); + moveChild(item,x+diff,y); } } @@ -1837,5 +1842,5 @@ KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,i agendaItem->setCellXY(XBegin,0,0); agendaItem->setCellXWidth(XEnd); - agendaItem->resize(mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); + agendaItem->resizeMe(mGridSpacingX, mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY); //addChild(agendaItem,XBegin*mGridSpacingX,0); @@ -1943,8 +1948,9 @@ void KOAgenda::computeSizes() for ( item=mItems.first(); item != 0; item=mItems.next() ) { subCellWidth = mGridSpacingY / item->subCells(); - item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); - moveChild(item,KOGlobals::self()->reverseLayout() ? + int diff = 0; + diff = item->resizeMe(mGridSpacingX ,mGridSpacingX * item->cellWidth(),subCellWidth); + moveChild(item,(KOGlobals::self()->reverseLayout() ? (mColumns - 1 - item->cellX()) * mGridSpacingX : - item->cellX() * mGridSpacingX, + item->cellX() * mGridSpacingX) + diff, item->subCell() * subCellWidth); } diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 49ad9b8..7a685d8 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -657,5 +657,23 @@ int KOAgendaItem::cellHeight() 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 diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index 2b26e95..97acd4c 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h @@ -110,4 +110,5 @@ class KOAgendaItem : public QWidget void initColor (); bool isAllDay() { return mAllDay; } + int resizeMe( int grid, int wid, int hei ); public slots: bool updateIcons( QPainter *, bool ); |