Bug 128435 - Working days views won't follow the configured work days
Summary: Working days views won't follow the configured work days
Status: RESOLVED FIXED
Alias: None
Product: korganizer
Classification: Applications
Component: general (show other bugs)
Version: 3.5
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
: 54350 116502 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-06-01 11:17 UTC by Doron
Modified: 2009-03-23 09:11 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Diff vs 3.5+ branch tree (3.09 KB, patch)
2007-02-22 08:28 UTC, Dmitry Kagan
Details
Remaining part of bug (146.99 KB, image/png)
2007-08-16 15:32 UTC, Shai
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Doron 2006-06-01 11:17:47 UTC
Version:           3.5 (using KDE KDE 3.5.2)
Installed from:    Gentoo Packages
Compiler:          cc (GCC) 3.4.6 Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9
OS:                Linux

Hi,
I was impressed of KOrganizer, so I decided to use it.
The problem is, in working days view I can't see my working days....
I defined Sunday to Thursday as my working days (in Israel), but
I keep getting Monday to Friday as my working days.

The Calendar on the left side colors Friday & Saturday in red, but
on Working days view Monday to Friday are painted blue....

This really makes it difficult for me do use KOrganizer. Is there
a workaround ? is there a fix ?

Expected Behaviour:
When switching to Working days view, only the days defined in the settings
will show in the main panel. The Calendar on the left side will paint blue
only the days defined as working days in the KOrganizer settings.

Thanks,
Doron
Comment 1 Reinhold Kainhofer 2006-11-02 19:11:05 UTC
Reassigning all KOrganizer bug reports and wishes to the newly created 
korganizer-devel mailing list.
Comment 2 Jhamhader 2006-12-19 15:08:21 UTC
I get this one too. 
 Under 'Time and Date' configuration, you can select your working days from a field of check boxs, however, selection does not affect the 'Work Week' Calendar view. 
 Work Week calendar view should respect the configuration and handle cases where: some days have been selected, one day have been selected, and no days have been selected as work days.
Comment 3 Reinhold Kainhofer 2007-01-01 16:33:26 UTC
*** Bug 116502 has been marked as a duplicate of this bug. ***
Comment 4 Reinhold Kainhofer 2007-01-01 16:33:32 UTC
*** Bug 54350 has been marked as a duplicate of this bug. ***
Comment 5 Oded Arbel 2007-01-01 16:46:19 UTC
I think its a good idea to close duplicate reports of the same issue, but - the other two report are each older, have been discussed more and carry more votes - I think it would have been a better idea to close this report as duplicate as one of the other reports (and I would suggest to make both Bug 116502 and this one a duplicate of Bug 54350 as the latter is older and carries more votes)
Comment 6 Shai 2007-01-01 16:51:13 UTC
Oded is correct. Whoever works on this bug should pay attention to the screenshot he posted on Bug 116502.
Comment 7 Reinhold Kainhofer 2007-01-01 17:04:27 UTC
Dear Oded, 
While I agree with you in general (and usually close bug reports as duplicates of older ones), this case is special, as report 54350 was reported a while before we introduced the exctended work day configuration in KOrganizer. So that bug talks about letting the user select the start day of the work week, which does not make sense any more. This bug report, however, describes the current situation much better: Currently we hardcode monday-friday as the days shown in the work day view.

As far as the votes are concerned: We are currently so short of developer manpower, that the number of votes of a bug is one of the least priorities. 

Cheers,
Reinhold
Comment 8 Doron 2007-01-02 08:52:10 UTC
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body dir="ltr" bgcolor="#ffffff" text="#000000">
<p style="margin-bottom: 0cm; margin-top: 0pt;">Hi Reinhold,</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;">This is a personal mail
(outside the bug system).</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><br>
</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;">It looks like Oded
&amp; Shay are sensitive to their own reports. </p>
<p style="margin-bottom: 0cm; margin-top: 0pt;">To help everyone I'm
willing to drop my report so either Oded's or Shay's report will be
used.</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><br>
</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;">I'm also willing to
help coding. Just let me know what to begin with.</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><br>
</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;">Thanks,</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;">Doron.<br>
</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;"><br>
</p>
<p style="margin-bottom: 0cm; margin-top: 0pt;">Reinhold Kainhofer
wrote:<br>
</p>
<blockquote cite="mid20070101160428.12238.qmail@ktown.kde.org"
 type="cite">
  <pre wrap="">------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.
         
<a class="moz-txt-link-freetext" href="http://bugs.kde.org/show_bug.cgi?id=128435">http://bugs.kde.org/show_bug.cgi?id=128435</a>         




------- Additional Comments From reinhold kainhofer com  2007-01-01 17:04 -------
Dear Oded, 
While I agree with you in general (and usually close bug reports as duplicates of older ones), this case is special, as report 54350 was reported a while before we introduced the exctended work day configuration in KOrganizer. So that bug talks about letting the user select the start day of the work week, which does not make sense any more. This bug report, however, describes the current situation much better: Currently we hardcode monday-friday as the days shown in the work day view.

