Commit 69737270 authored by David Jarvie's avatar David Jarvie

Purge archived calendar if needed, after setting new default calendar

parent dcf71d34
......@@ -157,7 +157,7 @@ KAlarmApp::KAlarmApp()
#ifdef USE_AKONADI
connect(AlarmCalendar::resources(), SIGNAL(atLoginEventAdded(KAEvent)), SLOT(atLoginEventAdded(KAEvent)));
connect(AkonadiModel::instance(), SIGNAL(collectionAdded(Akonadi::Collection)),
SLOT(slotCollectionAdded(Akonadi::Collection)));
SLOT(purgeNewArchivedDefault(Akonadi::Collection)));
#endif
KConfigGroup config(KGlobal::config(), "General");
......@@ -1033,10 +1033,11 @@ bool KAlarmApp::wantShowInSystemTray() const
#ifdef USE_AKONADI
/******************************************************************************
* Called when a new collection has been added.
* Called when a new collection has been added, or when a collection has been
* set as the standard collection for its type.
* If it is the default archived calendar, purge its old alarms if necessary.
*/
void KAlarmApp::slotCollectionAdded(const Akonadi::Collection& collection)
void KAlarmApp::purgeNewArchivedDefault(const Akonadi::Collection& collection)
{
Akonadi::Collection col(collection);
if (CollectionControlModel::isStandard(col, KAlarm::CalEvent::ARCHIVED))
......@@ -1055,9 +1056,6 @@ void KAlarmApp::slotCollectionAdded(const Akonadi::Collection& collection)
*/
void KAlarmApp::purgeAfterDelay()
{
#ifdef __GNUC__
#warning Purge after selecting a new default archived calendar
#endif
if (mArchivedPurgeDays >= 0)
purge(mArchivedPurgeDays);
else
......
......@@ -101,6 +101,7 @@ class KAlarmApp : public KUniqueApplication
void processQueue();
void setAlarmsEnabled(bool);
#ifdef USE_AKONADI
void purgeNewArchivedDefault(const Akonadi::Collection&);
void atLoginEventAdded(const KAEvent&);
#endif
void stopAudio();
......@@ -133,7 +134,6 @@ class KAlarmApp : public KUniqueApplication
void setArchivePurgeDays();
void slotPurge() { purge(mArchivedPurgeDays); }
#ifdef USE_AKONADI
void slotCollectionAdded(const Akonadi::Collection&);
void purgeAfterDelay();
#endif
void slotCommandExited(ShellProcess*);
......
......@@ -30,6 +30,7 @@
#ifdef USE_AKONADI
#include "akonadiresourcecreator.h"
#include "calendarmigrator.h"
#include "kalarmapp.h"
#else
#include "alarmresources.h"
#include "eventlistmodel.h"
......@@ -677,7 +678,10 @@ void ResourceSelector::archiveDaysChanged(int days)
{
Collection::List cols = CollectionControlModel::enabledCollections(KAlarm::CalEvent::ARCHIVED, true);
if (cols.count() == 1)
CollectionControlModel::setStandard(cols[1], KAlarm::CalEvent::ARCHIVED);
{
CollectionControlModel::setStandard(cols[0], KAlarm::CalEvent::ARCHIVED);
theApp()->purgeNewArchivedDefault(cols[0]);
}
}
#else
AlarmResources* resources = AlarmResources::instance();
......@@ -703,6 +707,8 @@ void ResourceSelector::setStandard()
if (standard)
CollectionControlModel::setEnabled(collection, alarmType, true);
CollectionControlModel::setStandard(collection, alarmType, standard);
if (alarmType == KAlarm::CalEvent::ARCHIVED)
theApp()->purgeNewArchivedDefault(collection);
}
#else
AlarmResource* resource = currentResource();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment