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 | 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 @@ -944,67 +944,68 @@ void KOAgenda::performItemAction(QPoint viewportPos) // Move or resize item if necessary if (mCurrentCellX != gx || mCurrentCellY != gy) { mItemMoved = true; mActionItem->raise(); if (mActionType == MOVE) { // Move all items belonging to a multi item KOAgendaItem *moveItem = mActionItem->firstMultiItem(); bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); if (!moveItem) moveItem = mActionItem; while (moveItem) { int dy; if (isMultiItem) dy = 0; 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()) { mActionItem->expandTop(gy - mCurrentCellY); mActionItem->resize(mActionItem->width(), mGridSpacingY * mActionItem->cellHeight()); int x,y; gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); //moveChild(mActionItem,childX(mActionItem),y); QScrollView::moveChild( mActionItem,childX(mActionItem),y ); } } else if (mActionType == RESIZEBOTTOM) { if (mCurrentCellY >= mActionItem->cellYTop()) { mActionItem->expandBottom(gy - mCurrentCellY); mActionItem->resize(mActionItem->width(), mGridSpacingY * mActionItem->cellHeight()); } } else if (mActionType == RESIZELEFT) { 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()); } } mCurrentCellX = gx; mCurrentCellY = gy; } } void KOAgenda::endItemAction() { if ( mItemMoved ) { KOAgendaItem *placeItem = mActionItem->firstMultiItem(); if ( !placeItem ) { placeItem = mActionItem; } @@ -1204,84 +1205,87 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem) if (i == maxSubCells) { placeItem->setSubCell(maxSubCells); maxSubCells++; // add new item to number of sub cells } // Prepare for sub cell geometry adjustment int newSubCellWidth; if (mAllDayMode) newSubCellWidth = mGridSpacingY / maxSubCells; else newSubCellWidth = mGridSpacingX / maxSubCells; conflictItems.append(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; gridToContents(item->cellX(),item->cellYTop(),x,y); if (mAllDayMode) { 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 for ( item=conflictItems.first(); item != 0; item=conflictItems.next() ) { if ( placeItem != item ) { KOAgendaItem *item2; QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 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; gridToContents(item2->cellX(),item2->cellYTop(),x,y); if (mAllDayMode) { 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() ) { // //item->updateItem(); // //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); // } // placeItem->updateItem(); } void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) { if ( globalFlagBlockAgenda ) return; if ( mInvalidPixmap ) { @@ -1382,48 +1386,49 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) } p->begin( pd ); } } void KOAgenda::finishUpdate() { KOAgendaItem *item; globalFlagBlockAgendaItemPaint = 1; // Adjust sub cell geometry of all conflict items of all conflict items of all conflict items ... of the conflict item with the max number of conflictitems 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; gridToContents(item->cellX(),item->cellYTop(),x,y); if (mAllDayMode) { 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() ) item->show(); } globalFlagBlockAgendaItemUpdate = 0; for ( item=mItems.first(); item != 0; item=mItems.next() ) { item->repaintMe( ); } globalFlagBlockAgendaItemUpdate = 1; qApp->processEvents(); globalFlagBlockAgendaItemPaint = 0; for ( item=mItems.first(); item != 0; item=mItems.next() ) { item->repaint( false ); @@ -1823,33 +1828,33 @@ KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int } /* Insert all-day KOAgendaItem into agenda. */ KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd) { if (!mAllDayMode) { return 0; } 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); placeSubCells(agendaItem); //agendaItem->show(); return agendaItem; } void KOAgenda::insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, int YTop,int YBottom) { if (mAllDayMode) { @@ -1929,36 +1934,37 @@ void KOAgenda::resizeEvent ( QResizeEvent *ev ) void KOAgenda::computeSizes() { if ( globalFlagBlockStartup ) return; int frameOffset = frameWidth() * 2 +1; if (mAllDayMode) { mGridSpacingX = (width()-frameOffset) / mColumns; mGridSpacingY = height() - 2 * frameWidth() - 1; resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); // mGridSpacingY = height(); // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 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 { mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; if (height() > mGridSpacingY * mRows + 1 ) { KOPrefs::instance()->mHourSize = ((height())/mRows)+1; mGridSpacingY = KOPrefs::instance()->mHourSize ; resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); emit resizedSignal(); } else resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); KOAgendaItem *item; int subCellWidth; for ( item=mItems.first(); item != 0; item=mItems.next() ) { diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 49ad9b8..7a685d8 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp @@ -643,33 +643,51 @@ void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 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; diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h index 2b26e95..97acd4c 100644 --- a/korganizer/koagendaitem.h +++ b/korganizer/koagendaitem.h @@ -96,32 +96,33 @@ class KOAgendaItem : public QWidget static QToolTipGroup *toolTipGroup(); QPtrList<KOAgendaItem> conflictItems(); void setConflictItems(QPtrList<KOAgendaItem>); void addConflictItem(KOAgendaItem *ci); void paintMe( bool, QPainter* painter = 0 ); void repaintMe(); static QPixmap * paintPix(); static QPixmap * paintPixAllday(); void updateItem(); void computeText(); 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(); protected: void dragEnterEvent(QDragEnterEvent *e); void dropEvent(QDropEvent *e); void paintEvent ( QPaintEvent * ); void resizeEvent ( QResizeEvent *ev ); private: KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; bool mAllDay; bool mWhiteText; int mCellX; |