Bug 111697 - i wish for the option to change the first day of week (sun / mon)
Summary: i wish for the option to change the first day of week (sun / mon)
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Generic-Calendar (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-29 11:18 UTC by Michael Gefen
Modified: 2018-03-23 11:30 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 0.5.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Gefen 2005-08-29 11:18:24 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    SuSE RPMs
OS:                Linux

when generating the calendar, it would be nice to:
1. change the first day of week (sun / mon).
2. colorize the weekend ina different color
Comment 1 Tom Albers 2006-05-14 13:57:37 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
     }
 
Comment 2 Yuchen Wang 2007-08-30 07:26:04 UTC
I can't find this setting anywhere in version 0.9.2. Is it fixed or not?
Comment 3 Orgad Shaneh 2007-11-18 22:06:36 UTC
Yes it is. the calendar plugin was not yet ported completely to KDE4. I hope to finish it soon (not much work left) and upload it to trunk.
Comment 4 caulier.gilles 2008-12-08 09:40:15 UTC
Orgad,

What's news about this file ? It still valid with kipi-plugins 0.2.0 ?

Gilles Caulier
Comment 5 Orgad Shaneh 2008-12-17 20:43:29 UTC
It is resolved.

First day of the week is taken from the locale settings (System Settings -> Regional & Language -> Time & Dates), and prayDay (weekend) is colored in red.
Comment 6 Nicolas L. 2009-07-12 21:47:47 UTC
as for comment #5 explain, we  can close this bug as fixed. Reopen it if needed