author | zautrix <zautrix> | 2005-02-06 13:44:49 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-06 13:44:49 (UTC) |
commit | 26b0c69fb3b11c29475ec02b2cfe52e33eb24e5f (patch) (unidiff) | |
tree | 34c4f5e6b2d77dc1210822e1539d9516842b5691 /korganizer/komonthview.cpp | |
parent | 118f5aab05c9ace5612d5c4fd69e7c5a59bed67b (diff) | |
download | kdepimpi-26b0c69fb3b11c29475ec02b2cfe52e33eb24e5f.zip kdepimpi-26b0c69fb3b11c29475ec02b2cfe52e33eb24e5f.tar.gz kdepimpi-26b0c69fb3b11c29475ec02b2cfe52e33eb24e5f.tar.bz2 |
many small fixes
-rw-r--r-- | korganizer/komonthview.cpp | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 65accdc..5926abe 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -774,71 +774,72 @@ void MonthViewCell::contextMenu( QListBoxItem *item ) | |||
774 | { | 774 | { |
775 | if ( !item ) return; | 775 | if ( !item ) return; |
776 | 776 | ||
777 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 777 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
778 | Incidence *incidence = eventItem->incidence(); | 778 | Incidence *incidence = eventItem->incidence(); |
779 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 779 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
780 | } | 780 | } |
781 | 781 | ||
782 | void MonthViewCell::selection( QListBoxItem *item ) | 782 | void MonthViewCell::selection( QListBoxItem *item ) |
783 | { | 783 | { |
784 | if ( !item ) return; | 784 | if ( !item ) return; |
785 | 785 | ||
786 | mMonthView->setSelectedCell( this ); | 786 | mMonthView->setSelectedCell( this ); |
787 | } | 787 | } |
788 | 788 | ||
789 | 789 | ||
790 | // ******************************************************************************* | 790 | // ******************************************************************************* |
791 | // ******************************************************************************* | 791 | // ******************************************************************************* |
792 | // ******************************************************************************* | 792 | // ******************************************************************************* |
793 | 793 | ||
794 | 794 | ||
795 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 795 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
796 | : KOEventView( calendar, parent, name ), | 796 | : KOEventView( calendar, parent, name ), |
797 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 797 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
798 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 798 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
799 | { | 799 | { |
800 | 800 | ignoreResizeEvent = 0; | |
801 | mShortDayLabelsW = false; | ||
802 | mShortDayLabelsM = false; | ||
801 | clPending = true; | 803 | clPending = true; |
802 | mWidStack = new QWidgetStack( this ); | 804 | mWidStack = new QWidgetStack( this ); |
803 | QHBoxLayout* hb = new QHBoxLayout( this ); | 805 | QHBoxLayout* hb = new QHBoxLayout( this ); |
804 | mMonthView = new QWidget( mWidStack ); | 806 | mMonthView = new QWidget( mWidStack ); |
805 | mWeekView = new QWidget( mWidStack ); | 807 | mWeekView = new QWidget( mWidStack ); |
806 | #if QT_VERSION >= 0x030000 | 808 | #if QT_VERSION >= 0x030000 |
807 | mWidStack->addWidget(mMonthView ); | 809 | mWidStack->addWidget(mMonthView ); |
808 | mWidStack->addWidget(mWeekView ); | 810 | mWidStack->addWidget(mWeekView ); |
809 | #else | 811 | #else |
810 | mWidStack->addWidget( mMonthView, 1 ); | 812 | mWidStack->addWidget( mMonthView, 1 ); |
811 | mWidStack->addWidget( mWeekView , 1 ); | 813 | mWidStack->addWidget( mWeekView , 1 ); |
812 | #endif | 814 | #endif |
813 | hb->addWidget( mWidStack ); | 815 | hb->addWidget( mWidStack ); |
814 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 816 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
815 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 817 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
816 | if ( mShowWeekView ) | 818 | if ( mShowWeekView ) |
817 | mWeekStartsMonday = true; | 819 | mWeekStartsMonday = true; |
818 | updatePossible = false; | 820 | updatePossible = false; |
819 | mCells.setAutoDelete( true ); | 821 | mCells.setAutoDelete( true ); |
820 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | ||
821 | mDayLabels.resize( mDaysPerWeek ); | 822 | mDayLabels.resize( mDaysPerWeek ); |
822 | mDayLabelsW.resize( mDaysPerWeek ); | 823 | mDayLabelsW.resize( mDaysPerWeek ); |
823 | QFont bfont = font(); | 824 | QFont bfont = font(); |
824 | if ( QApplication::desktop()->width() < 650 ) { | 825 | if ( QApplication::desktop()->width() < 650 ) { |
825 | bfont.setPointSize( bfont.pointSize() - 2 ); | 826 | bfont.setPointSize( bfont.pointSize() - 2 ); |
826 | } | 827 | } |
827 | bfont.setBold( true ); | 828 | bfont.setBold( true ); |
828 | int i; | 829 | int i; |
829 | 830 | ||
830 | for( i = 0; i < mDaysPerWeek; i++ ) { | 831 | for( i = 0; i < mDaysPerWeek; i++ ) { |
831 | QLabel *label = new QLabel( mMonthView ); | 832 | QLabel *label = new QLabel( mMonthView ); |
832 | label->setFont(bfont); | 833 | label->setFont(bfont); |
833 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 834 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
834 | label->setLineWidth(1); | 835 | label->setLineWidth(1); |
835 | label->setAlignment(AlignCenter); | 836 | label->setAlignment(AlignCenter); |
836 | mDayLabels.insert( i, label ); | 837 | mDayLabels.insert( i, label ); |
837 | label = new QLabel( mWeekView ); | 838 | label = new QLabel( mWeekView ); |
838 | label->setFont(bfont); | 839 | label->setFont(bfont); |
839 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 840 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
840 | label->setLineWidth(1); | 841 | label->setLineWidth(1); |
841 | label->setAlignment(AlignCenter); | 842 | label->setAlignment(AlignCenter); |
842 | mDayLabelsW.insert( i, label ); | 843 | mDayLabelsW.insert( i, label ); |
843 | } | 844 | } |
844 | 845 | ||
@@ -885,56 +886,52 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
885 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 886 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
886 | SLOT( defaultAction( Incidence * ) ) ); | 887 | SLOT( defaultAction( Incidence * ) ) ); |
887 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 888 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
888 | SIGNAL( newEventSignal( QDateTime ) ) ); | 889 | SIGNAL( newEventSignal( QDateTime ) ) ); |
889 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 890 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
890 | SIGNAL( showDaySignal( QDate ) ) ); | 891 | SIGNAL( showDaySignal( QDate ) ) ); |
891 | } | 892 | } |
892 | } | 893 | } |
893 | mCellsW.resize( mDaysPerWeek ); | 894 | mCellsW.resize( mDaysPerWeek ); |
894 | for( col = 0; col < mDaysPerWeek; ++col ) { | 895 | for( col = 0; col < mDaysPerWeek; ++col ) { |
895 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 896 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
896 | mCellsW.insert( col, cell ); | 897 | mCellsW.insert( col, cell ); |
897 | 898 | ||
898 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 899 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
899 | SLOT( defaultAction( Incidence * ) ) ); | 900 | SLOT( defaultAction( Incidence * ) ) ); |
900 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 901 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
901 | SIGNAL( newEventSignal( QDateTime ) ) ); | 902 | SIGNAL( newEventSignal( QDateTime ) ) ); |
902 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 903 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
903 | SIGNAL( showDaySignal( QDate ) ) ); | 904 | SIGNAL( showDaySignal( QDate ) ) ); |
904 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 905 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
905 | } | 906 | } |
906 | 907 | ||
907 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 908 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
908 | mContextMenu = eventPopup(); | 909 | mContextMenu = eventPopup(); |
909 | // updateConfig(); //useless here | 910 | updateConfig(); //useless here |
910 | 911 | ||
911 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 912 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
912 | #if 0 | 913 | |
913 | mWidStack = new QWidgetStack( this ); | ||
914 | mMonthView = new QWidget( mWidStack ); | ||
915 | mWeekView = new QWidget( mWidStack ); | ||
916 | #endif | ||
917 | if ( mShowWeekView ) | 914 | if ( mShowWeekView ) |
918 | mWidStack->raiseWidget( mWeekView ); | 915 | mWidStack->raiseWidget( mWeekView ); |
919 | else | 916 | else |
920 | mWidStack->raiseWidget( mMonthView ); | 917 | mWidStack->raiseWidget( mMonthView ); |
921 | 918 | ||
922 | emit incidenceSelected( 0 ); | 919 | emit incidenceSelected( 0 ); |
923 | } | 920 | } |
924 | 921 | ||
925 | KOMonthView::~KOMonthView() | 922 | KOMonthView::~KOMonthView() |
926 | { | 923 | { |
927 | delete mContextMenu; | 924 | delete mContextMenu; |
928 | } | 925 | } |
929 | 926 | ||
930 | void KOMonthView::selectInternalWeekNum ( int n ) | 927 | void KOMonthView::selectInternalWeekNum ( int n ) |
931 | { | 928 | { |
932 | switchView(); | 929 | switchView(); |
933 | emit selectWeekNum ( n ); | 930 | emit selectWeekNum ( n ); |
934 | } | 931 | } |
935 | 932 | ||
936 | int KOMonthView::currentWeek() | 933 | int KOMonthView::currentWeek() |
937 | { | 934 | { |
938 | if ( mShowWeekView ) | 935 | if ( mShowWeekView ) |
939 | return mWeekLabelsW[0]->getWeekNum(); | 936 | return mWeekLabelsW[0]->getWeekNum(); |
940 | return mWeekLabels[0]->getWeekNum(); | 937 | return mWeekLabels[0]->getWeekNum(); |
@@ -989,110 +986,107 @@ DateList KOMonthView::selectedDates() | |||
989 | if ( qd.isValid() ) selected.append( qd ); | 986 | if ( qd.isValid() ) selected.append( qd ); |
990 | } | 987 | } |
991 | 988 | ||
992 | return selected; | 989 | return selected; |
993 | } | 990 | } |
994 | 991 | ||
995 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 992 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
996 | const QDate &td) | 993 | const QDate &td) |
997 | { | 994 | { |
998 | #ifndef KORG_NOPRINTER | 995 | #ifndef KORG_NOPRINTER |
999 | calPrinter->preview(CalPrinter::Month, fd, td); | 996 | calPrinter->preview(CalPrinter::Month, fd, td); |
1000 | #endif | 997 | #endif |
1001 | } | 998 | } |
1002 | 999 | ||
1003 | void KOMonthView::updateConfig() | 1000 | void KOMonthView::updateConfig() |
1004 | { | 1001 | { |
1005 | 1002 | ||
1006 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1003 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1007 | 1004 | ||
1008 | if ( mShowWeekView ) { | 1005 | if ( mShowWeekView ) { |
1009 | mWeekStartsMonday = true; | 1006 | mWeekStartsMonday = true; |
1010 | } | 1007 | } |
1011 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1008 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1012 | mWidthLongDayLabel = 0; | 1009 | mWidthLongDayLabel = 0; |
1013 | 1010 | qDebug("KOMonthView::updateConfig() "); | |
1014 | for (int i = 0; i < 7; i++) { | 1011 | for (int i = 0; i < 7; i++) { |
1015 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1012 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1016 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1013 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1017 | } | 1014 | } |
1018 | bool temp = mShowSatSunComp ; | ||
1019 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | ||
1020 | if ( ! mShowWeekView ) { | 1015 | if ( ! mShowWeekView ) { |
1021 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | ||
1022 | computeLayout(); | 1016 | computeLayout(); |
1023 | } | 1017 | } |
1024 | updateDayLabels(); | 1018 | updateDayLabels(); |
1025 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1019 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1026 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1020 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1027 | //resizeEvent( 0 ); | 1021 | //resizeEvent( 0 ); |
1028 | for (uint i = 0; i < mCells.count(); ++i) { | 1022 | for (uint i = 0; i < mCells.count(); ++i) { |
1029 | mCells[i]->updateConfig(); | 1023 | mCells[i]->updateConfig(); |
1030 | } | 1024 | } |
1031 | 1025 | ||
1032 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1026 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1033 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1027 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1034 | } | 1028 | } |
1035 | #ifdef DESKTOP_VERSION | 1029 | #ifdef DESKTOP_VERSION |
1036 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1030 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1037 | #endif | 1031 | #endif |
1038 | updateView(); | 1032 | updateView(); |
1039 | } | 1033 | } |
1040 | 1034 | ||
1041 | void KOMonthView::updateDayLabels() | 1035 | void KOMonthView::updateDayLabels() |
1042 | { | 1036 | { |
1043 | 1037 | ||
1044 | QPtrVector<QLabel> *mDayLabelsT; | 1038 | QPtrVector<QLabel> *mDayLabelsT; |
1045 | #if 0 | 1039 | #if 0 |
1046 | if (mShowWeekView ) | 1040 | if (mShowWeekView ) |
1047 | mDayLabelsT = &mDayLabelsW; | 1041 | mDayLabelsT = &mDayLabelsW; |
1048 | else | 1042 | else |
1049 | mDayLabelsT = &mDayLabels; | 1043 | mDayLabelsT = &mDayLabels; |
1050 | #endif | 1044 | #endif |
1051 | 1045 | qDebug("updateDayLabels W %d M %d ",mShortDayLabelsW ,mShortDayLabelsM); | |
1052 | mDayLabelsT = &mDayLabelsW; | 1046 | mDayLabelsT = &mDayLabelsW; |
1053 | for (int i = 0; i < 7; i++) { | 1047 | for (int i = 0; i < 7; i++) { |
1054 | if (mWeekStartsMonday) { | 1048 | if (mWeekStartsMonday) { |
1055 | bool show = mShortDayLabels; | 1049 | bool show = mShortDayLabelsW; |
1056 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1050 | if ( i > 4 && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1057 | show = true; | 1051 | show = true; |
1058 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1052 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1059 | } else { | 1053 | } else { |
1060 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 1054 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); |
1061 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 1055 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); |
1062 | 1056 | ||
1063 | } | 1057 | } |
1064 | } | 1058 | } |
1065 | mDayLabelsT = &mDayLabels; | 1059 | mDayLabelsT = &mDayLabels; |
1066 | for (int i = 0; i < 7; i++) { | 1060 | for (int i = 0; i < 7; i++) { |
1067 | if (mWeekStartsMonday) { | 1061 | if (mWeekStartsMonday) { |
1068 | bool show = mShortDayLabels; | 1062 | bool show = mShortDayLabelsM; |
1069 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1063 | if ( i > 4 && KOPrefs::instance()->mMonthViewSatSunTog && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1070 | show = true; | 1064 | show = true; |
1071 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1065 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1072 | } else { | 1066 | } else { |
1073 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 1067 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1074 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 1068 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1075 | 1069 | ||
1076 | } | 1070 | } |
1077 | } | 1071 | } |
1078 | 1072 | ||
1079 | } | 1073 | } |
1080 | 1074 | ||
1081 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1075 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1082 | { | 1076 | { |
1083 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1077 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1084 | 1078 | ||
1085 | QPtrVector<MonthViewCell> *cells; | 1079 | QPtrVector<MonthViewCell> *cells; |
1086 | QPtrVector<QLabel> *dayLabels; | 1080 | QPtrVector<QLabel> *dayLabels; |
1087 | QPtrVector<KOWeekButton> *weekLabels; | 1081 | QPtrVector<KOWeekButton> *weekLabels; |
1088 | int weekNum = 6; | 1082 | int weekNum = 6; |
1089 | if ( mShowWeekView ) { | 1083 | if ( mShowWeekView ) { |
1090 | weekNum = 1; | 1084 | weekNum = 1; |
1091 | cells = &mCellsW; | 1085 | cells = &mCellsW; |
1092 | dayLabels = &mDayLabelsW; | 1086 | dayLabels = &mDayLabelsW; |
1093 | weekLabels = &mWeekLabelsW; | 1087 | weekLabels = &mWeekLabelsW; |
1094 | } else { | 1088 | } else { |
1095 | cells = &mCells; | 1089 | cells = &mCells; |
1096 | dayLabels = &mDayLabels; | 1090 | dayLabels = &mDayLabels; |
1097 | weekLabels = &mWeekLabels; | 1091 | weekLabels = &mWeekLabels; |
1098 | } | 1092 | } |
@@ -1248,79 +1242,81 @@ void KOMonthView::updateView() | |||
1248 | } | 1242 | } |
1249 | processSelectionChange(); | 1243 | processSelectionChange(); |
1250 | (*cells)[0]->setFocus(); | 1244 | (*cells)[0]->setFocus(); |
1251 | 1245 | ||
1252 | 1246 | ||
1253 | #else | 1247 | #else |
1254 | // old code | 1248 | // old code |
1255 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1249 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1256 | int i; | 1250 | int i; |
1257 | for( i = 0; i < (*cells).count(); ++i ) { | 1251 | for( i = 0; i < (*cells).count(); ++i ) { |
1258 | (*cells)[i]->updateCell(); | 1252 | (*cells)[i]->updateCell(); |
1259 | } | 1253 | } |
1260 | 1254 | ||
1261 | //qDebug("KOMonthView::updateView() "); | 1255 | //qDebug("KOMonthView::updateView() "); |
1262 | processSelectionChange(); | 1256 | processSelectionChange(); |
1263 | // qDebug("---------------------------------------------------------------------+ "); | 1257 | // qDebug("---------------------------------------------------------------------+ "); |
1264 | (*cells)[0]->setFocus(); | 1258 | (*cells)[0]->setFocus(); |
1265 | #endif | 1259 | #endif |
1266 | 1260 | ||
1267 | //qDebug("update time %d ", ti.elapsed()); | 1261 | //qDebug("update time %d ", ti.elapsed()); |
1268 | } | 1262 | } |
1269 | 1263 | ||
1270 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1264 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1271 | { | 1265 | { |
1266 | qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | ||
1267 | if ( ignoreResizeEvent ) { | ||
1268 | qDebug("KOMonthView::resizeEvent ignored "); | ||
1269 | --ignoreResizeEvent; | ||
1270 | return; | ||
1271 | } | ||
1272 | if ( e->size().width()+ e->size().height() < 240 ) | ||
1273 | return; | ||
1272 | computeLayout(); | 1274 | computeLayout(); |
1273 | clPending = true; | 1275 | clPending = true; |
1274 | if ( mShowWeekView ) | 1276 | if ( mShowWeekView ) |
1275 | mCellsW[0]->setFocus(); | 1277 | mCellsW[0]->setFocus(); |
1276 | else | 1278 | else |
1277 | mCells[0]->setFocus(); | 1279 | mCells[0]->setFocus(); |
1278 | } | 1280 | } |
1279 | void KOMonthView::computeLayoutWeek() | 1281 | void KOMonthView::computeLayoutWeek() |
1280 | { | 1282 | { |
1281 | 1283 | ||
1282 | int daysToShow; | 1284 | int daysToShow; |
1283 | bool combinedSatSun = false; | ||
1284 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | ||
1285 | daysToShow = 6; | ||
1286 | combinedSatSun = true; | ||
1287 | } | ||
1288 | int tWid = topLevelWidget()->size().width(); | 1285 | int tWid = topLevelWidget()->size().width(); |
1289 | int tHei = topLevelWidget()->size().height(); | 1286 | int tHei = topLevelWidget()->size().height(); |
1290 | 1287 | ||
1291 | int wid = size().width();//e | 1288 | int wid = size().width();//e |
1292 | int hei = size().height()-1; | 1289 | int hei = size().height()-1; |
1293 | 1290 | ||
1294 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1291 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1295 | return; | 1292 | return; |
1296 | 1293 | ||
1297 | if ( wid < hei ) | 1294 | if ( wid < hei ) |
1298 | daysToShow = 2; | 1295 | daysToShow = 2; |
1299 | else | 1296 | else |
1300 | daysToShow = 3; | 1297 | daysToShow = 3; |
1301 | mShowSatSunComp = true; | 1298 | bool combinedSatSun = true; |
1302 | combinedSatSun = true; | ||
1303 | 1299 | ||
1304 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1300 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1305 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1301 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1306 | int weeklabelwid = fm.width( "888" ); | 1302 | int weeklabelwid = fm.width( "888" ); |
1307 | wid -= weeklabelwid; | 1303 | wid -= weeklabelwid; |
1308 | 1304 | ||
1309 | int colWid = wid / daysToShow; | 1305 | int colWid = wid / daysToShow; |
1310 | int lastCol = wid - ( colWid*6 ); | 1306 | int lastCol = wid - ( colWid*6 ); |
1311 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1307 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1312 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1308 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1313 | int colModulo = wid % daysToShow; | 1309 | int colModulo = wid % daysToShow; |
1314 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1310 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1315 | //qDebug("rowmod %d ", rowModulo); | 1311 | //qDebug("rowmod %d ", rowModulo); |
1316 | int i; | 1312 | int i; |
1317 | int x,y,w,h; | 1313 | int x,y,w,h; |
1318 | x= 0; | 1314 | x= 0; |
1319 | y= 0; | 1315 | y= 0; |
1320 | w = colWid; | 1316 | w = colWid; |
1321 | h = dayLabelHei ; | 1317 | h = dayLabelHei ; |
1322 | for ( i = 0; i < 7; i++) { | 1318 | for ( i = 0; i < 7; i++) { |
1323 | if ( i && !( i % daysToShow) && i < 6) { | 1319 | if ( i && !( i % daysToShow) && i < 6) { |
1324 | y += hei/(5-daysToShow); | 1320 | y += hei/(5-daysToShow); |
1325 | x = 0; | 1321 | x = 0; |
1326 | w = colWid; | 1322 | w = colWid; |
@@ -1359,69 +1355,69 @@ void KOMonthView::computeLayoutWeek() | |||
1359 | x -= w ;y += h/2; | 1355 | x -= w ;y += h/2; |
1360 | } else { | 1356 | } else { |
1361 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1357 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1362 | ++w; | 1358 | ++w; |
1363 | } | 1359 | } |
1364 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1360 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1365 | y -= h/2; | 1361 | y -= h/2; |
1366 | } | 1362 | } |
1367 | } else | 1363 | } else |
1368 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1364 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1369 | 1365 | ||
1370 | 1366 | ||
1371 | x += w; | 1367 | x += w; |
1372 | if ( x + w/2 > wid ) { | 1368 | if ( x + w/2 > wid ) { |
1373 | x = 0; | 1369 | x = 0; |
1374 | y += h+dayLabelHei ; | 1370 | y += h+dayLabelHei ; |
1375 | } | 1371 | } |
1376 | } | 1372 | } |
1377 | y= dayLabelHei; | 1373 | y= dayLabelHei; |
1378 | h = cellHei ; | 1374 | h = cellHei ; |
1379 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1375 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1380 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1376 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1381 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1377 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1382 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1378 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1383 | mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; | 1379 | mShortDayLabelsW = mDayLabelsW[0]->width() < mWidthLongDayLabel ; |
1384 | updateDayLabels(); | 1380 | updateDayLabels(); |
1385 | bool forceUpdate = !updatePossible; | 1381 | bool forceUpdate = !updatePossible; |
1386 | updatePossible = true; | 1382 | updatePossible = true; |
1387 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1383 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1388 | if ( forceUpdate ) | 1384 | if ( forceUpdate ) |
1389 | updateView(); | 1385 | updateView(); |
1390 | } | 1386 | } |
1391 | void KOMonthView::computeLayout() | 1387 | void KOMonthView::computeLayout() |
1392 | { | 1388 | { |
1393 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1389 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
1394 | // note this only changes the text if the requested size crosses the | 1390 | // note this only changes the text if the requested size crosses the |
1395 | // threshold between big enough to support the full name and not big | 1391 | // threshold between big enough to support the full name and not big |
1396 | // enough. | 1392 | // enough. |
1397 | if ( mShowWeekView ){ | 1393 | if ( mShowWeekView ){ |
1398 | computeLayoutWeek(); | 1394 | computeLayoutWeek(); |
1399 | return; | 1395 | return; |
1400 | } | 1396 | } |
1401 | int daysToShow = 7; | 1397 | int daysToShow = 7; |
1402 | bool combinedSatSun = false; | 1398 | bool combinedSatSun = false; |
1403 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1399 | if (KOPrefs::instance()->mMonthViewSatSunTog ) { |
1404 | daysToShow = 6; | 1400 | daysToShow = 6; |
1405 | combinedSatSun = true; | 1401 | combinedSatSun = true; |
1406 | } | 1402 | } |
1407 | int tWid = topLevelWidget()->size().width(); | 1403 | int tWid = topLevelWidget()->size().width(); |
1408 | int tHei = topLevelWidget()->size().height(); | 1404 | int tHei = topLevelWidget()->size().height(); |
1409 | 1405 | ||
1410 | int wid = size().width();//e | 1406 | int wid = size().width();//e |
1411 | int hei = size().height()-1; | 1407 | int hei = size().height()-1; |
1412 | 1408 | ||
1413 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1409 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1414 | return; | 1410 | return; |
1415 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1411 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1416 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1412 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1417 | int weeklabelwid = fm.width( "888" ); | 1413 | int weeklabelwid = fm.width( "888" ); |
1418 | wid -= weeklabelwid; | 1414 | wid -= weeklabelwid; |
1419 | 1415 | ||
1420 | int colWid = wid / daysToShow; | 1416 | int colWid = wid / daysToShow; |
1421 | int lastCol = wid - ( colWid*6 ); | 1417 | int lastCol = wid - ( colWid*6 ); |
1422 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1418 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1423 | int cellHei = (hei - dayLabelHei) /6; | 1419 | int cellHei = (hei - dayLabelHei) /6; |
1424 | int colModulo = wid % daysToShow; | 1420 | int colModulo = wid % daysToShow; |
1425 | int rowModulo = (hei- dayLabelHei) % 6; | 1421 | int rowModulo = (hei- dayLabelHei) % 6; |
1426 | //qDebug("rowmod %d ", rowModulo); | 1422 | //qDebug("rowmod %d ", rowModulo); |
1427 | int i; | 1423 | int i; |
@@ -1466,49 +1462,50 @@ void KOMonthView::computeLayout() | |||
1466 | } | 1462 | } |
1467 | } else | 1463 | } else |
1468 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1464 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1469 | 1465 | ||
1470 | } | 1466 | } |
1471 | else | 1467 | else |
1472 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1468 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1473 | x += w; | 1469 | x += w; |
1474 | if ( x + w/2 > wid ) { | 1470 | if ( x + w/2 > wid ) { |
1475 | x = 0; | 1471 | x = 0; |
1476 | y += h; | 1472 | y += h; |
1477 | } | 1473 | } |
1478 | } | 1474 | } |
1479 | y= dayLabelHei; | 1475 | y= dayLabelHei; |
1480 | h = cellHei ; | 1476 | h = cellHei ; |
1481 | for ( i = 0; i < 6; i++) { | 1477 | for ( i = 0; i < 6; i++) { |
1482 | if ( i == (6-rowModulo)) | 1478 | if ( i == (6-rowModulo)) |
1483 | ++h; | 1479 | ++h; |
1484 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1480 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1485 | y += h; | 1481 | y += h; |
1486 | } | 1482 | } |
1487 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1483 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1488 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1484 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1489 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1485 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1490 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1486 | mShortDayLabelsM = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1487 | qDebug("dlwid %d %d ",mDayLabels[0]->width() , mWidthLongDayLabel); | ||
1491 | updateDayLabels(); | 1488 | updateDayLabels(); |
1492 | bool forceUpdate = !updatePossible; | 1489 | bool forceUpdate = !updatePossible; |
1493 | updatePossible = true; | 1490 | updatePossible = true; |
1494 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1491 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1495 | if ( forceUpdate ) | 1492 | if ( forceUpdate ) |
1496 | updateView(); | 1493 | updateView(); |
1497 | } | 1494 | } |
1498 | 1495 | ||
1499 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1496 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1500 | { | 1497 | { |
1501 | mContextMenu->showIncidencePopup(incidence); | 1498 | mContextMenu->showIncidencePopup(incidence); |
1502 | /* | 1499 | /* |
1503 | if( incidence && incidence->type() == "Event" ) { | 1500 | if( incidence && incidence->type() == "Event" ) { |
1504 | Event *event = static_cast<Event *>(incidence); | 1501 | Event *event = static_cast<Event *>(incidence); |
1505 | mContextMenu->showEventPopup(event); | 1502 | mContextMenu->showEventPopup(event); |
1506 | } else { | 1503 | } else { |
1507 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1504 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1508 | } | 1505 | } |
1509 | */ | 1506 | */ |
1510 | } | 1507 | } |
1511 | MonthViewCell * KOMonthView::selectedCell( ) | 1508 | MonthViewCell * KOMonthView::selectedCell( ) |
1512 | { | 1509 | { |
1513 | return mSelectedCell; | 1510 | return mSelectedCell; |
1514 | } | 1511 | } |