summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-31 08:05:32 (UTC)
committer zautrix <zautrix>2005-01-31 08:05:32 (UTC)
commitf7663a4c854d217bcb4f828a3ebb69cc40d0dd7c (patch) (unidiff)
tree683febfff7427b923f23178e74b7cc0e50ef461d
parented5723f40a93bbedfcbd9f54e6379a23c4a76096 (diff)
downloadkdepimpi-f7663a4c854d217bcb4f828a3ebb69cc40d0dd7c.zip
kdepimpi-f7663a4c854d217bcb4f828a3ebb69cc40d0dd7c.tar.gz
kdepimpi-f7663a4c854d217bcb4f828a3ebb69cc40d0dd7c.tar.bz2
fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp2
-rw-r--r--korganizer/kodaymatrix.cpp57
-rw-r--r--korganizer/kodaymatrix.h1
3 files changed, 29 insertions, 31 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 8b79788..8e9add3 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -742,807 +742,809 @@ void KOAgendaView::createDayLabels()
742 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 742 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
743 addString = i18n("Day after tomorrow"); 743 addString = i18n("Day after tomorrow");
744 if ( !addString.isEmpty() ) { 744 if ( !addString.isEmpty() ) {
745 str = addString+", " + str; 745 str = addString+", " + str;
746 } 746 }
747 } 747 }
748 dayLabel->setText(str); 748 dayLabel->setText(str);
749 dayLabel->setAlignment(QLabel::AlignHCenter); 749 dayLabel->setAlignment(QLabel::AlignHCenter);
750 if (date == QDate::currentDate()) { 750 if (date == QDate::currentDate()) {
751 QFont bFont = dlf; 751 QFont bFont = dlf;
752 bFont.setBold( true ); 752 bFont.setBold( true );
753 dayLabel->setFont(bFont); 753 dayLabel->setFont(bFont);
754 } 754 }
755 //dayLayout->addWidget(dayLabel); 755 //dayLayout->addWidget(dayLabel);
756 756
757#ifndef KORG_NOPLUGINS 757#ifndef KORG_NOPLUGINS
758 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 758 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
759 CalendarDecoration *it; 759 CalendarDecoration *it;
760 for(it = cds.first(); it; it = cds.next()) { 760 for(it = cds.first(); it; it = cds.next()) {
761 QString text = it->shortText( date ); 761 QString text = it->shortText( date );
762 if ( !text.isEmpty() ) { 762 if ( !text.isEmpty() ) {
763 QLabel *label = new QLabel(text,mDayLabels); 763 QLabel *label = new QLabel(text,mDayLabels);
764 label->setAlignment(AlignCenter); 764 label->setAlignment(AlignCenter);
765 dayLayout->addWidget(label); 765 dayLayout->addWidget(label);
766 } 766 }
767 } 767 }
768 768
769 for(it = cds.first(); it; it = cds.next()) { 769 for(it = cds.first(); it; it = cds.next()) {
770 QWidget *wid = it->smallWidget(mDayLabels,date); 770 QWidget *wid = it->smallWidget(mDayLabels,date);
771 if ( wid ) { 771 if ( wid ) {
772 // wid->setHeight(20); 772 // wid->setHeight(20);
773 dayLayout->addWidget(wid); 773 dayLayout->addWidget(wid);
774 } 774 }
775 } 775 }
776#endif 776#endif
777 } 777 }
778 if ( ! appendLabels ) { 778 if ( ! appendLabels ) {
779 dayLabel = mDayLabelsList.next(); 779 dayLabel = mDayLabelsList.next();
780 if ( !dayLabel ) 780 if ( !dayLabel )
781 appendLabels = true; 781 appendLabels = true;
782 } 782 }
783 if ( appendLabels ) { 783 if ( appendLabels ) {
784 dayLabel = new QLabel(mDayLabels); 784 dayLabel = new QLabel(mDayLabels);
785 mDayLabelsList.append( dayLabel ); 785 mDayLabelsList.append( dayLabel );
786 mLayoutDayLabels->addWidget(dayLabel); 786 mLayoutDayLabels->addWidget(dayLabel);
787 } 787 }
788 //dayLabel->hide();//test only 788 //dayLabel->hide();//test only
789 789
790 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 790 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
791 if ( offset < 0 ) offset = 0; 791 if ( offset < 0 ) offset = 0;
792 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 792 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
793 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); 793 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) );
794 dayLabel->show(); 794 dayLabel->show();
795 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 795 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
796 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 796 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
797 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 797 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
798 if ( !appendLabels ) { 798 if ( !appendLabels ) {
799 dayLabel = mDayLabelsList.next(); 799 dayLabel = mDayLabelsList.next();
800 while ( dayLabel ) { 800 while ( dayLabel ) {
801 //qDebug("!dayLabel %d",dayLabel ); 801 //qDebug("!dayLabel %d",dayLabel );
802 dayLabel->hide(); 802 dayLabel->hide();
803 dayLabel = mDayLabelsList.next(); 803 dayLabel = mDayLabelsList.next();
804 } 804 }
805 } 805 }
806 //mDayLabelsFrame->show(); 806 //mDayLabelsFrame->show();
807 //mDayLabels->show(); 807 //mDayLabels->show();
808 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 808 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
809 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 809 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
810 mDayLabelsFrame->setFixedHeight( newHight ); 810 mDayLabelsFrame->setFixedHeight( newHight );
811} 811}
812 812
813int KOAgendaView::maxDatesHint() 813int KOAgendaView::maxDatesHint()
814{ 814{
815 // Not sure about the max number of events, so return 0 for now. 815 // Not sure about the max number of events, so return 0 for now.
816 return 0; 816 return 0;
817} 817}
818 818
819int KOAgendaView::currentDateCount() 819int KOAgendaView::currentDateCount()
820{ 820{
821 return mSelectedDates.count(); 821 return mSelectedDates.count();
822} 822}
823 823
824QPtrList<Incidence> KOAgendaView::selectedIncidences() 824QPtrList<Incidence> KOAgendaView::selectedIncidences()
825{ 825{
826 QPtrList<Incidence> selected; 826 QPtrList<Incidence> selected;
827 Incidence *incidence; 827 Incidence *incidence;
828 828
829 incidence = mAgenda->selectedIncidence(); 829 incidence = mAgenda->selectedIncidence();
830 if (incidence) selected.append(incidence); 830 if (incidence) selected.append(incidence);
831 831
832 incidence = mAllDayAgenda->selectedIncidence(); 832 incidence = mAllDayAgenda->selectedIncidence();
833 if (incidence) selected.append(incidence); 833 if (incidence) selected.append(incidence);
834 834
835 return selected; 835 return selected;
836} 836}
837 837
838DateList KOAgendaView::selectedDates() 838DateList KOAgendaView::selectedDates()
839{ 839{
840 DateList selected; 840 DateList selected;
841 QDate qd; 841 QDate qd;
842 842
843 qd = mAgenda->selectedIncidenceDate(); 843 qd = mAgenda->selectedIncidenceDate();
844 if (qd.isValid()) selected.append(qd); 844 if (qd.isValid()) selected.append(qd);
845 845
846 qd = mAllDayAgenda->selectedIncidenceDate(); 846 qd = mAllDayAgenda->selectedIncidenceDate();
847 if (qd.isValid()) selected.append(qd); 847 if (qd.isValid()) selected.append(qd);
848 848
849 return selected; 849 return selected;
850} 850}
851 851
852 852
853void KOAgendaView::updateView() 853void KOAgendaView::updateView()
854{ 854{
855 if ( mBlockUpdating ) 855 if ( mBlockUpdating )
856 return; 856 return;
857 // kdDebug() << "KOAgendaView::updateView()" << endl; 857 // kdDebug() << "KOAgendaView::updateView()" << endl;
858 fillAgenda(); 858 fillAgenda();
859 859
860} 860}
861 861
862 862
863/* 863/*
864 Update configuration settings for the agenda view. This method is not 864 Update configuration settings for the agenda view. This method is not
865 complete. 865 complete.
866*/ 866*/
867void KOAgendaView::updateConfig() 867void KOAgendaView::updateConfig()
868{ 868{
869 if ( mBlockUpdating ) 869 if ( mBlockUpdating )
870 return; 870 return;
871 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 871 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
872 872
873 // update config for children 873 // update config for children
874 mTimeLabels->updateConfig(); 874 mTimeLabels->updateConfig();
875 mAgenda->storePosition(); 875 mAgenda->storePosition();
876 mAgenda->updateConfig(); 876 mAgenda->updateConfig();
877 mAllDayAgenda->updateConfig(); 877 mAllDayAgenda->updateConfig();
878 // widget synchronization 878 // widget synchronization
879 //TODO: find a better way, maybe signal/slot 879 //TODO: find a better way, maybe signal/slot
880 mTimeLabels->positionChanged(); 880 mTimeLabels->positionChanged();
881 881
882 // for some reason, this needs to be called explicitly 882 // for some reason, this needs to be called explicitly
883 mTimeLabels->repaint(); 883 mTimeLabels->repaint();
884 884
885 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 885 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
886 886
887 // ToolTips displaying summary of events 887 // ToolTips displaying summary of events
888 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 888 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
889 ->mEnableToolTips); 889 ->mEnableToolTips);
890 890
891 //setHolidayMasks(); 891 //setHolidayMasks();
892 892
893 //createDayLabels(); called by via updateView(); 893 //createDayLabels(); called by via updateView();
894 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 894 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
895 updateView(); 895 updateView();
896 mAgenda->restorePosition(); 896 mAgenda->restorePosition();
897} 897}
898 898
899 899
900void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 900void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
901{ 901{
902 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 902 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
903 //qDebug("KOAgendaView::updateEventDates "); 903 //qDebug("KOAgendaView::updateEventDates ");
904 QDateTime startDt,endDt; 904 QDateTime startDt,endDt;
905 QDate startDate; 905 QDate startDate;
906 int lenInSecs; 906 int lenInSecs;
907 // if ( type == KOAgenda::RESIZETOP ) 907 // if ( type == KOAgenda::RESIZETOP )
908 // qDebug("RESIZETOP "); 908 // qDebug("RESIZETOP ");
909 // if ( type == KOAgenda::RESIZEBOTTOM ) 909 // if ( type == KOAgenda::RESIZEBOTTOM )
910 // qDebug("RESIZEBOTTOM "); 910 // qDebug("RESIZEBOTTOM ");
911 // if ( type == KOAgenda::MOVE ) 911 // if ( type == KOAgenda::MOVE )
912 // qDebug("MOVE "); 912 // qDebug("MOVE ");
913 if ( item->incidence()->type() == "Event" ) { 913 if ( item->incidence()->type() == "Event" ) {
914 startDt =item->incidence()->dtStart(); 914 startDt =item->incidence()->dtStart();
915 endDt = item->incidence()->dtEnd(); 915 endDt = item->incidence()->dtEnd();
916 lenInSecs = startDt.secsTo( endDt ); 916 lenInSecs = startDt.secsTo( endDt );
917 } 917 }
918 918
919 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 919 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
920 920
921 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 921 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
922 startDate = mSelectedDates[item->mLastMoveXPos]; 922 startDate = mSelectedDates[item->mLastMoveXPos];
923 } else { 923 } else {
924 if (item->cellX() < 0) { 924 if (item->cellX() < 0) {
925 startDate = (mSelectedDates.first()).addDays(item->cellX()); 925 startDate = (mSelectedDates.first()).addDays(item->cellX());
926 } else { 926 } else {
927 startDate = mSelectedDates[item->cellX()]; 927 startDate = mSelectedDates[item->cellX()];
928 } 928 }
929 } 929 }
930 startDt.setDate(startDate); 930 startDt.setDate(startDate);
931 931
932 if (item->incidence()->doesFloat()) { 932 if (item->incidence()->doesFloat()) {
933 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 933 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
934 } else { 934 } else {
935 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 935 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
936 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 936 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
937 if ( item->incidence()->type() == "Event" ) { 937 if ( item->incidence()->type() == "Event" ) {
938 if ( type == KOAgenda::MOVE ) { 938 if ( type == KOAgenda::MOVE ) {
939 endDt = startDt.addSecs(lenInSecs); 939 endDt = startDt.addSecs(lenInSecs);
940 940
941 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 941 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
942 if (item->lastMultiItem()) { 942 if (item->lastMultiItem()) {
943 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 943 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
944 endDt.setDate(startDate. 944 endDt.setDate(startDate.
945 addDays(item->lastMultiItem()->cellX() - item->cellX())); 945 addDays(item->lastMultiItem()->cellX() - item->cellX()));
946 } else { 946 } else {
947 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 947 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
948 endDt.setDate(startDate); 948 endDt.setDate(startDate);
949 } 949 }
950 } 950 }
951 } else { 951 } else {
952 // todo 952 // todo
953 qDebug("tooooodoooooo "); 953 qDebug("tooooodoooooo ");
954 if (item->lastMultiItem()) { 954 if (item->lastMultiItem()) {
955 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 955 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
956 endDt.setDate(startDate. 956 endDt.setDate(startDate.
957 addDays(item->lastMultiItem()->cellX() - item->cellX())); 957 addDays(item->lastMultiItem()->cellX() - item->cellX()));
958 } else { 958 } else {
959 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 959 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
960 if ( item->cellYBottom() > 0 ) 960 if ( item->cellYBottom() > 0 )
961 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 961 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
962 else 962 else
963 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 963 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
964 endDt.setDate(startDate); 964 endDt.setDate(startDate);
965 } 965 }
966 } 966 }
967 } 967 }
968 968
969 qDebug("to888"); 969 qDebug("to888");
970 if ( item->incidence()->type() == "Event" ) { 970 if ( item->incidence()->type() == "Event" ) {
971 item->incidence()->setDtStart(startDt); 971 item->incidence()->setDtStart(startDt);
972 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 972 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
973 } else if ( item->incidence()->type() == "Todo" ) { 973 } else if ( item->incidence()->type() == "Todo" ) {
974 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 974 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
975 } 975 }
976 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 976 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
977 item->incidence()->setRevision(item->incidence()->revision()+1); 977 item->incidence()->setRevision(item->incidence()->revision()+1);
978 item->setItemDate(startDt.date()); 978 item->setItemDate(startDt.date());
979 //item->updateItem(); 979 //item->updateItem();
980 if ( item->incidence()->type() == "Todo" ) { 980 if ( item->incidence()->type() == "Todo" ) {
981 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 981 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
982 982
983 } 983 }
984 else 984 else
985 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 985 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
986 item->updateItem(); 986 item->updateItem();
987} 987}
988 988
989void KOAgendaView::showDates( const QDate &start, const QDate &end ) 989void KOAgendaView::showDates( const QDate &start, const QDate &end )
990{ 990{
991 // kdDebug() << "KOAgendaView::selectDates" << endl; 991 // kdDebug() << "KOAgendaView::selectDates" << endl;
992 992
993 mSelectedDates.clear(); 993 mSelectedDates.clear();
994 // qDebug("KOAgendaView::showDates "); 994 // qDebug("KOAgendaView::showDates ");
995 QDate d = start; 995 QDate d = start;
996 while (d <= end) { 996 while (d <= end) {
997 mSelectedDates.append(d); 997 mSelectedDates.append(d);
998 d = d.addDays( 1 ); 998 d = d.addDays( 1 );
999 } 999 }
1000 1000
1001 // and update the view 1001 // and update the view
1002 fillAgenda(); 1002 fillAgenda();
1003} 1003}
1004 1004
1005 1005
1006void KOAgendaView::showEvents(QPtrList<Event>) 1006void KOAgendaView::showEvents(QPtrList<Event>)
1007{ 1007{
1008 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1008 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1009} 1009}
1010 1010
1011void KOAgendaView::changeEventDisplay(Event *, int) 1011void KOAgendaView::changeEventDisplay(Event *, int)
1012{ 1012{
1013 // qDebug("KOAgendaView::changeEventDisplay "); 1013 // qDebug("KOAgendaView::changeEventDisplay ");
1014 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1014 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1015 // this should be re-written to be MUCH smarter. Right now we 1015 // this should be re-written to be MUCH smarter. Right now we
1016 // are just playing dumb. 1016 // are just playing dumb.
1017 fillAgenda(); 1017 fillAgenda();
1018} 1018}
1019 1019
1020void KOAgendaView::fillAgenda(const QDate &) 1020void KOAgendaView::fillAgenda(const QDate &)
1021{ 1021{
1022 // qDebug("KOAgendaView::fillAgenda "); 1022 // qDebug("KOAgendaView::fillAgenda ");
1023 fillAgenda(); 1023 fillAgenda();
1024} 1024}
1025 1025
1026void KOAgendaView::fillAgenda() 1026void KOAgendaView::fillAgenda()
1027{ 1027{
1028 if ( globalFlagBlockStartup ) 1028 if ( globalFlagBlockStartup )
1029 return; 1029 return;
1030 if ( globalFlagBlockAgenda == 1 ) 1030 if ( globalFlagBlockAgenda == 1 )
1031 return; 1031 return;
1032 //if ( globalFlagBlockAgenda == 2 ) 1032 //if ( globalFlagBlockAgenda == 2 )
1033 //globalFlagBlockAgenda = 0; 1033 //globalFlagBlockAgenda = 0;
1034 // globalFlagBlockPainting = false; 1034 // globalFlagBlockPainting = false;
1035 if ( globalFlagBlockAgenda == 0 ) 1035 if ( globalFlagBlockAgenda == 0 )
1036 globalFlagBlockAgenda = 1; 1036 globalFlagBlockAgenda = 1;
1037 // clearView(); 1037 // clearView();
1038 //qDebug("fillAgenda()++++ "); 1038 //qDebug("fillAgenda()++++ ");
1039 globalFlagBlockAgendaItemPaint = 1; 1039 globalFlagBlockAgendaItemPaint = 1;
1040 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1040 mAllDayAgenda->changeColumns(mSelectedDates.count());
1041 mAgenda->changeColumns(mSelectedDates.count()); 1041 mAgenda->changeColumns(mSelectedDates.count());
1042 qApp->processEvents(); 1042 qApp->processEvents();
1043 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1043 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1044 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1044 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1045 setHolidayMasks(); 1045 setHolidayMasks();
1046 1046
1047 //mAgenda->hideUnused(); 1047 //mAgenda->hideUnused();
1048 //mAllDayAgenda->hideUnused(); 1048 //mAllDayAgenda->hideUnused();
1049 1049
1050 // mAgenda->blockNextRepaint( false ); 1050 // mAgenda->blockNextRepaint( false );
1051 // mAgenda->viewport()->repaint(); 1051 // mAgenda->viewport()->repaint();
1052 // mAgenda->blockNextRepaint( true ); 1052 // mAgenda->blockNextRepaint( true );
1053 mMinY.resize(mSelectedDates.count()); 1053 mMinY.resize(mSelectedDates.count());
1054 mMaxY.resize(mSelectedDates.count()); 1054 mMaxY.resize(mSelectedDates.count());
1055 1055
1056 QPtrList<Event> dayEvents; 1056 QPtrList<Event> dayEvents;
1057 1057
1058 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1058 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1059 // Therefore, gtodoset all of them. 1059 // Therefore, gtodoset all of them.
1060 QPtrList<Todo> todos = calendar()->todos(); 1060 QPtrList<Todo> todos = calendar()->todos();
1061 1061
1062 mAgenda->setDateList(mSelectedDates); 1062 mAgenda->setDateList(mSelectedDates);
1063 1063
1064 QDate today = QDate::currentDate(); 1064 QDate today = QDate::currentDate();
1065 1065
1066 DateList::ConstIterator dit; 1066 DateList::ConstIterator dit;
1067 int curCol = 0; 1067 int curCol = 0;
1068 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1068 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1069 QDate currentDate = *dit; 1069 QDate currentDate = *dit;
1070 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1070 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1071 // << endl; 1071 // << endl;
1072 1072
1073 dayEvents = calendar()->events(currentDate,true); 1073 dayEvents = calendar()->events(currentDate,true);
1074 1074
1075 // Default values, which can never be reached 1075 // Default values, which can never be reached
1076 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1076 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1077 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1077 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1078 1078
1079 unsigned int numEvent; 1079 unsigned int numEvent;
1080 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1080 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1081 Event *event = dayEvents.at(numEvent); 1081 Event *event = dayEvents.at(numEvent);
1082 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1082 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1083 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1083 if ( event->uid().left(15) == QString("last-syncEvent-") )
1084 continue; 1084 continue;
1085 // kdDebug() << " Event: " << event->summary() << endl; 1085 // kdDebug() << " Event: " << event->summary() << endl;
1086 1086
1087 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1087 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1088 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1088 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1089 1089
1090 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1090 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1091 1091
1092 if (event->doesFloat()) { 1092 if (event->doesFloat()) {
1093 if (event->recurrence()->doesRecur()) { 1093 if (event->recurrence()->doesRecur()) {
1094 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1094 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1095 } else { 1095 } else {
1096 if (beginX <= 0 && curCol == 0) { 1096 if (beginX <= 0 && curCol == 0) {
1097 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1097 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1098 } else if (beginX == curCol) { 1098 } else if (beginX == curCol) {
1099 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1099 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1100 } 1100 }
1101 } 1101 }
1102 } else if (event->isMultiDay()) { 1102 } else if (event->isMultiDay()) {
1103 if ( event->doesRecur () ) { 1103 if ( event->doesRecur () ) {
1104 QDate dateit = currentDate; 1104 QDate dateit = currentDate;
1105 int count = 0; 1105 int count = 0;
1106 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1106 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1107 while (! event->recursOn( dateit ) && count <= max ) { 1107 while (! event->recursOn( dateit ) && count <= max ) {
1108 ++count; 1108 ++count;
1109 dateit = dateit.addDays( -1 ); 1109 dateit = dateit.addDays( -1 );
1110 } 1110 }
1111 bool ok; 1111 bool ok;
1112 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1112 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1113 if ( ok ) 1113 if ( ok )
1114 { 1114 {
1115 int secs = event->dtStart().secsTo( event->dtEnd() ); 1115 int secs = event->dtStart().secsTo( event->dtEnd() );
1116 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1116 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1117 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1117 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1118 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1118 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1119 1119
1120 } 1120 }
1121 } 1121 }
1122 int startY = mAgenda->timeToY(event->dtStart().time()); 1122 int startY = mAgenda->timeToY(event->dtStart().time());
1123 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1123 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1124 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1124 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1125 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1125 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1126 //qDebug("insert!!! "); 1126 //qDebug("insert!!! ");
1127 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1127 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1128 } 1128 }
1129 if (beginX == curCol) { 1129 if (beginX == curCol) {
1130 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1130 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1131 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1131 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1132 } else if (endX == curCol) { 1132 } else if (endX == curCol) {
1133 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1133 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1134 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1134 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1135 } else { 1135 } else {
1136 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1136 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1137 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1137 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1138 } 1138 }
1139 } else { 1139 } else {
1140 int startY = mAgenda->timeToY(event->dtStart().time()); 1140 int startY = mAgenda->timeToY(event->dtStart().time());
1141 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1141 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1142 if (endY < startY) endY = startY; 1142 if (endY < startY) endY = startY;
1143 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1143 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1144 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1144 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1145 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1145 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1146 } 1146 }
1147 } 1147 }
1148 // ---------- [display Todos -------------- 1148 // ---------- [display Todos --------------
1149 unsigned int numTodo; 1149 unsigned int numTodo;
1150 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1150 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1151 Todo *todo = todos.at(numTodo); 1151 Todo *todo = todos.at(numTodo);
1152 1152
1153 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1153 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1154 1154
1155 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1155 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1156 // Already completed items can be displayed on their original due date 1156 // Already completed items can be displayed on their original due date
1157 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1157 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1158 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1158 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1159 bool fillIn = false; 1159 bool fillIn = false;
1160 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1160 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1161 fillIn = true; 1161 fillIn = true;
1162 if ( ! fillIn && !todo->hasCompletedDate() ) 1162 if ( ! fillIn && !todo->hasCompletedDate() )
1163 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1163 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1164 if ( fillIn ) { 1164 if ( fillIn ) {
1165 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1165 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1166 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1166 if ( KOPrefs::instance()->mShowTodoInAgenda )
1167 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1167 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1168 } 1168 }
1169 else { 1169 else {
1170 QDateTime dt; 1170 QDateTime dt;
1171 if ( todo->hasCompletedDate() ) 1171 if ( todo->hasCompletedDate() )
1172 dt = todo->completed(); 1172 dt = todo->completed();
1173 else 1173 else
1174 dt = todo->dtDue();; 1174 dt = todo->dtDue();;
1175 1175
1176 1176
1177 int endY = mAgenda->timeToY(dt.time()) - 1; 1177 int endY = mAgenda->timeToY(dt.time()) - 1;
1178 int hi = (18/KOPrefs::instance()->mHourSize); 1178 int hi = (18/KOPrefs::instance()->mHourSize);
1179 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1179 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1180 int startY = endY -hi; 1180 int startY = endY -hi;
1181 1181
1182 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1182 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1183 1183
1184 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1184 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1185 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1185 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1186 } 1186 }
1187 } 1187 }
1188 } 1188 }
1189 // ---------- display Todos] -------------- 1189 // ---------- display Todos] --------------
1190 1190
1191 ++curCol; 1191 ++curCol;
1192 } 1192 }
1193 mAgenda->hideUnused(); 1193 mAgenda->hideUnused();
1194 mAllDayAgenda->hideUnused(); 1194 mAllDayAgenda->hideUnused();
1195 mAgenda->checkScrollBoundaries(); 1195 mAgenda->checkScrollBoundaries();
1196 1196
1197 deleteSelectedDateTime(); 1197 deleteSelectedDateTime();
1198 1198
1199 createDayLabels(); 1199 createDayLabels();
1200 emit incidenceSelected( 0 ); 1200 emit incidenceSelected( 0 );
1201 1201
1202 if ( globalFlagBlockAgenda == 2 ) { 1202 if ( globalFlagBlockAgenda == 2 ) {
1203 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1203 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1204 setStartHour( KOPrefs::instance()->mDayBegins ); 1204 setStartHour( KOPrefs::instance()->mDayBegins );
1205 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1205 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1206 setStartHour( QTime::currentTime ().hour() ); 1206 setStartHour( QTime::currentTime ().hour() );
1207 // qApp->processEvents(); 1207 // qApp->processEvents();
1208 } 1208 }
1209 qApp->processEvents(); 1209 qApp->processEvents();
1210 //qDebug("qApp->processEvents(); END "); 1210 //qDebug("qApp->processEvents(); END ");
1211 globalFlagBlockAgenda = 0; 1211 globalFlagBlockAgenda = 0;
1212 1212
1213 // mAgenda->hideUnused(); 1213 // mAgenda->hideUnused();
1214 //mAllDayAgenda->hideUnused(); 1214 //mAllDayAgenda->hideUnused();
1215 mAllDayAgenda->drawContentsToPainter(); 1215 mAllDayAgenda->drawContentsToPainter();
1216 mAgenda->drawContentsToPainter(); 1216 mAgenda->drawContentsToPainter();
1217 repaintAgenda(); 1217 repaintAgenda();
1218 // mAgenda->finishUpdate(); 1218 // mAgenda->finishUpdate();
1219 //mAllDayAgenda->finishUpdate(); 1219 //mAllDayAgenda->finishUpdate();
1220 1220
1221 // repaintAgenda(); 1221 // repaintAgenda();
1222 //qApp->processEvents(); 1222 //qApp->processEvents();
1223 // globalFlagBlockAgenda = 0; 1223 // globalFlagBlockAgenda = 0;
1224} 1224}
1225void KOAgendaView::repaintAgenda() 1225void KOAgendaView::repaintAgenda()
1226{ 1226{
1227 // mAllDayAgenda->drawContentsToPainter(); 1227 // mAllDayAgenda->drawContentsToPainter();
1228// mAllDayAgenda->viewport()->repaint( false ); 1228// mAllDayAgenda->viewport()->repaint( false );
1229// mAgenda->drawContentsToPainter(); 1229// mAgenda->drawContentsToPainter();
1230// mAgenda->viewport()->repaint( false ); 1230// mAgenda->viewport()->repaint( false );
1231// qApp->processEvents(); 1231// qApp->processEvents();
1232 1232
1233 //qDebug("KOAgendaView::repaintAgenda() "); 1233 //qDebug("KOAgendaView::repaintAgenda() ");
1234 //qApp->processEvents(); 1234 //qApp->processEvents();
1235 mAgenda->viewport()->repaint( false ); 1235 mAgenda->viewport()->repaint( false );
1236 mAllDayAgenda->viewport()->repaint( false ); 1236 mAllDayAgenda->viewport()->repaint( false );
1237 mAgenda->finishUpdate(); 1237 mAgenda->finishUpdate();
1238 mAllDayAgenda->finishUpdate(); 1238 mAllDayAgenda->finishUpdate();
1239} 1239}
1240 1240
1241 1241
1242void KOAgendaView::clearView() 1242void KOAgendaView::clearView()
1243{ 1243{
1244 // kdDebug() << "ClearView" << endl; 1244 // kdDebug() << "ClearView" << endl;
1245 mAllDayAgenda->clear(); 1245 mAllDayAgenda->clear();
1246 mAgenda->clear(); 1246 mAgenda->clear();
1247} 1247}
1248 1248
1249void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1249void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1250 const QDate &td) 1250 const QDate &td)
1251{ 1251{
1252#ifndef KORG_NOPRINTER 1252#ifndef KORG_NOPRINTER
1253 if (fd == td) 1253 if (fd == td)
1254 calPrinter->preview(CalPrinter::Day, fd, td); 1254 calPrinter->preview(CalPrinter::Day, fd, td);
1255 else 1255 else
1256 calPrinter->preview(CalPrinter::Week, fd, td); 1256 calPrinter->preview(CalPrinter::Week, fd, td);
1257#endif 1257#endif
1258} 1258}
1259 1259
1260// void KOAgendaView::updateMovedTodo() 1260// void KOAgendaView::updateMovedTodo()
1261// { 1261// {
1262// // updateConfig(); 1262// // updateConfig();
1263// // emit updateTodoViews(); 1263// // emit updateTodoViews();
1264// } 1264// }
1265 1265
1266void KOAgendaView::newEvent(int gx, int gy) 1266void KOAgendaView::newEvent(int gx, int gy)
1267{ 1267{
1268 if (!mSelectedDates.count()) return; 1268 if (!mSelectedDates.count()) return;
1269 1269
1270 QDate day = mSelectedDates[gx]; 1270 QDate day = mSelectedDates[gx];
1271 1271
1272 QTime time = mAgenda->gyToTime(gy); 1272 QTime time = mAgenda->gyToTime(gy);
1273 QDateTime dt(day,time); 1273 QDateTime dt(day,time);
1274 // if ( dt < QDateTime::currentDateTime () ) 1274 // if ( dt < QDateTime::currentDateTime () )
1275 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1275 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1276 emit newEventSignal(dt); 1276 emit newEventSignal(dt);
1277} 1277}
1278 1278
1279void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1279void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1280{ 1280{
1281 if (!mSelectedDates.count()) return; 1281 if (!mSelectedDates.count()) return;
1282 1282
1283 QDate dayStart = mSelectedDates[gxStart]; 1283 QDate dayStart = mSelectedDates[gxStart];
1284 QDate dayEnd = mSelectedDates[gxEnd]; 1284 QDate dayEnd = mSelectedDates[gxEnd];
1285 1285
1286 QTime timeStart = mAgenda->gyToTime(gyStart); 1286 QTime timeStart = mAgenda->gyToTime(gyStart);
1287 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1287 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1288 1288
1289 QDateTime dtStart(dayStart,timeStart); 1289 QDateTime dtStart(dayStart,timeStart);
1290 QDateTime dtEnd(dayEnd,timeEnd); 1290 QDateTime dtEnd(dayEnd,timeEnd);
1291 1291
1292 emit newEventSignal(dtStart,dtEnd); 1292 emit newEventSignal(dtStart,dtEnd);
1293} 1293}
1294 1294
1295void KOAgendaView::newEventAllDay(int gx, int ) 1295void KOAgendaView::newEventAllDay(int gx, int )
1296{ 1296{
1297 if (!mSelectedDates.count()) return; 1297 if (!mSelectedDates.count()) return;
1298 1298
1299 QDate day = mSelectedDates[gx]; 1299 QDate day = mSelectedDates[gx];
1300 1300
1301 emit newEventSignal(day); 1301 emit newEventSignal(day);
1302} 1302}
1303void KOAgendaView::newTodoAllDay(int gx, int ) 1303void KOAgendaView::newTodoAllDay(int gx, int )
1304{ 1304{
1305 if (!mSelectedDates.count()) return; 1305 if (!mSelectedDates.count()) return;
1306 1306
1307 QDateTime day (mSelectedDates[gx] ); 1307 QDateTime day (mSelectedDates[gx] );
1308 emit newTodoSignal(day, true); 1308 emit newTodoSignal(day, true);
1309} 1309}
1310void KOAgendaView::newTodo(int gx, int gy ) 1310void KOAgendaView::newTodo(int gx, int gy )
1311{ 1311{
1312 if (!mSelectedDates.count()) return; 1312 if (!mSelectedDates.count()) return;
1313 QDate dayStart = mSelectedDates[gx]; 1313 QDate dayStart = mSelectedDates[gx];
1314 QTime timeStart = mAgenda->gyToTime(gy); 1314 QTime timeStart = mAgenda->gyToTime(gy);
1315 QDateTime dt (dayStart,timeStart); 1315 QDateTime dt (dayStart,timeStart);
1316 emit newTodoSignal( dt, false ); 1316 emit newTodoSignal( dt, false );
1317} 1317}
1318 1318
1319void KOAgendaView::updateEventIndicatorTop(int newY) 1319void KOAgendaView::updateEventIndicatorTop(int newY)
1320{ 1320{
1321 uint i; 1321 uint i;
1322 for(i=0;i<mMinY.size();++i) { 1322 for(i=0;i<mMinY.size();++i) {
1323 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1323 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1324 else mEventIndicatorTop->enableColumn(i,false); 1324 else mEventIndicatorTop->enableColumn(i,false);
1325 } 1325 }
1326 1326
1327 mEventIndicatorTop->update(); 1327 mEventIndicatorTop->update();
1328} 1328}
1329 1329
1330void KOAgendaView::updateEventIndicatorBottom(int newY) 1330void KOAgendaView::updateEventIndicatorBottom(int newY)
1331{ 1331{
1332 uint i; 1332 uint i;
1333 for(i=0;i<mMaxY.size();++i) { 1333 for(i=0;i<mMaxY.size();++i) {
1334 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1334 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1335 else mEventIndicatorBottom->enableColumn(i,false); 1335 else mEventIndicatorBottom->enableColumn(i,false);
1336 } 1336 }
1337 1337
1338 mEventIndicatorBottom->update(); 1338 mEventIndicatorBottom->update();
1339} 1339}
1340 1340
1341void KOAgendaView::startDrag(Event *event) 1341void KOAgendaView::startDrag(Event *event)
1342{ 1342{
1343#ifndef KORG_NODND 1343#ifndef KORG_NODND
1344 DndFactory factory( calendar() ); 1344 DndFactory factory( calendar() );
1345 ICalDrag *vd = factory.createDrag(event,this); 1345 ICalDrag *vd = factory.createDrag(event,this);
1346 if (vd->drag()) { 1346 if (vd->drag()) {
1347 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1347 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1348 } 1348 }
1349#endif 1349#endif
1350} 1350}
1351 1351
1352void KOAgendaView::readSettings() 1352void KOAgendaView::readSettings()
1353{ 1353{
1354 readSettings(KOGlobals::config()); 1354 readSettings(KOGlobals::config());
1355} 1355}
1356 1356
1357void KOAgendaView::readSettings(KConfig *config) 1357void KOAgendaView::readSettings(KConfig *config)
1358{ 1358{
1359 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1359 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1360 1360
1361 config->setGroup("Views"); 1361 config->setGroup("Views");
1362 1362
1363 //#ifndef KORG_NOSPLITTER 1363 //#ifndef KORG_NOSPLITTER
1364 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1364 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1365 if (sizes.count() == 2) { 1365 if (sizes.count() == 2) {
1366 if ( sizes[0] < 20 ) { 1366 if ( sizes[0] < 20 ) {
1367 sizes[1] = sizes[1] +20 - sizes[0]; 1367 sizes[1] = sizes[1] +20 - sizes[0];
1368 sizes[0] = 20; 1368 sizes[0] = 20;
1369 } 1369 }
1370 mSplitterAgenda->setSizes(sizes); 1370 mSplitterAgenda->setSizes(sizes);
1371 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1371 // qDebug("read %d %d ",sizes[0],sizes[1] );
1372 } 1372 }
1373 //#endif 1373 //#endif
1374 1374
1375 // updateConfig(); 1375 // updateConfig();
1376} 1376}
1377 1377
1378void KOAgendaView::writeSettings(KConfig *config) 1378void KOAgendaView::writeSettings(KConfig *config)
1379{ 1379{
1380 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1380 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1381 1381
1382 config->setGroup("Views"); 1382 config->setGroup("Views");
1383 1383
1384 //#ifndef KORG_NOSPLITTER 1384 //#ifndef KORG_NOSPLITTER
1385 QValueList<int> list = mSplitterAgenda->sizes(); 1385 QValueList<int> list = mSplitterAgenda->sizes();
1386 config->writeEntry("Separator AgendaView",list); 1386 config->writeEntry("Separator AgendaView",list);
1387 //qDebug("write %d %d ", list[0],list[1] ); 1387 //qDebug("write %d %d ", list[0],list[1] );
1388 //#endif 1388 //#endif
1389} 1389}
1390 1390
1391void KOAgendaView::setHolidayMasks() 1391void KOAgendaView::setHolidayMasks()
1392{ 1392{
1393 mHolidayMask.resize(mSelectedDates.count()); 1393 mHolidayMask.resize(mSelectedDates.count());
1394 1394
1395 uint i; 1395 uint i;
1396 for(i=0;i<mSelectedDates.count();++i) { 1396 for(i=0;i<mSelectedDates.count();++i) {
1397 QDate date = mSelectedDates[i]; 1397 QDate date = mSelectedDates[i];
1398 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1398 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1399 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1399 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1400 bool showHoliday = false; 1400 bool showHoliday = false;
1401 if ( KOPrefs::instance()->mExcludeHolidays ) { 1401 if ( KOPrefs::instance()->mExcludeHolidays ) {
1402 QPtrList<Event> events = calendar()->events( date, true ); 1402 QPtrList<Event> events = calendar()->events( date, true );
1403 Event *event; 1403 Event *event;
1404 for( event = events.first(); event; event = events.next() ) { 1404 for( event = events.first(); event; event = events.next() ) {
1405 if ( event->categories().contains("Holiday") || 1405 if ( event->categories().contains("Holiday") ||
1406 event->categories().contains(i18n("Holiday"))) { 1406 event->categories().contains(i18n("Holiday"))) {
1407 showHoliday = true; 1407 showHoliday = true;
1408 break; 1408 break;
1409 } 1409 }
1410 } 1410 }
1411 1411
1412 } 1412 }
1413 1413
1414#ifndef KORG_NOPLUGINS 1414#ifndef KORG_NOPLUGINS
1415 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1415 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1416 !KOCore::self()->holiday(date).isEmpty(); 1416 !KOCore::self()->holiday(date).isEmpty();
1417#endif 1417#endif
1418 bool showDay = showSaturday || showSunday || showHoliday; 1418 bool showDay = showSaturday || showSunday || showHoliday;
1419 1419
1420 if (showDay) { 1420 if (showDay) {
1421 mHolidayMask.at(i) = true; 1421 mHolidayMask.at(i) = true;
1422 } else { 1422 } else {
1423 mHolidayMask.at(i) = false; 1423 mHolidayMask.at(i) = false;
1424 } 1424 }
1425 } 1425 }
1426 1426
1427 mAgenda->setHolidayMask(&mHolidayMask); 1427 mAgenda->setHolidayMask(&mHolidayMask);
1428 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1428 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1429} 1429}
1430 1430
1431void KOAgendaView::setContentsPos(int y) 1431void KOAgendaView::setContentsPos(int y)
1432{ 1432{
1433 mAgenda->setContentsPos(0,y); 1433 mAgenda->setContentsPos(0,y);
1434} 1434}
1435 1435
1436void KOAgendaView::setExpandedButton( bool expanded ) 1436void KOAgendaView::setExpandedButton( bool expanded )
1437{ 1437{
1438 if ( expanded ) { 1438 if ( expanded ) {
1439 mExpandButton->setPixmap( mExpandedPixmap ); 1439 mExpandButton->setPixmap( mExpandedPixmap );
1440 } else { 1440 } else {
1441 mExpandButton->setPixmap( mNotExpandedPixmap ); 1441 mExpandButton->setPixmap( mNotExpandedPixmap );
1442 } 1442 }
1443} 1443}
1444 1444
1445void KOAgendaView::clearSelection() 1445void KOAgendaView::clearSelection()
1446{ 1446{
1447 mAgenda->deselectItem(); 1447 mAgenda->deselectItem();
1448 mAllDayAgenda->deselectItem(); 1448 mAllDayAgenda->deselectItem();
1449} 1449}
1450 1450
1451void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1451void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1452 int gxEnd, int gyEnd) 1452 int gxEnd, int gyEnd)
1453{ 1453{
1454 mTimeSpanInAllDay = true; 1454 mTimeSpanInAllDay = true;
1455 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1455 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1456} 1456}
1457 1457
1458 1458
1459 1459
1460 1460
1461void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1461void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1462 int gxEnd, int gyEnd) 1462 int gxEnd, int gyEnd)
1463{ 1463{
1464 if (!mSelectedDates.count()) return; 1464 if (!mSelectedDates.count()) return;
1465 1465
1466 QDate dayStart = mSelectedDates[gxStart]; 1466 QDate dayStart = mSelectedDates[gxStart];
1467 QDate dayEnd = mSelectedDates[gxEnd]; 1467 QDate dayEnd = mSelectedDates[gxEnd];
1468 1468
1469 QTime timeStart = mAgenda->gyToTime(gyStart); 1469 QTime timeStart = mAgenda->gyToTime(gyStart);
1470 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1470 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1471 1471
1472 QDateTime dtStart(dayStart,timeStart); 1472 QDateTime dtStart(dayStart,timeStart);
1473 QDateTime dtEnd(dayEnd,timeEnd); 1473 QDateTime dtEnd(dayEnd,timeEnd);
1474 1474
1475 mTimeSpanBegin = dtStart; 1475 mTimeSpanBegin = dtStart;
1476 mTimeSpanEnd = dtEnd; 1476 mTimeSpanEnd = dtEnd;
1477 1477
1478} 1478}
1479 1479
1480void KOAgendaView::deleteSelectedDateTime() 1480void KOAgendaView::deleteSelectedDateTime()
1481{ 1481{
1482 mTimeSpanBegin.setDate(QDate()); 1482 mTimeSpanBegin.setDate(QDate());
1483 mTimeSpanEnd.setDate(QDate()); 1483 mTimeSpanEnd.setDate(QDate());
1484 mTimeSpanInAllDay = false; 1484 mTimeSpanInAllDay = false;
1485} 1485}
1486 1486
1487void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1487void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1488{ 1488{
1489 e->ignore(); 1489 e->ignore();
1490} 1490}
1491 1491
1492void KOAgendaView::scrollOneHourUp() 1492void KOAgendaView::scrollOneHourUp()
1493{ 1493{
1494 1494
1495 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1495 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1496} 1496}
1497void KOAgendaView::scrollOneHourDown() 1497void KOAgendaView::scrollOneHourDown()
1498{ 1498{
1499 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1499 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1500} 1500}
1501 1501
1502void KOAgendaView::setStartHour( int h ) 1502void KOAgendaView::setStartHour( int h )
1503{ 1503{
1504 mAgenda->setStartHour( h ); 1504 mAgenda->setStartHour( h );
1505 1505
1506} 1506}
1507 1507
1508void KOAgendaView::updateTodo( Todo * t, int ) 1508void KOAgendaView::updateTodo( Todo * t, int )
1509{ 1509{
1510 if ( !isVisible() )
1511 return;
1510 bool remove = false; 1512 bool remove = false;
1511 bool removeAD = false; 1513 bool removeAD = false;
1512 QDate da; 1514 QDate da;
1513 if ( t->hasCompletedDate() ) 1515 if ( t->hasCompletedDate() )
1514 da = t->completed().date(); 1516 da = t->completed().date();
1515 else 1517 else
1516 da = t->dtDue().date(); 1518 da = t->dtDue().date();
1517 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1519 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1518 remove = true; 1520 remove = true;
1519 removeAD = true; 1521 removeAD = true;
1520 } 1522 }
1521 else { 1523 else {
1522 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1524 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1523 if ( overdue && 1525 if ( overdue &&
1524 QDate::currentDate() >= mSelectedDates.first() && 1526 QDate::currentDate() >= mSelectedDates.first() &&
1525 QDate::currentDate() <= mSelectedDates.last()) { 1527 QDate::currentDate() <= mSelectedDates.last()) {
1526 removeAD = false; 1528 removeAD = false;
1527 remove = true; 1529 remove = true;
1528 } 1530 }
1529 else { 1531 else {
1530 1532
1531 if ( da < mSelectedDates.first() || 1533 if ( da < mSelectedDates.first() ||
1532 da > mSelectedDates.last() ) { 1534 da > mSelectedDates.last() ) {
1533 remove = true; 1535 remove = true;
1534 removeAD = true; 1536 removeAD = true;
1535 } else { 1537 } else {
1536 remove = t->doesFloat() && !t->hasCompletedDate(); 1538 remove = t->doesFloat() && !t->hasCompletedDate();
1537 removeAD = !remove; 1539 removeAD = !remove;
1538 } 1540 }
1539 } 1541 }
1540 } 1542 }
1541 int days = mSelectedDates.first().daysTo( da ); 1543 int days = mSelectedDates.first().daysTo( da );
1542 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1544 //qDebug("daysto %d %d %d", days, remove,removeAD );
1543 mAgenda->updateTodo( t , days, remove); 1545 mAgenda->updateTodo( t , days, remove);
1544 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1546 if ( KOPrefs::instance()->mShowTodoInAgenda )
1545 mAllDayAgenda->updateTodo( t , days, removeAD); 1547 mAllDayAgenda->updateTodo( t , days, removeAD);
1546 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1548 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1547 1549
1548} 1550}
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index 9c3621e..be5a775 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -1,634 +1,629 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
4 Parts of the source code have been copied from kdpdatebutton.cpp 4 Parts of the source code have been copied from kdpdatebutton.cpp
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source ode for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qevent.h> 25#include <qevent.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qptrlist.h> 27#include <qptrlist.h>
28#include <qtimer.h> 28#include <qtimer.h>
29 29
30#include <kglobal.h> 30#include <kglobal.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <klocale.h> 32#include <klocale.h>
33 33
34#include <libkcal/vcaldrag.h> 34#include <libkcal/vcaldrag.h>
35#include <libkcal/icaldrag.h> 35#include <libkcal/icaldrag.h>
36#include <libkcal/dndfactory.h> 36#include <libkcal/dndfactory.h>
37#include <libkcal/calendarresources.h> 37#include <libkcal/calendarresources.h>
38#include <libkcal/resourcecalendar.h> 38#include <libkcal/resourcecalendar.h>
39#include <kresources/resourceselectdialog.h> 39#include <kresources/resourceselectdialog.h>
40 40
41#include <kcalendarsystem.h> 41#include <kcalendarsystem.h>
42 42
43#ifndef KORG_NOPLUGINS 43#ifndef KORG_NOPLUGINS
44#include "kocore.h" 44#include "kocore.h"
45#endif 45#endif
46#include "koprefs.h" 46#include "koprefs.h"
47#include "koglobals.h" 47#include "koglobals.h"
48 48
49#include "kodaymatrix.h" 49#include "kodaymatrix.h"
50 50
51// ============================================================================ 51// ============================================================================
52// D Y N A M I C T I P 52// D Y N A M I C T I P
53// ============================================================================ 53// ============================================================================
54 54
55DynamicTip::DynamicTip( QWidget * parent ) 55DynamicTip::DynamicTip( QWidget * parent )
56 : QToolTip( parent ) 56 : QToolTip( parent )
57{ 57{
58 matrix = (KODayMatrix*)parent; 58 matrix = (KODayMatrix*)parent;
59} 59}
60 60
61 61
62void DynamicTip::maybeTip( const QPoint &pos ) 62void DynamicTip::maybeTip( const QPoint &pos )
63{ 63{
64 //calculate which cell of the matrix the mouse is in 64 //calculate which cell of the matrix the mouse is in
65 QRect sz = matrix->frameRect(); 65 QRect sz = matrix->frameRect();
66 int dheight = sz.height()*7 / 42; 66 int dheight = sz.height()*7 / 42;
67 int dwidth = sz.width() / 7; 67 int dwidth = sz.width() / 7;
68 int row = pos.y()/dheight; 68 int row = pos.y()/dheight;
69 int col = pos.x()/dwidth; 69 int col = pos.x()/dwidth;
70 70
71 QRect rct(col*dwidth, row*dheight, dwidth, dheight); 71 QRect rct(col*dwidth, row*dheight, dwidth, dheight);
72 72
73// kdDebug() << "DynamicTip::maybeTip matrix cell index [" << 73// kdDebug() << "DynamicTip::maybeTip matrix cell index [" <<
74// col << "][" << row << "] => " <<(col+row*7) << endl; 74// col << "][" << row << "] => " <<(col+row*7) << endl;
75 75
76 //show holiday names only 76 //show holiday names only
77 QString str = matrix->getHolidayLabel(col+row*7); 77 QString str = matrix->getHolidayLabel(col+row*7);
78 if (str.isEmpty()) return; 78 if (str.isEmpty()) return;
79 tip(rct, str); 79 tip(rct, str);
80} 80}
81 81
82 82
83// ============================================================================ 83// ============================================================================
84// K O D A Y M A T R I X 84// K O D A Y M A T R I X
85// ============================================================================ 85// ============================================================================
86 86
87const int KODayMatrix::NOSELECTION = -1000; 87const int KODayMatrix::NOSELECTION = -1000;
88const int KODayMatrix::NUMDAYS = 42; 88const int KODayMatrix::NUMDAYS = 42;
89 89
90KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) : 90KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name) :
91 QFrame(parent, name) 91 QFrame(parent, name)
92{ 92{
93 mCalendar = calendar; 93 mCalendar = calendar;
94 mPendingUpdateBeforeRepaint = false;
94 95
95 // initialize dynamic arrays 96 // initialize dynamic arrays
96 days = new QDate[NUMDAYS]; 97 days = new QDate[NUMDAYS];
97 daylbls = new QString[NUMDAYS]; 98 daylbls = new QString[NUMDAYS];
98 events = new int[NUMDAYS]; 99 events = new int[NUMDAYS];
99 mToolTip = new DynamicTip(this); 100 mToolTip = new DynamicTip(this);
100 101
101 // set default values used for drawing the matrix 102 // set default values used for drawing the matrix
102 mDefaultBackColor = palette().active().base(); 103 mDefaultBackColor = palette().active().base();
103 mDefaultTextColor = palette().active().foreground(); 104 mDefaultTextColor = palette().active().foreground();
104 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor); 105 mDefaultTextColorShaded = getShadedColor(mDefaultTextColor);
105 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor); 106 mHolidayColorShaded = getShadedColor(KOPrefs::instance()->mHolidayColor);
106 mSelectedDaysColor = QColor("white"); 107 mSelectedDaysColor = QColor("white");
107 mTodayMarginWidth = 2; 108 mTodayMarginWidth = 2;
108 mSelEnd = mSelStart = NOSELECTION; 109 mSelEnd = mSelStart = NOSELECTION;
109 110
110 setAcceptDrops(true); 111 setAcceptDrops(true);
111 //setFont( QFont("Arial", 10) ); 112 //setFont( QFont("Arial", 10) );
112 113
113 mUpdateTimer = new QTimer( this ); 114 mUpdateTimer = new QTimer( this );
114 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() )); 115 connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( updateViewTimed() ));
115 mRepaintTimer = new QTimer( this ); 116 mRepaintTimer = new QTimer( this );
116 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() )); 117 connect (mRepaintTimer ,SIGNAL(timeout()), this, SLOT ( repaintViewTimed() ));
117 mDayChanged = false; 118 mDayChanged = false;
118 updateView(); 119 updateView();
119} 120}
120 121
121QColor KODayMatrix::getShadedColor(QColor color) 122QColor KODayMatrix::getShadedColor(QColor color)
122{ 123{
123 QColor shaded; 124 QColor shaded;
124 int h=0; 125 int h=0;
125 int s=0; 126 int s=0;
126 int v=0; 127 int v=0;
127 color.hsv(&h,&s,&v); 128 color.hsv(&h,&s,&v);
128 s = s/4; 129 s = s/4;
129 v = 192+v/4; 130 v = 192+v/4;
130 shaded.setHsv(h,s,v); 131 shaded.setHsv(h,s,v);
131 132
132 return shaded; 133 return shaded;
133} 134}
134 135
135KODayMatrix::~KODayMatrix() 136KODayMatrix::~KODayMatrix()
136{ 137{
137 delete [] days; 138 delete [] days;
138 delete [] daylbls; 139 delete [] daylbls;
139 delete [] events; 140 delete [] events;
140 delete mToolTip; 141 delete mToolTip;
141} 142}
142 143
143/* 144/*
144void KODayMatrix::setStartDate(QDate start) 145void KODayMatrix::setStartDate(QDate start)
145{ 146{
146 updateView(start); 147 updateView(start);
147} 148}
148*/ 149*/
149 150
150void KODayMatrix::addSelectedDaysTo(DateList& selDays) 151void KODayMatrix::addSelectedDaysTo(DateList& selDays)
151{ 152{
152 153
153 if (mSelStart == NOSELECTION) { 154 if (mSelStart == NOSELECTION) {
154 return; 155 return;
155 } 156 }
156 157
157 //cope with selection being out of matrix limits at top (< 0) 158 //cope with selection being out of matrix limits at top (< 0)
158 int i0 = mSelStart; 159 int i0 = mSelStart;
159 if (i0 < 0) { 160 if (i0 < 0) {
160 for (int i = i0; i < 0; i++) { 161 for (int i = i0; i < 0; i++) {
161 selDays.append(days[0].addDays(i)); 162 selDays.append(days[0].addDays(i));
162 } 163 }
163 i0 = 0; 164 i0 = 0;
164 } 165 }
165 166
166 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1) 167 //cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
167 if (mSelEnd > NUMDAYS-1) { 168 if (mSelEnd > NUMDAYS-1) {
168 for (int i = i0; i <= NUMDAYS-1; i++) { 169 for (int i = i0; i <= NUMDAYS-1; i++) {
169 selDays.append(days[i]); 170 selDays.append(days[i]);
170 } 171 }
171 for (int i = NUMDAYS; i < mSelEnd; i++) { 172 for (int i = NUMDAYS; i < mSelEnd; i++) {
172 selDays.append(days[0].addDays(i)); 173 selDays.append(days[0].addDays(i));
173 } 174 }
174 175
175 // apply normal routine to selection being entirely within matrix limits 176 // apply normal routine to selection being entirely within matrix limits
176 } else { 177 } else {
177 for (int i = i0; i <= mSelEnd; i++) { 178 for (int i = i0; i <= mSelEnd; i++) {
178 selDays.append(days[i]); 179 selDays.append(days[i]);
179 } 180 }
180 } 181 }
181} 182}
182 183
183void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end) 184void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
184{ 185{
185 mSelStart = startdate.daysTo(start); 186 mSelStart = startdate.daysTo(start);
186 mSelEnd = startdate.daysTo(end); 187 mSelEnd = startdate.daysTo(end);
187} 188}
188 189
189 190
190void KODayMatrix::recalculateToday() 191void KODayMatrix::recalculateToday()
191{ 192{
192 today = -1; 193 today = -1;
193 for (int i=0; i<NUMDAYS; i++) { 194 for (int i=0; i<NUMDAYS; i++) {
195 events[i] = 0;
194 days[i] = startdate.addDays(i); 196 days[i] = startdate.addDays(i);
195 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] )); 197 daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
196 198
197 // if today is in the currently displayed month, hilight today 199 // if today is in the currently displayed month, hilight today
198 if (days[i].year() == QDate::currentDate().year() && 200 if (days[i].year() == QDate::currentDate().year() &&
199 days[i].month() == QDate::currentDate().month() && 201 days[i].month() == QDate::currentDate().month() &&
200 days[i].day() == QDate::currentDate().day()) { 202 days[i].day() == QDate::currentDate().day()) {
201 today = i; 203 today = i;
202 } 204 }
203 } 205 }
204 // qDebug(QString("Today is visible at %1.").arg(today)); 206 // qDebug(QString("Today is visible at %1.").arg(today));
205} 207}
206 208
207void KODayMatrix::updateView() 209void KODayMatrix::updateView()
208{ 210{
209 updateView(startdate); 211 updateView(startdate);
210} 212}
211void KODayMatrix::repaintViewTimed() 213void KODayMatrix::repaintViewTimed()
212{ 214{
213 qDebug("KODayMatrix::repaintViewTimed "); 215 //qDebug("KODayMatrix::repaintViewTimed ");
214 mRepaintTimer->stop(); 216 mRepaintTimer->stop();
215 repaint(false); 217 repaint(false);
216} 218}
217void KODayMatrix::updateViewTimed() 219void KODayMatrix::updateViewTimed()
218{ 220{
219 221
220 mUpdateTimer->stop(); 222 mUpdateTimer->stop();
221 //QDate actdate = mPendingNewDate; 223 //qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii );
222
223 static int iii = 0;
224 qDebug("KODayMatrix::updateView(QDate actdate) %d", ++iii );
225
226 if (mDayChanged) {
227 recalculateToday();
228 mDayChanged = false;
229 }
230
231 for(int i = 0; i < NUMDAYS; i++) { 224 for(int i = 0; i < NUMDAYS; i++) {
232 225
233 // if events are set for the day then remember to draw it bold 226 // if events are set for the day then remember to draw it bold
234 QPtrList<Event> eventlist = mCalendar->events(days[i]); 227 QPtrList<Event> eventlist = mCalendar->events(days[i]);
235 Event *event; 228 Event *event;
236 int numEvents = eventlist.count(); 229 int numEvents = eventlist.count();
237 230
238 for(event=eventlist.first();event != 0;event=eventlist.next()) { 231 for(event=eventlist.first();event != 0;event=eventlist.next()) {
239 ushort recurType = event->recurrence()->doesRecur(); 232 ushort recurType = event->recurrence()->doesRecur();
240 233
241 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 234 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
242 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 235 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
243 numEvents--; 236 numEvents--;
244 } 237 }
245 } 238 }
246 events[i] = numEvents; 239 events[i] = numEvents;
247 240
248 //if it is a holy day then draw it red. Sundays are consider holidays, too 241 //if it is a holy day then draw it red. Sundays are consider holidays, too
249#ifndef KORG_NOPLUGINS 242#ifndef KORG_NOPLUGINS
250 QString holiStr = KOCore::self()->holiday(days[i]); 243 QString holiStr = KOCore::self()->holiday(days[i]);
251#else 244#else
252 QString holiStr = QString::null; 245 QString holiStr = QString::null;
253#endif 246#endif
254 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) || 247 if ( (KOGlobals::self()->calendarSystem()->dayOfWeek(days[i]) == KOGlobals::self()->calendarSystem()->weekDayOfPray()) ||
255 !holiStr.isEmpty()) { 248 !holiStr.isEmpty()) {
256 if (holiStr.isNull()) holiStr = ""; 249 if (holiStr.isNull()) holiStr = "";
257 mHolidays[i] = holiStr; 250 mHolidays[i] = holiStr;
258 251
259 } else { 252 } else {
260 mHolidays[i] = QString::null; 253 mHolidays[i] = QString::null;
261 } 254 }
262 } 255 }
263 repaint(false); 256 if ( ! mPendingUpdateBeforeRepaint )
257 repaint(false);
264 } 258 }
265void KODayMatrix::updateView(QDate actdate) 259void KODayMatrix::updateView(QDate actdate)
266{ 260{
267 261
262 if ( ! actdate.isValid() ) {
263 //qDebug("date not valid ");
264 return;
265 }
266 mDayChanged = false;
268 //flag to indicate if the starting day of the matrix has changed by this call 267 //flag to indicate if the starting day of the matrix has changed by this call
269 //mDayChanged = false; 268 //mDayChanged = false;
270 // if a new startdate is to be set then apply Cornelius's calculation 269 // if a new startdate is to be set then apply Cornelius's calculation
271 // of the first day to be shown 270 // of the first day to be shown
272 if (actdate != startdate) { 271 if (actdate != startdate) {
273 // reset index of selection according to shift of starting date from startdate to actdate 272 // reset index of selection according to shift of starting date from startdate to actdate
274 if (mSelStart != NOSELECTION) { 273 if (mSelStart != NOSELECTION) {
275 int tmp = actdate.daysTo(startdate); 274 int tmp = actdate.daysTo(startdate);
276 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl; 275 //kdDebug() << "Shift of Selection1: " << mSelStart << " - " << mSelEnd << " -> " << tmp << "(" << offset << ")" << endl;
277 // shift selection if new one would be visible at least partly ! 276 // shift selection if new one would be visible at least partly !
278 277
279 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) { 278 if (mSelStart+tmp < NUMDAYS && mSelEnd+tmp >= 0) {
280 // nested if is required for next X display pushed from a different month - correction required 279 // nested if is required for next X display pushed from a different month - correction required
281 // otherwise, for month forward and backward, it must be avoided 280 // otherwise, for month forward and backward, it must be avoided
282 if( mSelStart > NUMDAYS || mSelStart < 0 ) 281 if( mSelStart > NUMDAYS || mSelStart < 0 )
283 mSelStart = mSelStart + tmp; 282 mSelStart = mSelStart + tmp;
284 if( mSelEnd > NUMDAYS || mSelEnd < 0 ) 283 if( mSelEnd > NUMDAYS || mSelEnd < 0 )
285 mSelEnd = mSelEnd + tmp; 284 mSelEnd = mSelEnd + tmp;
286 } 285 }
287 } 286 }
288
289 startdate = actdate; 287 startdate = actdate;
290 mDayChanged = true; 288 mDayChanged = true;
289 recalculateToday();
291 } 290 }
292 qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() ); 291 //qDebug("restart Timer %d vis: %d", mDayChanged, isVisible() );
293 static int iii = 0; 292 if ( !isVisible() ) {
294 if ( iii < 2 ) { 293 mPendingUpdateBeforeRepaint = true;
295 ++iii;
296 updateViewTimed();
297 } else { 294 } else {
298 if ( !isVisible() ) { 295 mRepaintTimer->start( 250 );
299 mUpdateTimer->start( 2000 ); 296#ifdef DESKTOP_VERSION
300 } else { 297 mUpdateTimer->start( 2000 );
301 if ( mDayChanged ) { 298#else
302 mUpdateTimer->start( 250 ); 299 mUpdateTimer->start( 4000 );
303 } else { 300#endif
304 mRepaintTimer->start( 250 );
305 mUpdateTimer->start( 2000 );
306 }
307 }
308 } 301 }
309
310} 302}
311 303
312const QDate& KODayMatrix::getDate(int offset) 304const QDate& KODayMatrix::getDate(int offset)
313{ 305{
314 if (offset < 0 || offset > NUMDAYS-1) { 306 if (offset < 0 || offset > NUMDAYS-1) {
315 qDebug("Wrong offset2 "); 307 qDebug("Wrong offset2 ");
316 return days[0]; 308 return days[0];
317 } 309 }
318 return days[offset]; 310 return days[offset];
319} 311}
320 312
321QString KODayMatrix::getHolidayLabel(int offset) 313QString KODayMatrix::getHolidayLabel(int offset)
322{ 314{
323 if (offset < 0 || offset > NUMDAYS-1) { 315 if (offset < 0 || offset > NUMDAYS-1) {
324 qDebug("Wrong offset1 "); 316 qDebug("Wrong offset1 ");
325 return 0; 317 return 0;
326 } 318 }
327 return mHolidays[offset]; 319 return mHolidays[offset];
328} 320}
329 321
330int KODayMatrix::getDayIndexFrom(int x, int y) 322int KODayMatrix::getDayIndexFrom(int x, int y)
331{ 323{
332 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ? 324 return 7*(y/daysize.height()) + (KOGlobals::self()->reverseLayout() ?
333 6 - x/daysize.width() : x/daysize.width()); 325 6 - x/daysize.width() : x/daysize.width());
334} 326}
335 327
336// ---------------------------------------------------------------------------- 328// ----------------------------------------------------------------------------
337// M O U S E E V E N T H A N D L I N G 329// M O U S E E V E N T H A N D L I N G
338// ---------------------------------------------------------------------------- 330// ----------------------------------------------------------------------------
339 331
340void KODayMatrix::mousePressEvent (QMouseEvent* e) 332void KODayMatrix::mousePressEvent (QMouseEvent* e)
341{ 333{
342 mSelStart = getDayIndexFrom(e->x(), e->y()); 334 mSelStart = getDayIndexFrom(e->x(), e->y());
343 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; 335 if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1;
344 mSelInit = mSelStart; 336 mSelInit = mSelStart;
345} 337}
346 338
347void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) 339void KODayMatrix::mouseReleaseEvent (QMouseEvent* e)
348{ 340{
349 341
350 int tmp = getDayIndexFrom(e->x(), e->y()); 342 int tmp = getDayIndexFrom(e->x(), e->y());
351 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 343 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
352 344
353 if (mSelInit > tmp) { 345 if (mSelInit > tmp) {
354 mSelEnd = mSelInit; 346 mSelEnd = mSelInit;
355 if (tmp != mSelStart) { 347 if (tmp != mSelStart) {
356 mSelStart = tmp; 348 mSelStart = tmp;
357 repaint(); 349 repaint();
358 } 350 }
359 } else { 351 } else {
360 mSelStart = mSelInit; 352 mSelStart = mSelInit;
361 353
362 //repaint only if selection has changed 354 //repaint only if selection has changed
363 if (tmp != mSelEnd) { 355 if (tmp != mSelEnd) {
364 mSelEnd = tmp; 356 mSelEnd = tmp;
365 repaint(); 357 repaint();
366 } 358 }
367 } 359 }
368 360
369 DateList daylist; 361 DateList daylist;
370 if ( mSelStart < 0 ) 362 if ( mSelStart < 0 )
371 mSelStart = 0; 363 mSelStart = 0;
372 for (int i = mSelStart; i <= mSelEnd; i++) { 364 for (int i = mSelStart; i <= mSelEnd; i++) {
373 daylist.append(days[i]); 365 daylist.append(days[i]);
374 } 366 }
375 emit selected((const DateList)daylist); 367 emit selected((const DateList)daylist);
376 368
377} 369}
378 370
379void KODayMatrix::mouseMoveEvent (QMouseEvent* e) 371void KODayMatrix::mouseMoveEvent (QMouseEvent* e)
380{ 372{
381 int tmp = getDayIndexFrom(e->x(), e->y()); 373 int tmp = getDayIndexFrom(e->x(), e->y());
382 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; 374 if (tmp > NUMDAYS-1) tmp=NUMDAYS-1;
383 375
384 if (mSelInit > tmp) { 376 if (mSelInit > tmp) {
385 mSelEnd = mSelInit; 377 mSelEnd = mSelInit;
386 if (tmp != mSelStart) { 378 if (tmp != mSelStart) {
387 mSelStart = tmp; 379 mSelStart = tmp;
388 repaint(); 380 repaint();
389 } 381 }
390 } else { 382 } else {
391 mSelStart = mSelInit; 383 mSelStart = mSelInit;
392 384
393 //repaint only if selection has changed 385 //repaint only if selection has changed
394 if (tmp != mSelEnd) { 386 if (tmp != mSelEnd) {
395 mSelEnd = tmp; 387 mSelEnd = tmp;
396 repaint(); 388 repaint();
397 } 389 }
398 } 390 }
399} 391}
400 392
401// ---------------------------------------------------------------------------- 393// ----------------------------------------------------------------------------
402// D R A G ' N D R O P H A N D L I N G 394// D R A G ' N D R O P H A N D L I N G
403// ---------------------------------------------------------------------------- 395// ----------------------------------------------------------------------------
404 396
405void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) 397void KODayMatrix::dragEnterEvent(QDragEnterEvent *e)
406{ 398{
407#ifndef KORG_NODND 399#ifndef KORG_NODND
408 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 400 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
409 e->ignore(); 401 e->ignore();
410 return; 402 return;
411 } 403 }
412 404
413 // some visual feedback 405 // some visual feedback
414// oldPalette = palette(); 406// oldPalette = palette();
415// setPalette(my_HilitePalette); 407// setPalette(my_HilitePalette);
416// update(); 408// update();
417#endif 409#endif
418} 410}
419 411
420void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) 412void KODayMatrix::dragMoveEvent(QDragMoveEvent *e)
421{ 413{
422#ifndef KORG_NODND 414#ifndef KORG_NODND
423 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 415 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
424 e->ignore(); 416 e->ignore();
425 return; 417 return;
426 } 418 }
427 419
428 e->accept(); 420 e->accept();
429#endif 421#endif
430} 422}
431 423
432void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/) 424void KODayMatrix::dragLeaveEvent(QDragLeaveEvent */*dl*/)
433{ 425{
434#ifndef KORG_NODND 426#ifndef KORG_NODND
435// setPalette(oldPalette); 427// setPalette(oldPalette);
436// update(); 428// update();
437#endif 429#endif
438} 430}
439 431
440void KODayMatrix::dropEvent(QDropEvent *e) 432void KODayMatrix::dropEvent(QDropEvent *e)
441{ 433{
442#ifndef KORG_NODND 434#ifndef KORG_NODND
443// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl; 435// kdDebug() << "KODayMatrix::dropEvent(e) begin" << endl;
444 436
445 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { 437 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) {
446 e->ignore(); 438 e->ignore();
447 return; 439 return;
448 } 440 }
449 441
450 DndFactory factory( mCalendar ); 442 DndFactory factory( mCalendar );
451 Event *event = factory.createDrop(e); 443 Event *event = factory.createDrop(e);
452 444
453 if (event) { 445 if (event) {
454 e->acceptAction(); 446 e->acceptAction();
455 447
456 Event *existingEvent = mCalendar->event(event->uid()); 448 Event *existingEvent = mCalendar->event(event->uid());
457 449
458 if(existingEvent) { 450 if(existingEvent) {
459 // uniquify event 451 // uniquify event
460 event->recreate(); 452 event->recreate();
461/* 453/*
462 KMessageBox::sorry(this, 454 KMessageBox::sorry(this,
463 i18n("Event already exists in this calendar."), 455 i18n("Event already exists in this calendar."),
464 i18n("Drop Event")); 456 i18n("Drop Event"));
465 delete event; 457 delete event;
466 return; 458 return;
467*/ 459*/
468 } 460 }
469// kdDebug() << "Drop new Event" << endl; 461// kdDebug() << "Drop new Event" << endl;
470 // Adjust date 462 // Adjust date
471 QDateTime start = event->dtStart(); 463 QDateTime start = event->dtStart();
472 QDateTime end = event->dtEnd(); 464 QDateTime end = event->dtEnd();
473 int duration = start.daysTo(end); 465 int duration = start.daysTo(end);
474 int idx = getDayIndexFrom(e->pos().x(), e->pos().y()); 466 int idx = getDayIndexFrom(e->pos().x(), e->pos().y());
475 467
476 start.setDate(days[idx]); 468 start.setDate(days[idx]);
477 end.setDate(days[idx].addDays(duration)); 469 end.setDate(days[idx].addDays(duration));
478 470
479 event->setDtStart(start); 471 event->setDtStart(start);
480 event->setDtEnd(end); 472 event->setDtEnd(end);
481 mCalendar->addEvent(event); 473 mCalendar->addEvent(event);
482 474
483 emit eventDropped(event); 475 emit eventDropped(event);
484 } else { 476 } else {
485// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl; 477// kdDebug() << "KODayMatrix::dropEvent(): Event from drop not decodable" << endl;
486 e->ignore(); 478 e->ignore();
487 } 479 }
488#endif 480#endif
489} 481}
490 482
491// ---------------------------------------------------------------------------- 483// ----------------------------------------------------------------------------
492// P A I N T E V E N T H A N D L I N G 484// P A I N T E V E N T H A N D L I N G
493// ---------------------------------------------------------------------------- 485// ----------------------------------------------------------------------------
494 486
495void KODayMatrix::paintEvent(QPaintEvent * pevent) 487void KODayMatrix::paintEvent(QPaintEvent * pevent)
496{ 488{
497//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl; 489//kdDebug() << "KODayMatrix::paintEvent() BEGIN" << endl;
498 490 if ( mPendingUpdateBeforeRepaint ) {
491 updateViewTimed();
492 mPendingUpdateBeforeRepaint = false;
493 }
499 QPainter p(this); 494 QPainter p(this);
500 495
501 QRect sz = frameRect(); 496 QRect sz = frameRect();
502 int dheight = daysize.height(); 497 int dheight = daysize.height();
503 int dwidth = daysize.width(); 498 int dwidth = daysize.width();
504 int row,col; 499 int row,col;
505 int selw, selh; 500 int selw, selh;
506 bool isRTL = KOGlobals::self()->reverseLayout(); 501 bool isRTL = KOGlobals::self()->reverseLayout();
507 502
508 // draw background and topleft frame 503 // draw background and topleft frame
509 p.fillRect(pevent->rect(), mDefaultBackColor); 504 p.fillRect(pevent->rect(), mDefaultBackColor);
510 p.setPen(mDefaultTextColor); 505 p.setPen(mDefaultTextColor);
511 p.drawRect(0, 0, sz.width()+1, sz.height()+1); 506 p.drawRect(0, 0, sz.width()+1, sz.height()+1);
512 507
513 // draw selected days with highlighted background color 508 // draw selected days with highlighted background color
514 if (mSelStart != NOSELECTION) { 509 if (mSelStart != NOSELECTION) {
515 510
516 row = mSelStart/7; 511 row = mSelStart/7;
517 col = mSelStart -row*7; 512 col = mSelStart -row*7;
518 QColor selcol = KOPrefs::instance()->mHighlightColor; 513 QColor selcol = KOPrefs::instance()->mHighlightColor;
519 514
520 if (row == mSelEnd/7) { 515 if (row == mSelEnd/7) {
521 // Single row selection 516 // Single row selection
522 p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth, 517 p.fillRect(isRTL ? (7 - (mSelEnd-mSelStart+1) - col)*dwidth : col*dwidth,
523 row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol); 518 row*dheight, (mSelEnd-mSelStart+1)*dwidth, dheight, selcol);
524 } else { 519 } else {
525 // draw first row to the right 520 // draw first row to the right
526 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth, 521 p.fillRect(isRTL ? 0 : col*dwidth, row*dheight, (7-col)*dwidth,
527 dheight, selcol); 522 dheight, selcol);
528 // draw full block till last line 523 // draw full block till last line
529 selh = mSelEnd/7-row; 524 selh = mSelEnd/7-row;
530 if (selh > 1) { 525 if (selh > 1) {
531 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol); 526 p.fillRect(0, (row+1)*dheight, 7*dwidth, (selh-1)*dheight,selcol);
532 } 527 }
533 // draw last block from left to mSelEnd 528 // draw last block from left to mSelEnd
534 selw = mSelEnd-7*(mSelEnd/7)+1; 529 selw = mSelEnd-7*(mSelEnd/7)+1;
535 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight, 530 p.fillRect(isRTL ? (7-selw)*dwidth : 0, (row+selh)*dheight,
536 selw*dwidth, dheight, selcol); 531 selw*dwidth, dheight, selcol);
537 } 532 }
538 } 533 }
539 534
540 // iterate over all days in the matrix and draw the day label in appropriate colors 535 // iterate over all days in the matrix and draw the day label in appropriate colors
541 QColor actcol = mDefaultTextColorShaded; 536 QColor actcol = mDefaultTextColorShaded;
542 p.setPen(actcol); 537 p.setPen(actcol);
543 QPen tmppen; 538 QPen tmppen;
544 for(int i = 0; i < NUMDAYS; i++) { 539 for(int i = 0; i < NUMDAYS; i++) {
545 row = i/7; 540 row = i/7;
546 col = isRTL ? 6-(i-row*7) : i-row*7; 541 col = isRTL ? 6-(i-row*7) : i-row*7;
547 542
548 // if it is the first day of a month switch color from normal to shaded and vice versa 543 // if it is the first day of a month switch color from normal to shaded and vice versa
549 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) { 544 if ( KOGlobals::self()->calendarSystem()->day( days[i] ) == 1) {
550 if (actcol == mDefaultTextColorShaded) { 545 if (actcol == mDefaultTextColorShaded) {
551 actcol = mDefaultTextColor; 546 actcol = mDefaultTextColor;
552 } else { 547 } else {
553 actcol = mDefaultTextColorShaded; 548 actcol = mDefaultTextColorShaded;
554 } 549 }
555 p.setPen(actcol); 550 p.setPen(actcol);
556 } 551 }
557 552
558 //Reset pen color after selected days block 553 //Reset pen color after selected days block
559 if (i == mSelEnd+1) { 554 if (i == mSelEnd+1) {
560 p.setPen(actcol); 555 p.setPen(actcol);
561 } 556 }
562 557
563 // if today then draw rectangle around day 558 // if today then draw rectangle around day
564 if (today == i) { 559 if (today == i) {
565 tmppen = p.pen(); 560 tmppen = p.pen();
566 QPen mTodayPen(p.pen()); 561 QPen mTodayPen(p.pen());
567 562
568 mTodayPen.setWidth(mTodayMarginWidth); 563 mTodayPen.setWidth(mTodayMarginWidth);
569 //draw red rectangle for holidays 564 //draw red rectangle for holidays
570 if (!mHolidays[i].isNull()) { 565 if (!mHolidays[i].isNull()) {
571 if (actcol == mDefaultTextColor) { 566 if (actcol == mDefaultTextColor) {
572 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 567 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
573 } else { 568 } else {
574 mTodayPen.setColor(mHolidayColorShaded); 569 mTodayPen.setColor(mHolidayColorShaded);
575 } 570 }
576 } 571 }
577 //draw gray rectangle for today if in selection 572 //draw gray rectangle for today if in selection
578 if (i >= mSelStart && i <= mSelEnd) { 573 if (i >= mSelStart && i <= mSelEnd) {
579 QColor grey("grey"); 574 QColor grey("grey");
580 mTodayPen.setColor(grey); 575 mTodayPen.setColor(grey);
581 } 576 }
582 p.setPen(mTodayPen); 577 p.setPen(mTodayPen);
583 p.drawRect(col*dwidth, row*dheight, dwidth, dheight); 578 p.drawRect(col*dwidth, row*dheight, dwidth, dheight);
584 p.setPen(tmppen); 579 p.setPen(tmppen);
585 } 580 }
586 581
587 // if any events are on that day then draw it using a bold font 582 // if any events are on that day then draw it using a bold font
588 if (events[i] > 0) { 583 if (events[i] > 0) {
589 QFont myFont = font(); 584 QFont myFont = font();
590 myFont.setBold(true); 585 myFont.setBold(true);
591 p.setFont(myFont); 586 p.setFont(myFont);
592 } 587 }
593 588
594 // if it is a holiday then use the default holiday color 589 // if it is a holiday then use the default holiday color
595 if (!mHolidays[i].isNull()) { 590 if (!mHolidays[i].isNull()) {
596 if (actcol == mDefaultTextColor) { 591 if (actcol == mDefaultTextColor) {
597 p.setPen(KOPrefs::instance()->mHolidayColor); 592 p.setPen(KOPrefs::instance()->mHolidayColor);
598 } else { 593 } else {
599 p.setPen(mHolidayColorShaded); 594 p.setPen(mHolidayColorShaded);
600 } 595 }
601 } 596 }
602 597
603 // draw selected days with special color 598 // draw selected days with special color
604 // DO NOT specially highlight holidays in selection ! 599 // DO NOT specially highlight holidays in selection !
605 if (i >= mSelStart && i <= mSelEnd) { 600 if (i >= mSelStart && i <= mSelEnd) {
606 p.setPen(mSelectedDaysColor); 601 p.setPen(mSelectedDaysColor);
607 } 602 }
608 603
609 p.drawText(col*dwidth, row*dheight, dwidth, dheight, 604 p.drawText(col*dwidth, row*dheight, dwidth, dheight,
610 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 605 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
611 606
612 // reset color to actual color 607 // reset color to actual color
613 if (!mHolidays[i].isNull()) { 608 if (!mHolidays[i].isNull()) {
614 p.setPen(actcol); 609 p.setPen(actcol);
615 } 610 }
616 // reset bold font to plain font 611 // reset bold font to plain font
617 if (events[i] > 0) { 612 if (events[i] > 0) {
618 QFont myFont = font(); 613 QFont myFont = font();
619 myFont.setBold(false); 614 myFont.setBold(false);
620 p.setFont(myFont); 615 p.setFont(myFont);
621 } 616 }
622 } 617 }
623} 618}
624 619
625// ---------------------------------------------------------------------------- 620// ----------------------------------------------------------------------------
626// R E SI Z E E V E N T H A N D L I N G 621// R E SI Z E E V E N T H A N D L I N G
627// ---------------------------------------------------------------------------- 622// ----------------------------------------------------------------------------
628 623
629void KODayMatrix::resizeEvent(QResizeEvent *) 624void KODayMatrix::resizeEvent(QResizeEvent *)
630{ 625{
631 QRect sz = frameRect(); 626 QRect sz = frameRect();
632 daysize.setHeight(sz.height()*7 / NUMDAYS); 627 daysize.setHeight(sz.height()*7 / NUMDAYS);
633 daysize.setWidth(sz.width() / 7); 628 daysize.setWidth(sz.width() / 7);
634} 629}
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index 0e9640a..ac2f59c 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -1,313 +1,314 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at> 3 Copyright (c) 2001 Eitzenberger Thomas <thomas.eitzenberger@siemens.at>
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 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef _KODAYMAT_H 23#ifndef _KODAYMAT_H
24#define _KODAYMAT_H 24#define _KODAYMAT_H
25 25
26#include <libkcal/calendar.h> 26#include <libkcal/calendar.h>
27 27
28#include <qstring.h> 28#include <qstring.h>
29#include <qframe.h> 29#include <qframe.h>
30#include <qcolor.h> 30#include <qcolor.h>
31#include <qpen.h> 31#include <qpen.h>
32#include <qdatetime.h> 32#include <qdatetime.h>
33#include <qtooltip.h> 33#include <qtooltip.h>
34 34
35#include <qmap.h> 35#include <qmap.h>
36 36
37class QDragEnterEvent; 37class QDragEnterEvent;
38class QDragMoveEvent; 38class QDragMoveEvent;
39class QDragLeaveEvent; 39class QDragLeaveEvent;
40class QDropEvent; 40class QDropEvent;
41 41
42class KODayMatrix; 42class KODayMatrix;
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46 46
47/** 47/**
48 * small helper class to dynamically show tooltips inside the day matrix. 48 * small helper class to dynamically show tooltips inside the day matrix.
49 * This class asks the day matrix object for a appropriate label which 49 * This class asks the day matrix object for a appropriate label which
50 * is in our special case the name of the holiday or null if this day is no holiday. 50 * is in our special case the name of the holiday or null if this day is no holiday.
51 */ 51 */
52class DynamicTip : public QToolTip 52class DynamicTip : public QToolTip
53{ 53{
54public: 54public:
55 55
56 /** 56 /**
57 * Constructor that expects a KODayMatrix object as parent. 57 * Constructor that expects a KODayMatrix object as parent.
58 * 58 *
59 * @param parent the parent KODayMatrix control. 59 * @param parent the parent KODayMatrix control.
60 */ 60 */
61 DynamicTip(QWidget* parent ); 61 DynamicTip(QWidget* parent );
62 62
63protected: 63protected:
64 64
65 /** 65 /**
66 * Qt's callback to ask the object to provide an approrpiate text for the 66 * Qt's callback to ask the object to provide an approrpiate text for the
67 * tooltip to be shown. 67 * tooltip to be shown.
68 * 68 *
69 * @param pos coordinates of the mouse. 69 * @param pos coordinates of the mouse.
70 */ 70 */
71 void maybeTip( const QPoint & pos); 71 void maybeTip( const QPoint & pos);
72 72
73private: 73private:
74 74
75 /** the parent control this tooltip is designed for. */ 75 /** the parent control this tooltip is designed for. */
76 KODayMatrix* matrix; 76 KODayMatrix* matrix;
77}; 77};
78 78
79/** 79/**
80 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed. 80 * replacement for kdpdatebuton.cpp that used 42 widgets for the day matrix to be displayed.
81 * Cornelius thought this was a waste of memory and a lot of overhead. 81 * Cornelius thought this was a waste of memory and a lot of overhead.
82 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame 82 * In addition the selection was not very intuitive so I decided to rewrite it using a QFrame
83 * that draws the labels and allows for dragging selection while maintaining nearly full 83 * that draws the labels and allows for dragging selection while maintaining nearly full
84 * compatibility in behaviour with its predecessor. 84 * compatibility in behaviour with its predecessor.
85 * 85 *
86 * The following functionality has been changed: 86 * The following functionality has been changed:
87 * 87 *
88 * o when shifting events in the agenda view from one day to another the day matrix is updated now 88 * o when shifting events in the agenda view from one day to another the day matrix is updated now
89 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date. 89 * o TODO ET dragging an event to the matrix will MOVE not COPY the event to the new date.
90 * o no support for Ctrl+click to create groups of dates 90 * o no support for Ctrl+click to create groups of dates
91 * (This has not really been supported in the predecessor. It was not very intuitive nor was it 91 * (This has not really been supported in the predecessor. It was not very intuitive nor was it
92 * user friendly.) 92 * user friendly.)
93 * This feature has been replaced with dragging a selection on the matrix. The matrix will 93 * This feature has been replaced with dragging a selection on the matrix. The matrix will
94 * automatically choose the appropriate selection (e.g. you are not any longer able to select 94 * automatically choose the appropriate selection (e.g. you are not any longer able to select
95 * two distinct groups of date selections as in the old class) 95 * two distinct groups of date selections as in the old class)
96 * o now that you can select more then a week it can happen that not all selected days are 96 * o now that you can select more then a week it can happen that not all selected days are
97 * displayed in the matrix. However this is preferred to the alternative which would mean to 97 * displayed in the matrix. However this is preferred to the alternative which would mean to
98 * adjust the selection and leave some days undisplayed while scrolling through the months 98 * adjust the selection and leave some days undisplayed while scrolling through the months
99 * 99 *
100 * @short day matrix widget of the KDateNavigator 100 * @short day matrix widget of the KDateNavigator
101 * 101 *
102 * @author Eitzenberger Thomas 102 * @author Eitzenberger Thomas
103 */ 103 */
104class KODayMatrix: public QFrame { 104class KODayMatrix: public QFrame {
105 105
106 Q_OBJECT 106 Q_OBJECT
107 107
108public: 108public:
109 109
110 /** constructor to create a day matrix widget. 110 /** constructor to create a day matrix widget.
111 * 111 *
112 * @param parent widget that is the parent of the day matrix. Normally this should 112 * @param parent widget that is the parent of the day matrix. Normally this should
113 * be a KDateNavigator 113 * be a KDateNavigator
114 * @param calendar instance of a calendar on which all calculations are based 114 * @param calendar instance of a calendar on which all calculations are based
115 * @param date start date of the matrix (is expected to be already fixed). It is 115 * @param date start date of the matrix (is expected to be already fixed). It is
116 * assumed that this date is the first week day to be shown in the matrix. 116 * assumed that this date is the first week day to be shown in the matrix.
117 * @param name name of the widget 117 * @param name name of the widget
118 */ 118 */
119 KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name ); 119 KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name );
120 120
121 /** destructor that deallocates all dynamically allocated private members. 121 /** destructor that deallocates all dynamically allocated private members.
122 */ 122 */
123 ~KODayMatrix(); 123 ~KODayMatrix();
124 124
125 /** updates the day matrix to start with the given date. Does all the necessary 125 /** updates the day matrix to start with the given date. Does all the necessary
126 * checks for holidays or events on a day and stores them for display later on. 126 * checks for holidays or events on a day and stores them for display later on.
127 * Does NOT update the view visually. Call repaint() for this. 127 * Does NOT update the view visually. Call repaint() for this.
128 * 128 *
129 * @param actdate recalculates the day matrix to show NUMDAYS starting from this 129 * @param actdate recalculates the day matrix to show NUMDAYS starting from this
130 * date. 130 * date.
131 */ 131 */
132 void updateView(QDate actdate); 132 void updateView(QDate actdate);
133 133
134 /** returns the QDate object associated with day indexed by the 134 /** returns the QDate object associated with day indexed by the
135 * supplied offset. 135 * supplied offset.
136 */ 136 */
137 const QDate& getDate(int offset); 137 const QDate& getDate(int offset);
138 138
139 /** returns the official name of this holy day or 0 if there is no label 139 /** returns the official name of this holy day or 0 if there is no label
140 * for this day. 140 * for this day.
141 */ 141 */
142 QString getHolidayLabel(int offset); 142 QString getHolidayLabel(int offset);
143 143
144 /** adds all actual selected days from mSelStart to mSelEnd to the supplied 144 /** adds all actual selected days from mSelStart to mSelEnd to the supplied
145 * DateList. 145 * DateList.
146 */ 146 */
147 void addSelectedDaysTo(DateList&); 147 void addSelectedDaysTo(DateList&);
148 148
149 /** sets the actual to be displayed selection in the day matrix starting from 149 /** sets the actual to be displayed selection in the day matrix starting from
150 * start and ending with end. Theview must be manually updated by calling 150 * start and ending with end. Theview must be manually updated by calling
151 * repaint. (?) 151 * repaint. (?)
152 */ 152 */
153 void setSelectedDaysFrom(const QDate& start, const QDate& end); 153 void setSelectedDaysFrom(const QDate& start, const QDate& end);
154 154
155 155
156 /** Is today visible in the view? Keep this in sync with 156 /** Is today visible in the view? Keep this in sync with
157 * the values today (below) can take. 157 * the values today (below) can take.
158 */ 158 */
159 bool isTodayVisible() const { return today>=0; } ; 159 bool isTodayVisible() const { return today>=0; } ;
160 160
161 /** If today is visible, then we can find out if today is 161 /** If today is visible, then we can find out if today is
162 * near the beginning or the end of the month. 162 * near the beginning or the end of the month.
163 * This is dependent on today remaining the index 163 * This is dependent on today remaining the index
164 * in the array of visible dates and going from 164 * in the array of visible dates and going from
165 * top left (0) to bottom right (41). 165 * top left (0) to bottom right (41).
166 */ 166 */
167 bool isBeginningOfMonth() const { return today<=8; } ; 167 bool isBeginningOfMonth() const { return today<=8; } ;
168 bool isEndOfMonth() const { return today>=27; } ; 168 bool isEndOfMonth() const { return today>=27; } ;
169 169
170public slots: 170public slots:
171 /** Recalculates all the flags of the days in the matrix like holidays or events 171 /** Recalculates all the flags of the days in the matrix like holidays or events
172 * on a day (Actually calls above method with the actual startdate). 172 * on a day (Actually calls above method with the actual startdate).
173 */ 173 */
174 void updateView(); 174 void updateView();
175 void updateViewTimed(); 175 void updateViewTimed();
176 void repaintViewTimed(); 176 void repaintViewTimed();
177 177
178 /** 178 /**
179 * Calculate which square in the matrix should be 179 * Calculate which square in the matrix should be
180 * hilighted to indicate it's today. 180 * hilighted to indicate it's today.
181 */ 181 */
182 void recalculateToday(); 182 void recalculateToday();
183 183
184/* 184/*
185 void setStartDate(QDate); 185 void setStartDate(QDate);
186*/ 186*/
187 187
188signals: 188signals:
189 189
190 /** emitted if the user selects a block of days with the mouse by dragging a rectangle 190 /** emitted if the user selects a block of days with the mouse by dragging a rectangle
191 * inside the matrix 191 * inside the matrix
192 * 192 *
193 * @param daylist list of days that have been selected by the user 193 * @param daylist list of days that have been selected by the user
194 */ 194 */
195 void selected( const KCal::DateList &daylist ); 195 void selected( const KCal::DateList &daylist );
196 196
197 /** emitted if the user has dropped an event inside the matrix 197 /** emitted if the user has dropped an event inside the matrix
198 * 198 *
199 * @param event the dropped calendar event 199 * @param event the dropped calendar event
200 */ 200 */
201 void eventDropped(Event *event); 201 void eventDropped(Event *event);
202 202
203protected: 203protected:
204 204
205 void paintEvent(QPaintEvent *ev); 205 void paintEvent(QPaintEvent *ev);
206 206
207 void mousePressEvent (QMouseEvent* e); 207 void mousePressEvent (QMouseEvent* e);
208 208
209 void mouseReleaseEvent (QMouseEvent* e); 209 void mouseReleaseEvent (QMouseEvent* e);
210 210
211 void mouseMoveEvent (QMouseEvent* e); 211 void mouseMoveEvent (QMouseEvent* e);
212 212
213 void dragEnterEvent(QDragEnterEvent *); 213 void dragEnterEvent(QDragEnterEvent *);
214 214
215 void dragMoveEvent(QDragMoveEvent *); 215 void dragMoveEvent(QDragMoveEvent *);
216 216
217 void dragLeaveEvent(QDragLeaveEvent *); 217 void dragLeaveEvent(QDragLeaveEvent *);
218 218
219 void dropEvent(QDropEvent *); 219 void dropEvent(QDropEvent *);
220 220
221 void resizeEvent(QResizeEvent *); 221 void resizeEvent(QResizeEvent *);
222 222
223private: 223private:
224 QTimer* mUpdateTimer; 224 QTimer* mUpdateTimer;
225 QTimer* mRepaintTimer; 225 QTimer* mRepaintTimer;
226 bool mDayChanged; 226 bool mDayChanged;
227 bool mPendingUpdateBeforeRepaint;
227 228
228 /** returns the index of the day located at the matrix's widget (x,y) position. 229 /** returns the index of the day located at the matrix's widget (x,y) position.
229 * 230 *
230 * @param x horizontal coordinate 231 * @param x horizontal coordinate
231 * @param y vertical coordinate 232 * @param y vertical coordinate
232 */ 233 */
233 int getDayIndexFrom(int x, int y); 234 int getDayIndexFrom(int x, int y);
234 235
235 /** calculates a "shaded" color from the supplied color object. 236 /** calculates a "shaded" color from the supplied color object.
236 * (Copied from Cornelius's kdpdatebutton.cpp) 237 * (Copied from Cornelius's kdpdatebutton.cpp)
237 * 238 *
238 * @param color source based on which a shaded color should be calculated. 239 * @param color source based on which a shaded color should be calculated.
239 */ 240 */
240 QColor getShadedColor(QColor color); 241 QColor getShadedColor(QColor color);
241 242
242 /** number of days to be displayed. For now there is no support for any other number then 42. 243 /** number of days to be displayed. For now there is no support for any other number then 42.
243 so change it at your own risk :o) */ 244 so change it at your own risk :o) */
244 static const int NUMDAYS; 245 static const int NUMDAYS;
245 246
246 /** calendar instance to be queried for holidays, events, ... */ 247 /** calendar instance to be queried for holidays, events, ... */
247 Calendar *mCalendar; 248 Calendar *mCalendar;
248 249
249 /** starting date of the matrix */ 250 /** starting date of the matrix */
250 QDate startdate; 251 QDate startdate;
251 252
252 /** array of day labels to optimeize drawing performance. */ 253 /** array of day labels to optimeize drawing performance. */
253 QString *daylbls; 254 QString *daylbls;
254 255
255 /** array of days displayed to reduce memory consumption by 256 /** array of days displayed to reduce memory consumption by
256 subsequently calling QDate::addDays(). */ 257 subsequently calling QDate::addDays(). */
257 QDate *days; 258 QDate *days;
258 259
259 /** array of storing the number of events on a given day. 260 /** array of storing the number of events on a given day.
260 * used for drawing a bold font if there is at least one event on that day. 261 * used for drawing a bold font if there is at least one event on that day.
261 */ 262 */
262 int *events; 263 int *events;
263 264
264 /** stores holiday names of the days shown in the matrix. */ 265 /** stores holiday names of the days shown in the matrix. */
265 QMap<int,QString> mHolidays; 266 QMap<int,QString> mHolidays;
266 267
267 /** indey of today or -1 if today is not visible in the matrix. */ 268 /** indey of today or -1 if today is not visible in the matrix. */
268 int today; 269 int today;
269 270
270 /** index of day where dragged selection was initiated. 271 /** index of day where dragged selection was initiated.
271 used to detect "negative" timely selections */ 272 used to detect "negative" timely selections */
272 int mSelInit; 273 int mSelInit;
273 274
274 /** if mSelStart has this value it indicates that there is no 275 /** if mSelStart has this value it indicates that there is no
275 actual selection in the matrix. */ 276 actual selection in the matrix. */
276 static const int NOSELECTION; 277 static const int NOSELECTION;
277 278
278 /** index of first selected day. */ 279 /** index of first selected day. */
279 int mSelStart; 280 int mSelStart;
280 281
281 /** index of last selected day. */ 282 /** index of last selected day. */
282 int mSelEnd; 283 int mSelEnd;
283 284
284 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */ 285 /** dynamic tooltip to handle mouse dependent tips for each day in the matrix. */
285 DynamicTip* mToolTip; 286 DynamicTip* mToolTip;
286 287
287 288
288 /** default background colour of the matrix. */ 289 /** default background colour of the matrix. */
289 QColor mDefaultBackColor; 290 QColor mDefaultBackColor;
290 291
291 /** default text color of the matrix. */ 292 /** default text color of the matrix. */
292 QColor mDefaultTextColor; 293 QColor mDefaultTextColor;
293 294
294 /** default text color for days not in the actual month. */ 295 /** default text color for days not in the actual month. */
295 QColor mDefaultTextColorShaded; 296 QColor mDefaultTextColorShaded;
296 297
297 /** default text color for holidays not in the actual month. */ 298 /** default text color for holidays not in the actual month. */
298 QColor mHolidayColorShaded; 299 QColor mHolidayColorShaded;
299 300
300 /** text color for selected days. */ 301 /** text color for selected days. */
301 QColor mSelectedDaysColor; 302 QColor mSelectedDaysColor;
302 303
303 /** default width of the frame drawn around today if it is visible in the matrix. */ 304 /** default width of the frame drawn around today if it is visible in the matrix. */
304 int mTodayMarginWidth; 305 int mTodayMarginWidth;
305 306
306 /** stores actual size of each day in the widget so that I dont need to ask this data 307 /** stores actual size of each day in the widget so that I dont need to ask this data
307 * on every repaint. 308 * on every repaint.
308 */ 309 */
309 QRect daysize; 310 QRect daysize;
310 311
311}; 312};
312 313
313#endif 314#endif