| Summary: | calendar tool should use internationalized country setting | ||
|---|---|---|---|
| Product: | [Applications] digikam | Reporter: | Roger Larsson <roger.larsson> |
| Component: | Plugin-Generic-Calendar | Assignee: | Digikam Developers <digikam-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | 0.1.0 | |
| Sentry Crash Report: | |||
|
Description
Roger Larsson
2005-11-26 17:15:48 UTC
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
}
|