[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdepim/enterprise/kdepim/korganizer
From:       Sergio Luis Martins <iamsergio () gmail ! com>
Date:       2010-10-13 13:44:21
Message-ID: 20101013134421.945A8AC895 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1185490 by smartins:

Finish kolab/issue4259.

"All-day event (marked as busy) should set background color for the whole day."

( implemented this in monthview )

MERGE: trunk

 M  +1 -13     koagenda.cpp  
 M  +3 -0      koeventview.h  
 M  +11 -0     kohelper.cpp  
 M  +4 -0      kohelper.h  
 M  +52 -10    komonthview.cpp  
 M  +2 -1      komonthview.h  


--- branches/kdepim/enterprise/kdepim/korganizer/koagenda.cpp #1185489:1185490
@@ -62,18 +62,6 @@
 #include <libkcal/calhelper.h>
 #include <math.h>
 
-
-static QColor mixColors( const QColor &transparentColor,
-                         double alpha,
-                         const QColor &otherColor )
-{
-  const int red = ( 1 - alpha )*otherColor.red() + alpha*transparentColor.red();
-  const int green = ( 1 - alpha )*otherColor.green() + \
                alpha*transparentColor.green();
-  const int blue = ( 1 - alpha )*otherColor.blue() + alpha*transparentColor.blue();
-
-  return QColor( red, green, blue );
-}
-
 static void freeItemList( const AgendaItemList &list )
 {
   AgendaItemList::ConstIterator it;
@@ -1437,7 +1425,7 @@
     QColor workAndBusyColor;
 
     if ( KOPrefs::instance()->mColorBusyDaysEnabled ) {
-      workAndBusyColor = mixColors( KOPrefs::instance()->mAgendaMonthBgBusyColor, \
0.60, KOPrefs::instance()->mWorkingHoursColor ); +      workAndBusyColor = \
KOHelper::mixColors( KOPrefs::instance()->mAgendaMonthBgBusyColor, 0.60, \
KOPrefs::instance()->mWorkingHoursColor );  } else {
       workAndBusyColor = KOPrefs::instance()->mWorkingHoursColor;
     }
--- branches/kdepim/enterprise/kdepim/korganizer/koeventview.h #1185489:1185490
@@ -92,6 +92,9 @@
 
     bool supportsDateNavigation() const { return true; }
 
+    QMap<QDate, KCal::Event::List >  busyDays() const { return mBusyDays; }
+    void setBusyDays( const QMap<QDate, KCal::Event::List > &days ) { mBusyDays = \
days; } +
   public slots:
 
     /**
--- branches/kdepim/enterprise/kdepim/korganizer/kohelper.cpp #1185489:1185490
@@ -34,6 +34,17 @@
 #include "koprefs.h"
 #include "kohelper.h"
 
+QColor KOHelper::mixColors( const QColor &transparentColor,
+                            double alpha,
+                            const QColor &otherColor )
+{
+  const int red = ( 1 - alpha )*otherColor.red() + alpha*transparentColor.red();
+  const int green = ( 1 - alpha )*otherColor.green() + \
alpha*transparentColor.green(); +  const int blue = ( 1 - alpha )*otherColor.blue() + \
alpha*transparentColor.blue(); +
+  return QColor( red, green, blue );
+}
+
 QColor KOHelper::resourceColor( KCal::Calendar*calendar, KCal::Incidence*incidence )
 {
   QColor resourceColor = QColor(); //Default invalid color
--- branches/kdepim/enterprise/kdepim/korganizer/kohelper.h #1185489:1185490
@@ -42,6 +42,10 @@
       to a subresource, the color for the subresource is returned (if set).
     */
     static QColor resourceColor( KCal::Calendar*calendar, KCal::Incidence*incidence \
); +
+    static QColor mixColors( const QColor &transparentColor, double alpha,
+                             const QColor &otherColor );
+
 };
 
 #endif
--- branches/kdepim/enterprise/kdepim/korganizer/komonthview.cpp #1185489:1185490
@@ -97,8 +97,10 @@
   setPalette( pal );
 }
 
-void KNoScrollListBox::setBackground( bool primary, bool workDay )
+void KNoScrollListBox::setBackground( bool primary, bool workDay, bool busyDay )
 {
+  busyDay = busyDay && KOPrefs::instance()->mColorMonthBusyDaysEnabled;
+
   QColor color;
   if ( workDay ) {
     color = KOPrefs::instance()->workingHoursColor();
@@ -107,11 +109,15 @@
   }
 
   QPalette pal = palette();
-  if ( primary ) {
+  if ( !primary ) {
+    color = color.dark( 115 );
+  }
+
+  if ( busyDay ) {
+    color = KOHelper::mixColors( KOPrefs::instance()->mAgendaMonthBgBusyColor, 0.60, \
color ); +  }
+
     pal.setColor( QColorGroup::Base, color );
-  } else {
-    pal.setColor( QColorGroup::Base, color.dark( 115 ) );
-  }
   setPalette( pal );
 }
 
@@ -476,7 +482,8 @@
     mLabel->setBackgroundMode( PaletteBackground );
   }
 
