-rw-r--r-- | korganizer/komonthview.cpp | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 234375b..7ba0b2f 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -748,113 +748,116 @@ void MonthViewCell::cellClicked( QListBoxItem *item ) | |||
748 | static QListBoxItem * lastClicked = 0; | 748 | static QListBoxItem * lastClicked = 0; |
749 | if ( item == 0 ) { | 749 | if ( item == 0 ) { |
750 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 750 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
751 | emit newEventSignal( dt ); | 751 | emit newEventSignal( dt ); |
752 | return; | 752 | return; |
753 | } | 753 | } |
754 | /* | 754 | /* |
755 | if ( lastClicked ) | 755 | if ( lastClicked ) |
756 | if ( ! item ) { | 756 | if ( ! item ) { |
757 | if ( lastClicked->listBox() != item->listBox() ) | 757 | if ( lastClicked->listBox() != item->listBox() ) |
758 | lastClicked->listBox()->clearSelection(); | 758 | lastClicked->listBox()->clearSelection(); |
759 | } | 759 | } |
760 | */ | 760 | */ |
761 | 761 | ||
762 | mMonthView->setSelectedCell( this ); | 762 | mMonthView->setSelectedCell( this ); |
763 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 763 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
764 | select(); | 764 | select(); |
765 | } | 765 | } |
766 | 766 | ||
767 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 767 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
768 | { | 768 | { |
769 | if ( !item ) return; | 769 | if ( !item ) return; |
770 | 770 | ||
771 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 771 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
772 | Incidence *incidence = eventItem->incidence(); | 772 | Incidence *incidence = eventItem->incidence(); |
773 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 773 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
774 | } | 774 | } |
775 | 775 | ||
776 | void MonthViewCell::selection( QListBoxItem *item ) | 776 | void MonthViewCell::selection( QListBoxItem *item ) |
777 | { | 777 | { |
778 | if ( !item ) return; | 778 | if ( !item ) return; |
779 | 779 | ||
780 | mMonthView->setSelectedCell( this ); | 780 | mMonthView->setSelectedCell( this ); |
781 | } | 781 | } |
782 | 782 | ||
783 | 783 | ||
784 | // ******************************************************************************* | 784 | // ******************************************************************************* |
785 | // ******************************************************************************* | 785 | // ******************************************************************************* |
786 | // ******************************************************************************* | 786 | // ******************************************************************************* |
787 | 787 | ||
788 | 788 | ||
789 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 789 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
790 | : KOEventView( calendar, parent, name ), | 790 | : KOEventView( calendar, parent, name ), |
791 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 791 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
792 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 792 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
793 | { | 793 | { |
794 | skipResize = false; | 794 | skipResize = false; |
795 | clPending = true; | 795 | clPending = true; |
796 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | ||
796 | mWidStack = new QWidgetStack( this ); | 797 | mWidStack = new QWidgetStack( this ); |
797 | QHBoxLayout* hb = new QHBoxLayout( this ); | 798 | QVBoxLayout* hb = new QVBoxLayout( this ); |
798 | mMonthView = new QWidget( mWidStack ); | 799 | mMonthView = new QWidget( mWidStack ); |
799 | mWeekView = new QWidget( mWidStack ); | 800 | mWeekView = new QWidget( mWidStack ); |
800 | #if QT_VERSION >= 0x030000 | 801 | #if QT_VERSION >= 0x030000 |
801 | mWidStack->addWidget(mMonthView ); | 802 | mWidStack->addWidget(mMonthView ); |
802 | mWidStack->addWidget(mWeekView ); | 803 | mWidStack->addWidget(mWeekView ); |
803 | #else | 804 | #else |
804 | mWidStack->addWidget( mMonthView, 1 ); | 805 | mWidStack->addWidget( mMonthView, 1 ); |
805 | mWidStack->addWidget( mWeekView , 1 ); | 806 | mWidStack->addWidget( mWeekView , 1 ); |
806 | #endif | 807 | #endif |
808 | hb->addWidget( mNavigatorBar ); | ||
807 | hb->addWidget( mWidStack ); | 809 | hb->addWidget( mWidStack ); |
808 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 810 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
809 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 811 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
810 | if ( mShowWeekView ) | 812 | if ( mShowWeekView ) |
811 | mWeekStartsMonday = true; | 813 | mWeekStartsMonday = true; |
812 | updatePossible = false; | 814 | updatePossible = false; |
815 | //updatePossible = true; | ||
813 | mCells.setAutoDelete( true ); | 816 | mCells.setAutoDelete( true ); |
814 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 817 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
815 | mDayLabels.resize( mDaysPerWeek ); | 818 | mDayLabels.resize( mDaysPerWeek ); |
816 | mDayLabelsW.resize( mDaysPerWeek ); | 819 | mDayLabelsW.resize( mDaysPerWeek ); |
817 | QFont bfont = font(); | 820 | QFont bfont = font(); |
818 | if ( QApplication::desktop()->width() < 650 ) { | 821 | if ( QApplication::desktop()->width() < 650 ) { |
819 | bfont.setPointSize( bfont.pointSize() - 2 ); | 822 | bfont.setPointSize( bfont.pointSize() - 2 ); |
820 | } | 823 | } |
821 | bfont.setBold( true ); | 824 | bfont.setBold( true ); |
822 | int i; | 825 | int i; |
823 | 826 | ||
824 | for( i = 0; i < mDaysPerWeek; i++ ) { | 827 | for( i = 0; i < mDaysPerWeek; i++ ) { |
825 | QLabel *label = new QLabel( mMonthView ); | 828 | QLabel *label = new QLabel( mMonthView ); |
826 | label->setFont(bfont); | 829 | label->setFont(bfont); |
827 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 830 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
828 | label->setLineWidth(1); | 831 | label->setLineWidth(1); |
829 | label->setAlignment(AlignCenter); | 832 | label->setAlignment(AlignCenter); |
830 | mDayLabels.insert( i, label ); | 833 | mDayLabels.insert( i, label ); |
831 | label = new QLabel( mWeekView ); | 834 | label = new QLabel( mWeekView ); |
832 | label->setFont(bfont); | 835 | label->setFont(bfont); |
833 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 836 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
834 | label->setLineWidth(1); | 837 | label->setLineWidth(1); |
835 | label->setAlignment(AlignCenter); | 838 | label->setAlignment(AlignCenter); |
836 | mDayLabelsW.insert( i, label ); | 839 | mDayLabelsW.insert( i, label ); |
837 | } | 840 | } |
838 | 841 | ||
839 | bfont.setBold( false ); | 842 | bfont.setBold( false ); |
840 | mWeekLabels.resize( mNumWeeks+1 ); | 843 | mWeekLabels.resize( mNumWeeks+1 ); |
841 | mWeekLabelsW.resize( 2 ); | 844 | mWeekLabelsW.resize( 2 ); |
842 | for( i = 0; i < mNumWeeks+1; i++ ) { | 845 | for( i = 0; i < mNumWeeks+1; i++ ) { |
843 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 846 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
844 | label->setFocusPolicy(NoFocus); | 847 | label->setFocusPolicy(NoFocus); |
845 | label->setFont(bfont); | 848 | label->setFont(bfont); |
846 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 849 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
847 | label->setFlat(true); | 850 | label->setFlat(true); |
848 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 851 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
849 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 852 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
850 | //label->setLineWidth(1); | 853 | //label->setLineWidth(1); |
851 | //label->setAlignment(AlignCenter); | 854 | //label->setAlignment(AlignCenter); |
852 | mWeekLabels.insert( i, label ); | 855 | mWeekLabels.insert( i, label ); |
853 | } | 856 | } |
854 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 857 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
855 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 858 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
856 | 859 | ||
857 | for( i = 0; i < 1+1; i++ ) { | 860 | for( i = 0; i < 1+1; i++ ) { |
858 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 861 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
859 | label->setFocusPolicy(NoFocus); | 862 | label->setFocusPolicy(NoFocus); |
860 | label->setFont(bfont); | 863 | label->setFont(bfont); |
@@ -872,123 +875,126 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
872 | int row, col; | 875 | int row, col; |
873 | mCells.resize( mNumCells ); | 876 | mCells.resize( mNumCells ); |
874 | for( row = 0; row < mNumWeeks; ++row ) { | 877 | for( row = 0; row < mNumWeeks; ++row ) { |
875 | for( col = 0; col < mDaysPerWeek; ++col ) { | 878 | for( col = 0; col < mDaysPerWeek; ++col ) { |
876 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 879 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
877 | mCells.insert( row * mDaysPerWeek + col, cell ); | 880 | mCells.insert( row * mDaysPerWeek + col, cell ); |
878 | 881 | ||
879 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 882 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
880 | SLOT( defaultAction( Incidence * ) ) ); | 883 | SLOT( defaultAction( Incidence * ) ) ); |
881 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 884 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
882 | SIGNAL( newEventSignal( QDateTime ) ) ); | 885 | SIGNAL( newEventSignal( QDateTime ) ) ); |
883 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 886 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
884 | SIGNAL( showDaySignal( QDate ) ) ); | 887 | SIGNAL( showDaySignal( QDate ) ) ); |
885 | } | 888 | } |
886 | } | 889 | } |
887 | mCellsW.resize( mDaysPerWeek ); | 890 | mCellsW.resize( mDaysPerWeek ); |
888 | for( col = 0; col < mDaysPerWeek; ++col ) { | 891 | for( col = 0; col < mDaysPerWeek; ++col ) { |
889 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 892 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
890 | mCellsW.insert( col, cell ); | 893 | mCellsW.insert( col, cell ); |
891 | 894 | ||
892 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 895 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
893 | SLOT( defaultAction( Incidence * ) ) ); | 896 | SLOT( defaultAction( Incidence * ) ) ); |
894 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 897 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
895 | SIGNAL( newEventSignal( QDateTime ) ) ); | 898 | SIGNAL( newEventSignal( QDateTime ) ) ); |
896 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 899 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
897 | SIGNAL( showDaySignal( QDate ) ) ); | 900 | SIGNAL( showDaySignal( QDate ) ) ); |
898 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 901 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
899 | } | 902 | } |
900 | 903 | ||
901 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 904 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
902 | mContextMenu = eventPopup(); | 905 | mContextMenu = eventPopup(); |
903 | // updateConfig(); //useless here... | 906 | // updateConfig(); //useless here... |
904 | // ... but we need mWidthLongDayLabel computed | 907 | // ... but we need mWidthLongDayLabel computed |
905 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 908 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
906 | mWidthLongDayLabel = 0; | 909 | mWidthLongDayLabel = 0; |
907 | for (int i = 0; i < 7; i++) { | 910 | for (int i = 0; i < 7; i++) { |
908 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 911 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
909 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 912 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
910 | } | 913 | } |
911 | 914 | ||
912 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 915 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
913 | 916 | ||
914 | if ( mShowWeekView ) | 917 | if ( mShowWeekView ) |
915 | mWidStack->raiseWidget( mWeekView ); | 918 | mWidStack->raiseWidget( mWeekView ); |
916 | else | 919 | else |
917 | mWidStack->raiseWidget( mMonthView ); | 920 | mWidStack->raiseWidget( mMonthView ); |
918 | 921 | ||
919 | emit incidenceSelected( 0 ); | 922 | emit incidenceSelected( 0 ); |
923 | #ifndef DESKTOP_VERSION | ||
924 | resize( QApplication::desktop()->size() ); | ||
925 | computeLayout(); | ||
926 | #endif | ||
920 | } | 927 | } |
921 | 928 | ||
922 | KOMonthView::~KOMonthView() | 929 | KOMonthView::~KOMonthView() |
923 | { | 930 | { |
924 | delete mContextMenu; | 931 | delete mContextMenu; |
925 | } | 932 | } |
926 | 933 | ||
927 | void KOMonthView::selectInternalWeekNum ( int n ) | 934 | void KOMonthView::selectInternalWeekNum ( int n ) |
928 | { | 935 | { |
929 | switchView(); | 936 | switchView(); |
930 | emit selectWeekNum ( n ); | 937 | emit selectWeekNum ( n ); |
931 | } | 938 | } |
932 | 939 | ||
933 | int KOMonthView::currentWeek() | 940 | int KOMonthView::currentWeek() |
934 | { | 941 | { |
935 | if ( mShowWeekView ) | 942 | if ( mShowWeekView ) |
936 | return mWeekLabelsW[0]->getWeekNum(); | 943 | return mWeekLabelsW[0]->getWeekNum(); |
937 | return mWeekLabels[0]->getWeekNum(); | 944 | return mWeekLabels[0]->getWeekNum(); |
938 | } | 945 | } |
939 | void KOMonthView::switchView() | 946 | void KOMonthView::switchView() |
940 | { | 947 | { |
941 | 948 | ||
942 | if ( selectedCell( ) ) | 949 | if ( selectedCell( ) ) |
943 | selectedCell()->deselect(); | 950 | selectedCell()->deselect(); |
944 | mShowWeekView = !mShowWeekView; | 951 | mShowWeekView = !mShowWeekView; |
945 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 952 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
946 | //emit showNavigator( !mShowWeekView ); | ||
947 | if ( clPending ) { | 953 | if ( clPending ) { |
948 | computeLayout(); | 954 | computeLayout(); |
949 | updateConfig(); | 955 | updateConfig(); |
950 | } | 956 | } |
951 | if ( mShowWeekView ) | 957 | if ( mShowWeekView ) |
952 | mWidStack->raiseWidget( mWeekView ); | 958 | mWidStack->raiseWidget( mWeekView ); |
953 | else | 959 | else |
954 | mWidStack->raiseWidget( mMonthView ); | 960 | mWidStack->raiseWidget( mMonthView ); |
955 | clPending = false; | 961 | clPending = false; |
956 | } | 962 | } |
957 | 963 | ||
958 | int KOMonthView::maxDatesHint() | 964 | int KOMonthView::maxDatesHint() |
959 | { | 965 | { |
960 | return mNumCells; | 966 | return mNumCells; |
961 | } | 967 | } |
962 | 968 | ||
963 | int KOMonthView::currentDateCount() | 969 | int KOMonthView::currentDateCount() |
964 | { | 970 | { |
965 | return mNumCells; | 971 | return mNumCells; |
966 | } | 972 | } |
967 | 973 | ||
968 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 974 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
969 | { | 975 | { |
970 | QPtrList<Incidence> selected; | 976 | QPtrList<Incidence> selected; |
971 | 977 | ||
972 | if ( mSelectedCell ) { | 978 | if ( mSelectedCell ) { |
973 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 979 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
974 | if ( incidence ) selected.append( incidence ); | 980 | if ( incidence ) selected.append( incidence ); |
975 | } | 981 | } |
976 | 982 | ||
977 | return selected; | 983 | return selected; |
978 | } | 984 | } |
979 | 985 | ||
980 | DateList KOMonthView::selectedDates() | 986 | DateList KOMonthView::selectedDates() |
981 | { | 987 | { |
982 | DateList selected; | 988 | DateList selected; |
983 | 989 | ||
984 | if ( mSelectedCell ) { | 990 | if ( mSelectedCell ) { |
985 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 991 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
986 | if ( qd.isValid() ) selected.append( qd ); | 992 | if ( qd.isValid() ) selected.append( qd ); |
987 | } | 993 | } |
988 | 994 | ||
989 | return selected; | 995 | return selected; |
990 | } | 996 | } |
991 | 997 | ||
992 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 998 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
993 | const QDate &td) | 999 | const QDate &td) |
994 | { | 1000 | { |
@@ -1215,341 +1221,336 @@ void KOMonthView::updateView() | |||
1215 | if ( st < 0 ) st = 0; | 1221 | if ( st < 0 ) st = 0; |
1216 | if ( end > timeSpan ) end = timeSpan; | 1222 | if ( end > timeSpan ) end = timeSpan; |
1217 | int iii; | 1223 | int iii; |
1218 | for ( iii = st;iii<= end;++iii) | 1224 | for ( iii = st;iii<= end;++iii) |
1219 | (*cells)[iii]->insertEvent( event ); | 1225 | (*cells)[iii]->insertEvent( event ); |
1220 | } | 1226 | } |
1221 | } | 1227 | } |
1222 | } | 1228 | } |
1223 | } | 1229 | } |
1224 | // insert due todos | 1230 | // insert due todos |
1225 | QPtrList<Todo> todos = calendar()->todos( ); | 1231 | QPtrList<Todo> todos = calendar()->todos( ); |
1226 | Todo *todo; | 1232 | Todo *todo; |
1227 | for(todo = todos.first(); todo; todo = todos.next()) { | 1233 | for(todo = todos.first(); todo; todo = todos.next()) { |
1228 | //insertTodo( todo ); | 1234 | //insertTodo( todo ); |
1229 | if ( todo->hasDueDate() ) { | 1235 | if ( todo->hasDueDate() ) { |
1230 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1236 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1231 | if ( day >= 0 && day < timeSpan + 1) { | 1237 | if ( day >= 0 && day < timeSpan + 1) { |
1232 | (*cells)[day]->insertTodo( todo ); | 1238 | (*cells)[day]->insertTodo( todo ); |
1233 | } | 1239 | } |
1234 | } | 1240 | } |
1235 | } | 1241 | } |
1236 | 1242 | ||
1237 | for( i = 0; i < timeSpan+1; ++i ) { | 1243 | for( i = 0; i < timeSpan+1; ++i ) { |
1238 | (*cells)[i]->finishUpdateCell(); | 1244 | (*cells)[i]->finishUpdateCell(); |
1239 | } | 1245 | } |
1240 | processSelectionChange(); | 1246 | processSelectionChange(); |
1241 | (*cells)[0]->setFocus(); | 1247 | (*cells)[0]->setFocus(); |
1242 | 1248 | ||
1243 | 1249 | ||
1244 | #else | 1250 | #else |
1245 | // old code | 1251 | // old code |
1246 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1252 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1247 | int i; | 1253 | int i; |
1248 | for( i = 0; i < (*cells).count(); ++i ) { | 1254 | for( i = 0; i < (*cells).count(); ++i ) { |
1249 | (*cells)[i]->updateCell(); | 1255 | (*cells)[i]->updateCell(); |
1250 | } | 1256 | } |
1251 | 1257 | ||
1252 | //qDebug("KOMonthView::updateView() "); | 1258 | //qDebug("KOMonthView::updateView() "); |
1253 | processSelectionChange(); | 1259 | processSelectionChange(); |
1254 | // qDebug("---------------------------------------------------------------------+ "); | 1260 | // qDebug("---------------------------------------------------------------------+ "); |
1255 | (*cells)[0]->setFocus(); | 1261 | (*cells)[0]->setFocus(); |
1256 | #endif | 1262 | #endif |
1257 | 1263 | ||
1258 | //qDebug("update time %d ", ti.elapsed()); | 1264 | //qDebug("update time %d ", ti.elapsed()); |
1259 | } | 1265 | } |
1260 | 1266 | ||
1261 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1267 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1262 | { | 1268 | { |
1263 | qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1269 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1264 | if ( skipResize ) { | ||
1265 | skipResize = false; | ||
1266 | qDebug("skipResize "); | ||
1267 | return; | ||
1268 | } | ||
1269 | computeLayout(); | 1270 | computeLayout(); |
1270 | clPending = true; | 1271 | clPending = true; |
1271 | if ( mShowWeekView ) | 1272 | if ( mShowWeekView ) |
1272 | mCellsW[0]->setFocus(); | 1273 | mCellsW[0]->setFocus(); |
1273 | else | 1274 | else |
1274 | mCells[0]->setFocus(); | 1275 | mCells[0]->setFocus(); |
1275 | } | 1276 | } |
1276 | void KOMonthView::computeLayoutWeek() | 1277 | void KOMonthView::computeLayoutWeek() |
1277 | { | 1278 | { |
1278 | static int lastWid = 0; | 1279 | static int lastWid = 0; |
1279 | static int lastHei = 0; | 1280 | static int lastHei = 0; |
1280 | int daysToShow; | 1281 | int daysToShow; |
1281 | bool combinedSatSun = false; | 1282 | bool combinedSatSun = false; |
1282 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1283 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1283 | daysToShow = 6; | 1284 | daysToShow = 6; |
1284 | combinedSatSun = true; | 1285 | combinedSatSun = true; |
1285 | } | 1286 | } |
1286 | int tWid = topLevelWidget()->size().width(); | 1287 | int tWid = topLevelWidget()->size().width(); |
1287 | int tHei = topLevelWidget()->size().height(); | 1288 | int tHei = topLevelWidget()->size().height(); |
1288 | 1289 | ||
1289 | int wid = size().width();//e | 1290 | int wid = width();//e |
1290 | int hei = size().height()-1; | 1291 | int hei = height()-1-mNavigatorBar->height(); |
1291 | 1292 | ||
1292 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1293 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1293 | return; | 1294 | return; |
1294 | 1295 | ||
1295 | 1296 | if ( lastWid == width() && lastHei == height() ) | |
1296 | if ( lastWid == width() && lastHei ==height() ) | ||
1297 | return; | 1297 | return; |
1298 | lastWid =width(); | 1298 | lastWid = width(); |
1299 | lastHei = height(); | 1299 | lastHei = height(); |
1300 | 1300 | ||
1301 | 1301 | ||
1302 | if ( wid < hei ) | 1302 | if ( wid < hei ) |
1303 | daysToShow = 2; | 1303 | daysToShow = 2; |
1304 | else | 1304 | else |
1305 | daysToShow = 3; | 1305 | daysToShow = 3; |
1306 | mShowSatSunComp = true; | 1306 | mShowSatSunComp = true; |
1307 | combinedSatSun = true; | 1307 | combinedSatSun = true; |
1308 | 1308 | ||
1309 | qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1309 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1310 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1310 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1311 | int weeklabelwid = fm.width( "888" ); | 1311 | int weeklabelwid = fm.width( "888" ); |
1312 | wid -= weeklabelwid; | 1312 | wid -= weeklabelwid; |
1313 | 1313 | ||
1314 | int colWid = wid / daysToShow; | 1314 | int colWid = wid / daysToShow; |
1315 | int lastCol = wid - ( colWid*6 ); | 1315 | int lastCol = wid - ( colWid*6 ); |
1316 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1316 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1317 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1317 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1318 | int colModulo = wid % daysToShow; | 1318 | int colModulo = wid % daysToShow; |
1319 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1319 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1320 | //qDebug("rowmod %d ", rowModulo); | 1320 | //qDebug("rowmod %d ", rowModulo); |
1321 | int i; | 1321 | int i; |
1322 | int x,y,w,h; | 1322 | int x,y,w,h; |
1323 | x= 0; | 1323 | x= 0; |
1324 | y= 0; | 1324 | y= 0; |
1325 | w = colWid; | 1325 | w = colWid; |
1326 | h = dayLabelHei ; | 1326 | h = dayLabelHei ; |
1327 | for ( i = 0; i < 7; i++) { | 1327 | for ( i = 0; i < 7; i++) { |
1328 | if ( i && !( i % daysToShow) && i < 6) { | 1328 | if ( i && !( i % daysToShow) && i < 6) { |
1329 | y += hei/(5-daysToShow); | 1329 | y += hei/(5-daysToShow); |
1330 | x = 0; | 1330 | x = 0; |
1331 | w = colWid; | 1331 | w = colWid; |
1332 | } | 1332 | } |
1333 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1333 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1334 | ++w; | 1334 | ++w; |
1335 | } | 1335 | } |
1336 | if ( i >= 5 ) { | 1336 | if ( i >= 5 ) { |
1337 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1337 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1338 | x -= (w/2 ); | 1338 | x -= (w/2 ); |
1339 | } | 1339 | } |
1340 | else | 1340 | else |
1341 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | 1341 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1342 | x += w; | 1342 | x += w; |
1343 | } | 1343 | } |
1344 | x= 0; | 1344 | x= 0; |
1345 | y= dayLabelHei; | 1345 | y= dayLabelHei; |
1346 | w = colWid; | 1346 | w = colWid; |
1347 | h = cellHei; | 1347 | h = cellHei; |
1348 | for ( i = 0; i < mCellsW.count(); ++i) { | 1348 | for ( i = 0; i < mCellsW.count(); ++i) { |
1349 | if ( i > 6 ) { | 1349 | if ( i > 6 ) { |
1350 | mCellsW[i]->hide(); | 1350 | mCellsW[i]->hide(); |
1351 | continue; | 1351 | continue; |
1352 | } | 1352 | } |
1353 | 1353 | ||
1354 | w = colWid; | 1354 | w = colWid; |
1355 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1355 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1356 | ++w; | 1356 | ++w; |
1357 | } | 1357 | } |
1358 | if ( i == (daysToShow-1-rowModulo)*7) | 1358 | if ( i == (daysToShow-1-rowModulo)*7) |
1359 | ++h; | 1359 | ++h; |
1360 | 1360 | ||
1361 | if ( i >= 5 ) { | 1361 | if ( i >= 5 ) { |
1362 | if ( i ==5 ) { | 1362 | if ( i ==5 ) { |
1363 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1363 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1364 | x -= w ;y += h/2; | 1364 | x -= w ;y += h/2; |
1365 | } else { | 1365 | } else { |
1366 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1366 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1367 | ++w; | 1367 | ++w; |
1368 | } | 1368 | } |
1369 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1369 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1370 | y -= h/2; | 1370 | y -= h/2; |
1371 | } | 1371 | } |
1372 | } else | 1372 | } else |
1373 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1373 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1374 | 1374 | ||
1375 | 1375 | ||
1376 | x += w; | 1376 | x += w; |
1377 | if ( x + w/2 > wid ) { | 1377 | if ( x + w/2 > wid ) { |
1378 | x = 0; | 1378 | x = 0; |
1379 | y += h+dayLabelHei ; | 1379 | y += h+dayLabelHei ; |
1380 | } | 1380 | } |
1381 | } | 1381 | } |
1382 | y= dayLabelHei; | 1382 | y= dayLabelHei; |
1383 | h = cellHei ; | 1383 | h = cellHei ; |
1384 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1384 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1385 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1385 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1386 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1386 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1387 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1387 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1388 | mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; | 1388 | mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; |
1389 | updateDayLabels(); | 1389 | updateDayLabels(); |
1390 | bool forceUpdate = !updatePossible; | 1390 | //bool forceUpdate = !updatePossible; |
1391 | updatePossible = true; | 1391 | updatePossible = true; |
1392 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1392 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1393 | if ( forceUpdate ) | 1393 | //if ( forceUpdate ) |
1394 | updateView(); | 1394 | // updateView(); |
1395 | } | 1395 | } |
1396 | void KOMonthView::computeLayout() | 1396 | void KOMonthView::computeLayout() |
1397 | { | 1397 | { |
1398 | 1398 | ||
1399 | 1399 | ||
1400 | static int lastWid = 0; | 1400 | static int lastWid = 0; |
1401 | static int lastHei = 0; | 1401 | static int lastHei = 0; |
1402 | 1402 | ||
1403 | if ( mShowWeekView ){ | 1403 | if ( mShowWeekView ){ |
1404 | computeLayoutWeek(); | 1404 | computeLayoutWeek(); |
1405 | return; | 1405 | return; |
1406 | } | 1406 | } |
1407 | int daysToShow = 7; | 1407 | int daysToShow = 7; |
1408 | bool combinedSatSun = false; | 1408 | bool combinedSatSun = false; |
1409 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1409 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1410 | daysToShow = 6; | 1410 | daysToShow = 6; |
1411 | combinedSatSun = true; | 1411 | combinedSatSun = true; |
1412 | } | 1412 | } |
1413 | int tWid = topLevelWidget()->size().width(); | 1413 | int tWid = topLevelWidget()->size().width(); |
1414 | int tHei = topLevelWidget()->size().height(); | 1414 | int tHei = topLevelWidget()->size().height(); |
1415 | 1415 | ||
1416 | int wid = size().width();//e | 1416 | int wid = width();//e |
1417 | int hei = size().height()-1; | 1417 | int hei = height()-1-mNavigatorBar->height(); |
1418 | 1418 | ||
1419 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1419 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { |
1420 | return; | 1420 | return; |
1421 | if ( lastWid == width() && lastHei ==height() ) | 1421 | } |
1422 | if ( lastWid == width() && lastHei == height() ){ | ||
1422 | return; | 1423 | return; |
1423 | lastWid =width(); | 1424 | } |
1424 | lastHei = height(); | 1425 | |
1425 | qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); | 1426 | lastWid = width(); |
1427 | lastHei = height(); | ||
1428 | //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); | ||
1426 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1429 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1427 | int weeklabelwid = fm.width( "888" ); | 1430 | int weeklabelwid = fm.width( "888" ); |
1428 | wid -= weeklabelwid; | 1431 | wid -= weeklabelwid; |
1429 | 1432 | ||
1430 | int colWid = wid / daysToShow; | 1433 | int colWid = wid / daysToShow; |
1431 | int lastCol = wid - ( colWid*6 ); | 1434 | int lastCol = wid - ( colWid*6 ); |
1432 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1435 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1433 | int cellHei = (hei - dayLabelHei) /6; | 1436 | int cellHei = (hei - dayLabelHei) /6; |
1434 | int colModulo = wid % daysToShow; | 1437 | int colModulo = wid % daysToShow; |
1435 | int rowModulo = (hei- dayLabelHei) % 6; | 1438 | int rowModulo = (hei- dayLabelHei) % 6; |
1436 | //qDebug("rowmod %d ", rowModulo); | 1439 | //qDebug("rowmod %d ", rowModulo); |
1437 | int i; | 1440 | int i; |
1438 | int x,y,w,h; | 1441 | int x,y,w,h; |
1439 | x= 0; | 1442 | x= 0; |
1440 | y= 0; | 1443 | y= 0; |
1441 | w = colWid; | 1444 | w = colWid; |
1442 | h = dayLabelHei ; | 1445 | h = dayLabelHei ; |
1443 | for ( i = 0; i < 7; i++) { | 1446 | for ( i = 0; i < 7; i++) { |
1444 | if ( i == daysToShow-colModulo ) | 1447 | if ( i == daysToShow-colModulo ) |
1445 | ++w; | 1448 | ++w; |
1446 | if ( combinedSatSun ) { | 1449 | if ( combinedSatSun ) { |
1447 | if ( i >= daysToShow-1 ) { | 1450 | if ( i >= daysToShow-1 ) { |
1448 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1451 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1449 | x -= w/2 ; | 1452 | x -= w/2 ; |
1450 | } | 1453 | } |
1451 | else | 1454 | else |
1452 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1455 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1453 | } else | 1456 | } else |
1454 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1457 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1455 | x += w; | 1458 | x += w; |
1456 | } | 1459 | } |
1457 | x= 0; | 1460 | x= 0; |
1458 | y= dayLabelHei; | 1461 | y= dayLabelHei; |
1459 | w = colWid; | 1462 | w = colWid; |
1460 | h = cellHei ; | 1463 | h = cellHei ; |
1461 | for ( i = 0; i < mCells.count(); ++i) { | 1464 | for ( i = 0; i < mCells.count(); ++i) { |
1462 | //qDebug("iii %d ", i); | 1465 | //qDebug("iii %d ", i); |
1463 | w = colWid; | 1466 | w = colWid; |
1464 | if ( ((i) % 7) >= 7-colModulo ) { | 1467 | if ( ((i) % 7) >= 7-colModulo ) { |
1465 | ++w; | 1468 | ++w; |
1466 | } | 1469 | } |
1467 | if ( i == (6-rowModulo)*7) | 1470 | if ( i == (6-rowModulo)*7) |
1468 | ++h; | 1471 | ++h; |
1469 | if ( combinedSatSun ) { | 1472 | if ( combinedSatSun ) { |
1470 | if ( (i)%7 >= daysToShow-1 ) { | 1473 | if ( (i)%7 >= daysToShow-1 ) { |
1471 | if ( (i)%7 == daysToShow-1 ) { | 1474 | if ( (i)%7 == daysToShow-1 ) { |
1472 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1475 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1473 | x -= w ;y += h/2; | 1476 | x -= w ;y += h/2; |
1474 | } else { | 1477 | } else { |
1475 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1478 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1476 | y -= h/2; | 1479 | y -= h/2; |
1477 | } | 1480 | } |
1478 | } else | 1481 | } else |
1479 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1482 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1480 | 1483 | ||
1481 | } | 1484 | } |
1482 | else | 1485 | else |
1483 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1486 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1484 | x += w; | 1487 | x += w; |
1485 | if ( x + w/2 > wid ) { | 1488 | if ( x + w/2 > wid ) { |
1486 | x = 0; | 1489 | x = 0; |
1487 | y += h; | 1490 | y += h; |
1488 | } | 1491 | } |
1489 | } | 1492 | } |
1490 | y= dayLabelHei; | 1493 | y= dayLabelHei; |
1491 | h = cellHei ; | 1494 | h = cellHei ; |
1492 | for ( i = 0; i < 6; i++) { | 1495 | for ( i = 0; i < 6; i++) { |
1493 | if ( i == (6-rowModulo)) | 1496 | if ( i == (6-rowModulo)) |
1494 | ++h; | 1497 | ++h; |
1495 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1498 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1496 | y += h; | 1499 | y += h; |
1497 | } | 1500 | } |
1498 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1501 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1499 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1502 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1500 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1503 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1501 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1504 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1502 | updateDayLabels(); | 1505 | updateDayLabels(); |
1503 | bool forceUpdate = !updatePossible; | 1506 | //bool forceUpdate = !updatePossible; |
1504 | updatePossible = true; | 1507 | updatePossible = true; |
1505 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1508 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1506 | if ( forceUpdate ) | ||
1507 | updateView(); | ||
1508 | } | 1509 | } |
1509 | 1510 | ||
1510 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1511 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1511 | { | 1512 | { |
1512 | mContextMenu->showIncidencePopup(incidence); | 1513 | mContextMenu->showIncidencePopup(incidence); |
1513 | /* | 1514 | /* |
1514 | if( incidence && incidence->type() == "Event" ) { | 1515 | if( incidence && incidence->type() == "Event" ) { |
1515 | Event *event = static_cast<Event *>(incidence); | 1516 | Event *event = static_cast<Event *>(incidence); |
1516 | mContextMenu->showEventPopup(event); | 1517 | mContextMenu->showEventPopup(event); |
1517 | } else { | 1518 | } else { |
1518 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1519 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1519 | } | 1520 | } |
1520 | */ | 1521 | */ |
1521 | } | 1522 | } |
1522 | MonthViewCell * KOMonthView::selectedCell( ) | 1523 | MonthViewCell * KOMonthView::selectedCell( ) |
1523 | { | 1524 | { |
1524 | return mSelectedCell; | 1525 | return mSelectedCell; |
1525 | } | 1526 | } |
1526 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1527 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1527 | { | 1528 | { |
1528 | // qDebug("KOMonthView::setSelectedCell "); | 1529 | // qDebug("KOMonthView::setSelectedCell "); |
1529 | if ( mSelectedCell && mSelectedCell != cell ) { | 1530 | if ( mSelectedCell && mSelectedCell != cell ) { |
1530 | MonthViewCell * mvc = mSelectedCell; | 1531 | MonthViewCell * mvc = mSelectedCell; |
1531 | mSelectedCell = cell; | 1532 | mSelectedCell = cell; |
1532 | mvc->deselect(); | 1533 | mvc->deselect(); |
1533 | } else | 1534 | } else |
1534 | mSelectedCell = cell; | 1535 | mSelectedCell = cell; |
1535 | // if ( mSelectedCell ) | 1536 | // if ( mSelectedCell ) |
1536 | // mSelectedCell->select(); | 1537 | // mSelectedCell->select(); |
1537 | if ( !mSelectedCell ) | 1538 | if ( !mSelectedCell ) |
1538 | emit incidenceSelected( 0 ); | 1539 | emit incidenceSelected( 0 ); |
1539 | else | 1540 | else |
1540 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1541 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1541 | } | 1542 | } |
1542 | 1543 | ||
1543 | void KOMonthView::processSelectionChange() | 1544 | void KOMonthView::processSelectionChange() |
1544 | { | 1545 | { |
1545 | QPtrList<Incidence> incidences = selectedIncidences(); | 1546 | QPtrList<Incidence> incidences = selectedIncidences(); |
1546 | if (incidences.count() > 0) { | 1547 | if (incidences.count() > 0) { |
1547 | emit incidenceSelected( incidences.first() ); | 1548 | emit incidenceSelected( incidences.first() ); |
1548 | } else { | 1549 | } else { |
1549 | emit incidenceSelected( 0 ); | 1550 | emit incidenceSelected( 0 ); |
1550 | } | 1551 | } |
1551 | } | 1552 | } |
1552 | 1553 | ||
1553 | void KOMonthView::clearSelection() | 1554 | void KOMonthView::clearSelection() |
1554 | { | 1555 | { |
1555 | if ( mSelectedCell ) { | 1556 | if ( mSelectedCell ) { |