summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-31 16:29:05 (UTC)
committer zautrix <zautrix>2005-01-31 16:29:05 (UTC)
commitec037c4616342c1b3976c55db98b775f48e0d455 (patch) (unidiff)
tree9d568c8f6ad6005f822c12644596b7a553837c7f /korganizer
parent5d52c81be9b43887c13f8534a04164d3b44b821f (diff)
downloadkdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.zip
kdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.tar.gz
kdepimpi-ec037c4616342c1b3976c55db98b775f48e0d455.tar.bz2
fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp165
-rw-r--r--korganizer/komonthview.h5
2 files changed, 144 insertions, 26 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 770a42b..6646b98 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -391,18 +391,20 @@ void MonthViewCell::keyPressEvent ( QKeyEvent * e )
391} 391}
392void MonthViewCell::clear() 392void MonthViewCell::clear()
393{ 393{
394 mItemList->clear(); 394 mItemList->clear();
395 QApplication::removePostedEvents ( mItemList ); 395 QApplication::removePostedEvents ( mItemList );
396 QApplication::removePostedEvents ( mLabel ); 396 QApplication::removePostedEvents ( mLabel );
397 QApplication::removePostedEvents ( this ); 397 QApplication::removePostedEvents ( this );
398} 398}
399void MonthViewCell::updateCell() 399
400void MonthViewCell::startUpdateCell()
400{ 401{
402
401 if ( !mMonthView->isUpdatePossible() ) 403 if ( !mMonthView->isUpdatePossible() )
402 return; 404 return;
403 /* 405 /*
404 if ( !isVisible() ){ 406 if ( !isVisible() ){
405 return; 407 return;
406 } 408 }
407 */ 409 */
408 // qDebug("MonthViewCell::updateCell() "); 410 // qDebug("MonthViewCell::updateCell() ");
@@ -413,35 +415,34 @@ void MonthViewCell::updateCell()
413 } else { 415 } else {
414 mItemList->setLineWidth( 1 ); 416 mItemList->setLineWidth( 1 );
415 } 417 }
416 mItemList->clear(); 418 mItemList->clear();
417 419
418#ifdef DESKTOP_VERSION 420#ifdef DESKTOP_VERSION
419 QToolTip::remove(this); 421 QToolTip::remove(this);
420#endif 422#endif
421 QString tipText(""); 423 mToolTip = "";
422 //qApp->processEvents(); 424 //qApp->processEvents();
423 if ( !mHolidayString.isEmpty() ) { 425 if ( !mHolidayString.isEmpty() ) {
424 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 426 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
425 item->setPalette( mHolidayPalette ); 427 item->setPalette( mHolidayPalette );
426 mItemList->insertItem( item ); 428 mItemList->insertItem( item );
427 tipText += mHolidayString+"\n"; 429 mToolTip += mHolidayString+"\n";
428 } 430 }
429 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 431}
430 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
431 Event *event;
432 for( event = events.first(); event; event = events.next() ) { // for event
433 432
433void MonthViewCell::insertEvent(Event *event)
434{
434 if ( !(event->doesRecur() == Recurrence::rNone) ) { 435 if ( !(event->doesRecur() == Recurrence::rNone) ) {
435 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 436 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
436 continue; 437 return;
437 else 438 else
438 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 439 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
439 continue; 440 return;
440 } 441 }
441 442
442 if ( event->categories().contains("Holiday") || 443 if ( event->categories().contains("Holiday") ||
443 event->categories().contains(i18n("Holiday"))) { 444 event->categories().contains(i18n("Holiday"))) {
444 setHoliday( true ); 445 setHoliday( true );
445 if ( mDate.dayOfWeek() == 7 ) 446 if ( mDate.dayOfWeek() == 7 )
446 mItemList->setLineWidth( 3 ); 447 mItemList->setLineWidth( 3 );
447 } 448 }
@@ -460,26 +461,26 @@ void MonthViewCell::updateCell()
460 } else { 461 } else {
461 if (mDate == event->dtStart().date()) { 462 if (mDate == event->dtStart().date()) {
462 prefix ="->" ; 463 prefix ="->" ;
463 } else if (mDate == event->dtEnd().date()) { 464 } else if (mDate == event->dtEnd().date()) {
464 prefix ="<-" ; 465 prefix ="<-" ;
465 } 466 }
466 } 467 }
467 text = prefix + event->summary(); 468 text = prefix + event->summary();
468 tipText += text; 469 mToolTip += text;
469 } else { 470 } else {
470 if (event->doesFloat()) { 471 if (event->doesFloat()) {
471 text = event->summary(); 472 text = event->summary();
472 tipText += text; 473 mToolTip += text;
473 } 474 }
474 else { 475 else {
475 text = KGlobal::locale()->formatTime(event->dtStart().time()); 476 text = KGlobal::locale()->formatTime(event->dtStart().time());
476 text += " " + event->summary(); 477 text += " " + event->summary();
477 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 478 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
478 } 479 }
479 } 480 }
480 481
481 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 482 MonthViewItem *item = new MonthViewItem( event, mDate, text );
482 QPalette pal; 483 QPalette pal;
483 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 484 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
484 QStringList categories = event->categories(); 485 QStringList categories = event->categories();
485 QString cat = categories.first(); 486 QString cat = categories.first();
@@ -513,25 +514,21 @@ void MonthViewCell::updateCell()
513 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 514 if ( me->status() == Attendee::NeedsAction && me->RSVP())
514 item->setReply(true); 515 item->setReply(true);
515 else 516 else
516 item->setReply(false); 517 item->setReply(false);
517 } else 518 } else
518 item->setReply(false); 519 item->setReply(false);
519#endif 520#endif
520 mItemList->insertItem( item ); 521 mItemList->insertItem( item );
521 tipText += "\n"; 522 mToolTip += "\n";
522 523}
523 } 524void MonthViewCell::insertTodo(Todo *todo)
524 525{
525 // insert due todos 526 QString text;
526 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
527 Todo *todo;
528 for(todo = todos.first(); todo; todo = todos.next()) {
529 QString text;
530 if (todo->hasDueDate()) { 527 if (todo->hasDueDate()) {
531 if (!todo->doesFloat()) { 528 if (!todo->doesFloat()) {
532 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 529 text += KGlobal::locale()->formatTime(todo->dtDue().time());
533 text += " "; 530 text += " ";
534 } 531 }
535 } 532 }
536 text += i18n("To-Do: %1").arg(todo->summary()); 533 text += i18n("To-Do: %1").arg(todo->summary());
537 534
@@ -557,21 +554,23 @@ void MonthViewCell::updateCell()
557 } 554 }
558 } 555 }
559 556
560 } else { 557 } else {
561 pal = mStandardPalette ; 558 pal = mStandardPalette ;
562 } 559 }
563 item->setPalette( pal ); 560 item->setPalette( pal );
564 mItemList->insertItem( item ); 561 mItemList->insertItem( item );
565 tipText += text+"\n"; 562 mToolTip += text+"\n";
566 } 563}
564void MonthViewCell::finishUpdateCell()
565{
567#ifdef DESKTOP_VERSION 566#ifdef DESKTOP_VERSION
568 if (tipText != "") 567 if (mToolTip != "")
569 QToolTip::add(this,tipText,toolTipGroup(),""); 568 QToolTip::add(this,mToolTip,toolTipGroup(),"");
570#endif 569#endif
571 570
572 //setMyPalette(); 571 //setMyPalette();
573 setMyPalette(); 572 setMyPalette();
574 QString text; 573 QString text;
575 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 574 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
576 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 575 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
577 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 576 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
@@ -579,23 +578,42 @@ void MonthViewCell::updateCell()
579 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 578 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
580 } else { 579 } else {
581 mLabel->resize( mLabelSize ); 580 mLabel->resize( mLabelSize );
582 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 581 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
583 } 582 }
584 583
585 mLabel->setText( text ); 584 mLabel->setText( text );
586 resizeEvent( 0 ); 585 resizeEvent( 0 );
586}
587void MonthViewCell::updateCell()
588{
589 if ( !mMonthView->isUpdatePossible() )
590 return;
591 startUpdateCell();
592 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
593 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
594 Event *event;
595 for( event = events.first(); event; event = events.next() ) { // for event
596 insertEvent(event);
597 }
598 // insert due todos
599 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
600 Todo *todo;
601 for(todo = todos.first(); todo; todo = todos.next()) {
602 insertTodo( todo );
603 }
604 finishUpdateCell();
587 // if ( isVisible()) 605 // if ( isVisible())
588 //qApp->processEvents(); 606 //qApp->processEvents();
589} 607}
590 608
591void MonthViewCell::updateConfig() 609void MonthViewCell::updateConfig()
592{ 610{
593 611 qDebug("MonthViewCell::updateConfig() ");
594 setFont( KOPrefs::instance()->mMonthViewFont ); 612 setFont( KOPrefs::instance()->mMonthViewFont );
595 613
596 QFontMetrics fm( font() ); 614 QFontMetrics fm( font() );
597 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 615 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
598 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 616 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
599 mHolidayPalette = mStandardPalette; 617 mHolidayPalette = mStandardPalette;
600 mPrimaryPalette = mStandardPalette; 618 mPrimaryPalette = mStandardPalette;
601 mNonPrimaryPalette = mStandardPalette; 619 mNonPrimaryPalette = mStandardPalette;
@@ -953,26 +971,121 @@ void KOMonthView::changeEventDisplay(Event *, int)
953 updateView(); 971 updateView();
954} 972}
955 973
956void KOMonthView::updateView() 974void KOMonthView::updateView()
957{ 975{
958 976
959 if ( !updatePossible ) 977 if ( !updatePossible )
960 return; 978 return;
979 QTime ti;
980 ti.start();
981#if 1
982 int i;
983 for( i = 0; i < mCells.count(); ++i ) {
984 mCells[i]->startUpdateCell();
985 }
986
987 QPtrList<Event> events = calendar()->events();
988 Event *event;
989 QDateTime dt;
990 bool ok;
991 int timeSpan = mCells.size()-1;
992 QDate endDate = mStartDate.addDays( timeSpan );
993 for( event = events.first(); event; event = events.next() ) { // for event
994 if ( event->doesRecur() ) {
995 bool last;
996 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
997 QDateTime incidenceEnd;
998 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
999 bool invalid = false;
1000 while( true ) {
1001 if ( incidenceStart.isValid() ) {
1002 incidenceEnd = incidenceStart.addDays( eventlen );
1003 int st = incidenceStart.date().daysTo( endDate );
1004 if ( st >= 0 ) { // start before timeend
1005 int end = mStartDate.daysTo( incidenceEnd.date() );
1006 if ( end >= 0 ) { // end after timestart --- got one!
1007 //normalize
1008 st = timeSpan - st;
1009 if ( st < 0 ) st = 0;
1010 if ( end > timeSpan ) end = timeSpan;
1011 int iii;
1012 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1013 for ( iii = st;iii<= end;++iii)
1014 mCells[iii]->insertEvent( event );
1015 }
1016 }
1017 } else {
1018 if ( invalid )
1019 break;
1020 invalid = true;
1021 //qDebug("invalid %s", event->summary().latin1());
1022 incidenceStart = QDateTime( mStartDate );
1023 }
1024 if ( last )
1025 break;
1026 bool ok;
1027 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1028 if ( ! ok )
1029 break;
1030 if ( incidenceStart.date() > endDate )
1031 break;
1032 }
1033 } else { // no recur
1034 int st = event->dtStart().date().daysTo( endDate );
1035 if ( st >= 0 ) { // start before timeend
1036 int end = mStartDate.daysTo( event->dtEnd().date() );
1037 if ( end >= 0 ) { // end after timestart --- got one!
1038 //normalize
1039 st = timeSpan - st;
1040 if ( st < 0 ) st = 0;
1041 if ( end > timeSpan ) end = timeSpan;
1042 int iii;
1043 for ( iii = st;iii<= end;++iii)
1044 mCells[iii]->insertEvent( event );
1045 }
1046 }
1047 }
1048 }
1049 // insert due todos
1050 QPtrList<Todo> todos = calendar()->todos( );
1051 Todo *todo;
1052 for(todo = todos.first(); todo; todo = todos.next()) {
1053 //insertTodo( todo );
1054 if ( todo->hasDueDate() ) {
1055 int day = mStartDate.daysTo( todo->dtDue().date() );
1056 if ( day >= 0 && day < mCells.size() ) {
1057 mCells[day]->insertTodo( todo );
1058 }
1059 }
1060 }
1061
1062 for( i = 0; i < mCells.count(); ++i ) {
1063 mCells[i]->finishUpdateCell();
1064 }
1065 processSelectionChange();
1066 mCells[0]->setFocus();
1067
1068
1069#else
1070 // old code
961 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1071 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
962 int i; 1072 int i;
963 for( i = 0; i < mCells.count(); ++i ) { 1073 for( i = 0; i < mCells.count(); ++i ) {
964 mCells[i]->updateCell(); 1074 mCells[i]->updateCell();
965 } 1075 }
966 1076
967 //qDebug("KOMonthView::updateView() "); 1077 //qDebug("KOMonthView::updateView() ");
968 processSelectionChange(); 1078 processSelectionChange();
969 // qDebug("---------------------------------------------------------------------+ "); 1079 // qDebug("---------------------------------------------------------------------+ ");
970 mCells[0]->setFocus(); 1080 mCells[0]->setFocus();
1081#endif
1082
1083 qDebug("update time %d ", ti.elapsed());
971} 1084}
972 1085
973void KOMonthView::resizeEvent(QResizeEvent * e) 1086void KOMonthView::resizeEvent(QResizeEvent * e)
974{ 1087{
975 computeLayout(); 1088 computeLayout();
976 mCells[0]->setFocus(); 1089 mCells[0]->setFocus();
977} 1090}
978void KOMonthView::computeLayout() 1091void KOMonthView::computeLayout()
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 50903b3..b84065e 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -132,16 +132,20 @@ class MonthViewCell : public QWidget
132 132
133 void setPrimary( bool ); 133 void setPrimary( bool );
134 bool isPrimary() const; 134 bool isPrimary() const;
135 135
136 void setHoliday( bool ); 136 void setHoliday( bool );
137 void setHoliday( const QString & ); 137 void setHoliday( const QString & );
138 138
139 void updateCell(); 139 void updateCell();
140 void startUpdateCell();
141 void finishUpdateCell();
142 void insertEvent(Event *);
143 void insertTodo(Todo *);
140 144
141 void updateConfig(); 145 void updateConfig();
142 146
143 void enableScrollBars( bool ); 147 void enableScrollBars( bool );
144 148
145 Incidence *selectedIncidence(); 149 Incidence *selectedIncidence();
146 QDate selectedIncidenceDate(); 150 QDate selectedIncidenceDate();
147 151
@@ -153,16 +157,17 @@ class MonthViewCell : public QWidget
153 static QToolTipGroup *toolTipGroup(); 157 static QToolTipGroup *toolTipGroup();
154#endif 158#endif
155 signals: 159 signals:
156 void defaultAction( Incidence * ); 160 void defaultAction( Incidence * );
157 void newEventSignal( QDateTime ); 161 void newEventSignal( QDateTime );
158 void showDaySignal( QDate ); 162 void showDaySignal( QDate );
159 163
160 protected: 164 protected:
165 QString mToolTip;
161 void resizeEvent( QResizeEvent * ); 166 void resizeEvent( QResizeEvent * );
162 167
163 protected slots: 168 protected slots:
164 void defaultAction( QListBoxItem * ); 169 void defaultAction( QListBoxItem * );
165 void contextMenu( QListBoxItem * ); 170 void contextMenu( QListBoxItem * );
166 void selection( QListBoxItem * ); 171 void selection( QListBoxItem * );
167 void cellClicked( QListBoxItem * ); 172 void cellClicked( QListBoxItem * );
168 void newEvent(); 173 void newEvent();