summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
Unidiff
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/komonthview.cpp14
1 files changed, 1 insertions, 13 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 2b7e41f..843526d 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -266,71 +266,67 @@ void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
266 266
267void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 267void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
268{ 268{
269 QListBox::mousePressEvent(e); 269 QListBox::mousePressEvent(e);
270 270
271 if(e->button() == RightButton) { 271 if(e->button() == RightButton) {
272 emit rightClick(); 272 emit rightClick();
273 } 273 }
274} 274}
275 275
276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 276MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
277 : QListBoxItem() 277 : QListBoxItem()
278{ 278{
279 mblockRepaint = true; 279 mblockRepaint = true;
280 setText( s ); 280 setText( s );
281 mMultiday = 0; 281 mMultiday = 0;
282 mIncidence = incidence; 282 mIncidence = incidence;
283 mDate = qd; 283 mDate = qd;
284 mRecur = false; 284 mRecur = false;
285 mAlarm = false; 285 mAlarm = false;
286 mReply = false; 286 mReply = false;
287 mInfo = false; 287 mInfo = false;
288 mdayPos = 0; 288 mdayPos = 0;
289 isWeekItem = KOPrefs::instance()->mMonthViewWeek; 289 isWeekItem = KOPrefs::instance()->mMonthViewWeek;
290 //qDebug("NEWWWWWWWWWWWWW ");
291} 290}
292void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) 291void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
293{ 292{
294 setText( s ); 293 setText( s );
295 mMultiday = 0; 294 mMultiday = 0;
296 mIncidence = incidence; 295 mIncidence = incidence;
297 mDate = qd; 296 mDate = qd;
298 mRecur = false; 297 mRecur = false;
299 mAlarm = false; 298 mAlarm = false;
300 mReply = false; 299 mReply = false;
301 mInfo = false; 300 mInfo = false;
302 mdayPos = 0; 301 mdayPos = 0;
303 //qDebug("recucleeeeeeeeeeeeeeeee ");
304} 302}
305 303
306void MonthViewItem::paint(QPainter *p) 304void MonthViewItem::paint(QPainter *p)
307{ 305{
308 if ( mblockRepaint ) { 306 if ( mblockRepaint ) {
309 //qDebug("block ");
310 return; 307 return;
311 } 308 }
312 //qDebug("NON block ");
313#if QT_VERSION >= 0x030000 309#if QT_VERSION >= 0x030000
314 bool sel = isSelected(); 310 bool sel = isSelected();
315#else 311#else
316 bool sel = selected(); 312 bool sel = selected();
317#endif 313#endif
318 314
319 315
320 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 316 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
321 { 317 {
322 p->setBackgroundColor( palette().color( QPalette::Normal, \ 318 p->setBackgroundColor( palette().color( QPalette::Normal, \
323 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 319 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
324 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 320 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
325 } 321 }
326 int x = 1; 322 int x = 1;
327 //int y = 3;//(height() - mRecurPixmap.height()) /2; 323 //int y = 3;//(height() - mRecurPixmap.height()) /2;
328 int size = PIXMAP_SIZE; 324 int size = PIXMAP_SIZE;
329 if ( QApplication::desktop()->width() < 300 ) 325 if ( QApplication::desktop()->width() < 300 )
330 size = 3; 326 size = 3;
331 int heihei = height( listBox () ); 327 int heihei = height( listBox () );
332 int y = (heihei - size -1 ) /2; 328 int y = (heihei - size -1 ) /2;
333 329
334 if ( KOPrefs::instance()->mMonthShowIcons ) { 330 if ( KOPrefs::instance()->mMonthShowIcons ) {
335 if ( mInfo ) { 331 if ( mInfo ) {
336 p->fillRect ( x, y,size,size, Qt::darkGreen ); 332 p->fillRect ( x, y,size,size, Qt::darkGreen );
@@ -439,49 +435,48 @@ int MonthViewItem::width(const QListBox *lb) const
439 if ( QApplication::desktop()->width() < 300 ) 435 if ( QApplication::desktop()->width() < 300 )
440 size = 3; 436 size = 3;
441 int x = 1; 437 int x = 1;
442 if ( KOPrefs::instance()->mMonthShowIcons ) { 438 if ( KOPrefs::instance()->mMonthShowIcons ) {
443 if ( mInfo ) { 439 if ( mInfo ) {
444 x += size + 1; 440 x += size + 1;
445 } 441 }
446 if( mRecur ) { 442 if( mRecur ) {
447 x += size+1; 443 x += size+1;
448 } 444 }
449 if( mAlarm ) { 445 if( mAlarm ) {
450 x += size+1; 446 x += size+1;
451 } 447 }
452 if( mReply ) { 448 if( mReply ) {
453 x += size+1; 449 x += size+1;
454 } 450 }
455 } 451 }
456 if( mMultiday ) { 452 if( mMultiday ) {
457 x += size+1+2+size/2; 453 x += size+1+2+size/2;
458 } 454 }
459 return( x + lb->fontMetrics().width( text() ) + 1 ); 455 return( x + lb->fontMetrics().width( text() ) + 1 );
460 } 456 }
461 if ( ! lb ) 457 if ( ! lb )
462 return 10; 458 return 10;
463 //qDebug("ret wid %d ", lb->width());
464 return lb->width(); 459 return lb->width();
465} 460}
466 461
467 462
468MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 463MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
469 : KNoScrollListBox( par ), 464 : KNoScrollListBox( par ),
470 mMonthView( parent ) 465 mMonthView( parent )
471{ 466{
472 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 467 //QVBoxLayout *topLayout = new QVBoxLayout( this );
473 currentPalette = 0; 468 currentPalette = 0;
474 // mLabel = new QLabel( this );QPushButton 469 // mLabel = new QLabel( this );QPushButton
475 mLabel = new QPushButton( this ); 470 mLabel = new QPushButton( this );
476 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 471 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
477 //mLabel->setLineWidth( 1 ); 472 //mLabel->setLineWidth( 1 );
478 //mLabel->setAlignment( AlignCenter ); 473 //mLabel->setAlignment( AlignCenter );
479 mLabel->setFlat( true ); 474 mLabel->setFlat( true );
480 mLabel->setFocusPolicy(NoFocus); 475 mLabel->setFocusPolicy(NoFocus);
481 //mItemList = new KNoScrollListBox( this ); 476 //mItemList = new KNoScrollListBox( this );
482 setMinimumSize( 10, 10 ); 477 setMinimumSize( 10, 10 );
483 setFrameStyle( QFrame::Panel | QFrame::Plain ); 478 setFrameStyle( QFrame::Panel | QFrame::Plain );
484 setLineWidth( 1 ); 479 setLineWidth( 1 );
485 //topLayout->addWidget( mItemList ); 480 //topLayout->addWidget( mItemList );
486 mLabel->raise(); 481 mLabel->raise();
487 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 482 // QColor( 0,0,255 ) QColor( 160,1600,255 )
@@ -591,54 +586,49 @@ void MonthViewCell::setHoliday( const QString &holiday )
591{ 586{
592 mHolidayString = holiday; 587 mHolidayString = holiday;
593 588
594 if ( !holiday.isEmpty() ) { 589 if ( !holiday.isEmpty() ) {
595 setHoliday( true ); 590 setHoliday( true );
596 } 591 }
597} 592}
598 593
599void MonthViewCell::startUpdateCell() 594void MonthViewCell::startUpdateCell()
600{ 595{
601 mdayCount = 0; 596 mdayCount = 0;
602 setFocusPolicy(NoFocus); 597 setFocusPolicy(NoFocus);
603 if ( !mMonthView->isUpdatePossible() ) 598 if ( !mMonthView->isUpdatePossible() )
604 return; 599 return;
605 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 600 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
606 while ( mitem ) { 601 while ( mitem ) {
607 mitem->setBlockRepaint( true ); 602 mitem->setBlockRepaint( true );
608 mitem = (MonthViewItem *)mitem->next(); 603 mitem = (MonthViewItem *)mitem->next();
609 } 604 }
610 if ( mAvailItemList.count() > 20 ) { 605 if ( mAvailItemList.count() > 20 ) {
611 mAvailItemList.setAutoDelete( true ); 606 mAvailItemList.setAutoDelete( true );
612 mAvailItemList.clear(); 607 mAvailItemList.clear();
613 mAvailItemList.setAutoDelete( false ); 608 mAvailItemList.setAutoDelete( false );
614 } 609 }
615 /* 610
616 if ( !isVisible() ){
617 return;
618 }
619 */
620 // qDebug("MonthViewCell::updateCell() ");
621 setPrimary( mDate.month()%2 ); 611 setPrimary( mDate.month()%2 );
622 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 612 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
623 if ( mDate == QDate::currentDate() ) { 613 if ( mDate == QDate::currentDate() ) {
624 setLineWidth( 3 ); 614 setLineWidth( 3 );
625 } else { 615 } else {
626 setLineWidth( 1 ); 616 setLineWidth( 1 );
627 } 617 }
628 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 618 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
629 //clear(); 619 //clear();
630 while ( CurrentAvailItem ) { 620 while ( CurrentAvailItem ) {
631 MonthViewItem *item = CurrentAvailItem; 621 MonthViewItem *item = CurrentAvailItem;
632 CurrentAvailItem = (MonthViewItem *)item->next(); 622 CurrentAvailItem = (MonthViewItem *)item->next();
633 mAvailItemList.append( item ); 623 mAvailItemList.append( item );
634 takeItem ( item ); 624 takeItem ( item );
635 } 625 }
636 626
637#ifdef DESKTOP_VERSION 627#ifdef DESKTOP_VERSION
638 QToolTip::remove(this); 628 QToolTip::remove(this);
639#endif 629#endif
640 mToolTip.clear(); 630 mToolTip.clear();
641 //qApp->processEvents(); 631 //qApp->processEvents();
642#if 0 632#if 0
643 if ( !mHolidayString.isEmpty() ) { 633 if ( !mHolidayString.isEmpty() ) {
644 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 634 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
@@ -850,49 +840,48 @@ void MonthViewCell::repaintfinishUpdateCell()
850 updateItem ( mitem ); 840 updateItem ( mitem );
851 mitem = (MonthViewItem *)mitem->next(); 841 mitem = (MonthViewItem *)mitem->next();
852 } 842 }
853} 843}
854void MonthViewCell::finishUpdateCell() 844void MonthViewCell::finishUpdateCell()
855{ 845{
856 846
857 847
858 848
859#ifdef DESKTOP_VERSION 849#ifdef DESKTOP_VERSION
860 if (mToolTip.count() > 0 ) { 850 if (mToolTip.count() > 0 ) {
861 mToolTip.sort(); 851 mToolTip.sort();
862 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 852 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
863 } 853 }
864#endif 854#endif
865 //sort(); 855 //sort();
866 //setMyPalette(); 856 //setMyPalette();
867 setMyPalette(); 857 setMyPalette();
868 858
869 resizeEvent( 0 ); 859 resizeEvent( 0 );
870 860
871} 861}
872void MonthViewCell::updateCell() 862void MonthViewCell::updateCell()
873{ 863{
874 //qDebug("MonthViewCell::updateCell() ");
875 if ( !mMonthView->isUpdatePossible() ) 864 if ( !mMonthView->isUpdatePossible() )
876 return; 865 return;
877 startUpdateCell(); 866 startUpdateCell();
878 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 867 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
879 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 868 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
880 Event *event; 869 Event *event;
881 for( event = events.first(); event; event = events.next() ) { // for event 870 for( event = events.first(); event; event = events.next() ) { // for event
882 insertEvent(event); 871 insertEvent(event);
883 } 872 }
884 // insert due todos 873 // insert due todos
885 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 874 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
886 Todo *todo; 875 Todo *todo;
887 for(todo = todos.first(); todo; todo = todos.next()) { 876 for(todo = todos.first(); todo; todo = todos.next()) {
888 insertTodo( todo ); 877 insertTodo( todo );
889 } 878 }
890 finishUpdateCell(); 879 finishUpdateCell();
891 // if ( isVisible()) 880 // if ( isVisible())
892 //qApp->processEvents(); 881 //qApp->processEvents();
893} 882}
894 883
895void MonthViewCell::updateConfig( bool bigFont ) // = false 884void MonthViewCell::updateConfig( bool bigFont ) // = false
896{ 885{
897 886
898 if ( bigFont ) { 887 if ( bigFont ) {
@@ -1032,49 +1021,48 @@ void MonthViewCell::defaultAction( QListBoxItem *item )
1032{ 1021{
1033 1022
1034 if ( !item ) { 1023 if ( !item ) {
1035 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1024 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1036 emit newEventSignal( dt ); 1025 emit newEventSignal( dt );
1037 return; 1026 return;
1038 } 1027 }
1039 1028
1040 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1029 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1041 Incidence *incidence = eventItem->incidence(); 1030 Incidence *incidence = eventItem->incidence();
1042 if ( incidence ) mMonthView->defaultAction( incidence ); 1031 if ( incidence ) mMonthView->defaultAction( incidence );
1043} 1032}
1044void MonthViewCell::showDay() 1033void MonthViewCell::showDay()
1045{ 1034{
1046 emit showDaySignal( date() ); 1035 emit showDaySignal( date() );
1047} 1036}
1048void MonthViewCell::newEvent() 1037void MonthViewCell::newEvent()
1049{ 1038{
1050 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1039 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1051 emit newEventSignal( dt ); 1040 emit newEventSignal( dt );
1052} 1041}
1053void MonthViewCell::cellClicked( QListBoxItem *item ) 1042void MonthViewCell::cellClicked( QListBoxItem *item )
1054{ 1043{
1055 mMonthView->setSelectedCell( this ); 1044 mMonthView->setSelectedCell( this );
1056 qDebug("CELL ");
1057 if ( item == 0 ) { 1045 if ( item == 0 ) {
1058 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1046 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1059 emit newEventSignal( dt ); 1047 emit newEventSignal( dt );
1060 return; 1048 return;
1061 } 1049 }
1062 1050
1063} 1051}
1064 1052
1065void MonthViewCell::contextMenu( QListBoxItem *item ) 1053void MonthViewCell::contextMenu( QListBoxItem *item )
1066{ 1054{
1067 mMonthView->setPopupCell( this ); 1055 mMonthView->setPopupCell( this );
1068 if ( !item ) { 1056 if ( !item ) {
1069 mMonthView->showContextMenu( 0 ); 1057 mMonthView->showContextMenu( 0 );
1070 return; 1058 return;
1071 } 1059 }
1072 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1060 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1073 Incidence *incidence = eventItem->incidence(); 1061 Incidence *incidence = eventItem->incidence();
1074 if ( incidence ) mMonthView->showContextMenu( incidence ); 1062 if ( incidence ) mMonthView->showContextMenu( incidence );
1075} 1063}
1076 1064
1077void MonthViewCell::selection( QListBoxItem *item ) 1065void MonthViewCell::selection( QListBoxItem *item )
1078{ 1066{
1079 if ( !item ) return; 1067 if ( !item ) return;
1080 1068