-  mItemList->setBackground( mPrimary, KOGlobals::self()->isWorkDay( mDate ) );
+  const bool busyDay = !mMonthView->busyDays()[date()].isEmpty();
+  mItemList->setBackground( mPrimary, KOGlobals::self()->isWorkDay( mDate ), busyDay \
);  }
 
 bool MonthViewCell::isPrimary() const
@@ -510,8 +517,7 @@
     QPalette pal = mItemList->palette();
     pal.setColor( QColorGroup::Foreground, KOPrefs::instance()->highlightColor() );
     mItemList->setPalette( pal );
-  }
-  else {
+  } else {
     if ( mHoliday )
       setPalette( mHolidayPalette );
     else
@@ -637,6 +643,10 @@
 
 void MonthViewCell::addIncidence( Incidence *incidence, CreateItemVisitor& v, int \
multiDay )  {
+  // So busy color is applied
+  const bool busyDay = !mMonthView->busyDays()[date()].isEmpty();
+  mItemList->setBackground( mPrimary, KOGlobals::self()->isWorkDay( mDate ), busyDay \
); +
   if ( v.act( incidence, mDate, mStandardPalette, multiDay ) ) {
     MonthViewItem *item = v.item();
     if ( item ) {
@@ -670,16 +680,40 @@
 
 void MonthViewCell::removeIncidence( Incidence *incidence )
 {
+  bool mustUpdateBackground = false;
+
   for ( uint i = 0; i < mItemList->count(); ++i ) {
     MonthViewItem *item = static_cast<MonthViewItem *>(mItemList->item( i ) );
     if ( item && item->incidence() &&
          item->incidence()->uid() == incidence->uid() ) {
+
+      QMap<QDate, KCal::Event::List > busyDays =  mMonthView->busyDays();
+      if ( busyDays.contains( date() ) ) {
+
+        Event::List &list = busyDays[date()];
+
+        Event::List::Iterator it;
+        for ( it = list.begin(); it != list.end(); ++it ) {
+          if ( (*it)->uid() == incidence->uid() ) {
+            mustUpdateBackground = true;
+            it = list.remove( it );
+          }
+        }
+        mMonthView->setBusyDays( busyDays );
+      }
+
       mItemList->removeItem( i );
       --i;
     }
   }
+
+  if ( mustUpdateBackground ) {
+    const bool busyDay = !mMonthView->busyDays()[date()].isEmpty();
+    mItemList->setBackground( mPrimary, KOGlobals::self()->isWorkDay( mDate ), \
busyDay );  }
 
+}
+
 void MonthViewCell::updateConfig()
 {
   setFont( KOPrefs::instance()->mMonthViewFont );
@@ -707,14 +741,17 @@
                             KOPrefs::instance()->holidayColor() );
   mHolidayPalette.setColor( QColorGroup::Text,
                             KOPrefs::instance()->holidayColor() );
+
   mTodayPalette = mStandardPalette;
   mTodayPalette.setColor( QColorGroup::Foreground,
                           KOPrefs::instance()->highlightColor() );
   mTodayPalette.setColor( QColorGroup::Text,
                           KOPrefs::instance()->highlightColor() );
+
   updateCell();
 
-  mItemList->setBackground( mPrimary, KOGlobals::self()->isWorkDay( mDate ) );
+  const bool busyDay = !mMonthView->busyDays()[date()].isEmpty();
+  mItemList->setBackground( mPrimary, KOGlobals::self()->isWorkDay( mDate ), busyDay \
);  }
 
 void MonthViewCell::enableScrollBars( bool enabled )
@@ -1095,8 +1132,12 @@
       if ( incidence->recursOn( mCells[i]->date() ) ) {
 
         // handle multiday events
-        int length = gdv.startDate().daysTo( gdv.endDate().addSecs( floats ? 0 : -1 \
).date() ); +        const int length = gdv.startDate().daysTo( \
gdv.endDate().addSecs( floats ? 0 : -1 ).date() );  for ( int j = 0; j <= length && \
i+j < mCells.count(); ++j ) { +          if ( makesItBusy ) {
+            Event::List &busyEvents = mBusyDays[mCells[i+j]->date()];
+            busyEvents.append( static_cast<Event*>( incidence ) );
+          }
           mCells[i+j]->addIncidence( incidence, v, j );
         }
       }
@@ -1143,6 +1184,7 @@
 
 void KOMonthView::updateView()
 {
+  mBusyDays.clear();
   for( uint i = 0; i < mCells.count(); ++i ) {
     mCells[i]->updateCell();
   }
--- branches/kdepim/enterprise/kdepim/korganizer/komonthview.h #1185489:1185490
@@ -55,7 +55,7 @@
     KNoScrollListBox(QWidget *parent=0, const char *name=0);
     ~KNoScrollListBox() {}
 
-    void setBackground( bool primary, bool workday );
+    void setBackground( bool primary, bool workday, bool busyDay );
 
   signals:
     void shiftDown();
@@ -161,6 +161,7 @@
 
     /** Make this cell show as a holiday */
     void setHoliday( bool );
+
     /**
       Sets the holiday name to this cell. This will not call
       setHoliday( true ).


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic