summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-07-04 21:23:46 (UTC)
committer zautrix <zautrix>2005-07-04 21:23:46 (UTC)
commit35f1ad23e06a0f6014d98c952e8b8652b5cffc49 (patch) (side-by-side diff)
tree4c3b222a9d2baff7b43c366bb0bfa1fab24a5177 /korganizer
parent2767ffda27fa0e88816832d4b2c6efdd0c52a8eb (diff)
downloadkdepimpi-35f1ad23e06a0f6014d98c952e8b8652b5cffc49.zip
kdepimpi-35f1ad23e06a0f6014d98c952e8b8652b5cffc49.tar.gz
kdepimpi-35f1ad23e06a0f6014d98c952e8b8652b5cffc49.tar.bz2
highlight pix smaller
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp225
1 files changed, 113 insertions, 112 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 63fdecd..9b817bc 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1223,657 +1223,658 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
}
}
} else {
placeItem->setSubCell(0);
placeItem->setSubCells(1);
if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
else placeItem->resize(mGridSpacingX,placeItem->height());
int x,y;
gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
moveChild(placeItem,x,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 ( ! mAllDayMode ) {
// currently not working for
//qDebug("KOAgenda::drawContents ");
if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
;//drawContentsToPainter();
QPaintDevice* pd = p->device();
p->end();
int vx, vy;
int selectionX = KOGlobals::self()->reverseLayout() ?
(mColumns - 1 - mSelectionCellX) * mGridSpacingX :
mSelectionCellX * mGridSpacingX;
contentsToViewport ( cx, cy, vx,vy);
//qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
int vxSel, vySel;
contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
int off = mSelectionHeight;
if ( vySel < 0 )
off += vySel;
//qDebug("OFF %d %d %d", off,vySel, vy );
bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
} else {
bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
}
}
if ( mSelectionHeight > 0 ) {
//qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
// bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
int hei = mSelectionHeight;
int offset = 0;
while ( hei > 0 ) {
int p_hei = 5;
if ( hei < 5 ) p_hei = hei;
hei -= 5;
bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
offset += 5;
}
}
}
p->begin( pd );
} else {
if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
;//drawContentsToPainter();
QPaintDevice* pd = p->device();
p->end();
int vx, vy;
int selectionX = KOGlobals::self()->reverseLayout() ?
(mColumns - 1 - mSelectionCellX) * mGridSpacingX :
mSelectionCellX * mGridSpacingX;
contentsToViewport ( cx, cy, vx,vy);
// qDebug(" %d %d %d %d ", cx, cy, cw,ch) ;
if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) )
bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
if ( mSelectionHeight > 0 ) {
//qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
//bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
int hei = mSelectionHeight;
int offset = 0;
while ( hei > 0 ) {
int p_hei = 5;
if ( hei < 5 ) p_hei = hei;
hei -= 5;
bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
offset += 5;
}
}
}
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;
if (mAllDayMode) newSubCellWidth = mGridSpacingY / item->subCells();
else newSubCellWidth = mGridSpacingX / item->subCells();
if (mAllDayMode) {
item->resize(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);
}
}
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 );
}
}
/*
Draw grid in the background of the agenda.
*/
void KOAgenda::drawContentsToPainter( QPainter* paint, bool backgroundOnly )// int cx, int cy, int cw, int ch)
{
if ( ! mGridSpacingX || ! mGridSpacingY ||! mHolidayMask )
return;
if ( globalFlagBlockAgenda > 1 && globalFlagBlockAgenda < 4 )
return;
int cx = 0, cy = 0, cw = contentsWidth(), ch = contentsHeight();
if ( ch < 1 )
ch = 1;
if ( mPaintPixmap.width() < contentsWidth()+42 || mPaintPixmap.height() < ch ) {
mPaintPixmap.resize( contentsWidth()+42, ch );
}
mCurPixWid = contentsWidth();
mCurPixHei = ch;
if ( mHighlightPixmap.width() < mGridSpacingX-1 ) {
mHighlightPixmap.resize( mGridSpacingX-1, 5 );
mHighlightPixmap.fill ( KOPrefs::instance()->mHighlightColor );
}
mPixPainter.begin( &mPaintPixmap) ;
//qDebug("wid %d hei %d ",mPaintPixmap.width(),mPaintPixmap.height() );
QPainter * p ;
if (paint == 0) {
mPaintPixmap.fill(KOPrefs::instance()->mAgendaBgColor);
p = &mPixPainter;
}
else
p = paint ;
// qDebug("++++++KOAgenda::drawContentsTo Painter %d %d %d %d ", cx, cy, cw, ch);
//--cx;++cw;
- int lGridSpacingY = mGridSpacingY*2;
- int selDay;
- if ( !backgroundOnly )
- for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
- {
- if ( mSelectedDates[selDay] == QDateTime::currentDateTime ().date() && KOPrefs::instance()->mHighlightCurrentDay) {
- int x1 = cx;
- int y1 = 0;
- if (y1 < cy) y1 = cy;
- int x2 = cx+cw-1;
- int y2 = contentsHeight();
- if (y2 > cy+ch-1) y2=cy+ch-1;
- if (x2 >= x1 && y2 >= y1) {
- int gxStart = selDay;
- int gxEnd = gxStart ;
- int xStart = KOGlobals::self()->reverseLayout() ?
- (mColumns - 1 - gxStart)*mGridSpacingX :
- gxStart*mGridSpacingX;
- if (xStart < x1) xStart = x1;
- int xEnd = KOGlobals::self()->reverseLayout() ?
- (mColumns - gxStart)*mGridSpacingX-1 :
- (gxStart+1)*mGridSpacingX-1;
- if (xEnd > x2) xEnd = x2;
- if ( KOPrefs::instance()->mUseHighlightLightColor )
- p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
- KOPrefs::instance()->mAgendaBgColor.light());
- else
- p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
- KOPrefs::instance()->mAgendaBgColor.dark());
+ int lGridSpacingY = mGridSpacingY*2;
+ int selDay;
+ QDate curDate = QDate::currentDate();
+ if ( !backgroundOnly ) {
+ for ( selDay = 0; selDay < mSelectedDates.count(); ++selDay)
+ {
+ if ( mSelectedDates[selDay] == curDate && KOPrefs::instance()->mHighlightCurrentDay) {
+ int x1 = cx;
+ int y1 = 0;
+ if (y1 < cy) y1 = cy;
+ int x2 = cx+cw-1;
+ int y2 = contentsHeight();
+ if (y2 > cy+ch-1) y2=cy+ch-1;
+ if (x2 >= x1 && y2 >= y1) {
+ int gxStart = selDay;
+ int gxEnd = gxStart ;
+ int xStart = KOGlobals::self()->reverseLayout() ?
+ (mColumns - 1 - gxStart)*mGridSpacingX :
+ gxStart*mGridSpacingX;
+ if (xStart < x1) xStart = x1;
+ int xEnd = KOGlobals::self()->reverseLayout() ?
+ (mColumns - gxStart)*mGridSpacingX-1 :
+ (gxStart+1)*mGridSpacingX-1;
+ if (xEnd > x2) xEnd = x2;
+ if ( KOPrefs::instance()->mUseHighlightLightColor )
+ p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
+ KOPrefs::instance()->mAgendaBgColor.light());
+ else
+ p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
+ KOPrefs::instance()->mAgendaBgColor.dark());
- }
- }
- }
- // Highlight working hours
-
- if ( !backgroundOnly )
- if (mWorkingHoursEnable) {
- int x1 = cx;
- int y1 = mWorkingHoursYTop;
- if (y1 < cy) y1 = cy;
- int x2 = cx+cw-1;
- // int x2 = mGridSpacingX * 5 - 1;
- // if (x2 > cx+cw-1) x2 = cx + cw - 1;
- int y2 = mWorkingHoursYBottom;
- if (y2 > cy+ch-1) y2=cy+ch-1;
-
- if (x2 >= x1 && y2 >= y1) {
- // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
- int gxStart = x1/mGridSpacingX;
- int gxEnd = x2/mGridSpacingX;
- while(gxStart <= gxEnd) {
- if (gxStart < int(mHolidayMask->count()) &&
- !mHolidayMask->at(gxStart)) {
- int xStart = KOGlobals::self()->reverseLayout() ?
- (mColumns - 1 - gxStart)*mGridSpacingX :
- gxStart*mGridSpacingX;
- if (xStart < x1) xStart = x1;
- int xEnd = KOGlobals::self()->reverseLayout() ?
- (mColumns - gxStart)*mGridSpacingX-1 :
- (gxStart+1)*mGridSpacingX-1;
- if (xEnd > x2) xEnd = x2;
- if ( mSelectedDates[gxStart] == QDateTime::currentDateTime ().date()&& KOPrefs::instance()->mHighlightCurrentDay ) {
- if ( KOPrefs::instance()->mUseHighlightLightColor )
- p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
- KOPrefs::instance()->mWorkingHoursColor.light());
- else
- p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
- KOPrefs::instance()->mWorkingHoursColor.dark());
- } else {
- p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
- KOPrefs::instance()->mWorkingHoursColor);
- }
+ }
+ }
+ }
+ }
+ // Highlight working hours
+
+ if ( !backgroundOnly )
+ if (mWorkingHoursEnable) {
+ int x1 = cx;
+ int y1 = mWorkingHoursYTop;
+ if (y1 < cy) y1 = cy;
+ int x2 = cx+cw-1;
+ // int x2 = mGridSpacingX * 5 - 1;
+ // if (x2 > cx+cw-1) x2 = cx + cw - 1;
+ int y2 = mWorkingHoursYBottom;
+ if (y2 > cy+ch-1) y2=cy+ch-1;
+
+ if (x2 >= x1 && y2 >= y1) {
+ // qDebug("x1 %d mGridSpacingX %d ", x1, mGridSpacingX );
+ int gxStart = x1/mGridSpacingX;
+ int gxEnd = x2/mGridSpacingX;
+ while(gxStart <= gxEnd) {
+ if (gxStart < int(mHolidayMask->count()) &&
+ !mHolidayMask->at(gxStart)) {
+ int xStart = KOGlobals::self()->reverseLayout() ?
+ (mColumns - 1 - gxStart)*mGridSpacingX :
+ gxStart*mGridSpacingX;
+ if (xStart < x1) xStart = x1;
+ int xEnd = KOGlobals::self()->reverseLayout() ?
+ (mColumns - gxStart)*mGridSpacingX-1 :
+ (gxStart+1)*mGridSpacingX-1;
+ if (xEnd > x2) xEnd = x2;
+ if ( mSelectedDates[gxStart] == curDate && KOPrefs::instance()->mHighlightCurrentDay ) {
+ if ( KOPrefs::instance()->mUseHighlightLightColor )
+ p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
+ KOPrefs::instance()->mWorkingHoursColor.light());
+ else
+ p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
+ KOPrefs::instance()->mWorkingHoursColor.dark());
+ } else {
+ p->fillRect(xStart,y1,xEnd-xStart+1,y2-y1+1,
+ KOPrefs::instance()->mWorkingHoursColor);
+ }
+ }
+ ++gxStart;
+ }
+ }
}
- ++gxStart;
+ /*
+ int selectionX = KOGlobals::self()->reverseLayout() ?
+ (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
+ mSelectionCellX * mGridSpacingX;
+
+ // Draw selection
+ if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
+ ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
+ // TODO: paint only part within cx,cy,cw,ch
+ p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
+ mSelectionHeight, KOPrefs::instance()->mHighlightColor );
}
- }
- }
- /*
- int selectionX = KOGlobals::self()->reverseLayout() ?
- (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
- mSelectionCellX * mGridSpacingX;
-
- // Draw selection
- if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
- ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
- // TODO: paint only part within cx,cy,cw,ch
- p->fillRect( selectionX, mSelectionYTop, mGridSpacingX,
- mSelectionHeight, KOPrefs::instance()->mHighlightColor );
- }
- */
- // Draw vertical lines of grid
+ */
+ // Draw vertical lines of grid
- int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
- if ( mGridSpacingX > 0 ) {
- while (x < cx + cw) {
- p->drawLine(x,cy,x,cy+ch);
- x+=mGridSpacingX;
- }
- }
- // Draw horizontal lines of grid
- int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
- if ( lGridSpacingY > 0 ) {
- while (y < cy + ch) {
- p->setPen( SolidLine );
- p->drawLine(cx,y,cx+cw,y);
- y+=lGridSpacingY;
- p->setPen( DotLine );
- p->drawLine(cx,y,cx+cw,y);
- y+=lGridSpacingY;
- }
- p->setPen( SolidLine );
- }
- mPixPainter.end() ;
+ int x = ((int)(cx/mGridSpacingX))*mGridSpacingX;
+ if ( mGridSpacingX > 0 ) {
+ while (x < cx + cw) {
+ p->drawLine(x,cy,x,cy+ch);
+ x+=mGridSpacingX;
+ }
+ }
+ // Draw horizontal lines of grid
+ int y = ((int)(cy/lGridSpacingY))*lGridSpacingY;
+ if ( lGridSpacingY > 0 ) {
+ while (y < cy + ch) {
+ p->setPen( SolidLine );
+ p->drawLine(cx,y,cx+cw,y);
+ y+=lGridSpacingY;
+ p->setPen( DotLine );
+ p->drawLine(cx,y,cx+cw,y);
+ y+=lGridSpacingY;
+ }
+ p->setPen( SolidLine );
+ }
+ mPixPainter.end() ;
}
/*
Convert srcollview contents coordinates to agenda grid coordinates.
*/
void KOAgenda::contentsToGrid (int x, int y, int& gx, int& gy)
{
gx = KOGlobals::self()->reverseLayout() ? mColumns - 1 - x/mGridSpacingX :
x/mGridSpacingX;
gy = y/mGridSpacingY;
}
/*
Convert agenda grid coordinates to scrollview contents coordinates.
*/
void KOAgenda::gridToContents (int gx, int gy, int& x, int& y)
{
x = KOGlobals::self()->reverseLayout() ? (mColumns - 1 - gx)*mGridSpacingX:
gx*mGridSpacingX;
y = gy*mGridSpacingY;
}
/*
Return Y coordinate corresponding to time. Coordinates are rounded to fit into
the grid.
*/
int KOAgenda::timeToY(const QTime &time)
{
int minutesPerCell = 24 * 60 / mRows;
int timeMinutes = time.hour() * 60 + time.minute();
int Y = (timeMinutes + (minutesPerCell / 2)) / minutesPerCell;
return Y;
}
/*
Return time corresponding to cell y coordinate. Coordinates are rounded to
fit into the grid.
*/
QTime KOAgenda::gyToTime(int gy)
{
int secondsPerCell = 24 * 60 * 60/ mRows;
int timeSeconds = secondsPerCell * gy;
QTime time( 0, 0, 0 );
if ( timeSeconds < 24 * 60 * 60 ) {
time = time.addSecs(timeSeconds);
} else {
time.setHMS( 23, 59, 59 );
}
return time;
}
void KOAgenda::setStartHour(int startHour)
{
int startCell = startHour * mRows / 24;
setContentsPos(0,startCell * gridSpacingY());
}
void KOAgenda::hideUnused()
{
// experimental only
// return;
KOAgendaItem *item;
for ( item=mUnusedItems.first(); item != 0; item=mUnusedItems.next() ) {
item->hide();
}
}
KOAgendaItem *KOAgenda::getNewItem(Incidence * event,QDate qd, QWidget* view)
{
KOAgendaItem *fi;
for ( fi=mUnusedItems.first(); fi != 0; fi=mUnusedItems.next() ) {
if ( fi->incidence() == event ) {
mUnusedItems.remove();
fi->init( event, qd );
return fi;
}
}
fi=mUnusedItems.first();
if ( fi ) {
mUnusedItems.remove();
fi->init( event, qd );
return fi;
}
// qDebug("new KOAgendaItem ");
KOAgendaItem* agendaItem = new KOAgendaItem( event, qd, view, mAllDayMode );
agendaItem->installEventFilter(this);
addChild(agendaItem,0,0);
return agendaItem;
}
KOAgendaItem * KOAgenda::getItemForTodo ( Todo * todo )
{
KOAgendaItem *item;
for ( item=mItems.first(); item != 0; item=mItems.next() ) {
if ( item->incidence() == todo ) {
mItems.remove();
return item;
}
}
return 0;
}
void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
{
// ( todo->hasCompletedDate() && todo->completed().date() == currentDate )||
KOAgendaItem *item;
item = getItemForTodo ( todo );
//qDebug("KOAgenda::updateTodo %d %d %d %d", this, todo, days, remove);
if ( item ) {
blockSignals( true );
//qDebug("item found ");
item->hide();
item->setCellX(-2, -1 );
item->select(false);
mUnusedItems.append( item );
mItems.remove( item );
QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
KOAgendaItem *itemit;
//globalFlagBlockAgendaItemPaint = 1;
for ( itemit=oldconflictItems.first(); itemit != 0;
itemit=oldconflictItems.next() ) {
if ( itemit != item )
placeSubCells(itemit);
}
qApp->processEvents();
//globalFlagBlockAgendaItemPaint = 0;
for ( itemit=oldconflictItems.first(); itemit != 0;
itemit=oldconflictItems.next() ) {
globalFlagBlockAgendaItemUpdate = 0;
if ( itemit != item )
itemit->repaintMe();
globalFlagBlockAgendaItemUpdate = 1;
itemit->repaint();
}
blockSignals( false );
}
if ( remove ) {
//qDebug("remove****************************************** ");
return;
}
if ( todo->hasCompletedDate() && !KOPrefs::instance()->mShowCompletedTodoInAgenda )
return;
//qDebug("updateTodo+++++++++++++++++++++++++++++++++++++ ");
- bool overdue = (!todo->isCompleted()) && (todo->dtDue() < QDate::currentDate())&& ( KOPrefs::instance()->mShowTodoInAgenda );
- QDate currentDate;
+ QDate currentDate = QDate::currentDate();
+ bool overdue = (!todo->isCompleted()) && (todo->dtDue() < currentDate)&& ( KOPrefs::instance()->mShowTodoInAgenda );
QDateTime dt;
if ( todo->hasCompletedDate() )
dt = todo->completed();
else
dt = todo->dtDue();
if ( overdue ) {
- currentDate = QDate::currentDate();
days += todo->dtDue().date().daysTo( currentDate );
}
else
currentDate = dt.date();
if (( todo->doesFloat() || overdue) && !todo->hasCompletedDate() ) {
if ( ! mAllDayMode ) return;
// aldayagenda
globalFlagBlockAgendaItemPaint = 1;
item = insertAllDayItem(todo, currentDate,days, days);
item->show();
}
else {
if ( mAllDayMode ) return;
// mAgenda
globalFlagBlockAgendaItemPaint = 1;
int endY = timeToY(dt.time()) - 1;
int hi = 12/KOPrefs::instance()->mHourSize;
int startY = endY - 1-hi;
item = insertItem(todo,currentDate,days,startY,endY);
item->show();
}
qApp->processEvents();
globalFlagBlockAgendaItemPaint = 0;
QPtrList<KOAgendaItem> oldconflictItems = item->conflictItems();
KOAgendaItem *itemit;
for ( itemit=oldconflictItems.first(); itemit != 0;
itemit=oldconflictItems.next() ) {
globalFlagBlockAgendaItemUpdate = 0;
itemit->repaintMe();
globalFlagBlockAgendaItemUpdate = 1;
itemit->repaint();
}
globalFlagBlockAgendaItemUpdate = 0;
item->repaintMe();
globalFlagBlockAgendaItemUpdate = 1;
item->repaint();
}
/*
Insert KOAgendaItem into agenda.
*/
KOAgendaItem *KOAgenda::insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom)
{
if (mAllDayMode) {
qDebug("KOAgenda: calling insertItem in all-day mode is illegal. ");
return 0;
}
KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
//agendaItem->setFrameStyle(WinPanel|Raised);
int YSize = YBottom - YTop + 1;
if (YSize < 0) {
YSize = 1;
}
int iheight = mGridSpacingY * YSize;
agendaItem->resize(mGridSpacingX,iheight );
agendaItem->setCellXY(X,YTop,YBottom);
agendaItem->setCellXWidth(X);
//addChild(agendaItem,X*mGridSpacingX,YTop*mGridSpacingY);
mItems.append(agendaItem);
placeSubCells(agendaItem);
//agendaItem->show();
marcus_bains();
return agendaItem;
}
/*
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);
//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) {
;
return;
}
int cellX,cellYTop,cellYBottom;
QString newtext;
int width = XEnd - XBegin + 1;
int count = 0;
KOAgendaItem *current = 0;
QPtrList<KOAgendaItem> multiItems;
for (cellX = XBegin;cellX <= XEnd;++cellX) {
if (cellX == XBegin) cellYTop = YTop;
else cellYTop = 0;
if (cellX == XEnd) cellYBottom = YBottom;
else cellYBottom = rows() - 1;
newtext = QString("(%1/%2): ").arg(++count).arg(width);
newtext.append(event->summary());
current = insertItem(event,qd,cellX,cellYTop,cellYBottom);
current->setText(newtext);
multiItems.append(current);
}
KOAgendaItem *next = 0;
KOAgendaItem *last = multiItems.last();
KOAgendaItem *first = multiItems.first();
KOAgendaItem *setFirst,*setLast;
current = first;
while (current) {
next = multiItems.next();
if (current == first) setFirst = 0;
else setFirst = first;
if (current == last) setLast = 0;
else setLast = last;
current->setMultiItem(setFirst,next,setLast);
current = next;
}
marcus_bains();
}
//QSizePolicy KOAgenda::sizePolicy() const
//{
// Thought this would make the all-day event agenda minimum size and the
// normal agenda take the remaining space. But it doesnīt work. The QSplitter
// donīt seem to think that an Expanding widget needs more space than a
// Preferred one.
// But it doesnīt hurt, so it stays.
// if (mAllDayMode) {
// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
// } else {
// return QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
// }
//}
void KOAgenda::finishResize ( )
{
//qDebug("finishResize+++++++++++++++++++++++++++++++ ( ) ");
if ( globalFlagBlockAgenda == 0 ) {
finishUpdate();
//qDebug("finishUpdate() called ");
}
}
/*
Overridden from QScrollView to provide proper resizing of KOAgendaItems.
*/
void KOAgenda::resizeEvent ( QResizeEvent *ev )
{
mSelectionHeight = 0;
mResizeTimer.start( 150 , true );
computeSizes();
return;
}
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;