summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp53
1 files changed, 31 insertions, 22 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 62281d4..39355b4 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -67,118 +67,96 @@ KOAgendaItem::KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent,bool
setWFlags ( wflags);
mAllDay = allday;
init ( incidence, qd );
setMouseTracking(true);
//setAcceptDrops(true);
xPaintCoord = -1;
yPaintCoord = -1;
}
void KOAgendaItem::init ( Incidence *incidence, QDate qd )
{
mIncidence = incidence;
mDate = qd;
mFirstMultiItem = 0;
mNextMultiItem = 0;
mLastMultiItem = 0;
computeText();
if ( (incidence->type() == "Todo") &&
( !((static_cast<Todo*>(incidence))->isCompleted()) &&
((static_cast<Todo*>(incidence))->dtDue().date() <= QDate::currentDate()) ) ) {
if ( (static_cast<Todo*>(incidence))->dtDue() < QDateTime::currentDateTime().date())
mBackgroundColor = KOPrefs::instance()->mTodoOverdueColor ;
else
mBackgroundColor = KOPrefs::instance()->mTodoDueTodayColor;
}
else {
QStringList categories = mIncidence->categories();
QString cat = categories.first();
if (cat.isEmpty()) {
mBackgroundColor =KOPrefs::instance()->mEventColor;
} else {
mBackgroundColor = *KOPrefs::instance()->categoryColor(cat);
}
}
mColorGroup = QColorGroup( mBackgroundColor.light(),
mBackgroundColor.dark(),mBackgroundColor.light(),
mBackgroundColor.dark(),mBackgroundColor, black, mBackgroundColor) ;
setBackgroundColor( mBackgroundColor );
setCellXY(0,0,1);
setCellXWidth(0);
setSubCell(0);
setSubCells(1);
setMultiItem(0,0,0);
startMove();
mSelected = true;
select(false);
- QString tipText = mIncidence->summary();
- // QToolTip::add(this,tipText);
- QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
- if ( !mIncidence->doesFloat() )
- if ( mIncidence->type() == "Event" ) {
- 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->type() == "Todo" ) {
- tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueTimeStr();
- }
-
- if (!mIncidence->location().isEmpty()) {
- tipText += "\n"+i18n("Location: ")+mIncidence->location();
- }
- QToolTip::add(this,tipText,toolTipGroup(),"");
QFontMetrics fontinf(KOPrefs::instance()->mAgendaViewFont);
mFontPixelSize = fontinf.height();;
hide();
xPaintCoord = -1;
yPaintCoord = -1;
}
KOAgendaItem::~KOAgendaItem()
{
// qDebug("deleteKOAgendaItem::~KOAgendaItem( ");
}
void KOAgendaItem::recreateIncidence()
{
#if 0
Incidence* newInc = mIncidence->clone();
newInc->recreate();
if ( mIncidence->doesRecur() ) {
mIncidence->addExDate( mDate );
newInc->recurrence()->unsetRecurs();
int len = mIncidence->dtStart().secsTo( ((Event*)mIncidence)->dtEnd());
QTime tim = mIncidence->dtStart().time();
newInc->setDtStart( QDateTime(mDate, tim) );
((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
}
#endif
mIncidence = mIncidence->recreateCloneException( mDate );
}
bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout)
{
int size = AGENDA_ICON_SIZE;
int yOff = 0;
int xOff = 0;
int x = pos().x() +3;
int y;
if ( mAllDay )
y = pos().y()+3;
else
y = mCellYTop * ( height() / cellHeight() ) +3;
if (mIncidence->cancelled()) {
int xpos = xOff*( 1 +AGENDA_ICON_SIZE )+x;
int ypos = yOff*( 1 +AGENDA_ICON_SIZE)+y;
p->drawLine( xpos, ypos, xpos+AGENDA_ICON_SIZE-1, ypos+AGENDA_ICON_SIZE-1 );
p->drawLine( xpos, ypos+AGENDA_ICON_SIZE-1, xpos+AGENDA_ICON_SIZE-1, ypos );
if ( horLayout )
@@ -443,124 +421,155 @@ QPixmap * KOAgendaItem::paintPixSel()
if ( ! mPaintPixSel )
mPaintPixSel = new QPixmap(1,1);
return mPaintPixSel ;
}
void KOAgendaItem::paintEvent ( QPaintEvent *e )
{
if ( globalFlagBlockAgendaItemPaint )
return;
if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
return;
int yy;
if ( mAllDay )
yy = y();
else
yy = mCellYTop * ( height() / cellHeight() );
int xx = x();
if ( xPaintCoord != xx || yPaintCoord != yy ||
wPaintCoord != width() || hPaintCoord != height()) {
xPaintCoord= xx;
yPaintCoord = yy;
wPaintCoord = width();
hPaintCoord = height();
globalFlagBlockAgendaItemUpdate = 0;
paintMe( mSelected );
//qDebug("calling paintMe ");
globalFlagBlockAgendaItemUpdate = 1;
}
int rx, ry, rw, rh;
rx = e->rect().x();
ry = e->rect().y();
rw = e->rect().width();
rh = e->rect().height();
//qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
QPixmap* paintFrom ;
if ( mSelected ) {
paintFrom = paintPixSel();
} else {
if ( mAllDay )
paintFrom = paintPixAllday();
else
paintFrom = paintPix();
}
bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP);
}
void KOAgendaItem::computeText()
{
+
mDisplayedText = mIncidence->summary();
if ( (mIncidence->type() == "Todo") ) {
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() ) {
mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
}
}
}
if ( !mIncidence->location().isEmpty() ) {
if ( mAllDay )
mDisplayedText += " (";
else
mDisplayedText += "\n(";
mDisplayedText += mIncidence->location() +")";
}
+
+ QString tipText = mIncidence->summary();
+ QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
+ if ( !mIncidence->doesFloat() ) {
+ if ( mIncidence->type() == "Event" ) {
+ 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->type() == "Todo" ) {
+ if (mIncidence->hasStartDate())
+ tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
+ tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
+ }
+ } else if ( mIncidence->type() == "Todo" ) {
+ if (mIncidence->hasStartDate())
+ tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
+ tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
+ }
+
+ if (!mIncidence->location().isEmpty()) {
+ tipText += "\n"+i18n("Location: ")+mIncidence->location();
+ }
+ QToolTip::add(this,tipText,toolTipGroup(),"");
+
}
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;
}
/*
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;