Diffstat (limited to 'korganizer/kdatenavigator.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/kdatenavigator.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 5aa1c9b..6697602 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -100,101 +100,99 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) | |||
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 = sizeHintTwoButtons(); | 118 | mySizeHint = sizeHintTwoButtons(); |
119 | myFullSizeHint = sizeHintTwoButtons( 4 ); | 119 | myFullSizeHint = sizeHintTwoButtons( 4 ); |
120 | mFontChanged = false; | 120 | mFontChanged = false; |
121 | //resize ( 3,3 ); | 121 | //resize ( 3,3 ); |
122 | 122 | ||
123 | } | 123 | } |
124 | void KDateNavigator::changeFont ( QFont fo ) | 124 | void KDateNavigator::changeFont ( QFont fo ) |
125 | { | 125 | { |
126 | setFont( fo ); | 126 | setFont( fo ); |
127 | mNavigatorBar->resetFont( fo ); | 127 | mNavigatorBar->resetFont( fo ); |
128 | } | 128 | } |
129 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) | 129 | QFont KDateNavigator::yourFontHint( QSize si , bool *b) |
130 | { | 130 | { |
131 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; | 131 | QFont fo = KOPrefs::instance()->mDateNavigatorFont; |
132 | *b = false; | 132 | *b = false; |
133 | int fontPoint = fo.pointSize(); | 133 | int fontPoint = fo.pointSize(); |
134 | while ( fontPoint > 5 ) { | 134 | while ( fontPoint > 5 ) { |
135 | --fontPoint; | 135 | --fontPoint; |
136 | fo.setPointSize( fontPoint ); | 136 | fo.setPointSize( fontPoint ); |
137 | setFont( fo ); | 137 | setFont( fo ); |
138 | mFontChanged = true; | 138 | mFontChanged = true; |
139 | mNavigatorBar->resetFont( fo ); | 139 | mNavigatorBar->resetFont( fo ); |
140 | QSize sh = sizeHintTwoButtons( 2 ); | 140 | QSize sh = sizeHintTwoButtons( 2 ); |
141 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); | 141 | //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); |
142 | if ( si.width() > sh.width() && si.height() > sh.height()) { | 142 | if ( si.width() > sh.width() && si.height() > sh.height()) { |
143 | if ( si.width() / sh.width() == 1 ) { | 143 | if ( si.width() / sh.width() == 1 ) { |
144 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) | 144 | if ( si.width() < sizeHintTwoButtons( 4 ).width()) |
145 | continue; | 145 | continue; |
146 | } | 146 | } |
147 | *b = true; | 147 | *b = true; |
148 | //qDebug("fooooooooooooooooooooooouuuuund "); | ||
149 | break; | 148 | break; |
150 | } | 149 | } |
151 | } | 150 | } |
152 | //qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() ); | ||
153 | return fo; | 151 | return fo; |
154 | } | 152 | } |
155 | QSize KDateNavigator::sizeHint() const | 153 | QSize KDateNavigator::sizeHint() const |
156 | { | 154 | { |
157 | QFontMetrics fm ( font() ); | 155 | QFontMetrics fm ( font() ); |
158 | QSize day = daymatrix->sizeHint(); | 156 | QSize day = daymatrix->sizeHint(); |
159 | QSize nav = mNavigatorBar->sizeHint(); | 157 | QSize nav = mNavigatorBar->sizeHint(); |
160 | int wid = fm.width( "30") + day.width()+3; | 158 | int wid = fm.width( "30") + day.width()+3; |
161 | int hei = fm.height() +day.height()+nav.height()+2; | 159 | int hei = fm.height() +day.height()+nav.height()+2; |
162 | if ( wid < nav.width() ) | 160 | if ( wid < nav.width() ) |
163 | wid = nav.width() ; | 161 | wid = nav.width() ; |
164 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 162 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
165 | return QSize ( wid, hei ); | 163 | return QSize ( wid, hei ); |
166 | } | 164 | } |
167 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const | 165 | QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const |
168 | { | 166 | { |
169 | QFontMetrics fm ( font() ); | 167 | QFontMetrics fm ( font() ); |
170 | QSize day = daymatrix->sizeHint(); | 168 | QSize day = daymatrix->sizeHint(); |
171 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); | 169 | QSize nav = mNavigatorBar->sizeHintTwoButtons( butnum ); |
172 | int wid = fm.width( "30") + day.width()+3; | 170 | int wid = fm.width( "30") + day.width()+3; |
173 | int hei = fm.height() +day.height()+nav.height()+2; | 171 | int hei = fm.height() +day.height()+nav.height()+2; |
174 | if ( wid < nav.width() ) | 172 | if ( wid < nav.width() ) |
175 | wid = nav.width() ; | 173 | wid = nav.width() ; |
176 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); | 174 | //qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei); |
177 | return QSize ( wid, hei ); | 175 | return QSize ( wid, hei ); |
178 | } | 176 | } |
179 | void KDateNavigator::slotMonthSelected( int m ) | 177 | void KDateNavigator::slotMonthSelected( int m ) |
180 | { | 178 | { |
181 | if ( m_MthYr.month() <= mMonthSignalOffset) | 179 | if ( m_MthYr.month() <= mMonthSignalOffset) |
182 | m += 12; | 180 | m += 12; |
183 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); | 181 | //qDebug("%d mMonthSignalOffset %d emit %d", m, mMonthSignalOffset, m - mMonthSignalOffset); |
184 | emit monthSelected( m - mMonthSignalOffset ); | 182 | emit monthSelected( m - mMonthSignalOffset ); |
185 | 183 | ||
186 | } | 184 | } |
187 | void KDateNavigator::setCalendar( Calendar *cal ) | 185 | void KDateNavigator::setCalendar( Calendar *cal ) |
188 | { | 186 | { |
189 | daymatrix->setCalendar( cal ); | 187 | daymatrix->setCalendar( cal ); |
190 | } | 188 | } |
191 | 189 | ||
192 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true | 190 | void KDateNavigator::setBaseDate( const QDate &date , bool doRepaint ) // = true |
193 | { | 191 | { |
194 | m_MthYr = date; | 192 | m_MthYr = date; |
195 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); | 193 | //qDebug("KDateNavigator::setBaseDate %s ", date.toString().latin1()); |
196 | 194 | ||
197 | updateDates(); | 195 | updateDates(); |
198 | updateView(); | 196 | updateView(); |
199 | 197 | ||
200 | KCal::DateList dates; | 198 | KCal::DateList dates; |
@@ -323,97 +321,97 @@ void KDateNavigator::updateView() | |||
323 | daymatrix->updateView(); | 321 | daymatrix->updateView(); |
324 | int sub = 4; | 322 | int sub = 4; |
325 | if ( ! KGlobal::locale()->weekStartsMonday() ) | 323 | if ( ! KGlobal::locale()->weekStartsMonday() ) |
326 | --sub; | 324 | --sub; |
327 | // set the week numbers. | 325 | // set the week numbers. |
328 | for(i = 0; i < 6; i++) { | 326 | for(i = 0; i < 6; i++) { |
329 | // remember, according to ISO 8601, the first week of the year is the | 327 | // remember, according to ISO 8601, the first week of the year is the |
330 | // first week that contains a thursday. Thus we must subtract off 4, | 328 | // first week that contains a thursday. Thus we must subtract off 4, |
331 | // not just 1. | 329 | // not just 1. |
332 | 330 | ||
333 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 331 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
334 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub))); | 332 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub))); |
335 | int weekNo; | 333 | int weekNo; |
336 | if (dayOfYear % 7 != 0) | 334 | if (dayOfYear % 7 != 0) |
337 | weekNo = (dayOfYear / 7 + 1); | 335 | weekNo = (dayOfYear / 7 + 1); |
338 | else | 336 | else |
339 | weekNo = (dayOfYear / 7); | 337 | weekNo = (dayOfYear / 7); |
340 | weeknos[i]->setText(QString::number( weekNo )); | 338 | weeknos[i]->setText(QString::number( weekNo )); |
341 | } | 339 | } |
342 | 340 | ||
343 | setUpdatesEnabled( true ); | 341 | setUpdatesEnabled( true ); |
344 | // kdDebug() << "updateView() -> repaint()" << endl; | 342 | // kdDebug() << "updateView() -> repaint()" << endl; |
345 | repaint(); | 343 | repaint(); |
346 | // daymatrix->repaint(); | 344 | // daymatrix->repaint(); |
347 | } | 345 | } |
348 | 346 | ||
349 | void KDateNavigator::updateConfig() | 347 | void KDateNavigator::updateConfig() |
350 | { | 348 | { |
351 | int day; | 349 | int day; |
352 | for(int i=0; i<7; i++) { | 350 | for(int i=0; i<7; i++) { |
353 | // take the first letter of the day name to be the abbreviation | 351 | // take the first letter of the day name to be the abbreviation |
354 | if (KGlobal::locale()->weekStartsMonday()) { | 352 | if (KGlobal::locale()->weekStartsMonday()) { |
355 | day = i+1; | 353 | day = i+1; |
356 | } else { | 354 | } else { |
357 | if (i==0) day = 7; | 355 | if (i==0) day = 7; |
358 | else day = i; | 356 | else day = i; |
359 | } | 357 | } |
360 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 358 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
361 | true ); | 359 | true ); |
362 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 360 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
363 | headings[i]->setText( dayName ); | 361 | headings[i]->setText( dayName ); |
364 | } | 362 | } |
365 | updateDates(); | 363 | updateDates(); |
366 | updateView(); | 364 | updateView(); |
367 | } | 365 | } |
368 | 366 | ||
369 | void KDateNavigator::setShowWeekNums(bool enabled) | 367 | void KDateNavigator::setShowWeekNums(bool enabled) |
370 | { | 368 | { |
371 | qDebug("KDateNavigator::setShowWeekNums***************************** "); | 369 | |
372 | m_bShowWeekNums = enabled; | 370 | m_bShowWeekNums = enabled; |
373 | for(int i=0; i<6; i++) { | 371 | for(int i=0; i<6; i++) { |
374 | if(enabled) | 372 | if(enabled) |
375 | weeknos[i]->show(); | 373 | weeknos[i]->show(); |
376 | else | 374 | else |
377 | weeknos[i]->hide(); | 375 | weeknos[i]->hide(); |
378 | } | 376 | } |
379 | resize(size()); | 377 | resize(size()); |
380 | } | 378 | } |
381 | 379 | ||
382 | void KDateNavigator::selectDates(const DateList& dateList) | 380 | void KDateNavigator::selectDates(const DateList& dateList) |
383 | { | 381 | { |
384 | 382 | ||
385 | if (dateList.count() > 0) { | 383 | if (dateList.count() > 0) { |
386 | mNavigatorBar->selectDates( dateList ); | 384 | mNavigatorBar->selectDates( dateList ); |
387 | mSelectedDates = dateList; | 385 | mSelectedDates = dateList; |
388 | 386 | ||
389 | // set our record of the month and year that this datetbl is | 387 | // set our record of the month and year that this datetbl is |
390 | // displaying. | 388 | // displaying. |
391 | m_MthYr = mSelectedDates.first(); | 389 | m_MthYr = mSelectedDates.first(); |
392 | 390 | ||
393 | 391 | ||
394 | // set our record of the first day of the week of the current | 392 | // set our record of the first day of the week of the current |
395 | // month. This needs to be done before calling dayToIndex, since it | 393 | // month. This needs to be done before calling dayToIndex, since it |
396 | // relies on this information being up to date. | 394 | // relies on this information being up to date. |
397 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); | 395 | QDate dayone(m_MthYr.year(), m_MthYr.month(), 1); |
398 | m_fstDayOfWk = dayone.dayOfWeek(); | 396 | m_fstDayOfWk = dayone.dayOfWeek(); |
399 | 397 | ||
400 | updateDates(); | 398 | updateDates(); |
401 | 399 | ||
402 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); | 400 | daymatrix->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end())); |
403 | 401 | ||
404 | updateView(); | 402 | updateView(); |
405 | } | 403 | } |
406 | } | 404 | } |
407 | 405 | ||
408 | int KDateNavigator::dayNum(int row, int col) | 406 | int KDateNavigator::dayNum(int row, int col) |
409 | { | 407 | { |
410 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; | 408 | return 7 * (row - 1) + (col + 1) - m_fstDayOfWk; |
411 | } | 409 | } |
412 | 410 | ||
413 | int KDateNavigator::dayToIndex(int dayNum) | 411 | int KDateNavigator::dayToIndex(int dayNum) |
414 | { | 412 | { |
415 | int row, col; | 413 | int row, col; |
416 | 414 | ||
417 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; | 415 | row = (dayNum+m_fstDayOfWk-1-(KGlobal::locale()->weekStartsMonday() ? 1 : 0)) / 7; |
418 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) | 416 | if (KGlobal::locale()->weekStartsMonday() && (m_fstDayOfWk == 1)) |
419 | row++; | 417 | row++; |