This class provides a calendar storage as an sqlite database. More...
#include <sqlitestorage.h>
Public Types | |
typedef QSharedPointer < SqliteStorage > | Ptr |
A shared pointer to a SqliteStorage. | |
Public Slots | |
void | fileChanged (const QString &path) |
void | queryFinished () |
Public Member Functions | |
SqliteStorage (const ExtendedCalendar::Ptr &cal, const QString &databaseName, bool useTracker=false, bool validateNotebooks=false, bool synchronousTrackerSave=false) | |
Constructs a new SqliteStorage object for Calendar calendar with format format , and storage to file fileName . | |
virtual | ~SqliteStorage () |
Destructor. | |
QString | databaseName () const |
Returns a string containing the name of the calendar database. | |
bool | useTracker () const |
Returns true if tracker is also used in saves. | |
bool | open () |
bool | load () |
bool | load (const QString &uid, const KDateTime &recurrenceId=KDateTime()) |
bool | load (const QDate &date) |
bool | load (const QDate &start, const QDate &end) |
bool | loadNotebookIncidences (const QString ¬ebookUid) |
bool | loadJournals () |
bool | loadPlainIncidences () |
bool | loadRecurringIncidences () |
bool | loadGeoIncidences () |
bool | loadGeoIncidences (float geoLatitude, float geoLongitude, float diffLatitude, float diffLongitude) |
bool | loadAttendeeIncidences () |
int | loadUncompletedTodos () |
int | loadCompletedTodos (bool hasDate, int limit, KDateTime *last) |
int | loadIncidences (bool hasDate, int limit, KDateTime *last) |
int | loadFutureIncidences (int limit, KDateTime *last) |
int | loadGeoIncidences (bool hasDate, int limit, KDateTime *last) |
int | loadUnreadInvitationIncidences () |
int | loadOldInvitationIncidences (int limit, KDateTime *last) |
KCalCore::Person::List | loadContacts () |
int | loadContactIncidences (const KCalCore::Person::Ptr &person, int limit, KDateTime *last) |
int | loadJournals (int limit, KDateTime *last) |
bool | notifyOpened (const KCalCore::Incidence::Ptr &incidence) |
bool | save () |
bool | cancel () |
bool | close () |
void | calendarModified (bool modified, KCalCore::Calendar *calendar) |
void | calendarIncidenceCreated (const KCalCore::Incidence::Ptr &incidence) |
void | calendarIncidenceAdded (const KCalCore::Incidence::Ptr &incidence) |
void | calendarIncidenceChanged (const KCalCore::Incidence::Ptr &incidence) |
void | calendarIncidenceDeleted (const KCalCore::Incidence::Ptr &incidence) |
void | calendarIncidenceAdditionCanceled (const KCalCore::Incidence::Ptr &incidence) |
bool | insertedIncidences (KCalCore::Incidence::List *list, const KDateTime &after, const QString ¬ebookUid=QString()) |
bool | modifiedIncidences (KCalCore::Incidence::List *list, const KDateTime &after, const QString ¬ebookUid=QString()) |
bool | deletedIncidences (KCalCore::Incidence::List *list, const KDateTime &after, const QString ¬ebookUid=QString()) |
bool | deletedIncidencesCreatedAfter (KCalCore::Incidence::List *list, const KDateTime &after, const QString ¬ebookUid=QString()) |
bool | allIncidences (KCalCore::Incidence::List *list, const QString ¬ebookUid=QString()) |
bool | duplicateIncidences (KCalCore::Incidence::List *list, const KCalCore::Incidence::Ptr &incidence, const QString ¬ebookUid=QString()) |
KDateTime | incidenceDeletedDate (const KCalCore::Incidence::Ptr &incidence) |
int | eventCount () |
int | todoCount () |
int | journalCount () |
virtual void | virtual_hook (int id, void *data) |
sqlite3_int64 | toOriginTime (KDateTime dt) |
Convert datetime to seconds relative to the origin. | |
sqlite3_int64 | toLocalOriginTime (KDateTime dt) |
Convert local datetime to seconds relative to the origin. | |
KDateTime | fromOriginTime (sqlite3_int64 seconds) |
Convert seconds from the origin to UTC datetime. | |
KDateTime | fromOriginTime (sqlite3_int64 seconds, QString zonename) |
Convert seconds from the origin to datetime in given timezone. | |
const QList< int > | saveErrors () |
List of errors after last save operation. | |
const QList< int > | modifyNotebookErrors () |
List of errors after last notebook modification. | |
Protected Member Functions | |
bool | loadNotebooks () |
bool | reloadNotebooks () |
bool | modifyNotebook (const Notebook::Ptr &nb, DBOperation dbop, bool signal=true) |
This class provides a calendar storage as an sqlite database.
typedef QSharedPointer<SqliteStorage> mKCal::SqliteStorage::Ptr |
A shared pointer to a SqliteStorage.
Reimplemented from mKCal::ExtendedStorage.
SqliteStorage::SqliteStorage | ( | const ExtendedCalendar::Ptr & | cal, | |
const QString & | databaseName, | |||
bool | useTracker = false , |
|||
bool | validateNotebooks = false , |
|||
bool | synchronousTrackerSave = false | |||
) | [explicit] |
Constructs a new SqliteStorage object for Calendar calendar
with format format
, and storage to file fileName
.
Private class that helps to provide binary compatibility between releases.
calendar | is a pointer to a valid Calendar object. | |
databaseName | is the name of the database containing the Calendar data. | |
useTracker | set to true to save everything into tracker as well | |
validateNotebooks | set to true for saving only those incidences that belong to an existing notebook of this storage | |
synchronousTrackerSave | set to true for saving into tracker as synchronous, default=false |
SqliteStorage::~SqliteStorage | ( | ) | [virtual] |
Destructor.
bool mKCal::SqliteStorage::allIncidences | ( | KCalCore::Incidence::List * | list, | |
const QString & | notebookUid = QString() | |||
) | [virtual] |
Get all incidences from storage.
list | notebook's incidences | |
notebookUid | list incidences for given notebook |
Implements mKCal::ExtendedStorage.
void mKCal::SqliteStorage::calendarIncidenceAdded | ( | const KCalCore::Incidence::Ptr & | incidence | ) | [virtual] |
Implements mKCal::ExtendedStorage.
void mKCal::SqliteStorage::calendarIncidenceAdditionCanceled | ( | const KCalCore::Incidence::Ptr & | incidence | ) | [virtual] |
Implements mKCal::ExtendedStorage.
void mKCal::SqliteStorage::calendarIncidenceChanged | ( | const KCalCore::Incidence::Ptr & | incidence | ) | [virtual] |
Implements mKCal::ExtendedStorage.
void mKCal::SqliteStorage::calendarIncidenceCreated | ( | const KCalCore::Incidence::Ptr & | incidence | ) |
void mKCal::SqliteStorage::calendarIncidenceDeleted | ( | const KCalCore::Incidence::Ptr & | incidence | ) | [virtual] |
Implements mKCal::ExtendedStorage.
void mKCal::SqliteStorage::calendarModified | ( | bool | modified, | |
KCalCore::Calendar * | calendar | |||
) | [virtual] |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::cancel | ( | ) | [virtual] |
Cancel any ongoing action (load etc.
).
Implements mKCal::ExtendedStorage.
bool SqliteStorage::close | ( | ) | [virtual] |
Implements mKCal::ExtendedStorage.
QString SqliteStorage::databaseName | ( | ) | const |
Returns a string containing the name of the calendar database.
bool mKCal::SqliteStorage::deletedIncidences | ( | KCalCore::Incidence::List * | list, | |
const KDateTime & | after, | |||
const QString & | notebookUid = QString() | |||
) | [virtual] |
Get deleted incidences from storage.
list | deleted incidences | |
after | list only incidences deleted after or at given datetime and created before given datetime | |
notebookUid | list only incidences for given notebook |
Implements mKCal::ExtendedStorage.
bool mKCal::SqliteStorage::deletedIncidencesCreatedAfter | ( | KCalCore::Incidence::List * | list, | |
const KDateTime & | after, | |||
const QString & | notebookUid = QString() | |||
) | [virtual] |
Get deleted incidences from storage, that are created and deleted after given datetime.
list | deleted incidences | |
after | list only incidences deleted after or at given datetime | |
notebookUid | list only incidences for given notebook |
Implements mKCal::ExtendedStorage.
bool mKCal::SqliteStorage::duplicateIncidences | ( | KCalCore::Incidence::List * | list, | |
const KCalCore::Incidence::Ptr & | incidence, | |||
const QString & | notebookUid = QString() | |||
) | [virtual] |
Get possible duplicates for given incidence.
list | duplicate incidences | |
incidence | incidence to check | |
notebookUid | list incidences for given notebook |
Implements mKCal::ExtendedStorage.
int SqliteStorage::eventCount | ( | ) | [virtual] |
void SqliteStorage::fileChanged | ( | const QString & | path | ) | [slot] |
KDateTime SqliteStorage::fromOriginTime | ( | sqlite3_int64 | seconds, | |
QString | zonename | |||
) |
Convert seconds from the origin to datetime in given timezone.
seconds | relative to origin. | |
zonename | timezone name. |
KDateTime SqliteStorage::fromOriginTime | ( | sqlite3_int64 | seconds | ) |
Convert seconds from the origin to UTC datetime.
seconds | relative to origin. |
KDateTime mKCal::SqliteStorage::incidenceDeletedDate | ( | const KCalCore::Incidence::Ptr & | incidence | ) | [virtual] |
Get deletion time of incidence.
incidence | incidence to check |
Implements mKCal::ExtendedStorage.
bool mKCal::SqliteStorage::insertedIncidences | ( | KCalCore::Incidence::List * | list, | |
const KDateTime & | after, | |||
const QString & | notebookUid = QString() | |||
) | [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 |
Implements mKCal::ExtendedStorage.
int SqliteStorage::journalCount | ( | ) | [virtual] |
bool SqliteStorage::load | ( | ) | [virtual] |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::load | ( | const QString & | uid, | |
const KDateTime & | recurrenceId = KDateTime() | |||
) | [virtual] |
Load incidence by uid into the memory.
uid | is uid of incidence | |
recurrenceid | is recurrenceid of incidence, default null |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::load | ( | const QDate & | date | ) | [virtual] |
Load incidences at given date into the memory.
date | date |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::load | ( | const QDate & | start, | |
const QDate & | end | |||
) | [virtual] |
Load incidences between given dates into the memory.
start | is the starting date | |
end | is the ending date |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::loadAttendeeIncidences | ( | ) | [virtual] |
Load incidences that have attendee.
Implements mKCal::ExtendedStorage.
int SqliteStorage::loadCompletedTodos | ( | bool | hasDate, | |
int | limit, | |||
KDateTime * | last | |||
) | [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 |
Implements mKCal::ExtendedStorage.
int mKCal::SqliteStorage::loadContactIncidences | ( | const KCalCore::Person::Ptr & | person, | |
int | limit, | |||
KDateTime * | last | |||
) | [virtual] |
Implements mKCal::ExtendedStorage.
Person::List SqliteStorage::loadContacts | ( | ) | [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.
Implements mKCal::ExtendedStorage.
int SqliteStorage::loadFutureIncidences | ( | int | limit, | |
KDateTime * | last | |||
) | [virtual] |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::loadGeoIncidences | ( | float | geoLatitude, | |
float | geoLongitude, | |||
float | diffLatitude, | |||
float | diffLongitude | |||
) | [virtual] |
Load incidences that have geo parameters inside given rectangle.
geoLatitude | latitude | |
geoLongitude | longitude | |
diffLatitude | maximum latitudinal difference | |
diffLongitude | maximum longitudinal difference |
Implements mKCal::ExtendedStorage.
int SqliteStorage::loadGeoIncidences | ( | bool | hasDate, | |
int | limit, | |||
KDateTime * | last | |||
) | [virtual] |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::loadGeoIncidences | ( | ) | [virtual] |
Load incidences that have geo parameters.
Implements mKCal::ExtendedStorage.
int SqliteStorage::loadIncidences | ( | bool | hasDate, | |
int | limit, | |||
KDateTime * | last | |||
) | [virtual] |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::loadJournals | ( | ) | [virtual] |
Load journal type entries.
Implements mKCal::ExtendedStorage.
int SqliteStorage::loadJournals | ( | int | limit, | |
KDateTime * | last | |||
) | [virtual] |
Load journal type entries.
Implements mKCal::ExtendedStorage.
bool SqliteStorage::loadNotebookIncidences | ( | const QString & | notebookUid | ) | [virtual] |
Load incidences of one notebook into the memory.
notebookUid | is uid of notebook |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::loadNotebooks | ( | ) | [protected, virtual] |
Implements mKCal::ExtendedStorage.
int SqliteStorage::loadOldInvitationIncidences | ( | int | limit, | |
KDateTime * | last | |||
) | [virtual] |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::loadPlainIncidences | ( | ) | [virtual] |
Load plain incidences (no startdate and no enddate).
Implements mKCal::ExtendedStorage.
bool SqliteStorage::loadRecurringIncidences | ( | ) | [virtual] |
Load recurring incidences.
Implements mKCal::ExtendedStorage.
int SqliteStorage::loadUncompletedTodos | ( | ) | [virtual] |
Load all uncompleted todos.
Implements mKCal::ExtendedStorage.
int SqliteStorage::loadUnreadInvitationIncidences | ( | ) | [virtual] |
Load all unread incidences that are related to an invitation.
Implements mKCal::ExtendedStorage.
bool mKCal::SqliteStorage::modifiedIncidences | ( | KCalCore::Incidence::List * | list, | |
const KDateTime & | after, | |||
const QString & | notebookUid = QString() | |||
) | [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 |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::modifyNotebook | ( | const Notebook::Ptr & | nb, | |
DBOperation | dbop, | |||
bool | signal = true | |||
) | [protected, virtual] |
Implements mKCal::ExtendedStorage.
const QList< int > SqliteStorage::modifyNotebookErrors | ( | ) |
List of errors after last notebook modification.
bool mKCal::SqliteStorage::notifyOpened | ( | const KCalCore::Incidence::Ptr & | incidence | ) | [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 |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::open | ( | ) | [virtual] |
Implements mKCal::ExtendedStorage.
void SqliteStorage::queryFinished | ( | ) | [slot] |
bool SqliteStorage::reloadNotebooks | ( | ) | [protected, virtual] |
Implements mKCal::ExtendedStorage.
bool SqliteStorage::save | ( | ) | [virtual] |
Implements mKCal::ExtendedStorage.
const QList< int > SqliteStorage::saveErrors | ( | ) |
List of errors after last save operation.
int SqliteStorage::todoCount | ( | ) | [virtual] |
sqlite3_int64 SqliteStorage::toLocalOriginTime | ( | KDateTime | dt | ) |
Convert local datetime to seconds relative to the origin.
dt | datetime |
sqlite3_int64 SqliteStorage::toOriginTime | ( | KDateTime | dt | ) |
Convert datetime to seconds relative to the origin.
dt | datetime |
bool SqliteStorage::useTracker | ( | ) | const |
Returns true if tracker is also used in saves.
void SqliteStorage::virtual_hook | ( | int | id, | |
void * | data | |||
) | [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. |
Implements mKCal::ExtendedStorage.