As far as the votes are concerned: We are currently so short of developer manpower, that the number of votes of a bug is one of the least priorities. 

Cheers,
Reinhold

  </pre>
</blockquote>
</body>
</html>
Comment 9 Bram Schoenmakers 2007-01-02 11:00:20 UTC
Votes of two duplicated bug reports are accumulated.
Comment 10 Oded Arbel 2007-01-02 14:36:47 UTC
Not that me and Shay are sensitive to our report (If you'd notice, I recommended Shay's report to be kept and he recommended my report ;-) ), its just that I'd hate to see a good discussion goes to waste.

But Reinhold Kainhofer comments seems very reasonable to me, and everyone agrees what the problem is and how to fix it, so its not that important.
Comment 11 Dmitry Kagan 2007-02-05 10:15:20 UTC
Hello, all!

I wanted to try the new PCLinuxOS 2007 so I went on to install it in vmware.
The amazing thing about it is that korganizer shows the working days correctly(!) as configured, i.e. a week starts with Sunday and Friday and Saturday are weekend days.
PCLinuxOS 2007 uses KDE 3.5.5. Has this issue finally been fixed in KDE or is this a patch by PCLinuxOS devs? If it is, surely it can be integrated into upstream version as well, no?

Please, fix this issue so that Kontact can finally remove Evolution from people's KDE desktops!

Thank you!
Comment 12 Dmitry Kagan 2007-02-05 10:18:44 UTC
Sorry for misleading you.
The Work View still has the bug. :( Ignore the previous comment.
Comment 13 Dmitry Kagan 2007-02-22 08:28:29 UTC
Created attachment 19778 [details]
Diff vs 3.5+ branch tree
Comment 14 Dmitry Kagan 2007-02-22 08:32:53 UTC
Hi!

Attached above is the patch, solving this issue.
Someone on the irc recommended that I post it first on the mailing list, in order to receive comments. I did so but I got no reaction on it, so I did decided to post it directly here.
Here is the link to my mailing list post, giving details about the patch:
http://lists.kde.org/?l=kde-pim&m=117200154931609&w=2

I really hope this can make it into the main 3.5 before the next 3.5 release.
I'll be happy to receive any comments and questions regarding this patch.

Thanks is advance, Reinhold! ;)
Comment 15 Allen Winter 2007-04-15 02:27:45 UTC
SVN commit 654061 by winterz:

Fix "Working days views won't follow the configured work days"
Patch provided by Dmitry Kagan. Thanks!

BUG: 128435


 M  +2 -3      calendarview.cpp  
 M  +17 -9     datenavigator.cpp  
 M  +5 -0      koglobals.cpp  
 M  +1 -1      koglobals.h  


--- branches/KDE/3.5/kdepim/korganizer/calendarview.cpp #654060:654061
@@ -494,9 +494,8 @@
 
   config->setGroup( "Views" );
   int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
-  if ( dateCount == 5 ) mNavigator->selectWorkWeek();
-  else if ( dateCount == 7 ) mNavigator->selectWeek();
-  else mNavigator->selectDates( dateCount );
+  if ( dateCount == 7 ) mNavigator->selectWeek();
+  else mNavigator->selectDates( mNavigator->selectedDates().first(), dateCount );
 }
 
 
--- branches/KDE/3.5/kdepim/korganizer/datenavigator.cpp #654060:654061
@@ -101,8 +101,7 @@
 {
   int dateCount = mSelectedDates.count();
   bool weekStart = ( weekDay == KGlobal::locale()->weekStartDay() );
-  if ( weekDay == 1 && dateCount == 5 ) selectWorkWeek( d );
-  else if ( weekStart && dateCount == 7 ) selectWeek( d );
+  if ( weekStart && dateCount == 7 ) selectWeek( d );
   else selectDates( d, dateCount );
 }
 
@@ -133,16 +132,26 @@
 
 void DateNavigator::selectWorkWeek( const QDate &d )
 {
+  int weekStart = KGlobal::locale()->weekStartDay();
+ 
   int dayOfWeek = KOGlobals::self()->calendarSystem()->dayOfWeek( d );
 
-  QDate firstDate = d.addDays( 1 - dayOfWeek );
+  QDate currentDate = d.addDays( weekStart - dayOfWeek );
 
-  int weekStart = KGlobal::locale()->weekStartDay();
-  if ( weekStart != 1 && dayOfWeek >= weekStart ) {
-    firstDate = firstDate.addDays( 7 );
+  if ( weekStart != 1 && dayOfWeek < weekStart ) {
+    currentDate = currentDate.addDays( -7 );
   }
 
-  selectDates( firstDate, 5 );
+  mSelectedDates.clear();
+  int mask = KOGlobals::self()->getWorkWeekMask();
+
+  for ( int i = 0; i < 7; ++i ) {
+    if( (1<< ((i + weekStart + 6) % 7)) & (mask) ) {
+	mSelectedDates.append(currentDate.addDays(i));
+    }
+  }
+  
+  emitSelected();
 }
 
 void DateNavigator::selectToday()
@@ -151,8 +160,7 @@
 
   int dateCount = mSelectedDates.count();
 
-  if ( dateCount == 5 ) selectWorkWeek( d );
-  else if ( dateCount == 7 ) selectWeek( d );
+  if ( dateCount == 7 ) selectWeek( d );
   else selectDates( d, dateCount );
 }
 
