summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-29 22:27:13 (UTC)
committer zautrix <zautrix>2004-10-29 22:27:13 (UTC)
commitaafa695508796e86e9f267633ea5e6965d876031 (patch) (unidiff)
tree8ff03f51e99f7e90b85e8f94af157a883bcd48f8 /korganizer
parent8e08679a79398def54980c0e838b242d69ca6030 (diff)
downloadkdepimpi-aafa695508796e86e9f267633ea5e6965d876031.zip
kdepimpi-aafa695508796e86e9f267633ea5e6965d876031.tar.gz
kdepimpi-aafa695508796e86e9f267633ea5e6965d876031.tar.bz2
monthview exclude sat fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp19
-rw-r--r--korganizer/komonthview.cpp2
2 files changed, 17 insertions, 4 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 749204b..c5acafd 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -801,643 +801,656 @@ void KOAgendaView::updateView()
801/* 801/*
802 Update configuration settings for the agenda view. This method is not 802 Update configuration settings for the agenda view. This method is not
803 complete. 803 complete.
804*/ 804*/
805void KOAgendaView::updateConfig() 805void KOAgendaView::updateConfig()
806{ 806{
807 if ( mBlockUpdating ) 807 if ( mBlockUpdating )
808 return; 808 return;
809 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 809 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
810 810
811 // update config for children 811 // update config for children
812 mTimeLabels->updateConfig(); 812 mTimeLabels->updateConfig();
813 mAgenda->storePosition(); 813 mAgenda->storePosition();
814 mAgenda->updateConfig(); 814 mAgenda->updateConfig();
815 mAllDayAgenda->updateConfig(); 815 mAllDayAgenda->updateConfig();
816 // widget synchronization 816 // widget synchronization
817 //TODO: find a better way, maybe signal/slot 817 //TODO: find a better way, maybe signal/slot
818 mTimeLabels->positionChanged(); 818 mTimeLabels->positionChanged();
819 819
820 // for some reason, this needs to be called explicitly 820 // for some reason, this needs to be called explicitly
821 mTimeLabels->repaint(); 821 mTimeLabels->repaint();
822 822
823 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 823 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
824 824
825 // ToolTips displaying summary of events 825 // ToolTips displaying summary of events
826 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 826 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
827 ->mEnableToolTips); 827 ->mEnableToolTips);
828 828
829 //setHolidayMasks(); 829 //setHolidayMasks();
830 830
831 //createDayLabels(); called by via updateView(); 831 //createDayLabels(); called by via updateView();
832 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 832 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
833 updateView(); 833 updateView();
834 mAgenda->restorePosition(); 834 mAgenda->restorePosition();
835} 835}
836 836
837 837
838void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 838void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
839{ 839{
840 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 840 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
841 //qDebug("KOAgendaView::updateEventDates "); 841 //qDebug("KOAgendaView::updateEventDates ");
842 QDateTime startDt,endDt; 842 QDateTime startDt,endDt;
843 QDate startDate; 843 QDate startDate;
844 int lenInSecs; 844 int lenInSecs;
845 // if ( type == KOAgenda::RESIZETOP ) 845 // if ( type == KOAgenda::RESIZETOP )
846 // qDebug("RESIZETOP "); 846 // qDebug("RESIZETOP ");
847 // if ( type == KOAgenda::RESIZEBOTTOM ) 847 // if ( type == KOAgenda::RESIZEBOTTOM )
848 // qDebug("RESIZEBOTTOM "); 848 // qDebug("RESIZEBOTTOM ");
849 // if ( type == KOAgenda::MOVE ) 849 // if ( type == KOAgenda::MOVE )
850 // qDebug("MOVE "); 850 // qDebug("MOVE ");
851 if ( item->incidence()->type() == "Event" ) { 851 if ( item->incidence()->type() == "Event" ) {
852 startDt =item->incidence()->dtStart(); 852 startDt =item->incidence()->dtStart();
853 endDt = item->incidence()->dtEnd(); 853 endDt = item->incidence()->dtEnd();
854 lenInSecs = startDt.secsTo( endDt ); 854 lenInSecs = startDt.secsTo( endDt );
855 } 855 }
856 856
857 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 857 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
858 858
859 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 859 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
860 startDate = mSelectedDates[item->mLastMoveXPos]; 860 startDate = mSelectedDates[item->mLastMoveXPos];
861 } else { 861 } else {
862 if (item->cellX() < 0) { 862 if (item->cellX() < 0) {
863 startDate = (mSelectedDates.first()).addDays(item->cellX()); 863 startDate = (mSelectedDates.first()).addDays(item->cellX());
864 } else { 864 } else {
865 startDate = mSelectedDates[item->cellX()]; 865 startDate = mSelectedDates[item->cellX()];
866 } 866 }
867 } 867 }
868 startDt.setDate(startDate); 868 startDt.setDate(startDate);
869 869
870 if (item->incidence()->doesFloat()) { 870 if (item->incidence()->doesFloat()) {
871 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 871 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
872 } else { 872 } else {
873 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 873 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
874 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 874 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
875 if ( item->incidence()->type() == "Event" ) { 875 if ( item->incidence()->type() == "Event" ) {
876 if ( type == KOAgenda::MOVE ) { 876 if ( type == KOAgenda::MOVE ) {
877 endDt = startDt.addSecs(lenInSecs); 877 endDt = startDt.addSecs(lenInSecs);
878 878
879 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 879 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
880 if (item->lastMultiItem()) { 880 if (item->lastMultiItem()) {
881 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 881 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
882 endDt.setDate(startDate. 882 endDt.setDate(startDate.
883 addDays(item->lastMultiItem()->cellX() - item->cellX())); 883 addDays(item->lastMultiItem()->cellX() - item->cellX()));
884 } else { 884 } else {
885 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 885 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
886 endDt.setDate(startDate); 886 endDt.setDate(startDate);
887 } 887 }
888 } 888 }
889 } else { 889 } else {
890 // todo 890 // todo
891 if (item->lastMultiItem()) { 891 if (item->lastMultiItem()) {
892 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 892 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
893 endDt.setDate(startDate. 893 endDt.setDate(startDate.
894 addDays(item->lastMultiItem()->cellX() - item->cellX())); 894 addDays(item->lastMultiItem()->cellX() - item->cellX()));
895 } else { 895 } else {
896 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 896 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
897 if ( item->cellYBottom() > 0 ) 897 if ( item->cellYBottom() > 0 )
898 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 898 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
899 else 899 else
900 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 900 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
901 endDt.setDate(startDate); 901 endDt.setDate(startDate);
902 } 902 }
903 } 903 }
904 } 904 }
905 905
906 906
907 if ( item->incidence()->type() == "Event" ) { 907 if ( item->incidence()->type() == "Event" ) {
908 item->incidence()->setDtStart(startDt); 908 item->incidence()->setDtStart(startDt);
909 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 909 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
910 } else if ( item->incidence()->type() == "Todo" ) { 910 } else if ( item->incidence()->type() == "Todo" ) {
911 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 911 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
912 } 912 }
913 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 913 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
914 item->incidence()->setRevision(item->incidence()->revision()+1); 914 item->incidence()->setRevision(item->incidence()->revision()+1);
915 item->setItemDate(startDt.date()); 915 item->setItemDate(startDt.date());
916 //item->updateItem(); 916 //item->updateItem();
917 if ( item->incidence()->type() == "Todo" ) { 917 if ( item->incidence()->type() == "Todo" ) {
918 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 918 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
919 919
920 } 920 }
921 else 921 else
922 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 922 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
923 item->updateItem(); 923 item->updateItem();
924} 924}
925 925
926void KOAgendaView::showDates( const QDate &start, const QDate &end ) 926void KOAgendaView::showDates( const QDate &start, const QDate &end )
927{ 927{
928 // kdDebug() << "KOAgendaView::selectDates" << endl; 928 // kdDebug() << "KOAgendaView::selectDates" << endl;
929 929
930 mSelectedDates.clear(); 930 mSelectedDates.clear();
931 // qDebug("KOAgendaView::showDates "); 931 // qDebug("KOAgendaView::showDates ");
932 QDate d = start; 932 QDate d = start;
933 while (d <= end) { 933 while (d <= end) {
934 mSelectedDates.append(d); 934 mSelectedDates.append(d);
935 d = d.addDays( 1 ); 935 d = d.addDays( 1 );
936 } 936 }
937 937
938 // and update the view 938 // and update the view
939 fillAgenda(); 939 fillAgenda();
940} 940}
941 941
942 942
943void KOAgendaView::showEvents(QPtrList<Event>) 943void KOAgendaView::showEvents(QPtrList<Event>)
944{ 944{
945 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 945 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
946} 946}
947 947
948void KOAgendaView::changeEventDisplay(Event *, int) 948void KOAgendaView::changeEventDisplay(Event *, int)
949{ 949{
950 // qDebug("KOAgendaView::changeEventDisplay "); 950 // qDebug("KOAgendaView::changeEventDisplay ");
951 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 951 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
952 // this should be re-written to be MUCH smarter. Right now we 952 // this should be re-written to be MUCH smarter. Right now we
953 // are just playing dumb. 953 // are just playing dumb.
954 fillAgenda(); 954 fillAgenda();
955} 955}
956 956
957void KOAgendaView::fillAgenda(const QDate &) 957void KOAgendaView::fillAgenda(const QDate &)
958{ 958{
959 // qDebug("KOAgendaView::fillAgenda "); 959 // qDebug("KOAgendaView::fillAgenda ");
960 fillAgenda(); 960 fillAgenda();
961} 961}
962 962
963void KOAgendaView::fillAgenda() 963void KOAgendaView::fillAgenda()
964{ 964{
965 if ( globalFlagBlockStartup ) 965 if ( globalFlagBlockStartup )
966 return; 966 return;
967 if ( globalFlagBlockAgenda == 1 ) 967 if ( globalFlagBlockAgenda == 1 )
968 return; 968 return;
969 //if ( globalFlagBlockAgenda == 2 ) 969 //if ( globalFlagBlockAgenda == 2 )
970 //globalFlagBlockAgenda = 0; 970 //globalFlagBlockAgenda = 0;
971 // globalFlagBlockPainting = false; 971 // globalFlagBlockPainting = false;
972 if ( globalFlagBlockAgenda == 0 ) 972 if ( globalFlagBlockAgenda == 0 )
973 globalFlagBlockAgenda = 1; 973 globalFlagBlockAgenda = 1;
974 // clearView(); 974 // clearView();
975 //qDebug("fillAgenda()++++ "); 975 //qDebug("fillAgenda()++++ ");
976 globalFlagBlockAgendaItemPaint = 1; 976 globalFlagBlockAgendaItemPaint = 1;
977 mAllDayAgenda->changeColumns(mSelectedDates.count()); 977 mAllDayAgenda->changeColumns(mSelectedDates.count());
978 mAgenda->changeColumns(mSelectedDates.count()); 978 mAgenda->changeColumns(mSelectedDates.count());
979 qApp->processEvents(); 979 qApp->processEvents();
980 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 980 mEventIndicatorTop->changeColumns(mSelectedDates.count());
981 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 981 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
982 setHolidayMasks(); 982 setHolidayMasks();
983 983
984 //mAgenda->hideUnused(); 984 //mAgenda->hideUnused();
985 //mAllDayAgenda->hideUnused(); 985 //mAllDayAgenda->hideUnused();
986 986
987 // mAgenda->blockNextRepaint( false ); 987 // mAgenda->blockNextRepaint( false );
988 // mAgenda->viewport()->repaint(); 988 // mAgenda->viewport()->repaint();
989 // mAgenda->blockNextRepaint( true ); 989 // mAgenda->blockNextRepaint( true );
990 mMinY.resize(mSelectedDates.count()); 990 mMinY.resize(mSelectedDates.count());
991 mMaxY.resize(mSelectedDates.count()); 991 mMaxY.resize(mSelectedDates.count());
992 992
993 QPtrList<Event> dayEvents; 993 QPtrList<Event> dayEvents;
994 994
995 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 995 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
996 // Therefore, get all of them. 996 // Therefore, get all of them.
997 QPtrList<Todo> todos = calendar()->todos(); 997 QPtrList<Todo> todos = calendar()->todos();
998 998
999 mAgenda->setDateList(mSelectedDates); 999 mAgenda->setDateList(mSelectedDates);
1000 1000
1001 QDate today = QDate::currentDate(); 1001 QDate today = QDate::currentDate();
1002 1002
1003 DateList::ConstIterator dit; 1003 DateList::ConstIterator dit;
1004 int curCol = 0; 1004 int curCol = 0;
1005 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1005 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1006 QDate currentDate = *dit; 1006 QDate currentDate = *dit;
1007 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1007 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1008 // << endl; 1008 // << endl;
1009 1009
1010 dayEvents = calendar()->events(currentDate,true); 1010 dayEvents = calendar()->events(currentDate,true);
1011 1011
1012 // Default values, which can never be reached 1012 // Default values, which can never be reached
1013 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1013 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1014 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1014 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1015 1015
1016 unsigned int numEvent; 1016 unsigned int numEvent;
1017 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1017 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1018 Event *event = dayEvents.at(numEvent); 1018 Event *event = dayEvents.at(numEvent);
1019 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1019 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1020 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1020 if ( event->uid().left(15) == QString("last-syncEvent-") )
1021 continue; 1021 continue;
1022 // kdDebug() << " Event: " << event->summary() << endl; 1022 // kdDebug() << " Event: " << event->summary() << endl;
1023 1023
1024 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1024 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1025 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1025 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1026 1026
1027 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1027 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1028 1028
1029 if (event->doesFloat()) { 1029 if (event->doesFloat()) {
1030 if (event->recurrence()->doesRecur()) { 1030 if (event->recurrence()->doesRecur()) {
1031 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1031 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1032 } else { 1032 } else {
1033 if (beginX <= 0 && curCol == 0) { 1033 if (beginX <= 0 && curCol == 0) {
1034 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1034 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1035 } else if (beginX == curCol) { 1035 } else if (beginX == curCol) {
1036 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1036 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1037 } 1037 }
1038 } 1038 }
1039 } else if (event->isMultiDay()) { 1039 } else if (event->isMultiDay()) {
1040 if ( event->doesRecur () ) { 1040 if ( event->doesRecur () ) {
1041 QDate dateit = currentDate; 1041 QDate dateit = currentDate;
1042 int count = 0; 1042 int count = 0;
1043 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1043 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1044 while (! event->recursOn( dateit ) && count <= max ) { 1044 while (! event->recursOn( dateit ) && count <= max ) {
1045 ++count; 1045 ++count;
1046 dateit = dateit.addDays( -1 ); 1046 dateit = dateit.addDays( -1 );
1047 } 1047 }
1048 bool ok; 1048 bool ok;
1049 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1049 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1050 if ( ok ) 1050 if ( ok )
1051 { 1051 {
1052 int secs = event->dtStart().secsTo( event->dtEnd() ); 1052 int secs = event->dtStart().secsTo( event->dtEnd() );
1053 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1053 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1054 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1054 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1055 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1055 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1056 1056
1057 } 1057 }
1058 } 1058 }
1059 int startY = mAgenda->timeToY(event->dtStart().time()); 1059 int startY = mAgenda->timeToY(event->dtStart().time());
1060 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1060 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1061 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1061 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1062 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1062 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1063 //qDebug("insert!!! "); 1063 //qDebug("insert!!! ");
1064 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1064 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1065 } 1065 }
1066 if (beginX == curCol) { 1066 if (beginX == curCol) {
1067 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1067 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1068 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1068 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1069 } else if (endX == curCol) { 1069 } else if (endX == curCol) {
1070 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1070 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1071 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1071 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1072 } else { 1072 } else {
1073 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1073 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1074 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1074 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1075 } 1075 }
1076 } else { 1076 } else {
1077 int startY = mAgenda->timeToY(event->dtStart().time()); 1077 int startY = mAgenda->timeToY(event->dtStart().time());
1078 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1078 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1079 if (endY < startY) endY = startY; 1079 if (endY < startY) endY = startY;
1080 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1080 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1081 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1081 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1082 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1082 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1083 } 1083 }
1084 } 1084 }
1085 // ---------- [display Todos -------------- 1085 // ---------- [display Todos --------------
1086 unsigned int numTodo; 1086 unsigned int numTodo;
1087 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1087 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1088 Todo *todo = todos.at(numTodo); 1088 Todo *todo = todos.at(numTodo);
1089 1089
1090 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date 1090 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date
1091 1091
1092 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1092 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1093 // Already completed items can be displayed on their original due date 1093 // Already completed items can be displayed on their original due date
1094 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1094 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1095 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1095 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1096 1096
1097 if ( ((todo->dtDue().date() == currentDate) && !overdue) || 1097 if ( ((todo->dtDue().date() == currentDate) && !overdue) ||
1098 ((currentDate == today) && overdue) ) { 1098 ((currentDate == today) && overdue) ) {
1099 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue 1099 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue
1100 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1100 if ( KOPrefs::instance()->mShowTodoInAgenda )
1101 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1101 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1102 } 1102 }
1103 else { 1103 else {
1104 1104
1105 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1; 1105 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1;
1106 int hi = (18/KOPrefs::instance()->mHourSize); 1106 int hi = (18/KOPrefs::instance()->mHourSize);
1107 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1107 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1108 int startY = endY -hi; 1108 int startY = endY -hi;
1109 1109
1110 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1110 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1111 1111
1112 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1112 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1113 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1113 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1114 } 1114 }
1115 } 1115 }
1116 } 1116 }
1117 // ---------- display Todos] -------------- 1117 // ---------- display Todos] --------------
1118 1118
1119 ++curCol; 1119 ++curCol;
1120 } 1120 }
1121 mAgenda->hideUnused(); 1121 mAgenda->hideUnused();
1122 mAllDayAgenda->hideUnused(); 1122 mAllDayAgenda->hideUnused();
1123 mAgenda->checkScrollBoundaries(); 1123 mAgenda->checkScrollBoundaries();
1124 1124
1125 deleteSelectedDateTime(); 1125 deleteSelectedDateTime();
1126 1126
1127 createDayLabels(); 1127 createDayLabels();
1128 emit incidenceSelected( 0 ); 1128 emit incidenceSelected( 0 );
1129 1129
1130 if ( globalFlagBlockAgenda == 2 ) { 1130 if ( globalFlagBlockAgenda == 2 ) {
1131 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1131 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1132 setStartHour( KOPrefs::instance()->mDayBegins ); 1132 setStartHour( KOPrefs::instance()->mDayBegins );
1133 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1133 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1134 setStartHour( QTime::currentTime ().hour() ); 1134 setStartHour( QTime::currentTime ().hour() );
1135 // qApp->processEvents(); 1135 // qApp->processEvents();
1136 } 1136 }
1137 qApp->processEvents(); 1137 qApp->processEvents();
1138 //qDebug("qApp->processEvents(); END "); 1138 //qDebug("qApp->processEvents(); END ");
1139 globalFlagBlockAgenda = 0; 1139 globalFlagBlockAgenda = 0;
1140 1140
1141 // mAgenda->hideUnused(); 1141 // mAgenda->hideUnused();
1142 //mAllDayAgenda->hideUnused(); 1142 //mAllDayAgenda->hideUnused();
1143 mAllDayAgenda->drawContentsToPainter(); 1143 mAllDayAgenda->drawContentsToPainter();
1144 mAgenda->drawContentsToPainter(); 1144 mAgenda->drawContentsToPainter();
1145 repaintAgenda(); 1145 repaintAgenda();
1146 // mAgenda->finishUpdate(); 1146 // mAgenda->finishUpdate();
1147 //mAllDayAgenda->finishUpdate(); 1147 //mAllDayAgenda->finishUpdate();
1148 1148
1149 // repaintAgenda(); 1149 // repaintAgenda();
1150 //qApp->processEvents(); 1150 //qApp->processEvents();
1151 // globalFlagBlockAgenda = 0; 1151 // globalFlagBlockAgenda = 0;
1152} 1152}
1153void KOAgendaView::repaintAgenda() 1153void KOAgendaView::repaintAgenda()
1154{ 1154{
1155 // mAllDayAgenda->drawContentsToPainter(); 1155 // mAllDayAgenda->drawContentsToPainter();
1156// mAllDayAgenda->viewport()->repaint( false ); 1156// mAllDayAgenda->viewport()->repaint( false );
1157// mAgenda->drawContentsToPainter(); 1157// mAgenda->drawContentsToPainter();
1158// mAgenda->viewport()->repaint( false ); 1158// mAgenda->viewport()->repaint( false );
1159// qApp->processEvents(); 1159// qApp->processEvents();
1160 1160
1161 //qDebug("KOAgendaView::repaintAgenda() "); 1161 //qDebug("KOAgendaView::repaintAgenda() ");
1162 //qApp->processEvents(); 1162 //qApp->processEvents();
1163 mAgenda->viewport()->repaint( false ); 1163 mAgenda->viewport()->repaint( false );
1164 mAllDayAgenda->viewport()->repaint( false ); 1164 mAllDayAgenda->viewport()->repaint( false );
1165 mAgenda->finishUpdate(); 1165 mAgenda->finishUpdate();
1166 mAllDayAgenda->finishUpdate(); 1166 mAllDayAgenda->finishUpdate();
1167} 1167}
1168 1168
1169 1169
1170void KOAgendaView::clearView() 1170void KOAgendaView::clearView()
1171{ 1171{
1172 // kdDebug() << "ClearView" << endl; 1172 // kdDebug() << "ClearView" << endl;
1173 mAllDayAgenda->clear(); 1173 mAllDayAgenda->clear();
1174 mAgenda->clear(); 1174 mAgenda->clear();
1175} 1175}
1176 1176
1177void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1177void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1178 const QDate &td) 1178 const QDate &td)
1179{ 1179{
1180#ifndef KORG_NOPRINTER 1180#ifndef KORG_NOPRINTER
1181 if (fd == td) 1181 if (fd == td)
1182 calPrinter->preview(CalPrinter::Day, fd, td); 1182 calPrinter->preview(CalPrinter::Day, fd, td);
1183 else 1183 else
1184 calPrinter->preview(CalPrinter::Week, fd, td); 1184 calPrinter->preview(CalPrinter::Week, fd, td);
1185#endif 1185#endif
1186} 1186}
1187 1187
1188// void KOAgendaView::updateMovedTodo() 1188// void KOAgendaView::updateMovedTodo()
1189// { 1189// {
1190// // updateConfig(); 1190// // updateConfig();
1191// // emit updateTodoViews(); 1191// // emit updateTodoViews();
1192// } 1192// }
1193 1193
1194void KOAgendaView::newEvent(int gx, int gy) 1194void KOAgendaView::newEvent(int gx, int gy)
1195{ 1195{
1196 if (!mSelectedDates.count()) return; 1196 if (!mSelectedDates.count()) return;
1197 1197
1198 QDate day = mSelectedDates[gx]; 1198 QDate day = mSelectedDates[gx];
1199 1199
1200 QTime time = mAgenda->gyToTime(gy); 1200 QTime time = mAgenda->gyToTime(gy);
1201 QDateTime dt(day,time); 1201 QDateTime dt(day,time);
1202 // if ( dt < QDateTime::currentDateTime () ) 1202 // if ( dt < QDateTime::currentDateTime () )
1203 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1203 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1204 emit newEventSignal(dt); 1204 emit newEventSignal(dt);
1205} 1205}
1206 1206
1207void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1207void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1208{ 1208{
1209 if (!mSelectedDates.count()) return; 1209 if (!mSelectedDates.count()) return;
1210 1210
1211 QDate dayStart = mSelectedDates[gxStart]; 1211 QDate dayStart = mSelectedDates[gxStart];
1212 QDate dayEnd = mSelectedDates[gxEnd]; 1212 QDate dayEnd = mSelectedDates[gxEnd];
1213 1213
1214 QTime timeStart = mAgenda->gyToTime(gyStart); 1214 QTime timeStart = mAgenda->gyToTime(gyStart);
1215 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1215 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1216 1216
1217 QDateTime dtStart(dayStart,timeStart); 1217 QDateTime dtStart(dayStart,timeStart);
1218 QDateTime dtEnd(dayEnd,timeEnd); 1218 QDateTime dtEnd(dayEnd,timeEnd);
1219 1219
1220 emit newEventSignal(dtStart,dtEnd); 1220 emit newEventSignal(dtStart,dtEnd);
1221} 1221}
1222 1222
1223void KOAgendaView::newEventAllDay(int gx, int ) 1223void KOAgendaView::newEventAllDay(int gx, int )
1224{ 1224{
1225 if (!mSelectedDates.count()) return; 1225 if (!mSelectedDates.count()) return;
1226 1226
1227 QDate day = mSelectedDates[gx]; 1227 QDate day = mSelectedDates[gx];
1228 1228
1229 emit newEventSignal(day); 1229 emit newEventSignal(day);
1230} 1230}
1231 1231
1232void KOAgendaView::updateEventIndicatorTop(int newY) 1232void KOAgendaView::updateEventIndicatorTop(int newY)
1233{ 1233{
1234 uint i; 1234 uint i;
1235 for(i=0;i<mMinY.size();++i) { 1235 for(i=0;i<mMinY.size();++i) {
1236 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1236 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1237 else mEventIndicatorTop->enableColumn(i,false); 1237 else mEventIndicatorTop->enableColumn(i,false);
1238 } 1238 }
1239 1239
1240 mEventIndicatorTop->update(); 1240 mEventIndicatorTop->update();
1241} 1241}
1242 1242
1243void KOAgendaView::updateEventIndicatorBottom(int newY) 1243void KOAgendaView::updateEventIndicatorBottom(int newY)
1244{ 1244{
1245 uint i; 1245 uint i;
1246 for(i=0;i<mMaxY.size();++i) { 1246 for(i=0;i<mMaxY.size();++i) {
1247 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1247 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1248 else mEventIndicatorBottom->enableColumn(i,false); 1248 else mEventIndicatorBottom->enableColumn(i,false);
1249 } 1249 }
1250 1250
1251 mEventIndicatorBottom->update(); 1251 mEventIndicatorBottom->update();
1252} 1252}
1253 1253
1254void KOAgendaView::startDrag(Event *event) 1254void KOAgendaView::startDrag(Event *event)
1255{ 1255{
1256#ifndef KORG_NODND 1256#ifndef KORG_NODND
1257 DndFactory factory( calendar() ); 1257 DndFactory factory( calendar() );
1258 ICalDrag *vd = factory.createDrag(event,this); 1258 ICalDrag *vd = factory.createDrag(event,this);
1259 if (vd->drag()) { 1259 if (vd->drag()) {
1260 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1260 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1261 } 1261 }
1262#endif 1262#endif
1263} 1263}
1264 1264
1265void KOAgendaView::readSettings() 1265void KOAgendaView::readSettings()
1266{ 1266{
1267 readSettings(KOGlobals::config()); 1267 readSettings(KOGlobals::config());
1268} 1268}
1269 1269
1270void KOAgendaView::readSettings(KConfig *config) 1270void KOAgendaView::readSettings(KConfig *config)
1271{ 1271{
1272 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1272 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1273 1273
1274 config->setGroup("Views"); 1274 config->setGroup("Views");
1275 1275
1276 //#ifndef KORG_NOSPLITTER 1276 //#ifndef KORG_NOSPLITTER
1277 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1277 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1278 if (sizes.count() == 2) { 1278 if (sizes.count() == 2) {
1279 if ( sizes[0] < 20 ) { 1279 if ( sizes[0] < 20 ) {
1280 sizes[1] = sizes[1] +20 - sizes[0]; 1280 sizes[1] = sizes[1] +20 - sizes[0];
1281 sizes[0] = 20; 1281 sizes[0] = 20;
1282 } 1282 }
1283 mSplitterAgenda->setSizes(sizes); 1283 mSplitterAgenda->setSizes(sizes);
1284 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1284 // qDebug("read %d %d ",sizes[0],sizes[1] );
1285 } 1285 }
1286 //#endif 1286 //#endif
1287 1287
1288 // updateConfig(); 1288 // updateConfig();
1289} 1289}
1290 1290
1291void KOAgendaView::writeSettings(KConfig *config) 1291void KOAgendaView::writeSettings(KConfig *config)
1292{ 1292{
1293 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1293 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1294 1294
1295 config->setGroup("Views"); 1295 config->setGroup("Views");
1296 1296
1297 //#ifndef KORG_NOSPLITTER 1297 //#ifndef KORG_NOSPLITTER
1298 QValueList<int> list = mSplitterAgenda->sizes(); 1298 QValueList<int> list = mSplitterAgenda->sizes();
1299 config->writeEntry("Separator AgendaView",list); 1299 config->writeEntry("Separator AgendaView",list);
1300 //qDebug("write %d %d ", list[0],list[1] ); 1300 //qDebug("write %d %d ", list[0],list[1] );
1301 //#endif 1301 //#endif
1302} 1302}
1303 1303
1304void KOAgendaView::setHolidayMasks() 1304void KOAgendaView::setHolidayMasks()
1305{ 1305{
1306 mHolidayMask.resize(mSelectedDates.count()); 1306 mHolidayMask.resize(mSelectedDates.count());
1307 1307
1308 uint i; 1308 uint i;
1309 for(i=0;i<mSelectedDates.count();++i) { 1309 for(i=0;i<mSelectedDates.count();++i) {
1310 QDate date = mSelectedDates[i]; 1310 QDate date = mSelectedDates[i];
1311 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1311 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1312 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1312 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1313 bool showHoliday = false;
1314 if ( KOPrefs::instance()->mExcludeHolidays ) {
1315 QPtrList<Event> events = calendar()->events( date, true );
1316 Event *event;
1317 for( event = events.first(); event; event = events.next() ) {
1318 if ( event->categories().contains("Holiday") ||
1319 event->categories().contains(i18n("Holiday"))) {
1320 showHoliday = true;
1321 break;
1322 }
1323 }
1324
1325 }
1326
1313#ifndef KORG_NOPLUGINS 1327#ifndef KORG_NOPLUGINS
1314 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1328 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1315 !KOCore::self()->holiday(date).isEmpty(); 1329 !KOCore::self()->holiday(date).isEmpty();
1316 bool showDay = showSaturday || showSunday || showHoliday;
1317#else
1318 bool showDay = showSaturday || showSunday;
1319#endif 1330#endif
1331 bool showDay = showSaturday || showSunday || showHoliday;
1332
1320 if (showDay) { 1333 if (showDay) {
1321 mHolidayMask.at(i) = true; 1334 mHolidayMask.at(i) = true;
1322 } else { 1335 } else {
1323 mHolidayMask.at(i) = false; 1336 mHolidayMask.at(i) = false;
1324 } 1337 }
1325 } 1338 }
1326 1339
1327 mAgenda->setHolidayMask(&mHolidayMask); 1340 mAgenda->setHolidayMask(&mHolidayMask);
1328 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1341 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1329} 1342}
1330 1343
1331void KOAgendaView::setContentsPos(int y) 1344void KOAgendaView::setContentsPos(int y)
1332{ 1345{
1333 mAgenda->setContentsPos(0,y); 1346 mAgenda->setContentsPos(0,y);
1334} 1347}
1335 1348
1336void KOAgendaView::setExpandedButton( bool expanded ) 1349void KOAgendaView::setExpandedButton( bool expanded )
1337{ 1350{
1338 if ( expanded ) { 1351 if ( expanded ) {
1339 mExpandButton->setPixmap( mExpandedPixmap ); 1352 mExpandButton->setPixmap( mExpandedPixmap );
1340 } else { 1353 } else {
1341 mExpandButton->setPixmap( mNotExpandedPixmap ); 1354 mExpandButton->setPixmap( mNotExpandedPixmap );
1342 } 1355 }
1343} 1356}
1344 1357
1345void KOAgendaView::clearSelection() 1358void KOAgendaView::clearSelection()
1346{ 1359{
1347 mAgenda->deselectItem(); 1360 mAgenda->deselectItem();
1348 mAllDayAgenda->deselectItem(); 1361 mAllDayAgenda->deselectItem();
1349} 1362}
1350 1363
1351void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1364void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1352 int gxEnd, int gyEnd) 1365 int gxEnd, int gyEnd)
1353{ 1366{
1354 mTimeSpanInAllDay = true; 1367 mTimeSpanInAllDay = true;
1355 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1368 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1356} 1369}
1357 1370
1358 1371
1359 1372
1360 1373
1361void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1374void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1362 int gxEnd, int gyEnd) 1375 int gxEnd, int gyEnd)
1363{ 1376{
1364 if (!mSelectedDates.count()) return; 1377 if (!mSelectedDates.count()) return;
1365 1378
1366 QDate dayStart = mSelectedDates[gxStart]; 1379 QDate dayStart = mSelectedDates[gxStart];
1367 QDate dayEnd = mSelectedDates[gxEnd]; 1380 QDate dayEnd = mSelectedDates[gxEnd];
1368 1381
1369 QTime timeStart = mAgenda->gyToTime(gyStart); 1382 QTime timeStart = mAgenda->gyToTime(gyStart);
1370 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1383 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1371 1384
1372 QDateTime dtStart(dayStart,timeStart); 1385 QDateTime dtStart(dayStart,timeStart);
1373 QDateTime dtEnd(dayEnd,timeEnd); 1386 QDateTime dtEnd(dayEnd,timeEnd);
1374 1387
1375 mTimeSpanBegin = dtStart; 1388 mTimeSpanBegin = dtStart;
1376 mTimeSpanEnd = dtEnd; 1389 mTimeSpanEnd = dtEnd;
1377 1390
1378} 1391}
1379 1392
1380void KOAgendaView::deleteSelectedDateTime() 1393void KOAgendaView::deleteSelectedDateTime()
1381{ 1394{
1382 mTimeSpanBegin.setDate(QDate()); 1395 mTimeSpanBegin.setDate(QDate());
1383 mTimeSpanEnd.setDate(QDate()); 1396 mTimeSpanEnd.setDate(QDate());
1384 mTimeSpanInAllDay = false; 1397 mTimeSpanInAllDay = false;
1385} 1398}
1386 1399
1387void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1400void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1388{ 1401{
1389 e->ignore(); 1402 e->ignore();
1390} 1403}
1391 1404
1392void KOAgendaView::scrollOneHourUp() 1405void KOAgendaView::scrollOneHourUp()
1393{ 1406{
1394 1407
1395 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1408 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1396} 1409}
1397void KOAgendaView::scrollOneHourDown() 1410void KOAgendaView::scrollOneHourDown()
1398{ 1411{
1399 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1412 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1400} 1413}
1401 1414
1402void KOAgendaView::setStartHour( int h ) 1415void KOAgendaView::setStartHour( int h )
1403{ 1416{
1404 mAgenda->setStartHour( h ); 1417 mAgenda->setStartHour( h );
1405 1418
1406} 1419}
1407 1420
1408void KOAgendaView::updateTodo( Todo * t, int ) 1421void KOAgendaView::updateTodo( Todo * t, int )
1409{ 1422{
1410 1423
1411 bool remove = false; 1424 bool remove = false;
1412 bool removeAD = false; 1425 bool removeAD = false;
1413 if ( ! t->hasDueDate() ) { 1426 if ( ! t->hasDueDate() ) {
1414 remove = true; 1427 remove = true;
1415 removeAD = true; 1428 removeAD = true;
1416 } 1429 }
1417 else { 1430 else {
1418 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1431 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1419 if ( overdue && 1432 if ( overdue &&
1420 QDate::currentDate() >= mSelectedDates.first() && 1433 QDate::currentDate() >= mSelectedDates.first() &&
1421 QDate::currentDate() <= mSelectedDates.last()) { 1434 QDate::currentDate() <= mSelectedDates.last()) {
1422 removeAD = false; 1435 removeAD = false;
1423 remove = true; 1436 remove = true;
1424 } 1437 }
1425 else { 1438 else {
1426 if ( t->dtDue().date() < mSelectedDates.first() || 1439 if ( t->dtDue().date() < mSelectedDates.first() ||
1427 t->dtDue().date() > mSelectedDates.last() ) { 1440 t->dtDue().date() > mSelectedDates.last() ) {
1428 remove = true; 1441 remove = true;
1429 removeAD = true; 1442 removeAD = true;
1430 } else { 1443 } else {
1431 remove = t->doesFloat(); 1444 remove = t->doesFloat();
1432 removeAD = !remove; 1445 removeAD = !remove;
1433 } 1446 }
1434 } 1447 }
1435 } 1448 }
1436 int days = mSelectedDates.first().daysTo( t->dtDue().date() ); 1449 int days = mSelectedDates.first().daysTo( t->dtDue().date() );
1437 // qDebug("daysto %d ", days ); 1450 // qDebug("daysto %d ", days );
1438 mAgenda->updateTodo( t , days, remove); 1451 mAgenda->updateTodo( t , days, remove);
1439 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1452 if ( KOPrefs::instance()->mShowTodoInAgenda )
1440 mAllDayAgenda->updateTodo( t , days, removeAD); 1453 mAllDayAgenda->updateTodo( t , days, removeAD);
1441 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1454 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1442 1455
1443} 1456}
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 688d9e1..7d1e82f 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,900 +1,900 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 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 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qtooltip.h> 27#include <qtooltip.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35 35
36#include <kdebug.h> 36#include <kdebug.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPRINTER 44#ifndef KORG_NOPRINTER
45#include "calprinter.h" 45#include "calprinter.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#ifndef KORG_NOPLUGINS 48#ifndef KORG_NOPLUGINS
49#include "kocore.h" 49#include "kocore.h"
50#endif 50#endif
51#include "koglobals.h" 51#include "koglobals.h"
52#include <libkcal/kincidenceformatter.h> 52#include <libkcal/kincidenceformatter.h>
53 53
54#include "komonthview.h" 54#include "komonthview.h"
55 55
56#define PIXMAP_SIZE 5 56#define PIXMAP_SIZE 5
57 57
58class KNOWhatsThis :public QWhatsThis 58class KNOWhatsThis :public QWhatsThis
59{ 59{
60public: 60public:
61 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 61 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
62 62
63protected: 63protected:
64 virtual QString text( const QPoint& p) 64 virtual QString text( const QPoint& p)
65 { 65 {
66 return _wid->getWhatsThisText(p) ; 66 return _wid->getWhatsThisText(p) ;
67 }; 67 };
68private: 68private:
69 KNoScrollListBox* _wid; 69 KNoScrollListBox* _wid;
70 70
71}; 71};
72 72
73 73
74KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 74KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
75 : QListBox(parent, name) 75 : QListBox(parent, name)
76{ 76{
77#ifndef DESKTOP_VERSION 77#ifndef DESKTOP_VERSION
78 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 78 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
79#endif 79#endif
80 new KNOWhatsThis(this); 80 new KNOWhatsThis(this);
81} 81}
82 82
83QString KNoScrollListBox::getWhatsThisText(QPoint p) 83QString KNoScrollListBox::getWhatsThisText(QPoint p)
84{ 84{
85 QListBoxItem* item = itemAt ( p ); 85 QListBoxItem* item = itemAt ( p );
86 if ( ! item ) { 86 if ( ! item ) {
87 return i18n("Click in the cell or\non the date label\nto add an event!"); 87 return i18n("Click in the cell or\non the date label\nto add an event!");
88 } 88 }
89 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 89 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
90} 90}
91void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 91void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
92{ 92{
93 93
94 switch(e->key()) { 94 switch(e->key()) {
95 case Key_Right: 95 case Key_Right:
96 // if ( e->state() == Qt::ControlButton ) 96 // if ( e->state() == Qt::ControlButton )
97 { 97 {
98 e->ignore(); 98 e->ignore();
99 return; 99 return;
100 } 100 }
101 scrollBy(4,0); 101 scrollBy(4,0);
102 break; 102 break;
103 case Key_Left: 103 case Key_Left:
104 // if ( e->state() == Qt::ControlButton ) 104 // if ( e->state() == Qt::ControlButton )
105 { 105 {
106 e->ignore(); 106 e->ignore();
107 return; 107 return;
108 } 108 }
109 scrollBy(-4,0); 109 scrollBy(-4,0);
110 break; 110 break;
111 case Key_Up: 111 case Key_Up:
112 if(!count()) break; 112 if(!count()) break;
113 setCurrentItem((currentItem()+count()-1)%count()); 113 setCurrentItem((currentItem()+count()-1)%count());
114 if(!itemVisible(currentItem())) { 114 if(!itemVisible(currentItem())) {
115 if((unsigned int) currentItem() == (count()-1)) { 115 if((unsigned int) currentItem() == (count()-1)) {
116 setTopItem(currentItem()-numItemsVisible()+1); 116 setTopItem(currentItem()-numItemsVisible()+1);
117 } else { 117 } else {
118 setTopItem(topItem()-1); 118 setTopItem(topItem()-1);
119 } 119 }
120 } 120 }
121 break; 121 break;
122 case Key_Down: 122 case Key_Down:
123 if(!count()) break; 123 if(!count()) break;
124 setCurrentItem((currentItem()+1)%count()); 124 setCurrentItem((currentItem()+1)%count());
125 if(!itemVisible(currentItem())) { 125 if(!itemVisible(currentItem())) {
126 if(currentItem() == 0) { 126 if(currentItem() == 0) {
127 setTopItem(0); 127 setTopItem(0);
128 } else { 128 } else {
129 setTopItem(topItem()+1); 129 setTopItem(topItem()+1);
130 } 130 }
131 } 131 }
132 break; 132 break;
133 case Key_Shift: 133 case Key_Shift:
134 emit shiftDown(); 134 emit shiftDown();
135 break; 135 break;
136 default: 136 default:
137 e->ignore(); 137 e->ignore();
138 break; 138 break;
139 } 139 }
140} 140}
141 141
142void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 142void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
143{ 143{
144 switch(e->key()) { 144 switch(e->key()) {
145 case Key_Shift: 145 case Key_Shift:
146 emit shiftUp(); 146 emit shiftUp();
147 break; 147 break;
148 default: 148 default:
149 break; 149 break;
150 } 150 }
151} 151}
152 152
153void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 153void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
154{ 154{
155 QListBox::mousePressEvent(e); 155 QListBox::mousePressEvent(e);
156 156
157 if(e->button() == RightButton) { 157 if(e->button() == RightButton) {
158 emit rightClick(); 158 emit rightClick();
159 } 159 }
160} 160}
161 161
162MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 162MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
163 : QListBoxItem() 163 : QListBoxItem()
164{ 164{
165 setText( s ); 165 setText( s );
166 166
167 mIncidence = incidence; 167 mIncidence = incidence;
168 mDate = qd; 168 mDate = qd;
169 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 169 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
170 mRecur = false; 170 mRecur = false;
171 mAlarm = false; 171 mAlarm = false;
172 mReply = false; 172 mReply = false;
173 mInfo = false; 173 mInfo = false;
174} 174}
175 175
176void MonthViewItem::paint(QPainter *p) 176void MonthViewItem::paint(QPainter *p)
177{ 177{
178#if QT_VERSION >= 0x030000 178#if QT_VERSION >= 0x030000
179 bool sel = isSelected(); 179 bool sel = isSelected();
180#else 180#else
181 bool sel = selected(); 181 bool sel = selected();
182#endif 182#endif
183 183
184 184
185 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 185 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
186 { 186 {
187 p->setBackgroundColor( palette().color( QPalette::Normal, \ 187 p->setBackgroundColor( palette().color( QPalette::Normal, \
188 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 188 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
189 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 189 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
190 } 190 }
191 int x = 1; 191 int x = 1;
192 int y = 3;//(height() - mRecurPixmap.height()) /2; 192 int y = 3;//(height() - mRecurPixmap.height()) /2;
193 int size = PIXMAP_SIZE; 193 int size = PIXMAP_SIZE;
194 if ( QApplication::desktop()->width() < 300 ) 194 if ( QApplication::desktop()->width() < 300 )
195 size = 3; 195 size = 3;
196 if ( KOPrefs::instance()->mMonthShowIcons ) { 196 if ( KOPrefs::instance()->mMonthShowIcons ) {
197 if ( mInfo ) { 197 if ( mInfo ) {
198 p->fillRect ( x, y,size,size, Qt::darkGreen ); 198 p->fillRect ( x, y,size,size, Qt::darkGreen );
199 x += size + 1; 199 x += size + 1;
200 } 200 }
201 if ( mRecur ) { 201 if ( mRecur ) {
202 p->fillRect ( x, y,size,size, Qt::blue ); 202 p->fillRect ( x, y,size,size, Qt::blue );
203 x += size + 1; 203 x += size + 1;
204 } 204 }
205 if ( mAlarm ) { 205 if ( mAlarm ) {
206 p->fillRect ( x, y,size,size, Qt::red ); 206 p->fillRect ( x, y,size,size, Qt::red );
207 x += size + 1; 207 x += size + 1;
208 } 208 }
209 if ( mReply ) { 209 if ( mReply ) {
210 p->fillRect ( x, y,size,size, Qt::yellow ); 210 p->fillRect ( x, y,size,size, Qt::yellow );
211 x += size + 1; 211 x += size + 1;
212 } 212 }
213 } 213 }
214 QFontMetrics fm = p->fontMetrics(); 214 QFontMetrics fm = p->fontMetrics();
215 int yPos; 215 int yPos;
216 int pmheight = size; 216 int pmheight = size;
217 if( pmheight < fm.height() ) 217 if( pmheight < fm.height() )
218 yPos = fm.ascent() + fm.leading()/2; 218 yPos = fm.ascent() + fm.leading()/2;
219 else 219 else
220 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 220 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
221 p->setPen( palette().color( QPalette::Normal, sel ? \ 221 p->setPen( palette().color( QPalette::Normal, sel ? \
222 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 222 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
223 p->drawText( x, yPos, text() ); 223 p->drawText( x, yPos, text() );
224 if ( mIncidence->cancelled() ) { 224 if ( mIncidence->cancelled() ) {
225 int wid = fm.width( text() ); 225 int wid = fm.width( text() );
226 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); 226 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
227 } 227 }
228 228
229} 229}
230 230
231int MonthViewItem::height(const QListBox *lb) const 231int MonthViewItem::height(const QListBox *lb) const
232{ 232{
233 return lb->fontMetrics().lineSpacing()+1; 233 return lb->fontMetrics().lineSpacing()+1;
234} 234}
235 235
236int MonthViewItem::width(const QListBox *lb) const 236int MonthViewItem::width(const QListBox *lb) const
237{ 237{
238 int size = PIXMAP_SIZE; 238 int size = PIXMAP_SIZE;
239 if ( QApplication::desktop()->width() < 300 ) 239 if ( QApplication::desktop()->width() < 300 )
240 size = 3; 240 size = 3;
241 int x = 1; 241 int x = 1;
242 if ( mInfo ) { 242 if ( mInfo ) {
243 x += size + 1; 243 x += size + 1;
244 } 244 }
245 if( mRecur ) { 245 if( mRecur ) {
246 x += size+1; 246 x += size+1;
247 } 247 }
248 if( mAlarm ) { 248 if( mAlarm ) {
249 x += size+1; 249 x += size+1;
250 } 250 }
251 if( mReply ) { 251 if( mReply ) {
252 x += size+1; 252 x += size+1;
253 } 253 }
254 254
255 return( x + lb->fontMetrics().width( text() ) + 1 ); 255 return( x + lb->fontMetrics().width( text() ) + 1 );
256} 256}
257 257
258 258
259MonthViewCell::MonthViewCell( KOMonthView *parent) 259MonthViewCell::MonthViewCell( KOMonthView *parent)
260 : QWidget( parent ), 260 : QWidget( parent ),
261 mMonthView( parent ) 261 mMonthView( parent )
262{ 262{
263 263
264 QVBoxLayout *topLayout = new QVBoxLayout( this ); 264 QVBoxLayout *topLayout = new QVBoxLayout( this );
265 265
266 // mLabel = new QLabel( this );QPushButton 266 // mLabel = new QLabel( this );QPushButton
267 mLabel = new QPushButton( this ); 267 mLabel = new QPushButton( this );
268 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 268 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
269 //mLabel->setLineWidth( 1 ); 269 //mLabel->setLineWidth( 1 );
270 //mLabel->setAlignment( AlignCenter ); 270 //mLabel->setAlignment( AlignCenter );
271 mLabel->setFlat( true ); 271 mLabel->setFlat( true );
272 mItemList = new KNoScrollListBox( this ); 272 mItemList = new KNoScrollListBox( this );
273 mItemList->setMinimumSize( 10, 10 ); 273 mItemList->setMinimumSize( 10, 10 );
274 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 274 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
275 mItemList->setLineWidth( 1 ); 275 mItemList->setLineWidth( 1 );
276 topLayout->addWidget( mItemList ); 276 topLayout->addWidget( mItemList );
277 mLabel->raise(); 277 mLabel->raise();
278 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 278 // QColor( 0,0,255 ) QColor( 160,1600,255 )
279 mStandardPalette = palette(); 279 mStandardPalette = palette();
280 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 280 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
281 281
282 enableScrollBars( false ); 282 enableScrollBars( false );
283 updateConfig(); 283 updateConfig();
284 connect( mLabel, SIGNAL( clicked( )), 284 connect( mLabel, SIGNAL( clicked( )),
285 SLOT( newEvent() )); 285 SLOT( newEvent() ));
286 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 286 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
287 SLOT( defaultAction( QListBoxItem * ) ) ); 287 SLOT( defaultAction( QListBoxItem * ) ) );
288 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 288 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
289 const QPoint &) ), 289 const QPoint &) ),
290 SLOT( contextMenu( QListBoxItem * ) ) ); 290 SLOT( contextMenu( QListBoxItem * ) ) );
291 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 291 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
292 SLOT( selection( QListBoxItem * ) ) ); 292 SLOT( selection( QListBoxItem * ) ) );
293 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 293 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
294 SLOT( cellClicked( QListBoxItem * ) ) ); 294 SLOT( cellClicked( QListBoxItem * ) ) );
295 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 295 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
296 SLOT( selection( QListBoxItem * ) ) ); 296 SLOT( selection( QListBoxItem * ) ) );
297} 297}
298 298
299void MonthViewCell::setDate( const QDate &date ) 299void MonthViewCell::setDate( const QDate &date )
300{ 300{
301// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 301// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
302 302
303 mDate = date; 303 mDate = date;
304 304
305 QString text; 305 QString text;
306 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 306 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
307 if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 307 if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
308 text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " "; 308 text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " ";
309 mLabel->resize( mLabelBigSize ); 309 mLabel->resize( mLabelBigSize );
310 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 310 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
311 } else { 311 } else {
312 mLabel->resize( mLabelSize ); 312 mLabel->resize( mLabelSize );
313 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 313 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
314 } 314 }
315 mLabel->setText( text ); 315 mLabel->setText( text );
316 316
317 //resizeEvent( 0 ); 317 //resizeEvent( 0 );
318} 318}
319 319
320QDate MonthViewCell::date() const 320QDate MonthViewCell::date() const
321{ 321{
322 return mDate; 322 return mDate;
323} 323}
324 324
325void MonthViewCell::setPrimary( bool primary ) 325void MonthViewCell::setPrimary( bool primary )
326{ 326{
327 mPrimary = primary; 327 mPrimary = primary;
328 //setMyPalette(); 328 //setMyPalette();
329} 329}
330void MonthViewCell::setMyPalette() 330void MonthViewCell::setMyPalette()
331{ 331{
332 332
333 if ( mHoliday) { 333 if ( mHoliday) {
334 setPalette( mHolidayPalette ); 334 setPalette( mHolidayPalette );
335 } else { 335 } else {
336 if ( mPrimary ) { 336 if ( mPrimary ) {
337 setPalette( mPrimaryPalette ); 337 setPalette( mPrimaryPalette );
338 } else { 338 } else {
339 setPalette( mNonPrimaryPalette ); 339 setPalette( mNonPrimaryPalette );
340 } 340 }
341 } 341 }
342 QPalette pal = palette(); 342 QPalette pal = palette();
343 343
344 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 344 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
345} 345}
346QPalette MonthViewCell::getPalette () 346QPalette MonthViewCell::getPalette ()
347{ 347{
348 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 348 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
349 return mStandardPalette; 349 return mStandardPalette;
350 if ( mHoliday) { 350 if ( mHoliday) {
351 return mHolidayPalette ; 351 return mHolidayPalette ;
352 } else { 352 } else {
353 if ( mPrimary ) { 353 if ( mPrimary ) {
354 return mPrimaryPalette ; 354 return mPrimaryPalette ;
355 } 355 }
356 } 356 }
357 return mNonPrimaryPalette; 357 return mNonPrimaryPalette;
358} 358}
359bool MonthViewCell::isPrimary() const 359bool MonthViewCell::isPrimary() const
360{ 360{
361 return mPrimary; 361 return mPrimary;
362} 362}
363 363
364void MonthViewCell::setHoliday( bool holiday ) 364void MonthViewCell::setHoliday( bool holiday )
365{ 365{
366 mHoliday = holiday; 366 mHoliday = holiday;
367 //setMyPalette(); 367 //setMyPalette();
368} 368}
369 369
370void MonthViewCell::setHoliday( const QString &holiday ) 370void MonthViewCell::setHoliday( const QString &holiday )
371{ 371{
372 mHolidayString = holiday; 372 mHolidayString = holiday;
373 373
374 if ( !holiday.isEmpty() ) { 374 if ( !holiday.isEmpty() ) {
375 setHoliday( true ); 375 setHoliday( true );
376 } 376 }
377} 377}
378void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 378void MonthViewCell::keyPressEvent ( QKeyEvent * e )
379{ 379{
380 380
381 e->ignore(); 381 e->ignore();
382 382
383} 383}
384void MonthViewCell::updateCell() 384void MonthViewCell::updateCell()
385{ 385{
386 386
387 setPrimary( mDate.month()%2 ); 387 setPrimary( mDate.month()%2 );
388 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() ); 388 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
389 if ( mDate == QDate::currentDate() ) { 389 if ( mDate == QDate::currentDate() ) {
390 mItemList->setLineWidth( 3 ); 390 mItemList->setLineWidth( 3 );
391 } else { 391 } else {
392 mItemList->setLineWidth( 1 ); 392 mItemList->setLineWidth( 1 );
393 } 393 }
394 mItemList->clear(); 394 mItemList->clear();
395 //qApp->processEvents(); 395 //qApp->processEvents();
396 if ( !mHolidayString.isEmpty() ) { 396 if ( !mHolidayString.isEmpty() ) {
397 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 397 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
398 item->setPalette( mHolidayPalette ); 398 item->setPalette( mHolidayPalette );
399 mItemList->insertItem( item ); 399 mItemList->insertItem( item );
400 } 400 }
401 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 401 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
402 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 402 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
403 Event *event; 403 Event *event;
404 for( event = events.first(); event; event = events.next() ) { 404 for( event = events.first(); event; event = events.next() ) {
405 if ( event->categories().contains("Holiday") || 405 if ( event->categories().contains("Holiday") ||
406 event->categories().contains(i18n("Holiday"))) { 406 event->categories().contains(i18n("Holiday"))) {
407 setHoliday( true ); 407 setHoliday( true );
408 if ( mDate.dayOfWeek() == 7 ) 408 if ( mDate.dayOfWeek() == 7 )
409 mItemList->setLineWidth( 3 ); 409 mItemList->setLineWidth( 3 );
410 } 410 }
411 QString text; 411 QString text;
412 if (event->isMultiDay()) { 412 if (event->isMultiDay()) {
413 QString prefix = "<->"; 413 QString prefix = "<->";
414 if ( event->doesRecur() ) { 414 if ( event->doesRecur() ) {
415 if ( event->recursOn( mDate) ) 415 if ( event->recursOn( mDate) )
416 prefix ="->" ; 416 prefix ="->" ;
417 else { 417 else {
418 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 418 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
419 if ( event->recursOn( mDate.addDays( -days)) ) 419 if ( event->recursOn( mDate.addDays( -days)) )
420 prefix ="<-" ; 420 prefix ="<-" ;
421 } 421 }
422 422
423 } else { 423 } else {
424 if (mDate == event->dtStart().date()) { 424 if (mDate == event->dtStart().date()) {
425 prefix ="->" ; 425 prefix ="->" ;
426 } else if (mDate == event->dtEnd().date()) { 426 } else if (mDate == event->dtEnd().date()) {
427 prefix ="<-" ; 427 prefix ="<-" ;
428 } 428 }
429 } 429 }
430 text = prefix + event->summary(); 430 text = prefix + event->summary();
431 } else { 431 } else {
432 if (event->doesFloat()) 432 if (event->doesFloat())
433 text = event->summary(); 433 text = event->summary();
434 else { 434 else {
435 text = KGlobal::locale()->formatTime(event->dtStart().time()); 435 text = KGlobal::locale()->formatTime(event->dtStart().time());
436 text += " " + event->summary(); 436 text += " " + event->summary();
437 } 437 }
438 } 438 }
439 439
440 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 440 MonthViewItem *item = new MonthViewItem( event, mDate, text );
441 QPalette pal; 441 QPalette pal;
442 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 442 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
443 QStringList categories = event->categories(); 443 QStringList categories = event->categories();
444 QString cat = categories.first(); 444 QString cat = categories.first();
445 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 445 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
446 pal = getPalette(); 446 pal = getPalette();
447 if (cat.isEmpty()) { 447 if (cat.isEmpty()) {
448 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 448 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
449 } else { 449 } else {
450 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 450 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
451 } 451 }
452 452
453 } else { 453 } else {
454 if (cat.isEmpty()) { 454 if (cat.isEmpty()) {
455 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 455 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
456 } else { 456 } else {
457 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 457 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
458 } 458 }
459 } 459 }
460 460
461 } else { 461 } else {
462 pal = mStandardPalette ; 462 pal = mStandardPalette ;
463 } 463 }
464 item->setPalette( pal ); 464 item->setPalette( pal );
465 item->setRecur( event->recurrence()->doesRecur() ); 465 item->setRecur( event->recurrence()->doesRecur() );
466 item->setAlarm( event->isAlarmEnabled() ); 466 item->setAlarm( event->isAlarmEnabled() );
467 item->setMoreInfo( event->description().length() > 0 ); 467 item->setMoreInfo( event->description().length() > 0 );
468 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 468 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
469 KOPrefs::instance()->email()); 469 KOPrefs::instance()->email());
470 if ( me != 0 ) { 470 if ( me != 0 ) {
471 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 471 if ( me->status() == Attendee::NeedsAction && me->RSVP())
472 item->setReply(true); 472 item->setReply(true);
473 else 473 else
474 item->setReply(false); 474 item->setReply(false);
475 } else 475 } else
476 item->setReply(false); 476 item->setReply(false);
477 bool insert = true; 477 bool insert = true;
478 if ( !(event->doesRecur() == Recurrence::rNone) ) { 478 if ( !(event->doesRecur() == Recurrence::rNone) ) {
479 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 479 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
480 insert = false; 480 insert = false;
481 else 481 else
482 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 482 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
483 insert = false; 483 insert = false;
484 484
485 } 485 }
486 if ( insert ) 486 if ( insert )
487 mItemList->insertItem( item ); 487 mItemList->insertItem( item );
488 } 488 }
489 489
490 // insert due todos 490 // insert due todos
491 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 491 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
492 Todo *todo; 492 Todo *todo;
493 for(todo = todos.first(); todo; todo = todos.next()) { 493 for(todo = todos.first(); todo; todo = todos.next()) {
494 QString text; 494 QString text;
495 if (todo->hasDueDate()) { 495 if (todo->hasDueDate()) {
496 if (!todo->doesFloat()) { 496 if (!todo->doesFloat()) {
497 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 497 text += KGlobal::locale()->formatTime(todo->dtDue().time());
498 text += " "; 498 text += " ";
499 } 499 }
500 } 500 }
501 text += i18n("To-Do: %1").arg(todo->summary()); 501 text += i18n("To-Do: %1").arg(todo->summary());
502 502
503 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 503 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
504 //item->setPalette( mStandardPalette ); 504 //item->setPalette( mStandardPalette );
505 QPalette pal; 505 QPalette pal;
506 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 506 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
507 QStringList categories = todo->categories(); 507 QStringList categories = todo->categories();
508 QString cat = categories.first(); 508 QString cat = categories.first();
509 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 509 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
510 pal = getPalette(); 510 pal = getPalette();
511 if (cat.isEmpty()) { 511 if (cat.isEmpty()) {
512 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 512 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
513 } else { 513 } else {
514 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 514 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
515 } 515 }
516 516
517 } else { 517 } else {
518 if (cat.isEmpty()) { 518 if (cat.isEmpty()) {
519 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 519 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
520 } else { 520 } else {
521 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 521 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
522 } 522 }
523 } 523 }
524 524
525 } else { 525 } else {
526 pal = mStandardPalette ; 526 pal = mStandardPalette ;
527 } 527 }
528 item->setPalette( pal ); 528 item->setPalette( pal );
529 mItemList->insertItem( item ); 529 mItemList->insertItem( item );
530 } 530 }
531 //setMyPalette(); 531 //setMyPalette();
532 setMyPalette(); 532 setMyPalette();
533 resizeEvent( 0 ); 533 resizeEvent( 0 );
534 // if ( isVisible()) 534 // if ( isVisible())
535 // qApp->processEvents(); 535 // qApp->processEvents();
536} 536}
537 537
538void MonthViewCell::updateConfig() 538void MonthViewCell::updateConfig()
539{ 539{
540 540
541 setFont( KOPrefs::instance()->mMonthViewFont ); 541 setFont( KOPrefs::instance()->mMonthViewFont );
542 542
543 QFontMetrics fm( font() ); 543 QFontMetrics fm( font() );
544 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 544 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
545 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 545 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
546 mHolidayPalette = mStandardPalette; 546 mHolidayPalette = mStandardPalette;
547 mPrimaryPalette = mStandardPalette; 547 mPrimaryPalette = mStandardPalette;
548 mNonPrimaryPalette = mStandardPalette; 548 mNonPrimaryPalette = mStandardPalette;
549 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 549 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
550 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 550 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
551 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 551 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
552 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 552 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
553 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 553 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
554 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 554 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
555 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 555 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
556 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 556 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
557 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 557 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
558 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 558 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
559 } 559 }
560 updateCell(); 560 updateCell();
561} 561}
562 562
563void MonthViewCell::enableScrollBars( bool enabled ) 563void MonthViewCell::enableScrollBars( bool enabled )
564{ 564{
565 if ( enabled ) { 565 if ( enabled ) {
566 mItemList->setVScrollBarMode(QScrollView::Auto); 566 mItemList->setVScrollBarMode(QScrollView::Auto);
567 mItemList->setHScrollBarMode(QScrollView::Auto); 567 mItemList->setHScrollBarMode(QScrollView::Auto);
568 } else { 568 } else {
569 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 569 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
570 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 570 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
571 } 571 }
572} 572}
573 573
574Incidence *MonthViewCell::selectedIncidence() 574Incidence *MonthViewCell::selectedIncidence()
575{ 575{
576 int index = mItemList->currentItem(); 576 int index = mItemList->currentItem();
577 if ( index < 0 ) return 0; 577 if ( index < 0 ) return 0;
578 578
579 MonthViewItem *item = 579 MonthViewItem *item =
580 static_cast<MonthViewItem *>( mItemList->item( index ) ); 580 static_cast<MonthViewItem *>( mItemList->item( index ) );
581 581
582 if ( !item ) return 0; 582 if ( !item ) return 0;
583 583
584 return item->incidence(); 584 return item->incidence();
585} 585}
586 586
587QDate MonthViewCell::selectedIncidenceDate() 587QDate MonthViewCell::selectedIncidenceDate()
588{ 588{
589 QDate qd; 589 QDate qd;
590 int index = mItemList->currentItem(); 590 int index = mItemList->currentItem();
591 if ( index < 0 ) return qd; 591 if ( index < 0 ) return qd;
592 592
593 MonthViewItem *item = 593 MonthViewItem *item =
594 static_cast<MonthViewItem *>( mItemList->item( index ) ); 594 static_cast<MonthViewItem *>( mItemList->item( index ) );
595 595
596 if ( !item ) return qd; 596 if ( !item ) return qd;
597 597
598 return item->incidenceDate(); 598 return item->incidenceDate();
599} 599}
600 600
601void MonthViewCell::deselect() 601void MonthViewCell::deselect()
602{ 602{
603 mItemList->clearSelection(); 603 mItemList->clearSelection();
604 enableScrollBars( false ); 604 enableScrollBars( false );
605 // updateCell(); 605 // updateCell();
606} 606}
607void MonthViewCell::select() 607void MonthViewCell::select()
608{ 608{
609 ;// updateCell(); 609 ;// updateCell();
610} 610}
611 611
612void MonthViewCell::resizeEvent ( QResizeEvent * ) 612void MonthViewCell::resizeEvent ( QResizeEvent * )
613{ 613{
614 int size = height() - mLabel->height(); 614 int size = height() - mLabel->height();
615 if ( size > 0 ) 615 if ( size > 0 )
616 mItemList->verticalScrollBar()->setMaximumHeight( size ); 616 mItemList->verticalScrollBar()->setMaximumHeight( size );
617 size = width() - mLabel->width(); 617 size = width() - mLabel->width();
618 if ( size > 0 ) 618 if ( size > 0 )
619 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 619 mItemList->horizontalScrollBar()->setMaximumWidth( size );
620 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 620 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
621 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 621 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
622} 622}
623 623
624void MonthViewCell::defaultAction( QListBoxItem *item ) 624void MonthViewCell::defaultAction( QListBoxItem *item )
625{ 625{
626 if ( !item ) return; 626 if ( !item ) return;
627 627
628 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 628 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
629 Incidence *incidence = eventItem->incidence(); 629 Incidence *incidence = eventItem->incidence();
630 if ( incidence ) mMonthView->defaultAction( incidence ); 630 if ( incidence ) mMonthView->defaultAction( incidence );
631} 631}
632void MonthViewCell::newEvent() 632void MonthViewCell::newEvent()
633{ 633{
634 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 634 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
635 emit newEventSignal( dt ); 635 emit newEventSignal( dt );
636} 636}
637void MonthViewCell::cellClicked( QListBoxItem *item ) 637void MonthViewCell::cellClicked( QListBoxItem *item )
638{ 638{
639 static QListBoxItem * lastClicked = 0; 639 static QListBoxItem * lastClicked = 0;
640 if ( item == 0 ) { 640 if ( item == 0 ) {
641 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 641 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
642 emit newEventSignal( dt ); 642 emit newEventSignal( dt );
643 return; 643 return;
644 } 644 }
645 /* 645 /*
646 if ( lastClicked ) 646 if ( lastClicked )
647 if ( ! item ) { 647 if ( ! item ) {
648 if ( lastClicked->listBox() != item->listBox() ) 648 if ( lastClicked->listBox() != item->listBox() )
649 lastClicked->listBox()->clearSelection(); 649 lastClicked->listBox()->clearSelection();
650 } 650 }
651 */ 651 */
652 652
653 mMonthView->setSelectedCell( this ); 653 mMonthView->setSelectedCell( this );
654 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); 654 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
655 select(); 655 select();
656} 656}
657 657
658void MonthViewCell::contextMenu( QListBoxItem *item ) 658void MonthViewCell::contextMenu( QListBoxItem *item )
659{ 659{
660 if ( !item ) return; 660 if ( !item ) return;
661 661
662 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 662 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
663 Incidence *incidence = eventItem->incidence(); 663 Incidence *incidence = eventItem->incidence();
664 if ( incidence ) mMonthView->showContextMenu( incidence ); 664 if ( incidence ) mMonthView->showContextMenu( incidence );
665} 665}
666 666
667void MonthViewCell::selection( QListBoxItem *item ) 667void MonthViewCell::selection( QListBoxItem *item )
668{ 668{
669 if ( !item ) return; 669 if ( !item ) return;
670 670
671 mMonthView->setSelectedCell( this ); 671 mMonthView->setSelectedCell( this );
672} 672}
673 673
674 674
675// ******************************************************************************* 675// *******************************************************************************
676// ******************************************************************************* 676// *******************************************************************************
677// ******************************************************************************* 677// *******************************************************************************
678 678
679 679
680KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 680KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
681 : KOEventView( calendar, parent, name ), 681 : KOEventView( calendar, parent, name ),
682 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 682 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
683 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 683 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
684{ 684{
685 mCells.setAutoDelete( true ); 685 mCells.setAutoDelete( true );
686 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 686 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
687 // mDayLayout = new QGridLayout( this ); 687 // mDayLayout = new QGridLayout( this );
688 // create the day of the week labels (Sun, Mon, etc) and add them to 688 // create the day of the week labels (Sun, Mon, etc) and add them to
689 // the layout. 689 // the layout.
690 mDayLabels.resize( mDaysPerWeek ); 690 mDayLabels.resize( mDaysPerWeek );
691 QFont bfont = font(); 691 QFont bfont = font();
692 if ( QApplication::desktop()->width() < 650 ) { 692 if ( QApplication::desktop()->width() < 650 ) {
693 bfont.setPointSize( bfont.pointSize() - 2 ); 693 bfont.setPointSize( bfont.pointSize() - 2 );
694 } 694 }
695 bfont.setBold( true ); 695 bfont.setBold( true );
696 int i; 696 int i;
697 697
698 for( i = 0; i < mDaysPerWeek; i++ ) { 698 for( i = 0; i < mDaysPerWeek; i++ ) {
699 QLabel *label = new QLabel( this ); 699 QLabel *label = new QLabel( this );
700 label->setFont(bfont); 700 label->setFont(bfont);
701 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 701 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
702 label->setLineWidth(1); 702 label->setLineWidth(1);
703 label->setAlignment(AlignCenter); 703 label->setAlignment(AlignCenter);
704 mDayLabels.insert( i, label ); 704 mDayLabels.insert( i, label );
705 } 705 }
706 706
707 bfont.setBold( false ); 707 bfont.setBold( false );
708 mWeekLabels.resize( mNumWeeks+1 ); 708 mWeekLabels.resize( mNumWeeks+1 );
709 for( i = 0; i < mNumWeeks+1; i++ ) { 709 for( i = 0; i < mNumWeeks+1; i++ ) {
710 KOWeekButton *label = new KOWeekButton( this ); 710 KOWeekButton *label = new KOWeekButton( this );
711 label->setFont(bfont); 711 label->setFont(bfont);
712 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); 712 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
713 label->setFlat(true); 713 label->setFlat(true);
714 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); 714 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
715 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 715 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
716 //label->setLineWidth(1); 716 //label->setLineWidth(1);
717 //label->setAlignment(AlignCenter); 717 //label->setAlignment(AlignCenter);
718 mWeekLabels.insert( i, label ); 718 mWeekLabels.insert( i, label );
719 } 719 }
720 mWeekLabels[mNumWeeks]->setText( i18n("W")); 720 mWeekLabels[mNumWeeks]->setText( i18n("W"));
721 int row, col; 721 int row, col;
722 mCells.resize( mNumCells ); 722 mCells.resize( mNumCells );
723 for( row = 0; row < mNumWeeks; ++row ) { 723 for( row = 0; row < mNumWeeks; ++row ) {
724 for( col = 0; col < mDaysPerWeek; ++col ) { 724 for( col = 0; col < mDaysPerWeek; ++col ) {
725 MonthViewCell *cell = new MonthViewCell( this ); 725 MonthViewCell *cell = new MonthViewCell( this );
726 mCells.insert( row * mDaysPerWeek + col, cell ); 726 mCells.insert( row * mDaysPerWeek + col, cell );
727 727
728 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 728 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
729 SLOT( defaultAction( Incidence * ) ) ); 729 SLOT( defaultAction( Incidence * ) ) );
730 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 730 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
731 SIGNAL( newEventSignal( QDateTime ) ) ); 731 SIGNAL( newEventSignal( QDateTime ) ) );
732 } 732 }
733 } 733 }
734 734
735 mContextMenu = eventPopup(); 735 mContextMenu = eventPopup();
736 // updateConfig(); //useless here 736 // updateConfig(); //useless here
737 737
738 emit incidenceSelected( 0 ); 738 emit incidenceSelected( 0 );
739} 739}
740 740
741KOMonthView::~KOMonthView() 741KOMonthView::~KOMonthView()
742{ 742{
743 delete mContextMenu; 743 delete mContextMenu;
744} 744}
745 745
746int KOMonthView::maxDatesHint() 746int KOMonthView::maxDatesHint()
747{ 747{
748 return mNumCells; 748 return mNumCells;
749} 749}
750 750
751int KOMonthView::currentDateCount() 751int KOMonthView::currentDateCount()
752{ 752{
753 return mNumCells; 753 return mNumCells;
754} 754}
755 755
756QPtrList<Incidence> KOMonthView::selectedIncidences() 756QPtrList<Incidence> KOMonthView::selectedIncidences()
757{ 757{
758 QPtrList<Incidence> selected; 758 QPtrList<Incidence> selected;
759 759
760 if ( mSelectedCell ) { 760 if ( mSelectedCell ) {
761 Incidence *incidence = mSelectedCell->selectedIncidence(); 761 Incidence *incidence = mSelectedCell->selectedIncidence();
762 if ( incidence ) selected.append( incidence ); 762 if ( incidence ) selected.append( incidence );
763 } 763 }
764 764
765 return selected; 765 return selected;
766} 766}
767 767
768DateList KOMonthView::selectedDates() 768DateList KOMonthView::selectedDates()
769{ 769{
770 DateList selected; 770 DateList selected;
771 771
772 if ( mSelectedCell ) { 772 if ( mSelectedCell ) {
773 QDate qd = mSelectedCell->selectedIncidenceDate(); 773 QDate qd = mSelectedCell->selectedIncidenceDate();
774 if ( qd.isValid() ) selected.append( qd ); 774 if ( qd.isValid() ) selected.append( qd );
775 } 775 }
776 776
777 return selected; 777 return selected;
778} 778}
779 779
780void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 780void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
781 const QDate &td) 781 const QDate &td)
782{ 782{
783#ifndef KORG_NOPRINTER 783#ifndef KORG_NOPRINTER
784 calPrinter->preview(CalPrinter::Month, fd, td); 784 calPrinter->preview(CalPrinter::Month, fd, td);
785#endif 785#endif
786} 786}
787 787
788void KOMonthView::updateConfig() 788void KOMonthView::updateConfig()
789{ 789{
790 790
791 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 791 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
792 792
793 QFontMetrics fontmetric(mDayLabels[0]->font()); 793 QFontMetrics fontmetric(mDayLabels[0]->font());
794 mWidthLongDayLabel = 0; 794 mWidthLongDayLabel = 0;
795 795
796 for (int i = 0; i < 7; i++) { 796 for (int i = 0; i < 7; i++) {
797 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 797 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
798 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 798 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
799 } 799 }
800 bool temp = mShowSatSunComp ; 800 bool temp = mShowSatSunComp ;
801 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 801 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
802 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 802 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
803 computeLayout(); 803 computeLayout();
804 updateDayLabels(); 804 updateDayLabels();
805 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 805 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
806 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 806 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
807 //resizeEvent( 0 ); 807 //resizeEvent( 0 );
808 for (uint i = 0; i < mCells.count(); ++i) { 808 for (uint i = 0; i < mCells.count(); ++i) {
809 mCells[i]->updateConfig(); 809 mCells[i]->updateConfig();
810 } 810 }
811} 811}
812 812
813void KOMonthView::updateDayLabels() 813void KOMonthView::updateDayLabels()
814{ 814{
815 815
816 for (int i = 0; i < 7; i++) { 816 for (int i = 0; i < 7; i++) {
817 if (mWeekStartsMonday) { 817 if (mWeekStartsMonday) {
818 bool show = mShortDayLabels; 818 bool show = mShortDayLabels;
819 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 819 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
820 show = true; 820 show = true;
821 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 821 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
822 } else { 822 } else {
823 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 823 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
824 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 824 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
825 825
826 } 826 }
827 } 827 }
828} 828}
829 829
830void KOMonthView::showDates(const QDate &start, const QDate &) 830void KOMonthView::showDates(const QDate &start, const QDate &)
831{ 831{
832// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 832// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
833 833
834 834
835 mStartDate = start; 835 mStartDate = start;
836 836
837 int startWeekDay = mWeekStartsMonday ? 1 : 7; 837 int startWeekDay = mWeekStartsMonday ? 1 : 7;
838 838
839 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 839 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
840 mStartDate = mStartDate.addDays( -1 ); 840 mStartDate = mStartDate.addDays( -1 );
841 } 841 }
842 842
843 bool primary = false; 843 bool primary = false;
844 uint i; 844 uint i;
845 for( i = 0; i < mCells.size(); ++i ) { 845 for( i = 0; i < mCells.size(); ++i ) {
846 QDate date = mStartDate.addDays( i ); 846 QDate date = mStartDate.addDays( i );
847 mCells[i]->setDate( date ); 847 mCells[i]->setDate( date );
848 848
849#ifndef KORG_NOPLUGINS 849#ifndef KORG_NOPLUGINS
850 // add holiday, if present 850 // add holiday, if present
851 QString hstring(KOCore::self()->holiday(date)); 851 QString hstring(KOCore::self()->holiday(date));
852 mCells[i]->setHoliday( hstring ); 852 mCells[i]->setHoliday( hstring );
853#endif 853#endif
854 854
855 } 855 }
856 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 856 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
857 for( i = 0; i < 6; ++i ) { 857 for( i = 0; i < 6; ++i ) {
858 int wno; 858 int wno;
859 // remember, according to ISO 8601, the first week of the year is the 859 // remember, according to ISO 8601, the first week of the year is the
860 // first week that contains a thursday. Thus we must subtract off 4, 860 // first week that contains a thursday. Thus we must subtract off 4,
861 // not just 1. 861 // not just 1.
862 int dayOfYear = date.dayOfYear(); 862 int dayOfYear = date.dayOfYear();
863 if (dayOfYear % 7 != 0) 863 if (dayOfYear % 7 != 0)
864 wno = dayOfYear / 7 + 1; 864 wno = dayOfYear / 7 + 1;
865 else 865 else
866 wno =dayOfYear / 7; 866 wno =dayOfYear / 7;
867 mWeekLabels[i]->setWeekNum( wno ); 867 mWeekLabels[i]->setWeekNum( wno );
868 date = date.addDays( 7 ); 868 date = date.addDays( 7 );
869 } 869 }
870 updateView(); 870 updateView();
871} 871}
872 872
873void KOMonthView::showEvents(QPtrList<Event>) 873void KOMonthView::showEvents(QPtrList<Event>)
874{ 874{
875 qDebug("KOMonthView::selectEvents is not implemented yet. "); 875 qDebug("KOMonthView::selectEvents is not implemented yet. ");
876} 876}
877 877
878void KOMonthView::changeEventDisplay(Event *, int) 878void KOMonthView::changeEventDisplay(Event *, int)
879{ 879{
880 // this should be re-written to be much more efficient, but this 880 // this should be re-written to be much more efficient, but this
881 // quick-and-dirty-hack gets the job done for right now. 881 // quick-and-dirty-hack gets the job done for right now.
882 updateView(); 882 updateView();
883} 883}
884 884
885void KOMonthView::updateView() 885void KOMonthView::updateView()
886{ 886{
887 887
888 uint i; 888 uint i;
889 for( i = 0; i < mCells.count(); ++i ) { 889 for( i = 0; i < mCells.count(); ++i ) {
890 mCells[i]->updateCell(); 890 mCells[i]->updateCell();
891 } 891 }
892 //qDebug("KOMonthView::updateView() "); 892 //qDebug("KOMonthView::updateView() ");
893 processSelectionChange(); 893 processSelectionChange();
894} 894}
895 895
896void KOMonthView::resizeEvent(QResizeEvent * e) 896void KOMonthView::resizeEvent(QResizeEvent * e)
897{ 897{
898 computeLayout(); 898 computeLayout();
899} 899}
900void KOMonthView::computeLayout() 900void KOMonthView::computeLayout()