summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-25 05:47:45 (UTC)
committer zautrix <zautrix>2005-03-25 05:47:45 (UTC)
commite3b935f4e24086117213662e670ab26cb2ad8822 (patch) (unidiff)
treed20ad8e8dd09cc3efb9f9e57568d4d009048d518 /korganizer
parent658354b7112aff72f0fadd924c82b977d803bc27 (diff)
downloadkdepimpi-e3b935f4e24086117213662e670ab26cb2ad8822.zip
kdepimpi-e3b935f4e24086117213662e670ab26cb2ad8822.tar.gz
kdepimpi-e3b935f4e24086117213662e670ab26cb2ad8822.tar.bz2
mal sehn...
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kdatenavigator.cpp3
-rw-r--r--korganizer/komonthview.cpp226
-rw-r--r--korganizer/komonthview.h14
-rw-r--r--korganizer/koviewmanager.cpp3
4 files changed, 175 insertions, 71 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 6438c9a..0cb767f 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -98,49 +98,50 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
98 } 98 }
99 weeknos[i]->installEventFilter(this); 99 weeknos[i]->installEventFilter(this);
100 100
101 topLayout->addWidget(weeknos[i],i+2,0); 101 topLayout->addWidget(weeknos[i],i+2,0);
102 } 102 }
103 103
104 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix"); 104 daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
105 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken); 105 daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
106 daymatrix->setLineWidth(1); 106 daymatrix->setLineWidth(1);
107 107
108 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ), 108 connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
109 SIGNAL( datesSelected( const KCal::DateList & ) ) ); 109 SIGNAL( datesSelected( const KCal::DateList & ) ) );
110 110
111 connect( daymatrix, SIGNAL( eventDropped( Event * ) ), 111 connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
112 SIGNAL( eventDropped( Event * ) ) ); 112 SIGNAL( eventDropped( Event * ) ) );
113 113
114 topLayout->addMultiCellWidget(daymatrix,2,7,1,7); 114 topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
115 115
116 // read settings from configuration file. 116 // read settings from configuration file.
117 updateConfig(); 117 updateConfig();
118 enableRollover(FollowMonth); 118 enableRollover(FollowMonth);
119 mySizeHint = sizeHintTwoButtons(); 119 mySizeHint = sizeHintTwoButtons();
120 myFullSizeHint = sizeHintTwoButtons( 4 ); 120 myFullSizeHint = sizeHintTwoButtons( 4 );
121 mFontChanged = false; 121 mFontChanged = false;
122 resize ( 0,0 ); 122 resize ( 3,3 );
123
123} 124}
124void KDateNavigator::changeFont ( QFont fo ) 125void KDateNavigator::changeFont ( QFont fo )
125{ 126{
126 setFont( fo ); 127 setFont( fo );
127 mNavigatorBar->resetFont( fo ); 128 mNavigatorBar->resetFont( fo );
128} 129}
129QFont KDateNavigator::yourFontHint( QSize si , bool *b) 130QFont KDateNavigator::yourFontHint( QSize si , bool *b)
130{ 131{
131 QFont fo = KOPrefs::instance()->mDateNavigatorFont; 132 QFont fo = KOPrefs::instance()->mDateNavigatorFont;
132 *b = false; 133 *b = false;
133 int fontPoint = fo.pointSize(); 134 int fontPoint = fo.pointSize();
134 while ( fontPoint > 5 ) { 135 while ( fontPoint > 5 ) {
135 --fontPoint; 136 --fontPoint;
136 fo.setPointSize( fontPoint ); 137 fo.setPointSize( fontPoint );
137 setFont( fo ); 138 setFont( fo );
138 mFontChanged = true; 139 mFontChanged = true;
139 mNavigatorBar->resetFont( fo ); 140 mNavigatorBar->resetFont( fo );
140 QSize sh = sizeHintTwoButtons( 2 ); 141 QSize sh = sizeHintTwoButtons( 2 );
141 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() ); 142 //qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
142 if ( si.width() > sh.width() && si.height() > sh.height()) { 143 if ( si.width() > sh.width() && si.height() > sh.height()) {
143 if ( si.width() / sh.width() == 1 ) { 144 if ( si.width() / sh.width() == 1 ) {
144 if ( si.width() < sizeHintTwoButtons( 4 ).width()) 145 if ( si.width() < sizeHintTwoButtons( 4 ).width())
145 continue; 146 continue;
146 } 147 }
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 050bfb9..38cfda7 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -173,60 +173,79 @@ void KNoScrollListBox::oneDown()
173} 173}
174void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 174void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
175{ 175{
176 switch(e->key()) { 176 switch(e->key()) {
177 case Key_Shift: 177 case Key_Shift:
178 emit shiftUp(); 178 emit shiftUp();
179 break; 179 break;
180 default: 180 default:
181 break; 181 break;
182 } 182 }
183} 183}
184 184
185void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 185void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
186{ 186{
187 QListBox::mousePressEvent(e); 187 QListBox::mousePressEvent(e);
188 188
189 if(e->button() == RightButton) { 189 if(e->button() == RightButton) {
190 emit rightClick(); 190 emit rightClick();
191 } 191 }
192} 192}
193 193
194MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 194MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
195 : QListBoxItem() 195 : QListBoxItem()
196{ 196{
197 mblockRepaint = true;
197 setText( s ); 198 setText( s );
198 mMultiday = 0; 199 mMultiday = 0;
199 mIncidence = incidence; 200 mIncidence = incidence;
200 mDate = qd; 201 mDate = qd;
201 mRecur = false; 202 mRecur = false;
202 mAlarm = false; 203 mAlarm = false;
203 mReply = false; 204 mReply = false;
204 mInfo = false; 205 mInfo = false;
206 //qDebug("NEWWWWWWWWWWWWW ");
207}
208void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
209{
210 setText( s );
211 mMultiday = 0;
212 mIncidence = incidence;
213 mDate = qd;
214 mRecur = false;
215 mAlarm = false;
216 mReply = false;
217 mInfo = false;
218 //qDebug("recucleeeeeeeeeeeeeeeee ");
205} 219}
206 220
207void MonthViewItem::paint(QPainter *p) 221void MonthViewItem::paint(QPainter *p)
208{ 222{
223 if ( mblockRepaint ) {
224 //qDebug("block ");
225 return;
226 }
227 //qDebug("NON block ");
209#if QT_VERSION >= 0x030000 228#if QT_VERSION >= 0x030000
210 bool sel = isSelected(); 229 bool sel = isSelected();
211#else 230#else
212 bool sel = selected(); 231 bool sel = selected();
213#endif 232#endif
214 233
215 234
216 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 235 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
217 { 236 {
218 p->setBackgroundColor( palette().color( QPalette::Normal, \ 237 p->setBackgroundColor( palette().color( QPalette::Normal, \
219 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 238 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
220 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 239 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
221 } 240 }
222 int x = 1; 241 int x = 1;
223 //int y = 3;//(height() - mRecurPixmap.height()) /2; 242 //int y = 3;//(height() - mRecurPixmap.height()) /2;
224 int size = PIXMAP_SIZE; 243 int size = PIXMAP_SIZE;
225 if ( QApplication::desktop()->width() < 300 ) 244 if ( QApplication::desktop()->width() < 300 )
226 size = 3; 245 size = 3;
227 int heihei = height( listBox () ); 246 int heihei = height( listBox () );
228 int y = (heihei - size -1 ) /2; 247 int y = (heihei - size -1 ) /2;
229 248
230 if ( KOPrefs::instance()->mMonthShowIcons ) { 249 if ( KOPrefs::instance()->mMonthShowIcons ) {
231 if ( mInfo ) { 250 if ( mInfo ) {
232 p->fillRect ( x, y,size,size, Qt::darkGreen ); 251 p->fillRect ( x, y,size,size, Qt::darkGreen );
@@ -332,365 +351,428 @@ int MonthViewItem::width(const QListBox *lb) const
332 } 351 }
333 if( mRecur ) { 352 if( mRecur ) {
334 x += size+1; 353 x += size+1;
335 } 354 }
336 if( mAlarm ) { 355 if( mAlarm ) {
337 x += size+1; 356 x += size+1;
338 } 357 }
339 if( mReply ) { 358 if( mReply ) {
340 x += size+1; 359 x += size+1;
341 } 360 }
342 } 361 }
343 if( mMultiday ) { 362 if( mMultiday ) {
344 x += size+1+2+size/2; 363 x += size+1+2+size/2;
345 } 364 }
346 return( x + lb->fontMetrics().width( text() ) + 1 ); 365 return( x + lb->fontMetrics().width( text() ) + 1 );
347 } 366 }
348 if ( ! lb ) 367 if ( ! lb )
349 return 10; 368 return 10;
350 //qDebug("ret wid %d ", lb->width()); 369 //qDebug("ret wid %d ", lb->width());
351 return lb->width(); 370 return lb->width();
352} 371}
353 372
354 373
355MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 374MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
356 : QWidget( par ), 375 : KNoScrollListBox( par ),
357 mMonthView( parent ) 376 mMonthView( parent )
358{ 377{
359 378
379 mCurrentAvailItem = 0;
360 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 380 //QVBoxLayout *topLayout = new QVBoxLayout( this );
361 381 currentPalette = 0;
362 // mLabel = new QLabel( this );QPushButton 382 // mLabel = new QLabel( this );QPushButton
363 mLabel = new QPushButton( this ); 383 mLabel = new QPushButton( this );
364 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 384 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
365 //mLabel->setLineWidth( 1 ); 385 //mLabel->setLineWidth( 1 );
366 //mLabel->setAlignment( AlignCenter ); 386 //mLabel->setAlignment( AlignCenter );
367 mLabel->setFlat( true ); 387 mLabel->setFlat( true );
368 mLabel->setFocusPolicy(NoFocus); 388 mLabel->setFocusPolicy(NoFocus);
369 mItemList = new KNoScrollListBox( this ); 389 //mItemList = new KNoScrollListBox( this );
370 mItemList->setMinimumSize( 10, 10 ); 390 setMinimumSize( 10, 10 );
371 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 391 setFrameStyle( QFrame::Panel | QFrame::Plain );
372 mItemList->setLineWidth( 1 ); 392 setLineWidth( 1 );
373 //topLayout->addWidget( mItemList ); 393 //topLayout->addWidget( mItemList );
374 mLabel->raise(); 394 mLabel->raise();
375 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 395 // QColor( 0,0,255 ) QColor( 160,1600,255 )
376 mStandardPalette = palette(); 396 mStandardPalette = palette();
377 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 397 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
378 398
379 enableScrollBars( false ); 399 enableScrollBars( false );
380 updateConfig(); 400 updateConfig();
381 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 401 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
382 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 402 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
383 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 403 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
384 SLOT( defaultAction( QListBoxItem * ) ) ); 404 SLOT( defaultAction( QListBoxItem * ) ) );
385 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 405 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
386 const QPoint &) ), 406 const QPoint &) ),
387 SLOT( contextMenu( QListBoxItem * ) ) ); 407 SLOT( contextMenu( QListBoxItem * ) ) );
388 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 408 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
389 SLOT( selection( QListBoxItem * ) ) ); 409 SLOT( selection( QListBoxItem * ) ) );
390 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 410 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
391 SLOT( cellClicked( QListBoxItem * ) ) ); 411 SLOT( cellClicked( QListBoxItem * ) ) );
392 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 412 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
393 SLOT( selection( QListBoxItem * ) ) ); 413 SLOT( selection( QListBoxItem * ) ) );
394} 414}
395#ifdef DESKTOP_VERSION 415#ifdef DESKTOP_VERSION
396QToolTipGroup *MonthViewCell::toolTipGroup() 416QToolTipGroup *MonthViewCell::toolTipGroup()
397{ 417{
398 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 418 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
399 return mToolTipGroup; 419 return mToolTipGroup;
400} 420}
401#endif 421#endif
402 422
403void MonthViewCell::setDate( const QDate &date ) 423void MonthViewCell::setDate( const QDate &date )
404{ 424{
405 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 425 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
406 mDate = date; 426 mDate = date;
407 427
408 428
409 429
410 //resizeEvent( 0 ); 430 //resizeEvent( 0 );
411} 431}
412 432
413QDate MonthViewCell::date() const 433QDate MonthViewCell::date() const
414{ 434{
415 return mDate; 435 return mDate;
416} 436}
417 437
418void MonthViewCell::setPrimary( bool primary ) 438void MonthViewCell::setPrimary( bool primary )
419{ 439{
420 mPrimary = primary; 440 mPrimary = primary;
421 //setMyPalette(); 441 //setMyPalette();
422} 442}
423void MonthViewCell::setMyPalette() 443void MonthViewCell::setMyPalette()
424{ 444{
425 445
426 if ( mHoliday) { 446 if ( mHoliday) {
447 if ( currentPalette == 1 ) return;
427 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 448 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
428 mItemList->setPalette( mHolidayPalette ); 449 setPalette( mHolidayPalette );
450 //mLabel->setPalette( mHolidayPalette );
451 currentPalette = 1;
452
429 } else { 453 } else {
430 if ( mPrimary ) { 454 if ( mPrimary ) {
455 if ( currentPalette == 2 ) return;
431 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 456 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
432 mItemList->setPalette( mPrimaryPalette ); 457 //mLabel->setPalette( mPrimaryPalette );
458 setPalette( mPrimaryPalette );
459 currentPalette = 2;
460
433 } else { 461 } else {
434 mItemList->setPalette( mNonPrimaryPalette ); 462 if ( currentPalette == 3 ) return;
435 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 463 setPalette( mNonPrimaryPalette );
464 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
465 //mLabel->setPalette( mNonPrimaryPalette );;
466 currentPalette = 3;
436 } 467 }
437 } 468 }
438 //QPalette pal = palette(); 469 //QPalette pal = palette();
439 470
440 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 471 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
441} 472}
442QPalette MonthViewCell::getPalette () 473QPalette MonthViewCell::getPalette ()
443{ 474{
444 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 475 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
445 return mStandardPalette; 476 return mStandardPalette;
446 if ( mHoliday) { 477 if ( mHoliday) {
447 return mHolidayPalette ; 478 return mHolidayPalette ;
448 } else { 479 } else {
449 if ( mPrimary ) { 480 if ( mPrimary ) {
450 return mPrimaryPalette ; 481 return mPrimaryPalette ;
451 } 482 }
452 } 483 }
453 return mNonPrimaryPalette; 484 return mNonPrimaryPalette;
454} 485}
455bool MonthViewCell::isPrimary() const 486bool MonthViewCell::isPrimary() const
456{ 487{
457 return mPrimary; 488 return mPrimary;
458} 489}
459 490
460void MonthViewCell::setHoliday( bool holiday ) 491void MonthViewCell::setHoliday( bool holiday )
461{ 492{
462 mHoliday = holiday; 493 mHoliday = holiday;
463 //setMyPalette(); 494 //setMyPalette();
464} 495}
465 496
466void MonthViewCell::setHoliday( const QString &holiday ) 497void MonthViewCell::setHoliday( const QString &holiday )
467{ 498{
468 mHolidayString = holiday; 499 mHolidayString = holiday;
469 500
470 if ( !holiday.isEmpty() ) { 501 if ( !holiday.isEmpty() ) {
471 setHoliday( true ); 502 setHoliday( true );
472 } 503 }
473} 504}
474void MonthViewCell::keyPressEvent ( QKeyEvent * e )
475{
476
477 e->ignore();
478
479}
480 505
481void MonthViewCell::startUpdateCell() 506void MonthViewCell::startUpdateCell()
482{ 507{
483 508
484 mItemList->setFocusPolicy(NoFocus); 509 setFocusPolicy(NoFocus);
485 if ( !mMonthView->isUpdatePossible() ) 510 if ( !mMonthView->isUpdatePossible() )
486 return; 511 return;
487 512 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
513 while ( mitem ) {
514 mitem->setBlockRepaint( true );
515 mitem = (MonthViewItem *)mitem->next();
516 }
488 /* 517 /*
489 if ( !isVisible() ){ 518 if ( !isVisible() ){
490 return; 519 return;
491 } 520 }
492 */ 521 */
493 // qDebug("MonthViewCell::updateCell() "); 522 // qDebug("MonthViewCell::updateCell() ");
494 setPrimary( mDate.month()%2 ); 523 setPrimary( mDate.month()%2 );
495 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 524 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
496 if ( mDate == QDate::currentDate() ) { 525 if ( mDate == QDate::currentDate() ) {
497 mItemList->setLineWidth( 3 ); 526 setLineWidth( 3 );
498 } else { 527 } else {
499 mItemList->setLineWidth( 1 ); 528 setLineWidth( 1 );
500 } 529 }
501 mItemList->clear(); 530 mCurrentAvailItem = (MonthViewItem*) firstItem ();
531 //clear();
502 532
503#ifdef DESKTOP_VERSION 533#ifdef DESKTOP_VERSION
504 QToolTip::remove(this); 534 QToolTip::remove(this);
505#endif 535#endif
506 mToolTip.clear(); 536 mToolTip.clear();
507 //qApp->processEvents(); 537 //qApp->processEvents();
538#if 0
508 if ( !mHolidayString.isEmpty() ) { 539 if ( !mHolidayString.isEmpty() ) {
509 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 540 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
510 item->setPalette( mHolidayPalette ); 541 item->setPalette( mHolidayPalette );
511 mItemList->insertItem( item ); 542 insertItem( item );
512 mToolTip.append ( mHolidayString ); 543 mToolTip.append ( mHolidayString );
513 } 544 }
545#endif
514} 546}
515 547
516void MonthViewCell::insertEvent(Event *event) 548void MonthViewCell::insertEvent(Event *event)
517{ 549{
518 QString mToolTipText; 550 QString mToolTipText;
519 mItemList->setFocusPolicy(WheelFocus); 551 bool insertNewItem = false;
552 setFocusPolicy(WheelFocus);
520 if ( !(event->doesRecur() == Recurrence::rNone) ) { 553 if ( !(event->doesRecur() == Recurrence::rNone) ) {
521 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 554 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
522 return; 555 return;
523 else 556 else
524 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 557 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
525 return; 558 return;
526 } 559 }
527 560
528 if ( event->isHoliday()) { 561 if ( event->isHoliday()) {
529 setHoliday( true ); 562 setHoliday( true );
530 if ( mDate.dayOfWeek() == 7 ) 563 if ( mDate.dayOfWeek() == 7 )
531 mItemList->setLineWidth( 3 ); 564 setLineWidth( 3 );
532 } 565 }
533 QString text; 566 QString text;
534 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 567 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
535 if (event->isMultiDay()) { 568 if (event->isMultiDay()) {
536 QString prefix = "<->";multiday = 2; 569 QString prefix = "<->";multiday = 2;
537 QString time; 570 QString time;
538 if ( event->doesRecur() ) { 571 if ( event->doesRecur() ) {
539 if ( event->recursOn( mDate) ) { 572 if ( event->recursOn( mDate) ) {
540 prefix ="->" ;multiday = 1; 573 prefix ="->" ;multiday = 1;
541 } 574 }
542 else { 575 else {
543 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 576 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
544 if ( event->recursOn( mDate.addDays( -days)) ) { 577 if ( event->recursOn( mDate.addDays( -days)) ) {
545 prefix ="<-" ;multiday = 3; 578 prefix ="<-" ;multiday = 3;
546 } 579 }
547 } 580 }
548 581
549 } else { 582 } else {
550 if (mDate == event->dtStart().date()) { 583 if (mDate == event->dtStart().date()) {
551 prefix ="->" ;multiday = 1; 584 prefix ="->" ;multiday = 1;
552 } else if (mDate == event->dtEnd().date()) { 585 } else if (mDate == event->dtEnd().date()) {
553 prefix ="<-" ;multiday = 3; 586 prefix ="<-" ;multiday = 3;
554 } 587 }
555 } 588 }
556 if ( !event->doesFloat() ) { 589 if ( !event->doesFloat() ) {
557 if ( mDate == event->dtStart().date () ) 590 if ( mDate == event->dtStart().date () )
558 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 591 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
559 else if ( mDate == event->dtEnd().date () ) 592 else if ( mDate == event->dtEnd().date () )
560 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 593 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
561 594
562 } 595 }
563 text = time + event->summary(); 596 text = time + event->summary();
564 mToolTipText += prefix + text; 597 mToolTipText += prefix + text;
565 } else { 598 } else {
566 if (event->doesFloat()) { 599 if (event->doesFloat()) {
567 text = event->summary(); 600 text = event->summary();
568 mToolTipText += text; 601 mToolTipText += text;
569 } 602 }
570 else { 603 else {
571 text = KGlobal::locale()->formatTime(event->dtStart().time()); 604 text = KGlobal::locale()->formatTime(event->dtStart().time());
572 text += " " + event->summary(); 605 text += " " + event->summary();
573 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 606 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
574 } 607 }
575 } 608 }
576 609 MonthViewItem *item ;
577 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 610 if ( mCurrentAvailItem ) {
611 item = mCurrentAvailItem;
612 mCurrentAvailItem = (MonthViewItem*) item->next();
613 item->recycle( event, mDate, text );
614 } else {
615 if ( mAvailItemList.count() ) {
616 item = mAvailItemList.first();
617 mAvailItemList.remove( item );
618 item->recycle( event, mDate, text );
619 insertNewItem = true;
620 } else {
621 insertNewItem = true;
622 item = new MonthViewItem( event, mDate, text );
623 }
624 }
578 QPalette pal; 625 QPalette pal;
579 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 626 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
580 QStringList categories = event->categories(); 627 QStringList categories = event->categories();
581 QString cat = categories.first(); 628 QString cat = categories.first();
582 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 629 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
583 pal = getPalette(); 630 pal = getPalette();
584 if (cat.isEmpty()) { 631 if (cat.isEmpty()) {
585 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 632 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
586 } else { 633 } else {
587 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 634 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
588 } 635 }
589 636
590 } else { 637 } else {
591 if (cat.isEmpty()) { 638 if (cat.isEmpty()) {
592 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 639 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
593 } else { 640 } else {
594 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 641 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
595 } 642 }
596 } 643 }
597 644
598 } else { 645 } else {
599 pal = mStandardPalette ; 646 pal = mStandardPalette ;
600 } 647 }
601 item->setPalette( pal ); 648 item->setPalette( pal );
602 item->setRecur( event->recurrence()->doesRecur() ); 649 item->setRecur( event->recurrence()->doesRecur() );
603 item->setAlarm( event->isAlarmEnabled() && multiday < 2 ); 650 item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
604 item->setMoreInfo( event->description().length() > 0 ); 651 item->setMoreInfo( event->description().length() > 0 );
605#ifdef DESKTOP_VERSION 652#ifdef DESKTOP_VERSION
606 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 653 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
607 KOPrefs::instance()->email()); 654 KOPrefs::instance()->email());
608 if ( me != 0 ) { 655 if ( me != 0 ) {
609 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 656 if ( me->status() == Attendee::NeedsAction && me->RSVP())
610 item->setReply(true && multiday < 2); 657 item->setReply(true && multiday < 2);
611 else 658 else
612 item->setReply(false); 659 item->setReply(false);
613 } else 660 } else
614 item->setReply(false); 661 item->setReply(false);
615#endif 662#endif
616 item->setMultiDay( multiday ); 663 item->setMultiDay( multiday );
617 mItemList->insertItem( item ); 664 if ( insertNewItem)
665 insertItem( item );
618 mToolTip.append( mToolTipText ); 666 mToolTip.append( mToolTipText );
619} 667}
620void MonthViewCell::insertTodo(Todo *todo) 668void MonthViewCell::insertTodo(Todo *todo)
621{ 669{
622 mItemList->setFocusPolicy(WheelFocus); 670 bool insertNewItem = false;
671 setFocusPolicy(WheelFocus);
623 QString text; 672 QString text;
624 if (todo->hasDueDate()) { 673 if (todo->hasDueDate()) {
625 if (!todo->doesFloat()) { 674 if (!todo->doesFloat()) {
626 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 675 text += KGlobal::locale()->formatTime(todo->dtDue().time());
627 text += " "; 676 text += " ";
628 } 677 }
629 } 678 }
630 text += todo->summary(); 679 text += todo->summary();
631 680 MonthViewItem *item ;
632 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 681 if ( mCurrentAvailItem ) {
682 item = mCurrentAvailItem;
683 mCurrentAvailItem = (MonthViewItem*) item->next();
684 item->recycle( todo, mDate, text );
685 } else {
686 if ( mAvailItemList.count() ) {
687 item = mAvailItemList.first();
688 mAvailItemList.remove( item );
689 item->recycle( todo, mDate, text );
690 insertNewItem = true;
691 } else {
692 insertNewItem = true;
693 item = new MonthViewItem( todo, mDate, text );
694 }
695 }
696 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
633 //item->setPalette( mStandardPalette ); 697 //item->setPalette( mStandardPalette );
634 QPalette pal; 698 QPalette pal;
635 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 699 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
636 QStringList categories = todo->categories(); 700 QStringList categories = todo->categories();
637 QString cat = categories.first(); 701 QString cat = categories.first();
638 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 702 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
639 pal = getPalette(); 703 pal = getPalette();
640 if (cat.isEmpty()) { 704 if (cat.isEmpty()) {
641 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 705 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
642 } else { 706 } else {
643 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 707 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
644 } 708 }
645 709
646 } else { 710 } else {
647 if (cat.isEmpty()) { 711 if (cat.isEmpty()) {
648 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 712 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
649 } else { 713 } else {
650 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 714 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
651 } 715 }
652 } 716 }
653 717
654 } else { 718 } else {
655 pal = mStandardPalette ; 719 pal = mStandardPalette ;
656 } 720 }
657 item->setPalette( pal ); 721 item->setPalette( pal );
658 item->setRecur( todo->recurrence()->doesRecur() ); 722 item->setRecur( todo->recurrence()->doesRecur() );
659 item->setAlarm( todo->isAlarmEnabled() ); 723 item->setAlarm( todo->isAlarmEnabled() );
660 item->setMoreInfo( todo->description().length() > 0 ); 724 item->setMoreInfo( todo->description().length() > 0 );
661 mItemList->insertItem( item ); 725 if ( insertNewItem)
726 insertItem( item );
662 mToolTip.append( text ); 727 mToolTip.append( text );
663} 728}
729void MonthViewCell::repaintfinishUpdateCell()
730{
731 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
732 while ( mitem ) {
733 mitem->setBlockRepaint( false );
734 updateItem ( mitem );
735 mitem = (MonthViewItem *)mitem->next();
736 }
737}
664void MonthViewCell::finishUpdateCell() 738void MonthViewCell::finishUpdateCell()
665{ 739{
740 while ( mCurrentAvailItem ) {
741 MonthViewItem *item = mCurrentAvailItem;
742 mCurrentAvailItem = (MonthViewItem *)item->next();
743 mAvailItemList.append( item );
744 takeItem ( item );
745 }
746
747
666#ifdef DESKTOP_VERSION 748#ifdef DESKTOP_VERSION
667 if (mToolTip.count() > 0 ) { 749 if (mToolTip.count() > 0 ) {
668 mToolTip.sort(); 750 mToolTip.sort();
669 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 751 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
670 } 752 }
671#endif 753#endif
672 mItemList->sort(); 754 sort();
673 //setMyPalette(); 755 //setMyPalette();
674 setMyPalette(); 756 setMyPalette();
675 QString text; 757 QString text;
676 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 758 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
677 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 759 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
678 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 760 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
679 mLabel->resize( mLabelBigSize ); 761 mLabel->resize( mLabelBigSize );
680 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 762 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
681 } else { 763 } else {
682 mLabel->resize( mLabelSize ); 764 mLabel->resize( mLabelSize );
683 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 765 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
684 } 766 }
685 767
686 mLabel->setText( text ); 768 mLabel->setText( text );
687 resizeEvent( 0 ); 769 resizeEvent( 0 );
688 770
689} 771}
690void MonthViewCell::updateCell() 772void MonthViewCell::updateCell()
691{ 773{
692 //qDebug("MonthViewCell::updateCell() "); 774 //qDebug("MonthViewCell::updateCell() ");
693 if ( !mMonthView->isUpdatePossible() ) 775 if ( !mMonthView->isUpdatePossible() )
694 return; 776 return;
695 startUpdateCell(); 777 startUpdateCell();
696 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 778 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
@@ -725,118 +807,127 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
725 807
726 QFontMetrics fm( font() ); 808 QFontMetrics fm( font() );
727 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 809 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
728 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 810 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
729 mHolidayPalette = mStandardPalette; 811 mHolidayPalette = mStandardPalette;
730 mPrimaryPalette = mStandardPalette; 812 mPrimaryPalette = mStandardPalette;
731 mNonPrimaryPalette = mStandardPalette; 813 mNonPrimaryPalette = mStandardPalette;
732 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 814 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
733 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 815 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
734 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 816 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
735 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 817 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
736 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 818 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
737 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 819 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
738 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 820 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
739 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 821 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
740 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 822 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
741 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 823 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
742 } 824 }
743 //updateCell(); 825 //updateCell();
744} 826}
745 827
746void MonthViewCell::enableScrollBars( bool enabled ) 828void MonthViewCell::enableScrollBars( bool enabled )
747{ 829{
748 if ( enabled ) { 830 if ( enabled ) {
749 //mItemList->setVScrollBarMode(QScrollView::Auto); 831
750 mItemList->setHScrollBarMode(QScrollView::Auto); 832 QListBoxItem *fi = firstItem ();
751 QListBoxItem *fi = mItemList->firstItem ();
752 if (fi ) { 833 if (fi ) {
753 int hei = mItemList->numRows () * fi->height(mItemList); 834 int ihei = fi->height( this );
754 if ( hei < height() - mItemList->horizontalScrollBar()->height () ) 835 int hei = numRows () * ihei;
755 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 836 if ( hei < height() - horizontalScrollBar()->height () )
837 setVScrollBarMode(QScrollView::AlwaysOff);
756 else 838 else
757 mItemList->setVScrollBarMode(QScrollView::Auto); 839 setVScrollBarMode(QScrollView::Auto);
840 if ( ihei *3 > height() )
841 setHScrollBarMode(QScrollView::AlwaysOff);
842 else
843 setHScrollBarMode(QScrollView::Auto);
844 } else {
845 setVScrollBarMode(QScrollView::Auto);
846 setHScrollBarMode(QScrollView::Auto);
758 } 847 }
759 } else { 848 } else {
760 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 849 setVScrollBarMode(QScrollView::AlwaysOff);
761 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 850 setHScrollBarMode(QScrollView::AlwaysOff);
762 } 851 }
763} 852}
764 853
765Incidence *MonthViewCell::selectedIncidence() 854Incidence *MonthViewCell::selectedIncidence()
766{ 855{
767 int index = mItemList->currentItem(); 856 int index = currentItem();
768 if ( index < 0 ) return 0; 857 if ( index < 0 ) return 0;
769 858
770 MonthViewItem *item = 859 MonthViewItem *mitem =
771 static_cast<MonthViewItem *>( mItemList->item( index ) ); 860 static_cast<MonthViewItem *>( item( index ) );
772 861
773 if ( !item ) return 0; 862 if ( !mitem ) return 0;
774 863
775 return item->incidence(); 864 return mitem->incidence();
776} 865}
777 866
778QDate MonthViewCell::selectedIncidenceDate() 867QDate MonthViewCell::selectedIncidenceDate()
779{ 868{
780 QDate qd; 869 QDate qd;
781 int index = mItemList->currentItem(); 870 int index = currentItem();
782 if ( index < 0 ) return qd; 871 if ( index < 0 ) return qd;
783 872
784 MonthViewItem *item = 873 MonthViewItem *mitem =
785 static_cast<MonthViewItem *>( mItemList->item( index ) ); 874 static_cast<MonthViewItem *>( item( index ) );
786 875
787 if ( !item ) return qd; 876 if ( !mitem ) return qd;
788 877
789 return item->incidenceDate(); 878 return mitem->incidenceDate();
790} 879}
791 880
792void MonthViewCell::deselect() 881void MonthViewCell::deselect()
793{ 882{
794 mItemList->clearSelection(); 883 clearSelection();
795 enableScrollBars( false ); 884 enableScrollBars( false );
796 // updateCell(); 885 // updateCell();
797} 886}
798void MonthViewCell::select() 887void MonthViewCell::select()
799{ 888{
800 ;// updateCell(); 889 ;// updateCell();
801} 890}
802 891
803void MonthViewCell::resizeEvent ( QResizeEvent * e ) 892void MonthViewCell::resizeEvent ( QResizeEvent * e )
804{ 893{
805 if ( !mMonthView->isUpdatePossible() ) 894 if ( !mMonthView->isUpdatePossible() )
806 return; 895 return;
807 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 896 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
808 deselect(); 897 deselect();
809 int size = height() - mLabel->height() - 2; 898 int size = height() - mLabel->height() - lineWidth()-1;
899 //qDebug("LW %d ", lineWidth());
810 if ( size > 0 ) 900 if ( size > 0 )
811 mItemList->verticalScrollBar()->setMaximumHeight( size ); 901 verticalScrollBar()->setMaximumHeight( size );
812 size = width() - mLabel->width() -2; 902 size = width() - mLabel->width() -lineWidth()-1;
813 if ( size > 0 ) 903 if ( size > 0 )
814 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 904 horizontalScrollBar()->setMaximumWidth( size );
815 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 905 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
816 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 906 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
817 mItemList->resize ( width(), height () ); 907 // mItemList->resize ( width(), height () );
818 908 if ( e )
909 KNoScrollListBox::resizeEvent ( e );
819} 910}
820 911
821void MonthViewCell::defaultAction( QListBoxItem *item ) 912void MonthViewCell::defaultAction( QListBoxItem *item )
822{ 913{
823 if ( !item ) return; 914 if ( !item ) return;
824 915
825 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 916 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
826 Incidence *incidence = eventItem->incidence(); 917 Incidence *incidence = eventItem->incidence();
827 if ( incidence ) mMonthView->defaultAction( incidence ); 918 if ( incidence ) mMonthView->defaultAction( incidence );
828} 919}
829void MonthViewCell::showDay() 920void MonthViewCell::showDay()
830{ 921{
831 emit showDaySignal( date() ); 922 emit showDaySignal( date() );
832} 923}
833void MonthViewCell::newEvent() 924void MonthViewCell::newEvent()
834{ 925{
835 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 926 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
836 emit newEventSignal( dt ); 927 emit newEventSignal( dt );
837} 928}
838void MonthViewCell::cellClicked( QListBoxItem *item ) 929void MonthViewCell::cellClicked( QListBoxItem *item )
839{ 930{
840 static QListBoxItem * lastClicked = 0; 931 static QListBoxItem * lastClicked = 0;
841 if ( item == 0 ) { 932 if ( item == 0 ) {
842 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 933 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
@@ -1239,48 +1330,49 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
1239 wno =dayOfYear / 7; 1330 wno =dayOfYear / 7;
1240 (*weekLabels)[i]->setWeekNum( wno ); 1331 (*weekLabels)[i]->setWeekNum( wno );
1241 date = date.addDays( 7 ); 1332 date = date.addDays( 7 );
1242 } 1333 }
1243 updateView(); 1334 updateView();
1244} 1335}
1245 1336
1246void KOMonthView::showEvents(QPtrList<Event>) 1337void KOMonthView::showEvents(QPtrList<Event>)
1247{ 1338{
1248 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1339 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1249} 1340}
1250 1341
1251void KOMonthView::changeEventDisplay(Event *, int) 1342void KOMonthView::changeEventDisplay(Event *, int)
1252{ 1343{
1253 // this should be re-written to be much more efficient, but this 1344 // this should be re-written to be much more efficient, but this
1254 // quick-and-dirty-hack gets the job done for right now. 1345 // quick-and-dirty-hack gets the job done for right now.
1255 updateView(); 1346 updateView();
1256} 1347}
1257 1348
1258void KOMonthView::updateView() 1349void KOMonthView::updateView()
1259{ 1350{
1260 1351
1261 if ( !updatePossible ) 1352 if ( !updatePossible )
1262 return; 1353 return;
1354 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1263 //QTime ti; 1355 //QTime ti;
1264 //ti.start(); 1356 //ti.start();
1265 clearSelection(); 1357 clearSelection();
1266 QPtrVector<MonthViewCell> *cells; 1358 QPtrVector<MonthViewCell> *cells;
1267 if ( mShowWeekView ) { 1359 if ( mShowWeekView ) {
1268 cells = &mCellsW; 1360 cells = &mCellsW;
1269 } else { 1361 } else {
1270 cells = &mCells; 1362 cells = &mCells;
1271 } 1363 }
1272#if 1 1364#if 1
1273 int i; 1365 int i;
1274 int timeSpan = (*cells).size()-1; 1366 int timeSpan = (*cells).size()-1;
1275 if ( KOPrefs::instance()->mMonthViewWeek ) 1367 if ( KOPrefs::instance()->mMonthViewWeek )
1276 timeSpan = 6; 1368 timeSpan = 6;
1277 for( i = 0; i < timeSpan + 1; ++i ) { 1369 for( i = 0; i < timeSpan + 1; ++i ) {
1278 (*cells)[i]->startUpdateCell(); 1370 (*cells)[i]->startUpdateCell();
1279 } 1371 }
1280 1372
1281 QPtrList<Event> events = calendar()->events(); 1373 QPtrList<Event> events = calendar()->events();
1282 Event *event; 1374 Event *event;
1283 QDateTime dt; 1375 QDateTime dt;
1284 bool ok; 1376 bool ok;
1285 QDate endDate = mStartDate.addDays( timeSpan ); 1377 QDate endDate = mStartDate.addDays( timeSpan );
1286 for( event = events.first(); event; event = events.next() ) { // for event 1378 for( event = events.first(); event; event = events.next() ) { // for event
@@ -1335,48 +1427,52 @@ void KOMonthView::updateView()
1335 int iii; 1427 int iii;
1336 for ( iii = st;iii<= end;++iii) 1428 for ( iii = st;iii<= end;++iii)
1337 (*cells)[iii]->insertEvent( event ); 1429 (*cells)[iii]->insertEvent( event );
1338 } 1430 }
1339 } 1431 }
1340 } 1432 }
1341 } 1433 }
1342 // insert due todos 1434 // insert due todos
1343 QPtrList<Todo> todos = calendar()->todos( ); 1435 QPtrList<Todo> todos = calendar()->todos( );
1344 Todo *todo; 1436 Todo *todo;
1345 for(todo = todos.first(); todo; todo = todos.next()) { 1437 for(todo = todos.first(); todo; todo = todos.next()) {
1346 //insertTodo( todo ); 1438 //insertTodo( todo );
1347 if ( todo->hasDueDate() ) { 1439 if ( todo->hasDueDate() ) {
1348 int day = mStartDate.daysTo( todo->dtDue().date() ); 1440 int day = mStartDate.daysTo( todo->dtDue().date() );
1349 if ( day >= 0 && day < timeSpan + 1) { 1441 if ( day >= 0 && day < timeSpan + 1) {
1350 (*cells)[day]->insertTodo( todo ); 1442 (*cells)[day]->insertTodo( todo );
1351 } 1443 }
1352 } 1444 }
1353 } 1445 }
1354 1446
1355 for( i = 0; i < timeSpan+1; ++i ) { 1447 for( i = 0; i < timeSpan+1; ++i ) {
1356 (*cells)[i]->finishUpdateCell(); 1448 (*cells)[i]->finishUpdateCell();
1357 } 1449 }
1358 processSelectionChange(); 1450 processSelectionChange();
1451 qApp->processEvents();
1452 for( i = 0; i < timeSpan+1; ++i ) {
1453 (*cells)[i]->repaintfinishUpdateCell();
1454 }
1359 (*cells)[0]->setFocus(); 1455 (*cells)[0]->setFocus();
1360 1456
1361 1457
1362#else 1458#else
1363 // old code 1459 // old code
1364 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1460 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1365 int i; 1461 int i;
1366 for( i = 0; i < (*cells).count(); ++i ) { 1462 for( i = 0; i < (*cells).count(); ++i ) {
1367 (*cells)[i]->updateCell(); 1463 (*cells)[i]->updateCell();
1368 } 1464 }
1369 1465
1370 //qDebug("KOMonthView::updateView() "); 1466 //qDebug("KOMonthView::updateView() ");
1371 processSelectionChange(); 1467 processSelectionChange();
1372 // qDebug("---------------------------------------------------------------------+ "); 1468 // qDebug("---------------------------------------------------------------------+ ");
1373 (*cells)[0]->setFocus(); 1469 (*cells)[0]->setFocus();
1374#endif 1470#endif
1375 1471
1376 //qDebug("update time %d ", ti.elapsed()); 1472 //qDebug("update time %d ", ti.elapsed());
1377} 1473}
1378 1474
1379void KOMonthView::resizeEvent(QResizeEvent * e) 1475void KOMonthView::resizeEvent(QResizeEvent * e)
1380{ 1476{
1381 qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1477 qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1382 if ( isVisible() ) { 1478 if ( isVisible() ) {
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 89912e0..b997c1a 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -72,160 +72,166 @@ class KNoScrollListBox: public QListBox
72 KNoScrollListBox(QWidget *parent=0, const char *name=0); 72 KNoScrollListBox(QWidget *parent=0, const char *name=0);
73 ~KNoScrollListBox(); 73 ~KNoScrollListBox();
74 QString getWhatsThisText(QPoint p) ; 74 QString getWhatsThisText(QPoint p) ;
75 75
76 signals: 76 signals:
77 void shiftDown(); 77 void shiftDown();
78 void shiftUp(); 78 void shiftUp();
79 void rightClick(); 79 void rightClick();
80 80
81 protected slots: 81 protected slots:
82 void oneDown(); 82 void oneDown();
83 void keyPressEvent(QKeyEvent *); 83 void keyPressEvent(QKeyEvent *);
84 void keyReleaseEvent(QKeyEvent *); 84 void keyReleaseEvent(QKeyEvent *);
85 void mousePressEvent(QMouseEvent *); 85 void mousePressEvent(QMouseEvent *);
86 86
87 private: 87 private:
88 KNOWhatsThis * mWT; 88 KNOWhatsThis * mWT;
89}; 89};
90 90
91 91
92class MonthViewItem: public QListBoxItem 92class MonthViewItem: public QListBoxItem
93{ 93{
94 public: 94 public:
95 MonthViewItem( Incidence *, QDate qd, const QString & title ); 95 MonthViewItem( Incidence *, QDate qd, const QString & title );
96 96 void recycle( Incidence *incidence, QDate qd, const QString & s);
97 void setRecur(bool on) { mRecur = on; } 97 void setRecur(bool on) { mRecur = on; }
98 void setAlarm(bool on) { mAlarm = on; } 98 void setAlarm(bool on) { mAlarm = on; }
99 void setReply(bool on) { mReply = on; } 99 void setReply(bool on) { mReply = on; }
100 void setMoreInfo(bool on) { mInfo = on; } 100 void setMoreInfo(bool on) { mInfo = on; }
101 void setMultiDay(int type) { mMultiday = type; } 101 void setMultiDay(int type) { mMultiday = type; }
102 void setBlockRepaint(bool on) { mblockRepaint = on; }
102 103
103 104
104 void setPalette(const QPalette &p) { mPalette = p; } 105 void setPalette(const QPalette &p) { mPalette = p; }
105 QPalette palette() const { return mPalette; } 106 QPalette palette() const { return mPalette; }
106 107
107 Incidence *incidence() const { return mIncidence; } 108 Incidence *incidence() const { return mIncidence; }
108 QDate incidenceDate() { return mDate; } 109 QDate incidenceDate() { return mDate; }
109 110
110 protected: 111 protected:
111 virtual void paint(QPainter *); 112 virtual void paint(QPainter *);
112 virtual int height(const QListBox *) const; 113 virtual int height(const QListBox *) const;
113 virtual int width(const QListBox *) const; 114 virtual int width(const QListBox *) const;
114 115
115 private: 116 private:
117 bool mblockRepaint;
116 int mMultiday; 118 int mMultiday;
117 bool mRecur; 119 bool mRecur;
118 bool mAlarm; 120 bool mAlarm;
119 bool mReply; 121 bool mReply;
120 bool mInfo; 122 bool mInfo;
121 123
122 QPalette mPalette; 124 QPalette mPalette;
123 QDate mDate; 125 QDate mDate;
124 126
125 Incidence *mIncidence; 127 Incidence *mIncidence;
126}; 128};
127 129
128 130
129class KOMonthView; 131class KOMonthView;
130 132
131class MonthViewCell : public QWidget 133class MonthViewCell : public KNoScrollListBox
132{ 134{
133 Q_OBJECT 135 Q_OBJECT
134 public: 136 public:
135 MonthViewCell(KOMonthView *,QWidget* ); 137 MonthViewCell(KOMonthView *,QWidget* );
138 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
136 139
137 void setDate( const QDate & ); 140 void setDate( const QDate & );
138 QDate date() const; 141 QDate date() const;
139 142
140 void setPrimary( bool ); 143 void setPrimary( bool );
141 bool isPrimary() const; 144 bool isPrimary() const;
142 145
143 void setHoliday( bool ); 146 void setHoliday( bool );
144 void setHoliday( const QString & ); 147 void setHoliday( const QString & );
145 148
146 void updateCell(); 149 void updateCell();
147 void startUpdateCell(); 150 void startUpdateCell();
148 void finishUpdateCell(); 151 void finishUpdateCell();
152 void repaintfinishUpdateCell();
149 void insertEvent(Event *); 153 void insertEvent(Event *);
150 void insertTodo(Todo *); 154 void insertTodo(Todo *);
151 155
152 void updateConfig( bool bigFont = false ); 156 void updateConfig( bool bigFont = false );
153 157
154 void enableScrollBars( bool ); 158 void enableScrollBars( bool );
155 159
156 Incidence *selectedIncidence(); 160 Incidence *selectedIncidence();
157 QDate selectedIncidenceDate(); 161 QDate selectedIncidenceDate();
158 162
159 void deselect(); 163 void deselect();
160 void select(); 164 void select();
161 165
162#ifdef DESKTOP_VERSION 166#ifdef DESKTOP_VERSION
163 static QToolTipGroup *toolTipGroup(); 167 static QToolTipGroup *toolTipGroup();
164#endif 168#endif
165 signals: 169 signals:
166 void defaultAction( Incidence * ); 170 void defaultAction( Incidence * );
167 void newEventSignal( QDateTime ); 171 void newEventSignal( QDateTime );
168 void showDaySignal( QDate ); 172 void showDaySignal( QDate );
169 173
170 protected: 174 protected:
171 QStringList mToolTip; 175 QStringList mToolTip;
172 void resizeEvent( QResizeEvent * ); 176 void resizeEvent( QResizeEvent * );
173 177
174 178
175public slots: 179public slots:
176 void showDay(); 180 void showDay();
177 181
178 protected slots: 182 protected slots:
179 void defaultAction( QListBoxItem * ); 183 void defaultAction( QListBoxItem * );
180 void contextMenu( QListBoxItem * ); 184 void contextMenu( QListBoxItem * );
181 void selection( QListBoxItem * ); 185 void selection( QListBoxItem * );
182 void cellClicked( QListBoxItem * ); 186 void cellClicked( QListBoxItem * );
183 void newEvent(); 187 void newEvent();
184 188
185 private: 189 private:
190 MonthViewItem* mCurrentAvailItem;
191 QPtrList <MonthViewItem> mAvailItemList;
186 KOMonthView *mMonthView; 192 KOMonthView *mMonthView;
193 int currentPalette;
187 194
188 QDate mDate; 195 QDate mDate;
189 bool mPrimary; 196 bool mPrimary;
190 bool mHoliday; 197 bool mHoliday;
191 QString mHolidayString; 198 QString mHolidayString;
192 199
193 //QLabel *mLabel; 200 //QLabel *mLabel;
194 QPushButton *mLabel; 201 QPushButton *mLabel;
195 QListBox *mItemList; 202 //QListBox *mItemList;
196#ifdef DESKTOP_VERSION 203#ifdef DESKTOP_VERSION
197 static QToolTipGroup *mToolTipGroup; 204 static QToolTipGroup *mToolTipGroup;
198#endif 205#endif
199 QSize mLabelSize; 206 QSize mLabelSize;
200 QSize mLabelBigSize; 207 QSize mLabelBigSize;
201 QPalette mHolidayPalette; 208 QPalette mHolidayPalette;
202 QPalette mStandardPalette; 209 QPalette mStandardPalette;
203 QPalette mPrimaryPalette; 210 QPalette mPrimaryPalette;
204 QPalette mNonPrimaryPalette; 211 QPalette mNonPrimaryPalette;
205 void setMyPalette(); 212 void setMyPalette();
206 QPalette getPalette (); 213 QPalette getPalette ();
207 void keyPressEvent ( QKeyEvent * ) ;
208 214
209}; 215};
210 216
211 217
212class KOMonthView: public KOEventView 218class KOMonthView: public KOEventView
213{ 219{
214 Q_OBJECT 220 Q_OBJECT
215 public: 221 public:
216 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 222 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
217 ~KOMonthView(); 223 ~KOMonthView();
218 224
219 /** Returns maximum number of days supported by the komonthview */ 225 /** Returns maximum number of days supported by the komonthview */
220 virtual int maxDatesHint(); 226 virtual int maxDatesHint();
221 227
222 /** Returns number of currently shown dates. */ 228 /** Returns number of currently shown dates. */
223 virtual int currentDateCount(); 229 virtual int currentDateCount();
224 230
225 /** returns the currently selected events */ 231 /** returns the currently selected events */
226 virtual QPtrList<Incidence> selectedIncidences(); 232 virtual QPtrList<Incidence> selectedIncidences();
227 233
228 /** returns dates of the currently selected events */ 234 /** returns dates of the currently selected events */
229 virtual DateList selectedDates(); 235 virtual DateList selectedDates();
230 236
231 virtual void printPreview(CalPrinter *calPrinter, 237 virtual void printPreview(CalPrinter *calPrinter,
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 94d74f1..c6e76c4 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -187,70 +187,71 @@ void KOViewManager::writeSettings(KConfig *config)
187 if (mAgendaView) { 187 if (mAgendaView) {
188 mAgendaView->writeSettings(config); 188 mAgendaView->writeSettings(config);
189 } 189 }
190 if (mTimeSpanView) { 190 if (mTimeSpanView) {
191 mTimeSpanView->writeSettings(config); 191 mTimeSpanView->writeSettings(config);
192 } 192 }
193 if (mListView) { 193 if (mListView) {
194 mListView->writeSettings(config); 194 mListView->writeSettings(config);
195 } 195 }
196 if (mTodoView) { 196 if (mTodoView) {
197 mTodoView->saveLayout(config,"Todo View"); 197 mTodoView->saveLayout(config,"Todo View");
198 } 198 }
199} 199}
200 200
201void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 201void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
202{ 202{
203 203
204 //mFlagShowNextxDays = false; 204 //mFlagShowNextxDays = false;
205 //if(view == mCurrentView) return; 205 //if(view == mCurrentView) return;
206 if ( view == 0 ) { 206 if ( view == 0 ) {
207 view = mCurrentView; 207 view = mCurrentView;
208 if ( view == 0 ) 208 if ( view == 0 )
209 return; 209 return;
210 } 210 }
211 bool callupdate = !(view == mCurrentView);
211 bool full = fullScreen; 212 bool full = fullScreen;
212 if(view == mCurrentView && view != mWhatsNextView ) { 213 if(view == mCurrentView && view != mWhatsNextView ) {
213 if ( mCurrentAgendaView < 0 ) 214 if ( mCurrentAgendaView < 0 )
214 return; 215 return;
215 if ( view != mMonthView ) 216 if ( view != mMonthView )
216 full = mMainView->leftFrame()->isVisible(); 217 full = mMainView->leftFrame()->isVisible();
217 } else { 218 } else {
218 if ( view == mMonthView && mMonthView) 219 if ( view == mMonthView && mMonthView)
219 ;//mMonthView->skipResize = true ; 220 ;//mMonthView->skipResize = true ;
220 mCurrentView = view; 221 mCurrentView = view;
221 // bool full = fullScreen; 222 // bool full = fullScreen;
222 bool isFull = !mMainView->leftFrame()->isVisible(); 223 bool isFull = !mMainView->leftFrame()->isVisible();
223 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 224 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
224 full = true; 225 full = true;
225 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 226 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
226 full = false; 227 full = false;
227 } 228 }
228 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 229 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
229 //raiseCurrentView( full ); 230 //raiseCurrentView( full );
230 mMainView->processIncidenceSelection( 0 ); 231 mMainView->processIncidenceSelection( 0 );
231 //mMainView->updateView(); 232 //mMainView->updateView();
232 raiseCurrentView( full, true ); 233 raiseCurrentView( full, callupdate );
233 mMainView->adaptNavigationUnits(); 234 mMainView->adaptNavigationUnits();
234} 235}
235 236
236void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 237void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
237{ 238{
238 mCurrentAgendaView = 0; 239 mCurrentAgendaView = 0;
239 if ( fullScreen ) { 240 if ( fullScreen ) {
240 mMainView->leftFrame()->hide(); 241 mMainView->leftFrame()->hide();
241 } else { 242 } else {
242 mMainView->leftFrame()->show(); 243 mMainView->leftFrame()->show();
243 } 244 }
244 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 245 //if ( mCurrentView == mMonthView ) qApp->processEvents();
245 emit signalFullScreen( !fullScreen ); 246 emit signalFullScreen( !fullScreen );
246 if ( callUpdateView ) 247 if ( callUpdateView )
247 mMainView->updateView(); 248 mMainView->updateView();
248 249
249 if ( globalFlagBlockAgenda == 5 ) { 250 if ( globalFlagBlockAgenda == 5 ) {
250 globalFlagBlockAgenda = 4; 251 globalFlagBlockAgenda = 4;
251 globalFlagBlockAgendaItemPaint = 1; 252 globalFlagBlockAgendaItemPaint = 1;
252 } 253 }
253 mMainView->viewStack()->raiseWidget(mCurrentView); 254 mMainView->viewStack()->raiseWidget(mCurrentView);
254 if ( globalFlagBlockAgenda == 4 ) { 255 if ( globalFlagBlockAgenda == 4 ) {
255 if ( mCurrentView == mAgendaView ) { 256 if ( mCurrentView == mAgendaView ) {
256 //globalFlagBlockAgenda =1 ; 257 //globalFlagBlockAgenda =1 ;