Version: 0.7.4 (using KDE 3.4.2 Level "b" , SUSE 10.0) Compiler: Target: i586-suse-linux OS: Linux (i686) release 2.6.13-15-default First weekday in week. Name of month and name of weekday (3 letter, is there a translated short). And even type of calendar.
SVN commit 540657 by toma: Look at the settings to find out the first day of the week and adjust the calendars for that. So if the first day of the week in your country is wednesday, that will work now. CCBUG: 111697 BUG: 117105 M +41 -13 calpainter.cpp --- trunk/extragear/libs/kipi-plugins/calendar/calpainter.cpp #540656:540657 @@ -20,7 +20,7 @@ * ============================================================ */ // Qt includes. - + #include <qpainter.h> #include <qrect.h> #include <qpaintdevice.h> @@ -85,7 +85,8 @@ // -------------------------------------------------- - int days[42]; + int days[42]; + int startDayOffset = KGlobal::locale()->weekStartDay(); for (int i=0; i<42; i++) days[i] = -1; @@ -93,8 +94,11 @@ QDate d(year_, month_, 1); int s = d.dayOfWeek(); + if (s+7-startDayOffset >= 7) + s=s-7; + for (int i=s; i<(s+d.daysInMonth()); i++) { - days[i-1] = i-s+1; + days[i + (7-startDayOffset)] = i-s+1; } // ----------------------------------------------- @@ -227,7 +231,12 @@ painter->setPen(Qt::red); sy = rCal.top(); - for (int i=0; i<7; i++) { + for (int i=0; i<7; i++) + { + int dayname = i + startDayOffset; + if (dayname > 7) + dayname = dayname-7; + sx = cellSize * i + rCal.left(); r.moveTopLeft(QPoint(sx,sy)); rsmall = r; @@ -235,10 +244,10 @@ rsmall.setHeight(r.height() - 2); #if KDE_IS_VERSION(3,2,0) painter->drawText(rsmall, Qt::AlignRight|Qt::AlignBottom, - KGlobal::locale()->calendar()->weekDayName(i+1, true)); + KGlobal::locale()->calendar()->weekDayName(dayname, true)); #else painter->drawText(rsmall, Qt::AlignRight|Qt::AlignBottom, - KGlobal::locale()->weekDayName(i+1, true)); + KGlobal::locale()->weekDayName(dayname, true)); #endif } @@ -302,7 +311,8 @@ // -------------------------------------------------- - int days[42]; + int days[42]; + int startDayOffset = KGlobal::locale()->weekStartDay(); for (int i=0; i<42; i++) days[i] = -1; @@ -310,8 +320,11 @@ QDate d(year, month, 1); int s = d.dayOfWeek(); + if (s+7-startDayOffset >= 7) + s=s-7; + for (int i=s; i<(s+d.daysInMonth()); i++) { - days[i-1] = i-s+1; + days[i+(7-startDayOffset)] = i-s+1; } // ----------------------------------------------- @@ -459,6 +472,11 @@ painter->setPen(Qt::red); sy = rCal.top(); for (int i=0; i<7; i++) { + + int dayname = i + startDayOffset; + if (dayname > 7) + dayname = dayname-7; + sx = cellSize * i + rCal.left(); r.moveTopLeft(QPoint(sx,sy)); rsmall = r; @@ -466,10 +484,10 @@ rsmall.setHeight(r.height() - 2); #if KDE_IS_VERSION(3,2,0) painter->drawText(rsmall, Qt::AlignRight|Qt::AlignBottom, - KGlobal::locale()->calendar()->weekDayName(i+1, true)); + KGlobal::locale()->calendar()->weekDayName(dayname, true)); #else painter->drawText(rsmall, Qt::AlignRight|Qt::AlignBottom, - KGlobal::locale()->weekDayName(i+1, true)); + KGlobal::locale()->weekDayName(dayname, true)); #endif } @@ -526,14 +544,19 @@ // -------------------------------------------------- int days[42]; + int startDayOffset = KGlobal::locale()->weekStartDay(); + for (int i=0; i<42; i++) days[i] = -1; QDate d(year, month, 1); int s = d.dayOfWeek(); + if (s+7-startDayOffset >= 7) + s=s-7; + for (int i=s; i<(s+d.daysInMonth()); i++) { - days[i-1] = i-s+1; + days[i+(7-startDayOffset)] = i-s+1; } // ----------------------------------------------- @@ -666,6 +689,11 @@ painter->setPen(Qt::red); sy = rCal.top(); for (int i=0; i<7; i++) { + + int dayname = i + startDayOffset; + if (dayname > 7) + dayname = dayname-7; + sx = cellSize * i + rCal.left(); r.moveTopLeft(QPoint(sx,sy)); rsmall = r; @@ -673,10 +701,10 @@ rsmall.setHeight(r.height() - 2); #if KDE_IS_VERSION(3,2,0) painter->drawText(rsmall, Qt::AlignRight|Qt::AlignBottom, - KGlobal::locale()->calendar()->weekDayName(i+1, true)); + KGlobal::locale()->calendar()->weekDayName(dayname, true)); #else painter->drawText(rsmall, Qt::AlignRight|Qt::AlignBottom, - KGlobal::locale()->weekDayName(i+1, true)); + KGlobal::locale()->weekDayName(dayname, true)); #endif }