summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagenda.cpp4
-rw-r--r--korganizer/koagendaitem.cpp8
-rw-r--r--korganizer/koagendaitem.h2
-rw-r--r--korganizer/koagendaview.cpp1
4 files changed, 8 insertions, 7 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 796d633..d9d1283 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -1791,102 +1791,102 @@ void KOAgenda::updateTodo( Todo * todo, int days, bool remove)
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();
return agendaItem;
}
/*
Insert all-day KOAgendaItem into agenda.
*/
KOAgendaItem *KOAgenda::insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd)
{
if (!mAllDayMode) {
return 0;
}
-
+ //qDebug("insertallday %s -- %d - %d ",qd.toString().latin1(), XBegin, XEnd );
KOAgendaItem *agendaItem = getNewItem(event,qd,viewport());
agendaItem->setCellXY(XBegin,0,0);
agendaItem->setCellXWidth(XEnd);
- agendaItem->resizeMe(mGridSpacingX, mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY);
+ agendaItem->resizeMe(mGridSpacingX, mGridSpacingX * agendaItem->cellWidth(),mGridSpacingY, true );
//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;
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 7a685d8..81681df 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -537,187 +537,189 @@ void KOAgendaItem::paintEvent ( QPaintEvent *e )
paintMe( mSelected );
return;
} else {
if ( mAllDay )
paintFrom = paintPixAllday();
else
paintFrom = paintPix();
}
xx += rx;
if ( xx < 0 ) {
rw = rw + xx;
rx -= xx;
xx = 0;
if ( rw <= 1 ) {
//qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
return;
}
}
if ( paintFrom->width() < xx+rw ) {
rw = paintFrom->width() - xx;
if ( rw <= 1 ) {
//qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
return;
}
}
//qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
}
void KOAgendaItem::computeText()
{
mDisplayedText = mIncidence->summary();
if ( (mIncidence->typeID() == todoID ) ) {
if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
else if ( !(mIncidence->doesFloat()))
mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
}
} else {
if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
if ( mAllDay ) {
if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
if ( mIncidence->doesRecur() ) {
mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
} else {
- mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
+ int dur = 1+ (static_cast<Event*>(mIncidence))->dtStart().date().daysTo( (static_cast<Event*>(mIncidence))->dtEnd().date() );
+ mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) + " ("+QString::number( dur )+i18n(" days") +")" ;
}
}
}
}
if ( !mIncidence->location().isEmpty() ) {
if ( mAllDay )
mDisplayedText += " (";
else
mDisplayedText += "\n(";
mDisplayedText += mIncidence->location() +")";
}
#ifdef DESKTOP_VERSION
QString tipText = mIncidence->summary();
if ( !mIncidence->doesFloat() ) {
if ( mIncidence->typeID() == eventID ) {
if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
}
else {
tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
}
}
else if ( mIncidence->typeID() == todoID ) {
if (mIncidence->hasStartDate())
tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
if (((Todo*)mIncidence)->hasDueDate())
tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
}
} else if ( mIncidence->typeID() == todoID ) {
if (mIncidence->hasStartDate())
tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
if (((Todo*)mIncidence)->hasDueDate())
tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
}
if (!mIncidence->location().isEmpty()) {
tipText += "\n"+i18n("Location: ")+mIncidence->location();
}
QToolTip::add(this,tipText,toolTipGroup(),"");
#endif
}
void KOAgendaItem::updateItem()
{
computeText();
//qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
paintMe( mSelected );
repaint( false);
}
void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
{
//qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
paintMe( mSelected );
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 KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth )
{
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 )
+ if ( (!invalidWidth && wid == width() ) || diff >= wid )
resize( wid, hei );
else
resize( wid - diff, hei );
+ //qDebug("wid %d x %d ", width(), x());
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;
mCellYTop = YTop;
mCellYBottom = YBottom;
}
void KOAgendaItem::setCellXWidth(int xwidth)
{
mCellXWidth = xwidth;
}
void KOAgendaItem::setCellX(int XLeft, int XRight)
{
mCellX = XLeft;
mCellXWidth = XRight;
}
void KOAgendaItem::setCellY(int YTop, int YBottom)
{
mCellYTop = YTop;
mCellYBottom = YBottom;
}
void KOAgendaItem::setSubCell(int subCell)
{
mSubCell = subCell;
}
void KOAgendaItem::setSubCells(int subCells)
{
mSubCells = subCells;
}
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 97acd4c..37d89a6 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -64,97 +64,97 @@ class KOAgendaItem : public QWidget
void setCellXWidth(int xwidth);
void setSubCell(int subCell);
void setSubCells(int subCells);
/** Start movement */
void startMove();
/** Reset to original values */
void resetMove();
void moveRelative(int dx,int dy);
void expandTop(int dy);
void expandBottom(int dy);
void expandLeft(int dx);
void expandRight(int dx);
int mLastMoveXPos;
void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
KOAgendaItem *last);
KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
Incidence *incidence() const { return mIncidence; }
QDate itemDate() { return mDate; }
/** Update the date of this item's occurence (not in the event) */
void setItemDate(QDate qd);
void setText ( const QString & text ) { mDisplayedText = text; }
QString text () { return mDisplayedText; }
virtual bool eventFilter ( QObject *, QEvent * );
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 );
+ int resizeMe( int grid, int wid, int hei, bool invalidHei = false );
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;
int mCellXWidth;
int mCellYTop,mCellYBottom;
int mSubCell; // subcell number of this item
int mSubCells; // Total number of subcells in cell of this item
int xPaintCoord;
int yPaintCoord;
int wPaintCoord;
int hPaintCoord;
// Variables to remember start position
int mStartCellX;
int mStartCellXWidth;
int mStartCellYTop,mStartCellYBottom;
int mLastMovePos;
// Multi item pointers
KOAgendaItem *mFirstMultiItem;
KOAgendaItem *mNextMultiItem;
KOAgendaItem *mLastMultiItem;
int mFontPixelSize;
Incidence *mIncidence; // corresponding event or todo
QDate mDate; //date this events occurs (for recurrence)
//void showIcon( QLabel*, int );
//QLabel *mTodoIconLabel;
//QLabel *mItemLabel;
//QWidget *mIconBox;
//QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
//QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
//QLabel *mIconMoreInfo;
static QToolTipGroup *mToolTipGroup;
QColor mBackgroundColor;
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 1cf03a0..d8a2134 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1190,97 +1190,96 @@ void KOAgendaView::fillAgenda()
unsigned int numEvent;
//qDebug("+++++NUMEVENT %d", dayEvents.count());
for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
Event *event = dayEvents.at(numEvent);
if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
if ( event->uid().left(15) == QString("last-syncEvent-") )
continue;
// kdDebug() << " Event: " << event->summary() << endl;
int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
// kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
if (event->doesFloat()) {
if (event->doesRecur()) {
if (event->isMultiDay() ) {
endX = endX - beginX;// endX is now number of days
if ( event->recursOn( currentDate ) ) {
endX += curCol;
beginX = curCol;
mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
} else {
//qDebug("days endX %d curCol %d max Col %d %s",endX ,curCol, maxCol, currentDate.toString().latin1());
if ( curCol == maxCol && maxCol+1 < endX ) {
int i;
for ( i = 1; i< endX; ++i ) {
if ( event->recursOn( currentDate.addDays( -i ) ) )
break;
}
if ( i > maxCol ) {
mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
//qDebug("BINGO ");
}
} else {
QDate dateit = currentDate.addDays( -endX );
if ( event->recursOn( dateit ) ) {
//qDebug("found %d %d %d %s", endX,curCol, curCol-endX ,dateit.toString().latin1() );
if ( curCol-endX < 0 ) {
mAllDayAgenda->insertAllDayItem(event,currentDate,0,curCol);
}
}
}
}
} else {
mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
}
-
} else {
if (beginX <= 0 && curCol == 0) {
mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
} else if (beginX == curCol) {
mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
}
}
} else if (event->isMultiDay()) {
if ( event->doesRecur () ) {
QDate dateit = currentDate;
int count = 0;
int max = event->dtStart().daysTo( event->dtEnd() ) +2;
while (! event->recursOn( dateit ) && count <= max ) {
++count;
dateit = dateit.addDays( -1 );
}
bool ok;
QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
if ( ok )
{
int secs = event->dtStart().secsTo( event->dtEnd() );
QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
endX = currentDate.daysTo(nextOcend.date()) + curCol;
}
}
int startY = mAgenda->timeToY(event->dtStart().time());
int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
//qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
//qDebug("insert!!! ");
mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
}
if (beginX == curCol) {
mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
if (startY < mMinY[curCol]) mMinY[curCol] = startY;
} else if (endX == curCol) {
mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
} else {
mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
}
} else {
int startY = mAgenda->timeToY(event->dtStart().time());
int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
if (endY < startY) endY = startY;