summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt2
-rw-r--r--korganizer/kdatenavigator.cpp18
-rw-r--r--korganizer/komonthview.cpp25
-rw-r--r--korganizer/komonthview.h2
-rw-r--r--korganizer/mainwindow.cpp28
-rw-r--r--microkde/kdecore/klocale.cpp37
-rw-r--r--microkde/kdecore/klocale.h2
7 files changed, 64 insertions, 50 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index ce68a1d..b5285bf 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -10,4 +10,6 @@ Added a print option to the desktop version:
Now you can print out the view of the "Event Viewer".
That means you can print all data of one particular event/todo.
+Added scaling options to printout of Event Viewer and What'sNext View.
+Fixed some problems in the month view in "week start sunday" mode.
********** VERSION 2.0.21 ************
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 38bddc2..2fca49e 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -323,8 +323,9 @@ void KDateNavigator::updateView()
// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
daymatrix->updateView();
-
+ int sub = 4;
+ if ( ! KGlobal::locale()->weekStartsMonday() )
+ --sub;
// set the week numbers.
for(i = 0; i < 6; i++) {
- QString weeknum;
// remember, according to ISO 8601, the first week of the year is the
// first week that contains a thursday. Thus we must subtract off 4,
@@ -332,14 +333,11 @@ void KDateNavigator::updateView()
//ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear();
- int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4)));
-
- int add = 0;
- if ( ! KGlobal::locale()->weekStartsMonday() )
- ++add;
+ int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub)));
+ int weekNo;
if (dayOfYear % 7 != 0)
- weeknum.setNum(dayOfYear / 7 + 1+add);
+ weekNo = (dayOfYear / 7 + 1);
else
- weeknum.setNum(dayOfYear / 7 +add);
- weeknos[i]->setText(weeknum);
+ weekNo = (dayOfYear / 7);
+ weeknos[i]->setText(QString::number( weekNo ));
}
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9085775..d825493 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1002,8 +1002,5 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
hb->addWidget( mNavigatorBar );
hb->addWidget( mWidStack );
- mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
- if ( mShowWeekView )
- mWeekStartsMonday = true;
updatePossible = false;
//updatePossible = true;
@@ -1218,7 +1215,7 @@ void KOMonthView::updateConfig()
{
- mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
+ int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
- if ( mShowWeekView ) {
+ if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
mWeekStartsMonday = true;
}
@@ -1260,18 +1257,14 @@ void KOMonthView::updateDayLabels()
mDayLabelsT = &mDayLabelsW;
for (int i = 0; i < 7; i++) {
- if (mWeekStartsMonday) {
+ {
bool show = mShortDayLabelsW;
if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
show = true;
(*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
- } else {
- if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW));
- else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW));
-
}
}
mDayLabelsT = &mDayLabels;
for (int i = 0; i < 7; i++) {
- if (mWeekStartsMonday) {
+ if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
bool show = mShortDayLabelsM;
if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
@@ -1295,4 +1288,5 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
QPtrVector<KOWeekButton> *weekLabels;
int weekNum = 6;
+ mStartDate = start;
if ( mShowWeekView ) {
weekNum = 1;
@@ -1300,4 +1294,7 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
dayLabels = &mDayLabelsW;
weekLabels = &mWeekLabelsW;
+ if ( !KGlobal::locale()->weekStartsMonday() ) {
+ mStartDate = mStartDate.addDays( 1 );
+ }
} else {
cells = &mCells;
@@ -1306,6 +1303,9 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
}
- mStartDate = start;
+ int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
+ if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
+ mWeekStartsMonday = true;
+ }
int startWeekDay = mWeekStartsMonday ? 1 : 7;
@@ -1313,5 +1313,4 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
mStartDate = mStartDate.addDays( -1 );
}
-
bool primary = false;
uint i;
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index a58f6b8..9e724c7 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -287,5 +287,5 @@ class KOMonthView: public KOEventView
int mNumWeeks;
int mNumCells;
- bool mWeekStartsMonday;
+ //bool mWeekStartsMonday;
bool mShowSatSunComp;
void computeLayout();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 2da592b..8e52968 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1479,31 +1479,9 @@ QString MainWindow::syncFileName()
#endif
}
+#include "koglobals.h"
+#include <kcalendarsystem.h>
void MainWindow::updateWeek(QDate seda)
{
- int weekNum = 0;
- QDate d = QDate ( seda.year(), 1,1);
- seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
- if ( seda.addDays(6).year() != seda.year() ) {
- if ( seda.year() != d.year() ) {
- if ( d.dayOfWeek() > 4 )
- d = QDate ( seda.year(), 1,1);
- else
- weekNum = 1;
- } else {
- QDate dd( seda.year()+1, 1,1);
- if ( dd.dayOfWeek() <= 4 )
- weekNum = 1;
- }
- }
- if ( weekNum == 0 ){
- int dow = d.dayOfWeek();
- if ( dow <= 4 )
- d = d.addDays( 1-dow );
- else // 5,6,7
- d = d.addDays( 8-dow );
- // we have the first week of the year.we are on monday
- weekNum = d.daysTo( seda ) / 7 +1;
- }
-
+ int weekNum = KGlobal::locale()->weekNum ( seda );
mWeekPixmap.fill( mWeekBgColor );
QPainter p ( &mWeekPixmap );
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 7f31ab1..1d8ae9f 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -269,4 +269,41 @@ QString KLocale::translate( const char *, const char *fallback) const
}
+int KLocale::weekNum ( const QDate & date )
+{
+ QDate seda = date;
+ int weekNum = 0;
+ int dayofweek = seda.dayOfWeek(); // 1... 7 Mo .. So. Do = 4
+ int daystoprevthursday = (dayofweek + 3) % 7 ;
+ int dayofyear = seda.dayOfYear();
+ int prevThursday = dayofyear - ( daystoprevthursday );
+ int subweeknum = 0;
+ if ( prevThursday < 1 ) {
+ seda = seda.addDays( - daystoprevthursday );
+ dayofyear = seda.dayOfYear();
+ prevThursday = dayofyear;
+ subweeknum = prevThursday / 7;
+ if ( prevThursday % 7 != 0 )
+ ++subweeknum;
+ } else {
+ if ( dayofyear >= 360 ) { //maybe week 1
+ seda = seda.addDays( 7 - daystoprevthursday );
+ dayofyear = seda.dayOfYear();
+ if ( dayofyear < 360 && ( dayofweek < 4 || dayofweek == 7 && !mWeekStartsMonday ) )
+ return 1;
+ }
+ }
+ if ( ! weekNum ) {
+ weekNum = prevThursday / 7;
+ if ( prevThursday % 7 != 0 )
+ ++weekNum;
+ if ( dayofweek < 4 )
+ ++weekNum;
+ else if ( dayofweek == 7 && !mWeekStartsMonday )
+ ++weekNum;
+ if ( weekNum > subweeknum )
+ weekNum -= subweeknum;
+ }
+ return weekNum;
+}
QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const
{
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h
index 14660d6..58e0b39 100644
--- a/microkde/kdecore/klocale.h
+++ b/microkde/kdecore/klocale.h
@@ -66,5 +66,5 @@ class KLocale
QString country() const;
-
+ int weekNum ( const QDate & );
QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const;
QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const;