Branch 'kolab/integration/4.13.0' - 3 commits - calendarsupport/collectiongeneralpage.cpp calendarviews/prefs.cpp calendarviews/prefs.h korganizer/kohelper.cpp korganizer/kohelper.h korganizer/koprefs.cpp korganizer/koprefs.h korganizer/views

Christian Mollekopf mollekopf at kolabsys.com
Tue Dec 9 16:12:59 CET 2014


 calendarsupport/collectiongeneralpage.cpp            |   12 +++++----
 calendarviews/prefs.cpp                              |   22 +++++++++-------
 calendarviews/prefs.h                                |    1 
 korganizer/kohelper.cpp                              |   19 ++++++++++++++
 korganizer/kohelper.h                                |    2 +
 korganizer/koprefs.cpp                               |    5 +++
 korganizer/koprefs.h                                 |    1 
 korganizer/views/collectionview/calendardelegate.cpp |   25 ++++++++++++++++++-
 8 files changed, 72 insertions(+), 15 deletions(-)

New commits:
commit 744001e250ae3171f32850ddc423e87f70996095
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Mon Dec 1 13:13:34 2014 +0100

    default color of subcalendars same as the person folder
    
    KOLAB: #3624

diff --git a/calendarviews/prefs.cpp b/calendarviews/prefs.cpp
index ba25d9c..9f46e60 100644
--- a/calendarviews/prefs.cpp
+++ b/calendarviews/prefs.cpp
@@ -947,22 +947,26 @@ void Prefs::setResourceColor ( const QString &cal, const QColor &color )
   d->mBaseConfig.setResourceColor( cal, color );
 }
 
