Branch 'kolab/integration/4.13.0' - calendarviews/agenda calendarviews/eventview.h

Sandro Knauß knauss at kolabsys.com
Fri Sep 26 16:30:10 CEST 2014


 calendarviews/agenda/agendaview.cpp |   14 ++++++++++----
 calendarviews/agenda/agendaview.h   |    7 +++++++
 calendarviews/eventview.h           |    2 ++
 3 files changed, 19 insertions(+), 4 deletions(-)

New commits:
commit 53ab02ea6da78952d35be57bc0e5a7bd67bfa905
Author: Sandro Knauß <knauss at kolabsys.com>
Date:   Fri Sep 26 16:24:22 2014 +0200

    CalendarViews: Merge with f192b4ecdc cleanups
    
    add comments what should be done in future and make code better
    readable.

diff --git a/calendarviews/agenda/agendaview.cpp b/calendarviews/agenda/agendaview.cpp
index b77b0b7..eddf0c7 100644
--- a/calendarviews/agenda/agendaview.cpp
+++ b/calendarviews/agenda/agendaview.cpp
@@ -416,7 +416,7 @@ void AgendaView::Private::calendarIncidenceAdded( const KCalCore::Incidence::Ptr
 
   if ( incidence->hasRecurrenceId() && mViewCalendar->isValid(incidence)) {
     // Reevaluate the main event instead, if it was inserted before this one
-    KCalCore::Incidence::Ptr mainIncidence = mViewCalendar->findCalendar(incidence)->getCalendar()->incidence( incidence->uid() );
+    KCalCore::Incidence::Ptr mainIncidence = q->calendar2(incidence)->incidence( incidence->uid() );
     if ( mainIncidence ) {
       reevaluateIncidence( mainIncidence );
     }
@@ -456,7 +456,7 @@ void AgendaView::Private::calendarIncidenceChanged( const KCalCore::Incidence::P
 
     if ( incidence->hasRecurrenceId() && mViewCalendar->isValid(incidence) ) {
     // Reevaluate the main event instead, if it exists
-    KCalCore::Incidence::Ptr mainIncidence = mViewCalendar->findCalendar(incidence)->getCalendar()->incidence( incidence->uid() );
+    KCalCore::Incidence::Ptr mainIncidence = q->calendar2(incidence)->incidence( incidence->uid() );
     reevaluateIncidence( mainIncidence ? mainIncidence : incidence );
   } else {
     reevaluateIncidence( incidence );
@@ -480,7 +480,7 @@ void AgendaView::Private::calendarIncidenceDeleted( const KCalCore::Incidence::P
     // Reevaluate the main event, if it exists. The exception was removed so the main recurrent series
     // will no be bigger.
     if ( mViewCalendar->isValid(incidence) ) {
-      KCalCore::Incidence::Ptr mainIncidence = mViewCalendar->findCalendar(incidence)->getCalendar()->incidence( incidence->uid() );
+      KCalCore::Incidence::Ptr mainIncidence = q->calendar2(incidence)->incidence( incidence->uid() );
       if ( mainIncidence ) {
         reevaluateIncidence( mainIncidence  );
       }
@@ -840,6 +840,12 @@ AgendaView::~AgendaView()
   delete d;
 }
 
+KCalCore::Calendar::Ptr AgendaView::calendar2(KCalCore::Incidence::Ptr incidence) const
+{
+  return d->mViewCalendar->findCalendar(incidence)->getCalendar();
+}
+
+
 void AgendaView::setCalendar( const Akonadi::ETMCalendar::Ptr &cal )
 {
   if ( calendar() ) {
@@ -2174,7 +2180,7 @@ void AgendaView::removeIncidence( const KCalCore::Incidence::Ptr &incidence )
   d->mAgenda->removeIncidence( incidence );
 
   if ( !incidence->hasRecurrenceId() && d->mViewCalendar->isValid(incidence)) {
-    KCalCore::Incidence::List exceptions = d->mViewCalendar->findCalendar(incidence)->getCalendar()->instances( incidence );
+    KCalCore::Incidence::List exceptions = calendar2(incidence)->instances( incidence );
     foreach ( const KCalCore::Incidence::Ptr &exception, exceptions ) {
       if ( exception->allDay() ) {
         d->mAllDayAgenda->removeIncidence( exception );
diff --git a/calendarviews/agenda/agendaview.h b/calendarviews/agenda/agendaview.h
index e8e0b99..03b49f6 100644
--- a/calendarviews/agenda/agendaview.h
+++ b/calendarviews/agenda/agendaview.h
@@ -155,6 +155,13 @@ class EVENTVIEWS_EXPORT AgendaView : public EventView
 
     QVector<bool> busyDayMask() const;
 
+    /**
+     * Return calendar object for an congrete incidence.
+     * this function is able to use mutiple calenders
+     * TODO: replace EventsView::calendar()
+     */
+    virtual KCalCore::Calendar::Ptr calendar2(KCalCore::Incidence::Ptr incidence) const;
+
   public slots:
     virtual void updateView();
     virtual void updateConfig();
diff --git a/calendarviews/eventview.h b/calendarviews/eventview.h
index 583f2e5..4e31b06 100644
--- a/calendarviews/eventview.h
+++ b/calendarviews/eventview.h
@@ -142,6 +142,8 @@ class EVENTVIEWS_EXPORT EventView : public QWidget
 
     /**
       Return calendar object of this view.
+      TODO: replace with a version that returns a KCalcCore::Calendar to be able to use it in different enviroments
+           see agendaview for example calendar2(incidence)
     */
     virtual Akonadi::ETMCalendar::Ptr calendar() const;
 




More information about the commits mailing list