This class provides a calendar storage interface. More...
#include <extendedstorage.h>
Public Types | |
enum | DeleteAction { MarkDeleted , PurgeDeleted } |
Action to be performed on save for deleted incidences. More... | |
typedef QSharedPointer< ExtendedStorage > | Ptr |
A shared pointer to a ExtendedStorage. | |
Public Member Functions | |
ExtendedStorage (const ExtendedCalendar::Ptr &cal, bool validateNotebooks=true) | |
Constructs a new ExtendedStorage object. | |
virtual | ~ExtendedStorage () |
Destructor. | |
virtual bool | open ()=0 |
virtual bool | load ()=0 |
virtual bool | load (const QString &uid, const QDateTime &recurrenceId=QDateTime())=0 |
Load incidence by uid into the memory. | |
virtual bool | load (const QDate &date)=0 |
Load incidences at given date into the memory. | |
virtual bool | load (const QDate &start, const QDate &end)=0 |
Load incidences between given dates into the memory. | |
virtual bool | loadSeries (const QString &uid)=0 |
Load all incidences sharing the same uid into the memory. | |
virtual bool | loadIncidenceInstance (const QString &instanceIdentifier)=0 |
Load the incidence matching the given identifier. | |
virtual bool | loadNotebookIncidences (const QString ¬ebookUid)=0 |
Load incidences of one notebook into the memory. | |
virtual bool | loadJournals ()=0 |
Load journal type entries. | |
virtual bool | loadPlainIncidences ()=0 |
Load plain incidences (no startdate and no enddate). | |
virtual bool | loadRecurringIncidences ()=0 |
Load recurring incidences. | |
virtual bool | loadGeoIncidences ()=0 |
Load incidences that have geo parameters. | |
virtual bool | loadGeoIncidences (float geoLatitude, float geoLongitude, float diffLatitude, float diffLongitude)=0 |
Load incidences that have geo parameters inside given rectangle. | |
virtual bool | loadAttendeeIncidences ()=0 |
Load incidences that have attendee. | |
virtual int | loadUncompletedTodos ()=0 |
Load all uncompleted todos. | |
virtual int | loadCompletedTodos (bool hasDate, int limit, QDateTime *last)=0 |
Load completed todos based on parameters. | |
virtual int | loadIncidences (bool hasDate, int limit, QDateTime *last)=0 |
Load incidences based on start/due date or creation date. | |
virtual int | loadFutureIncidences (int limit, QDateTime *last)=0 |
Load future incidences based on start/due date. | |
virtual int | loadGeoIncidences (bool hasDate, int limit, QDateTime *last)=0 |
Load incidences that have location information based on parameters. | |
virtual KCalendarCore::Person::List | loadContacts ()=0 |
Load all contacts in the database. | |
virtual int | loadContactIncidences (const KCalendarCore::Person &person, int limit, QDateTime *last)=0 |
Load all incidences that have the specified attendee. | |
virtual int | loadJournals (int limit, QDateTime *last)=0 |
Load journal entries based on parameters. | |
virtual bool | purgeDeletedIncidences (const KCalendarCore::Incidence::List &list)=0 |
Remove from storage all incidences that have been previously marked as deleted and that matches the UID / RecID of the incidences in list. | |
virtual bool | save ()=0 |
virtual bool | save (DeleteAction deleteAction)=0 |
This is an overload of save() method. | |
virtual bool | notifyOpened (const KCalendarCore::Incidence::Ptr &incidence)=0 |
Mark if supported by the storage that an incidence has been opened. | |
virtual bool | cancel ()=0 |
Cancel any ongoing action (load etc.). | |
virtual bool | close () |
virtual void | calendarModified (bool modified, KCalendarCore::Calendar *calendar)=0 |
virtual void | calendarIncidenceAdded (const KCalendarCore::Incidence::Ptr &incidence)=0 |
virtual void | calendarIncidenceChanged (const KCalendarCore::Incidence::Ptr &incidence)=0 |
virtual void | calendarIncidenceDeleted (const KCalendarCore::Incidence::Ptr &incidence, const KCalendarCore::Calendar *calendar)=0 |
virtual void | calendarIncidenceAdditionCanceled (const KCalendarCore::Incidence::Ptr &incidence)=0 |
virtual bool | insertedIncidences (KCalendarCore::Incidence::List *list, const QDateTime &after=QDateTime(), const QString ¬ebookUid=QString())=0 |
Get inserted incidences from storage. | |
virtual bool | modifiedIncidences (KCalendarCore::Incidence::List *list, const QDateTime &after=QDateTime(), const QString ¬ebookUid=QString())=0 |
Get modified incidences from storage. | |
virtual bool | deletedIncidences (KCalendarCore::Incidence::List *list, const QDateTime &after=QDateTime(), const QString ¬ebookUid=QString())=0 |
Get deleted incidences from storage. | |
virtual bool | allIncidences (KCalendarCore::Incidence::List *list, const QString ¬ebookUid=QString())=0 |
Get all incidences from storage. | |
virtual bool | duplicateIncidences (KCalendarCore::Incidence::List *list, const KCalendarCore::Incidence::Ptr &incidence, const QString ¬ebookUid=QString())=0 |
Get possible duplicates for given incidence. | |
virtual QDateTime | incidenceDeletedDate (const KCalendarCore::Incidence::Ptr &incidence)=0 |
Get deletion time of incidence. | |
virtual int | eventCount ()=0 |
Get count of events. | |
virtual int | todoCount ()=0 |
Get count of todos. | |
virtual int | journalCount ()=0 |
Get count of journals. | |
void | registerObserver (ExtendedStorageObserver *observer) |
Registers an Observer for this Storage. | |
void | unregisterObserver (ExtendedStorageObserver *observer) |
Unregisters an Observer for this Storage. | |
bool | addNotebook (const Notebook::Ptr &nb) |
Add new notebook to the storage. | |
bool | updateNotebook (const Notebook::Ptr &nb) |
Update notebook parameters. | |
bool | deleteNotebook (const Notebook::Ptr &nb) |
Delete notebook from storage. | |
bool | setDefaultNotebook (const Notebook::Ptr &nb) |
setDefaultNotebook to the storage. | |
Notebook::Ptr | defaultNotebook () |
defaultNotebook. | |
Notebook::Ptr | notebook (const QString &uid) |
Search for notebook. | |
Notebook::Ptr | notebook (Notebook::List &list, const QString &uid) |
Search for notebook in a list. | |
Notebook::List | notebooks () |
List all notebooks. | |
void | setValidateNotebooks (bool validateNotebooks) |
Determine if notebooks should be validated in saves and loads. | |
bool | validateNotebooks () |
Returns true if notebooks should be validated in saves and loads. | |
bool | isValidNotebook (const QString ¬ebookUid) |
Returns true if the given notebook is valid for the storage. | |
KCalendarCore::Incidence::Ptr | checkAlarm (const QString &uid, const QString &recurrenceId, bool loadAlways=false) |
Checking if an incidence has active alarms. | |
Notebook::Ptr | createDefaultNotebook (QString name=QString(), QString color=QString()) |
Creates and sets a default notebook. | |
virtual void | virtual_hook (int id, void *data)=0 |
Standard trick to add virtuals later. | |
Protected Member Functions | |
virtual bool | loadNotebooks ()=0 |
virtual bool | modifyNotebook (const Notebook::Ptr &nb, DBOperation dbop)=0 |
bool | getLoadDates (const QDate &start, const QDate &end, QDateTime *loadStart, QDateTime *loadEnd) const |
void | addLoadedRange (const QDate &start, const QDate &end) const |
bool | isRecurrenceLoaded () const |
void | setIsRecurrenceLoaded (bool loaded) |
void | setModified (const QString &info) |
void | setFinished (bool error, const QString &info) |
void | setUpdated (const KCalendarCore::Incidence::List &added, const KCalendarCore::Incidence::List &modified, const KCalendarCore::Incidence::List &deleted) |
bool | isUncompletedTodosLoaded () |
void | setIsUncompletedTodosLoaded (bool loaded) |
bool | isCompletedTodosDateLoaded () |
void | setIsCompletedTodosDateLoaded (bool loaded) |
bool | isCompletedTodosCreatedLoaded () |
void | setIsCompletedTodosCreatedLoaded (bool loaded) |
bool | isJournalsLoaded () |
void | setIsJournalsLoaded (bool loaded) |
bool | isDateLoaded () |
void | setIsDateLoaded (bool loaded) |
bool | isCreatedLoaded () |
void | setIsCreatedLoaded (bool loaded) |
bool | isFutureDateLoaded () |
void | setIsFutureDateLoaded (bool loaded) |
bool | isGeoDateLoaded () |
void | setIsGeoDateLoaded (bool loaded) |
bool | isGeoCreatedLoaded () |
void | setIsGeoCreatedLoaded (bool loaded) |
void | clearLoaded () |
This class provides a calendar storage interface.
Every action on the storage can be asynchronous, which means that actions are only scheduled for execution. Caller must use ExtendedStorageObserver to get notified about the completion.
typedef QSharedPointer<ExtendedStorage> mKCal::ExtendedStorage::Ptr |
A shared pointer to a ExtendedStorage.
|
explicit |
Constructs a new ExtendedStorage object.
Private class that helps to provide binary compatibility between releases.
cal | is a pointer to a valid Calendar object. |
validateNotebooks | set to true for loading/saving only those incidences that belong to an existing notebook of this storage |
|
virtual |
Destructor.
|
protected |
bool ExtendedStorage::addNotebook | ( | const Notebook::Ptr & | nb | ) |
Add new notebook to the storage.
Notebook object is owned by the storage if operation succeeds. Operation is executed immediately into storage,
nb | notebook |
|
pure virtual |
Get all incidences from storage.
list | notebook's incidences |
notebookUid | list incidences for given notebook |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Calendar::CalendarObserver::calendarIncidenceAdded()
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Calendar::CalendarObserver::calendarIncidenceAdditionCanceled()
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Calendar::CalendarObserver::calendarIncidenceChanged()
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Calendar::CalendarObserver::calendarIncidenceDeleted()
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Calendar::CalendarObserver::calendarModified()
Implemented in mKCal::SqliteStorage, and DummyStorage.
|
pure virtual |
Cancel any ongoing action (load etc.).
Implemented in DummyStorage, and mKCal::SqliteStorage.
Incidence::Ptr ExtendedStorage::checkAlarm | ( | const QString & | uid, |
const QString & | recurrenceId, | ||
bool | loadAlways = false |
||
) |
Checking if an incidence has active alarms.
Application can use this function for getting the incidence in question, for example, displaying the incidence after an alarm.
uid | uid |
recurrenceId | recurrenceId |
loadAlways | set true to load always from storage |
|
protected |
|
virtual |
CalStorage::close()
Reimplemented in DummyStorage, and mKCal::SqliteStorage.
Notebook::Ptr ExtendedStorage::createDefaultNotebook | ( | QString | name = QString() , |
QString | color = QString() |
||
) |
Creates and sets a default notebook.
Usually called for an empty calendar.
name | notebook's name, if empty default used |
color | notebook's color in format "#FF0042", if empty default used |
Notebook::Ptr ExtendedStorage::defaultNotebook | ( | ) |
defaultNotebook.
|
pure virtual |
Get deleted incidences from storage.
list | deleted incidences |
after | list only incidences deleted after or at given datetime |
notebookUid | list only incidences for given notebook |
Implemented in DummyStorage, and mKCal::SqliteStorage.
bool ExtendedStorage::deleteNotebook | ( | const Notebook::Ptr & | nb | ) |
Delete notebook from storage.
Operation is executed immediately into storage,
nb | notebook |
|
pure virtual |
Get possible duplicates for given incidence.
list | duplicate incidences |
incidence | incidence to check |
notebookUid | list incidences for given notebook |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
|
protected |
|
pure virtual |
Get deletion time of incidence.
incidence | incidence to check |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Get inserted incidences from storage.
NOTE: time stamps assigned by KCalExtended are created during save(). To obtain a time stamp that is guaranteed to not included recent changes, sleep for a second or increment the current time by a second.
list | inserted incidences |
after | list only incidences inserted after or at given datetime |
notebookUid | list only incidences for given notebook |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
bool ExtendedStorage::isValidNotebook | ( | const QString & | notebookUid | ) |
Returns true if the given notebook is valid for the storage.
That means that storage can load/save incidences on this notebook.
notebookUid | notebook uid |
|
pure virtual |
Get count of journals.
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
CalStorage::load()
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load incidences at given date into the memory.
All incidences that happens within date, or starts / ends within date or span during date are loaded into memory. The time zone used to expand date into points in time is the time zone of the associated calendar. In addition, all recurring events are also loaded into memory since there is no way to know in advance if they will have occurrences intersecting date. Internally, recurring incidences and incidences of date are cached to avoid loading them several times.
date | date |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load incidences between given dates into the memory.
start is inclusive, while end is exclusive. The same definitions and restrictions for loading apply as for load(const QDate &) method.
start | is the starting date |
end | is the ending date, exclusive |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load incidence by uid into the memory.
uid | is uid of incidence |
recurrenceid | is recurrenceid of incidence, default null |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load incidences that have attendee.
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load completed todos based on parameters.
Load direction is descending, i.e., starting from most distant upcoming todo.
hasDate | set true to load todos that have due date |
limit | load only that many todos |
last | last loaded todo due/creation date in return |
Implemented in mKCal::SqliteStorage, and DummyStorage.
|
pure virtual |
Load all incidences that have the specified attendee.
Also includes all shared notes (in a shared notebook).
person | person in question |
limit | load only that many incidences |
last | last loaded incidence due/creation date in return |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load all contacts in the database.
Doesn't put anything into calendar. Resulting list of persons is ordered by the number of appearances. Use Person::count to get the number of appearances.
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load future incidences based on start/due date.
Load direction is ascending, i.e., starting from the oldest event that is still valid at the day of the loadIncidences call. (=end time > 00:00:00 on that day).
limit | load only that many incidences |
last | last loaded incidence start date in return |
Implemented in mKCal::SqliteStorage, and DummyStorage.
|
pure virtual |
Load incidences that have geo parameters.
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load incidences that have location information based on parameters.
Load direction is descending, i.e., starting from most distant upcoming incidence.
hasDate | set true to load incidences that have start/due date |
limit | load only that many incidences |
last | last loaded incidence due/creation date in return |
Implemented in mKCal::SqliteStorage, and DummyStorage.
|
pure virtual |
Load incidences that have geo parameters inside given rectangle.
geoLatitude | latitude |
geoLongitude | longitude |
diffLatitude | maximum latitudinal difference |
diffLongitude | maximum longitudinal difference |
Implemented in mKCal::SqliteStorage, and DummyStorage.
|
pure virtual |
Load the incidence matching the given identifier.
This method may be more fragile than load(uid, recid) though since the instanceIdentifier is not saved as is in the database.
instanceIdentifier | is an identifier returned by Incidence::instanceIdentifier() |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load incidences based on start/due date or creation date.
Load direction is descending, i.e., starting from most distant upcoming incidence.
hasDate | set true to load incidences that have start/due date |
limit | load only that many incidences |
last | last loaded incidence due/creation date in return |
Implemented in mKCal::SqliteStorage, and DummyStorage.
|
pure virtual |
Load journal type entries.
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load journal entries based on parameters.
Load direction is descending, i.e. starting from the most recently modified journal.
limit | load only that many incidences |
last | last loaded incidence due/creation date in return |
Implemented in mKCal::SqliteStorage, and DummyStorage.
|
pure virtual |
Load incidences of one notebook into the memory.
notebookUid | is uid of notebook |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
protectedpure virtual |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load plain incidences (no startdate and no enddate).
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load recurring incidences.
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load all incidences sharing the same uid into the memory.
uid | is uid of the series |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Load all uncompleted todos.
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Get modified incidences from storage.
NOTE: if an incidence is both created and modified after the given time, it will be returned in insertedIncidences only, not here!
list | modified incidences |
after | list only incidences modified after or at given datetime |
notebookUid | list only incidences for given notebook |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
protectedpure virtual |
Implemented in DummyStorage, and mKCal::SqliteStorage.
Notebook::Ptr ExtendedStorage::notebook | ( | const QString & | uid | ) |
Search for notebook.
uid | notebook uid |
Notebook::Ptr mKCal::ExtendedStorage::notebook | ( | Notebook::List & | list, |
const QString & | uid | ||
) |
Search for notebook in a list.
list | notebook list |
uid | notebook uid |
Notebook::List ExtendedStorage::notebooks | ( | ) |
List all notebooks.
|
pure virtual |
Mark if supported by the storage that an incidence has been opened.
This should be called only if the Incidence has been opened by the user and displayed all the contents. Being in a list doesn't qualify for it.
incidence | The incidence that has been opened |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
CalStorage::open()
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
Remove from storage all incidences that have been previously marked as deleted and that matches the UID / RecID of the incidences in list.
The action is performed immediately on database.
Implemented in DummyStorage, and mKCal::SqliteStorage.
void ExtendedStorage::registerObserver | ( | ExtendedStorageObserver * | observer | ) |
Registers an Observer for this Storage.
observer | is a pointer to an Observer object that will be watching this Storage. |
|
pure virtual |
CalStorage::save()
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
pure virtual |
This is an overload of save() method.
When @deleteAction is PurgeDeleted, the deleted incidences are not marked as deleted but completely removed from the database and won't appear anymore when calling deletedIncidences().
deleteAction | the action to apply to deleted incidences |
Implemented in DummyStorage, and mKCal::SqliteStorage.
bool ExtendedStorage::setDefaultNotebook | ( | const Notebook::Ptr & | nb | ) |
setDefaultNotebook to the storage.
nb | notebook |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
void ExtendedStorage::setValidateNotebooks | ( | bool | validateNotebooks | ) |
Determine if notebooks should be validated in saves and loads.
That means that storage can only load/save incidences into/from existing notebooks.
validate | true to validate |
|
pure virtual |
void ExtendedStorage::unregisterObserver | ( | ExtendedStorageObserver * | observer | ) |
Unregisters an Observer for this Storage.
observer | is a pointer to an Observer object that has been watching this Storage. |
bool ExtendedStorage::updateNotebook | ( | const Notebook::Ptr & | nb | ) |
Update notebook parameters.
Operation is executed immediately into storage,
nb | notebook |
bool ExtendedStorage::validateNotebooks | ( | ) |
Returns true if notebooks should be validated in saves and loads.
That means that storage can only load/save incidences into/from existing notebooks.
|
pure virtual |
Standard trick to add virtuals later.
id | is any integer unique to this class which we will use to identify the method to be called. |
data | is a pointer to some glob of data, typically a struct. |
Implemented in mKCal::SqliteStorage, and DummyStorage.