-QColor Prefs::resourceColor( const QString &cal )
+QColor Prefs::resourceColorKnown(const QString &cal)
 {
   QColor color;
-  if ( !cal.isEmpty() ) {
-    if ( d->mBaseConfig.mResourceColors.contains( cal ) ) {
+  if ( !cal.isEmpty()  &&
+      d->mBaseConfig.mResourceColors.contains( cal ) ) {
       color = d->mBaseConfig.mResourceColors.value( cal );
-      if ( !color.isValid() ) {
-        return color;
-      }
-    }
-  } else {
+  }
+  return color;
+}
+
+QColor Prefs::resourceColor( const QString &cal )
+{
+  if ( cal.isEmpty() ) {
     return d->mBaseConfig.mDefaultResourceColor;
   }
 
+  QColor color = resourceColorKnown(cal);
+
   // assign default color if enabled
-  if ( !cal.isEmpty() && !color.isValid() &&
+  if ( !color.isValid() &&
        d->getBool( d->mBaseConfig.assignDefaultResourceColorsItem() ) ) {
     QColor defColor( 0x37, 0x7A, 0xBC );
     const int seed = d->getInt( d->mBaseConfig.defaultResourceColorSeedItem() );
diff --git a/calendarviews/prefs.h b/calendarviews/prefs.h
index c210bd5..1c0aa03 100644
--- a/calendarviews/prefs.h
+++ b/calendarviews/prefs.h
@@ -154,6 +154,7 @@ class EVENTVIEWS_EXPORT Prefs
 
     void setResourceColor ( const QString &, const QColor & );
     QColor resourceColor( const QString & );
+    QColor resourceColorKnown( const QString & );
 
     void setTimeSpec( const KDateTime::Spec &spec );
     KDateTime::Spec timeSpec() const;
diff --git a/korganizer/kohelper.cpp b/korganizer/kohelper.cpp
index 2959b42..c114dfa 100644
--- a/korganizer/kohelper.cpp
+++ b/korganizer/kohelper.cpp
@@ -45,6 +45,25 @@ QColor KOHelper::resourceColor( const Akonadi::Collection &coll )
   return KOPrefs::instance()->resourceColor( id );
 }
 
+QColor KOHelper::resourceColorKnown( const Akonadi::Collection &coll )
+{
+  if ( !coll.isValid() ) {
+    return QColor();
+  }
+
+  const QString id = QString::number( coll.id() );
+  return KOPrefs::instance()->resourceColorKnown( id );
+}
+
+void KOHelper::setResourceColor(const Akonadi::Collection &collection, const QColor &color)
+{
+  if ( collection.isValid() ) {
+      const QString id = QString::number( collection.id() );
+      return KOPrefs::instance()->setResourceColor(id, color);
+  }
+}
+
+
 QColor KOHelper::resourceColor( const Akonadi::Item &item )
 {
   if ( !item.isValid() ) {
diff --git a/korganizer/kohelper.h b/korganizer/kohelper.h
index c83e448..4e8c559 100644
--- a/korganizer/kohelper.h
+++ b/korganizer/kohelper.h
@@ -58,6 +58,8 @@ namespace KOHelper {
   KORGANIZERPRIVATE_EXPORT QColor resourceColor( const Akonadi::Item &incidence );
 
   KORGANIZERPRIVATE_EXPORT QColor resourceColor( const Akonadi::Collection &collection );
+  KORGANIZERPRIVATE_EXPORT QColor resourceColorKnown( const Akonadi::Collection &collection );
+  KORGANIZERPRIVATE_EXPORT void setResourceColor( const Akonadi::Collection &collection, const QColor &color );
 
   /**
     Returns the number of years between the @p start QDate and the @p end QDate
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 93ac61c..60b41a2 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -112,6 +112,11 @@ QColor KOPrefs::resourceColor( const QString &cal )
   return mEventViewsPrefs->resourceColor( cal );
 }
 
+QColor KOPrefs::resourceColorKnown(const QString &cal)
+{
+  return mEventViewsPrefs->resourceColorKnown( cal );
+}
+
 QStringList KOPrefs::timeScaleTimezones() const
 {
   return mTimeScaleTimeZones;
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 03dff13..0a00c7d 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -59,6 +59,7 @@ class KORGANIZER_CORE_EXPORT KOPrefs : public KOPrefsBase
   public:
     void setResourceColor ( const QString &, const QColor & );
     QColor resourceColor( const QString & );
+    QColor resourceColorKnown( const QString & );
 
     void setHtmlExportFile( const QString &fileName );
     QString htmlExportFile() const;
diff --git a/korganizer/views/collectionview/calendardelegate.cpp b/korganizer/views/collectionview/calendardelegate.cpp
index 6633c93..c8b6a40 100644
--- a/korganizer/views/collectionview/calendardelegate.cpp
+++ b/korganizer/views/collectionview/calendardelegate.cpp
@@ -86,6 +86,18 @@ static bool isChildOfPersonCollection(const QModelIndex &index)
     return false;
 }
 
+static Akonadi::Collection personCollection(const QModelIndex &index)
+{
+    QModelIndex parent = index.parent();
+    while (parent.isValid()) {
+        if (parent.data(NodeTypeRole).toInt() == PersonNodeRole) {
+            return CalendarSupport::collectionFromIndex(parent);
+        }
+        parent = parent.parent();
+    }
+    return Akonadi::Collection();
+}
+
 static bool isPersonNode(const QModelIndex &index)
 {
     if (index.data(NodeTypeRole).toInt() == PersonNodeRole) {
@@ -168,7 +180,18 @@ void StyledCalendarDelegate::paint( QPainter * painter, const QStyleOptionViewIt
 
     //Color indicator
     if (opt.checkState){
-        QColor color = KOHelper::resourceColor(col);
+        QColor color = KOHelper::resourceColorKnown(col);
+        if (!color.isValid() && isChildOfPersonCollection(index)){
+            const Akonadi::Collection parentCol = personCollection(index);
+            if (parentCol.isValid()) {
+                color = KOHelper::resourceColor(parentCol);
+                KOHelper::setResourceColor(col, color);
+            } else {
+                color = KOHelper::resourceColor(col);
+            }
+        } else {
+             color = KOHelper::resourceColor(col);
+        }
         if (color.isValid()){
             painter->save();
             painter->setRenderHint(QPainter::Antialiasing);


commit 54771262a0cca0f51d7ce65035abfe5405f7f734
Merge: 1ea0b04 23f1552
Author: Christian Mollekopf <chrigi_1 at fastmail.fm>
Date:   Tue Dec 9 13:11:25 2014 +0100

    Merge remote-tracking branch 'kolab/dev/disable_notifications' into kolab/integration/4.13.0



commit 23f1552a2e46ef9f6fd8486072df2870c9965244
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Wed Dec 3 18:43:03 2014 +0100

    existance of the BlockAlarmAttribute != blocking alarms
    
    Check if all alarms are blocked, to activate the checkeckbox "block
    reminders locally". Background is, that we have to descide, if an user
    has set this value by his own or not.
    
    KOLAB: #3731

diff --git a/calendarsupport/collectiongeneralpage.cpp b/calendarsupport/collectiongeneralpage.cpp
index e82a23a..5e3d92c 100644
--- a/calendarsupport/collectiongeneralpage.cpp
+++ b/calendarsupport/collectiongeneralpage.cpp
@@ -113,7 +113,7 @@ void CollectionGeneralPage::load( const Akonadi::Collection &collection )
   const QString displayName = collection.displayName();
 
   mNameEdit->setText( displayName );
-  mBlockAlarmsCheckBox->setChecked( collection.hasAttribute<BlockAlarmsAttribute>() );
+  mBlockAlarmsCheckBox->setChecked( collection.hasAttribute<BlockAlarmsAttribute>() && collection.attribute<BlockAlarmsAttribute>()->isEverythingBlocked() );
 
   QString iconName;
   if ( collection.hasAttribute<EntityDisplayAttribute>() ) {
@@ -151,12 +151,14 @@ void CollectionGeneralPage::save( Collection &collection )
     collection.setName( mNameEdit->text() );
   }
 
-  if ( mBlockAlarmsCheckBox->isChecked() ) {
-    if ( !collection.hasAttribute<BlockAlarmsAttribute>() ) {
+  if ( !collection.hasAttribute<BlockAlarmsAttribute>() ) {
       collection.attribute<BlockAlarmsAttribute>( Collection::AddIfMissing );
-    }
+  }
+
+  if ( mBlockAlarmsCheckBox->isChecked() ) {
+      collection.attribute<BlockAlarmsAttribute>()->blockEverything(true);
   } else {
-    collection.removeAttribute<BlockAlarmsAttribute>();
+      collection.attribute<BlockAlarmsAttribute>()->blockEverything(false);
   }
 
 #ifndef KDEPIM_MOBILE_UI




More information about the commits mailing list