summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
Unidiff
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp89
1 files changed, 56 insertions, 33 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9344567..842f6eb 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -79,9 +79,12 @@ KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
79#ifndef DESKTOP_VERSION 79#ifndef DESKTOP_VERSION
80 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 80 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
81#endif 81#endif
82 new KNOWhatsThis(this); 82 mWT = new KNOWhatsThis(this);
83}
84KNoScrollListBox::~KNoScrollListBox()
85{
86 delete mWT;
83} 87}
84
85QString KNoScrollListBox::getWhatsThisText(QPoint p) 88QString KNoScrollListBox::getWhatsThisText(QPoint p)
86{ 89{
87 QListBoxItem* item = itemAt ( p ); 90 QListBoxItem* item = itemAt ( p );
@@ -308,20 +311,9 @@ QToolTipGroup *MonthViewCell::toolTipGroup()
308void MonthViewCell::setDate( const QDate &date ) 311void MonthViewCell::setDate( const QDate &date )
309{ 312{
310// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 313// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
311
312 mDate = date; 314 mDate = date;
313 315
314 QString text; 316
315 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
316 if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
317 text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " ";
318 mLabel->resize( mLabelBigSize );
319 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
320 } else {
321 mLabel->resize( mLabelSize );
322 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
323 }
324 mLabel->setText( text );
325 317
326 //resizeEvent( 0 ); 318 //resizeEvent( 0 );
327} 319}
@@ -392,7 +384,11 @@ void MonthViewCell::keyPressEvent ( QKeyEvent * e )
392} 384}
393void MonthViewCell::updateCell() 385void MonthViewCell::updateCell()
394{ 386{
395 387 if ( !mMonthView->isUpdatePossible() )
388 return;
389 if ( !isVisible() ){
390 return;
391 }
396 setPrimary( mDate.month()%2 ); 392 setPrimary( mDate.month()%2 );
397 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 393 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
398 if ( mDate == QDate::currentDate() ) { 394 if ( mDate == QDate::currentDate() ) {
@@ -401,6 +397,9 @@ void MonthViewCell::updateCell()
401 mItemList->setLineWidth( 1 ); 397 mItemList->setLineWidth( 1 );
402 } 398 }
403 mItemList->clear(); 399 mItemList->clear();
400
401
402
404#ifdef DESKTOP_VERSION 403#ifdef DESKTOP_VERSION
405 QToolTip::remove(this); 404 QToolTip::remove(this);
406#endif 405#endif
@@ -415,7 +414,16 @@ void MonthViewCell::updateCell()
415 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 414 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
416 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 415 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
417 Event *event; 416 Event *event;
418 for( event = events.first(); event; event = events.next() ) { 417 for( event = events.first(); event; event = events.next() ) { // for event
418
419 if ( !(event->doesRecur() == Recurrence::rNone) ) {
420 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
421 continue;
422 else
423 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
424 continue;
425 }
426
419 if ( event->categories().contains("Holiday") || 427 if ( event->categories().contains("Holiday") ||
420 event->categories().contains(i18n("Holiday"))) { 428 event->categories().contains(i18n("Holiday"))) {
421 setHoliday( true ); 429 setHoliday( true );
@@ -483,6 +491,7 @@ void MonthViewCell::updateCell()
483 item->setRecur( event->recurrence()->doesRecur() ); 491 item->setRecur( event->recurrence()->doesRecur() );
484 item->setAlarm( event->isAlarmEnabled() ); 492 item->setAlarm( event->isAlarmEnabled() );
485 item->setMoreInfo( event->description().length() > 0 ); 493 item->setMoreInfo( event->description().length() > 0 );
494#ifdef DESKTOP_VERSION
486 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 495 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
487 KOPrefs::instance()->email()); 496 KOPrefs::instance()->email());
488 if ( me != 0 ) { 497 if ( me != 0 ) {
@@ -492,20 +501,10 @@ void MonthViewCell::updateCell()
492 item->setReply(false); 501 item->setReply(false);
493 } else 502 } else
494 item->setReply(false); 503 item->setReply(false);
495 bool insert = true; 504#endif
496 if ( !(event->doesRecur() == Recurrence::rNone) ) { 505 mItemList->insertItem( item );
497 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 506 tipText += "\n";
498 insert = false; 507
499 else
500 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
501 insert = false;
502
503 }
504 if ( insert ) {
505 mItemList->insertItem( item );
506 tipText += "\n";
507 } else
508 tipText = "";
509 } 508 }
510 509
511 // insert due todos 510 // insert due todos
@@ -557,9 +556,20 @@ void MonthViewCell::updateCell()
557 556
558 //setMyPalette(); 557 //setMyPalette();
559 setMyPalette(); 558 setMyPalette();
559 QString text;
560 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
561 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
562 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
563 mLabel->resize( mLabelBigSize );
564 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
565 } else {
566 mLabel->resize( mLabelSize );
567 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
568 }
569 mLabel->setText( text );
560 resizeEvent( 0 ); 570 resizeEvent( 0 );
561 // if ( isVisible()) 571 // if ( isVisible())
562 // qApp->processEvents(); 572 qApp->processEvents();
563} 573}
564 574
565void MonthViewCell::updateConfig() 575void MonthViewCell::updateConfig()
@@ -638,6 +648,11 @@ void MonthViewCell::select()
638 648
639void MonthViewCell::resizeEvent ( QResizeEvent * ) 649void MonthViewCell::resizeEvent ( QResizeEvent * )
640{ 650{
651 if ( !mMonthView->isUpdatePossible() )
652 return;
653 if ( !isVisible() ){
654 return;
655 }
641 int size = height() - mLabel->height(); 656 int size = height() - mLabel->height();
642 if ( size > 0 ) 657 if ( size > 0 )
643 mItemList->verticalScrollBar()->setMaximumHeight( size ); 658 mItemList->verticalScrollBar()->setMaximumHeight( size );
@@ -713,6 +728,7 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
713 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 728 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
714 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 729 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
715{ 730{
731 updatePossible = false;
716 mCells.setAutoDelete( true ); 732 mCells.setAutoDelete( true );
717 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 733 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
718 // mDayLayout = new QGridLayout( this ); 734 // mDayLayout = new QGridLayout( this );
@@ -920,7 +936,10 @@ void KOMonthView::changeEventDisplay(Event *, int)
920 936
921void KOMonthView::updateView() 937void KOMonthView::updateView()
922{ 938{
923 939 static int iii = 0;
940 ++iii;
941 if ( !updatePossible )
942 return;
924 uint i; 943 uint i;
925 for( i = 0; i < mCells.count(); ++i ) { 944 for( i = 0; i < mCells.count(); ++i ) {
926 mCells[i]->updateCell(); 945 mCells[i]->updateCell();
@@ -954,7 +973,7 @@ void KOMonthView::computeLayout()
954 973
955 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 974 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
956 return; 975 return;
957 976 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
958 QFontMetrics fm ( mWeekLabels[0]->font() ); 977 QFontMetrics fm ( mWeekLabels[0]->font() );
959 int weeklabelwid = fm.width( "888" ); 978 int weeklabelwid = fm.width( "888" );
960 wid -= weeklabelwid; 979 wid -= weeklabelwid;
@@ -1032,6 +1051,10 @@ void KOMonthView::computeLayout()
1032 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1051 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1033 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1052 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1034 updateDayLabels(); 1053 updateDayLabels();
1054 bool forceUpdate = !updatePossible;
1055 updatePossible = true;
1056 if ( forceUpdate )
1057 updateView();
1035} 1058}
1036 1059
1037void KOMonthView::showContextMenu( Incidence *incidence ) 1060void KOMonthView::showContextMenu( Incidence *incidence )