summaryrefslogtreecommitdiffabout
path: root/korganizer/kodaymatrix.cpp
Unidiff
Diffstat (limited to 'korganizer/kodaymatrix.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 120bc89..a2e0ae0 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -369,97 +369,98 @@ void KODayMatrix::updateViewTimed()
369 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 369 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
370 !holiStr.isEmpty()) { 370 !holiStr.isEmpty()) {
371 mHolidays[i] = holiStr; 371 mHolidays[i] = holiStr;
372 } else { 372 } else {
373 mHolidays[i] = QString::null; 373 mHolidays[i] = QString::null;
374 } 374 }
375 } 375 }
376 if ( ! mPendingUpdateBeforeRepaint ) 376 if ( ! mPendingUpdateBeforeRepaint )
377 repaint(false); 377 repaint(false);
378} 378}
379void KODayMatrix::updateView(QDate actdate) 379void KODayMatrix::updateView(QDate actdate)
380{ 380{
381 381
382 if ( ! actdate.isValid() ) { 382 if ( ! actdate.isValid() ) {
383 //qDebug("date not valid "); 383 //qDebug("date not valid ");
384 return; 384 return;
385 } 385 }
386 mDayChanged = false; 386 mDayChanged = false;
387 //flag to indicate if the starting day of the matrix has changed by this call 387 //flag to indicate if the starting day of the matrix has changed by this call
388 //mDayChanged = false; 388 //mDayChanged = false;
389 // if a new startdate is to be set then apply Cornelius's calculation 389 // if a new startdate is to be set then apply Cornelius's calculation
390 // of the first day to be shown 390 // of the first day to be shown
391 if (actdate != startdate) { 391 if (actdate != startdate) {
392 // reset index of selection according to shift of starting date from startdate to actdate 392 // reset index of selection according to shift of starting date from startdate to actdate
393 if (mSelStart != NOSELECTION) { 393 if (mSelStart != NOSELECTION) {
394 int tmp = actdate.daysTo(startdate); 394 int tmp = actdate.daysTo(startdate);
395 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 395 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
396 // shift selection if new one would be visible at least partly ! 396 // shift selection if new one would be visible at least partly !
397 397
398 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 398 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
399 // nested if is required for next X display pushed from a different month - correction required 399 // nested if is required for next X display pushed from a different month - correction required
400 // otherwise, for month forward and backward, it must be avoided 400 // otherwise, for month forward and backward, it must be avoided
401 if( mSelStart > NUMDAYS || mSelStart < 0 ) 401 if( mSelStart > NUMDAYS || mSelStart < 0 )
402 mSelStart = mSelStart + tmp; 402 mSelStart = mSelStart + tmp;
403 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 403 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
404 mSelEnd = mSelEnd + tmp; 404 mSelEnd = mSelEnd + tmp;
405 } 405 }
406 } 406 }
407 startdate = actdate; 407 startdate = actdate;
408 mDayChanged = true; 408 mDayChanged = true;
409 recalculateToday(); 409 recalculateToday();
410 } 410 }
411 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 411 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
412 if ( !isVisible() ) { 412 if ( !isVisible() ) {
413 mPendingUpdateBeforeRepaint = true; 413 mPendingUpdateBeforeRepaint = true;
414 } else { 414 } else {
415#ifdef DESKTOP_VERSION 415#ifdef DESKTOP_VERSION
416 //mRepaintTimer->start( 100 ); 416 //mRepaintTimer->start( 100 );
417 mUpdateTimer->start( 100 ); 417 //updateViewTimed();
418 mUpdateTimer->start( 20 );
418#else 419#else
419 mRepaintTimer->start( 350 ); 420 mRepaintTimer->start( 350 );
420 mUpdateTimer->start( 1200 ); 421 mUpdateTimer->start( 1200 );
421#endif 422#endif
422 } 423 }
423} 424}
424void KODayMatrix::updateEvents() 425void KODayMatrix::updateEvents()
425{ 426{
426 if ( !mCalendar ) return; 427 if ( !mCalendar ) return;
427 428
428 for( int i = 0; i < NUMDAYS; i++ ) { 429 for( int i = 0; i < NUMDAYS; i++ ) {
429 // if events are set for the day then remember to draw it bold 430 // if events are set for the day then remember to draw it bold
430 QPtrList<Event> eventlist = mCalendar->events( days[ i ] ); 431 QPtrList<Event> eventlist = mCalendar->events( days[ i ] );
431 int numEvents = eventlist.count(); 432 int numEvents = eventlist.count();
432 Event *event; 433 Event *event;
433 for( event = eventlist.first(); event != 0;event=eventlist.next()) { 434 for( event = eventlist.first(); event != 0;event=eventlist.next()) {
434 ushort recurType = event->doesRecur(); 435 ushort recurType = event->doesRecur();
435 436
436 if ( ( recurType == Recurrence::rDaily && 437 if ( ( recurType == Recurrence::rDaily &&
437 !KOPrefs::instance()->mDailyRecur ) || 438 !KOPrefs::instance()->mDailyRecur ) ||
438 ( recurType == Recurrence::rWeekly && 439 ( recurType == Recurrence::rWeekly &&
439 !KOPrefs::instance()->mWeeklyRecur ) ) { 440 !KOPrefs::instance()->mWeeklyRecur ) ) {
440 numEvents--; 441 numEvents--;
441 } 442 }
442 } 443 }
443 events[ i ] = numEvents; 444 events[ i ] = numEvents;
444 } 445 }
445} 446}
446 447
447const QDate& KODayMatrix::getDate(int offset) 448const QDate& KODayMatrix::getDate(int offset)
448{ 449{
449 if (offset < 0 || offset > NUMDAYS-1) { 450 if (offset < 0 || offset > NUMDAYS-1) {
450 qDebug("Wrong offset2 %d", offset); 451 qDebug("Wrong offset2 %d", offset);
451 return days[0]; 452 return days[0];
452 } 453 }
453 return days[offset]; 454 return days[offset];
454} 455}
455 456
456QString KODayMatrix::getHolidayLabel(int offset) 457QString KODayMatrix::getHolidayLabel(int offset)
457{ 458{
458 if (offset < 0 || offset > NUMDAYS-1) { 459 if (offset < 0 || offset > NUMDAYS-1) {
459 qDebug("Wrong offset1 %d", offset); 460 qDebug("Wrong offset1 %d", offset);
460 return QString(); 461 return QString();
461 } 462 }
462 return mHolidays[offset]; 463 return mHolidays[offset];
463} 464}
464 465
465int KODayMatrix::getDayIndexFrom(int x, int y) 466int KODayMatrix::getDayIndexFrom(int x, int y)
@@ -798,98 +799,98 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
798 actcol = mDefaultTextColorShaded; 799 actcol = mDefaultTextColorShaded;
799 } 800 }
800 p.setPen(actcol); 801 p.setPen(actcol);
801 } 802 }
802 if (actcol == mDefaultTextColorShaded) { 803 if (actcol == mDefaultTextColorShaded) {
803 if ( ! mouseDown ) { 804 if ( ! mouseDown ) {
804 continue; 805 continue;
805 } 806 }
806 } 807 }
807 //Reset pen color after selected days block 808 //Reset pen color after selected days block
808 if (i == mSelEndT+1) { 809 if (i == mSelEndT+1) {
809 p.setPen(actcol); 810 p.setPen(actcol);
810 } 811 }
811 812
812 // if today then draw rectangle around day 813 // if today then draw rectangle around day
813 if (today == i) { 814 if (today == i) {
814 tmppen = p.pen(); 815 tmppen = p.pen();
815 QPen mTodayPen(p.pen()); 816 QPen mTodayPen(p.pen());
816 if ( daysize.width() < 20 ) 817 if ( daysize.width() < 20 )
817 mTodayPen.setWidth(1); 818 mTodayPen.setWidth(1);
818 else 819 else
819 mTodayPen.setWidth(mTodayMarginWidth); 820 mTodayPen.setWidth(mTodayMarginWidth);
820 //draw red rectangle for holidays 821 //draw red rectangle for holidays
821 if (!mHolidays[i].isNull()) { 822 if (!mHolidays[i].isNull()) {
822 if (actcol == mDefaultTextColor) { 823 if (actcol == mDefaultTextColor) {
823 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 824 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
824 } else { 825 } else {
825 mTodayPen.setColor(mHolidayColorShaded); 826 mTodayPen.setColor(mHolidayColorShaded);
826 } 827 }
827 } 828 }
828 //draw gray rectangle for today if in selection 829 //draw gray rectangle for today if in selection
829 if (i >= mSelStartT && i <= mSelEndT) { 830 if (i >= mSelStartT && i <= mSelEndT) {
830 QColor grey("grey"); 831 QColor grey("grey");
831 mTodayPen.setColor(grey); 832 mTodayPen.setColor(grey);
832 } 833 }
833 p.setPen(mTodayPen); 834 p.setPen(mTodayPen);
834 835
835 836
836 int addCol = 0; 837 int addCol = 0;
837 int addRow = 0; 838 int addRow = 0;
838 if (rowModulo) { 839 if (rowModulo) {
839 if ( row >= 6 - rowModulo ) 840 if ( row >= 6 - rowModulo )
840 addRow = row - 5 + rowModulo; 841 addRow = row - 5 + rowModulo;
841 } 842 }
842 if ( colModulo ) { 843 if ( colModulo ) {
843 if ( col >= 7 - colModulo ) 844 if ( col >= 7 - colModulo )
844 addCol = col - 6 + colModulo-1; 845 addCol = col - 6 + colModulo-1;
845 } 846 }
846 if ( col == 0 ) 847
847 addCol = 1; 848 addCol += 1;
848 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1); 849 p.drawRect(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight+1);
849 p.setPen(tmppen); 850 p.setPen(tmppen);
850 } 851 }
851 852
852 // if any events are on that day then draw it using a bold font 853 // if any events are on that day then draw it using a bold font
853 if (events[i] > 0) { 854 if (events[i] > 0) {
854 QFont myFont = font(); 855 QFont myFont = font();
855 myFont.setBold(true); 856 myFont.setBold(true);
856 p.setFont(myFont); 857 p.setFont(myFont);
857 } 858 }
858 859
859 // if it is a holiday then use the default holiday color 860 // if it is a holiday then use the default holiday color
860 if (!mHolidays[i].isNull()) { 861 if (!mHolidays[i].isNull()) {
861 if ( bDays.testBit(i) ) { 862 if ( bDays.testBit(i) ) {
862 p.setPen(Qt::green); 863 p.setPen(Qt::green);
863 } else { 864 } else {
864 if (actcol == mDefaultTextColor) { 865 if (actcol == mDefaultTextColor) {
865 p.setPen(KOPrefs::instance()->mHolidayColor); 866 p.setPen(KOPrefs::instance()->mHolidayColor);
866 } else { 867 } else {
867 p.setPen(mHolidayColorShaded); 868 p.setPen(mHolidayColorShaded);
868 } 869 }
869 } 870 }
870 } 871 }
871 872
872 // draw selected days with special color 873 // draw selected days with special color
873 // DO NOT specially highlight holidays in selection ! 874 // DO NOT specially highlight holidays in selection !
874 if (i >= mSelStartT && i <= mSelEndT) { 875 if (i >= mSelStartT && i <= mSelEndT) {
875 ;//p.setPen(mSelectedDaysColor); 876 ;//p.setPen(mSelectedDaysColor);
876 } 877 }
877 878
878 int addCol = 0; 879 int addCol = 0;
879 int addRow = 0; 880 int addRow = 0;
880 if ( colModulo ) { 881 if ( colModulo ) {
881 if ( col >= 7 - colModulo ) 882 if ( col >= 7 - colModulo )
882 addCol = col - 7 + colModulo; 883 addCol = col - 7 + colModulo;
883 } 884 }
884 if ( rowModulo ) { 885 if ( rowModulo ) {
885 if ( row >= 6 - rowModulo ) 886 if ( row >= 6 - rowModulo )
886 addRow = row - 5 + rowModulo; 887 addRow = row - 5 + rowModulo;
887 } 888 }
888 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow); 889 //qDebug("add %d %d -- %d %d ", col, addCol, row, addRow);
889 ++addCol;//++addCol; 890 ++addCol;//++addCol;
890 if ( row == 0) 891 if ( row == 0)
891 addRow = 1; 892 addRow = 1;
892 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, 893 p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight,
893 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 894 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
894 895
895 // reset color to actual color 896 // reset color to actual color