author | zautrix <zautrix> | 2005-04-05 09:30:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-05 09:30:00 (UTC) |
commit | 53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216 (patch) (side-by-side diff) | |
tree | 8dfcb059271cbfd4e28425d85dea747aa998594d | |
parent | 768858848f466a726e2f50b777345976828cc2ff (diff) | |
download | kdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.zip kdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.tar.gz kdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.tar.bz2 |
fix
-rw-r--r-- | korganizer/kodaymatrix.cpp | 144 | ||||
-rw-r--r-- | korganizer/kodaymatrix.h | 2 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 34 | ||||
-rw-r--r-- | korganizer/komonthview.h | 6 |
4 files changed, 173 insertions, 13 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index c7e1b45..322131f 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -118,8 +118,9 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const mPendingUpdateBeforeRepaint = false; mouseDown = false; // initialize dynamic arrays bDays.resize ( NUMDAYS ); + pDays.resize ( NUMDAYS ); hDays.resize ( NUMDAYS ); eDays.resize ( NUMDAYS ); days = new QDate[NUMDAYS]; daylbls = new QString[NUMDAYS]; @@ -339,20 +340,153 @@ void KODayMatrix::updateView() void KODayMatrix::repaintViewTimed() { mRedrawNeeded = true; bDays.fill( false); + pDays.fill( false); hDays.fill( false); eDays.fill( false); mRepaintTimer->stop(); + int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday + int i; + for(i = 0; i < NUMDAYS; i++) { + if ( ( (i+startDay) % 7 == 0 ) ) { + pDays.setBit(i); + } + } repaint(false); } +void KODayMatrix::computeEvent(Event *event, int i ) +{ + QString holiStr = mHolidays[i]; + if ( event->isHoliday()) { + pDays.setBit(i); + hDays.setBit(i); + if ( !holiStr.isEmpty() ) + holiStr += "\n"; + holiStr += event->summary(); + if ( !event->location().isEmpty() ) + holiStr += " (" + event->location() + ")"; + mHolidays[i] =holiStr ; + } + if ( event->isBirthday()) { + pDays.setBit(i); + if ( !holiStr.isEmpty() ) + holiStr += "\n"; + holiStr += i18n("Birthday") + ": "+event->summary(); + if ( !event->location().isEmpty() ) + holiStr += " (" + event->location() + ")"; + bDays.setBit(i); + mHolidays[i] =holiStr ; + } + eDays.setBit(i); +} void KODayMatrix::updateViewTimed() { mUpdateTimer->stop(); if ( !mCalendar ) { qDebug("NOT CAL "); return; } +#if 1 + + int i; + int timeSpan = NUMDAYS-1; + QPtrList<Event> events = mCalendar->events(); + Event *event; + QDateTime dt; + bool ok; + bDays.fill( false); + pDays.fill( false); + hDays.fill( false); + eDays.fill( false); + mHolidays.clear(); + QDate mStartDate = days[0]; + QDate endDate = mStartDate.addDays( timeSpan ); + for( event = events.first(); event; event = events.next() ) { // for event + ushort recurType = event->recurrence()->doesRecur(); + if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || + (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { + continue; + } + if ( event->doesRecur() ) { + bool last; + QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); + QDateTime incidenceEnd; + int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); + bool invalid = false; + while( true ) { + if ( incidenceStart.isValid() ) { + incidenceEnd = incidenceStart.addDays( eventlen ); + int st = incidenceStart.date().daysTo( endDate ); + if ( st >= 0 ) { // start before timeend + int end = mStartDate.daysTo( incidenceEnd.date() ); + if ( end >= 0 ) { // end after timestart --- got one! + //normalize + st = timeSpan - st; + if ( st < 0 ) st = 0; + if ( end > timeSpan ) end = timeSpan; + int iii; + //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); + for ( iii = st;iii<= end;++iii) { + computeEvent( event, iii ); + } + } + } + } else { + if ( invalid ) + break; + invalid = true; + //qDebug("invalid %s", event->summary().latin1()); + incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; + } + if ( last ) + break; + bool ok; + incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); + if ( ! ok ) + break; + if ( incidenceStart.date() > endDate ) + break; + } + } else { // no recur + int st = event->dtStart().date().daysTo( endDate ); + if ( st >= 0 ) { // start before timeend + int end = mStartDate.daysTo( event->dtEnd().date() ); + if ( end >= 0 ) { // end after timestart --- got one! + //normalize + st = timeSpan - st; + if ( st < 0 ) st = 0; + if ( end > timeSpan ) end = timeSpan; + int iii; + for ( iii = st;iii<= end;++iii) + computeEvent( event, iii ); + } + } + } + } + int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday + for(i = 0; i < NUMDAYS; i++) { + if ( ( (i+startDay) % 7 == 0 ) ) { + pDays.setBit(i); + } + } + +#if 0 + // insert due todos + QPtrList<Todo> todos = calendar()->todos( ); + Todo *todo; + for(todo = todos.first(); todo; todo = todos.next()) { + //insertTodo( todo ); + if ( todo->hasDueDate() ) { + int day = mStartDate.daysTo( todo->dtDue().date() ); + if ( day >= 0 && day < timeSpan + 1) { + (*cells)[day]->insertTodo( todo ); + } + } + } +#endif + +#else //qDebug("KODayMatrix::updateViewTimed "); for(int i = 0; i < NUMDAYS; i++) { // if events are set for the day then remember to draw it bold QPtrList<Event> eventlist = mCalendar->events(days[i]); @@ -362,8 +496,9 @@ void KODayMatrix::updateViewTimed() bDays.clearBit(i); hDays.clearBit(i); eDays.clearBit(i); for(event=eventlist.first();event != 0;event=eventlist.next()) { + qDebug("FFFFFFFFFFFFFFFFFFFFFFFFF "); ushort recurType = event->recurrence()->doesRecur(); if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { numEvents--; @@ -394,8 +529,9 @@ void KODayMatrix::updateViewTimed() } else { mHolidays[i] = QString::null; } } +#endif mRedrawNeeded = true; if ( ! mPendingUpdateBeforeRepaint ) repaint(false); } @@ -441,9 +577,9 @@ void KODayMatrix::updateView(QDate actdate) //updateViewTimed(); mUpdateTimer->start( 50 ); #else mRepaintTimer->start( 350 ); - mUpdateTimer->start( 1200 ); + mUpdateTimer->start( 800 ); #endif } } void KODayMatrix::updateEvents() @@ -872,9 +1008,9 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) mTodayPen.setWidth(1); else mTodayPen.setWidth(mTodayMarginWidth); //draw red rectangle for holidays - if (!mHolidays[i].isNull()) { + if (pDays.testBit(i)) { if (actcol == mDefaultTextColor) { mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); } else { mTodayPen.setColor(mHolidayColorShaded); @@ -913,9 +1049,9 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) p.setFont(myFont); } // if it is a holiday then use the default holiday color - if ( !mHolidays[i].isNull()) { + if ( pDays.testBit(i)) { if ( bDays.testBit(i) ) { if ( hDays.testBit(i) ) p.setPen(QColor(Qt::green)); else @@ -952,9 +1088,9 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent) p.drawText(col*dwidth+addCol, row*dheight+addRow, dwidth, dheight, Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); // reset color to actual color - if (!mHolidays[i].isNull()) { + if (pDays.testBit(i)) { p.setPen(actcol); } // reset bold font to plain font if ( eDays.testBit(i)) { diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h index d725ead..b686bd7 100644 --- a/korganizer/kodaymatrix.h +++ b/korganizer/kodaymatrix.h @@ -226,15 +226,17 @@ protected: void resizeEvent(QResizeEvent *); private: + void computeEvent(Event *even, int dayindex ); int oldW, oldH; bool mRedrawNeeded; KODaymatrixWhatsThis* mKODaymatrixWhatsThis; bool mouseDown; QBitArray bDays; QBitArray hDays; QBitArray eDays; + QBitArray pDays; QPixmap myPix; QTimer* mUpdateTimer; QTimer* mRepaintTimer; bool mDayChanged; diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 1ed288b..425496a 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -268,8 +268,9 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) mRecur = false; mAlarm = false; mReply = false; mInfo = false; + mdayPos = 0; isWeekItem = KOPrefs::instance()->mMonthViewWeek; //qDebug("NEWWWWWWWWWWWWW "); } void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) @@ -280,9 +281,10 @@ void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) mDate = qd; mRecur = false; mAlarm = false; mReply = false; - mInfo = false; + mInfo = false; + mdayPos = 0; //qDebug("recucleeeeeeeeeeeeeeeee "); } void MonthViewItem::paint(QPainter *p) @@ -569,9 +571,9 @@ void MonthViewCell::setHoliday( const QString &holiday ) } void MonthViewCell::startUpdateCell() { - + mdayCount = 0; setFocusPolicy(NoFocus); if ( !mMonthView->isUpdatePossible() ) return; MonthViewItem *mitem = (MonthViewItem*) firstItem (); @@ -620,18 +622,18 @@ void MonthViewCell::startUpdateCell() } #endif } -void MonthViewCell::insertEvent(Event *event) +int MonthViewCell::insertEvent(Event *event) { QString mToolTipText; setFocusPolicy(WheelFocus); if ( !(event->doesRecur() == Recurrence::rNone) ) { if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) - return; + return mdayCount; else if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) - return; + return mdayCount; } if ( event->isHoliday()) { setHoliday( true ); @@ -729,10 +731,26 @@ void MonthViewCell::insertEvent(Event *event) } else item->setReply(false); #endif item->setMultiDay( multiday ); - insertItem( item ); + if ( multiday ) { + insertItem( item ,mdayCount); + ++mdayCount; + } else { + uint i; + int pos = mdayCount; + for ( i = mdayCount; i < count();++i ) { + QListBoxItem* it = this->item ( i ); + if ( text < it->text() ) { + pos = i; + break; + } + ++pos; + } + insertItem( item ,pos); + } mToolTip.append( mToolTipText ); + return mdayCount; } void MonthViewCell::insertTodo(Todo *todo) { setFocusPolicy(WheelFocus); @@ -780,9 +798,9 @@ void MonthViewCell::insertTodo(Todo *todo) item->setPalette( pal ); item->setRecur( todo->recurrence()->doesRecur() ); item->setAlarm( todo->isAlarmEnabled() ); item->setMoreInfo( todo->description().length() > 0 ); - insertItem( item ); + insertItem( item , count()); mToolTip.append( text ); } void MonthViewCell::repaintfinishUpdateCell() { @@ -803,9 +821,9 @@ void MonthViewCell::finishUpdateCell() mToolTip.sort(); QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); } #endif - sort(); + //sort(); //setMyPalette(); setMyPalette(); resizeEvent( 0 ); diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index e962756..e39eeb0 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -107,8 +107,10 @@ class MonthViewItem: public QListBoxItem void setAlarm(bool on) { mAlarm = on; } void setReply(bool on) { mReply = on; } void setMoreInfo(bool on) { mInfo = on; } void setMultiDay(int type) { mMultiday = type; } + void setMultiDayPos(int type) { mdayPos = type; } + int gettMultiDayPos() { return mdayPos; } void setBlockRepaint(bool on) { mblockRepaint = on; } void setPalette(const QPalette &p) { mPalette = p; } @@ -122,8 +124,9 @@ class MonthViewItem: public QListBoxItem virtual int height(const QListBox *) const; virtual int width(const QListBox *) const; private: + int mdayPos; bool isWeekItem; bool mblockRepaint; int mMultiday; bool mRecur; @@ -159,9 +162,9 @@ class MonthViewCell : public KNoScrollListBox void updateCell(); void startUpdateCell(); void finishUpdateCell(); void repaintfinishUpdateCell(); - void insertEvent(Event *); + int insertEvent(Event *); void insertTodo(Todo *); void updateConfig( bool bigFont = false ); @@ -196,8 +199,9 @@ public slots: void cellClicked( QListBoxItem * ); void newEvent(); private: + int mdayCount; QPtrList <MonthViewItem> mAvailItemList; KOMonthView *mMonthView; int currentPalette; |