author | zautrix <zautrix> | 2005-03-28 23:39:37 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-28 23:39:37 (UTC) |
commit | 4e7c45695672ecdbd0cd14cac0ea29a8e134ee78 (patch) (unidiff) | |
tree | 6815e055d6cb35d56d43f036261f5be9d2a9c350 /korganizer | |
parent | 4034290f894ff7d1b0cf1197078e0ed832566bb7 (diff) | |
download | kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.zip kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.gz kdepimpi-4e7c45695672ecdbd0cd14cac0ea29a8e134ee78.tar.bz2 |
montview sunday fix
-rw-r--r-- | korganizer/kdatenavigator.cpp | 18 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 25 | ||||
-rw-r--r-- | korganizer/komonthview.h | 2 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 28 |
4 files changed, 24 insertions, 49 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 38bddc2..2fca49e 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp | |||
@@ -277,115 +277,113 @@ void KDateNavigator::passedMidnight() | |||
277 | //.arg(now.toString()).arg(midnight.toString())); | 277 | //.arg(now.toString()).arg(midnight.toString())); |
278 | 278 | ||
279 | updateTimer->stop(); | 279 | updateTimer->stop(); |
280 | updateTimer->start(msecsWait,true); | 280 | updateTimer->start(msecsWait,true); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | void KDateNavigator::updateDates() | 284 | void KDateNavigator::updateDates() |
285 | { | 285 | { |
286 | // Find the first day of the week of the current month. | 286 | // Find the first day of the week of the current month. |
287 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); | 287 | //int d1 = KOGlobals::self()->calendarSystem()->day( m_MthYr ); |
288 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); | 288 | QDate dayone( m_MthYr.year(), m_MthYr.month(), m_MthYr.day() ); |
289 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); | 289 | int d2 = KOGlobals::self()->calendarSystem()->day( dayone ); |
290 | //int di = d1 - d2 + 1; | 290 | //int di = d1 - d2 + 1; |
291 | dayone = dayone.addDays( -d2 + 1 ); | 291 | dayone = dayone.addDays( -d2 + 1 ); |
292 | 292 | ||
293 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); | 293 | int m_fstDayOfWkCalsys = KOGlobals::self()->calendarSystem()->dayOfWeek( dayone ); |
294 | 294 | ||
295 | // If month begins on Monday and Monday is first day of week, | 295 | // If month begins on Monday and Monday is first day of week, |
296 | // month should begin on second line. Sunday doesn't have this problem. | 296 | // month should begin on second line. Sunday doesn't have this problem. |
297 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && | 297 | int nextLine = ( ( m_fstDayOfWkCalsys == 1) && |
298 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; | 298 | ( KGlobal::locale()->weekStartsMonday() == 1 ) ) ? 7 : 0; |
299 | 299 | ||
300 | // update the matrix dates | 300 | // update the matrix dates |
301 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; | 301 | int index = (KGlobal::locale()->weekStartsMonday() ? 1 : 0) - m_fstDayOfWkCalsys - nextLine; |
302 | 302 | ||
303 | 303 | ||
304 | daymatrix->updateView(dayone.addDays(index)); | 304 | daymatrix->updateView(dayone.addDays(index)); |
305 | //each updateDates is followed by an updateView -> repaint is issued there ! | 305 | //each updateDates is followed by an updateView -> repaint is issued there ! |
306 | // daymatrix->repaint(); | 306 | // daymatrix->repaint(); |
307 | } | 307 | } |
308 | 308 | ||
309 | void KDateNavigator::updateDayMatrix() | 309 | void KDateNavigator::updateDayMatrix() |
310 | { | 310 | { |
311 | daymatrix->updateView(); | 311 | daymatrix->updateView(); |
312 | //daymatrix->repaint(); | 312 | //daymatrix->repaint(); |
313 | } | 313 | } |
314 | 314 | ||
315 | 315 | ||
316 | void KDateNavigator::updateView() | 316 | void KDateNavigator::updateView() |
317 | { | 317 | { |
318 | 318 | ||
319 | setUpdatesEnabled( false ); | 319 | setUpdatesEnabled( false ); |
320 | 320 | ||
321 | int i; | 321 | int i; |
322 | 322 | ||
323 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; | 323 | // kdDebug() << "updateView() -> daymatrix->updateView()" << endl; |
324 | daymatrix->updateView(); | 324 | daymatrix->updateView(); |
325 | 325 | int sub = 4; | |
326 | if ( ! KGlobal::locale()->weekStartsMonday() ) | ||
327 | --sub; | ||
326 | // set the week numbers. | 328 | // set the week numbers. |
327 | for(i = 0; i < 6; i++) { | 329 | for(i = 0; i < 6; i++) { |
328 | QString weeknum; | ||
329 | // remember, according to ISO 8601, the first week of the year is the | 330 | // 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, | 331 | // first week that contains a thursday. Thus we must subtract off 4, |
331 | // not just 1. | 332 | // not just 1. |
332 | 333 | ||
333 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); | 334 | //ET int dayOfYear = buttons[(i + 1) * 7 - 4]->date().dayOfYear(); |
334 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-4))); | 335 | int dayOfYear = KOGlobals::self()->calendarSystem()->dayOfYear((daymatrix->getDate((i+1)*7-sub))); |
335 | 336 | int weekNo; | |
336 | int add = 0; | ||
337 | if ( ! KGlobal::locale()->weekStartsMonday() ) | ||
338 | ++add; | ||
339 | if (dayOfYear % 7 != 0) | 337 | if (dayOfYear % 7 != 0) |
340 | weeknum.setNum(dayOfYear / 7 + 1+add); | 338 | weekNo = (dayOfYear / 7 + 1); |
341 | else | 339 | else |
342 | weeknum.setNum(dayOfYear / 7 +add); | 340 | weekNo = (dayOfYear / 7); |
343 | weeknos[i]->setText(weeknum); | 341 | weeknos[i]->setText(QString::number( weekNo )); |
344 | } | 342 | } |
345 | 343 | ||
346 | setUpdatesEnabled( true ); | 344 | setUpdatesEnabled( true ); |
347 | // kdDebug() << "updateView() -> repaint()" << endl; | 345 | // kdDebug() << "updateView() -> repaint()" << endl; |
348 | repaint(); | 346 | repaint(); |
349 | // daymatrix->repaint(); | 347 | // daymatrix->repaint(); |
350 | } | 348 | } |
351 | 349 | ||
352 | void KDateNavigator::updateConfig() | 350 | void KDateNavigator::updateConfig() |
353 | { | 351 | { |
354 | int day; | 352 | int day; |
355 | for(int i=0; i<7; i++) { | 353 | for(int i=0; i<7; i++) { |
356 | // take the first letter of the day name to be the abbreviation | 354 | // take the first letter of the day name to be the abbreviation |
357 | if (KGlobal::locale()->weekStartsMonday()) { | 355 | if (KGlobal::locale()->weekStartsMonday()) { |
358 | day = i+1; | 356 | day = i+1; |
359 | } else { | 357 | } else { |
360 | if (i==0) day = 7; | 358 | if (i==0) day = 7; |
361 | else day = i; | 359 | else day = i; |
362 | } | 360 | } |
363 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, | 361 | QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( day, |
364 | true ); | 362 | true ); |
365 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); | 363 | if ( KOPrefs::instance()->mCompactDialogs ) dayName = dayName.left( 1 ); |
366 | headings[i]->setText( dayName ); | 364 | headings[i]->setText( dayName ); |
367 | } | 365 | } |
368 | updateDates(); | 366 | updateDates(); |
369 | updateView(); | 367 | updateView(); |
370 | } | 368 | } |
371 | 369 | ||
372 | void KDateNavigator::setShowWeekNums(bool enabled) | 370 | void KDateNavigator::setShowWeekNums(bool enabled) |
373 | { | 371 | { |
374 | qDebug("KDateNavigator::setShowWeekNums***************************** "); | 372 | qDebug("KDateNavigator::setShowWeekNums***************************** "); |
375 | m_bShowWeekNums = enabled; | 373 | m_bShowWeekNums = enabled; |
376 | for(int i=0; i<6; i++) { | 374 | for(int i=0; i<6; i++) { |
377 | if(enabled) | 375 | if(enabled) |
378 | weeknos[i]->show(); | 376 | weeknos[i]->show(); |
379 | else | 377 | else |
380 | weeknos[i]->hide(); | 378 | weeknos[i]->hide(); |
381 | } | 379 | } |
382 | resize(size()); | 380 | resize(size()); |
383 | } | 381 | } |
384 | 382 | ||
385 | void KDateNavigator::selectDates(const DateList& dateList) | 383 | void KDateNavigator::selectDates(const DateList& dateList) |
386 | { | 384 | { |
387 | 385 | ||
388 | if (dateList.count() > 0) { | 386 | if (dateList.count() > 0) { |
389 | mNavigatorBar->selectDates( dateList ); | 387 | mNavigatorBar->selectDates( dateList ); |
390 | mSelectedDates = dateList; | 388 | mSelectedDates = dateList; |
391 | 389 | ||
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9085775..d825493 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -956,100 +956,97 @@ void MonthViewCell::cellClicked( QListBoxItem *item ) | |||
956 | select(); | 956 | select(); |
957 | } | 957 | } |
958 | 958 | ||
959 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 959 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
960 | { | 960 | { |
961 | if ( !item ) return; | 961 | if ( !item ) return; |
962 | 962 | ||
963 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 963 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
964 | Incidence *incidence = eventItem->incidence(); | 964 | Incidence *incidence = eventItem->incidence(); |
965 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 965 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
966 | } | 966 | } |
967 | 967 | ||
968 | void MonthViewCell::selection( QListBoxItem *item ) | 968 | void MonthViewCell::selection( QListBoxItem *item ) |
969 | { | 969 | { |
970 | if ( !item ) return; | 970 | if ( !item ) return; |
971 | 971 | ||
972 | mMonthView->setSelectedCell( this ); | 972 | mMonthView->setSelectedCell( this ); |
973 | } | 973 | } |
974 | 974 | ||
975 | 975 | ||
976 | // ******************************************************************************* | 976 | // ******************************************************************************* |
977 | // ******************************************************************************* | 977 | // ******************************************************************************* |
978 | // ******************************************************************************* | 978 | // ******************************************************************************* |
979 | 979 | ||
980 | 980 | ||
981 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 981 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
982 | : KOEventView( calendar, parent, name ), | 982 | : KOEventView( calendar, parent, name ), |
983 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 983 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
984 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 984 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
985 | { | 985 | { |
986 | mShortDayLabelsM = false; | 986 | mShortDayLabelsM = false; |
987 | mShortDayLabelsW = false; | 987 | mShortDayLabelsW = false; |
988 | skipResize = false; | 988 | skipResize = false; |
989 | clPending = true; | 989 | clPending = true; |
990 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 990 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
991 | mWidStack = new QWidgetStack( this ); | 991 | mWidStack = new QWidgetStack( this ); |
992 | QVBoxLayout* hb = new QVBoxLayout( this ); | 992 | QVBoxLayout* hb = new QVBoxLayout( this ); |
993 | mMonthView = new QWidget( mWidStack ); | 993 | mMonthView = new QWidget( mWidStack ); |
994 | mWeekView = new QWidget( mWidStack ); | 994 | mWeekView = new QWidget( mWidStack ); |
995 | #if QT_VERSION >= 0x030000 | 995 | #if QT_VERSION >= 0x030000 |
996 | mWidStack->addWidget(mMonthView ); | 996 | mWidStack->addWidget(mMonthView ); |
997 | mWidStack->addWidget(mWeekView ); | 997 | mWidStack->addWidget(mWeekView ); |
998 | #else | 998 | #else |
999 | mWidStack->addWidget( mMonthView, 1 ); | 999 | mWidStack->addWidget( mMonthView, 1 ); |
1000 | mWidStack->addWidget( mWeekView , 1 ); | 1000 | mWidStack->addWidget( mWeekView , 1 ); |
1001 | #endif | 1001 | #endif |
1002 | hb->addWidget( mNavigatorBar ); | 1002 | hb->addWidget( mNavigatorBar ); |
1003 | hb->addWidget( mWidStack ); | 1003 | hb->addWidget( mWidStack ); |
1004 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | ||
1005 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1004 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1006 | if ( mShowWeekView ) | ||
1007 | mWeekStartsMonday = true; | ||
1008 | updatePossible = false; | 1005 | updatePossible = false; |
1009 | //updatePossible = true; | 1006 | //updatePossible = true; |
1010 | mCells.setAutoDelete( true ); | 1007 | mCells.setAutoDelete( true ); |
1011 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1008 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1012 | mDayLabels.resize( mDaysPerWeek ); | 1009 | mDayLabels.resize( mDaysPerWeek ); |
1013 | mDayLabelsW.resize( mDaysPerWeek ); | 1010 | mDayLabelsW.resize( mDaysPerWeek ); |
1014 | QFont bfont = font(); | 1011 | QFont bfont = font(); |
1015 | if ( QApplication::desktop()->width() < 650 ) { | 1012 | if ( QApplication::desktop()->width() < 650 ) { |
1016 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1013 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1017 | } | 1014 | } |
1018 | bfont.setBold( true ); | 1015 | bfont.setBold( true ); |
1019 | int i; | 1016 | int i; |
1020 | 1017 | ||
1021 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1018 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1022 | QLabel *label = new QLabel( mMonthView ); | 1019 | QLabel *label = new QLabel( mMonthView ); |
1023 | label->setFont(bfont); | 1020 | label->setFont(bfont); |
1024 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1021 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1025 | label->setLineWidth(1); | 1022 | label->setLineWidth(1); |
1026 | label->setAlignment(AlignCenter); | 1023 | label->setAlignment(AlignCenter); |
1027 | mDayLabels.insert( i, label ); | 1024 | mDayLabels.insert( i, label ); |
1028 | label = new QLabel( mWeekView ); | 1025 | label = new QLabel( mWeekView ); |
1029 | label->setFont(bfont); | 1026 | label->setFont(bfont); |
1030 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1027 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1031 | label->setLineWidth(1); | 1028 | label->setLineWidth(1); |
1032 | label->setAlignment(AlignCenter); | 1029 | label->setAlignment(AlignCenter); |
1033 | mDayLabelsW.insert( i, label ); | 1030 | mDayLabelsW.insert( i, label ); |
1034 | } | 1031 | } |
1035 | 1032 | ||
1036 | bfont.setBold( false ); | 1033 | bfont.setBold( false ); |
1037 | mWeekLabels.resize( mNumWeeks+1 ); | 1034 | mWeekLabels.resize( mNumWeeks+1 ); |
1038 | mWeekLabelsW.resize( 2 ); | 1035 | mWeekLabelsW.resize( 2 ); |
1039 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1036 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1040 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1037 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1041 | label->setFocusPolicy(NoFocus); | 1038 | label->setFocusPolicy(NoFocus); |
1042 | label->setFont(bfont); | 1039 | label->setFont(bfont); |
1043 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1040 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1044 | label->setFlat(true); | 1041 | label->setFlat(true); |
1045 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1042 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1046 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1043 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1047 | //label->setLineWidth(1); | 1044 | //label->setLineWidth(1); |
1048 | //label->setAlignment(AlignCenter); | 1045 | //label->setAlignment(AlignCenter); |
1049 | mWeekLabels.insert( i, label ); | 1046 | mWeekLabels.insert( i, label ); |
1050 | } | 1047 | } |
1051 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1048 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1052 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1049 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1053 | 1050 | ||
1054 | for( i = 0; i < 1+1; i++ ) { | 1051 | for( i = 0; i < 1+1; i++ ) { |
1055 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1052 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
@@ -1172,192 +1169,194 @@ void KOMonthView::switchView() | |||
1172 | clPending = false; | 1169 | clPending = false; |
1173 | } | 1170 | } |
1174 | 1171 | ||
1175 | int KOMonthView::maxDatesHint() | 1172 | int KOMonthView::maxDatesHint() |
1176 | { | 1173 | { |
1177 | return mNumCells; | 1174 | return mNumCells; |
1178 | } | 1175 | } |
1179 | 1176 | ||
1180 | int KOMonthView::currentDateCount() | 1177 | int KOMonthView::currentDateCount() |
1181 | { | 1178 | { |
1182 | return mNumCells; | 1179 | return mNumCells; |
1183 | } | 1180 | } |
1184 | 1181 | ||
1185 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1182 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1186 | { | 1183 | { |
1187 | QPtrList<Incidence> selected; | 1184 | QPtrList<Incidence> selected; |
1188 | 1185 | ||
1189 | if ( mSelectedCell ) { | 1186 | if ( mSelectedCell ) { |
1190 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1187 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1191 | if ( incidence ) selected.append( incidence ); | 1188 | if ( incidence ) selected.append( incidence ); |
1192 | } | 1189 | } |
1193 | 1190 | ||
1194 | return selected; | 1191 | return selected; |
1195 | } | 1192 | } |
1196 | 1193 | ||
1197 | DateList KOMonthView::selectedDates() | 1194 | DateList KOMonthView::selectedDates() |
1198 | { | 1195 | { |
1199 | DateList selected; | 1196 | DateList selected; |
1200 | 1197 | ||
1201 | if ( mSelectedCell ) { | 1198 | if ( mSelectedCell ) { |
1202 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1199 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1203 | if ( qd.isValid() ) selected.append( qd ); | 1200 | if ( qd.isValid() ) selected.append( qd ); |
1204 | } | 1201 | } |
1205 | 1202 | ||
1206 | return selected; | 1203 | return selected; |
1207 | } | 1204 | } |
1208 | 1205 | ||
1209 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1206 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1210 | const QDate &td) | 1207 | const QDate &td) |
1211 | { | 1208 | { |
1212 | #ifndef KORG_NOPRINTER | 1209 | #ifndef KORG_NOPRINTER |
1213 | calPrinter->preview(CalPrinter::Month, fd, td); | 1210 | calPrinter->preview(CalPrinter::Month, fd, td); |
1214 | #endif | 1211 | #endif |
1215 | } | 1212 | } |
1216 | 1213 | ||
1217 | void KOMonthView::updateConfig() | 1214 | void KOMonthView::updateConfig() |
1218 | { | 1215 | { |
1219 | 1216 | ||
1220 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1217 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1221 | 1218 | ||
1222 | if ( mShowWeekView ) { | 1219 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1223 | mWeekStartsMonday = true; | 1220 | mWeekStartsMonday = true; |
1224 | } | 1221 | } |
1225 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1222 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1226 | mWidthLongDayLabel = 0; | 1223 | mWidthLongDayLabel = 0; |
1227 | 1224 | ||
1228 | for (int i = 0; i < 7; i++) { | 1225 | for (int i = 0; i < 7; i++) { |
1229 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1226 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1230 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1227 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1231 | } | 1228 | } |
1232 | bool temp = mShowSatSunComp ; | 1229 | bool temp = mShowSatSunComp ; |
1233 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1230 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1234 | if ( ! mShowWeekView ) { | 1231 | if ( ! mShowWeekView ) { |
1235 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1232 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1236 | computeLayout(); | 1233 | computeLayout(); |
1237 | } | 1234 | } |
1238 | updateDayLabels(); | 1235 | updateDayLabels(); |
1239 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1236 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1240 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1237 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1241 | //resizeEvent( 0 ); | 1238 | //resizeEvent( 0 ); |
1242 | for (uint i = 0; i < mCells.count(); ++i) { | 1239 | for (uint i = 0; i < mCells.count(); ++i) { |
1243 | mCells[i]->updateConfig(); | 1240 | mCells[i]->updateConfig(); |
1244 | } | 1241 | } |
1245 | 1242 | ||
1246 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1243 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1247 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1244 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1248 | } | 1245 | } |
1249 | #ifdef DESKTOP_VERSION | 1246 | #ifdef DESKTOP_VERSION |
1250 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1247 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1251 | #endif | 1248 | #endif |
1252 | updateView(); | 1249 | updateView(); |
1253 | } | 1250 | } |
1254 | 1251 | ||
1255 | void KOMonthView::updateDayLabels() | 1252 | void KOMonthView::updateDayLabels() |
1256 | { | 1253 | { |
1257 | 1254 | ||
1258 | QPtrVector<QLabel> *mDayLabelsT; | 1255 | QPtrVector<QLabel> *mDayLabelsT; |
1259 | 1256 | ||
1260 | mDayLabelsT = &mDayLabelsW; | 1257 | mDayLabelsT = &mDayLabelsW; |
1261 | for (int i = 0; i < 7; i++) { | 1258 | for (int i = 0; i < 7; i++) { |
1262 | if (mWeekStartsMonday) { | 1259 | { |
1263 | bool show = mShortDayLabelsW; | 1260 | bool show = mShortDayLabelsW; |
1264 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1261 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1265 | show = true; | 1262 | show = true; |
1266 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1263 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1267 | } else { | ||
1268 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); | ||
1269 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); | ||
1270 | |||
1271 | } | 1264 | } |
1272 | } | 1265 | } |
1273 | mDayLabelsT = &mDayLabels; | 1266 | mDayLabelsT = &mDayLabels; |
1274 | for (int i = 0; i < 7; i++) { | 1267 | for (int i = 0; i < 7; i++) { |
1275 | if (mWeekStartsMonday) { | 1268 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1276 | bool show = mShortDayLabelsM; | 1269 | bool show = mShortDayLabelsM; |
1277 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1270 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1278 | show = true; | 1271 | show = true; |
1279 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1272 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1280 | } else { | 1273 | } else { |
1281 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1274 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1282 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1275 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1283 | 1276 | ||
1284 | } | 1277 | } |
1285 | } | 1278 | } |
1286 | 1279 | ||
1287 | } | 1280 | } |
1288 | 1281 | ||
1289 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1282 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1290 | { | 1283 | { |
1291 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1284 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1292 | 1285 | ||
1293 | QPtrVector<MonthViewCell> *cells; | 1286 | QPtrVector<MonthViewCell> *cells; |
1294 | QPtrVector<QLabel> *dayLabels; | 1287 | QPtrVector<QLabel> *dayLabels; |
1295 | QPtrVector<KOWeekButton> *weekLabels; | 1288 | QPtrVector<KOWeekButton> *weekLabels; |
1296 | int weekNum = 6; | 1289 | int weekNum = 6; |
1290 | mStartDate = start; | ||
1297 | if ( mShowWeekView ) { | 1291 | if ( mShowWeekView ) { |
1298 | weekNum = 1; | 1292 | weekNum = 1; |
1299 | cells = &mCellsW; | 1293 | cells = &mCellsW; |
1300 | dayLabels = &mDayLabelsW; | 1294 | dayLabels = &mDayLabelsW; |
1301 | weekLabels = &mWeekLabelsW; | 1295 | weekLabels = &mWeekLabelsW; |
1296 | if ( !KGlobal::locale()->weekStartsMonday() ) { | ||
1297 | mStartDate = mStartDate.addDays( 1 ); | ||
1298 | } | ||
1302 | } else { | 1299 | } else { |
1303 | cells = &mCells; | 1300 | cells = &mCells; |
1304 | dayLabels = &mDayLabels; | 1301 | dayLabels = &mDayLabels; |
1305 | weekLabels = &mWeekLabels; | 1302 | weekLabels = &mWeekLabels; |
1306 | } | 1303 | } |
1307 | 1304 | ||
1308 | mStartDate = start; | 1305 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1309 | 1306 | ||
1307 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | ||
1308 | mWeekStartsMonday = true; | ||
1309 | } | ||
1310 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1310 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1311 | 1311 | ||
1312 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1312 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1313 | mStartDate = mStartDate.addDays( -1 ); | 1313 | mStartDate = mStartDate.addDays( -1 ); |
1314 | } | 1314 | } |
1315 | |||
1316 | bool primary = false; | 1315 | bool primary = false; |
1317 | uint i; | 1316 | uint i; |
1318 | for( i = 0; i < (*cells).size(); ++i ) { | 1317 | for( i = 0; i < (*cells).size(); ++i ) { |
1319 | QDate date = mStartDate.addDays( i ); | 1318 | QDate date = mStartDate.addDays( i ); |
1320 | (*cells)[i]->setDate( date ); | 1319 | (*cells)[i]->setDate( date ); |
1321 | 1320 | ||
1322 | #ifndef KORG_NOPLUGINS | 1321 | #ifndef KORG_NOPLUGINS |
1323 | // add holiday, if present | 1322 | // add holiday, if present |
1324 | QString hstring(KOCore::self()->holiday(date)); | 1323 | QString hstring(KOCore::self()->holiday(date)); |
1325 | (*cells)[i]->setHoliday( hstring ); | 1324 | (*cells)[i]->setHoliday( hstring ); |
1326 | #endif | 1325 | #endif |
1327 | 1326 | ||
1328 | } | 1327 | } |
1329 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1328 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1330 | for( i = 0; i < weekNum; ++i ) { | 1329 | for( i = 0; i < weekNum; ++i ) { |
1331 | int wno; | 1330 | int wno; |
1332 | // remember, according to ISO 8601, the first week of the year is the | 1331 | // remember, according to ISO 8601, the first week of the year is the |
1333 | // first week that contains a thursday. Thus we must subtract off 4, | 1332 | // first week that contains a thursday. Thus we must subtract off 4, |
1334 | // not just 1. | 1333 | // not just 1. |
1335 | int dayOfYear = date.dayOfYear(); | 1334 | int dayOfYear = date.dayOfYear(); |
1336 | if (dayOfYear % 7 != 0) | 1335 | if (dayOfYear % 7 != 0) |
1337 | wno = dayOfYear / 7 + 1; | 1336 | wno = dayOfYear / 7 + 1; |
1338 | else | 1337 | else |
1339 | wno =dayOfYear / 7; | 1338 | wno =dayOfYear / 7; |
1340 | (*weekLabels)[i]->setWeekNum( wno ); | 1339 | (*weekLabels)[i]->setWeekNum( wno ); |
1341 | date = date.addDays( 7 ); | 1340 | date = date.addDays( 7 ); |
1342 | } | 1341 | } |
1343 | updateView(); | 1342 | updateView(); |
1344 | } | 1343 | } |
1345 | 1344 | ||
1346 | void KOMonthView::showEvents(QPtrList<Event>) | 1345 | void KOMonthView::showEvents(QPtrList<Event>) |
1347 | { | 1346 | { |
1348 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1347 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1349 | } | 1348 | } |
1350 | 1349 | ||
1351 | void KOMonthView::changeEventDisplay(Event *, int) | 1350 | void KOMonthView::changeEventDisplay(Event *, int) |
1352 | { | 1351 | { |
1353 | // this should be re-written to be much more efficient, but this | 1352 | // this should be re-written to be much more efficient, but this |
1354 | // quick-and-dirty-hack gets the job done for right now. | 1353 | // quick-and-dirty-hack gets the job done for right now. |
1355 | updateView(); | 1354 | updateView(); |
1356 | } | 1355 | } |
1357 | 1356 | ||
1358 | void KOMonthView::updateView() | 1357 | void KOMonthView::updateView() |
1359 | { | 1358 | { |
1360 | 1359 | ||
1361 | if ( !updatePossible ) | 1360 | if ( !updatePossible ) |
1362 | return; | 1361 | return; |
1363 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1362 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index a58f6b8..9e724c7 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h | |||
@@ -241,74 +241,74 @@ class KOMonthView: public KOEventView | |||
241 | bool isUpdatePossible() { return updatePossible; } | 241 | bool isUpdatePossible() { return updatePossible; } |
242 | 242 | ||
243 | MonthViewCell * selectedCell(); | 243 | MonthViewCell * selectedCell(); |
244 | bool skipResize; | 244 | bool skipResize; |
245 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} | 245 | NavigatorBar* navigatorBar() { return mNavigatorBar ;} |
246 | public slots: | 246 | public slots: |
247 | virtual void updateView(); | 247 | virtual void updateView(); |
248 | virtual void updateConfig(); | 248 | virtual void updateConfig(); |
249 | virtual void showDates(const QDate &start, const QDate &end); | 249 | virtual void showDates(const QDate &start, const QDate &end); |
250 | virtual void showEvents(QPtrList<Event> eventList); | 250 | virtual void showEvents(QPtrList<Event> eventList); |
251 | 251 | ||
252 | void changeEventDisplay(Event *, int); | 252 | void changeEventDisplay(Event *, int); |
253 | 253 | ||
254 | void clearSelection(); | 254 | void clearSelection(); |
255 | 255 | ||
256 | void showContextMenu( Incidence * ); | 256 | void showContextMenu( Incidence * ); |
257 | 257 | ||
258 | void setSelectedCell( MonthViewCell * ); | 258 | void setSelectedCell( MonthViewCell * ); |
259 | void switchView(); | 259 | void switchView(); |
260 | 260 | ||
261 | protected slots: | 261 | protected slots: |
262 | void slotComputeLayout(); | 262 | void slotComputeLayout(); |
263 | void selectInternalWeekNum ( int ); | 263 | void selectInternalWeekNum ( int ); |
264 | void processSelectionChange(); | 264 | void processSelectionChange(); |
265 | signals: | 265 | signals: |
266 | void nextMonth(); | 266 | void nextMonth(); |
267 | void prevMonth(); | 267 | void prevMonth(); |
268 | void selectWeekNum ( int ); | 268 | void selectWeekNum ( int ); |
269 | void selectMonth (); | 269 | void selectMonth (); |
270 | void showDaySignal( QDate ); | 270 | void showDaySignal( QDate ); |
271 | protected: | 271 | protected: |
272 | void resizeEvent(QResizeEvent *); | 272 | void resizeEvent(QResizeEvent *); |
273 | void viewChanged(); | 273 | void viewChanged(); |
274 | void updateDayLabels(); | 274 | void updateDayLabels(); |
275 | 275 | ||
276 | private: | 276 | private: |
277 | QTimer* mComputeLayoutTimer; | 277 | QTimer* mComputeLayoutTimer; |
278 | NavigatorBar* mNavigatorBar; | 278 | NavigatorBar* mNavigatorBar; |
279 | int currentWeek(); | 279 | int currentWeek(); |
280 | bool clPending; | 280 | bool clPending; |
281 | QWidgetStack * mWidStack; | 281 | QWidgetStack * mWidStack; |
282 | QWidget* mMonthView; | 282 | QWidget* mMonthView; |
283 | QWidget* mWeekView; | 283 | QWidget* mWeekView; |
284 | bool mShowWeekView; | 284 | bool mShowWeekView; |
285 | bool updatePossible; | 285 | bool updatePossible; |
286 | int mDaysPerWeek; | 286 | int mDaysPerWeek; |
287 | int mNumWeeks; | 287 | int mNumWeeks; |
288 | int mNumCells; | 288 | int mNumCells; |
289 | bool mWeekStartsMonday; | 289 | //bool mWeekStartsMonday; |
290 | bool mShowSatSunComp; | 290 | bool mShowSatSunComp; |
291 | void computeLayout(); | 291 | void computeLayout(); |
292 | void computeLayoutWeek(); | 292 | void computeLayoutWeek(); |
293 | 293 | ||
294 | QPtrVector<MonthViewCell> mCells; | 294 | QPtrVector<MonthViewCell> mCells; |
295 | QPtrVector<QLabel> mDayLabels; | 295 | QPtrVector<QLabel> mDayLabels; |
296 | QPtrVector<KOWeekButton> mWeekLabels; | 296 | QPtrVector<KOWeekButton> mWeekLabels; |
297 | QPtrVector<MonthViewCell> mCellsW; | 297 | QPtrVector<MonthViewCell> mCellsW; |
298 | QPtrVector<QLabel> mDayLabelsW; | 298 | QPtrVector<QLabel> mDayLabelsW; |
299 | QPtrVector<KOWeekButton> mWeekLabelsW; | 299 | QPtrVector<KOWeekButton> mWeekLabelsW; |
300 | 300 | ||
301 | bool mShortDayLabelsM; | 301 | bool mShortDayLabelsM; |
302 | bool mShortDayLabelsW; | 302 | bool mShortDayLabelsW; |
303 | int mWidthLongDayLabel; | 303 | int mWidthLongDayLabel; |
304 | 304 | ||
305 | QDate mStartDate; | 305 | QDate mStartDate; |
306 | 306 | ||
307 | MonthViewCell *mSelectedCell; | 307 | MonthViewCell *mSelectedCell; |
308 | 308 | ||
309 | KOEventPopupMenu *mContextMenu; | 309 | KOEventPopupMenu *mContextMenu; |
310 | void keyPressEvent ( QKeyEvent * ) ; | 310 | void keyPressEvent ( QKeyEvent * ) ; |
311 | 311 | ||
312 | }; | 312 | }; |
313 | 313 | ||
314 | #endif | 314 | #endif |
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 2da592b..8e52968 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -1433,123 +1433,101 @@ void MainWindow::keyBindings() | |||
1433 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + | 1433 | i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + |
1434 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + | 1434 | i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + |
1435 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ | 1435 | i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ |
1436 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ | 1436 | i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ |
1437 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ | 1437 | i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ |
1438 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ | 1438 | i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ |
1439 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ | 1439 | i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ |
1440 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + | 1440 | i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + |
1441 | i18n("<p><b>White</b>: Item readonly</p>\n"); | 1441 | i18n("<p><b>White</b>: Item readonly</p>\n"); |
1442 | displayText( text, cap); | 1442 | displayText( text, cap); |
1443 | } | 1443 | } |
1444 | void MainWindow::aboutAutoSaving() | 1444 | void MainWindow::aboutAutoSaving() |
1445 | { | 1445 | { |
1446 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); | 1446 | QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); |
1447 | 1447 | ||
1448 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); | 1448 | KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); |
1449 | 1449 | ||
1450 | } | 1450 | } |
1451 | void MainWindow::aboutKnownBugs() | 1451 | void MainWindow::aboutKnownBugs() |
1452 | { | 1452 | { |
1453 | QMessageBox* msg; | 1453 | QMessageBox* msg; |
1454 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), | 1454 | msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), |
1455 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ | 1455 | i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ |
1456 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ | 1456 | i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ |
1457 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + | 1457 | i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.info\n") + |
1458 | i18n("\nor report them in the bugtracker on\n") + | 1458 | i18n("\nor report them in the bugtracker on\n") + |
1459 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), | 1459 | i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), |
1460 | QMessageBox::NoIcon, | 1460 | QMessageBox::NoIcon, |
1461 | QMessageBox::Ok, | 1461 | QMessageBox::Ok, |
1462 | QMessageBox::NoButton, | 1462 | QMessageBox::NoButton, |
1463 | QMessageBox::NoButton); | 1463 | QMessageBox::NoButton); |
1464 | msg->exec(); | 1464 | msg->exec(); |
1465 | delete msg; | 1465 | delete msg; |
1466 | 1466 | ||
1467 | } | 1467 | } |
1468 | 1468 | ||
1469 | QString MainWindow::defaultFileName() | 1469 | QString MainWindow::defaultFileName() |
1470 | { | 1470 | { |
1471 | return locateLocal( "data", "korganizer/mycalendar.ics" ); | 1471 | return locateLocal( "data", "korganizer/mycalendar.ics" ); |
1472 | } | 1472 | } |
1473 | QString MainWindow::syncFileName() | 1473 | QString MainWindow::syncFileName() |
1474 | { | 1474 | { |
1475 | #ifdef DESKTOP_VERSION | 1475 | #ifdef DESKTOP_VERSION |
1476 | return locateLocal( "tmp", "synccalendar.ics" ); | 1476 | return locateLocal( "tmp", "synccalendar.ics" ); |
1477 | #else | 1477 | #else |
1478 | return QString( "/tmp/synccalendar.ics" ); | 1478 | return QString( "/tmp/synccalendar.ics" ); |
1479 | #endif | 1479 | #endif |
1480 | } | 1480 | } |
1481 | #include "koglobals.h" | ||
1482 | #include <kcalendarsystem.h> | ||
1481 | void MainWindow::updateWeek(QDate seda) | 1483 | void MainWindow::updateWeek(QDate seda) |
1482 | { | 1484 | { |
1483 | int weekNum = 0; | 1485 | int weekNum = KGlobal::locale()->weekNum ( seda ); |
1484 | QDate d = QDate ( seda.year(), 1,1); | ||
1485 | seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday | ||
1486 | if ( seda.addDays(6).year() != seda.year() ) { | ||
1487 | if ( seda.year() != d.year() ) { | ||
1488 | if ( d.dayOfWeek() > 4 ) | ||
1489 | d = QDate ( seda.year(), 1,1); | ||
1490 | else | ||
1491 | weekNum = 1; | ||
1492 | } else { | ||
1493 | QDate dd( seda.year()+1, 1,1); | ||
1494 | if ( dd.dayOfWeek() <= 4 ) | ||
1495 | weekNum = 1; | ||
1496 | } | ||
1497 | } | ||
1498 | if ( weekNum == 0 ){ | ||
1499 | int dow = d.dayOfWeek(); | ||
1500 | if ( dow <= 4 ) | ||
1501 | d = d.addDays( 1-dow ); | ||
1502 | else // 5,6,7 | ||
1503 | d = d.addDays( 8-dow ); | ||
1504 | // we have the first week of the year.we are on monday | ||
1505 | weekNum = d.daysTo( seda ) / 7 +1; | ||
1506 | } | ||
1507 | |||
1508 | mWeekPixmap.fill( mWeekBgColor ); | 1486 | mWeekPixmap.fill( mWeekBgColor ); |
1509 | QPainter p ( &mWeekPixmap ); | 1487 | QPainter p ( &mWeekPixmap ); |
1510 | p.setFont( mWeekFont ); | 1488 | p.setFont( mWeekFont ); |
1511 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); | 1489 | p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); |
1512 | p.end(); | 1490 | p.end(); |
1513 | QIconSet icon3 ( mWeekPixmap ); | 1491 | QIconSet icon3 ( mWeekPixmap ); |
1514 | mWeekAction->setIconSet ( icon3 ); | 1492 | mWeekAction->setIconSet ( icon3 ); |
1515 | 1493 | ||
1516 | } | 1494 | } |
1517 | void MainWindow::updateWeekNum(const DateList &selectedDates) | 1495 | void MainWindow::updateWeekNum(const DateList &selectedDates) |
1518 | { | 1496 | { |
1519 | updateWeek( selectedDates.first() ); | 1497 | updateWeek( selectedDates.first() ); |
1520 | } | 1498 | } |
1521 | void MainWindow::processIncidenceSelection( Incidence *incidence ) | 1499 | void MainWindow::processIncidenceSelection( Incidence *incidence ) |
1522 | { | 1500 | { |
1523 | 1501 | ||
1524 | if ( !incidence ) { | 1502 | if ( !incidence ) { |
1525 | enableIncidenceActions( false ); | 1503 | enableIncidenceActions( false ); |
1526 | 1504 | ||
1527 | mNewSubTodoAction->setEnabled( false ); | 1505 | mNewSubTodoAction->setEnabled( false ); |
1528 | setCaptionToDates(); | 1506 | setCaptionToDates(); |
1529 | return; | 1507 | return; |
1530 | 1508 | ||
1531 | } | 1509 | } |
1532 | 1510 | ||
1533 | //KGlobal::locale()->formatDateTime(nextA, true); | 1511 | //KGlobal::locale()->formatDateTime(nextA, true); |
1534 | QString startString = ""; | 1512 | QString startString = ""; |
1535 | if ( incidence->type() != "Todo" ) { | 1513 | if ( incidence->type() != "Todo" ) { |
1536 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { | 1514 | if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { |
1537 | if ( incidence->doesFloat() ) { | 1515 | if ( incidence->doesFloat() ) { |
1538 | startString += ": "+incidence->dtStartDateStr( true ); | 1516 | startString += ": "+incidence->dtStartDateStr( true ); |
1539 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); | 1517 | startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); |
1540 | 1518 | ||
1541 | } else { | 1519 | } else { |
1542 | startString = ": "+incidence->dtStartStr(true); | 1520 | startString = ": "+incidence->dtStartStr(true); |
1543 | startString += " --- "+((Event*)incidence)->dtEndStr(true); | 1521 | startString += " --- "+((Event*)incidence)->dtEndStr(true); |
1544 | 1522 | ||
1545 | } | 1523 | } |
1546 | 1524 | ||
1547 | } else { | 1525 | } else { |
1548 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) | 1526 | if ( incidence->dtStart().time() != incidence->dtEnd().time() ) |
1549 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ | 1527 | startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ |
1550 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); | 1528 | "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); |
1551 | if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { | 1529 | if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { |
1552 | bool ok; | 1530 | bool ok; |
1553 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); | 1531 | QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); |
1554 | if ( ok ) { | 1532 | if ( ok ) { |
1555 | int years = noc.date().year() - incidence->dtStart().date().year(); | 1533 | int years = noc.date().year() - incidence->dtStart().date().year(); |