summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp1
-rw-r--r--korganizer/komonthview.cpp10
-rw-r--r--korganizer/koviewmanager.cpp5
3 files changed, 8 insertions, 8 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index c8cef44..d4ff77a 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -791,385 +791,384 @@ void KOAgendaView::createDayLabels()
791 QString text = it->shortText( date ); 791 QString text = it->shortText( date );
792 if ( !text.isEmpty() ) { 792 if ( !text.isEmpty() ) {
793 QLabel *label = new QLabel(text,mDayLabels); 793 QLabel *label = new QLabel(text,mDayLabels);
794 label->setAlignment(AlignCenter); 794 label->setAlignment(AlignCenter);
795 dayLayout->addWidget(label); 795 dayLayout->addWidget(label);
796 } 796 }
797 } 797 }
798 798
799 for(it = cds.first(); it; it = cds.next()) { 799 for(it = cds.first(); it; it = cds.next()) {
800 QWidget *wid = it->smallWidget(mDayLabels,date); 800 QWidget *wid = it->smallWidget(mDayLabels,date);
801 if ( wid ) { 801 if ( wid ) {
802 // wid->setHeight(20); 802 // wid->setHeight(20);
803 dayLayout->addWidget(wid); 803 dayLayout->addWidget(wid);
804 } 804 }
805 } 805 }
806#endif 806#endif
807 } 807 }
808 if ( ! appendLabels ) { 808 if ( ! appendLabels ) {
809 dayLabel = mDayLabelsList.next(); 809 dayLabel = mDayLabelsList.next();
810 if ( !dayLabel ) 810 if ( !dayLabel )
811 appendLabels = true; 811 appendLabels = true;
812 } 812 }
813 if ( appendLabels ) { 813 if ( appendLabels ) {
814 dayLabel = getNewDaylabel(); 814 dayLabel = getNewDaylabel();
815 } 815 }
816 //dayLabel->hide();//test only 816 //dayLabel->hide();//test only
817 817
818 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 818 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
819 if ( offset < 0 ) offset = 0; 819 if ( offset < 0 ) offset = 0;
820 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 820 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
821 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); 821 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
822 dayLabel->setFont( dlf ); 822 dayLabel->setFont( dlf );
823 dayLabel->show(); 823 dayLabel->show();
824 dayLabel->setNum( -2 ); 824 dayLabel->setNum( -2 );
825 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 825 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
826 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 826 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
827 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 827 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
828 if ( !appendLabels ) { 828 if ( !appendLabels ) {
829 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
830 while ( dayLabel ) { 830 while ( dayLabel ) {
831 //qDebug("!dayLabel %d",dayLabel ); 831 //qDebug("!dayLabel %d",dayLabel );
832 dayLabel->hide(); 832 dayLabel->hide();
833 dayLabel = mDayLabelsList.next(); 833 dayLabel = mDayLabelsList.next();
834 } 834 }
835 } 835 }
836 //mDayLabelsFrame->show(); 836 //mDayLabelsFrame->show();
837 //mDayLabels->show(); 837 //mDayLabels->show();
838 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 838 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
839 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 839 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
840 mDayLabelsFrame->setFixedHeight( newHight ); 840 mDayLabelsFrame->setFixedHeight( newHight );
841} 841}
842 842
843int KOAgendaView::maxDatesHint() 843int KOAgendaView::maxDatesHint()
844{ 844{
845 // Not sure about the max number of events, so return 0 for now. 845 // Not sure about the max number of events, so return 0 for now.
846 return 0; 846 return 0;
847} 847}
848 848
849int KOAgendaView::currentDateCount() 849int KOAgendaView::currentDateCount()
850{ 850{
851 return mSelectedDates.count(); 851 return mSelectedDates.count();
852} 852}
853 853
854QPtrList<Incidence> KOAgendaView::selectedIncidences() 854QPtrList<Incidence> KOAgendaView::selectedIncidences()
855{ 855{
856 QPtrList<Incidence> selected; 856 QPtrList<Incidence> selected;
857 Incidence *incidence; 857 Incidence *incidence;
858 858
859 incidence = mAgenda->selectedIncidence(); 859 incidence = mAgenda->selectedIncidence();
860 if (incidence) selected.append(incidence); 860 if (incidence) selected.append(incidence);
861 861
862 incidence = mAllDayAgenda->selectedIncidence(); 862 incidence = mAllDayAgenda->selectedIncidence();
863 if (incidence) selected.append(incidence); 863 if (incidence) selected.append(incidence);
864 864
865 return selected; 865 return selected;
866} 866}
867 867
868DateList KOAgendaView::selectedDates() 868DateList KOAgendaView::selectedDates()
869{ 869{
870 DateList selected; 870 DateList selected;
871 QDate qd; 871 QDate qd;
872 872
873 qd = mAgenda->selectedIncidenceDate(); 873 qd = mAgenda->selectedIncidenceDate();
874 if (qd.isValid()) selected.append(qd); 874 if (qd.isValid()) selected.append(qd);
875 875
876 qd = mAllDayAgenda->selectedIncidenceDate(); 876 qd = mAllDayAgenda->selectedIncidenceDate();
877 if (qd.isValid()) selected.append(qd); 877 if (qd.isValid()) selected.append(qd);
878 878
879 return selected; 879 return selected;
880} 880}
881 881
882 882
883void KOAgendaView::updateView() 883void KOAgendaView::updateView()
884{ 884{
885 if ( mBlockUpdating ) 885 if ( mBlockUpdating )
886 return; 886 return;
887 // kdDebug() << "KOAgendaView::updateView()" << endl; 887 // kdDebug() << "KOAgendaView::updateView()" << endl;
888 fillAgenda(); 888 fillAgenda();
889 889
890} 890}
891 891
892 892
893/* 893/*
894 Update configuration settings for the agenda view. This method is not 894 Update configuration settings for the agenda view. This method is not
895 complete. 895 complete.
896*/ 896*/
897void KOAgendaView::updateConfig() 897void KOAgendaView::updateConfig()
898{ 898{
899 if ( mBlockUpdating ) 899 if ( mBlockUpdating )
900 return; 900 return;
901 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 901 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
902 902
903 // update config for children 903 // update config for children
904 mTimeLabels->updateConfig(); 904 mTimeLabels->updateConfig();
905 mAgenda->storePosition(); 905 mAgenda->storePosition();
906 mAgenda->updateConfig(); 906 mAgenda->updateConfig();
907 mAllDayAgenda->updateConfig(); 907 mAllDayAgenda->updateConfig();
908 // widget synchronization 908 // widget synchronization
909 //TODO: find a better way, maybe signal/slot 909 //TODO: find a better way, maybe signal/slot
910 mTimeLabels->positionChanged(); 910 mTimeLabels->positionChanged();
911 911
912 // for some reason, this needs to be called explicitly 912 // for some reason, this needs to be called explicitly
913 mTimeLabels->repaint(); 913 mTimeLabels->repaint();
914 914
915 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 915 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
916 916
917 // ToolTips displaying summary of events 917 // ToolTips displaying summary of events
918 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 918 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
919 ->mEnableToolTips); 919 ->mEnableToolTips);
920 920
921 //setHolidayMasks(); 921 //setHolidayMasks();
922 922
923 //createDayLabels(); called by via updateView(); 923 //createDayLabels(); called by via updateView();
924 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 924 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
925 updateView(); 925 updateView();
926 mAgenda->restorePosition(); 926 mAgenda->restorePosition();
927} 927}
928 928
929 929
930void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 930void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
931{ 931{
932 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 932 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
933 //qDebug("KOAgendaView::updateEventDates "); 933 //qDebug("KOAgendaView::updateEventDates ");
934 QDateTime startDt,endDt; 934 QDateTime startDt,endDt;
935 QDate startDate; 935 QDate startDate;
936 int lenInSecs; 936 int lenInSecs;
937 // if ( type == KOAgenda::RESIZETOP ) 937 // if ( type == KOAgenda::RESIZETOP )
938 // qDebug("RESIZETOP "); 938 // qDebug("RESIZETOP ");
939 // if ( type == KOAgenda::RESIZEBOTTOM ) 939 // if ( type == KOAgenda::RESIZEBOTTOM )
940 // qDebug("RESIZEBOTTOM "); 940 // qDebug("RESIZEBOTTOM ");
941 // if ( type == KOAgenda::MOVE ) 941 // if ( type == KOAgenda::MOVE )
942 // qDebug("MOVE "); 942 // qDebug("MOVE ");
943 if ( item->incidence()->type() == "Event" ) { 943 if ( item->incidence()->type() == "Event" ) {
944 startDt =item->incidence()->dtStart(); 944 startDt =item->incidence()->dtStart();
945 endDt = item->incidence()->dtEnd(); 945 endDt = item->incidence()->dtEnd();
946 lenInSecs = startDt.secsTo( endDt ); 946 lenInSecs = startDt.secsTo( endDt );
947 } 947 }
948 948
949 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 949 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
950 950
951 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 951 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
952 startDate = mSelectedDates[item->mLastMoveXPos]; 952 startDate = mSelectedDates[item->mLastMoveXPos];
953 } else { 953 } else {
954 if (item->cellX() < 0) { 954 if (item->cellX() < 0) {
955 startDate = (mSelectedDates.first()).addDays(item->cellX()); 955 startDate = (mSelectedDates.first()).addDays(item->cellX());
956 } else { 956 } else {
957 startDate = mSelectedDates[item->cellX()]; 957 startDate = mSelectedDates[item->cellX()];
958 } 958 }
959 } 959 }
960 startDt.setDate(startDate); 960 startDt.setDate(startDate);
961 961
962 if (item->incidence()->doesFloat()) { 962 if (item->incidence()->doesFloat()) {
963 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 963 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
964 } else { 964 } else {
965 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 965 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
966 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 966 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
967 if ( item->incidence()->type() == "Event" ) { 967 if ( item->incidence()->type() == "Event" ) {
968 if ( type == KOAgenda::MOVE ) { 968 if ( type == KOAgenda::MOVE ) {
969 endDt = startDt.addSecs(lenInSecs); 969 endDt = startDt.addSecs(lenInSecs);
970 970
971 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 971 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
972 if (item->lastMultiItem()) { 972 if (item->lastMultiItem()) {
973 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 973 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
974 endDt.setDate(startDate. 974 endDt.setDate(startDate.
975 addDays(item->lastMultiItem()->cellX() - item->cellX())); 975 addDays(item->lastMultiItem()->cellX() - item->cellX()));
976 } else { 976 } else {
977 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 977 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
978 endDt.setDate(startDate); 978 endDt.setDate(startDate);
979 } 979 }
980 } 980 }
981 } else { 981 } else {
982 // todo 982 // todo
983 qDebug("tooooodoooooo ");
984 if (item->lastMultiItem()) { 983 if (item->lastMultiItem()) {
985 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 984 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
986 endDt.setDate(startDate. 985 endDt.setDate(startDate.
987 addDays(item->lastMultiItem()->cellX() - item->cellX())); 986 addDays(item->lastMultiItem()->cellX() - item->cellX()));
988 } else { 987 } else {
989 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 988 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
990 if ( item->cellYBottom() > 0 ) 989 if ( item->cellYBottom() > 0 )
991 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 990 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
992 else 991 else
993 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 992 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
994 endDt.setDate(startDate); 993 endDt.setDate(startDate);
995 } 994 }
996 } 995 }
997 } 996 }
998 if ( item->incidence()->type() == "Event" ) { 997 if ( item->incidence()->type() == "Event" ) {
999 item->incidence()->setDtStart(startDt); 998 item->incidence()->setDtStart(startDt);
1000 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 999 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1001 } else if ( item->incidence()->type() == "Todo" ) { 1000 } else if ( item->incidence()->type() == "Todo" ) {
1002 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 1001 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
1003 } 1002 }
1004 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1003 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1005 item->incidence()->setRevision(item->incidence()->revision()+1); 1004 item->incidence()->setRevision(item->incidence()->revision()+1);
1006 item->setItemDate(startDt.date()); 1005 item->setItemDate(startDt.date());
1007 //item->updateItem(); 1006 //item->updateItem();
1008 if ( item->incidence()->type() == "Todo" ) { 1007 if ( item->incidence()->type() == "Todo" ) {
1009 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1008 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1010 1009
1011 } 1010 }
1012 else 1011 else
1013 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1012 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1014 item->updateItem(); 1013 item->updateItem();
1015} 1014}
1016 1015
1017void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1016void KOAgendaView::showDates( const QDate &start, const QDate &end )
1018{ 1017{
1019 // kdDebug() << "KOAgendaView::selectDates" << endl; 1018 // kdDebug() << "KOAgendaView::selectDates" << endl;
1020 1019
1021 mSelectedDates.clear(); 1020 mSelectedDates.clear();
1022 // qDebug("KOAgendaView::showDates "); 1021 // qDebug("KOAgendaView::showDates ");
1023 QDate d = start; 1022 QDate d = start;
1024 while (d <= end) { 1023 while (d <= end) {
1025 mSelectedDates.append(d); 1024 mSelectedDates.append(d);
1026 d = d.addDays( 1 ); 1025 d = d.addDays( 1 );
1027 } 1026 }
1028 1027
1029 // and update the view 1028 // and update the view
1030 fillAgenda(); 1029 fillAgenda();
1031} 1030}
1032 1031
1033 1032
1034void KOAgendaView::showEvents(QPtrList<Event>) 1033void KOAgendaView::showEvents(QPtrList<Event>)
1035{ 1034{
1036 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1035 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1037} 1036}
1038 1037
1039void KOAgendaView::changeEventDisplay(Event *, int) 1038void KOAgendaView::changeEventDisplay(Event *, int)
1040{ 1039{
1041 // qDebug("KOAgendaView::changeEventDisplay "); 1040 // qDebug("KOAgendaView::changeEventDisplay ");
1042 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1041 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1043 // this should be re-written to be MUCH smarter. Right now we 1042 // this should be re-written to be MUCH smarter. Right now we
1044 // are just playing dumb. 1043 // are just playing dumb.
1045 fillAgenda(); 1044 fillAgenda();
1046} 1045}
1047 1046
1048void KOAgendaView::fillAgenda(const QDate &) 1047void KOAgendaView::fillAgenda(const QDate &)
1049{ 1048{
1050 // qDebug("KOAgendaView::fillAgenda "); 1049 // qDebug("KOAgendaView::fillAgenda ");
1051 fillAgenda(); 1050 fillAgenda();
1052} 1051}
1053 1052
1054void KOAgendaView::fillAgenda() 1053void KOAgendaView::fillAgenda()
1055{ 1054{
1056 if ( globalFlagBlockStartup ) 1055 if ( globalFlagBlockStartup )
1057 return; 1056 return;
1058 if ( globalFlagBlockAgenda == 1 ) 1057 if ( globalFlagBlockAgenda == 1 )
1059 return; 1058 return;
1060 //if ( globalFlagBlockAgenda == 2 ) 1059 //if ( globalFlagBlockAgenda == 2 )
1061 //globalFlagBlockAgenda = 0; 1060 //globalFlagBlockAgenda = 0;
1062 // globalFlagBlockPainting = false; 1061 // globalFlagBlockPainting = false;
1063 if ( globalFlagBlockAgenda == 0 ) 1062 if ( globalFlagBlockAgenda == 0 )
1064 globalFlagBlockAgenda = 1; 1063 globalFlagBlockAgenda = 1;
1065 // clearView(); 1064 // clearView();
1066 //qDebug("fillAgenda()++++ "); 1065 //qDebug("fillAgenda()++++ ");
1067 globalFlagBlockAgendaItemPaint = 1; 1066 globalFlagBlockAgendaItemPaint = 1;
1068 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1067 mAllDayAgenda->changeColumns(mSelectedDates.count());
1069 mAgenda->changeColumns(mSelectedDates.count()); 1068 mAgenda->changeColumns(mSelectedDates.count());
1070 qApp->processEvents(); 1069 qApp->processEvents();
1071 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1070 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1072 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1071 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1073 setHolidayMasks(); 1072 setHolidayMasks();
1074 1073
1075 //mAgenda->hideUnused(); 1074 //mAgenda->hideUnused();
1076 //mAllDayAgenda->hideUnused(); 1075 //mAllDayAgenda->hideUnused();
1077 1076
1078 // mAgenda->blockNextRepaint( false ); 1077 // mAgenda->blockNextRepaint( false );
1079 // mAgenda->viewport()->repaint(); 1078 // mAgenda->viewport()->repaint();
1080 // mAgenda->blockNextRepaint( true ); 1079 // mAgenda->blockNextRepaint( true );
1081 mMinY.resize(mSelectedDates.count()); 1080 mMinY.resize(mSelectedDates.count());
1082 mMaxY.resize(mSelectedDates.count()); 1081 mMaxY.resize(mSelectedDates.count());
1083 1082
1084 QPtrList<Event> dayEvents; 1083 QPtrList<Event> dayEvents;
1085 1084
1086 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1085 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1087 // Therefore, gtodoset all of them. 1086 // Therefore, gtodoset all of them.
1088 QPtrList<Todo> todos = calendar()->todos(); 1087 QPtrList<Todo> todos = calendar()->todos();
1089 1088
1090 mAgenda->setDateList(mSelectedDates); 1089 mAgenda->setDateList(mSelectedDates);
1091 1090
1092 QDate today = QDate::currentDate(); 1091 QDate today = QDate::currentDate();
1093 1092
1094 DateList::ConstIterator dit; 1093 DateList::ConstIterator dit;
1095 int curCol = 0; 1094 int curCol = 0;
1096 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1095 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1097 QDate currentDate = *dit; 1096 QDate currentDate = *dit;
1098 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1097 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1099 // << endl; 1098 // << endl;
1100 1099
1101 dayEvents = calendar()->events(currentDate,true); 1100 dayEvents = calendar()->events(currentDate,true);
1102 1101
1103 // Default values, which can never be reached 1102 // Default values, which can never be reached
1104 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1103 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1105 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1104 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1106 1105
1107 unsigned int numEvent; 1106 unsigned int numEvent;
1108 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1107 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1109 Event *event = dayEvents.at(numEvent); 1108 Event *event = dayEvents.at(numEvent);
1110 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1109 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1111 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1110 if ( event->uid().left(15) == QString("last-syncEvent-") )
1112 continue; 1111 continue;
1113 // kdDebug() << " Event: " << event->summary() << endl; 1112 // kdDebug() << " Event: " << event->summary() << endl;
1114 1113
1115 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1114 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1116 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1115 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1117 1116
1118 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1117 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1119 1118
1120 if (event->doesFloat()) { 1119 if (event->doesFloat()) {
1121 if (event->recurrence()->doesRecur()) { 1120 if (event->recurrence()->doesRecur()) {
1122 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1121 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1123 } else { 1122 } else {
1124 if (beginX <= 0 && curCol == 0) { 1123 if (beginX <= 0 && curCol == 0) {
1125 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1124 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1126 } else if (beginX == curCol) { 1125 } else if (beginX == curCol) {
1127 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1126 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1128 } 1127 }
1129 } 1128 }
1130 } else if (event->isMultiDay()) { 1129 } else if (event->isMultiDay()) {
1131 if ( event->doesRecur () ) { 1130 if ( event->doesRecur () ) {
1132 QDate dateit = currentDate; 1131 QDate dateit = currentDate;
1133 int count = 0; 1132 int count = 0;
1134 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1133 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1135 while (! event->recursOn( dateit ) && count <= max ) { 1134 while (! event->recursOn( dateit ) && count <= max ) {
1136 ++count; 1135 ++count;
1137 dateit = dateit.addDays( -1 ); 1136 dateit = dateit.addDays( -1 );
1138 } 1137 }
1139 bool ok; 1138 bool ok;
1140 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1139 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1141 if ( ok ) 1140 if ( ok )
1142 { 1141 {
1143 int secs = event->dtStart().secsTo( event->dtEnd() ); 1142 int secs = event->dtStart().secsTo( event->dtEnd() );
1144 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1143 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1145 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1144 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1146 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1145 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1147 1146
1148 } 1147 }
1149 } 1148 }
1150 int startY = mAgenda->timeToY(event->dtStart().time()); 1149 int startY = mAgenda->timeToY(event->dtStart().time());
1151 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1150 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1152 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1151 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1153 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1152 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1154 //qDebug("insert!!! "); 1153 //qDebug("insert!!! ");
1155 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1154 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1156 } 1155 }
1157 if (beginX == curCol) { 1156 if (beginX == curCol) {
1158 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1157 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1159 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1158 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1160 } else if (endX == curCol) { 1159 } else if (endX == curCol) {
1161 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1160 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1162 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1161 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1163 } else { 1162 } else {
1164 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1163 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1165 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1164 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1166 } 1165 }
1167 } else { 1166 } else {
1168 int startY = mAgenda->timeToY(event->dtStart().time()); 1167 int startY = mAgenda->timeToY(event->dtStart().time());
1169 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1168 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1170 if (endY < startY) endY = startY; 1169 if (endY < startY) endY = startY;
1171 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1170 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1172 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1171 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1173 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1172 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1174 } 1173 }
1175 } 1174 }
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 6294b98..0ef5ae4 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -970,416 +970,420 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
970 // not just 1. 970 // not just 1.
971 int dayOfYear = date.dayOfYear(); 971 int dayOfYear = date.dayOfYear();
972 if (dayOfYear % 7 != 0) 972 if (dayOfYear % 7 != 0)
973 wno = dayOfYear / 7 + 1; 973 wno = dayOfYear / 7 + 1;
974 else 974 else
975 wno =dayOfYear / 7; 975 wno =dayOfYear / 7;
976 mWeekLabels[i]->setWeekNum( wno ); 976 mWeekLabels[i]->setWeekNum( wno );
977 date = date.addDays( 7 ); 977 date = date.addDays( 7 );
978 } 978 }
979 updateView(); 979 updateView();
980} 980}
981 981
982void KOMonthView::showEvents(QPtrList<Event>) 982void KOMonthView::showEvents(QPtrList<Event>)
983{ 983{
984 qDebug("KOMonthView::selectEvents is not implemented yet. "); 984 qDebug("KOMonthView::selectEvents is not implemented yet. ");
985} 985}
986 986
987void KOMonthView::changeEventDisplay(Event *, int) 987void KOMonthView::changeEventDisplay(Event *, int)
988{ 988{
989 // this should be re-written to be much more efficient, but this 989 // this should be re-written to be much more efficient, but this
990 // quick-and-dirty-hack gets the job done for right now. 990 // quick-and-dirty-hack gets the job done for right now.
991 updateView(); 991 updateView();
992} 992}
993 993
994void KOMonthView::updateView() 994void KOMonthView::updateView()
995{ 995{
996 996
997 if ( !updatePossible ) 997 if ( !updatePossible )
998 return; 998 return;
999 //QTime ti; 999 //QTime ti;
1000 //ti.start(); 1000 //ti.start();
1001#if 1 1001#if 1
1002 int i; 1002 int i;
1003 int timeSpan = mCells.size()-1; 1003 int timeSpan = mCells.size()-1;
1004 if ( KOPrefs::instance()->mMonthViewWeek ) 1004 if ( KOPrefs::instance()->mMonthViewWeek )
1005 timeSpan = 6; 1005 timeSpan = 6;
1006 for( i = 0; i < timeSpan + 1; ++i ) { 1006 for( i = 0; i < timeSpan + 1; ++i ) {
1007 mCells[i]->startUpdateCell(); 1007 mCells[i]->startUpdateCell();
1008 } 1008 }
1009 1009
1010 QPtrList<Event> events = calendar()->events(); 1010 QPtrList<Event> events = calendar()->events();
1011 Event *event; 1011 Event *event;
1012 QDateTime dt; 1012 QDateTime dt;
1013 bool ok; 1013 bool ok;
1014 QDate endDate = mStartDate.addDays( timeSpan ); 1014 QDate endDate = mStartDate.addDays( timeSpan );
1015 for( event = events.first(); event; event = events.next() ) { // for event 1015 for( event = events.first(); event; event = events.next() ) { // for event
1016 if ( event->doesRecur() ) { 1016 if ( event->doesRecur() ) {
1017 bool last; 1017 bool last;
1018 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1018 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1019 QDateTime incidenceEnd; 1019 QDateTime incidenceEnd;
1020 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1020 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1021 bool invalid = false; 1021 bool invalid = false;
1022 while( true ) { 1022 while( true ) {
1023 if ( incidenceStart.isValid() ) { 1023 if ( incidenceStart.isValid() ) {
1024 incidenceEnd = incidenceStart.addDays( eventlen ); 1024 incidenceEnd = incidenceStart.addDays( eventlen );
1025 int st = incidenceStart.date().daysTo( endDate ); 1025 int st = incidenceStart.date().daysTo( endDate );
1026 if ( st >= 0 ) { // start before timeend 1026 if ( st >= 0 ) { // start before timeend
1027 int end = mStartDate.daysTo( incidenceEnd.date() ); 1027 int end = mStartDate.daysTo( incidenceEnd.date() );
1028 if ( end >= 0 ) { // end after timestart --- got one! 1028 if ( end >= 0 ) { // end after timestart --- got one!
1029 //normalize 1029 //normalize
1030 st = timeSpan - st; 1030 st = timeSpan - st;
1031 if ( st < 0 ) st = 0; 1031 if ( st < 0 ) st = 0;
1032 if ( end > timeSpan ) end = timeSpan; 1032 if ( end > timeSpan ) end = timeSpan;
1033 int iii; 1033 int iii;
1034 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1034 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1035 for ( iii = st;iii<= end;++iii) 1035 for ( iii = st;iii<= end;++iii)
1036 mCells[iii]->insertEvent( event ); 1036 mCells[iii]->insertEvent( event );
1037 } 1037 }
1038 } 1038 }
1039 } else { 1039 } else {
1040 if ( invalid ) 1040 if ( invalid )
1041 break; 1041 break;
1042 invalid = true; 1042 invalid = true;
1043 //qDebug("invalid %s", event->summary().latin1()); 1043 //qDebug("invalid %s", event->summary().latin1());
1044 incidenceStart = QDateTime( mStartDate ); 1044 incidenceStart = QDateTime( mStartDate );
1045 } 1045 }
1046 if ( last ) 1046 if ( last )
1047 break; 1047 break;
1048 bool ok; 1048 bool ok;
1049 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1049 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1050 if ( ! ok ) 1050 if ( ! ok )
1051 break; 1051 break;
1052 if ( incidenceStart.date() > endDate ) 1052 if ( incidenceStart.date() > endDate )
1053 break; 1053 break;
1054 } 1054 }
1055 } else { // no recur 1055 } else { // no recur
1056 int st = event->dtStart().date().daysTo( endDate ); 1056 int st = event->dtStart().date().daysTo( endDate );
1057 if ( st >= 0 ) { // start before timeend 1057 if ( st >= 0 ) { // start before timeend
1058 int end = mStartDate.daysTo( event->dtEnd().date() ); 1058 int end = mStartDate.daysTo( event->dtEnd().date() );
1059 if ( end >= 0 ) { // end after timestart --- got one! 1059 if ( end >= 0 ) { // end after timestart --- got one!
1060 //normalize 1060 //normalize
1061 st = timeSpan - st; 1061 st = timeSpan - st;
1062 if ( st < 0 ) st = 0; 1062 if ( st < 0 ) st = 0;
1063 if ( end > timeSpan ) end = timeSpan; 1063 if ( end > timeSpan ) end = timeSpan;
1064 int iii; 1064 int iii;
1065 for ( iii = st;iii<= end;++iii) 1065 for ( iii = st;iii<= end;++iii)
1066 mCells[iii]->insertEvent( event ); 1066 mCells[iii]->insertEvent( event );
1067 } 1067 }
1068 } 1068 }
1069 } 1069 }
1070 } 1070 }
1071 // insert due todos 1071 // insert due todos
1072 QPtrList<Todo> todos = calendar()->todos( ); 1072 QPtrList<Todo> todos = calendar()->todos( );
1073 Todo *todo; 1073 Todo *todo;
1074 for(todo = todos.first(); todo; todo = todos.next()) { 1074 for(todo = todos.first(); todo; todo = todos.next()) {
1075 //insertTodo( todo ); 1075 //insertTodo( todo );
1076 if ( todo->hasDueDate() ) { 1076 if ( todo->hasDueDate() ) {
1077 int day = mStartDate.daysTo( todo->dtDue().date() ); 1077 int day = mStartDate.daysTo( todo->dtDue().date() );
1078 if ( day >= 0 && day < timeSpan + 1) { 1078 if ( day >= 0 && day < timeSpan + 1) {
1079 mCells[day]->insertTodo( todo ); 1079 mCells[day]->insertTodo( todo );
1080 } 1080 }
1081 } 1081 }
1082 } 1082 }
1083 1083
1084 for( i = 0; i < timeSpan+1; ++i ) { 1084 for( i = 0; i < timeSpan+1; ++i ) {
1085 mCells[i]->finishUpdateCell(); 1085 mCells[i]->finishUpdateCell();
1086 } 1086 }
1087 processSelectionChange(); 1087 processSelectionChange();
1088 mCells[0]->setFocus(); 1088 mCells[0]->setFocus();
1089 1089
1090 1090
1091#else 1091#else
1092 // old code 1092 // old code
1093 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1093 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1094 int i; 1094 int i;
1095 for( i = 0; i < mCells.count(); ++i ) { 1095 for( i = 0; i < mCells.count(); ++i ) {
1096 mCells[i]->updateCell(); 1096 mCells[i]->updateCell();
1097 } 1097 }
1098 1098
1099 //qDebug("KOMonthView::updateView() "); 1099 //qDebug("KOMonthView::updateView() ");
1100 processSelectionChange(); 1100 processSelectionChange();
1101 // qDebug("---------------------------------------------------------------------+ "); 1101 // qDebug("---------------------------------------------------------------------+ ");
1102 mCells[0]->setFocus(); 1102 mCells[0]->setFocus();
1103#endif 1103#endif
1104 1104
1105 //qDebug("update time %d ", ti.elapsed()); 1105 //qDebug("update time %d ", ti.elapsed());
1106} 1106}
1107 1107
1108void KOMonthView::resizeEvent(QResizeEvent * e) 1108void KOMonthView::resizeEvent(QResizeEvent * e)
1109{ 1109{
1110 computeLayout(); 1110 computeLayout();
1111 mCells[0]->setFocus(); 1111 mCells[0]->setFocus();
1112} 1112}
1113void KOMonthView::computeLayoutWeek() 1113void KOMonthView::computeLayoutWeek()
1114{ 1114{
1115 1115
1116 int daysToShow; 1116 int daysToShow;
1117 bool combinedSatSun = false; 1117 bool combinedSatSun = false;
1118 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1118 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1119 daysToShow = 6; 1119 daysToShow = 6;
1120 combinedSatSun = true; 1120 combinedSatSun = true;
1121 } 1121 }
1122 int tWid = topLevelWidget()->size().width(); 1122 int tWid = topLevelWidget()->size().width();
1123 int tHei = topLevelWidget()->size().height(); 1123 int tHei = topLevelWidget()->size().height();
1124 1124
1125 int wid = size().width();//e 1125 int wid = size().width();//e
1126 int hei = size().height()-1; 1126 int hei = size().height()-1;
1127 1127
1128 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1128 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1129 return; 1129 return;
1130 1130
1131 if ( wid < hei ) 1131 if ( wid < hei )
1132 daysToShow = 2; 1132 daysToShow = 2;
1133 else 1133 else
1134 daysToShow = 3; 1134 daysToShow = 3;
1135 mShowSatSunComp = true; 1135 mShowSatSunComp = true;
1136 combinedSatSun = true; 1136 combinedSatSun = true;
1137 1137
1138 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1138 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1139 QFontMetrics fm ( mWeekLabels[0]->font() ); 1139 QFontMetrics fm ( mWeekLabels[0]->font() );
1140 int weeklabelwid = fm.width( "888" ); 1140 int weeklabelwid = fm.width( "888" );
1141 wid -= weeklabelwid; 1141 wid -= weeklabelwid;
1142 1142
1143 int colWid = wid / daysToShow; 1143 int colWid = wid / daysToShow;
1144 int lastCol = wid - ( colWid*6 ); 1144 int lastCol = wid - ( colWid*6 );
1145 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1145 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1146 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1146 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1147 int colModulo = wid % daysToShow; 1147 int colModulo = wid % daysToShow;
1148 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1148 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1149 //qDebug("rowmod %d ", rowModulo); 1149 //qDebug("rowmod %d ", rowModulo);
1150 int i; 1150 int i;
1151 int x,y,w,h; 1151 int x,y,w,h;
1152 x= 0; 1152 x= 0;
1153 y= 0; 1153 y= 0;
1154 w = colWid; 1154 w = colWid;
1155 h = dayLabelHei ; 1155 h = dayLabelHei ;
1156 for ( i = 0; i < 7; i++) { 1156 for ( i = 0; i < 7; i++) {
1157 if ( i && !( i % daysToShow) && i < 6) { 1157 if ( i && !( i % daysToShow) && i < 6) {
1158 y += hei/(5-daysToShow); 1158 y += hei/(5-daysToShow);
1159 x = 0; 1159 x = 0;
1160 w = colWid; 1160 w = colWid;
1161 } 1161 }
1162 if ( i == daysToShow-colModulo ) 1162 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1163 ++w; 1163 ++w;
1164 }
1164 if ( i >= 5 ) { 1165 if ( i >= 5 ) {
1165 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+1,h); 1166 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1166 x -= w/2 ; 1167 x -= (w/2 );
1167 } 1168 }
1168 else 1169 else
1169 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1170 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1170 x += w; 1171 x += w;
1171 } 1172 }
1172 x= 0; 1173 x= 0;
1173 y= dayLabelHei; 1174 y= dayLabelHei;
1174 w = colWid; 1175 w = colWid;
1175 h = cellHei; 1176 h = cellHei;
1176 for ( i = 0; i < mCells.count(); ++i) { 1177 for ( i = 0; i < mCells.count(); ++i) {
1177 if ( i > 6 ) { 1178 if ( i > 6 ) {
1178 mCells[i]->hide(); 1179 mCells[i]->hide();
1179 continue; 1180 continue;
1180 } 1181 }
1181 1182
1182 w = colWid; 1183 w = colWid;
1183 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1184 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1184 ++w; 1185 ++w;
1185 } 1186 }
1186 if ( i == (daysToShow-1-rowModulo)*7) 1187 if ( i == (daysToShow-1-rowModulo)*7)
1187 ++h; 1188 ++h;
1188 1189
1189 if ( i >= 5 ) { 1190 if ( i >= 5 ) {
1190 if ( i ==5 ) { 1191 if ( i ==5 ) {
1191 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1192 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1192 x -= w ;y += h/2; 1193 x -= w ;y += h/2;
1193 } else { 1194 } else {
1195 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1196 ++w;
1197 }
1194 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1198 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1195 y -= h/2; 1199 y -= h/2;
1196 } 1200 }
1197 } else 1201 } else
1198 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1202 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1199 1203
1200 1204
1201 x += w; 1205 x += w;
1202 if ( x + w/2 > wid ) { 1206 if ( x + w/2 > wid ) {
1203 x = 0; 1207 x = 0;
1204 y += h+dayLabelHei ; 1208 y += h+dayLabelHei ;
1205 } 1209 }
1206 } 1210 }
1207 y= dayLabelHei; 1211 y= dayLabelHei;
1208 h = cellHei ; 1212 h = cellHei ;
1209 mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1213 mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1210 for ( i = 1; i < 6; i++) { 1214 for ( i = 1; i < 6; i++) {
1211 mWeekLabels[i]->hide(); 1215 mWeekLabels[i]->hide();
1212 } 1216 }
1213 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1217 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1214 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1218 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1215 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1219 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1216 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1220 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1217 updateDayLabels(); 1221 updateDayLabels();
1218 bool forceUpdate = !updatePossible; 1222 bool forceUpdate = !updatePossible;
1219 updatePossible = true; 1223 updatePossible = true;
1220 mWeekLabels[mNumWeeks]->setText( i18n("M")); 1224 mWeekLabels[mNumWeeks]->setText( i18n("M"));
1221 if ( forceUpdate ) 1225 if ( forceUpdate )
1222 updateView(); 1226 updateView();
1223} 1227}
1224void KOMonthView::computeLayout() 1228void KOMonthView::computeLayout()
1225{ 1229{
1226 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 1230 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
1227 // note this only changes the text if the requested size crosses the 1231 // note this only changes the text if the requested size crosses the
1228 // threshold between big enough to support the full name and not big 1232 // threshold between big enough to support the full name and not big
1229 // enough. 1233 // enough.
1230 if ( mShowWeekView ){ 1234 if ( mShowWeekView ){
1231 computeLayoutWeek(); 1235 computeLayoutWeek();
1232 return; 1236 return;
1233 } 1237 }
1234 int daysToShow = 7; 1238 int daysToShow = 7;
1235 bool combinedSatSun = false; 1239 bool combinedSatSun = false;
1236 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1240 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1237 daysToShow = 6; 1241 daysToShow = 6;
1238 combinedSatSun = true; 1242 combinedSatSun = true;
1239 } 1243 }
1240 int tWid = topLevelWidget()->size().width(); 1244 int tWid = topLevelWidget()->size().width();
1241 int tHei = topLevelWidget()->size().height(); 1245 int tHei = topLevelWidget()->size().height();
1242 1246
1243 int wid = size().width();//e 1247 int wid = size().width();//e
1244 int hei = size().height()-1; 1248 int hei = size().height()-1;
1245 1249
1246 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1250 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1247 return; 1251 return;
1248 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1252 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1249 QFontMetrics fm ( mWeekLabels[0]->font() ); 1253 QFontMetrics fm ( mWeekLabels[0]->font() );
1250 int weeklabelwid = fm.width( "888" ); 1254 int weeklabelwid = fm.width( "888" );
1251 wid -= weeklabelwid; 1255 wid -= weeklabelwid;
1252 1256
1253 int colWid = wid / daysToShow; 1257 int colWid = wid / daysToShow;
1254 int lastCol = wid - ( colWid*6 ); 1258 int lastCol = wid - ( colWid*6 );
1255 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1259 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1256 int cellHei = (hei - dayLabelHei) /6; 1260 int cellHei = (hei - dayLabelHei) /6;
1257 int colModulo = wid % daysToShow; 1261 int colModulo = wid % daysToShow;
1258 int rowModulo = (hei- dayLabelHei) % 6; 1262 int rowModulo = (hei- dayLabelHei) % 6;
1259 //qDebug("rowmod %d ", rowModulo); 1263 //qDebug("rowmod %d ", rowModulo);
1260 int i; 1264 int i;
1261 int x,y,w,h; 1265 int x,y,w,h;
1262 x= 0; 1266 x= 0;
1263 y= 0; 1267 y= 0;
1264 w = colWid; 1268 w = colWid;
1265 h = dayLabelHei ; 1269 h = dayLabelHei ;
1266 for ( i = 0; i < 7; i++) { 1270 for ( i = 0; i < 7; i++) {
1267 if ( i == daysToShow-colModulo ) 1271 if ( i == daysToShow-colModulo )
1268 ++w; 1272 ++w;
1269 if ( combinedSatSun ) { 1273 if ( combinedSatSun ) {
1270 if ( i >= daysToShow-1 ) { 1274 if ( i >= daysToShow-1 ) {
1271 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1275 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1272 x -= w/2 ; 1276 x -= w/2 ;
1273 } 1277 }
1274 else 1278 else
1275 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1279 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1276 } else 1280 } else
1277 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1281 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1278 x += w; 1282 x += w;
1279 } 1283 }
1280 x= 0; 1284 x= 0;
1281 y= dayLabelHei; 1285 y= dayLabelHei;
1282 w = colWid; 1286 w = colWid;
1283 h = cellHei ; 1287 h = cellHei ;
1284 for ( i = 0; i < mCells.count(); ++i) { 1288 for ( i = 0; i < mCells.count(); ++i) {
1285 mCells[i]->show(); 1289 mCells[i]->show();
1286 w = colWid; 1290 w = colWid;
1287 if ( ((i) % 7) >= 7-colModulo ) { 1291 if ( ((i) % 7) >= 7-colModulo ) {
1288 ++w; 1292 ++w;
1289 } 1293 }
1290 if ( i == (6-rowModulo)*7) 1294 if ( i == (6-rowModulo)*7)
1291 ++h; 1295 ++h;
1292 if ( combinedSatSun ) { 1296 if ( combinedSatSun ) {
1293 if ( (i)%7 >= daysToShow-1 ) { 1297 if ( (i)%7 >= daysToShow-1 ) {
1294 if ( (i)%7 == daysToShow-1 ) { 1298 if ( (i)%7 == daysToShow-1 ) {
1295 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1299 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1296 x -= w ;y += h/2; 1300 x -= w ;y += h/2;
1297 } else { 1301 } else {
1298 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1302 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1299 y -= h/2; 1303 y -= h/2;
1300 } 1304 }
1301 } else 1305 } else
1302 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1306 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1303 1307
1304 } 1308 }
1305 else 1309 else
1306 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1310 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1307 x += w; 1311 x += w;
1308 if ( x + w/2 > wid ) { 1312 if ( x + w/2 > wid ) {
1309 x = 0; 1313 x = 0;
1310 y += h; 1314 y += h;
1311 } 1315 }
1312 } 1316 }
1313 y= dayLabelHei; 1317 y= dayLabelHei;
1314 h = cellHei ; 1318 h = cellHei ;
1315 for ( i = 0; i < 6; i++) { 1319 for ( i = 0; i < 6; i++) {
1316 mWeekLabels[i]->show(); 1320 mWeekLabels[i]->show();
1317 if ( i == (6-rowModulo)) 1321 if ( i == (6-rowModulo))
1318 ++h; 1322 ++h;
1319 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1323 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1320 y += h; 1324 y += h;
1321 } 1325 }
1322 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1326 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1323 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1327 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1324 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1328 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1325 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1329 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1326 updateDayLabels(); 1330 updateDayLabels();
1327 bool forceUpdate = !updatePossible; 1331 bool forceUpdate = !updatePossible;
1328 updatePossible = true; 1332 updatePossible = true;
1329 mWeekLabels[mNumWeeks]->setText( i18n("W")); 1333 mWeekLabels[mNumWeeks]->setText( i18n("W"));
1330 if ( forceUpdate ) 1334 if ( forceUpdate )
1331 updateView(); 1335 updateView();
1332} 1336}
1333 1337
1334void KOMonthView::showContextMenu( Incidence *incidence ) 1338void KOMonthView::showContextMenu( Incidence *incidence )
1335{ 1339{
1336 mContextMenu->showIncidencePopup(incidence); 1340 mContextMenu->showIncidencePopup(incidence);
1337 /* 1341 /*
1338 if( incidence && incidence->type() == "Event" ) { 1342 if( incidence && incidence->type() == "Event" ) {
1339 Event *event = static_cast<Event *>(incidence); 1343 Event *event = static_cast<Event *>(incidence);
1340 mContextMenu->showEventPopup(event); 1344 mContextMenu->showEventPopup(event);
1341 } else { 1345 } else {
1342 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1346 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1343 } 1347 }
1344 */ 1348 */
1345} 1349}
1346MonthViewCell * KOMonthView::selectedCell( ) 1350MonthViewCell * KOMonthView::selectedCell( )
1347{ 1351{
1348 return mSelectedCell; 1352 return mSelectedCell;
1349} 1353}
1350void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1354void KOMonthView::setSelectedCell( MonthViewCell *cell )
1351{ 1355{
1352 // qDebug("KOMonthView::setSelectedCell "); 1356 // qDebug("KOMonthView::setSelectedCell ");
1353 if ( mSelectedCell && mSelectedCell != cell ) { 1357 if ( mSelectedCell && mSelectedCell != cell ) {
1354 MonthViewCell * mvc = mSelectedCell; 1358 MonthViewCell * mvc = mSelectedCell;
1355 mSelectedCell = cell; 1359 mSelectedCell = cell;
1356 mvc->deselect(); 1360 mvc->deselect();
1357 } else 1361 } else
1358 mSelectedCell = cell; 1362 mSelectedCell = cell;
1359 // if ( mSelectedCell ) 1363 // if ( mSelectedCell )
1360 // mSelectedCell->select(); 1364 // mSelectedCell->select();
1361 if ( !mSelectedCell ) 1365 if ( !mSelectedCell )
1362 emit incidenceSelected( 0 ); 1366 emit incidenceSelected( 0 );
1363 else 1367 else
1364 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1368 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1365} 1369}
1366 1370
1367void KOMonthView::processSelectionChange() 1371void KOMonthView::processSelectionChange()
1368{ 1372{
1369 QPtrList<Incidence> incidences = selectedIncidences(); 1373 QPtrList<Incidence> incidences = selectedIncidences();
1370 if (incidences.count() > 0) { 1374 if (incidences.count() > 0) {
1371 emit incidenceSelected( incidences.first() ); 1375 emit incidenceSelected( incidences.first() );
1372 } else { 1376 } else {
1373 emit incidenceSelected( 0 ); 1377 emit incidenceSelected( 0 );
1374 } 1378 }
1375} 1379}
1376 1380
1377void KOMonthView::clearSelection() 1381void KOMonthView::clearSelection()
1378{ 1382{
1379 if ( mSelectedCell ) { 1383 if ( mSelectedCell ) {
1380 mSelectedCell->deselect(); 1384 mSelectedCell->deselect();
1381 mSelectedCell = 0; 1385 mSelectedCell = 0;
1382 } 1386 }
1383} 1387}
1384void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1388void KOMonthView::keyPressEvent ( QKeyEvent * e )
1385{ 1389{
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 6afd203..8aa0697 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,321 +1,318 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 20
21 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.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#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 64
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") showMonthView(); 91 else if (view == "Month") showMonthView();
92 else if (view == "List") showListView(); 92 else if (view == "List") showListView();
93 else if (view == "Journal") showJournalView(); 93 else if (view == "Journal") showJournalView();
94 else if (view == "TimeSpan") showTimeSpanView(); 94 else if (view == "TimeSpan") showTimeSpanView();
95 else if (view == "Todo") showTodoView(); 95 else if (view == "Todo") showTodoView();
96 else { 96 else {
97 showAgendaView(); 97 showAgendaView();
98 } 98 }
99} 99}
100 100
101void KOViewManager::showDateView( int view, QDate date) 101void KOViewManager::showDateView( int view, QDate date)
102{ 102{
103 static int lastMode = 0; 103 static int lastMode = 0;
104 static int lastCount = 0; 104 static int lastCount = 0;
105 static bool lastNDMode = false; 105 static bool lastNDMode = false;
106 static QDate lastDate; 106 static QDate lastDate;
107 //qDebug("date %d %s", view, date.toString().latin1()); 107 //qDebug("date %d %s", view, date.toString().latin1());
108 108
109 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 109 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
110 bool savemFlagShowNextxDays = mFlagShowNextxDays; 110 bool savemFlagShowNextxDays = mFlagShowNextxDays;
111 mFlagShowNextxDays = false; 111 mFlagShowNextxDays = false;
112 if ( view == 3 ) { 112 if ( view == 3 ) {
113 //mCurrentAgendaView = 1 ; 113 //mCurrentAgendaView = 1 ;
114 lastDate = mMainView->dateNavigator()->selectedDates().first(); 114 lastDate = mMainView->dateNavigator()->selectedDates().first();
115 lastCount = mMainView->dateNavigator()->selectedDates().count(); 115 lastCount = mMainView->dateNavigator()->selectedDates().count();
116 lastNDMode = savemFlagShowNextxDays; 116 lastNDMode = savemFlagShowNextxDays;
117 mMainView->showDay( date ); 117 mMainView->showDay( date );
118 } else if (view == 4 ) { 118 } else if (view == 4 ) {
119 mCurrentAgendaView = 7 ; 119 mCurrentAgendaView = 7 ;
120 mMainView->dateNavigator()->selectDates( date, 7 ); 120 mMainView->dateNavigator()->selectDates( date, 7 );
121 } else if (view == 5 ) { 121 } else if (view == 5 ) {
122 mCurrentAgendaView = 14 ; 122 mCurrentAgendaView = 14 ;
123 mMainView->dateNavigator()->selectDates( date, 14); 123 mMainView->dateNavigator()->selectDates( date, 14);
124 } else if (view == 6 ) { 124 } else if (view == 6 ) {
125 mMainView->dateNavigator()->blockSignals( true ); 125 mMainView->dateNavigator()->selectDates( date, 7 );
126 showMonthView(); 126 showMonthView();
127 mMainView->dateNavigator()->selectMonthByDate( date );
128 mMainView->dateNavigator()->blockSignals( false );
129 mMainView->dateNavigator()->selectDate( date );
130 } else if (view == 7 ) { 127 } else if (view == 7 ) {
131 mMainView->dateNavigator()->selectDate( date ); 128 mMainView->dateNavigator()->selectDate( date );
132 showJournalView(); 129 showJournalView();
133 } else if (view == 8 ) { 130 } else if (view == 8 ) {
134 globalFlagBlockAgenda = 1; 131 globalFlagBlockAgenda = 1;
135 if ( mCurrentAgendaView != 3 ) 132 if ( mCurrentAgendaView != 3 )
136 mCurrentAgendaView = -1; 133 mCurrentAgendaView = -1;
137 showAgendaView(KOPrefs::instance()->mFullViewMonth); 134 showAgendaView(KOPrefs::instance()->mFullViewMonth);
138 globalFlagBlockAgenda = 2; 135 globalFlagBlockAgenda = 2;
139 mMainView->dateNavigator()->selectDates( date , 136 mMainView->dateNavigator()->selectDates( date ,
140 KOPrefs::instance()->mNextXDays ); 137 KOPrefs::instance()->mNextXDays );
141 mFlagShowNextxDays = true; 138 mFlagShowNextxDays = true;
142 mCurrentAgendaView = 3 ; 139 mCurrentAgendaView = 3 ;
143 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 140 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
144 if ( lastMode ) { 141 if ( lastMode ) {
145 mCurrentAgendaView = lastCount ; 142 mCurrentAgendaView = lastCount ;
146 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 143 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
147 mFlagShowNextxDays = lastNDMode; 144 mFlagShowNextxDays = lastNDMode;
148 if ( mFlagShowNextxDays ) { 145 if ( mFlagShowNextxDays ) {
149 mCurrentAgendaView = 3 ; 146 mCurrentAgendaView = 3 ;
150 } 147 }
151 } else 148 } else
152 showWeekView(); 149 showWeekView();
153 } else if (view == 10) { 150 } else if (view == 10) {
154 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 151 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
155 } 152 }
156 lastMode = view; 153 lastMode = view;
157} 154}
158 155
159 156
160 157
161void KOViewManager::writeSettings(KConfig *config) 158void KOViewManager::writeSettings(KConfig *config)
162{ 159{
163 config->setGroup("General"); 160 config->setGroup("General");
164 161
165 QString view; 162 QString view;
166 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 163 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
167 else if (mCurrentView == mMonthView) view = "Month"; 164 else if (mCurrentView == mMonthView) view = "Month";
168 else if (mCurrentView == mListView) view = "List"; 165 else if (mCurrentView == mListView) view = "List";
169 else if (mCurrentView == mJournalView) view = "Journal"; 166 else if (mCurrentView == mJournalView) view = "Journal";
170 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 167 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
171 else if (mCurrentView == mTodoView) view = "Todo"; 168 else if (mCurrentView == mTodoView) view = "Todo";
172 else view = "Agenda"; 169 else view = "Agenda";
173 170
174 config->writeEntry("Current View",view); 171 config->writeEntry("Current View",view);
175 172
176 if (mAgendaView) { 173 if (mAgendaView) {
177 mAgendaView->writeSettings(config); 174 mAgendaView->writeSettings(config);
178 } 175 }
179 if (mTimeSpanView) { 176 if (mTimeSpanView) {
180 mTimeSpanView->writeSettings(config); 177 mTimeSpanView->writeSettings(config);
181 } 178 }
182 if (mListView) { 179 if (mListView) {
183 mListView->writeSettings(config); 180 mListView->writeSettings(config);
184 } 181 }
185 if (mTodoView) { 182 if (mTodoView) {
186 mTodoView->saveLayout(config,"Todo View"); 183 mTodoView->saveLayout(config,"Todo View");
187 } 184 }
188} 185}
189 186
190void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 187void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
191{ 188{
192 189
193 //mFlagShowNextxDays = false; 190 //mFlagShowNextxDays = false;
194 //if(view == mCurrentView) return; 191 //if(view == mCurrentView) return;
195 if ( view == 0 ) { 192 if ( view == 0 ) {
196 view = mCurrentView; 193 view = mCurrentView;
197 if ( view == 0 ) 194 if ( view == 0 )
198 return; 195 return;
199 } 196 }
200 bool full = fullScreen; 197 bool full = fullScreen;
201 if(view == mCurrentView && view != mWhatsNextView ) { 198 if(view == mCurrentView && view != mWhatsNextView ) {
202 if ( mCurrentAgendaView < 0 ) 199 if ( mCurrentAgendaView < 0 )
203 return; 200 return;
204 full = mMainView->leftFrame()->isVisible(); 201 full = mMainView->leftFrame()->isVisible();
205 } else { 202 } else {
206 mCurrentView = view; 203 mCurrentView = view;
207 // bool full = fullScreen; 204 // bool full = fullScreen;
208 bool isFull = !mMainView->leftFrame()->isVisible(); 205 bool isFull = !mMainView->leftFrame()->isVisible();
209 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 206 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
210 full = true; 207 full = true;
211 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 208 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
212 full = false; 209 full = false;
213 } 210 }
214 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 211 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
215 //raiseCurrentView( full ); 212 //raiseCurrentView( full );
216 mMainView->processIncidenceSelection( 0 ); 213 mMainView->processIncidenceSelection( 0 );
217 //mMainView->updateView(); 214 //mMainView->updateView();
218 raiseCurrentView( full, true ); 215 raiseCurrentView( full, true );
219 mMainView->adaptNavigationUnits(); 216 mMainView->adaptNavigationUnits();
220} 217}
221 218
222void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 219void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
223{ 220{
224 mCurrentAgendaView = 0; 221 mCurrentAgendaView = 0;
225 int wid = mMainView->width() ; 222 int wid = mMainView->width() ;
226 int hei = mMainView->height(); 223 int hei = mMainView->height();
227 if ( mCurrentView == mMonthView ) { 224 if ( mCurrentView == mMonthView ) {
228 if ( !KOPrefs::instance()->mMonthViewWeek ) { 225 if ( !KOPrefs::instance()->mMonthViewWeek ) {
229 mMainView->navigatorBar()->show(); 226 mMainView->navigatorBar()->show();
230 hei -= mMainView->navigatorBar()->sizeHint().height(); 227 hei -= mMainView->navigatorBar()->sizeHint().height();
231 } 228 }
232 //mMainView->navigatorBar()->hide(); 229 //mMainView->navigatorBar()->hide();
233 } else { 230 } else {
234 mMainView->navigatorBar()->hide(); 231 mMainView->navigatorBar()->hide();
235 } 232 }
236 if ( fullScreen ) { 233 if ( fullScreen ) {
237 mMainView->leftFrame()->hide(); 234 mMainView->leftFrame()->hide();
238 } else { 235 } else {
239 mMainView->leftFrame()->show(); 236 mMainView->leftFrame()->show();
240 if ( KOPrefs::instance()->mVerticalScreen ) 237 if ( KOPrefs::instance()->mVerticalScreen )
241 hei -= mMainView->leftFrame()->height(); 238 hei -= mMainView->leftFrame()->height();
242 else 239 else
243 wid -= mMainView->leftFrame()->width(); 240 wid -= mMainView->leftFrame()->width();
244 } 241 }
245 emit signalFullScreen( !fullScreen ); 242 emit signalFullScreen( !fullScreen );
246 if ( callUpdateView ) 243 if ( callUpdateView )
247 mMainView->updateView(); 244 mMainView->updateView();
248 245
249 if ( globalFlagBlockAgenda == 5 ) { 246 if ( globalFlagBlockAgenda == 5 ) {
250 globalFlagBlockAgenda = 4; 247 globalFlagBlockAgenda = 4;
251 globalFlagBlockAgendaItemPaint = 1; 248 globalFlagBlockAgendaItemPaint = 1;
252 } 249 }
253 mMainView->viewStack()->raiseWidget(mCurrentView); 250 mMainView->viewStack()->raiseWidget(mCurrentView);
254 if ( globalFlagBlockAgenda == 4 ) { 251 if ( globalFlagBlockAgenda == 4 ) {
255 if ( mCurrentView == mAgendaView ) { 252 if ( mCurrentView == mAgendaView ) {
256 //globalFlagBlockAgenda =1 ; 253 //globalFlagBlockAgenda =1 ;
257 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 254 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
258 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 255 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
259 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 256 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
260 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 257 mAgendaView->setStartHour( QTime::currentTime ().hour() );
261 qApp->processEvents(); 258 qApp->processEvents();
262 //qDebug("qApp->processEvents() "); 259 //qDebug("qApp->processEvents() ");
263 globalFlagBlockAgenda = 0; 260 globalFlagBlockAgenda = 0;
264 mAgendaView->repaintAgenda(); 261 mAgendaView->repaintAgenda();
265 262
266 } 263 }
267 globalFlagBlockAgenda = 0; 264 globalFlagBlockAgenda = 0;
268 } 265 }
269 emit signalAgendaView( mCurrentView == mAgendaView ); 266 emit signalAgendaView( mCurrentView == mAgendaView );
270 //qDebug("raiseCurrentView ende "); 267 //qDebug("raiseCurrentView ende ");
271 268
272} 269}
273 270
274void KOViewManager::updateView() 271void KOViewManager::updateView()
275{ 272{
276 // qDebug("KOViewManager::updateView() "); 273 // qDebug("KOViewManager::updateView() ");
277 // if we are updating mTodoView, we get endless recursion 274 // if we are updating mTodoView, we get endless recursion
278 if ( mTodoView == mCurrentView ) 275 if ( mTodoView == mCurrentView )
279 return; 276 return;
280 if ( mCurrentView ) mCurrentView->updateView(); 277 if ( mCurrentView ) mCurrentView->updateView();
281 278
282} 279}
283 280
284void KOViewManager::updateView(const QDate &start, const QDate &end) 281void KOViewManager::updateView(const QDate &start, const QDate &end)
285{ 282{
286 // kdDebug() << "KOViewManager::updateView()" << endl; 283 // kdDebug() << "KOViewManager::updateView()" << endl;
287 284
288 if (mCurrentView) mCurrentView->showDates(start, end); 285 if (mCurrentView) mCurrentView->showDates(start, end);
289 286
290 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 287 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
291} 288}
292 289
293 290
294void KOViewManager::updateWNview() 291void KOViewManager::updateWNview()
295{ 292{
296 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 293 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
297 mWhatsNextView->updateView(); 294 mWhatsNextView->updateView();
298 295
299} 296}
300void KOViewManager::showWhatsNextView() 297void KOViewManager::showWhatsNextView()
301{ 298{
302 if (!mWhatsNextView) { 299 if (!mWhatsNextView) {
303 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 300 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
304 "KOViewManager::WhatsNextView"); 301 "KOViewManager::WhatsNextView");
305 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 302 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
306 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 303 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
307 addView(mWhatsNextView); 304 addView(mWhatsNextView);
308 connect(this, SIGNAL( printWNV() ), 305 connect(this, SIGNAL( printWNV() ),
309 mWhatsNextView, SLOT( printMe() ) ); 306 mWhatsNextView, SLOT( printMe() ) );
310 } 307 }
311 globalFlagBlockAgenda = 1; 308 globalFlagBlockAgenda = 1;
312 showView(mWhatsNextView, true ); 309 showView(mWhatsNextView, true );
313 //mWhatsNextView->updateView(); 310 //mWhatsNextView->updateView();
314 311
315} 312}
316 313
317void KOViewManager::showListView() 314void KOViewManager::showListView()
318{ 315{
319 if (!mListView) { 316 if (!mListView) {
320 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 317 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
321 addView(mListView); 318 addView(mListView);