-rw-r--r-- | korganizer/komonthview.cpp | 57 |
1 files changed, 16 insertions, 41 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 00e5a6f..aeb3974 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -277,49 +277,28 @@ void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | |||
277 | emit rightClick(); | 277 | emit rightClick(); |
278 | } | 278 | } |
279 | } | 279 | } |
280 | 280 | ||
281 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 281 | MonthViewItem::MonthViewItem( Incidence *incidence, const QString & s) |
282 | : QListBoxItem() | 282 | : QListBoxItem() |
283 | { | 283 | { |
284 | mDisplayHightlighted = false; | ||
285 | mblockRepaint = true; | 284 | mblockRepaint = true; |
286 | setText( s ); | ||
287 | mMultiday = 0; | ||
288 | mIncidence = incidence; | ||
289 | mDate = qd; | ||
290 | mRecur = false; | ||
291 | mAlarm = false; | ||
292 | mReply = false; | ||
293 | mInfo = false; | ||
294 | mdayPos = 0; | ||
295 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; | 285 | isWeekItem = KOPrefs::instance()->mMonthViewWeek; |
286 | recycle( incidence, s ); | ||
296 | } | 287 | } |
297 | void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) | 288 | void MonthViewItem::recycle( Incidence *incidence, const QString & s) |
298 | { | 289 | { |
299 | mDisplayHightlighted = false; | 290 | mDisplayHightlighted = false; |
300 | setText( s ); | 291 | setText( s ); |
301 | mMultiday = 0; | 292 | mMultiday = 0; |
302 | mIncidence = incidence; | 293 | mIncidence = incidence; |
303 | mDate = qd; | ||
304 | mRecur = false; | ||
305 | mAlarm = false; | ||
306 | mReply = false; | ||
307 | mInfo = false; | ||
308 | mdayPos = 0; | ||
309 | } | ||
310 | void MonthViewItem::clearData() | ||
311 | { | ||
312 | mDisplayHightlighted = false; | ||
313 | setText( "" ); | ||
314 | mMultiday = 0; | ||
315 | mIncidence = 0; | ||
316 | mRecur = false; | 294 | mRecur = false; |
317 | mAlarm = false; | 295 | mAlarm = false; |
318 | mReply = false; | 296 | mReply = false; |
319 | mInfo = false; | 297 | mInfo = false; |
320 | mdayPos = 0; | 298 | mdayPos = 0; |
321 | } | 299 | } |
300 | |||
322 | bool MonthViewItem::setHighlightedFalse() | 301 | bool MonthViewItem::setHighlightedFalse() |
323 | { | 302 | { |
324 | if ( !mDisplayHightlighted ) | 303 | if ( !mDisplayHightlighted ) |
325 | return false; | 304 | return false; |
@@ -343,9 +322,9 @@ bool MonthViewItem::setHighlighted( Incidence * inc ) | |||
343 | return false; | 322 | return false; |
344 | } | 323 | } |
345 | void MonthViewItem::paint(QPainter *p) | 324 | void MonthViewItem::paint(QPainter *p) |
346 | { | 325 | { |
347 | if ( mblockRepaint ) { | 326 | if ( mblockRepaint || !mIncidence ) { |
348 | return; | 327 | return; |
349 | } | 328 | } |
350 | #if QT_VERSION >= 0x030000 | 329 | #if QT_VERSION >= 0x030000 |
351 | bool sel = isSelected(); | 330 | bool sel = isSelected(); |
@@ -353,9 +332,9 @@ void MonthViewItem::paint(QPainter *p) | |||
353 | bool sel = selected(); | 332 | bool sel = selected(); |
354 | #endif | 333 | #endif |
355 | int heihei = height( listBox () ); | 334 | int heihei = height( listBox () ); |
356 | int x = 1; | 335 | int x = 1; |
357 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted ) | 336 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted || sel ) |
358 | { | 337 | { |
359 | if ( mDisplayHightlighted ) | 338 | if ( mDisplayHightlighted ) |
360 | sel = true; | 339 | sel = true; |
361 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 340 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
@@ -394,9 +373,9 @@ void MonthViewItem::paint(QPainter *p) | |||
394 | } | 373 | } |
395 | if ( mMultiday ) { | 374 | if ( mMultiday ) { |
396 | int yyy = y+(size/2); | 375 | int yyy = y+(size/2); |
397 | int sizeM = size+2; | 376 | int sizeM = size+2; |
398 | p->setBrush( QBrush::SolidPattern ); | 377 | p->setBrush( QBrush( p->pen().color() ) ); |
399 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 378 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
400 | if ( mMultiday == 2 || mMultiday == 3 ) { | 379 | if ( mMultiday == 2 || mMultiday == 3 ) { |
401 | QPointArray pa ( 3 ); | 380 | QPointArray pa ( 3 ); |
402 | pa.setPoint (0, x, yyy ); | 381 | pa.setPoint (0, x, yyy ); |
@@ -433,9 +412,9 @@ void MonthViewItem::paint(QPainter *p) | |||
433 | x += half+half + 4; | 412 | x += half+half + 4; |
434 | 413 | ||
435 | } else { | 414 | } else { |
436 | int val = td->percentComplete()/20; | 415 | int val = td->percentComplete()/20; |
437 | p->fillRect ( x+1, y-2, val ,size+4,Qt::black ); | 416 | p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() ); |
438 | p->drawRect ( x, y-2,7,size+4); | 417 | p->drawRect ( x, y-2,7,size+4); |
439 | x += size + 3; | 418 | x += size + 3; |
440 | } | 419 | } |
441 | } | 420 | } |
@@ -667,9 +646,9 @@ void MonthViewCell::startUpdateCell() | |||
667 | //clear(); | 646 | //clear(); |
668 | while ( CurrentAvailItem ) { | 647 | while ( CurrentAvailItem ) { |
669 | MonthViewItem *item = CurrentAvailItem; | 648 | MonthViewItem *item = CurrentAvailItem; |
670 | //item->setHighlightedFalse(); | 649 | //item->setHighlightedFalse(); |
671 | item->clearData(); | 650 | item->recycle( 0, ""); |
672 | CurrentAvailItem = (MonthViewItem *)item->next(); | 651 | CurrentAvailItem = (MonthViewItem *)item->next(); |
673 | mAvailItemList.append( item ); | 652 | mAvailItemList.append( item ); |
674 | takeItem ( item ); | 653 | takeItem ( item ); |
675 | } | 654 | } |
@@ -763,11 +742,11 @@ int MonthViewCell::insertEvent(Event *event) | |||
763 | 742 | ||
764 | if ( mAvailItemList.count() ) { | 743 | if ( mAvailItemList.count() ) { |
765 | item = mAvailItemList.first(); | 744 | item = mAvailItemList.first(); |
766 | mAvailItemList.remove( item ); | 745 | mAvailItemList.remove( item ); |
767 | item->recycle( event, mDate, text ); | 746 | item->recycle( event, text ); |
768 | } else { | 747 | } else { |
769 | item = new MonthViewItem( event, mDate, text ); | 748 | item = new MonthViewItem( event, text ); |
770 | } | 749 | } |
771 | 750 | ||
772 | QPalette pal; | 751 | QPalette pal; |
773 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 752 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
@@ -793,8 +772,9 @@ int MonthViewCell::insertEvent(Event *event) | |||
793 | 772 | ||
794 | } else { | 773 | } else { |
795 | pal = mStandardPalette ; | 774 | pal = mStandardPalette ; |
796 | } | 775 | } |
776 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | ||
797 | item->setPalette( pal ); | 777 | item->setPalette( pal ); |
798 | item->setRecur( event->recurrence()->doesRecur() ); | 778 | item->setRecur( event->recurrence()->doesRecur() ); |
799 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); | 779 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); |
800 | item->setMoreInfo( event->description().length() > 0 ); | 780 | item->setMoreInfo( event->description().length() > 0 ); |
@@ -852,11 +832,11 @@ void MonthViewCell::insertTodo(Todo *todo) | |||
852 | MonthViewItem *item ; | 832 | MonthViewItem *item ; |
853 | if ( mAvailItemList.count() ) { | 833 | if ( mAvailItemList.count() ) { |
854 | item = mAvailItemList.first(); | 834 | item = mAvailItemList.first(); |
855 | mAvailItemList.remove( item ); | 835 | mAvailItemList.remove( item ); |
856 | item->recycle( todo, mDate, text ); | 836 | item->recycle( todo, text ); |
857 | } else { | 837 | } else { |
858 | item = new MonthViewItem( todo, mDate, text ); | 838 | item = new MonthViewItem( todo, text ); |
859 | } | 839 | } |
860 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 840 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
861 | //item->setPalette( mStandardPalette ); | 841 | //item->setPalette( mStandardPalette ); |
862 | QPalette pal; | 842 | QPalette pal; |
@@ -883,8 +863,9 @@ void MonthViewCell::insertTodo(Todo *todo) | |||
883 | 863 | ||
884 | } else { | 864 | } else { |
885 | pal = mStandardPalette ; | 865 | pal = mStandardPalette ; |
886 | } | 866 | } |
867 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | ||
887 | item->setPalette( pal ); | 868 | item->setPalette( pal ); |
888 | item->setRecur( todo->recurrence()->doesRecur() ); | 869 | item->setRecur( todo->recurrence()->doesRecur() ); |
889 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); | 870 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); |
890 | item->setMoreInfo( todo->description().length() > 0 ); | 871 | item->setMoreInfo( todo->description().length() > 0 ); |
@@ -1022,15 +1003,9 @@ QDate MonthViewCell::selectedIncidenceDate() | |||
1022 | { | 1003 | { |
1023 | QDate qd; | 1004 | QDate qd; |
1024 | int index = currentItem(); | 1005 | int index = currentItem(); |
1025 | if ( index < 0 ) return qd; | 1006 | if ( index < 0 ) return qd; |
1026 | 1007 | return mDate; | |
1027 | MonthViewItem *mitem = | ||
1028 | static_cast<MonthViewItem *>( item( index ) ); | ||
1029 | |||
1030 | if ( !mitem ) return qd; | ||
1031 | |||
1032 | return mitem->incidenceDate(); | ||
1033 | } | 1008 | } |
1034 | 1009 | ||
1035 | void MonthViewCell::deselect() | 1010 | void MonthViewCell::deselect() |
1036 | { | 1011 | { |