summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-03-18 15:11:51 (UTC)
committer zautrix <zautrix>2005-03-18 15:11:51 (UTC)
commit66bc0202d4e2306f7029362fe09d0c7ab0e7cc36 (patch) (unidiff)
treeeafee97f377c32339488833065313c2494e1f5a5
parent414cb038cbe353f2fdb90969bc2531b687acc85f (diff)
downloadkdepimpi-66bc0202d4e2306f7029362fe09d0c7ab0e7cc36.zip
kdepimpi-66bc0202d4e2306f7029362fe09d0c7ab0e7cc36.tar.gz
kdepimpi-66bc0202d4e2306f7029362fe09d0c7ab0e7cc36.tar.bz2
rec fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 004ff50..cb69832 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -751,948 +751,957 @@ Incidence *MonthViewCell::selectedIncidence()
751 751
752 MonthViewItem *item = 752 MonthViewItem *item =
753 static_cast<MonthViewItem *>( mItemList->item( index ) ); 753 static_cast<MonthViewItem *>( mItemList->item( index ) );
754 754
755 if ( !item ) return 0; 755 if ( !item ) return 0;
756 756
757 return item->incidence(); 757 return item->incidence();
758} 758}
759 759
760QDate MonthViewCell::selectedIncidenceDate() 760QDate MonthViewCell::selectedIncidenceDate()
761{ 761{
762 QDate qd; 762 QDate qd;
763 int index = mItemList->currentItem(); 763 int index = mItemList->currentItem();
764 if ( index < 0 ) return qd; 764 if ( index < 0 ) return qd;
765 765
766 MonthViewItem *item = 766 MonthViewItem *item =
767 static_cast<MonthViewItem *>( mItemList->item( index ) ); 767 static_cast<MonthViewItem *>( mItemList->item( index ) );
768 768
769 if ( !item ) return qd; 769 if ( !item ) return qd;
770 770
771 return item->incidenceDate(); 771 return item->incidenceDate();
772} 772}
773 773
774void MonthViewCell::deselect() 774void MonthViewCell::deselect()
775{ 775{
776 mItemList->clearSelection(); 776 mItemList->clearSelection();
777 enableScrollBars( false ); 777 enableScrollBars( false );
778 // updateCell(); 778 // updateCell();
779} 779}
780void MonthViewCell::select() 780void MonthViewCell::select()
781{ 781{
782 ;// updateCell(); 782 ;// updateCell();
783} 783}
784 784
785void MonthViewCell::resizeEvent ( QResizeEvent * ) 785void MonthViewCell::resizeEvent ( QResizeEvent * )
786{ 786{
787 if ( !mMonthView->isUpdatePossible() ) 787 if ( !mMonthView->isUpdatePossible() )
788 return; 788 return;
789 789
790 int size = height() - mLabel->height() - 2; 790 int size = height() - mLabel->height() - 2;
791 if ( size > 0 ) 791 if ( size > 0 )
792 mItemList->verticalScrollBar()->setMaximumHeight( size ); 792 mItemList->verticalScrollBar()->setMaximumHeight( size );
793 size = width() - mLabel->width() -2; 793 size = width() - mLabel->width() -2;
794 if ( size > 0 ) 794 if ( size > 0 )
795 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 795 mItemList->horizontalScrollBar()->setMaximumWidth( size );
796 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 796 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
797 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 797 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
798} 798}
799 799
800void MonthViewCell::defaultAction( QListBoxItem *item ) 800void MonthViewCell::defaultAction( QListBoxItem *item )
801{ 801{
802 if ( !item ) return; 802 if ( !item ) return;
803 803
804 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 804 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
805 Incidence *incidence = eventItem->incidence(); 805 Incidence *incidence = eventItem->incidence();
806 if ( incidence ) mMonthView->defaultAction( incidence ); 806 if ( incidence ) mMonthView->defaultAction( incidence );
807} 807}
808void MonthViewCell::showDay() 808void MonthViewCell::showDay()
809{ 809{
810 emit showDaySignal( date() ); 810 emit showDaySignal( date() );
811} 811}
812void MonthViewCell::newEvent() 812void MonthViewCell::newEvent()
813{ 813{
814 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 814 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
815 emit newEventSignal( dt ); 815 emit newEventSignal( dt );
816} 816}
817void MonthViewCell::cellClicked( QListBoxItem *item ) 817void MonthViewCell::cellClicked( QListBoxItem *item )
818{ 818{
819 static QListBoxItem * lastClicked = 0; 819 static QListBoxItem * lastClicked = 0;
820 if ( item == 0 ) { 820 if ( item == 0 ) {
821 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 821 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
822 emit newEventSignal( dt ); 822 emit newEventSignal( dt );
823 return; 823 return;
824 } 824 }
825 /* 825 /*
826 if ( lastClicked ) 826 if ( lastClicked )
827 if ( ! item ) { 827 if ( ! item ) {
828 if ( lastClicked->listBox() != item->listBox() ) 828 if ( lastClicked->listBox() != item->listBox() )
829 lastClicked->listBox()->clearSelection(); 829 lastClicked->listBox()->clearSelection();
830 } 830 }
831 */ 831 */
832 832
833 mMonthView->setSelectedCell( this ); 833 mMonthView->setSelectedCell( this );
834 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 834 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
835 select(); 835 select();
836} 836}
837 837
838void MonthViewCell::contextMenu( QListBoxItem *item ) 838void MonthViewCell::contextMenu( QListBoxItem *item )
839{ 839{
840 if ( !item ) return; 840 if ( !item ) return;
841 841
842 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 842 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
843 Incidence *incidence = eventItem->incidence(); 843 Incidence *incidence = eventItem->incidence();
844 if ( incidence ) mMonthView->showContextMenu( incidence ); 844 if ( incidence ) mMonthView->showContextMenu( incidence );
845} 845}
846 846
847void MonthViewCell::selection( QListBoxItem *item ) 847void MonthViewCell::selection( QListBoxItem *item )
848{ 848{
849 if ( !item ) return; 849 if ( !item ) return;
850 850
851 mMonthView->setSelectedCell( this ); 851 mMonthView->setSelectedCell( this );
852} 852}
853 853
854 854
855// ******************************************************************************* 855// *******************************************************************************
856// ******************************************************************************* 856// *******************************************************************************
857// ******************************************************************************* 857// *******************************************************************************
858 858
859 859
860KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 860KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
861 : KOEventView( calendar, parent, name ), 861 : KOEventView( calendar, parent, name ),
862 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 862 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
863 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 863 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
864{ 864{
865 mShortDayLabelsM = false; 865 mShortDayLabelsM = false;
866 mShortDayLabelsW = false; 866 mShortDayLabelsW = false;
867 skipResize = false; 867 skipResize = false;
868 clPending = true; 868 clPending = true;
869 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 869 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
870 mWidStack = new QWidgetStack( this ); 870 mWidStack = new QWidgetStack( this );
871 QVBoxLayout* hb = new QVBoxLayout( this ); 871 QVBoxLayout* hb = new QVBoxLayout( this );
872 mMonthView = new QWidget( mWidStack ); 872 mMonthView = new QWidget( mWidStack );
873 mWeekView = new QWidget( mWidStack ); 873 mWeekView = new QWidget( mWidStack );
874#if QT_VERSION >= 0x030000 874#if QT_VERSION >= 0x030000
875 mWidStack->addWidget(mMonthView ); 875 mWidStack->addWidget(mMonthView );
876 mWidStack->addWidget(mWeekView ); 876 mWidStack->addWidget(mWeekView );
877#else 877#else
878 mWidStack->addWidget( mMonthView, 1 ); 878 mWidStack->addWidget( mMonthView, 1 );
879 mWidStack->addWidget( mWeekView , 1 ); 879 mWidStack->addWidget( mWeekView , 1 );
880#endif 880#endif
881 hb->addWidget( mNavigatorBar ); 881 hb->addWidget( mNavigatorBar );
882 hb->addWidget( mWidStack ); 882 hb->addWidget( mWidStack );
883 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 883 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
884 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 884 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
885 if ( mShowWeekView ) 885 if ( mShowWeekView )
886 mWeekStartsMonday = true; 886 mWeekStartsMonday = true;
887 updatePossible = false; 887 updatePossible = false;
888 //updatePossible = true; 888 //updatePossible = true;
889 mCells.setAutoDelete( true ); 889 mCells.setAutoDelete( true );
890 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 890 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
891 mDayLabels.resize( mDaysPerWeek ); 891 mDayLabels.resize( mDaysPerWeek );
892 mDayLabelsW.resize( mDaysPerWeek ); 892 mDayLabelsW.resize( mDaysPerWeek );
893 QFont bfont = font(); 893 QFont bfont = font();
894 if ( QApplication::desktop()->width() < 650 ) { 894 if ( QApplication::desktop()->width() < 650 ) {
895 bfont.setPointSize( bfont.pointSize() - 2 ); 895 bfont.setPointSize( bfont.pointSize() - 2 );
896 } 896 }
897 bfont.setBold( true ); 897 bfont.setBold( true );
898 int i; 898 int i;
899 899
900 for( i = 0; i < mDaysPerWeek; i++ ) { 900 for( i = 0; i < mDaysPerWeek; i++ ) {
901 QLabel *label = new QLabel( mMonthView ); 901 QLabel *label = new QLabel( mMonthView );
902 label->setFont(bfont); 902 label->setFont(bfont);
903 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 903 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
904 label->setLineWidth(1); 904 label->setLineWidth(1);
905 label->setAlignment(AlignCenter); 905 label->setAlignment(AlignCenter);
906 mDayLabels.insert( i, label ); 906 mDayLabels.insert( i, label );
907 label = new QLabel( mWeekView ); 907 label = new QLabel( mWeekView );
908 label->setFont(bfont); 908 label->setFont(bfont);
909 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 909 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
910 label->setLineWidth(1); 910 label->setLineWidth(1);
911 label->setAlignment(AlignCenter); 911 label->setAlignment(AlignCenter);
912 mDayLabelsW.insert( i, label ); 912 mDayLabelsW.insert( i, label );
913 } 913 }
914 914
915 bfont.setBold( false ); 915 bfont.setBold( false );
916 mWeekLabels.resize( mNumWeeks+1 ); 916 mWeekLabels.resize( mNumWeeks+1 );
917 mWeekLabelsW.resize( 2 ); 917 mWeekLabelsW.resize( 2 );
918 for( i = 0; i < mNumWeeks+1; i++ ) { 918 for( i = 0; i < mNumWeeks+1; i++ ) {
919 KOWeekButton *label = new KOWeekButton( mMonthView ); 919 KOWeekButton *label = new KOWeekButton( mMonthView );
920 label->setFocusPolicy(NoFocus); 920 label->setFocusPolicy(NoFocus);
921 label->setFont(bfont); 921 label->setFont(bfont);
922 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 922 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
923 label->setFlat(true); 923 label->setFlat(true);
924 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 924 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
925 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 925 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
926 //label->setLineWidth(1); 926 //label->setLineWidth(1);
927 //label->setAlignment(AlignCenter); 927 //label->setAlignment(AlignCenter);
928 mWeekLabels.insert( i, label ); 928 mWeekLabels.insert( i, label );
929 } 929 }
930 mWeekLabels[mNumWeeks]->setText( i18n("W")); 930 mWeekLabels[mNumWeeks]->setText( i18n("W"));
931 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 931 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
932 932
933 for( i = 0; i < 1+1; i++ ) { 933 for( i = 0; i < 1+1; i++ ) {
934 KOWeekButton *label = new KOWeekButton( mWeekView ); 934 KOWeekButton *label = new KOWeekButton( mWeekView );
935 label->setFocusPolicy(NoFocus); 935 label->setFocusPolicy(NoFocus);
936 label->setFont(bfont); 936 label->setFont(bfont);
937 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 937 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
938 label->setFlat(true); 938 label->setFlat(true);
939 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 939 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
940 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 940 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
941 //label->setLineWidth(1); 941 //label->setLineWidth(1);
942 //label->setAlignment(AlignCenter); 942 //label->setAlignment(AlignCenter);
943 mWeekLabelsW.insert( i, label ); 943 mWeekLabelsW.insert( i, label );
944 } 944 }
945 mWeekLabelsW[1]->setText( i18n("W")); 945 mWeekLabelsW[1]->setText( i18n("W"));
946 946
947 947
948 int row, col; 948 int row, col;
949 mCells.resize( mNumCells ); 949 mCells.resize( mNumCells );
950 for( row = 0; row < mNumWeeks; ++row ) { 950 for( row = 0; row < mNumWeeks; ++row ) {
951 for( col = 0; col < mDaysPerWeek; ++col ) { 951 for( col = 0; col < mDaysPerWeek; ++col ) {
952 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 952 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
953 mCells.insert( row * mDaysPerWeek + col, cell ); 953 mCells.insert( row * mDaysPerWeek + col, cell );
954 954
955 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 955 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
956 SLOT( defaultAction( Incidence * ) ) ); 956 SLOT( defaultAction( Incidence * ) ) );
957 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 957 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
958 SIGNAL( newEventSignal( QDateTime ) ) ); 958 SIGNAL( newEventSignal( QDateTime ) ) );
959 connect( cell, SIGNAL( showDaySignal( QDate ) ), 959 connect( cell, SIGNAL( showDaySignal( QDate ) ),
960 SIGNAL( showDaySignal( QDate ) ) ); 960 SIGNAL( showDaySignal( QDate ) ) );
961 } 961 }
962 } 962 }
963 mCellsW.resize( mDaysPerWeek ); 963 mCellsW.resize( mDaysPerWeek );
964 for( col = 0; col < mDaysPerWeek; ++col ) { 964 for( col = 0; col < mDaysPerWeek; ++col ) {
965 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 965 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
966 mCellsW.insert( col, cell ); 966 mCellsW.insert( col, cell );
967 967
968 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 968 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
969 SLOT( defaultAction( Incidence * ) ) ); 969 SLOT( defaultAction( Incidence * ) ) );
970 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 970 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
971 SIGNAL( newEventSignal( QDateTime ) ) ); 971 SIGNAL( newEventSignal( QDateTime ) ) );
972 connect( cell, SIGNAL( showDaySignal( QDate ) ), 972 connect( cell, SIGNAL( showDaySignal( QDate ) ),
973 SIGNAL( showDaySignal( QDate ) ) ); 973 SIGNAL( showDaySignal( QDate ) ) );
974 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 974 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
975 } 975 }
976 976
977 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 977 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
978 mContextMenu = eventPopup(); 978 mContextMenu = eventPopup();
979 // updateConfig(); //useless here... 979 // updateConfig(); //useless here...
980 // ... but we need mWidthLongDayLabel computed 980 // ... but we need mWidthLongDayLabel computed
981 QFontMetrics fontmetric(mDayLabels[0]->font()); 981 QFontMetrics fontmetric(mDayLabels[0]->font());
982 mWidthLongDayLabel = 0; 982 mWidthLongDayLabel = 0;
983 for (int i = 0; i < 7; i++) { 983 for (int i = 0; i < 7; i++) {
984 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 984 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
985 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 985 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
986 } 986 }
987 987
988 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 988 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
989 989
990#if 0 990#if 0
991 if ( mShowWeekView ) 991 if ( mShowWeekView )
992 mWidStack->raiseWidget( mWeekView ); 992 mWidStack->raiseWidget( mWeekView );
993 else 993 else
994 mWidStack->raiseWidget( mMonthView ); 994 mWidStack->raiseWidget( mMonthView );
995#endif 995#endif
996 996
997 emit incidenceSelected( 0 ); 997 emit incidenceSelected( 0 );
998#ifndef DESKTOP_VERSION 998#ifndef DESKTOP_VERSION
999 resize( QApplication::desktop()->size() ); 999 resize( QApplication::desktop()->size() );
1000#else 1000#else
1001 resize(640, 480 ); 1001 resize(640, 480 );
1002 updatePossible = true; 1002 updatePossible = true;
1003#endif 1003#endif
1004 computeLayout(); 1004 computeLayout();
1005 1005
1006 if ( mShowWeekView ) 1006 if ( mShowWeekView )
1007 mWidStack->raiseWidget( mWeekView ); 1007 mWidStack->raiseWidget( mWeekView );
1008 else 1008 else
1009 mWidStack->raiseWidget( mMonthView ); 1009 mWidStack->raiseWidget( mMonthView );
1010} 1010}
1011 1011
1012KOMonthView::~KOMonthView() 1012KOMonthView::~KOMonthView()
1013{ 1013{
1014 delete mContextMenu; 1014 delete mContextMenu;
1015} 1015}
1016 1016
1017void KOMonthView::selectInternalWeekNum ( int n ) 1017void KOMonthView::selectInternalWeekNum ( int n )
1018{ 1018{
1019 switchView(); 1019 switchView();
1020 if ( !KOPrefs::instance()->mMonthViewWeek ) 1020 if ( !KOPrefs::instance()->mMonthViewWeek )
1021 emit selectMonth (); 1021 emit selectMonth ();
1022 else 1022 else
1023 emit selectWeekNum ( n ); 1023 emit selectWeekNum ( n );
1024} 1024}
1025 1025
1026int KOMonthView::currentWeek() 1026int KOMonthView::currentWeek()
1027{ 1027{
1028 if ( mShowWeekView ) 1028 if ( mShowWeekView )
1029 return mWeekLabelsW[0]->getWeekNum(); 1029 return mWeekLabelsW[0]->getWeekNum();
1030 return mWeekLabels[0]->getWeekNum(); 1030 return mWeekLabels[0]->getWeekNum();
1031} 1031}
1032void KOMonthView::switchView() 1032void KOMonthView::switchView()
1033{ 1033{
1034 if ( selectedCell( ) ) 1034 if ( selectedCell( ) )
1035 selectedCell()->deselect(); 1035 selectedCell()->deselect();
1036 mShowWeekView = !mShowWeekView; 1036 mShowWeekView = !mShowWeekView;
1037 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1037 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1038 if ( clPending ) { 1038 if ( clPending ) {
1039 computeLayout(); 1039 computeLayout();
1040 updateConfig(); 1040 updateConfig();
1041 } 1041 }
1042 if ( mShowWeekView ) 1042 if ( mShowWeekView )
1043 mWidStack->raiseWidget( mWeekView ); 1043 mWidStack->raiseWidget( mWeekView );
1044 else 1044 else
1045 mWidStack->raiseWidget( mMonthView ); 1045 mWidStack->raiseWidget( mMonthView );
1046 clPending = false; 1046 clPending = false;
1047} 1047}
1048 1048
1049int KOMonthView::maxDatesHint() 1049int KOMonthView::maxDatesHint()
1050{ 1050{
1051 return mNumCells; 1051 return mNumCells;
1052} 1052}
1053 1053
1054int KOMonthView::currentDateCount() 1054int KOMonthView::currentDateCount()
1055{ 1055{
1056 return mNumCells; 1056 return mNumCells;
1057} 1057}
1058 1058
1059QPtrList<Incidence> KOMonthView::selectedIncidences() 1059QPtrList<Incidence> KOMonthView::selectedIncidences()
1060{ 1060{
1061 QPtrList<Incidence> selected; 1061 QPtrList<Incidence> selected;
1062 1062
1063 if ( mSelectedCell ) { 1063 if ( mSelectedCell ) {
1064 Incidence *incidence = mSelectedCell->selectedIncidence(); 1064 Incidence *incidence = mSelectedCell->selectedIncidence();
1065 if ( incidence ) selected.append( incidence ); 1065 if ( incidence ) selected.append( incidence );
1066 } 1066 }
1067 1067
1068 return selected; 1068 return selected;
1069} 1069}
1070 1070
1071DateList KOMonthView::selectedDates() 1071DateList KOMonthView::selectedDates()
1072{ 1072{
1073 DateList selected; 1073 DateList selected;
1074 1074
1075 if ( mSelectedCell ) { 1075 if ( mSelectedCell ) {
1076 QDate qd = mSelectedCell->selectedIncidenceDate(); 1076 QDate qd = mSelectedCell->selectedIncidenceDate();
1077 if ( qd.isValid() ) selected.append( qd ); 1077 if ( qd.isValid() ) selected.append( qd );
1078 } 1078 }
1079 1079
1080 return selected; 1080 return selected;
1081} 1081}
1082 1082
1083void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1083void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1084 const QDate &td) 1084 const QDate &td)
1085{ 1085{
1086#ifndef KORG_NOPRINTER 1086#ifndef KORG_NOPRINTER
1087 calPrinter->preview(CalPrinter::Month, fd, td); 1087 calPrinter->preview(CalPrinter::Month, fd, td);
1088#endif 1088#endif
1089} 1089}
1090 1090
1091void KOMonthView::updateConfig() 1091void KOMonthView::updateConfig()
1092{ 1092{
1093 1093
1094 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1094 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1095 1095
1096 if ( mShowWeekView ) { 1096 if ( mShowWeekView ) {
1097 mWeekStartsMonday = true; 1097 mWeekStartsMonday = true;
1098 } 1098 }
1099 QFontMetrics fontmetric(mDayLabels[0]->font()); 1099 QFontMetrics fontmetric(mDayLabels[0]->font());
1100 mWidthLongDayLabel = 0; 1100 mWidthLongDayLabel = 0;
1101 1101
1102 for (int i = 0; i < 7; i++) { 1102 for (int i = 0; i < 7; i++) {
1103 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1103 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1104 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1104 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1105 } 1105 }
1106 bool temp = mShowSatSunComp ; 1106 bool temp = mShowSatSunComp ;
1107 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1107 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1108 if ( ! mShowWeekView ) { 1108 if ( ! mShowWeekView ) {
1109 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1109 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1110 computeLayout(); 1110 computeLayout();
1111 } 1111 }
1112 updateDayLabels(); 1112 updateDayLabels();
1113 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1113 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1114 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1114 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1115 //resizeEvent( 0 ); 1115 //resizeEvent( 0 );
1116 for (uint i = 0; i < mCells.count(); ++i) { 1116 for (uint i = 0; i < mCells.count(); ++i) {
1117 mCells[i]->updateConfig(); 1117 mCells[i]->updateConfig();
1118 } 1118 }
1119 1119
1120 for (uint i = 0; i < mCellsW.count(); ++i) { 1120 for (uint i = 0; i < mCellsW.count(); ++i) {
1121 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1121 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1122 } 1122 }
1123#ifdef DESKTOP_VERSION 1123#ifdef DESKTOP_VERSION
1124 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1124 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1125#endif 1125#endif
1126 updateView(); 1126 updateView();
1127} 1127}
1128 1128
1129void KOMonthView::updateDayLabels() 1129void KOMonthView::updateDayLabels()
1130{ 1130{
1131 1131
1132 QPtrVector<QLabel> *mDayLabelsT; 1132 QPtrVector<QLabel> *mDayLabelsT;
1133 1133
1134 mDayLabelsT = &mDayLabelsW; 1134 mDayLabelsT = &mDayLabelsW;
1135 for (int i = 0; i < 7; i++) { 1135 for (int i = 0; i < 7; i++) {
1136 if (mWeekStartsMonday) { 1136 if (mWeekStartsMonday) {
1137 bool show = mShortDayLabelsW; 1137 bool show = mShortDayLabelsW;
1138 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1138 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1139 show = true; 1139 show = true;
1140 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1140 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1141 } else { 1141 } else {
1142 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); 1142 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW));
1143 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); 1143 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW));
1144 1144
1145 } 1145 }
1146 } 1146 }
1147 mDayLabelsT = &mDayLabels; 1147 mDayLabelsT = &mDayLabels;
1148 for (int i = 0; i < 7; i++) { 1148 for (int i = 0; i < 7; i++) {
1149 if (mWeekStartsMonday) { 1149 if (mWeekStartsMonday) {
1150 bool show = mShortDayLabelsM; 1150 bool show = mShortDayLabelsM;
1151 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1151 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1152 show = true; 1152 show = true;
1153 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1153 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1154 } else { 1154 } else {
1155 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1155 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1156 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1156 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1157 1157
1158 } 1158 }
1159 } 1159 }
1160 1160
1161} 1161}
1162 1162
1163void KOMonthView::showDates(const QDate &start, const QDate &) 1163void KOMonthView::showDates(const QDate &start, const QDate &)
1164{ 1164{
1165 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1165 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1166 1166
1167 QPtrVector<MonthViewCell> *cells; 1167 QPtrVector<MonthViewCell> *cells;
1168 QPtrVector<QLabel> *dayLabels; 1168 QPtrVector<QLabel> *dayLabels;
1169 QPtrVector<KOWeekButton> *weekLabels; 1169 QPtrVector<KOWeekButton> *weekLabels;
1170 int weekNum = 6; 1170 int weekNum = 6;
1171 if ( mShowWeekView ) { 1171 if ( mShowWeekView ) {
1172 weekNum = 1; 1172 weekNum = 1;
1173 cells = &mCellsW; 1173 cells = &mCellsW;
1174 dayLabels = &mDayLabelsW; 1174 dayLabels = &mDayLabelsW;
1175 weekLabels = &mWeekLabelsW; 1175 weekLabels = &mWeekLabelsW;
1176 } else { 1176 } else {
1177 cells = &mCells; 1177 cells = &mCells;
1178 dayLabels = &mDayLabels; 1178 dayLabels = &mDayLabels;
1179 weekLabels = &mWeekLabels; 1179 weekLabels = &mWeekLabels;
1180 } 1180 }
1181 1181
1182 mStartDate = start; 1182 mStartDate = start;
1183 1183
1184 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1184 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1185 1185
1186 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1186 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1187 mStartDate = mStartDate.addDays( -1 ); 1187 mStartDate = mStartDate.addDays( -1 );
1188 } 1188 }
1189 1189
1190 bool primary = false; 1190 bool primary = false;
1191 uint i; 1191 uint i;
1192 for( i = 0; i < (*cells).size(); ++i ) { 1192 for( i = 0; i < (*cells).size(); ++i ) {
1193 QDate date = mStartDate.addDays( i ); 1193 QDate date = mStartDate.addDays( i );
1194 (*cells)[i]->setDate( date ); 1194 (*cells)[i]->setDate( date );
1195 1195
1196#ifndef KORG_NOPLUGINS 1196#ifndef KORG_NOPLUGINS
1197 // add holiday, if present 1197 // add holiday, if present
1198 QString hstring(KOCore::self()->holiday(date)); 1198 QString hstring(KOCore::self()->holiday(date));
1199 (*cells)[i]->setHoliday( hstring ); 1199 (*cells)[i]->setHoliday( hstring );
1200#endif 1200#endif
1201 1201
1202 } 1202 }
1203 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1203 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1204 for( i = 0; i < weekNum; ++i ) { 1204 for( i = 0; i < weekNum; ++i ) {
1205 int wno; 1205 int wno;
1206 // remember, according to ISO 8601, the first week of the year is the 1206 // remember, according to ISO 8601, the first week of the year is the
1207 // first week that contains a thursday. Thus we must subtract off 4, 1207 // first week that contains a thursday. Thus we must subtract off 4,
1208 // not just 1. 1208 // not just 1.
1209 int dayOfYear = date.dayOfYear(); 1209 int dayOfYear = date.dayOfYear();
1210 if (dayOfYear % 7 != 0) 1210 if (dayOfYear % 7 != 0)
1211 wno = dayOfYear / 7 + 1; 1211 wno = dayOfYear / 7 + 1;
1212 else 1212 else
1213 wno =dayOfYear / 7; 1213 wno =dayOfYear / 7;
1214 (*weekLabels)[i]->setWeekNum( wno ); 1214 (*weekLabels)[i]->setWeekNum( wno );
1215 date = date.addDays( 7 ); 1215 date = date.addDays( 7 );
1216 } 1216 }
1217 updateView(); 1217 updateView();
1218} 1218}
1219 1219
1220void KOMonthView::showEvents(QPtrList<Event>) 1220void KOMonthView::showEvents(QPtrList<Event>)
1221{ 1221{
1222 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1222 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1223} 1223}
1224 1224
1225void KOMonthView::changeEventDisplay(Event *, int) 1225void KOMonthView::changeEventDisplay(Event *, int)
1226{ 1226{
1227 // this should be re-written to be much more efficient, but this 1227 // this should be re-written to be much more efficient, but this
1228 // quick-and-dirty-hack gets the job done for right now. 1228 // quick-and-dirty-hack gets the job done for right now.
1229 updateView(); 1229 updateView();
1230} 1230}
1231 1231
1232void KOMonthView::updateView() 1232void KOMonthView::updateView()
1233{ 1233{
1234 1234
1235 if ( !updatePossible ) 1235 if ( !updatePossible )
1236 return; 1236 return;
1237 //QTime ti; 1237 //QTime ti;
1238 //ti.start(); 1238 //ti.start();
1239 clearSelection(); 1239 clearSelection();
1240 QPtrVector<MonthViewCell> *cells; 1240 QPtrVector<MonthViewCell> *cells;
1241 if ( mShowWeekView ) { 1241 if ( mShowWeekView ) {
1242 cells = &mCellsW; 1242 cells = &mCellsW;
1243 } else { 1243 } else {
1244 cells = &mCells; 1244 cells = &mCells;
1245 } 1245 }
1246#if 1 1246#if 1
1247 int i; 1247 int i;
1248 int timeSpan = (*cells).size()-1; 1248 int timeSpan = (*cells).size()-1;
1249 if ( KOPrefs::instance()->mMonthViewWeek ) 1249 if ( KOPrefs::instance()->mMonthViewWeek )
1250 timeSpan = 6; 1250 timeSpan = 6;
1251 for( i = 0; i < timeSpan + 1; ++i ) { 1251 for( i = 0; i < timeSpan + 1; ++i ) {
1252 (*cells)[i]->startUpdateCell(); 1252 (*cells)[i]->startUpdateCell();
1253 } 1253 }
1254 1254
1255 QPtrList<Event> events = calendar()->events(); 1255 QPtrList<Event> events = calendar()->events();
1256 Event *event; 1256 Event *event;
1257 QDateTime dt; 1257 QDateTime dt;
1258 bool ok; 1258 bool ok;
1259 QDate endDate = mStartDate.addDays( timeSpan ); 1259 QDate endDate = mStartDate.addDays( timeSpan );
1260 for( event = events.first(); event; event = events.next() ) { // for event 1260 for( event = events.first(); event; event = events.next() ) { // for event
1261 if ( event->doesRecur() ) { 1261 if ( event->doesRecur() ) {
1262 bool last; 1262 bool last;
1263 qDebug("********************************************** ");
1264 qDebug("Event summary: %s ", event->summary().latin1());
1263 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1265 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1264 QDateTime incidenceEnd; 1266 QDateTime incidenceEnd;
1265 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1267 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1268 qDebug("eventlen %d ", eventlen);
1266 bool invalid = false; 1269 bool invalid = false;
1267 while( true ) { 1270 while( true ) {
1268 if ( incidenceStart.isValid() ) { 1271 if ( incidenceStart.isValid() ) {
1269 incidenceEnd = incidenceStart.addDays( eventlen ); 1272 incidenceEnd = incidenceStart.addDays( eventlen );
1270 int st = incidenceStart.date().daysTo( endDate ); 1273 int st = incidenceStart.date().daysTo( endDate );
1271 if ( st >= 0 ) { // start before timeend 1274 if ( st >= 0 ) { // start before timeend
1272 int end = mStartDate.daysTo( incidenceEnd.date() ); 1275 int end = mStartDate.daysTo( incidenceEnd.date() );
1273 if ( end >= 0 ) { // end after timestart --- got one! 1276 if ( end >= 0 ) { // end after timestart --- got one!
1274 //normalize 1277 //normalize
1275 st = timeSpan - st; 1278 st = timeSpan - st;
1276 if ( st < 0 ) st = 0; 1279 if ( st < 0 ) st = 0;
1277 if ( end > timeSpan ) end = timeSpan; 1280 if ( end > timeSpan ) end = timeSpan;
1278 int iii; 1281 int iii;
1279 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1282 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1280 for ( iii = st;iii<= end;++iii) 1283 for ( iii = st;iii<= end;++iii)
1281 (*cells)[iii]->insertEvent( event ); 1284 (*cells)[iii]->insertEvent( event );
1282 } 1285 }
1283 } 1286 }
1284 } else { 1287 } else {
1285 if ( invalid ) 1288 if ( invalid )
1286 break; 1289 break;
1287 invalid = true; 1290 invalid = true;
1288 //qDebug("invalid %s", event->summary().latin1()); 1291 qDebug("invalid %s", event->summary().latin1());
1289 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1292 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1290 } 1293 }
1291 if ( last ) 1294 if ( last )
1292 break; 1295 break;
1293 bool ok; 1296 bool ok;
1297 qDebug("TRY next occurence %s ", incidenceStart.toString().latin1());
1294 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1298 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1295 if ( ! ok ) 1299 if ( ! ok ) {
1300 qDebug("NOT OK ");
1296 break; 1301 break;
1297 if ( incidenceStart.date() > endDate ) 1302 }
1303 if ( incidenceStart.date() > endDate ) {
1304 qDebug("incidenceStart.date() > endDate ");
1298 break; 1305 break;
1306 }
1307 qDebug("next occurence %s ", incidenceStart.toString().latin1());
1299 } 1308 }
1300 } else { // no recur 1309 } else { // no recur
1301 int st = event->dtStart().date().daysTo( endDate ); 1310 int st = event->dtStart().date().daysTo( endDate );
1302 if ( st >= 0 ) { // start before timeend 1311 if ( st >= 0 ) { // start before timeend
1303 int end = mStartDate.daysTo( event->dtEnd().date() ); 1312 int end = mStartDate.daysTo( event->dtEnd().date() );
1304 if ( end >= 0 ) { // end after timestart --- got one! 1313 if ( end >= 0 ) { // end after timestart --- got one!
1305 //normalize 1314 //normalize
1306 st = timeSpan - st; 1315 st = timeSpan - st;
1307 if ( st < 0 ) st = 0; 1316 if ( st < 0 ) st = 0;
1308 if ( end > timeSpan ) end = timeSpan; 1317 if ( end > timeSpan ) end = timeSpan;
1309 int iii; 1318 int iii;
1310 for ( iii = st;iii<= end;++iii) 1319 for ( iii = st;iii<= end;++iii)
1311 (*cells)[iii]->insertEvent( event ); 1320 (*cells)[iii]->insertEvent( event );
1312 } 1321 }
1313 } 1322 }
1314 } 1323 }
1315 } 1324 }
1316 // insert due todos 1325 // insert due todos
1317 QPtrList<Todo> todos = calendar()->todos( ); 1326 QPtrList<Todo> todos = calendar()->todos( );
1318 Todo *todo; 1327 Todo *todo;
1319 for(todo = todos.first(); todo; todo = todos.next()) { 1328 for(todo = todos.first(); todo; todo = todos.next()) {
1320 //insertTodo( todo ); 1329 //insertTodo( todo );
1321 if ( todo->hasDueDate() ) { 1330 if ( todo->hasDueDate() ) {
1322 int day = mStartDate.daysTo( todo->dtDue().date() ); 1331 int day = mStartDate.daysTo( todo->dtDue().date() );
1323 if ( day >= 0 && day < timeSpan + 1) { 1332 if ( day >= 0 && day < timeSpan + 1) {
1324 (*cells)[day]->insertTodo( todo ); 1333 (*cells)[day]->insertTodo( todo );
1325 } 1334 }
1326 } 1335 }
1327 } 1336 }
1328 1337
1329 for( i = 0; i < timeSpan+1; ++i ) { 1338 for( i = 0; i < timeSpan+1; ++i ) {
1330 (*cells)[i]->finishUpdateCell(); 1339 (*cells)[i]->finishUpdateCell();
1331 } 1340 }
1332 processSelectionChange(); 1341 processSelectionChange();
1333 (*cells)[0]->setFocus(); 1342 (*cells)[0]->setFocus();
1334 1343
1335 1344
1336#else 1345#else
1337 // old code 1346 // old code
1338 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1347 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1339 int i; 1348 int i;
1340 for( i = 0; i < (*cells).count(); ++i ) { 1349 for( i = 0; i < (*cells).count(); ++i ) {
1341 (*cells)[i]->updateCell(); 1350 (*cells)[i]->updateCell();
1342 } 1351 }
1343 1352
1344 //qDebug("KOMonthView::updateView() "); 1353 //qDebug("KOMonthView::updateView() ");
1345 processSelectionChange(); 1354 processSelectionChange();
1346 // qDebug("---------------------------------------------------------------------+ "); 1355 // qDebug("---------------------------------------------------------------------+ ");
1347 (*cells)[0]->setFocus(); 1356 (*cells)[0]->setFocus();
1348#endif 1357#endif
1349 1358
1350 //qDebug("update time %d ", ti.elapsed()); 1359 //qDebug("update time %d ", ti.elapsed());
1351} 1360}
1352 1361
1353void KOMonthView::resizeEvent(QResizeEvent * e) 1362void KOMonthView::resizeEvent(QResizeEvent * e)
1354{ 1363{
1355 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1364 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1356 computeLayout(); 1365 computeLayout();
1357 clPending = true; 1366 clPending = true;
1358 if ( mShowWeekView ) 1367 if ( mShowWeekView )
1359 mCellsW[0]->setFocus(); 1368 mCellsW[0]->setFocus();
1360 else 1369 else
1361 mCells[0]->setFocus(); 1370 mCells[0]->setFocus();
1362} 1371}
1363void KOMonthView::computeLayoutWeek() 1372void KOMonthView::computeLayoutWeek()
1364{ 1373{
1365 static int lastWid = 0; 1374 static int lastWid = 0;
1366 static int lastHei = 0; 1375 static int lastHei = 0;
1367 int daysToShow; 1376 int daysToShow;
1368 bool combinedSatSun = false; 1377 bool combinedSatSun = false;
1369 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1378 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1370 daysToShow = 6; 1379 daysToShow = 6;
1371 combinedSatSun = true; 1380 combinedSatSun = true;
1372 } 1381 }
1373 int tWid = topLevelWidget()->size().width(); 1382 int tWid = topLevelWidget()->size().width();
1374 int tHei = topLevelWidget()->size().height(); 1383 int tHei = topLevelWidget()->size().height();
1375 1384
1376 int wid = width();//e 1385 int wid = width();//e
1377 int hei = height()-1-mNavigatorBar->height(); 1386 int hei = height()-1-mNavigatorBar->height();
1378 1387
1379 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1388 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1380 return; 1389 return;
1381 1390
1382 if ( lastWid == width() && lastHei == height() ) 1391 if ( lastWid == width() && lastHei == height() )
1383 return; 1392 return;
1384 lastWid = width(); 1393 lastWid = width();
1385 lastHei = height(); 1394 lastHei = height();
1386 1395
1387 1396
1388 if ( wid < hei ) 1397 if ( wid < hei )
1389 daysToShow = 2; 1398 daysToShow = 2;
1390 else 1399 else
1391 daysToShow = 3; 1400 daysToShow = 3;
1392 mShowSatSunComp = true; 1401 mShowSatSunComp = true;
1393 combinedSatSun = true; 1402 combinedSatSun = true;
1394 1403
1395 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1404 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1396 QFontMetrics fm ( mWeekLabels[0]->font() ); 1405 QFontMetrics fm ( mWeekLabels[0]->font() );
1397 int weeklabelwid = fm.width( "888" ); 1406 int weeklabelwid = fm.width( "888" );
1398 wid -= weeklabelwid; 1407 wid -= weeklabelwid;
1399 1408
1400 int colWid = wid / daysToShow; 1409 int colWid = wid / daysToShow;
1401 int lastCol = wid - ( colWid*6 ); 1410 int lastCol = wid - ( colWid*6 );
1402 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1411 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1403 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1412 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1404 int colModulo = wid % daysToShow; 1413 int colModulo = wid % daysToShow;
1405 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1414 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1406 //qDebug("rowmod %d ", rowModulo); 1415 //qDebug("rowmod %d ", rowModulo);
1407 int i; 1416 int i;
1408 int x,y,w,h; 1417 int x,y,w,h;
1409 x= 0; 1418 x= 0;
1410 y= 0; 1419 y= 0;
1411 w = colWid; 1420 w = colWid;
1412 h = dayLabelHei ; 1421 h = dayLabelHei ;
1413 for ( i = 0; i < 7; i++) { 1422 for ( i = 0; i < 7; i++) {
1414 if ( i && !( i % daysToShow) && i < 6) { 1423 if ( i && !( i % daysToShow) && i < 6) {
1415 y += hei/(5-daysToShow); 1424 y += hei/(5-daysToShow);
1416 x = 0; 1425 x = 0;
1417 w = colWid; 1426 w = colWid;
1418 } 1427 }
1419 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1428 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1420 ++w; 1429 ++w;
1421 } 1430 }
1422 if ( i >= 5 ) { 1431 if ( i >= 5 ) {
1423 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1432 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1424 x -= (w/2 ); 1433 x -= (w/2 );
1425 } 1434 }
1426 else 1435 else
1427 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); 1436 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
1428 x += w; 1437 x += w;
1429 } 1438 }
1430 x= 0; 1439 x= 0;
1431 y= dayLabelHei; 1440 y= dayLabelHei;
1432 w = colWid; 1441 w = colWid;
1433 h = cellHei; 1442 h = cellHei;
1434 for ( i = 0; i < mCellsW.count(); ++i) { 1443 for ( i = 0; i < mCellsW.count(); ++i) {
1435 if ( i > 6 ) { 1444 if ( i > 6 ) {
1436 mCellsW[i]->hide(); 1445 mCellsW[i]->hide();
1437 continue; 1446 continue;
1438 } 1447 }
1439 1448
1440 w = colWid; 1449 w = colWid;
1441 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1450 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1442 ++w; 1451 ++w;
1443 } 1452 }
1444 if ( i == (daysToShow-1-rowModulo)*7) 1453 if ( i == (daysToShow-1-rowModulo)*7)
1445 ++h; 1454 ++h;
1446 1455
1447 if ( i >= 5 ) { 1456 if ( i >= 5 ) {
1448 if ( i ==5 ) { 1457 if ( i ==5 ) {
1449 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1458 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1450 x -= w ;y += h/2; 1459 x -= w ;y += h/2;
1451 } else { 1460 } else {
1452 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1461 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1453 ++w; 1462 ++w;
1454 } 1463 }
1455 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1464 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1456 y -= h/2; 1465 y -= h/2;
1457 } 1466 }
1458 } else 1467 } else
1459 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1468 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1460 1469
1461 1470
1462 x += w; 1471 x += w;
1463 if ( x + w/2 > wid ) { 1472 if ( x + w/2 > wid ) {
1464 x = 0; 1473 x = 0;
1465 y += h+dayLabelHei ; 1474 y += h+dayLabelHei ;
1466 } 1475 }
1467 } 1476 }
1468 y= dayLabelHei; 1477 y= dayLabelHei;
1469 h = cellHei ; 1478 h = cellHei ;
1470 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1479 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1471 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1480 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1472 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1481 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1473 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1482 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1474 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1483 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1475 updateDayLabels(); 1484 updateDayLabels();
1476 //bool forceUpdate = !updatePossible; 1485 //bool forceUpdate = !updatePossible;
1477 updatePossible = true; 1486 updatePossible = true;
1478 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1487 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1479 //if ( forceUpdate ) 1488 //if ( forceUpdate )
1480 // updateView(); 1489 // updateView();
1481} 1490}
1482void KOMonthView::computeLayout() 1491void KOMonthView::computeLayout()
1483{ 1492{
1484 1493
1485 1494
1486 static int lastWid = 0; 1495 static int lastWid = 0;
1487 static int lastHei = 0; 1496 static int lastHei = 0;
1488 1497
1489 if ( mShowWeekView ){ 1498 if ( mShowWeekView ){
1490 computeLayoutWeek(); 1499 computeLayoutWeek();
1491 return; 1500 return;
1492 } 1501 }
1493 int daysToShow = 7; 1502 int daysToShow = 7;
1494 bool combinedSatSun = false; 1503 bool combinedSatSun = false;
1495 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1504 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1496 daysToShow = 6; 1505 daysToShow = 6;
1497 combinedSatSun = true; 1506 combinedSatSun = true;
1498 } 1507 }
1499 int tWid = topLevelWidget()->size().width(); 1508 int tWid = topLevelWidget()->size().width();
1500 int tHei = topLevelWidget()->size().height(); 1509 int tHei = topLevelWidget()->size().height();
1501 1510
1502 int wid = width();//e 1511 int wid = width();//e
1503 int hei = height()-1-mNavigatorBar->height(); 1512 int hei = height()-1-mNavigatorBar->height();
1504 1513
1505 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1514 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1506 return; 1515 return;
1507 } 1516 }
1508 if ( lastWid == width() && lastHei == height() ){ 1517 if ( lastWid == width() && lastHei == height() ){
1509 return; 1518 return;
1510 } 1519 }
1511 1520
1512 lastWid = width(); 1521 lastWid = width();
1513 lastHei = height(); 1522 lastHei = height();
1514 //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); 1523 //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ ");
1515 QFontMetrics fm ( mWeekLabels[0]->font() ); 1524 QFontMetrics fm ( mWeekLabels[0]->font() );
1516 int weeklabelwid = fm.width( "888" ); 1525 int weeklabelwid = fm.width( "888" );
1517 wid -= weeklabelwid; 1526 wid -= weeklabelwid;
1518 1527
1519 int colWid = wid / daysToShow; 1528 int colWid = wid / daysToShow;
1520 int lastCol = wid - ( colWid*6 ); 1529 int lastCol = wid - ( colWid*6 );
1521 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1530 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1522 int cellHei = (hei - dayLabelHei) /6; 1531 int cellHei = (hei - dayLabelHei) /6;
1523 int colModulo = wid % daysToShow; 1532 int colModulo = wid % daysToShow;
1524 int rowModulo = (hei- dayLabelHei) % 6; 1533 int rowModulo = (hei- dayLabelHei) % 6;
1525 //qDebug("rowmod %d ", rowModulo); 1534 //qDebug("rowmod %d ", rowModulo);
1526 int i; 1535 int i;
1527 int x,y,w,h; 1536 int x,y,w,h;
1528 x= 0; 1537 x= 0;
1529 y= 0; 1538 y= 0;
1530 w = colWid; 1539 w = colWid;
1531 h = dayLabelHei ; 1540 h = dayLabelHei ;
1532 for ( i = 0; i < 7; i++) { 1541 for ( i = 0; i < 7; i++) {
1533 if ( i == daysToShow-colModulo ) 1542 if ( i == daysToShow-colModulo )
1534 ++w; 1543 ++w;
1535 if ( combinedSatSun ) { 1544 if ( combinedSatSun ) {
1536 if ( i >= daysToShow-1 ) { 1545 if ( i >= daysToShow-1 ) {
1537 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1546 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1538 x -= w/2 ; 1547 x -= w/2 ;
1539 } 1548 }
1540 else 1549 else
1541 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1550 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1542 } else 1551 } else
1543 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1552 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1544 x += w; 1553 x += w;
1545 } 1554 }
1546 x= 0; 1555 x= 0;
1547 y= dayLabelHei; 1556 y= dayLabelHei;
1548 w = colWid; 1557 w = colWid;
1549 h = cellHei ; 1558 h = cellHei ;
1550 for ( i = 0; i < mCells.count(); ++i) { 1559 for ( i = 0; i < mCells.count(); ++i) {
1551 //qDebug("iii %d ", i); 1560 //qDebug("iii %d ", i);
1552 w = colWid; 1561 w = colWid;
1553 if ( ((i) % 7) >= 7-colModulo ) { 1562 if ( ((i) % 7) >= 7-colModulo ) {
1554 ++w; 1563 ++w;
1555 } 1564 }
1556 if ( i == (6-rowModulo)*7) 1565 if ( i == (6-rowModulo)*7)
1557 ++h; 1566 ++h;
1558 if ( combinedSatSun ) { 1567 if ( combinedSatSun ) {
1559 if ( (i)%7 >= daysToShow-1 ) { 1568 if ( (i)%7 >= daysToShow-1 ) {
1560 if ( (i)%7 == daysToShow-1 ) { 1569 if ( (i)%7 == daysToShow-1 ) {
1561 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1570 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1562 x -= w ;y += h/2; 1571 x -= w ;y += h/2;
1563 } else { 1572 } else {
1564 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1573 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1565 y -= h/2; 1574 y -= h/2;
1566 } 1575 }
1567 } else 1576 } else
1568 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1577 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1569 1578
1570 } 1579 }
1571 else 1580 else
1572 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1581 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1573 x += w; 1582 x += w;
1574 if ( x + w/2 > wid ) { 1583 if ( x + w/2 > wid ) {
1575 x = 0; 1584 x = 0;
1576 y += h; 1585 y += h;
1577 } 1586 }
1578 } 1587 }
1579 y= dayLabelHei; 1588 y= dayLabelHei;
1580 h = cellHei ; 1589 h = cellHei ;
1581 for ( i = 0; i < 6; i++) { 1590 for ( i = 0; i < 6; i++) {
1582 if ( i == (6-rowModulo)) 1591 if ( i == (6-rowModulo))
1583 ++h; 1592 ++h;
1584 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1593 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1585 y += h; 1594 y += h;
1586 } 1595 }
1587 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1596 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1588 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1597 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1589 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1598 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1590 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1599 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1591 updateDayLabels(); 1600 updateDayLabels();
1592 //bool forceUpdate = !updatePossible; 1601 //bool forceUpdate = !updatePossible;
1593 updatePossible = true; 1602 updatePossible = true;
1594 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1603 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1595} 1604}
1596 1605
1597void KOMonthView::showContextMenu( Incidence *incidence ) 1606void KOMonthView::showContextMenu( Incidence *incidence )
1598{ 1607{
1599 mContextMenu->showIncidencePopup(incidence); 1608 mContextMenu->showIncidencePopup(incidence);
1600 /* 1609 /*
1601 if( incidence && incidence->type() == "Event" ) { 1610 if( incidence && incidence->type() == "Event" ) {
1602 Event *event = static_cast<Event *>(incidence); 1611 Event *event = static_cast<Event *>(incidence);
1603 mContextMenu->showEventPopup(event); 1612 mContextMenu->showEventPopup(event);
1604 } else { 1613 } else {
1605 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1614 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1606 } 1615 }
1607 */ 1616 */
1608} 1617}
1609MonthViewCell * KOMonthView::selectedCell( ) 1618MonthViewCell * KOMonthView::selectedCell( )
1610{ 1619{
1611 return mSelectedCell; 1620 return mSelectedCell;
1612} 1621}
1613void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1622void KOMonthView::setSelectedCell( MonthViewCell *cell )
1614{ 1623{
1615 //qDebug("KOMonthView::setSelectedCell "); 1624 //qDebug("KOMonthView::setSelectedCell ");
1616 if ( mSelectedCell && mSelectedCell != cell ) { 1625 if ( mSelectedCell && mSelectedCell != cell ) {
1617 MonthViewCell * mvc = mSelectedCell; 1626 MonthViewCell * mvc = mSelectedCell;
1618 mSelectedCell = cell; 1627 mSelectedCell = cell;
1619 mvc->deselect(); 1628 mvc->deselect();
1620 } else 1629 } else
1621 mSelectedCell = cell; 1630 mSelectedCell = cell;
1622 // if ( mSelectedCell ) 1631 // if ( mSelectedCell )
1623 // mSelectedCell->select(); 1632 // mSelectedCell->select();
1624 if ( !mSelectedCell ) 1633 if ( !mSelectedCell )
1625 emit incidenceSelected( 0 ); 1634 emit incidenceSelected( 0 );
1626 else 1635 else
1627 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1636 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1628} 1637}
1629 1638
1630void KOMonthView::processSelectionChange() 1639void KOMonthView::processSelectionChange()
1631{ 1640{
1632 QPtrList<Incidence> incidences = selectedIncidences(); 1641 QPtrList<Incidence> incidences = selectedIncidences();
1633 if (incidences.count() > 0) { 1642 if (incidences.count() > 0) {
1634 emit incidenceSelected( incidences.first() ); 1643 emit incidenceSelected( incidences.first() );
1635 } else { 1644 } else {
1636 emit incidenceSelected( 0 ); 1645 emit incidenceSelected( 0 );
1637 clearSelection(); 1646 clearSelection();
1638 } 1647 }
1639} 1648}
1640 1649
1641void KOMonthView::clearSelection() 1650void KOMonthView::clearSelection()
1642{ 1651{
1643 if ( mSelectedCell ) { 1652 if ( mSelectedCell ) {
1644 mSelectedCell->deselect(); 1653 mSelectedCell->deselect();
1645 mSelectedCell = 0; 1654 mSelectedCell = 0;
1646 } 1655 }
1647} 1656}
1648void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1657void KOMonthView::keyPressEvent ( QKeyEvent * e )
1649{ 1658{
1650 //qDebug("KOMonthView::keyPressEvent "); 1659 //qDebug("KOMonthView::keyPressEvent ");
1651 switch(e->key()) { 1660 switch(e->key()) {
1652 case Key_Up: 1661 case Key_Up:
1653 { 1662 {
1654 if ( mShowWeekView ) { 1663 if ( mShowWeekView ) {
1655 mCellsW[0]->setFocus(); 1664 mCellsW[0]->setFocus();
1656 emit selectWeekNum ( currentWeek() - 1 ); 1665 emit selectWeekNum ( currentWeek() - 1 );
1657 } 1666 }
1658 else { 1667 else {
1659 mCells[0]->setFocus(); 1668 mCells[0]->setFocus();
1660 emit prevMonth(); 1669 emit prevMonth();
1661 } 1670 }
1662 } 1671 }
1663 e->accept(); 1672 e->accept();
1664 break; 1673 break;
1665 case Key_Down: 1674 case Key_Down:
1666 { 1675 {
1667 if ( mShowWeekView ) { 1676 if ( mShowWeekView ) {
1668 mCellsW[0]->setFocus(); 1677 mCellsW[0]->setFocus();
1669 emit selectWeekNum ( currentWeek() +1); 1678 emit selectWeekNum ( currentWeek() +1);
1670 } 1679 }
1671 else { 1680 else {
1672 mCells[0]->setFocus(); 1681 mCells[0]->setFocus();
1673 emit nextMonth(); 1682 emit nextMonth();
1674 } 1683 }
1675 1684
1676 } 1685 }
1677 e->accept(); 1686 e->accept();
1678 break; 1687 break;
1679 case Key_Return: 1688 case Key_Return:
1680 case Key_Enter: 1689 case Key_Enter:
1681 { 1690 {
1682 selectInternalWeekNum ( currentWeek() ); 1691 selectInternalWeekNum ( currentWeek() );
1683 } 1692 }
1684 e->accept(); 1693 e->accept();
1685 break; 1694 break;
1686 case Key_D: 1695 case Key_D:
1687 if ( mSelectedCell ) { 1696 if ( mSelectedCell ) {
1688 mSelectedCell->showDay(); 1697 mSelectedCell->showDay();
1689 e->accept(); 1698 e->accept();
1690 } else { 1699 } else {
1691 e->ignore(); 1700 e->ignore();
1692 } 1701 }
1693 break; 1702 break;
1694 default: 1703 default:
1695 e->ignore(); 1704 e->ignore();
1696 break; 1705 break;
1697 } 1706 }
1698} 1707}