author | zautrix <zautrix> | 2005-03-31 23:55:51 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-31 23:55:51 (UTC) |
commit | b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c (patch) (unidiff) | |
tree | b0b3d0eb7a3d29981c183275aadeed0cbbef0007 /korganizer/komonthview.cpp | |
parent | c0fa26aa3b33c293853bdd7d028ddb0545e33c85 (diff) | |
download | kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.zip kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.tar.gz kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.tar.bz2 |
fixes
-rw-r--r-- | korganizer/komonthview.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index b9ce4f4..ab9a4b6 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -844,193 +844,197 @@ void MonthViewCell::enableScrollBars( bool enabled ) | |||
844 | int ihei = fi->height( this ); | 844 | int ihei = fi->height( this ); |
845 | int hei = numRows () * ihei; | 845 | int hei = numRows () * ihei; |
846 | if ( hei < height() - horizontalScrollBar()->height () ) { | 846 | if ( hei < height() - horizontalScrollBar()->height () ) { |
847 | setVScrollBarMode(QScrollView::AlwaysOff); | 847 | setVScrollBarMode(QScrollView::AlwaysOff); |
848 | } | 848 | } |
849 | else | 849 | else |
850 | setVScrollBarMode(QScrollView::Auto); | 850 | setVScrollBarMode(QScrollView::Auto); |
851 | if ( ihei *3 > height() ) | 851 | if ( ihei *3 > height() ) |
852 | setHScrollBarMode(QScrollView::AlwaysOff); | 852 | setHScrollBarMode(QScrollView::AlwaysOff); |
853 | else | 853 | else |
854 | setHScrollBarMode(QScrollView::Auto); | 854 | setHScrollBarMode(QScrollView::Auto); |
855 | } else { | 855 | } else { |
856 | setVScrollBarMode(QScrollView::Auto); | 856 | setVScrollBarMode(QScrollView::Auto); |
857 | setHScrollBarMode(QScrollView::Auto); | 857 | setHScrollBarMode(QScrollView::Auto); |
858 | } | 858 | } |
859 | } else { | 859 | } else { |
860 | setVScrollBarMode(QScrollView::AlwaysOff); | 860 | setVScrollBarMode(QScrollView::AlwaysOff); |
861 | setHScrollBarMode(QScrollView::AlwaysOff); | 861 | setHScrollBarMode(QScrollView::AlwaysOff); |
862 | } | 862 | } |
863 | } | 863 | } |
864 | 864 | ||
865 | Incidence *MonthViewCell::selectedIncidence() | 865 | Incidence *MonthViewCell::selectedIncidence() |
866 | { | 866 | { |
867 | int index = currentItem(); | 867 | int index = currentItem(); |
868 | if ( index < 0 ) return 0; | 868 | if ( index < 0 ) return 0; |
869 | 869 | ||
870 | MonthViewItem *mitem = | 870 | MonthViewItem *mitem = |
871 | static_cast<MonthViewItem *>( item( index ) ); | 871 | static_cast<MonthViewItem *>( item( index ) ); |
872 | 872 | ||
873 | if ( !mitem ) return 0; | 873 | if ( !mitem ) return 0; |
874 | 874 | ||
875 | return mitem->incidence(); | 875 | return mitem->incidence(); |
876 | } | 876 | } |
877 | 877 | ||
878 | QDate MonthViewCell::selectedIncidenceDate() | 878 | QDate MonthViewCell::selectedIncidenceDate() |
879 | { | 879 | { |
880 | QDate qd; | 880 | QDate qd; |
881 | int index = currentItem(); | 881 | int index = currentItem(); |
882 | if ( index < 0 ) return qd; | 882 | if ( index < 0 ) return qd; |
883 | 883 | ||
884 | MonthViewItem *mitem = | 884 | MonthViewItem *mitem = |
885 | static_cast<MonthViewItem *>( item( index ) ); | 885 | static_cast<MonthViewItem *>( item( index ) ); |
886 | 886 | ||
887 | if ( !mitem ) return qd; | 887 | if ( !mitem ) return qd; |
888 | 888 | ||
889 | return mitem->incidenceDate(); | 889 | return mitem->incidenceDate(); |
890 | } | 890 | } |
891 | 891 | ||
892 | void MonthViewCell::deselect() | 892 | void MonthViewCell::deselect() |
893 | { | 893 | { |
894 | clearSelection(); | 894 | clearSelection(); |
895 | enableScrollBars( false ); | 895 | enableScrollBars( false ); |
896 | // updateCell(); | 896 | // updateCell(); |
897 | } | 897 | } |
898 | void MonthViewCell::select() | 898 | void MonthViewCell::select() |
899 | { | 899 | { |
900 | ;// updateCell(); | 900 | ;// updateCell(); |
901 | } | 901 | } |
902 | 902 | ||
903 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 903 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
904 | { | 904 | { |
905 | if ( !mMonthView->isUpdatePossible() ) | 905 | if ( !mMonthView->isUpdatePossible() ) |
906 | return; | 906 | return; |
907 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 907 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
908 | deselect(); | 908 | deselect(); |
909 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 909 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
910 | 910 | ||
911 | QString text; | 911 | QString text; |
912 | mLabel->setText( text ); | 912 | mLabel->setText( text ); |
913 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 913 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
914 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 914 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
915 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 915 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
916 | mLabel->resize( mLabelBigSize ); | 916 | mLabel->resize( mLabelBigSize ); |
917 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 917 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
918 | } else { | 918 | } else { |
919 | mLabel->resize( mLabelSize ); | 919 | mLabel->resize( mLabelSize ); |
920 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 920 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
921 | } | 921 | } |
922 | mLabel->setText( text ); | 922 | mLabel->setText( text ); |
923 | 923 | ||
924 | int size = height() - mLabel->height() - lineWidth()-1; | 924 | int size = height() - mLabel->height() - lineWidth()-1; |
925 | //qDebug("LW %d ", lineWidth()); | 925 | //qDebug("LW %d ", lineWidth()); |
926 | if ( size > 0 ) | 926 | if ( size > 0 ) |
927 | verticalScrollBar()->setMaximumHeight( size ); | 927 | verticalScrollBar()->setMaximumHeight( size ); |
928 | size = width() - mLabel->width() -lineWidth()-1; | 928 | size = width() - mLabel->width() -lineWidth()-1; |
929 | if ( size > 0 ) | 929 | if ( size > 0 ) |
930 | horizontalScrollBar()->setMaximumWidth( size ); | 930 | horizontalScrollBar()->setMaximumWidth( size ); |
931 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 931 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
932 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 932 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
933 | // mItemList->resize ( width(), height () ); | 933 | // mItemList->resize ( width(), height () ); |
934 | if ( e ) | 934 | if ( e ) |
935 | KNoScrollListBox::resizeEvent ( e ); | 935 | KNoScrollListBox::resizeEvent ( e ); |
936 | } | 936 | } |
937 | 937 | ||
938 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 938 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
939 | { | 939 | { |
940 | if ( !item ) return; | 940 | if ( !item ) { |
941 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | ||
942 | emit newEventSignal( dt ); | ||
943 | return; | ||
944 | } | ||
941 | 945 | ||
942 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 946 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
943 | Incidence *incidence = eventItem->incidence(); | 947 | Incidence *incidence = eventItem->incidence(); |
944 | if ( incidence ) mMonthView->defaultAction( incidence ); | 948 | if ( incidence ) mMonthView->defaultAction( incidence ); |
945 | } | 949 | } |
946 | void MonthViewCell::showDay() | 950 | void MonthViewCell::showDay() |
947 | { | 951 | { |
948 | emit showDaySignal( date() ); | 952 | emit showDaySignal( date() ); |
949 | } | 953 | } |
950 | void MonthViewCell::newEvent() | 954 | void MonthViewCell::newEvent() |
951 | { | 955 | { |
952 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 956 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
953 | emit newEventSignal( dt ); | 957 | emit newEventSignal( dt ); |
954 | } | 958 | } |
955 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 959 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
956 | { | 960 | { |
957 | static QListBoxItem * lastClicked = 0; | 961 | static QListBoxItem * lastClicked = 0; |
958 | if ( item == 0 ) { | 962 | if ( item == 0 ) { |
959 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 963 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
960 | emit newEventSignal( dt ); | 964 | emit newEventSignal( dt ); |
961 | return; | 965 | return; |
962 | } | 966 | } |
963 | /* | 967 | /* |
964 | if ( lastClicked ) | 968 | if ( lastClicked ) |
965 | if ( ! item ) { | 969 | if ( ! item ) { |
966 | if ( lastClicked->listBox() != item->listBox() ) | 970 | if ( lastClicked->listBox() != item->listBox() ) |
967 | lastClicked->listBox()->clearSelection(); | 971 | lastClicked->listBox()->clearSelection(); |
968 | } | 972 | } |
969 | */ | 973 | */ |
970 | 974 | ||
971 | mMonthView->setSelectedCell( this ); | 975 | mMonthView->setSelectedCell( this ); |
972 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 976 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
973 | select(); | 977 | select(); |
974 | } | 978 | } |
975 | 979 | ||
976 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 980 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
977 | { | 981 | { |
978 | if ( !item ) return; | 982 | if ( !item ) return; |
979 | 983 | ||
980 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 984 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
981 | Incidence *incidence = eventItem->incidence(); | 985 | Incidence *incidence = eventItem->incidence(); |
982 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 986 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
983 | } | 987 | } |
984 | 988 | ||
985 | void MonthViewCell::selection( QListBoxItem *item ) | 989 | void MonthViewCell::selection( QListBoxItem *item ) |
986 | { | 990 | { |
987 | if ( !item ) return; | 991 | if ( !item ) return; |
988 | 992 | ||
989 | mMonthView->setSelectedCell( this ); | 993 | mMonthView->setSelectedCell( this ); |
990 | } | 994 | } |
991 | 995 | ||
992 | 996 | ||
993 | // ******************************************************************************* | 997 | // ******************************************************************************* |
994 | // ******************************************************************************* | 998 | // ******************************************************************************* |
995 | // ******************************************************************************* | 999 | // ******************************************************************************* |
996 | 1000 | ||
997 | 1001 | ||
998 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1002 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
999 | : KOEventView( calendar, parent, name ), | 1003 | : KOEventView( calendar, parent, name ), |
1000 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1004 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1001 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1005 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1002 | { | 1006 | { |
1003 | mFlagKeyPressed = false; | 1007 | mFlagKeyPressed = false; |
1004 | mShortDayLabelsM = false; | 1008 | mShortDayLabelsM = false; |
1005 | mShortDayLabelsW = false; | 1009 | mShortDayLabelsW = false; |
1006 | skipResize = false; | 1010 | skipResize = false; |
1007 | clPending = true; | 1011 | clPending = true; |
1008 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1012 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1009 | mWidStack = new QWidgetStack( this ); | 1013 | mWidStack = new QWidgetStack( this ); |
1010 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1014 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1011 | mMonthView = new QWidget( mWidStack ); | 1015 | mMonthView = new QWidget( mWidStack ); |
1012 | mWeekView = new QWidget( mWidStack ); | 1016 | mWeekView = new QWidget( mWidStack ); |
1013 | #if QT_VERSION >= 0x030000 | 1017 | #if QT_VERSION >= 0x030000 |
1014 | mWidStack->addWidget(mMonthView ); | 1018 | mWidStack->addWidget(mMonthView ); |
1015 | mWidStack->addWidget(mWeekView ); | 1019 | mWidStack->addWidget(mWeekView ); |
1016 | #else | 1020 | #else |
1017 | mWidStack->addWidget( mMonthView, 1 ); | 1021 | mWidStack->addWidget( mMonthView, 1 ); |
1018 | mWidStack->addWidget( mWeekView , 1 ); | 1022 | mWidStack->addWidget( mWeekView , 1 ); |
1019 | #endif | 1023 | #endif |
1020 | hb->addWidget( mNavigatorBar ); | 1024 | hb->addWidget( mNavigatorBar ); |
1021 | hb->addWidget( mWidStack ); | 1025 | hb->addWidget( mWidStack ); |
1022 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1026 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1023 | updatePossible = false; | 1027 | updatePossible = false; |
1024 | //updatePossible = true; | 1028 | //updatePossible = true; |
1025 | mCells.setAutoDelete( true ); | 1029 | mCells.setAutoDelete( true ); |
1026 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1030 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1027 | mDayLabels.resize( mDaysPerWeek ); | 1031 | mDayLabels.resize( mDaysPerWeek ); |
1028 | mDayLabelsW.resize( mDaysPerWeek ); | 1032 | mDayLabelsW.resize( mDaysPerWeek ); |
1029 | QFont bfont = font(); | 1033 | QFont bfont = font(); |
1030 | if ( QApplication::desktop()->width() < 650 ) { | 1034 | if ( QApplication::desktop()->width() < 650 ) { |
1031 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1035 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1032 | } | 1036 | } |
1033 | bfont.setBold( true ); | 1037 | bfont.setBold( true ); |
1034 | int i; | 1038 | int i; |
1035 | 1039 | ||
1036 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1040 | for( i = 0; i < mDaysPerWeek; i++ ) { |
@@ -1278,192 +1282,193 @@ void KOMonthView::updateDayLabels() | |||
1278 | for (int i = 0; i < 7; i++) { | 1282 | for (int i = 0; i < 7; i++) { |
1279 | { | 1283 | { |
1280 | bool show = mShortDayLabelsW; | 1284 | bool show = mShortDayLabelsW; |
1281 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1285 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1282 | show = true; | 1286 | show = true; |
1283 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1287 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1284 | } | 1288 | } |
1285 | } | 1289 | } |
1286 | mDayLabelsT = &mDayLabels; | 1290 | mDayLabelsT = &mDayLabels; |
1287 | for (int i = 0; i < 7; i++) { | 1291 | for (int i = 0; i < 7; i++) { |
1288 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1292 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1289 | bool show = mShortDayLabelsM; | 1293 | bool show = mShortDayLabelsM; |
1290 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1294 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1291 | show = true; | 1295 | show = true; |
1292 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1296 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1293 | } else { | 1297 | } else { |
1294 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1298 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1295 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1299 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1296 | 1300 | ||
1297 | } | 1301 | } |
1298 | } | 1302 | } |
1299 | 1303 | ||
1300 | } | 1304 | } |
1301 | 1305 | ||
1302 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1306 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1303 | { | 1307 | { |
1304 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1308 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1305 | 1309 | ||
1306 | QPtrVector<MonthViewCell> *cells; | 1310 | QPtrVector<MonthViewCell> *cells; |
1307 | QPtrVector<QLabel> *dayLabels; | 1311 | QPtrVector<QLabel> *dayLabels; |
1308 | QPtrVector<KOWeekButton> *weekLabels; | 1312 | QPtrVector<KOWeekButton> *weekLabels; |
1309 | int weekNum = 6; | 1313 | int weekNum = 6; |
1310 | mStartDate = start; | 1314 | mStartDate = start; |
1311 | if ( mShowWeekView ) { | 1315 | if ( mShowWeekView ) { |
1312 | weekNum = 1; | 1316 | weekNum = 1; |
1313 | cells = &mCellsW; | 1317 | cells = &mCellsW; |
1314 | dayLabels = &mDayLabelsW; | 1318 | dayLabels = &mDayLabelsW; |
1315 | weekLabels = &mWeekLabelsW; | 1319 | weekLabels = &mWeekLabelsW; |
1316 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1320 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1317 | mStartDate = mStartDate.addDays( 1 ); | 1321 | mStartDate = mStartDate.addDays( 1 ); |
1318 | } | 1322 | } |
1319 | } else { | 1323 | } else { |
1320 | cells = &mCells; | 1324 | cells = &mCells; |
1321 | dayLabels = &mDayLabels; | 1325 | dayLabels = &mDayLabels; |
1322 | weekLabels = &mWeekLabels; | 1326 | weekLabels = &mWeekLabels; |
1323 | } | 1327 | } |
1324 | 1328 | ||
1325 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1329 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1326 | 1330 | ||
1327 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1331 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1328 | mWeekStartsMonday = true; | 1332 | mWeekStartsMonday = true; |
1329 | } | 1333 | } |
1330 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1334 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1331 | 1335 | ||
1332 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1336 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1333 | mStartDate = mStartDate.addDays( -1 ); | 1337 | mStartDate = mStartDate.addDays( -1 ); |
1334 | } | 1338 | } |
1335 | bool primary = false; | 1339 | bool primary = false; |
1336 | uint i; | 1340 | uint i; |
1337 | for( i = 0; i < (*cells).size(); ++i ) { | 1341 | for( i = 0; i < (*cells).size(); ++i ) { |
1338 | QDate date = mStartDate.addDays( i ); | 1342 | QDate date = mStartDate.addDays( i ); |
1339 | (*cells)[i]->setDate( date ); | 1343 | (*cells)[i]->setDate( date ); |
1340 | 1344 | ||
1341 | #ifndef KORG_NOPLUGINS | 1345 | #ifndef KORG_NOPLUGINS |
1342 | // add holiday, if present | 1346 | // add holiday, if present |
1343 | QString hstring(KOCore::self()->holiday(date)); | 1347 | QString hstring(KOCore::self()->holiday(date)); |
1344 | (*cells)[i]->setHoliday( hstring ); | 1348 | (*cells)[i]->setHoliday( hstring ); |
1345 | #endif | 1349 | #endif |
1346 | 1350 | ||
1347 | } | 1351 | } |
1348 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1352 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1349 | for( i = 0; i < weekNum; ++i ) { | 1353 | for( i = 0; i < weekNum; ++i ) { |
1350 | int wno; | 1354 | int wno; |
1351 | // remember, according to ISO 8601, the first week of the year is the | 1355 | // remember, according to ISO 8601, the first week of the year is the |
1352 | // first week that contains a thursday. Thus we must subtract off 4, | 1356 | // first week that contains a thursday. Thus we must subtract off 4, |
1353 | // not just 1. | 1357 | // not just 1. |
1354 | int dayOfYear = date.dayOfYear(); | 1358 | int dayOfYear = date.dayOfYear(); |
1355 | if (dayOfYear % 7 != 0) | 1359 | if (dayOfYear % 7 != 0) |
1356 | wno = dayOfYear / 7 + 1; | 1360 | wno = dayOfYear / 7 + 1; |
1357 | else | 1361 | else |
1358 | wno =dayOfYear / 7; | 1362 | wno =dayOfYear / 7; |
1359 | (*weekLabels)[i]->setWeekNum( wno ); | 1363 | (*weekLabels)[i]->setWeekNum( wno ); |
1360 | date = date.addDays( 7 ); | 1364 | date = date.addDays( 7 ); |
1361 | } | 1365 | } |
1362 | updateView(); | 1366 | updateView(); |
1363 | } | 1367 | } |
1364 | 1368 | ||
1365 | void KOMonthView::showEvents(QPtrList<Event>) | 1369 | void KOMonthView::showEvents(QPtrList<Event>) |
1366 | { | 1370 | { |
1367 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1371 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1368 | } | 1372 | } |
1369 | 1373 | ||
1370 | void KOMonthView::changeEventDisplay(Event *, int) | 1374 | void KOMonthView::changeEventDisplay(Event *, int) |
1371 | { | 1375 | { |
1372 | // this should be re-written to be much more efficient, but this | 1376 | // this should be re-written to be much more efficient, but this |
1373 | // quick-and-dirty-hack gets the job done for right now. | 1377 | // quick-and-dirty-hack gets the job done for right now. |
1378 | qDebug("KOMonthView::changeEventDisplay "); | ||
1374 | updateView(); | 1379 | updateView(); |
1375 | } | 1380 | } |
1376 | 1381 | ||
1377 | void KOMonthView::updateView() | 1382 | void KOMonthView::updateView() |
1378 | { | 1383 | { |
1379 | 1384 | ||
1380 | if ( !updatePossible ) | 1385 | if ( !updatePossible ) |
1381 | return; | 1386 | return; |
1382 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1387 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1383 | //QTime ti; | 1388 | //QTime ti; |
1384 | //ti.start(); | 1389 | //ti.start(); |
1385 | clearSelection(); | 1390 | clearSelection(); |
1386 | QPtrVector<MonthViewCell> *cells; | 1391 | QPtrVector<MonthViewCell> *cells; |
1387 | if ( mShowWeekView ) { | 1392 | if ( mShowWeekView ) { |
1388 | cells = &mCellsW; | 1393 | cells = &mCellsW; |
1389 | } else { | 1394 | } else { |
1390 | cells = &mCells; | 1395 | cells = &mCells; |
1391 | } | 1396 | } |
1392 | #if 1 | 1397 | #if 1 |
1393 | int i; | 1398 | int i; |
1394 | int timeSpan = (*cells).size()-1; | 1399 | int timeSpan = (*cells).size()-1; |
1395 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1400 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1396 | timeSpan = 6; | 1401 | timeSpan = 6; |
1397 | for( i = 0; i < timeSpan + 1; ++i ) { | 1402 | for( i = 0; i < timeSpan + 1; ++i ) { |
1398 | (*cells)[i]->startUpdateCell(); | 1403 | (*cells)[i]->startUpdateCell(); |
1399 | } | 1404 | } |
1400 | 1405 | ||
1401 | QPtrList<Event> events = calendar()->events(); | 1406 | QPtrList<Event> events = calendar()->events(); |
1402 | Event *event; | 1407 | Event *event; |
1403 | QDateTime dt; | 1408 | QDateTime dt; |
1404 | bool ok; | 1409 | bool ok; |
1405 | QDate endDate = mStartDate.addDays( timeSpan ); | 1410 | QDate endDate = mStartDate.addDays( timeSpan ); |
1406 | for( event = events.first(); event; event = events.next() ) { // for event | 1411 | for( event = events.first(); event; event = events.next() ) { // for event |
1407 | if ( event->doesRecur() ) { | 1412 | if ( event->doesRecur() ) { |
1408 | bool last; | 1413 | bool last; |
1409 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1414 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1410 | QDateTime incidenceEnd; | 1415 | QDateTime incidenceEnd; |
1411 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1416 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1412 | bool invalid = false; | 1417 | bool invalid = false; |
1413 | while( true ) { | 1418 | while( true ) { |
1414 | if ( incidenceStart.isValid() ) { | 1419 | if ( incidenceStart.isValid() ) { |
1415 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1420 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1416 | int st = incidenceStart.date().daysTo( endDate ); | 1421 | int st = incidenceStart.date().daysTo( endDate ); |
1417 | if ( st >= 0 ) { // start before timeend | 1422 | if ( st >= 0 ) { // start before timeend |
1418 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1423 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1419 | if ( end >= 0 ) { // end after timestart --- got one! | 1424 | if ( end >= 0 ) { // end after timestart --- got one! |
1420 | //normalize | 1425 | //normalize |
1421 | st = timeSpan - st; | 1426 | st = timeSpan - st; |
1422 | if ( st < 0 ) st = 0; | 1427 | if ( st < 0 ) st = 0; |
1423 | if ( end > timeSpan ) end = timeSpan; | 1428 | if ( end > timeSpan ) end = timeSpan; |
1424 | int iii; | 1429 | int iii; |
1425 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1430 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1426 | for ( iii = st;iii<= end;++iii) | 1431 | for ( iii = st;iii<= end;++iii) |
1427 | (*cells)[iii]->insertEvent( event ); | 1432 | (*cells)[iii]->insertEvent( event ); |
1428 | } | 1433 | } |
1429 | } | 1434 | } |
1430 | } else { | 1435 | } else { |
1431 | if ( invalid ) | 1436 | if ( invalid ) |
1432 | break; | 1437 | break; |
1433 | invalid = true; | 1438 | invalid = true; |
1434 | //qDebug("invalid %s", event->summary().latin1()); | 1439 | //qDebug("invalid %s", event->summary().latin1()); |
1435 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1440 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1436 | } | 1441 | } |
1437 | if ( last ) | 1442 | if ( last ) |
1438 | break; | 1443 | break; |
1439 | bool ok; | 1444 | bool ok; |
1440 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1445 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1441 | if ( ! ok ) | 1446 | if ( ! ok ) |
1442 | break; | 1447 | break; |
1443 | if ( incidenceStart.date() > endDate ) | 1448 | if ( incidenceStart.date() > endDate ) |
1444 | break; | 1449 | break; |
1445 | } | 1450 | } |
1446 | } else { // no recur | 1451 | } else { // no recur |
1447 | int st = event->dtStart().date().daysTo( endDate ); | 1452 | int st = event->dtStart().date().daysTo( endDate ); |
1448 | if ( st >= 0 ) { // start before timeend | 1453 | if ( st >= 0 ) { // start before timeend |
1449 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1454 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1450 | if ( end >= 0 ) { // end after timestart --- got one! | 1455 | if ( end >= 0 ) { // end after timestart --- got one! |
1451 | //normalize | 1456 | //normalize |
1452 | st = timeSpan - st; | 1457 | st = timeSpan - st; |
1453 | if ( st < 0 ) st = 0; | 1458 | if ( st < 0 ) st = 0; |
1454 | if ( end > timeSpan ) end = timeSpan; | 1459 | if ( end > timeSpan ) end = timeSpan; |
1455 | int iii; | 1460 | int iii; |
1456 | for ( iii = st;iii<= end;++iii) | 1461 | for ( iii = st;iii<= end;++iii) |
1457 | (*cells)[iii]->insertEvent( event ); | 1462 | (*cells)[iii]->insertEvent( event ); |
1458 | } | 1463 | } |
1459 | } | 1464 | } |
1460 | } | 1465 | } |
1461 | } | 1466 | } |
1462 | // insert due todos | 1467 | // insert due todos |
1463 | QPtrList<Todo> todos = calendar()->todos( ); | 1468 | QPtrList<Todo> todos = calendar()->todos( ); |
1464 | Todo *todo; | 1469 | Todo *todo; |
1465 | for(todo = todos.first(); todo; todo = todos.next()) { | 1470 | for(todo = todos.first(); todo; todo = todos.next()) { |
1466 | //insertTodo( todo ); | 1471 | //insertTodo( todo ); |
1467 | if ( todo->hasDueDate() ) { | 1472 | if ( todo->hasDueDate() ) { |
1468 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1473 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1469 | if ( day >= 0 && day < timeSpan + 1) { | 1474 | if ( day >= 0 && day < timeSpan + 1) { |