summaryrefslogtreecommitdiffabout
path: root/korganizer/kodaymatrix.cpp
Unidiff
Diffstat (limited to 'korganizer/kodaymatrix.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index ca896b5..549ef2a 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -203,61 +203,54 @@ void KODayMatrix::recalculateToday()
203 today = i; 203 today = i;
204 } 204 }
205 } 205 }
206 // qDebug(QString("Today is visible at %1.").arg(today)); 206 // qDebug(QString("Today is visible at %1.").arg(today));
207} 207}
208 208
209void KODayMatrix::updateView() 209void KODayMatrix::updateView()
210{ 210{
211 updateView(startdate); 211 updateView(startdate);
212} 212}
213void KODayMatrix::repaintViewTimed() 213void KODayMatrix::repaintViewTimed()
214{ 214{
215 qDebug("KODayMatrix::repaintViewTimed ");
216 mRepaintTimer->stop(); 215 mRepaintTimer->stop();
217 repaint(false); 216 repaint(false);
218} 217}
219void KODayMatrix::updateViewTimed() 218void KODayMatrix::updateViewTimed()
220{ 219{
221 220
222 mUpdateTimer->stop(); 221 mUpdateTimer->stop();
223 qDebug("KODayMatrix::updateView(QDate actdate)");
224 for(int i = 0; i < NUMDAYS; i++) { 222 for(int i = 0; i < NUMDAYS; i++) {
225
226 // if events are set for the day then remember to draw it bold 223 // if events are set for the day then remember to draw it bold
227 QPtrList<Event> eventlist = mCalendar->events(days[i]); 224 QPtrList<Event> eventlist = mCalendar->events(days[i]);
228 Event *event; 225 Event *event;
229 int numEvents = eventlist.count(); 226 int numEvents = eventlist.count();
230 227 QString holiStr = "";
231 for(event=eventlist.first();event != 0;event=eventlist.next()) { 228 for(event=eventlist.first();event != 0;event=eventlist.next()) {
232 ushort recurType = event->recurrence()->doesRecur(); 229 ushort recurType = event->recurrence()->doesRecur();
233
234 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 230 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
235 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 231 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
236 numEvents--; 232 numEvents--;
237 } 233 }
234 if ( event->categories().contains( i18n("Holiday") ) || event->categories().contains( "Holiday" )) {
235 if ( !holiStr.isEmpty() )
236 holiStr += "\n";
237 holiStr += event->summary();
238 }
238 } 239 }
239 events[i] = numEvents; 240 events[i] = numEvents;
240
241 //if it is a holy day then draw it red. Sundays are consider holidays, too 241 //if it is a holy day then draw it red. Sundays are consider holidays, too
242#ifndef KORG_NOPLUGINS
243 QString holiStr = KOCore::self()->holiday(days[i]);
244#else
245 QString holiStr = QString::null;
246#endif
247 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 242 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
248 !holiStr.isEmpty()) { 243 !holiStr.isEmpty()) {
249 if (holiStr.isNull()) holiStr = "";
250 mHolidays[i] = holiStr; 244 mHolidays[i] = holiStr;
251
252 } else { 245 } else {
253 mHolidays[i] = QString::null; 246 mHolidays[i] = QString::null;
254 } 247 }
255 } 248 }
256 if ( ! mPendingUpdateBeforeRepaint ) 249 if ( ! mPendingUpdateBeforeRepaint )
257 repaint(false); 250 repaint(false);
258 } 251 }
259void KODayMatrix::updateView(QDate actdate) 252void KODayMatrix::updateView(QDate actdate)
260{ 253{
261 254
262 if ( ! actdate.isValid() ) { 255 if ( ! actdate.isValid() ) {
263 //qDebug("date not valid "); 256 //qDebug("date not valid ");
@@ -279,25 +272,25 @@ void KODayMatrix::updateView(QDate actdate)
279 // nested if is required for next X display pushed from a different month - correction required 272 // nested if is required for next X display pushed from a different month - correction required
280 // otherwise, for month forward and backward, it must be avoided 273 // otherwise, for month forward and backward, it must be avoided
281 if( mSelStart > NUMDAYS || mSelStart < 0 ) 274 if( mSelStart > NUMDAYS || mSelStart < 0 )
282 mSelStart = mSelStart + tmp; 275 mSelStart = mSelStart + tmp;
283 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 276 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
284 mSelEnd = mSelEnd + tmp; 277 mSelEnd = mSelEnd + tmp;
285 } 278 }
286 } 279 }
287 startdate = actdate; 280 startdate = actdate;
288 mDayChanged = true; 281 mDayChanged = true;
289 recalculateToday(); 282 recalculateToday();
290 } 283 }
291 qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 284 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
292 if ( !isVisible() ) { 285 if ( !isVisible() ) {
293 mPendingUpdateBeforeRepaint = true; 286 mPendingUpdateBeforeRepaint = true;
294 } else { 287 } else {
295#ifdef DESKTOP_VERSION 288#ifdef DESKTOP_VERSION
296 //mRepaintTimer->start( 250 ); 289 //mRepaintTimer->start( 250 );
297 mUpdateTimer->start( 250 ); 290 mUpdateTimer->start( 250 );
298#else 291#else
299 mRepaintTimer->start( 350 ); 292 mRepaintTimer->start( 350 );
300 mUpdateTimer->start( 2000 ); 293 mUpdateTimer->start( 2000 );
301#endif 294#endif
302 } 295 }
303} 296}
@@ -478,30 +471,34 @@ void KODayMatrix::dropEvent(QDropEvent *e)
478// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 471// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
479 e->ignore(); 472 e->ignore();
480 } 473 }
481#endif 474#endif
482} 475}
483 476
484// ---------------------------------------------------------------------------- 477// ----------------------------------------------------------------------------
485// P A I N T E V E N T H A N D L I N G 478// P A I N T E V E N T H A N D L I N G
486// ---------------------------------------------------------------------------- 479// ----------------------------------------------------------------------------
487 480
488void KODayMatrix::paintEvent(QPaintEvent * pevent) 481void KODayMatrix::paintEvent(QPaintEvent * pevent)
489{ 482{
490//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; 483 if ( width() <= 0 || height() <= 0 )
484 return;
491 if ( mPendingUpdateBeforeRepaint ) { 485 if ( mPendingUpdateBeforeRepaint ) {
492 updateViewTimed(); 486 updateViewTimed();
493 mPendingUpdateBeforeRepaint = false; 487 mPendingUpdateBeforeRepaint = false;
494 } 488 }
495 QPainter p(this); 489 if ( myPix.width() != width() || myPix.height()!=height() ) {
490 myPix.resize(size() );
491 }
492 QPainter p(&myPix);
496 493
497 QRect sz = frameRect(); 494 QRect sz = frameRect();
498 int dheight = daysize.height(); 495 int dheight = daysize.height();
499 int dwidth = daysize.width(); 496 int dwidth = daysize.width();
500 int row,col; 497 int row,col;
501 int selw, selh; 498 int selw, selh;
502 bool isRTL = KOGlobals::self()->reverseLayout(); 499 bool isRTL = KOGlobals::self()->reverseLayout();
503 500
504 // draw background and topleft frame 501 // draw background and topleft frame
505 p.fillRect(pevent->rect(), mDefaultBackColor); 502 p.fillRect(pevent->rect(), mDefaultBackColor);
506 p.setPen(mDefaultTextColor); 503 p.setPen(mDefaultTextColor);
507 p.drawRect(0, 0, sz.width()+1, sz.height()+1); 504 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
@@ -607,24 +604,25 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
607 604
608 // reset color to actual color 605 // reset color to actual color
609 if (!mHolidays[i].isNull()) { 606 if (!mHolidays[i].isNull()) {
610 p.setPen(actcol); 607 p.setPen(actcol);
611 } 608 }
612 // reset bold font to plain font 609 // reset bold font to plain font
613 if (events[i] > 0) { 610 if (events[i] > 0) {
614 QFont myFont = font(); 611 QFont myFont = font();
615 myFont.setBold(false); 612 myFont.setBold(false);
616 p.setFont(myFont); 613 p.setFont(myFont);
617 } 614 }
618 } 615 }
616 bitBlt (this, 0, 0, &myPix, 0 ,0,width(), height() ,CopyROP);
619} 617}
620 618
621// ---------------------------------------------------------------------------- 619// ----------------------------------------------------------------------------
622// R E SI Z E E V E N T H A N D L I N G 620// R E SI Z E E V E N T H A N D L I N G
623// ---------------------------------------------------------------------------- 621// ----------------------------------------------------------------------------
624 622
625void KODayMatrix::resizeEvent(QResizeEvent *) 623void KODayMatrix::resizeEvent(QResizeEvent *)
626{ 624{
627 QRect sz = frameRect(); 625 QRect sz = frameRect();
628 daysize.setHeight(sz.height()*7 / NUMDAYS); 626 daysize.setHeight(sz.height()*7 / NUMDAYS);
629 daysize.setWidth(sz.width() / 7); 627 daysize.setWidth(sz.width() / 7);
630} 628}