summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagenda.cpp40
1 files changed, 23 insertions, 17 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 88f5d99..796d633 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -948,59 +948,60 @@ void KOAgenda::performItemAction(QPoint viewportPos)
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(),
+ 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 ) {
@@ -1208,76 +1209,79 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
// 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)
{
@@ -1386,40 +1390,41 @@ void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
}
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;
@@ -1827,25 +1832,25 @@ 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;
}
@@ -1933,28 +1938,29 @@ void KOAgenda::computeSizes()
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 );