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.cpp34
1 files changed, 23 insertions, 11 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 59618bf..d543aaf 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -112,15 +112,17 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const
{
mKODaymatrixWhatsThis = new KODaymatrixWhatsThis(this);
mPendingUpdateBeforeRepaint = false;
mouseDown = false;
// initialize dynamic arrays
bDays.resize ( NUMDAYS );
+ hDays.resize ( NUMDAYS );;
+ eDays.resize ( NUMDAYS );;
days = new QDate[NUMDAYS];
daylbls = new QString[NUMDAYS];
- events = new int[NUMDAYS];
+ //events = new int[NUMDAYS];
mToolTip = new DynamicTip(this);
// set default values used for drawing the matrix
mDefaultBackColor = palette().active().base();
mDefaultTextColor = palette().active().foreground();
mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
@@ -237,13 +239,13 @@ QColor KODayMatrix::getShadedColor(QColor color)
KODayMatrix::~KODayMatrix()
{
// delete mKODaymatrixWhatsThis;
delete [] days;
delete [] daylbls;
- delete [] events;
+ //delete [] events;
delete mToolTip;
}
/*
void KODayMatrix::setStartDate(QDate start)
{
@@ -308,13 +310,13 @@ void KODayMatrix::clearSelection()
void KODayMatrix::recalculateToday()
{
today = -1;
for (int i=0; i<NUMDAYS; i++) {
- events[i] = 0;
+ //events[i] = 0;
days[i] = startdate.addDays(i);
daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
// if today is in the currently displayed month, hilight today
if (days[i].year() == QDate::currentDate().year() &&
days[i].month() == QDate::currentDate().month() &&
@@ -346,19 +348,22 @@ void KODayMatrix::updateViewTimed()
// 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 = "";
bDays.clearBit(i);
+ hDays.clearBit(i);
+ eDays.clearBit(i);
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->isHoliday()) {
+ hDays.setBit(i);
if ( !holiStr.isEmpty() )
holiStr += "\n";
holiStr += event->summary();
if ( !event->location().isEmpty() )
holiStr += " (" + event->location() + ")";
}
@@ -368,13 +373,14 @@ void KODayMatrix::updateViewTimed()
holiStr += i18n("Birthday") + ": "+event->summary();
if ( !event->location().isEmpty() )
holiStr += " (" + event->location() + ")";
bDays.setBit(i);
}
}
- events[i] = numEvents;
+ if ( numEvents )
+ eDays.setBit(i);
//if it is a holy day then draw it red. Sundays are consider holidays, too
if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
!holiStr.isEmpty()) {
mHolidays[i] = holiStr;
} else {
mHolidays[i] = QString::null;
@@ -444,14 +450,17 @@ void KODayMatrix::updateEvents()
if ( ( recurType == Recurrence::rDaily &&
!KOPrefs::instance()->mDailyRecur ) ||
( recurType == Recurrence::rWeekly &&
!KOPrefs::instance()->mWeeklyRecur ) ) {
numEvents--;
}
- }
- events[ i ] = numEvents;
+ }
+ if ( numEvents )
+ eDays.setBit(i);
+ else
+ eDays.clearBit(i);
}
}
const QDate& KODayMatrix::getDate(int offset)
{
if (offset < 0 || offset > NUMDAYS-1) {
@@ -859,24 +868,27 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
addCol += 1;
p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1);
p.setPen(tmppen);
}
// if any events are on that day then draw it using a bold font
- if (events[i] > 0) {
+ if ( eDays.testBit(i) ) {
QFont myFont = font();
myFont.setBold(true);
p.setFont(myFont);
}
// if it is a holiday then use the default holiday color
- if (!mHolidays[i].isNull()) {
+ if ( !mHolidays[i].isNull()) {
if ( bDays.testBit(i) ) {
- p.setPen(Qt::green);
+ if ( hDays.testBit(i) )
+ p.setPen(QColor(Qt::green));
+ else
+ p.setPen(QColor(Qt::green).dark());
} else {
- if (actcol == mDefaultTextColor) {
+ if (actcol == mDefaultTextColor ) {
p.setPen(KOPrefs::instance()->mHolidayColor);
} else {
p.setPen(mHolidayColorShaded);
}
}
}
@@ -906,13 +918,13 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
// reset color to actual color
if (!mHolidays[i].isNull()) {
p.setPen(actcol);
}
// reset bold font to plain font
- if (events[i] > 0) {
+ if ( eDays.testBit(i)) {
QFont myFont = font();
myFont.setBold(false);
p.setFont(myFont);
}
}
int off = 0;//xyOff;