summaryrefslogtreecommitdiffabout
path: root/korganizer/kdatenavigator.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kdatenavigator.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kdatenavigator.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 7d0c516..b420351 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -204,100 +204,103 @@ void KDateNavigator::updateDates()
QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() );
int d2 = KOGlobals::self()->calendarSystem()->day( dayone );
//int di = d1 - d2 + 1;
dayone = dayone.addDays( -d2 + 1 );
int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone );
// If month begins on Monday and Monday is first day of week,
// month should begin on second line. Sunday doesn't have this problem.
int nextLine = ( ( m_fstDayOfWkCalsys == 1) &&
( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0;
// update the matrix dates
int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine;
daymatrix->updateView(dayone.addDays(index));
//each updateDates is followed by an updateView -> repaint is issued there !
// daymatrix->repaint();
}
void KDateNavigator::updateDayMatrix()
{
daymatrix->updateView();
daymatrix->repaint();
}
void KDateNavigator::updateView()
{
setUpdatesEnabled( false );
int i;
// kdDebug() << "updateView() -> daymatrix->updateView()" << endl;
daymatrix->updateView();
// 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,
// not just 1.
//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;
if (dayOfYear % 7 != 0)
- weeknum.setNum(dayOfYear / 7 + 1);
+ weeknum.setNum(dayOfYear / 7 + 1+add);
else
- weeknum.setNum(dayOfYear / 7);
+ weeknum.setNum(dayOfYear / 7 +add);
weeknos[i]->setText(weeknum);
}
setUpdatesEnabled( true );
// kdDebug() << "updateView() -> repaint()" << endl;
repaint();
daymatrix->repaint();
}
void KDateNavigator::updateConfig()
{
int day;
for(int i=0; i<7; i++) {
// take the first letter of the day name to be the abbreviation
if (KGlobal::locale()->weekStartsMonday()) {
day = i+1;
} else {
if (i==0) day = 7;
else day = i;
}
QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day,
true );
if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 );
headings[i]->setText( dayName );
}
updateDates();
updateView();
}
void KDateNavigator::setShowWeekNums(bool enabled)
{
m_bShowWeekNums = enabled;
for(int i=0; i<6; i++) {
if(enabled)
weeknos[i]->show();
else
weeknos[i]->hide();
}
resize(size());
}
void KDateNavigator::selectDates(const DateList& dateList)
{
if (dateList.count() > 0) {
mNavigatorBar->selectDates( dateList );
mSelectedDates = dateList;