-rw-r--r-- | korganizer/kdatenavigator.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index b097dc1..92a0ac2 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -1,310 +1,350 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qkeycode.h> | 25 | #include <qkeycode.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qframe.h> | 28 | #include <qframe.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qapplication.h> | 30 | #include <qapplication.h> |
31 | 31 | ||
32 | #include <kdebug.h> | 32 | #include <kdebug.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kglobal.h> | 34 | #include <kglobal.h> |
35 | 35 | ||
36 | #include "koglobals.h" | 36 | #include "koglobals.h" |
37 | #include "koprefs.h" | 37 | #include "koprefs.h" |
38 | #ifndef KORG_NOPLUGINS | 38 | #ifndef KORG_NOPLUGINS |
39 | #include "kocore.h" | 39 | #include "kocore.h" |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <kcalendarsystem.h> | 42 | #include <kcalendarsystem.h> |
43 | 43 | ||
44 | #include "navigatorbar.h" | 44 | #include "navigatorbar.h" |
45 | 45 | ||
46 | #include "kdatenavigator.h" | 46 | #include "kdatenavigator.h" |
47 | 47 | ||
48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | 48 | KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) |
49 | : QFrame(parent, name), | 49 | : QFrame(parent, name), |
50 | updateTimer(0L) | 50 | updateTimer(0L) |
51 | { | 51 | { |
52 | setFrameStyle(QFrame::NoFrame); | 52 | setFrameStyle(QFrame::NoFrame); |
53 | QDate startDate = QDate::currentDate(); | 53 | QDate startDate = QDate::currentDate(); |
54 | QGridLayout *topLayout = new QGridLayout(this,8,8); | 54 | QGridLayout *topLayout = new QGridLayout(this,8,8); |
55 | 55 | ||
56 | if (! startDate.isValid()) { | 56 | if (! startDate.isValid()) { |
57 | qDebug("KDateNavigator::invalid startdate "); | 57 | qDebug("KDateNavigator::invalid startdate "); |
58 | startDate = QDate::currentDate(); | 58 | startDate = QDate::currentDate(); |
59 | } | 59 | } |
60 | mMonthSignalOffset = 0; | 60 | mMonthSignalOffset = 0; |
61 | mSelectedDates.append(startDate); | 61 | mSelectedDates.append(startDate); |
62 | m_MthYr = startDate; | 62 | m_MthYr = startDate; |
63 | m_bShowWeekNums = true; | 63 | m_bShowWeekNums = true; |
64 | 64 | ||
65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); | 65 | setFont( KOPrefs::instance()->mDateNavigatorFont ); |
66 | mNavigatorBar = new NavigatorBar( startDate, this ); | 66 | mNavigatorBar = new NavigatorBar( startDate, this ); |
67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); | 67 | topLayout->addMultiCellWidget( mNavigatorBar, 0, 0, 0, 7 ); |
68 | //mNavigatorBar->resize( 1,1); | 68 | //mNavigatorBar->resize( 1,1); |
69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); | 69 | connect( mNavigatorBar, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) ); |
70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); | 70 | connect( mNavigatorBar, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) ); |
71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); | 71 | connect( mNavigatorBar, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) ); |
72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); | 72 | connect( mNavigatorBar, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) ); |
73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); | 73 | connect( mNavigatorBar, SIGNAL( monthSelected( int ) ), SLOT( slotMonthSelected( int ) ) ); |
74 | 74 | ||
75 | // get the day of the week on the first day | 75 | // get the day of the week on the first day |
76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 76 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
77 | m_fstDayOfWk = dayone.dayOfWeek(); | 77 | m_fstDayOfWk = dayone.dayOfWeek(); |
78 | 78 | ||
79 | int i; | 79 | int i; |
80 | 80 | ||
81 | // Set up the heading fields. | 81 | // Set up the heading fields. |
82 | for( i = 0; i < 7; i++ ) { | 82 | for( i = 0; i < 7; i++ ) { |
83 | headings[i] = new QLabel("",this); | 83 | headings[i] = new QLabel("",this); |
84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); | 84 | //headings[i]->setFont(QFont("Arial", 10, QFont::Bold)); |
85 | headings[i]->setAlignment(AlignCenter); | 85 | headings[i]->setAlignment(AlignCenter); |
86 | 86 | ||
87 | topLayout->addWidget(headings[i],1,i+1); | 87 | topLayout->addWidget(headings[i],1,i+1); |
88 | } | 88 | } |
89 | 89 | ||
90 | // Create the weeknumber labels | 90 | // Create the weeknumber labels |
91 | for( i = 0; i < 6; i++ ) { | 91 | for( i = 0; i < 6; i++ ) { |
92 | weeknos[i] = new QLabel(this); | 92 | weeknos[i] = new QLabel(this); |
93 | weeknos[i]->setAlignment(AlignCenter); | 93 | weeknos[i]->setAlignment(AlignCenter); |
94 | //weeknos[i]->setFont(QFont("Arial", 10)); | 94 | //weeknos[i]->setFont(QFont("Arial", 10)); |
95 | if(!m_bShowWeekNums) { | 95 | if(!m_bShowWeekNums) { |
96 | weeknos[i]->hide(); | 96 | weeknos[i]->hide(); |
97 | } | 97 | } |
98 | weeknos[i]->installEventFilter(this); | 98 | weeknos[i]->installEventFilter(this); |
99 | 99 | ||
100 | topLayout->addWidget(weeknos[i],i+2,0); | 100 | topLayout->addWidget(weeknos[i],i+2,0); |
101 | } | 101 | } |
102 | 102 | ||
103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); | 103 | daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); |
104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 104 | daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); |
105 | daymatrix->setLineWidth(1); | 105 | daymatrix->setLineWidth(1); |
106 | 106 | ||
107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), | 107 | connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), |
108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); | 108 | SIGNAL( datesSelected( const KCal::DateList & ) ) ); |
109 | 109 | ||
110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), | 110 | connect( daymatrix, SIGNAL( eventDropped( Event * ) ), |
111 | SIGNAL( eventDropped( Event * ) ) ); | 111 | SIGNAL( eventDropped( Event * ) ) ); |
112 | 112 | ||
113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); | 113 | topLayout->addMultiCellWidget(daymatrix,2,7,1,7); |
114 | 114 | ||
115 | // read settings from configuration file. | 115 | // read settings from configuration file. |
116 | updateConfig(); | 116 | updateConfig(); |
117 | enableRollover(FollowMonth); | 117 | enableRollover(FollowMonth); |
118 | mySizeHint = sizeHint(); | 118 | mySizeHint = sizeHint(); |
119 | mFontChanged = false; | ||
120 | } | ||
121 | void KDateNavigator::changeFont ( QFont fo ) | ||
122 | { | ||
123 | setFont( fo ); | ||
124 | mNavigatorBar->resetFont( fo ); | ||
125 | } | ||
126 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | ||
127 | { | ||
128 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | ||
129 | *b = false; | ||
130 | int fontPoint = fo.pointSize(); | ||
131 | while ( fontPoint > 5 ) { | ||
132 | --fontPoint; | ||
133 | fo.setPointSize( fontPoint ); | ||
134 | setFont( fo ); | ||
135 | mFontChanged = true; | ||
136 | mNavigatorBar->resetFont( fo ); | ||
137 | QSize sh = sizeHint(); | ||
138 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | ||
139 | if ( si.width() > sh.width() && si.height() > sh.height()) { | ||
140 | *b = true; | ||
141 | //qDebug("fooooooooooooooooooooooouuuuund "); | ||
142 | break; | ||
143 | } | ||
144 | } | ||
145 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | ||
146 | return fo; | ||
147 | } | ||
148 | QSize KDateNavigator::sizeHint() const | ||
149 | { | ||
150 | QFontMetrics fm ( font() ); | ||
151 | QSize day = daymatrix->sizeHint(); | ||
152 | QSize nav = mNavigatorBar->sizeHint(); | ||
153 | int wid = fm.width( "30") + day.width()+3; | ||
154 | int hei = fm.height() +day.height()+nav.height()+2; | ||
155 | if ( wid < nav.width() ) | ||
156 | wid = nav.width() ; | ||
157 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | ||
158 | return QSize ( wid, hei ); | ||
119 | } | 159 | } |
120 | void KDateNavigator::slotMonthSelected( int m ) | 160 | void KDateNavigator::slotMonthSelected( int m ) |
121 | { | 161 | { |
122 | if ( m_MthYr.month() <= mMonthSignalOffset) | 162 | if ( m_MthYr.month() <= mMonthSignalOffset) |
123 | m += 12; | 163 | m += 12; |
124 | int mo = m - mMonthSignalOffset; | 164 | int mo = m - mMonthSignalOffset; |
125 | emit monthSelected( m - mMonthSignalOffset ); | 165 | emit monthSelected( m - mMonthSignalOffset ); |
126 | 166 | ||
127 | } | 167 | } |
128 | void KDateNavigator::setCalendar( Calendar *cal ) | 168 | void KDateNavigator::setCalendar( Calendar *cal ) |
129 | { | 169 | { |
130 | daymatrix->setCalendar( cal ); | 170 | daymatrix->setCalendar( cal ); |
131 | } | 171 | } |
132 | 172 | ||
133 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 173 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
134 | { | 174 | { |
135 | m_MthYr = date; | 175 | m_MthYr = date; |
136 | 176 | ||
137 | updateDates(); | 177 | updateDates(); |
138 | updateView(); | 178 | updateView(); |
139 | 179 | ||
140 | KCal::DateList dates; | 180 | KCal::DateList dates; |
141 | dates.append( date ); | 181 | dates.append( date ); |
142 | mNavigatorBar->selectDates( dates ); | 182 | mNavigatorBar->selectDates( dates ); |
143 | 183 | ||
144 | daymatrix->clearSelection(); | 184 | daymatrix->clearSelection(); |
145 | if ( doRepaint ) | 185 | if ( doRepaint ) |
146 | daymatrix->repaint(); | 186 | daymatrix->repaint(); |
147 | } | 187 | } |
148 | 188 | ||
149 | void KDateNavigator::enableRollover(RolloverType r) | 189 | void KDateNavigator::enableRollover(RolloverType r) |
150 | { | 190 | { |
151 | switch(r) | 191 | switch(r) |
152 | { | 192 | { |
153 | case None : | 193 | case None : |
154 | if (updateTimer) | 194 | if (updateTimer) |
155 | { | 195 | { |
156 | updateTimer->stop(); | 196 | updateTimer->stop(); |
157 | delete updateTimer; | 197 | delete updateTimer; |
158 | updateTimer=0L; | 198 | updateTimer=0L; |
159 | } | 199 | } |
160 | break; | 200 | break; |
161 | case FollowDay : | 201 | case FollowDay : |
162 | case FollowMonth : | 202 | case FollowMonth : |
163 | if (!updateTimer) | 203 | if (!updateTimer) |
164 | { | 204 | { |
165 | updateTimer = new QTimer(this); | 205 | updateTimer = new QTimer(this); |
166 | QObject::connect(updateTimer,SIGNAL(timeout()), | 206 | QObject::connect(updateTimer,SIGNAL(timeout()), |
167 | this,SLOT(possiblyPastMidnight())); | 207 | this,SLOT(possiblyPastMidnight())); |
168 | } | 208 | } |
169 | updateTimer->start(0,true); | 209 | updateTimer->start(0,true); |
170 | lastDayChecked = QDate::currentDate(); | 210 | lastDayChecked = QDate::currentDate(); |
171 | } | 211 | } |
172 | updateRollover=r; | 212 | updateRollover=r; |
173 | } | 213 | } |
174 | 214 | ||
175 | 215 | ||
176 | KDateNavigator::~KDateNavigator() | 216 | KDateNavigator::~KDateNavigator() |
177 | { | 217 | { |
178 | } | 218 | } |
179 | 219 | ||
180 | 220 | ||
181 | void KDateNavigator::passedMidnight() | 221 | void KDateNavigator::passedMidnight() |
182 | { | 222 | { |
183 | QDate today = QDate::currentDate(); | 223 | QDate today = QDate::currentDate(); |
184 | bool emitMonth = false; | 224 | bool emitMonth = false; |
185 | 225 | ||
186 | if (today.month() != lastDayChecked.month()) | 226 | if (today.month() != lastDayChecked.month()) |
187 | { | 227 | { |
188 | if (updateRollover==FollowMonth && | 228 | if (updateRollover==FollowMonth && |
189 | daymatrix->isEndOfMonth()) { | 229 | daymatrix->isEndOfMonth()) { |
190 | goNextMonth(); | 230 | goNextMonth(); |
191 | emitMonth=true; | 231 | emitMonth=true; |
192 | } | 232 | } |
193 | } | 233 | } |
194 | daymatrix->recalculateToday(); | 234 | daymatrix->recalculateToday(); |
195 | daymatrix->repaint(); | 235 | daymatrix->repaint(); |
196 | emit dayPassed(today); | 236 | emit dayPassed(today); |
197 | if (emitMonth) { emit monthPassed(today); } | 237 | if (emitMonth) { emit monthPassed(today); } |
198 | } | 238 | } |
199 | 239 | ||
200 | /* slot */ void KDateNavigator::possiblyPastMidnight() | 240 | /* slot */ void KDateNavigator::possiblyPastMidnight() |
201 | { | 241 | { |
202 | if (lastDayChecked!=QDate::currentDate()) | 242 | if (lastDayChecked!=QDate::currentDate()) |
203 | { | 243 | { |
204 | passedMidnight(); | 244 | passedMidnight(); |
205 | lastDayChecked=QDate::currentDate(); | 245 | lastDayChecked=QDate::currentDate(); |
206 | } | 246 | } |
207 | // Set the timer to go off 1 second after midnight | 247 | // Set the timer to go off 1 second after midnight |
208 | // or after 8 minutes, whichever comes first. | 248 | // or after 8 minutes, whichever comes first. |
209 | if (updateTimer) | 249 | if (updateTimer) |
210 | { | 250 | { |
211 | QTime now = QTime::currentTime(); | 251 | QTime now = QTime::currentTime(); |
212 | QTime midnight = QTime(23,59,59); | 252 | QTime midnight = QTime(23,59,59); |
213 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); | 253 | int msecsWait = QMIN(480000,now.msecsTo(midnight)+2000); |
214 | 254 | ||
215 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) | 255 | // qDebug(QString("Waiting %1 msec from %2 to %3.").arg(msecsWait)) |
216 | //.arg(now.toString()).arg(midnight.toString())); | 256 | //.arg(now.toString()).arg(midnight.toString())); |
217 | 257 | ||
218 | updateTimer->stop(); | 258 | updateTimer->stop(); |
219 | updateTimer->start(msecsWait,true); | 259 | updateTimer->start(msecsWait,true); |
220 | } | 260 | } |
221 | } | 261 | } |
222 | 262 | ||
223 | void KDateNavigator::updateDates() | 263 | void KDateNavigator::updateDates() |
224 | { | 264 | { |
225 | // Find the first day of the week of the current month. | 265 | // Find the first day of the week of the current month. |
226 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 266 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
227 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 267 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
228 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 268 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
229 | //int di = d1 - d2 + 1; | 269 | //int di = d1 - d2 + 1; |
230 | dayone = dayone.addDays( -d2 + 1 ); | 270 | dayone = dayone.addDays( -d2 + 1 ); |
231 | 271 | ||
232 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 272 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
233 | 273 | ||
234 | // If month begins on Monday and Monday is first day of week, | 274 | // If month begins on Monday and Monday is first day of week, |
235 | // month should begin on second line. Sunday doesn't have this problem. | 275 | // month should begin on second line. Sunday doesn't have this problem. |
236 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 276 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
237 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 277 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
238 | 278 | ||
239 | // update the matrix dates | 279 | // update the matrix dates |
240 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 280 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
241 | 281 | ||
242 | 282 | ||
243 | daymatrix->updateView(dayone.addDays(index)); | 283 | daymatrix->updateView(dayone.addDays(index)); |
244 | //each updateDates is followed by an updateView -> repaint is issued there ! | 284 | //each updateDates is followed by an updateView -> repaint is issued there ! |
245 | // daymatrix->repaint(); | 285 | // daymatrix->repaint(); |
246 | } | 286 | } |
247 | 287 | ||
248 | void KDateNavigator::updateDayMatrix() | 288 | void KDateNavigator::updateDayMatrix() |
249 | { | 289 | { |
250 | daymatrix->updateView(); | 290 | daymatrix->updateView(); |
251 | //daymatrix->repaint(); | 291 | //daymatrix->repaint(); |
252 | } | 292 | } |
253 | 293 | ||
254 | 294 | ||
255 | void KDateNavigator::updateView() | 295 | void KDateNavigator::updateView() |
256 | { | 296 | { |
257 | 297 | ||
258 | setUpdatesEnabled( false ); | 298 | setUpdatesEnabled( false ); |
259 | 299 | ||
260 | int i; | 300 | int i; |
261 | 301 | ||
262 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 302 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
263 | daymatrix->updateView(); | 303 | daymatrix->updateView(); |
264 | 304 | ||
265 | // set the week numbers. | 305 | // set the week numbers. |
266 | for(i = 0; i < 6; i++) { | 306 | for(i = 0; i < 6; i++) { |
267 | QString weeknum; | 307 | QString weeknum; |
268 | // remember, according to ISO 8601, the first week of the year is the | 308 | // remember, according to ISO 8601, the first week of the year is the |
269 | // first week that contains a thursday. Thus we must subtract off 4, | 309 | // first week that contains a thursday. Thus we must subtract off 4, |
270 | // not just 1. | 310 | // not just 1. |
271 | 311 | ||
272 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 312 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
273 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); | 313 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); |
274 | 314 | ||
275 | int add = 0; | 315 | int add = 0; |
276 | if ( ! KGlobal::locale()->weekStartsMonday() ) | 316 | if ( ! KGlobal::locale()->weekStartsMonday() ) |
277 | ++add; | 317 | ++add; |
278 | if (dayOfYear % 7 != 0) | 318 | if (dayOfYear % 7 != 0) |
279 | weeknum.setNum(dayOfYear / 7 + 1+add); | 319 | weeknum.setNum(dayOfYear / 7 + 1+add); |
280 | else | 320 | else |
281 | weeknum.setNum(dayOfYear / 7 +add); | 321 | weeknum.setNum(dayOfYear / 7 +add); |
282 | weeknos[i]->setText(weeknum); | 322 | weeknos[i]->setText(weeknum); |
283 | } | 323 | } |
284 | 324 | ||
285 | setUpdatesEnabled( true ); | 325 | setUpdatesEnabled( true ); |
286 | // kdDebug() << "updateView() -> repaint()" << endl; | 326 | // kdDebug() << "updateView() -> repaint()" << endl; |
287 | repaint(); | 327 | repaint(); |
288 | // daymatrix->repaint(); | 328 | // daymatrix->repaint(); |
289 | } | 329 | } |
290 | 330 | ||
291 | void KDateNavigator::updateConfig() | 331 | void KDateNavigator::updateConfig() |
292 | { | 332 | { |
293 | int day; | 333 | int day; |
294 | for(int i=0; i<7; i++) { | 334 | for(int i=0; i<7; i++) { |
295 | // take the first letter of the day name to be the abbreviation | 335 | // take the first letter of the day name to be the abbreviation |
296 | if (KGlobal::locale()->weekStartsMonday()) { | 336 | if (KGlobal::locale()->weekStartsMonday()) { |
297 | day = i+1; | 337 | day = i+1; |
298 | } else { | 338 | } else { |
299 | if (i==0) day = 7; | 339 | if (i==0) day = 7; |
300 | else day = i; | 340 | else day = i; |
301 | } | 341 | } |
302 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 342 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
303 | true ); | 343 | true ); |
304 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 344 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
305 | headings[i]->setText( dayName ); | 345 | headings[i]->setText( dayName ); |
306 | } | 346 | } |
307 | updateDates(); | 347 | updateDates(); |
308 | updateView(); | 348 | updateView(); |
309 | } | 349 | } |
310 | 350 | ||