summaryrefslogtreecommitdiffabout
path: root/korganizer/kodaymatrix.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kodaymatrix.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp170
1 files changed, 84 insertions, 86 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index ca896b5..549ef2a 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -203,68 +203,61 @@ void KODayMatrix::recalculateToday()
today = i;
}
}
// qDebug(QString("Today is visible at %1.").arg(today));
}
void KODayMatrix::updateView()
{
updateView(startdate);
}
void KODayMatrix::repaintViewTimed()
{
- qDebug("KODayMatrix::repaintViewTimed ");
mRepaintTimer->stop();
repaint(false);
}
void KODayMatrix::updateViewTimed()
{
mUpdateTimer->stop();
- qDebug("KODayMatrix::updateView(QDate actdate)");
for(int i = 0; i < NUMDAYS; i++) {
-
// if events are set for the day then remember to draw it bold
QPtrList<Event> eventlist = mCalendar->events(days[i]);
Event *event;
int numEvents = eventlist.count();
-
+ QString holiStr = "";
for(event=eventlist.first();event != 0;event=eventlist.next()) {
ushort recurType = event->recurrence()->doesRecur();
-
if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
(recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
numEvents--;
}
+ if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) {
+ if ( !holiStr.isEmpty() )
+ holiStr += "\n";
+ holiStr += event->summary();
+ }
}
events[i] = numEvents;
-
//if it is a holy day then draw it red. Sundays are consider holidays, too
-#ifndef KORG_NOPLUGINS
- QString holiStr = KOCore::self()->holiday(days[i]);
-#else
- QString holiStr = QString::null;
-#endif
if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
!holiStr.isEmpty()) {
- if (holiStr.isNull()) holiStr = "";
mHolidays[i] = holiStr;
-
} else {
mHolidays[i] = QString::null;
}
}
if ( ! mPendingUpdateBeforeRepaint )
repaint(false);
- }
+}
void KODayMatrix::updateView(QDate actdate)
{
if ( ! actdate.isValid() ) {
//qDebug("date not valid ");
return;
}
mDayChanged = false;
//flag to indicate if the starting day of the matrix has changed by this call
//mDayChanged = false;
// if a new startdate is to be set then apply Cornelius's calculation
// of the first day to be shown
@@ -279,25 +272,25 @@ void KODayMatrix::updateView(QDate actdate)
// nested if is required for next X display pushed from a different month - correction required
// otherwise, for month forward and backward, it must be avoided
if( mSelStart > NUMDAYS || mSelStart < 0 )
mSelStart = mSelStart + tmp;
if( mSelEnd > NUMDAYS || mSelEnd < 0 )
mSelEnd = mSelEnd + tmp;
}
}
startdate = actdate;
mDayChanged = true;
recalculateToday();
}
- qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
+ //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
if ( !isVisible() ) {
mPendingUpdateBeforeRepaint = true;
} else {
#ifdef DESKTOP_VERSION
//mRepaintTimer->start( 250 );
mUpdateTimer->start( 250 );
#else
mRepaintTimer->start( 350 );
mUpdateTimer->start( 2000 );
#endif
}
}
@@ -478,30 +471,34 @@ void KODayMatrix::dropEvent(QDropEvent *e)
// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
e->ignore();
}
#endif
}
// ----------------------------------------------------------------------------
// P A I N T E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::paintEvent(QPaintEvent * pevent)
{
-//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl;
- if ( mPendingUpdateBeforeRepaint ) {
- updateViewTimed();
- mPendingUpdateBeforeRepaint = false;
+ if ( width() <= 0 || height() <= 0 )
+ return;
+ if ( mPendingUpdateBeforeRepaint ) {
+ updateViewTimed();
+ mPendingUpdateBeforeRepaint = false;
+ }
+ if ( myPix.width() != width() || myPix.height()!=height() ) {
+ myPix.resize(size() );
}
- QPainter p(this);
+ QPainter p(&myPix);
QRect sz = frameRect();
int dheight = daysize.height();
int dwidth = daysize.width();
int row,col;
int selw, selh;
bool isRTL = KOGlobals::self()->reverseLayout();
// draw background and topleft frame
p.fillRect(pevent->rect(), mDefaultBackColor);
p.setPen(mDefaultTextColor);
p.drawRect(0, 0, sz.width()+1, sz.height()+1);
@@ -529,102 +526,103 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
// draw last block from left to mSelEnd
selw = mSelEnd-7*(mSelEnd/7)+1;
p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight,
selw*dwidth, dheight, selcol);
}
}
// iterate over all days in the matrix and draw the day label in appropriate colors
QColor actcol = mDefaultTextColorShaded;
p.setPen(actcol);
QPen tmppen;
for(int i = 0; i < NUMDAYS; i++) {
- row = i/7;
- col = isRTL ? 6-(i-row*7) : i-row*7;
-
- // if it is the first day of a month switch color from normal to shaded and vice versa
- if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
- if (actcol == mDefaultTextColorShaded) {
- actcol = mDefaultTextColor;
- } else {
- actcol = mDefaultTextColorShaded;
+ row = i/7;
+ col = isRTL ? 6-(i-row*7) : i-row*7;
+
+ // if it is the first day of a month switch color from normal to shaded and vice versa
+ if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
+ if (actcol == mDefaultTextColorShaded) {
+ actcol = mDefaultTextColor;
+ } else {
+ actcol = mDefaultTextColorShaded;
+ }
+ p.setPen(actcol);
}
- p.setPen(actcol);
- }
- //Reset pen color after selected days block
- if (i == mSelEnd+1) {
- p.setPen(actcol);
- }
+ //Reset pen color after selected days block
+ if (i == mSelEnd+1) {
+ p.setPen(actcol);
+ }
+
+ // if today then draw rectangle around day
+ if (today == i) {
+ tmppen = p.pen();
+ QPen mTodayPen(p.pen());
+
+ mTodayPen.setWidth(mTodayMarginWidth);
+ //draw red rectangle for holidays
+ if (!mHolidays[i].isNull()) {
+ if (actcol == mDefaultTextColor) {
+ mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
+ } else {
+ mTodayPen.setColor(mHolidayColorShaded);
+ }
+ }
+ //draw gray rectangle for today if in selection
+ if (i >= mSelStart && i <= mSelEnd) {
+ QColor grey("grey");
+ mTodayPen.setColor(grey);
+ }
+ p.setPen(mTodayPen);
+ p.drawRect(col*dwidth, row*dheight, dwidth, dheight);
+ p.setPen(tmppen);
+ }
- // if today then draw rectangle around day
- if (today == i) {
- tmppen = p.pen();
- QPen mTodayPen(p.pen());
+ // if any events are on that day then draw it using a bold font
+ if (events[i] > 0) {
+ QFont myFont = font();
+ myFont.setBold(true);
+ p.setFont(myFont);
+ }
- mTodayPen.setWidth(mTodayMarginWidth);
- //draw red rectangle for holidays
+ // if it is a holiday then use the default holiday color
if (!mHolidays[i].isNull()) {
- if (actcol == mDefaultTextColor) {
- mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
- } else {
- mTodayPen.setColor(mHolidayColorShaded);
- }
+ if (actcol == mDefaultTextColor) {
+ p.setPen(KOPrefs::instance()->mHolidayColor);
+ } else {
+ p.setPen(mHolidayColorShaded);
+ }
}
- //draw gray rectangle for today if in selection
+
+ // draw selected days with special color
+ // DO NOT specially highlight holidays in selection !
if (i >= mSelStart && i <= mSelEnd) {
- QColor grey("grey");
- mTodayPen.setColor(grey);
+ p.setPen(mSelectedDaysColor);
}
- p.setPen(mTodayPen);
- p.drawRect(col*dwidth, row*dheight, dwidth, dheight);
- p.setPen(tmppen);
- }
- // if any events are on that day then draw it using a bold font
- if (events[i] > 0) {
- QFont myFont = font();
- myFont.setBold(true);
- p.setFont(myFont);
- }
+ p.drawText(col*dwidth, row*dheight, dwidth, dheight,
+ Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
- // if it is a holiday then use the default holiday color
- if (!mHolidays[i].isNull()) {
- if (actcol == mDefaultTextColor) {
- p.setPen(KOPrefs::instance()->mHolidayColor);
- } else {
- p.setPen(mHolidayColorShaded);
+ // reset color to actual color
+ if (!mHolidays[i].isNull()) {
+ p.setPen(actcol);
+ }
+ // reset bold font to plain font
+ if (events[i] > 0) {
+ QFont myFont = font();
+ myFont.setBold(false);
+ p.setFont(myFont);
}
- }
-
- // draw selected days with special color
- // DO NOT specially highlight holidays in selection !
- if (i >= mSelStart && i <= mSelEnd) {
- p.setPen(mSelectedDaysColor);
- }
-
- p.drawText(col*dwidth, row*dheight, dwidth, dheight,
- Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
-
- // reset color to actual color
- if (!mHolidays[i].isNull()) {
- p.setPen(actcol);
- }
- // reset bold font to plain font
- if (events[i] > 0) {
- QFont myFont = font();
- myFont.setBold(false);
- p.setFont(myFont);
- }
}
+ bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
}
// ----------------------------------------------------------------------------
// R E SI Z E E V E N T H A N D L I N G
// ----------------------------------------------------------------------------
void KODayMatrix::resizeEvent(QResizeEvent *)
{
QRect sz = frameRect();
daysize.setHeight(sz.height()*7 / NUMDAYS);
daysize.setWidth(sz.width() / 7);
}