--- branches/KDE/3.5/kdepim/korganizer/koglobals.cpp #654060:654061
@@ -172,6 +172,11 @@
   return !nonWorkDay;
 }
 
+int KOGlobals::getWorkWeekMask()
+{
+  return KOPrefs::instance()->mWorkWeekMask;
+}
+
 void KOGlobals::setHolidays( KHolidays *h )
 {
   delete mHolidays;
--- branches/KDE/3.5/kdepim/korganizer/koglobals.h #654060:654061
@@ -61,7 +61,7 @@
 
     QStringList holiday( const QDate & );
     bool isWorkDay( const QDate & );
-
+    int getWorkWeekMask();
     /**
        Set which holidays the user wants to use.
        @param h a KHolidays object initialized with the desired locale.
Comment 16 Doron 2007-08-16 15:08:12 UTC
Hi All,
just upgraded to 3.5.7, and the bug is no longer there.
I suggest to change the status to "closed".

Thanks,
Doron
Comment 17 Shai 2007-08-16 15:32:26 UTC
Created attachment 21405 [details]
Remaining part of bug

This image shows that in some place, Sunday is still hard-coded as a weekend
day.
Comment 18 Shai 2007-08-16 15:41:53 UTC
Hi all,

As the attachment above shows, this bug is not quite dead yet. Could you please reopen it?

Thanks,
     Shai.
Comment 19 Reinhold Kainhofer 2007-08-16 15:46:27 UTC
Am Donnerstag, 16. August 2007 schrieb Shai:
> This image shows that in some place, Sunday is still hard-coded as a
> weekend day.


Actually, that's not hardcoded. The month view uses the system's weekDayOfPray 
setting. 
Don't ask me, where that comes from, though.

Cheers,
Reinhold
Comment 20 Doron 2007-08-16 15:55:26 UTC
I'm not sure, but maybe it's a bug in KCalendarSystemHebrew.
Is there a way to verify it ?
If not, then maybe korganizer should verify using calendarType ?

Doron
Comment 21 Doron 2007-08-16 16:10:01 UTC
OK, I found it.
Reinhold- I need your help here.

Most of the people are using a Gregorian calendar,
and set the relevant working days. This is the case
on my machine, and my collegues are doing the same.
So, you can't use weekDayOfPray- this would help if
we were using KCalendarSystemHebrew (or any other
non-Gregorian calendar).

Since weekDayOfPray only returns the weekend (and won't
dive you  anyfurther information about holidays), you
should rely on first day of the week instead.

Doron
Comment 22 Reinhold Kainhofer 2007-08-16 16:22:56 UTC
Am Donnerstag, 16. August 2007 schrieb Doron:
> Reinhold- I need your help here.
>
> Most of the people are using a Gregorian calendar,
> and set the relevant working days. 


Ah, I see. So basically the weekDayOfPray setting should be separated from the 
calendar system (since it's not really tied to the calendr system, but rather 
to politics and religion).


> Since weekDayOfPray only returns the weekend (and won't
> dive you  anyfurther information about holidays), you
> should rely on first day of the week instead.


Actually, that concept breaks even in "western"  countries: Europe (and 
everywhere else where ISO 8601 is used) use Monday as the first day of the 
week, whiel in the US, Austrialia and some other countries, it is quite 
widespread to use Sunday as the week start day...

Cheers,
Reinhold
Comment 23 Doron 2007-08-16 17:05:27 UTC
I'm not sure you are right about weekDayOfPray, since it should deal with religion. The solution is probably to define NonWorkingDays function, and use it for secular settings :-)

Should I reopen this bug or do you wish to open
a new one that deals with month-view relying on weekStartDay instead of weekDayOfPray ?

Doron.
Comment 24 Doron 2007-08-19 14:02:41 UTC
Re-opening to settle the month-view.
See comment #17. Probably should be fixed by not using weekDayOfPray.

Doron.
Comment 25 Sergio Martins 2009-03-23 09:11:40 UTC
(In reply to comment #24)
> Re-opening to settle the month-view.
> See comment #17. Probably should be fixed by not using weekDayOfPray.
> 
> Doron.

This is fixed in KDE4, Sunday is displayed like a normal work day.