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)=0 |
Load all incidences sharing the same uid into the memory. | |
bool | loadSeries (const QString &uid) |
Load all incidences sharing the same uid into the memory. | |
bool | load (const QString &uid, const QDateTime &recurrenceId) |
Load incidence by uid/recid into the memory. | |
virtual bool | load (const QDate &date) |
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 | loadIncidenceInstance (const QString &instanceIdentifier) |
Load the incidence matching the given identifier. | |
virtual bool | loadNotebookIncidences (const QString ¬ebookUid)=0 |
Load incidences of one notebook into the memory. | |
virtual bool | purgeDeletedIncidences (const KCalendarCore::Incidence::List &list, const QString ¬ebook=QString())=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 | 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 | search (const QString &key, QStringList *identifiers, int limit=0)=0 |
Get all incidences from storage that match key. | |
virtual QDateTime | incidenceDeletedDate (const KCalendarCore::Incidence::Ptr &incidence)=0 |
Get deletion time of incidence. | |
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) const |
Search for notebook. | |
Notebook::List | notebooks () |
List all notebooks. | |
void | setValidateNotebooks (bool validateNotebooks) |
Determine if notebooks should be validated in saves and loads. | |
bool | validateNotebooks () const |
Returns true if notebooks should be validated in saves and loads. | |
bool | isValidNotebook (const QString ¬ebookUid) const |
Returns true if the given notebook is valid for the storage. | |
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 | insertNotebook (const Notebook::Ptr &nb)=0 |
virtual bool | modifyNotebook (const Notebook::Ptr &nb)=0 |
virtual bool | eraseNotebook (const Notebook::Ptr &nb)=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 | emitStorageModified (const QString &info) |
void | emitStorageFinished (bool error, const QString &info) |
void | emitStorageUpdated (const KCalendarCore::Incidence::List &added, const KCalendarCore::Incidence::List &modified, const KCalendarCore::Incidence::List &deleted) |
This class provides a calendar storage interface.
Every action on the storage can be synchronous or asynchronous, depending on the storage implementation. SqliteStorage is a synchronous implementation.
In any case, caller can use ExtendedStorageObserver to get notified about the action done.
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 DummyStorage, and mKCal::SqliteStorage.
|
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.
Notice: deprecated since 0.6.10. Instead, create a notebook and call setDefaultNotebook().
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 |
|
protected |
|
protected |
|
protected |
|
protectedpure virtual |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
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.
|
protectedpure virtual |
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
protected |
bool ExtendedStorage::isValidNotebook | ( | const QString & | notebookUid | ) | const |
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 |
CalStorage::load()
Implemented in DummyStorage, and mKCal::SqliteStorage.
|
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 |
|
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 all incidences sharing the same uid into the memory.
uid | is uid of the series |
Implemented in DummyStorage, and mKCal::SqliteStorage.
bool ExtendedStorage::load | ( | const QString & | uid, |
const QDateTime & | recurrenceId ) |
Load incidence by uid/recid into the memory.
This method is deprecated since it may populate calendars with orphaned exceptions, or recurring event without their exceptions.
Use load(const QString &uid) which ensures for recurring incidences to also get their exceptions.
uid | is uid of incidence |
recurrenceid | is recurrenceid of incidence |
|
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() |
|
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.
bool ExtendedStorage::loadSeries | ( | const QString & | uid | ) |
Load all incidences sharing the same uid into the memory.
Deprecated call, equivalent to calling load(const QString &uid).
uid | is uid of the series |
|
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 | ) | const |
Search for notebook.
uid | notebook uid |
Notebook::List ExtendedStorage::notebooks | ( | ) |
List all notebooks.
|
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.
list | is the incidences to remove from the DB |
notebook | is the notebook they belong to, using an empty notebook uid is deprecated, but kept for backward backward compatibility. |
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.
|
pure virtual |
Get all incidences from storage that match key.
Incidences are loaded into the associated ExtendedCalendar. More incidences than the listed ones in
identifiers | may be loaded into memory to ensure calendar consistency with respect to exceptions of recurring incidences. |
Matching is done on summary, description and location fields.
The matching incidences are sorted by start dates before applying the
limit. | Since recurring incidences have occurrences later than their start date, they are not taken into account when counting the limit and all matching recurring events are always loaded. |
key | can be any substring from the summary, the description or the location. |
identifiers | optional, stores the instance identifiers of matching incidences. |
limit | the maximum number of non-recurring incidences, unlimited by default |
Implemented in DummyStorage, and mKCal::SqliteStorage.
bool ExtendedStorage::setDefaultNotebook | ( | const Notebook::Ptr & | nb | ) |
setDefaultNotebook to the storage.
nb | notebook |
|
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 |
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 | ( | ) | const |
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 DummyStorage, and mKCal::SqliteStorage.