summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp144
-rw-r--r--korganizer/kodaymatrix.h2
-rw-r--r--korganizer/komonthview.cpp34
-rw-r--r--korganizer/komonthview.h6
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
@@ -121,2 +121,3 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const
bDays.resize ( NUMDAYS );
+ pDays.resize ( NUMDAYS );
hDays.resize ( NUMDAYS );
@@ -342,2 +343,3 @@ void KODayMatrix::repaintViewTimed()
bDays.fill( false);
+ pDays.fill( false);
hDays.fill( false);
@@ -345,4 +347,36 @@ void KODayMatrix::repaintViewTimed()
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()
@@ -354,2 +388,102 @@ void KODayMatrix::updateViewTimed()
}
+#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 ");
@@ -365,2 +499,3 @@ void KODayMatrix::updateViewTimed()
for(event=eventlist.first();event != 0;event=eventlist.next()) {
+ qDebug("FFFFFFFFFFFFFFFFFFFFFFFFF ");
ushort recurType = event->recurrence()->doesRecur();
@@ -397,2 +532,3 @@ void KODayMatrix::updateViewTimed()
}
+#endif
mRedrawNeeded = true;
@@ -444,3 +580,3 @@ void KODayMatrix::updateView(QDate actdate)
mRepaintTimer->start( 350 );
- mUpdateTimer->start( 1200 );
+ mUpdateTimer->start( 800 );
#endif
@@ -875,3 +1011,3 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
//draw red rectangle for holidays
- if (!mHolidays[i].isNull()) {
+ if (pDays.testBit(i)) {
if (actcol == mDefaultTextColor) {
@@ -916,3 +1052,3 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
// if it is a holiday then use the default holiday color
- if ( !mHolidays[i].isNull()) {
+ if ( pDays.testBit(i)) {
if ( bDays.testBit(i) ) {
@@ -955,3 +1091,3 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
// reset color to actual color
- if (!mHolidays[i].isNull()) {
+ if (pDays.testBit(i)) {
p.setPen(actcol);
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index d725ead..b686bd7 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -229,2 +229,3 @@ protected:
private:
+ void computeEvent(Event *even, int dayindex );
int oldW, oldH;
@@ -236,2 +237,3 @@ private:
QBitArray eDays;
+ QBitArray pDays;
QPixmap myPix;
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 1ed288b..425496a 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -271,2 +271,3 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
mInfo = false;
+ mdayPos = 0;
isWeekItem = KOPrefs::instance()->mMonthViewWeek;
@@ -283,3 +284,4 @@ void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
mReply = false;
- mInfo = false;
+ mInfo = false;
+ mdayPos = 0;
//qDebug("recucleeeeeeeeeeeeeeeee ");
@@ -572,3 +574,3 @@ void MonthViewCell::startUpdateCell()
{
-
+ mdayCount = 0;
setFocusPolicy(NoFocus);
@@ -623,3 +625,3 @@ void MonthViewCell::startUpdateCell()
-void MonthViewCell::insertEvent(Event *event)
+int MonthViewCell::insertEvent(Event *event)
{
@@ -629,6 +631,6 @@ void MonthViewCell::insertEvent(Event *event)
if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
- return;
+ return mdayCount;
else
if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
- return;
+ return mdayCount;
}
@@ -732,4 +734,20 @@ void MonthViewCell::insertEvent(Event *event)
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;
}
@@ -783,3 +801,3 @@ void MonthViewCell::insertTodo(Todo *todo)
item->setMoreInfo( todo->description().length() > 0 );
- insertItem( item );
+ insertItem( item , count());
mToolTip.append( text );
@@ -806,3 +824,3 @@ void MonthViewCell::finishUpdateCell()
#endif
- sort();
+ //sort();
//setMyPalette();
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index e962756..e39eeb0 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -110,2 +110,4 @@ class MonthViewItem: public QListBoxItem
void setMultiDay(int type) { mMultiday = type; }
+ void setMultiDayPos(int type) { mdayPos = type; }
+ int gettMultiDayPos() { return mdayPos; }
void setBlockRepaint(bool on) { mblockRepaint = on; }
@@ -125,2 +127,3 @@ class MonthViewItem: public QListBoxItem
private:
+ int mdayPos;
bool isWeekItem;
@@ -162,3 +165,3 @@ class MonthViewCell : public KNoScrollListBox
void repaintfinishUpdateCell();
- void insertEvent(Event *);
+ int insertEvent(Event *);
void insertTodo(Todo *);
@@ -199,2 +202,3 @@ public slots:
private:
+ int mdayCount;
QPtrList <MonthViewItem> mAvailItemList;