Branch 'kolab/integration/4.13.0' - 3 commits - akonadi/calendar kcalcore/event.cpp

Sandro Knauß knauss at kolabsys.com
Thu Sep 25 13:01:25 CEST 2014


 akonadi/calendar/calendarmodel.cpp                   |   12 ++--------
 akonadi/calendar/calfilterpartstatusproxymodel_p.cpp |    4 +--
 akonadi/calendar/calfilterproxymodel_p.cpp           |    5 ++--
 kcalcore/event.cpp                                   |   22 +++++++++++--------
 4 files changed, 21 insertions(+), 22 deletions(-)

New commits:
commit 76cd423e2fb78b2852d29c3ad3765b2edc9f69c5
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Thu Sep 25 12:57:38 2014 +0200

    calfilterpartstatusproxy: alendarUtilits::incidence
    
    (merge with fd0b82b0 for kdepimlibs master)

diff --git a/akonadi/calendar/calfilterpartstatusproxymodel_p.cpp b/akonadi/calendar/calfilterpartstatusproxymodel_p.cpp
index 648f9a2..9f71cdc 100644
--- a/akonadi/calendar/calfilterpartstatusproxymodel_p.cpp
+++ b/akonadi/calendar/calfilterpartstatusproxymodel_p.cpp
@@ -94,11 +94,11 @@ bool CalFilterPartStatusProxyModel::filterAcceptsRow(int source_row, const QMode
         return false;
 
     const Akonadi::Item item = idx.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
-    if (!item.isValid() || !item.hasPayload<KCalCore::Incidence::Ptr>()) {
+    if (!item.isValid()) {
         return false;
     }
 
-    const KCalCore::Incidence::Ptr incidence = item.payload<KCalCore::Incidence::Ptr>();
+    const KCalCore::Incidence::Ptr incidence = CalendarUtils::incidence(item);
     if (!incidence) {
         return false;
     }


commit 5f2872fb83df95ebcc628f88a19ed8d23b04dbd2
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Thu Sep 25 12:55:39 2014 +0200

    Akonadi::Calendar: Using CalendarUtilits::incidence
    
    this is ~twices as fast as using hasPayload + payload

diff --git a/akonadi/calendar/calendarmodel.cpp b/akonadi/calendar/calendarmodel.cpp
index 93c8f5e..3a22509 100644
--- a/akonadi/calendar/calendarmodel.cpp
+++ b/akonadi/calendar/calendarmodel.cpp
@@ -20,6 +20,8 @@
 
 #include "calendarmodel_p.h"
 
+#include "utils_p.h"
+
 #include <akonadi/changerecorder.h>
 #include <akonadi/itemfetchscope.h>
 #include <kcalcore/event.h>
@@ -33,14 +35,6 @@
 
 using namespace Akonadi;
 
-static KCalCore::Incidence::Ptr incidence(const Akonadi::Item &item)
-{
-    return
-        item.hasPayload<KCalCore::Incidence::Ptr>() ?
-        item.payload<KCalCore::Incidence::Ptr>() :
-        KCalCore::Incidence::Ptr();
-}
-
 static KCalCore::Todo::Ptr todo(const Akonadi::Item &item)
 {
     return
@@ -91,7 +85,7 @@ void CalendarModel::setWeakPointer(const QWeakPointer<CalendarModel> &weakPointe
 
 QVariant CalendarModel::entityData(const Akonadi::Item &item, int column, int role) const
 {
-    const KCalCore::Incidence::Ptr inc = incidence(item);
+    const KCalCore::Incidence::Ptr inc = CalendarUtils::incidence(item);
     if (!inc) {
         return QVariant();
     }
diff --git a/akonadi/calendar/calfilterproxymodel_p.cpp b/akonadi/calendar/calfilterproxymodel_p.cpp
index b4193e0..c15591f 100644
--- a/akonadi/calendar/calfilterproxymodel_p.cpp
+++ b/akonadi/calendar/calfilterproxymodel_p.cpp
@@ -19,6 +19,7 @@
 */
 
 #include "calfilterproxymodel_p.h"
+#include "utils_p.h"
 
 #include <akonadi/item.h>
 #include <akonadi/entitytreemodel.h>
@@ -70,10 +71,10 @@ bool CalFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &so
         return false;
 
     const Akonadi::Item item = idx.data(Akonadi::EntityTreeModel::ItemRole).value<Akonadi::Item>();
-    if (!item.isValid() || !item.hasPayload<KCalCore::Incidence::Ptr>())
+    if (!item.isValid())
         return false;
 
-    const KCalCore::Incidence::Ptr incidence = item.payload<KCalCore::Incidence::Ptr>();
+    const KCalCore::Incidence::Ptr incidence = CalendarUtils::incidence(item);
     if (!incidence)
         return false;
 


commit e765065074b0b838da8e1838c5aca8a62701e5ba
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Thu Sep 25 12:26:53 2014 +0200

    KCalCore: event::isMutliDay was never using the cache
    
    mostly it is called with no argument, so spec is invalid
    
    * most of the time was spent in KDateTime.addSecs(-1), it is a realy
      rarce case, that this second is import.
    
    Solution: Test if the second can be important before executiing time
    intensive function.
    
    ~5% performance boost

diff --git a/kcalcore/event.cpp b/kcalcore/event.cpp
index 9057cdf..8056b13 100644
--- a/kcalcore/event.cpp
+++ b/kcalcore/event.cpp
@@ -213,20 +213,24 @@ bool Event::isMultiDay(const KDateTime::Spec &spec) const
         end = dtEnd().toTimeSpec(spec);
     }
 
-    // End date is non inclusive, so subtract 1 second... except if we
-    // got the event from some braindead implementation which gave us
-    // start == end one (those do happen)
-    if (start != end) {
-        end = end.addSecs(-1);
-    }
+    bool multi = (start < end && start.date() != end.date());
 
-    const bool multi = (start.date() != end.date() && start <= end);
+    // End date is non inclusive
+    // If we have an incidence that duration is one day and ends with a start of a new day
+    // than it is not a multiday event
+    if (multi && end.time() != QTime(0,0,0)) {
+        multi = start.daysTo(end) > 1;
+    }
 
     // Update the cache
-    if (spec.isValid()) {
+    // Also update Cache if spec is invalid
+    /*if (spec.isValid()) {
         d->mMultiDayValid = true;
         d->mMultiDay = multi;
-    }
+    } */
+
+    d->mMultiDayValid = true;
+    d->mMultiDay = multi;
     return multi;
 }
 




More information about the commits mailing list