[Kde-imaging] [Bug 117105] calendar tool should use internationalized country setting
Tom Albers
tomalbers at kde.nl
Sun May 14 13:57:40 CEST 2006
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=117105
tomalbers kde nl changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From tomalbers kde nl 2006-05-14 13:57 -------
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
}
More information about the Kde-imaging
mailing list