21 #ifndef ALARMCALENDAR_H
22 #define ALARMCALENDAR_H
28 #include "alarmresources.h"
31 #include <kalarmcal/kaevent.h>
34 #include <akonadi/collection.h>
35 #include <kcalcore/filestorage.h>
36 #include <kcalcore/event.h>
51 using namespace KAlarmCal;
63 bool valid()
const {
return (mCalType == RESOURCES) || mUrl.isValid(); }
64 CalEvent::Type
type()
const {
return (mCalType == RESOURCES) ? CalEvent::EMPTY : mEventType; }
69 void loadResource(AlarmResource*,
QWidget* parent);
70 void reloadFromCache(
const QString& resourceID);
76 KAEvent* earliestAlarm()
const;
77 void setAlarmPending(KAEvent*,
bool pending =
true);
79 void disabledChanged(
const KAEvent*);
80 KAEvent::List atLoginAlarms()
const;
82 KCalCore::Event::Ptr kcalEvent(
const QString& uniqueID);
83 KAEvent* event(
const EventId& uniqueId,
bool checkDuplicates =
false);
86 {
return createKCalEvent(e,
QString()); }
87 KCal::Event* kcalEvent(
const QString& uniqueId);
88 KAEvent* event(
const QString& uniqueId);
90 KAEvent* templateEvent(
const QString& templateName);
92 KAEvent::List events(
const QString& uniqueId)
const;
93 KAEvent::List events(CalEvent::Types s = CalEvent::EMPTY)
const {
return events(Akonadi::Collection(), s); }
94 KAEvent::List events(
const Akonadi::Collection&, CalEvent::Types = CalEvent::EMPTY)
const;
96 KAEvent::List
events(CalEvent::Types s = CalEvent::EMPTY)
const {
return events(0, s); }
97 KAEvent::List events(AlarmResource*, CalEvent::Types = CalEvent::EMPTY)
const;
98 KAEvent::List events(
const KDateTime&
from,
const KDateTime&
to, CalEvent::Types);
101 KCalCore::Event::List kcalEvents(CalEvent::Type s = CalEvent::EMPTY);
102 bool eventReadOnly(Akonadi::Item::Id)
const;
103 Akonadi::Collection collectionForEvent(Akonadi::Item::Id)
const;
104 bool addEvent(KAEvent&,
QWidget* promptParent = 0,
bool useEventID =
false, Akonadi::Collection* = 0,
bool noPrompt =
false,
bool* cancelled = 0);
105 bool modifyEvent(
const EventId& oldEventId, KAEvent& newEvent);
108 KCal::Event::List kcalEvents(AlarmResource*, CalEvent::Type = CalEvent::EMPTY);
109 bool eventReadOnly(
const QString& uniqueID)
const;
110 AlarmResource* resourceForEvent(
const QString& eventID)
const;
111 bool addEvent(KAEvent*,
QWidget* promptParent = 0,
bool useEventID =
false, AlarmResource* = 0,
bool noPrompt =
false,
bool* cancelled = 0);
112 bool modifyEvent(
const QString& oldEventId, KAEvent* newEvent);
114 KAEvent* updateEvent(
const KAEvent&);
115 KAEvent* updateEvent(
const KAEvent*);
117 bool deleteEvent(
const KAEvent&,
bool save =
false);
118 bool deleteDisplayEvent(
const QString& eventID,
bool save =
false);
120 bool deleteEvent(
const QString& eventID,
bool save =
false);
122 void purgeEvents(
const KAEvent::List&);
126 void adjustStartOfDay();
128 static bool initialiseCalendars();
129 static void terminateCalendars();
134 static KAEvent* getEvent(
const EventId&);
135 static bool importAlarms(
QWidget*, Akonadi::Collection* = 0);
137 static KAEvent* getEvent(
const QString& uniqueId);
138 static bool importAlarms(
QWidget*, AlarmResource* = 0);
140 static bool exportAlarms(
const KAEvent::List&,
QWidget* parent);
143 void earliestAlarmChanged();
144 void haveDisabledAlarmsChanged(
bool haveDisabled);
146 void atLoginEventAdded(
const KAEvent&);
151 void setAskResource(
bool ask);
154 const QVariant& value,
bool inserted);
159 void slotCacheDownloaded(AlarmResource*);
160 void slotResourceLoaded(AlarmResource*,
bool success);
161 void slotResourceChange(AlarmResource*, AlarmResources::Change);
165 enum CalType { RESOURCES, LOCAL_ICAL, LOCAL_VCAL };
180 bool isValid()
const {
return mCalType == RESOURCES || mCalendarStorage; }
181 void addNewEvent(
const Akonadi::Collection&, KAEvent*,
bool replace =
false);
182 CalEvent::Type deleteEventInternal(
const KAEvent&,
bool deleteFromAkonadi =
true);
183 CalEvent::Type deleteEventInternal(
const KAEvent&,
const Akonadi::Collection&,
184 bool deleteFromAkonadi =
true);
185 CalEvent::Type deleteEventInternal(
const QString& eventID,
const KAEvent& = KAEvent(),
186 const Akonadi::Collection& = Akonadi::Collection(),
bool deleteFromAkonadi =
true);
187 void updateDisplayKAEvents();
188 void removeKAEvents(Akonadi::Collection::Id,
bool closing =
false, CalEvent::Types = CalEvent::ACTIVE | CalEvent::ARCHIVED | CalEvent::TEMPLATE);
189 void findEarliestAlarm(
const Akonadi::Collection&);
190 void findEarliestAlarm(Akonadi::Collection::Id);
192 bool isValid()
const {
return mCalendar; }
193 bool addEvent(AlarmResource*, KAEvent*);
194 KAEvent* addEvent(AlarmResource*,
const KCal::Event*);
195 void addNewEvent(AlarmResource*, KAEvent*);
196 CalEvent::Type deleteEventInternal(
const QString& eventID);
197 void updateKAEvents(AlarmResource*, KCal::CalendarLocal*);
198 static void updateResourceKAEvents(AlarmResource*, KCal::CalendarLocal*);
199 void removeKAEvents(AlarmResource*,
bool closing =
false);
200 void findEarliestAlarm(AlarmResource*);
201 KCal::Event* createKCalEvent(
const KAEvent*,
const QString& baseID)
const;
203 void checkForDisabledAlarms();
204 void checkForDisabledAlarms(
bool oldEnabled,
bool newEnabled);
210 KCalCore::FileStorage::Ptr mCalendarStorage;
212 KCal::Calendar* mCalendar;
214 ResourceMap mResourceMap;
215 KAEventMap mEventMap;
216 EarliestMap mEarliestAlarm;
223 ProgressDlgMap mProgressDlgs;
224 ResourceWidgetMap mProgressParents;
228 CalEvent::Type mEventType;
232 bool mHaveDisabledAlarms;
237 #endif // ALARMCALENDAR_H
CalEvent::Type type() const
static AlarmCalendar * resources()
bool haveDisabledAlarms() const
QString urlString() const
virtual bool event(QEvent *e)
Struct containing a KAEvent and its parent Collection.
KCal::Event * createKCalEvent(const KAEvent *e) const
Unique event identifier for Akonadi.
KCal::Event::List kcalEvents(CalEvent::Type s=CalEvent::EMPTY)
Provides read and write access to calendar files and resources.
KAEvent::List events(CalEvent::Types s=CalEvent::EMPTY) const
static AlarmCalendar * displayCalendar()