Commit 2b33f98e authored by David Jarvie's avatar David Jarvie

Make at-login alarm work with Akonadi.

The alarm queue is initialised before Akonadi collections are
populated, so repeat-at-login alarms now have to be triggered when they
are added to AkonadiModel.
parent 4e51bd0b
......@@ -710,12 +710,17 @@ void AlarmCalendar::slotEventsAdded(const AkonadiModel::EventList& events)
*/
void AlarmCalendar::slotEventChanged(const AkonadiModel::Event& event)
{
if (mEventMap.contains(event.event.id()))
bool added = mEventMap.contains(event.event.id());
if (added)
updateEventInternal(event.event, event.collection);
else
addNewEvent(event.collection, new KAEvent(event.event));
bool enabled = event.event.enabled();
checkForDisabledAlarms(!enabled, enabled);
if (enabled && event.event.category() == KAlarm::CalEvent::ACTIVE
&& event.event.repeatAtLogin())
emit atLoginEventAdded(event.event);
}
/******************************************************************************
......
......@@ -134,6 +134,9 @@ class AlarmCalendar : public QObject
signals:
void earliestAlarmChanged();
void haveDisabledAlarmsChanged(bool haveDisabled);
#ifdef USE_AKONADI
void atLoginEventAdded(const KAEvent&);
#endif
void calendarSaved(AlarmCalendar*);
private slots:
......
......@@ -152,6 +152,7 @@ KAlarmApp::KAlarmApp()
if (AlarmCalendar::initialiseCalendars())
{
connect(AlarmCalendar::resources(), SIGNAL(earliestAlarmChanged()), SLOT(checkNextDueAlarm()));
connect(AlarmCalendar::resources(), SIGNAL(atLoginEventAdded(const KAEvent&)), SLOT(atLoginEventAdded(const KAEvent&)));
KConfigGroup config(KGlobal::config(), "General");
mNoSystemTray = config.readEntry("NoSystemTray", false);
......@@ -810,6 +811,22 @@ void KAlarmApp::processQueue()
}
}
#ifdef USE_AKONADI
/******************************************************************************
* Called when a repeat-at-login alarm has been added externally.
* Queues it for triggering.
*/
void KAlarmApp::atLoginEventAdded(const KAEvent& event)
{
if (mAlarmsEnabled)
{
mDcopQueue.enqueue(DcopQEntry(EVENT_HANDLE, event.id()));
if (mInitialised)
QTimer::singleShot(0, this, SLOT(processQueue()));
}
}
#endif
/******************************************************************************
* Called when the system tray main window is closed.
*/
......
/*
* kalarmapp.h - the KAlarm application object
* Program: kalarm
* Copyright © 2001-2010 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2011 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -94,6 +94,9 @@ class KAlarmApp : public KUniqueApplication
public slots:
void processQueue();
void setAlarmsEnabled(bool);
#ifdef USE_AKONADI
void atLoginEventAdded(const KAEvent&);
#endif
void stopAudio();
void spreadWindows(bool);
void emailSent(KAMail::JobData&, const QStringList& errmsgs, bool copyerr = false);
......
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