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 | |
parent | 31393a99cd2b190e62a7a09a7739a14af83936d1 (diff) | |
download | kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.zip kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.tar.gz kdepimpi-4b66565ed2db51bc636b7b4c12f19f036d9b80f3.tar.bz2 |
allday agenda item fix
-rw-r--r-- | korganizer/koagenda.cpp | 40 | ||||
-rw-r--r-- | korganizer/koagendaitem.cpp | 20 | ||||
-rw-r--r-- | korganizer/koagendaitem.h | 1 |
3 files changed, 43 insertions, 18 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 88f5d99..796d633 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp @@ -956,12 +956,12 @@ void KOAgenda::performItemAction(QPoint viewportPos) else dy = gy - mCurrentCellY; moveItem->moveRelative(gx - mCurrentCellX,dy); 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(); } } else if (mActionType == RESIZETOP) { if (mCurrentCellY <= mActionItem->cellYBottom()) { @@ -981,18 +981,19 @@ void KOAgenda::performItemAction(QPoint viewportPos) } } else if (mActionType == RESIZELEFT) { if (mCurrentCellX <= mActionItem->cellXWidth()) { mActionItem->expandLeft(gx - mCurrentCellX); - mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), + 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()); } } mCurrentCellX = gx; @@ -1216,10 +1217,11 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) // Adjust sub cell geometry of all direct conflict items for ( item=conflictItems.first(); item != 0; 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); } int x,y; @@ -1228,9 +1230,9 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) y += item->subCell() * newSubCellWidth; } else { 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(); } // Adjust sub cell geometry of all conflict items of all conflict items @@ -1242,10 +1244,11 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) for ( item2=conflictItems2.first(); item2 != 0; item2=conflictItems2.next() ) { 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); } int x,y; @@ -1254,22 +1257,23 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) y += item2->subCell() * newSubCellWidth; } else { x += item2->subCell() * newSubCellWidth; } - moveChild(item2,x,y); + moveChild(item2,x+diff,y); //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); } } } } } else { 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); // for ( item=conflictItems.first(); item != 0; // item=conflictItems.next() ) { @@ -1394,13 +1398,14 @@ void KOAgenda::finishUpdate() for ( item=mItems.first(); item != 0; item=mItems.next() ) { if ( !item->checkLayout() ) { //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); } int x,y; @@ -1409,9 +1414,9 @@ void KOAgenda::finishUpdate() y += item->subCell() * newSubCellWidth; } else { x += item->subCell() * newSubCellWidth; } - moveChild(item,x,y); + moveChild(item,x+diff,y); } } for ( item=mItems.first(); item != 0; item=mItems.next() ) { if ( !item->isVisible() ) @@ -1835,9 +1840,9 @@ KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,i KOAgendaItem *agendaItem = getNewItem(event,qd,viewport()); 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); mItems.append(agendaItem); @@ -1941,12 +1946,13 @@ void KOAgenda::computeSizes() KOAgendaItem *item; int subCellWidth; 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); } KOPrefs::instance()->mAllDaySize = mGridSpacingY; } else { diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 49ad9b8..7a685d8 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -655,9 +655,27 @@ int KOAgendaItem::cellHeight() 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() diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index 2b26e95..97acd4c 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h @@ -108,8 +108,9 @@ class KOAgendaItem : public QWidget void recreateIncidence(); bool checkLayout(); void initColor (); bool isAllDay() { return mAllDay; } + int resizeMe( int grid, int wid, int hei ); public slots: bool updateIcons( QPainter *, bool ); void select(bool=true); void repaintItem(); |