-rw-r--r-- | korganizer/komonthview.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index b9ce4f4..ab9a4b6 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -892,97 +892,101 @@ QDate MonthViewCell::selectedIncidenceDate() | |||
892 | void MonthViewCell::deselect() | 892 | void MonthViewCell::deselect() |
893 | { | 893 | { |
894 | clearSelection(); | 894 | clearSelection(); |
895 | enableScrollBars( false ); | 895 | enableScrollBars( false ); |
896 | // updateCell(); | 896 | // updateCell(); |
897 | } | 897 | } |
898 | void MonthViewCell::select() | 898 | void MonthViewCell::select() |
899 | { | 899 | { |
900 | ;// updateCell(); | 900 | ;// updateCell(); |
901 | } | 901 | } |
902 | 902 | ||
903 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 903 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
904 | { | 904 | { |
905 | if ( !mMonthView->isUpdatePossible() ) | 905 | if ( !mMonthView->isUpdatePossible() ) |
906 | return; | 906 | return; |
907 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 907 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
908 | deselect(); | 908 | deselect(); |
909 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 909 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
910 | 910 | ||
911 | QString text; | 911 | QString text; |
912 | mLabel->setText( text ); | 912 | mLabel->setText( text ); |
913 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 913 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
914 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 914 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
915 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 915 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
916 | mLabel->resize( mLabelBigSize ); | 916 | mLabel->resize( mLabelBigSize ); |
917 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 917 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
918 | } else { | 918 | } else { |
919 | mLabel->resize( mLabelSize ); | 919 | mLabel->resize( mLabelSize ); |
920 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 920 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
921 | } | 921 | } |
922 | mLabel->setText( text ); | 922 | mLabel->setText( text ); |
923 | 923 | ||
924 | int size = height() - mLabel->height() - lineWidth()-1; | 924 | int size = height() - mLabel->height() - lineWidth()-1; |
925 | //qDebug("LW %d ", lineWidth()); | 925 | //qDebug("LW %d ", lineWidth()); |
926 | if ( size > 0 ) | 926 | if ( size > 0 ) |
927 | verticalScrollBar()->setMaximumHeight( size ); | 927 | verticalScrollBar()->setMaximumHeight( size ); |
928 | size = width() - mLabel->width() -lineWidth()-1; | 928 | size = width() - mLabel->width() -lineWidth()-1; |
929 | if ( size > 0 ) | 929 | if ( size > 0 ) |
930 | horizontalScrollBar()->setMaximumWidth( size ); | 930 | horizontalScrollBar()->setMaximumWidth( size ); |
931 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 931 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
932 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 932 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
933 | // mItemList->resize ( width(), height () ); | 933 | // mItemList->resize ( width(), height () ); |
934 | if ( e ) | 934 | if ( e ) |
935 | KNoScrollListBox::resizeEvent ( e ); | 935 | KNoScrollListBox::resizeEvent ( e ); |
936 | } | 936 | } |
937 | 937 | ||
938 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 938 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
939 | { | 939 | { |
940 | if ( !item ) return; | 940 | if ( !item ) { |
941 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | ||
942 | emit newEventSignal( dt ); | ||
943 | return; | ||
944 | } | ||
941 | 945 | ||
942 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 946 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
943 | Incidence *incidence = eventItem->incidence(); | 947 | Incidence *incidence = eventItem->incidence(); |
944 | if ( incidence ) mMonthView->defaultAction( incidence ); | 948 | if ( incidence ) mMonthView->defaultAction( incidence ); |
945 | } | 949 | } |
946 | void MonthViewCell::showDay() | 950 | void MonthViewCell::showDay() |
947 | { | 951 | { |
948 | emit showDaySignal( date() ); | 952 | emit showDaySignal( date() ); |
949 | } | 953 | } |
950 | void MonthViewCell::newEvent() | 954 | void MonthViewCell::newEvent() |
951 | { | 955 | { |
952 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 956 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
953 | emit newEventSignal( dt ); | 957 | emit newEventSignal( dt ); |
954 | } | 958 | } |
955 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 959 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
956 | { | 960 | { |
957 | static QListBoxItem * lastClicked = 0; | 961 | static QListBoxItem * lastClicked = 0; |
958 | if ( item == 0 ) { | 962 | if ( item == 0 ) { |
959 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 963 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
960 | emit newEventSignal( dt ); | 964 | emit newEventSignal( dt ); |
961 | return; | 965 | return; |
962 | } | 966 | } |
963 | /* | 967 | /* |
964 | if ( lastClicked ) | 968 | if ( lastClicked ) |
965 | if ( ! item ) { | 969 | if ( ! item ) { |
966 | if ( lastClicked->listBox() != item->listBox() ) | 970 | if ( lastClicked->listBox() != item->listBox() ) |
967 | lastClicked->listBox()->clearSelection(); | 971 | lastClicked->listBox()->clearSelection(); |
968 | } | 972 | } |
969 | */ | 973 | */ |
970 | 974 | ||
971 | mMonthView->setSelectedCell( this ); | 975 | mMonthView->setSelectedCell( this ); |
972 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 976 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
973 | select(); | 977 | select(); |
974 | } | 978 | } |
975 | 979 | ||
976 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 980 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
977 | { | 981 | { |
978 | if ( !item ) return; | 982 | if ( !item ) return; |
979 | 983 | ||
980 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 984 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
981 | Incidence *incidence = eventItem->incidence(); | 985 | Incidence *incidence = eventItem->incidence(); |
982 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 986 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
983 | } | 987 | } |
984 | 988 | ||
985 | void MonthViewCell::selection( QListBoxItem *item ) | 989 | void MonthViewCell::selection( QListBoxItem *item ) |
986 | { | 990 | { |
987 | if ( !item ) return; | 991 | if ( !item ) return; |
988 | 992 | ||
@@ -1326,96 +1330,97 @@ void KOMonthView::showDates(const QDate &start, const QDate &) | |||
1326 | 1330 | ||
1327 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1331 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1328 | mWeekStartsMonday = true; | 1332 | mWeekStartsMonday = true; |
1329 | } | 1333 | } |
1330 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1334 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1331 | 1335 | ||
1332 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1336 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1333 | mStartDate = mStartDate.addDays( -1 ); | 1337 | mStartDate = mStartDate.addDays( -1 ); |
1334 | } | 1338 | } |
1335 | bool primary = false; | 1339 | bool primary = false; |
1336 | uint i; | 1340 | uint i; |
1337 | for( i = 0; i < (*cells).size(); ++i ) { | 1341 | for( i = 0; i < (*cells).size(); ++i ) { |
1338 | QDate date = mStartDate.addDays( i ); | 1342 | QDate date = mStartDate.addDays( i ); |
1339 | (*cells)[i]->setDate( date ); | 1343 | (*cells)[i]->setDate( date ); |
1340 | 1344 | ||
1341 | #ifndef KORG_NOPLUGINS | 1345 | #ifndef KORG_NOPLUGINS |
1342 | // add holiday, if present | 1346 | // add holiday, if present |
1343 | QString hstring(KOCore::self()->holiday(date)); | 1347 | QString hstring(KOCore::self()->holiday(date)); |
1344 | (*cells)[i]->setHoliday( hstring ); | 1348 | (*cells)[i]->setHoliday( hstring ); |
1345 | #endif | 1349 | #endif |
1346 | 1350 | ||
1347 | } | 1351 | } |
1348 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1352 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1349 | for( i = 0; i < weekNum; ++i ) { | 1353 | for( i = 0; i < weekNum; ++i ) { |
1350 | int wno; | 1354 | int wno; |
1351 | // remember, according to ISO 8601, the first week of the year is the | 1355 | // remember, according to ISO 8601, the first week of the year is the |
1352 | // first week that contains a thursday. Thus we must subtract off 4, | 1356 | // first week that contains a thursday. Thus we must subtract off 4, |
1353 | // not just 1. | 1357 | // not just 1. |
1354 | int dayOfYear = date.dayOfYear(); | 1358 | int dayOfYear = date.dayOfYear(); |
1355 | if (dayOfYear % 7 != 0) | 1359 | if (dayOfYear % 7 != 0) |
1356 | wno = dayOfYear / 7 + 1; | 1360 | wno = dayOfYear / 7 + 1; |
1357 | else | 1361 | else |
1358 | wno =dayOfYear / 7; | 1362 | wno =dayOfYear / 7; |
1359 | (*weekLabels)[i]->setWeekNum( wno ); | 1363 | (*weekLabels)[i]->setWeekNum( wno ); |
1360 | date = date.addDays( 7 ); | 1364 | date = date.addDays( 7 ); |
1361 | } | 1365 | } |
1362 | updateView(); | 1366 | updateView(); |
1363 | } | 1367 | } |
1364 | 1368 | ||
1365 | void KOMonthView::showEvents(QPtrList<Event>) | 1369 | void KOMonthView::showEvents(QPtrList<Event>) |
1366 | { | 1370 | { |
1367 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1371 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1368 | } | 1372 | } |
1369 | 1373 | ||
1370 | void KOMonthView::changeEventDisplay(Event *, int) | 1374 | void KOMonthView::changeEventDisplay(Event *, int) |
1371 | { | 1375 | { |
1372 | // this should be re-written to be much more efficient, but this | 1376 | // this should be re-written to be much more efficient, but this |
1373 | // quick-and-dirty-hack gets the job done for right now. | 1377 | // quick-and-dirty-hack gets the job done for right now. |
1378 | qDebug("KOMonthView::changeEventDisplay "); | ||
1374 | updateView(); | 1379 | updateView(); |
1375 | } | 1380 | } |
1376 | 1381 | ||
1377 | void KOMonthView::updateView() | 1382 | void KOMonthView::updateView() |
1378 | { | 1383 | { |
1379 | 1384 | ||
1380 | if ( !updatePossible ) | 1385 | if ( !updatePossible ) |
1381 | return; | 1386 | return; |
1382 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1387 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1383 | //QTime ti; | 1388 | //QTime ti; |
1384 | //ti.start(); | 1389 | //ti.start(); |
1385 | clearSelection(); | 1390 | clearSelection(); |
1386 | QPtrVector<MonthViewCell> *cells; | 1391 | QPtrVector<MonthViewCell> *cells; |
1387 | if ( mShowWeekView ) { | 1392 | if ( mShowWeekView ) { |
1388 | cells = &mCellsW; | 1393 | cells = &mCellsW; |
1389 | } else { | 1394 | } else { |
1390 | cells = &mCells; | 1395 | cells = &mCells; |
1391 | } | 1396 | } |
1392 | #if 1 | 1397 | #if 1 |
1393 | int i; | 1398 | int i; |
1394 | int timeSpan = (*cells).size()-1; | 1399 | int timeSpan = (*cells).size()-1; |
1395 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1400 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1396 | timeSpan = 6; | 1401 | timeSpan = 6; |
1397 | for( i = 0; i < timeSpan + 1; ++i ) { | 1402 | for( i = 0; i < timeSpan + 1; ++i ) { |
1398 | (*cells)[i]->startUpdateCell(); | 1403 | (*cells)[i]->startUpdateCell(); |
1399 | } | 1404 | } |
1400 | 1405 | ||
1401 | QPtrList<Event> events = calendar()->events(); | 1406 | QPtrList<Event> events = calendar()->events(); |
1402 | Event *event; | 1407 | Event *event; |
1403 | QDateTime dt; | 1408 | QDateTime dt; |
1404 | bool ok; | 1409 | bool ok; |
1405 | QDate endDate = mStartDate.addDays( timeSpan ); | 1410 | QDate endDate = mStartDate.addDays( timeSpan ); |
1406 | for( event = events.first(); event; event = events.next() ) { // for event | 1411 | for( event = events.first(); event; event = events.next() ) { // for event |
1407 | if ( event->doesRecur() ) { | 1412 | if ( event->doesRecur() ) { |
1408 | bool last; | 1413 | bool last; |
1409 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1414 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1410 | QDateTime incidenceEnd; | 1415 | QDateTime incidenceEnd; |
1411 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1416 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1412 | bool invalid = false; | 1417 | bool invalid = false; |
1413 | while( true ) { | 1418 | while( true ) { |
1414 | if ( incidenceStart.isValid() ) { | 1419 | if ( incidenceStart.isValid() ) { |
1415 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1420 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1416 | int st = incidenceStart.date().daysTo( endDate ); | 1421 | int st = incidenceStart.date().daysTo( endDate ); |
1417 | if ( st >= 0 ) { // start before timeend | 1422 | if ( st >= 0 ) { // start before timeend |
1418 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1423 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1419 | if ( end >= 0 ) { // end after timestart --- got one! | 1424 | if ( end >= 0 ) { // end after timestart --- got one! |
1420 | //normalize | 1425 | //normalize |
1421 | st = timeSpan - st; | 1426 | st = timeSpan - st; |