summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-05 09:30:00 (UTC)
committer zautrix <zautrix>2005-04-05 09:30:00 (UTC)
commit53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216 (patch) (unidiff)
tree8dfcb059271cbfd4e28425d85dea747aa998594d
parent768858848f466a726e2f50b777345976828cc2ff (diff)
downloadkdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.zip
kdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.tar.gz
kdepimpi-53d7ec81939a9cf7ea2f63f133c1b61b2e2a9216.tar.bz2
fix
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kodaymatrix.cpp144
-rw-r--r--korganizer/kodaymatrix.h2
-rw-r--r--korganizer/komonthview.cpp32
-rw-r--r--korganizer/komonthview.h6
4 files changed, 172 insertions, 12 deletions
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index c7e1b45..322131f 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -119,6 +119,7 @@ KODayMatrix::KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const
119 mouseDown = false; 119 mouseDown = false;
120 // initialize dynamic arrays 120 // initialize dynamic arrays
121 bDays.resize ( NUMDAYS ); 121 bDays.resize ( NUMDAYS );
122 pDays.resize ( NUMDAYS );
122 hDays.resize ( NUMDAYS ); 123 hDays.resize ( NUMDAYS );
123 eDays.resize ( NUMDAYS ); 124 eDays.resize ( NUMDAYS );
124 days = new QDate[NUMDAYS]; 125 days = new QDate[NUMDAYS];
@@ -340,11 +341,44 @@ void KODayMatrix::repaintViewTimed()
340{ 341{
341 mRedrawNeeded = true; 342 mRedrawNeeded = true;
342 bDays.fill( false); 343 bDays.fill( false);
344 pDays.fill( false);
343 hDays.fill( false); 345 hDays.fill( false);
344 eDays.fill( false); 346 eDays.fill( false);
345 mRepaintTimer->stop(); 347 mRepaintTimer->stop();
348 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
349 int i;
350 for(i = 0; i < NUMDAYS; i++) {
351 if ( ( (i+startDay) % 7 == 0 ) ) {
352 pDays.setBit(i);
353 }
354 }
346 repaint(false); 355 repaint(false);
347} 356}
357void KODayMatrix::computeEvent(Event *event, int i )
358{
359 QString holiStr = mHolidays[i];
360 if ( event->isHoliday()) {
361 pDays.setBit(i);
362 hDays.setBit(i);
363 if ( !holiStr.isEmpty() )
364 holiStr += "\n";
365 holiStr += event->summary();
366 if ( !event->location().isEmpty() )
367 holiStr += " (" + event->location() + ")";
368 mHolidays[i] =holiStr ;
369 }
370 if ( event->isBirthday()) {
371 pDays.setBit(i);
372 if ( !holiStr.isEmpty() )
373 holiStr += "\n";
374 holiStr += i18n("Birthday") + ": "+event->summary();
375 if ( !event->location().isEmpty() )
376 holiStr += " (" + event->location() + ")";
377 bDays.setBit(i);
378 mHolidays[i] =holiStr ;
379 }
380 eDays.setBit(i);
381}
348void KODayMatrix::updateViewTimed() 382void KODayMatrix::updateViewTimed()
349{ 383{
350 mUpdateTimer->stop(); 384 mUpdateTimer->stop();
@@ -352,6 +386,106 @@ void KODayMatrix::updateViewTimed()
352 qDebug("NOT CAL "); 386 qDebug("NOT CAL ");
353 return; 387 return;
354 } 388 }
389#if 1
390
391 int i;
392 int timeSpan = NUMDAYS-1;
393 QPtrList<Event> events = mCalendar->events();
394 Event *event;
395 QDateTime dt;
396 bool ok;
397 bDays.fill( false);
398 pDays.fill( false);
399 hDays.fill( false);
400 eDays.fill( false);
401 mHolidays.clear();
402 QDate mStartDate = days[0];
403 QDate endDate = mStartDate.addDays( timeSpan );
404 for( event = events.first(); event; event = events.next() ) { // for event
405 ushort recurType = event->recurrence()->doesRecur();
406 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
407 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
408 continue;
409 }
410 if ( event->doesRecur() ) {
411 bool last;
412 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
413 QDateTime incidenceEnd;
414 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
415 bool invalid = false;
416 while( true ) {
417 if ( incidenceStart.isValid() ) {
418 incidenceEnd = incidenceStart.addDays( eventlen );
419 int st = incidenceStart.date().daysTo( endDate );
420 if ( st >= 0 ) { // start before timeend
421 int end = mStartDate.daysTo( incidenceEnd.date() );
422 if ( end >= 0 ) { // end after timestart --- got one!
423 //normalize
424 st = timeSpan - st;
425 if ( st < 0 ) st = 0;
426 if ( end > timeSpan ) end = timeSpan;
427 int iii;
428 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
429 for ( iii = st;iii<= end;++iii) {
430 computeEvent( event, iii );
431 }
432 }
433 }
434 } else {
435 if ( invalid )
436 break;
437 invalid = true;
438 //qDebug("invalid %s", event->summary().latin1());
439 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
440 }
441 if ( last )
442 break;
443 bool ok;
444 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
445 if ( ! ok )
446 break;
447 if ( incidenceStart.date() > endDate )
448 break;
449 }
450 } else { // no recur
451 int st = event->dtStart().date().daysTo( endDate );
452 if ( st >= 0 ) { // start before timeend
453 int end = mStartDate.daysTo( event->dtEnd().date() );
454 if ( end >= 0 ) { // end after timestart --- got one!
455 //normalize
456 st = timeSpan - st;
457 if ( st < 0 ) st = 0;
458 if ( end > timeSpan ) end = timeSpan;
459 int iii;
460 for ( iii = st;iii<= end;++iii)
461 computeEvent( event, iii );
462 }
463 }
464 }
465 }
466 int startDay = days[0].dayOfWeek(); // 1...7 7 = sunday
467 for(i = 0; i < NUMDAYS; i++) {
468 if ( ( (i+startDay) % 7 == 0 ) ) {
469 pDays.setBit(i);
470 }
471 }
472
473#if 0
474 // insert due todos
475 QPtrList<Todo> todos = calendar()->todos( );
476 Todo *todo;
477 for(todo = todos.first(); todo; todo = todos.next()) {
478 //insertTodo( todo );
479 if ( todo->hasDueDate() ) {
480 int day = mStartDate.daysTo( todo->dtDue().date() );
481 if ( day >= 0 && day < timeSpan + 1) {
482 (*cells)[day]->insertTodo( todo );
483 }
484 }
485 }
486#endif
487
488#else
355 //qDebug("KODayMatrix::updateViewTimed "); 489 //qDebug("KODayMatrix::updateViewTimed ");
356 for(int i = 0; i < NUMDAYS; i++) { 490 for(int i = 0; i < NUMDAYS; i++) {
357 // if events are set for the day then remember to draw it bold 491 // if events are set for the day then remember to draw it bold
@@ -363,6 +497,7 @@ void KODayMatrix::updateViewTimed()
363 hDays.clearBit(i); 497 hDays.clearBit(i);
364 eDays.clearBit(i); 498 eDays.clearBit(i);
365 for(event=eventlist.first();event != 0;event=eventlist.next()) { 499 for(event=eventlist.first();event != 0;event=eventlist.next()) {
500 qDebug("FFFFFFFFFFFFFFFFFFFFFFFFF ");
366 ushort recurType = event->recurrence()->doesRecur(); 501 ushort recurType = event->recurrence()->doesRecur();
367 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) || 502 if ((recurType == Recurrence::rDaily && !KOPrefs::instance()->mDailyRecur) ||
368 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) { 503 (recurType == Recurrence::rWeekly && !KOPrefs::instance()->mWeeklyRecur)) {
@@ -395,6 +530,7 @@ void KODayMatrix::updateViewTimed()
395 mHolidays[i] = QString::null; 530 mHolidays[i] = QString::null;
396 } 531 }
397 } 532 }
533#endif
398 mRedrawNeeded = true; 534 mRedrawNeeded = true;
399 if ( ! mPendingUpdateBeforeRepaint ) 535 if ( ! mPendingUpdateBeforeRepaint )
400 repaint(false); 536 repaint(false);
@@ -442,7 +578,7 @@ void KODayMatrix::updateView(QDate actdate)
442 mUpdateTimer->start( 50 ); 578 mUpdateTimer->start( 50 );
443#else 579#else
444 mRepaintTimer->start( 350 ); 580 mRepaintTimer->start( 350 );
445 mUpdateTimer->start( 1200 ); 581 mUpdateTimer->start( 800 );
446#endif 582#endif
447 } 583 }
448} 584}
@@ -873,7 +1009,7 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
873 else 1009 else
874 mTodayPen.setWidth(mTodayMarginWidth); 1010 mTodayPen.setWidth(mTodayMarginWidth);
875 //draw red rectangle for holidays 1011 //draw red rectangle for holidays
876 if (!mHolidays[i].isNull()) { 1012 if (pDays.testBit(i)) {
877 if (actcol == mDefaultTextColor) { 1013 if (actcol == mDefaultTextColor) {
878 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor); 1014 mTodayPen.setColor(KOPrefs::instance()->mHolidayColor);
879 } else { 1015 } else {
@@ -914,7 +1050,7 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
914 } 1050 }
915 1051
916 // if it is a holiday then use the default holiday color 1052 // if it is a holiday then use the default holiday color
917 if ( !mHolidays[i].isNull()) { 1053 if ( pDays.testBit(i)) {
918 if ( bDays.testBit(i) ) { 1054 if ( bDays.testBit(i) ) {
919 if ( hDays.testBit(i) ) 1055 if ( hDays.testBit(i) )
920 p.setPen(QColor(Qt::green)); 1056 p.setPen(QColor(Qt::green));
@@ -953,7 +1089,7 @@ void KODayMatrix::paintEvent(QPaintEvent * pevent)
953 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]); 1089 Qt::AlignHCenter | Qt::AlignVCenter, daylbls[i]);
954 1090
955 // reset color to actual color 1091 // reset color to actual color
956 if (!mHolidays[i].isNull()) { 1092 if (pDays.testBit(i)) {
957 p.setPen(actcol); 1093 p.setPen(actcol);
958 } 1094 }
959 // reset bold font to plain font 1095 // reset bold font to plain font
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index d725ead..b686bd7 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -227,6 +227,7 @@ protected:
227 void resizeEvent(QResizeEvent *); 227 void resizeEvent(QResizeEvent *);
228 228
229private: 229private:
230 void computeEvent(Event *even, int dayindex );
230 int oldW, oldH; 231 int oldW, oldH;
231 bool mRedrawNeeded; 232 bool mRedrawNeeded;
232 KODaymatrixWhatsThis* mKODaymatrixWhatsThis; 233 KODaymatrixWhatsThis* mKODaymatrixWhatsThis;
@@ -234,6 +235,7 @@ private:
234 QBitArray bDays; 235 QBitArray bDays;
235 QBitArray hDays; 236 QBitArray hDays;
236 QBitArray eDays; 237 QBitArray eDays;
238 QBitArray pDays;
237 QPixmap myPix; 239 QPixmap myPix;
238 QTimer* mUpdateTimer; 240 QTimer* mUpdateTimer;
239 QTimer* mRepaintTimer; 241 QTimer* mRepaintTimer;
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 1ed288b..425496a 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -269,6 +269,7 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
269 mAlarm = false; 269 mAlarm = false;
270 mReply = false; 270 mReply = false;
271 mInfo = false; 271 mInfo = false;
272 mdayPos = 0;
272 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 273 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
273 //qDebug("NEWWWWWWWWWWWWW "); 274 //qDebug("NEWWWWWWWWWWWWW ");
274} 275}
@@ -282,6 +283,7 @@ void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
282 mAlarm = false; 283 mAlarm = false;
283 mReply = false; 284 mReply = false;
284 mInfo = false; 285 mInfo = false;
286 mdayPos = 0;
285 //qDebug("recucleeeeeeeeeeeeeeeee "); 287 //qDebug("recucleeeeeeeeeeeeeeeee ");
286} 288}
287 289
@@ -570,7 +572,7 @@ void MonthViewCell::setHoliday( const QString &holiday )
570 572
571void MonthViewCell::startUpdateCell() 573void MonthViewCell::startUpdateCell()
572{ 574{
573 575 mdayCount = 0;
574 setFocusPolicy(NoFocus); 576 setFocusPolicy(NoFocus);
575 if ( !mMonthView->isUpdatePossible() ) 577 if ( !mMonthView->isUpdatePossible() )
576 return; 578 return;
@@ -621,16 +623,16 @@ void MonthViewCell::startUpdateCell()
621#endif 623#endif
622} 624}
623 625
624void MonthViewCell::insertEvent(Event *event) 626int MonthViewCell::insertEvent(Event *event)
625{ 627{
626 QString mToolTipText; 628 QString mToolTipText;
627 setFocusPolicy(WheelFocus); 629 setFocusPolicy(WheelFocus);
628 if ( !(event->doesRecur() == Recurrence::rNone) ) { 630 if ( !(event->doesRecur() == Recurrence::rNone) ) {
629 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 631 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
630 return; 632 return mdayCount;
631 else 633 else
632 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 634 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
633 return; 635 return mdayCount;
634 } 636 }
635 637
636 if ( event->isHoliday()) { 638 if ( event->isHoliday()) {
@@ -730,8 +732,24 @@ void MonthViewCell::insertEvent(Event *event)
730 item->setReply(false); 732 item->setReply(false);
731#endif 733#endif
732 item->setMultiDay( multiday ); 734 item->setMultiDay( multiday );
733 insertItem( item ); 735 if ( multiday ) {
736 insertItem( item ,mdayCount);
737 ++mdayCount;
738 } else {
739 uint i;
740 int pos = mdayCount;
741 for ( i = mdayCount; i < count();++i ) {
742 QListBoxItem* it = this->item ( i );
743 if ( text < it->text() ) {
744 pos = i;
745 break;
746 }
747 ++pos;
748 }
749 insertItem( item ,pos);
750 }
734 mToolTip.append( mToolTipText ); 751 mToolTip.append( mToolTipText );
752 return mdayCount;
735} 753}
736void MonthViewCell::insertTodo(Todo *todo) 754void MonthViewCell::insertTodo(Todo *todo)
737{ 755{
@@ -781,7 +799,7 @@ void MonthViewCell::insertTodo(Todo *todo)
781 item->setRecur( todo->recurrence()->doesRecur() ); 799 item->setRecur( todo->recurrence()->doesRecur() );
782 item->setAlarm( todo->isAlarmEnabled() ); 800 item->setAlarm( todo->isAlarmEnabled() );
783 item->setMoreInfo( todo->description().length() > 0 ); 801 item->setMoreInfo( todo->description().length() > 0 );
784 insertItem( item ); 802 insertItem( item , count());
785 mToolTip.append( text ); 803 mToolTip.append( text );
786} 804}
787void MonthViewCell::repaintfinishUpdateCell() 805void MonthViewCell::repaintfinishUpdateCell()
@@ -804,7 +822,7 @@ void MonthViewCell::finishUpdateCell()
804 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 822 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
805 } 823 }
806#endif 824#endif
807 sort(); 825 //sort();
808 //setMyPalette(); 826 //setMyPalette();
809 setMyPalette(); 827 setMyPalette();
810 828
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index e962756..e39eeb0 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -108,6 +108,8 @@ class MonthViewItem: public QListBoxItem
108 void setReply(bool on) { mReply = on; } 108 void setReply(bool on) { mReply = on; }
109 void setMoreInfo(bool on) { mInfo = on; } 109 void setMoreInfo(bool on) { mInfo = on; }
110 void setMultiDay(int type) { mMultiday = type; } 110 void setMultiDay(int type) { mMultiday = type; }
111 void setMultiDayPos(int type) { mdayPos = type; }
112 int gettMultiDayPos() { return mdayPos; }
111 void setBlockRepaint(bool on) { mblockRepaint = on; } 113 void setBlockRepaint(bool on) { mblockRepaint = on; }
112 114
113 115
@@ -123,6 +125,7 @@ class MonthViewItem: public QListBoxItem
123 virtual int width(const QListBox *) const; 125 virtual int width(const QListBox *) const;
124 126
125 private: 127 private:
128 int mdayPos;
126 bool isWeekItem; 129 bool isWeekItem;
127 bool mblockRepaint; 130 bool mblockRepaint;
128 int mMultiday; 131 int mMultiday;
@@ -160,7 +163,7 @@ class MonthViewCell : public KNoScrollListBox
160 void startUpdateCell(); 163 void startUpdateCell();
161 void finishUpdateCell(); 164 void finishUpdateCell();
162 void repaintfinishUpdateCell(); 165 void repaintfinishUpdateCell();
163 void insertEvent(Event *); 166 int insertEvent(Event *);
164 void insertTodo(Todo *); 167 void insertTodo(Todo *);
165 168
166 void updateConfig( bool bigFont = false ); 169 void updateConfig( bool bigFont = false );
@@ -197,6 +200,7 @@ public slots:
197 void newEvent(); 200 void newEvent();
198 201
199 private: 202 private:
203 int mdayCount;
200 QPtrList <MonthViewItem> mAvailItemList; 204 QPtrList <MonthViewItem> mAvailItemList;
201 KOMonthView *mMonthView; 205 KOMonthView *mMonthView;
202 int currentPalette; 206 int currentPalette;