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

List:       kde-commits
Subject:    [kdepim] korganizer/korgac: Prevent KOrganizer from ignoring reminders that trigger during downtime
From:       Frank Roscher <Frank-Roscher () gmx ! net>
Date:       2012-10-29 18:27:51
Message-ID: 20121029182751.988BFA6078 () git ! kde ! org
[Download RAW message or body]

Git commit 7561d38cd6d233e2b55a7f3288ac9618337f25db by Frank Roscher.
Committed on 29/10/2012 at 19:22.
Pushed by froscher into branch 'master'.

Prevent KOrganizer from ignoring reminders that trigger during downtime

Wait for all collections to be populated before performing checks for reminders. \
Avoids the situation where KOrganizer thinks it has already checked for outstanding \
reminders in all collections even though it only looked at an uninitialized, empty \
list of collections.

BUG: 282535
FIXED-IN: 4.10
REVIEW: 106824
DIGEST: Makes KOrganizer reminders work reliably again for people who do not have KDE \
running 24/7. This was broken since the switch to Akonadi.

M  +25   -3    korganizer/korgac/koalarmclient.cpp
M  +2    -0    korganizer/korgac/koalarmclient.h

http://commits.kde.org/kdepim/7561d38cd6d233e2b55a7f3288ac9618337f25db

diff --git a/korganizer/korgac/koalarmclient.cpp \
b/korganizer/korgac/koalarmclient.cpp index 34e9a42..7bcd24d 100644
--- a/korganizer/korgac/koalarmclient.cpp
+++ b/korganizer/korgac/koalarmclient.cpp
@@ -37,6 +37,7 @@
 #include <Akonadi/Item>
 #include <Akonadi/ChangeRecorder>
 #include <Akonadi/Session>
+#include <Akonadi/Collection>
 #include <Akonadi/ItemFetchScope>
 #include <akonadi/dbusconnectionpool.h>
 
@@ -86,18 +87,20 @@ KOAlarmClient::KOAlarmClient( QObject *parent )
   monitor->setMimeTypeMonitored( KCalCore::Event::eventMimeType(), true );
   monitor->setMimeTypeMonitored( KCalCore::Todo::todoMimeType(), true );
   monitor->setMimeTypeMonitored( KCalCore::Journal::journalMimeType(), true );
-  CalendarSupport::CalendarModel *calendarModel = new \
CalendarSupport::CalendarModel( monitor, this ); +  mCalendarModel = new \
CalendarSupport::CalendarModel( monitor, this );  \
//mCalendarModel->setItemPopulationStrategy( EntityTreeModel::LazyPopulation );  
   KDescendantsProxyModel *flattener = new KDescendantsProxyModel(this);
-  flattener->setSourceModel( calendarModel );
+  flattener->setSourceModel( mCalendarModel );
 
-  mCalendar = new CalendarSupport::Calendar( calendarModel, flattener,
+  mCalendar = new CalendarSupport::Calendar( mCalendarModel, flattener,
                                      zone.isValid() ? KDateTime::Spec( zone ) : \
KDateTime::ClockTime );  
   mCalendar->setObjectName( "KOrgac's calendar" );
 
   connect( &mCheckTimer, SIGNAL(timeout()), SLOT(checkAlarms()) );
+  connect( mCalendarModel, SIGNAL(collectionPopulated(Akonadi::Collection::Id)), \
SLOT(checkAlarms()) ); +  connect( mCalendarModel, \
SIGNAL(collectionTreeFetched(Akonadi::Collection::List)), SLOT(checkAlarms()) );  
   KConfigGroup alarmGroup( KGlobal::config(), "Alarms" );
   const int interval = alarmGroup.readEntry( "Interval", 60 );
@@ -164,6 +167,25 @@ void KOAlarmClient::checkAlarms()
     return;
   }
 
+
+  // We do not want to miss any reminders, so don't perform check unless the list of \
collections is available. +  if ( !mCalendarModel->isCollectionTreeFetched() ) {
+    kDebug(5891) << "CollectionTree has not been fetched yet; aborting check.";
+    return;
+  }
+
+  // Collections also need to be populated if we want to be sure not to miss any \
reminders. +  const int rowCount = mCalendarModel->rowCount();
+  for ( int row = 0; row < rowCount; ++row ) {
+    static const int column = 0;
+    const QModelIndex index = mCalendarModel->index( row, column );
+    if ( !mCalendarModel->data( index, \
CalendarSupport::CalendarModel::IsPopulatedRole ).toBool() ) { +      kDebug(5891) << \
"Collections have not been populated yet; aborting check."; +      return;
+    }
+  }
+
+
   QDateTime from = mLastChecked.addSecs( 1 );
   mLastChecked = QDateTime::currentDateTime();
 
diff --git a/korganizer/korgac/koalarmclient.h b/korganizer/korgac/koalarmclient.h
index adc8cef..e16ea38 100644
--- a/korganizer/korgac/koalarmclient.h
+++ b/korganizer/korgac/koalarmclient.h
@@ -38,6 +38,7 @@ class AlarmDockWindow;
 
 namespace CalendarSupport {
   class Calendar;
+  class CalendarModel;
 }
 
 namespace Akonadi {
@@ -87,6 +88,7 @@ class KOAlarmClient : public QObject
 
     AlarmDockWindow *mDocker;  // the panel icon
     CalendarSupport::Calendar *mCalendar;
+    CalendarSupport::CalendarModel *mCalendarModel;
 
     QDateTime mLastChecked;
     QTimer mCheckTimer;


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

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