Public Types | Public Slots | Public Member Functions | Protected Member Functions

mKCal::SqliteStorage Class Reference

This class provides a calendar storage as an sqlite database. More...

#include <sqlitestorage.h>

Inheritance diagram for mKCal::SqliteStorage:
Inheritance graph
[legend]

List of all members.

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 &notebookUid)
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 &notebookUid=QString())
bool modifiedIncidences (KCalCore::Incidence::List *list, const KDateTime &after, const QString &notebookUid=QString())
bool deletedIncidences (KCalCore::Incidence::List *list, const KDateTime &after, const QString &notebookUid=QString())
bool deletedIncidencesCreatedAfter (KCalCore::Incidence::List *list, const KDateTime &after, const QString &notebookUid=QString())
bool allIncidences (KCalCore::Incidence::List *list, const QString &notebookUid=QString())
bool duplicateIncidences (KCalCore::Incidence::List *list, const KCalCore::Incidence::Ptr &incidence, const QString &notebookUid=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)

Detailed Description

This class provides a calendar storage as an sqlite database.

Warning:
When saving Attendees, the CustomProperties are not saved.

Member Typedef Documentation

typedef QSharedPointer<SqliteStorage> mKCal::SqliteStorage::Ptr

A shared pointer to a SqliteStorage.

Reimplemented from mKCal::ExtendedStorage.


Constructor & Destructor Documentation

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.

Parameters:
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
Warning:
if synchronousTrackerSave is used, a nested Event Loop is created!!!
SqliteStorage::~SqliteStorage (  )  [virtual]

Destructor.


Member Function Documentation

bool mKCal::SqliteStorage::allIncidences ( KCalCore::Incidence::List *  list,
const QString &  notebookUid = QString() 
) [virtual]

Get all incidences from storage.

Parameters:
list notebook's incidences
notebookUid list incidences for given notebook
Returns:
true if execution was scheduled; false otherwise

Implements mKCal::ExtendedStorage.

void mKCal::SqliteStorage::calendarIncidenceAdded ( const KCalCore::Incidence::Ptr &  incidence  )  [virtual]
void mKCal::SqliteStorage::calendarIncidenceAdditionCanceled ( const KCalCore::Incidence::Ptr &  incidence  )  [virtual]
void mKCal::SqliteStorage::calendarIncidenceChanged ( const KCalCore::Incidence::Ptr &  incidence  )  [virtual]
void mKCal::SqliteStorage::calendarIncidenceCreated ( const KCalCore::Incidence::Ptr &  incidence  ) 
void mKCal::SqliteStorage::calendarIncidenceDeleted ( const KCalCore::Incidence::Ptr &  incidence  )  [virtual]
void mKCal::SqliteStorage::calendarModified ( bool  modified,
KCalCore::Calendar *  calendar 
) [virtual]
bool SqliteStorage::cancel (  )  [virtual]

Cancel any ongoing action (load etc.

).

Returns:
true cancel was successful; false otherwise

Implements mKCal::ExtendedStorage.

bool SqliteStorage::close (  )  [virtual]
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.

Parameters:
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
Returns:
true if execution was scheduled; false otherwise

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.

Parameters:
list deleted incidences
after list only incidences deleted after or at given datetime
notebookUid list only incidences for given notebook
Returns:
true if execution was scheduled; false otherwise

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.

Parameters:
list duplicate incidences
incidence incidence to check
notebookUid list incidences for given notebook
Returns:
true if execution was scheduled; false otherwise

Implements mKCal::ExtendedStorage.

int SqliteStorage::eventCount (  )  [virtual]

Get count of events.

Returns:
count of events

Implements mKCal::ExtendedStorage.

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.

Parameters:
seconds relative to origin.
zonename timezone name.
Returns:
datetime in timezone.
KDateTime SqliteStorage::fromOriginTime ( sqlite3_int64  seconds  ) 

Convert seconds from the origin to UTC datetime.

Parameters:
seconds relative to origin.
Returns:
UTC datetime.
KDateTime mKCal::SqliteStorage::incidenceDeletedDate ( const KCalCore::Incidence::Ptr &  incidence  )  [virtual]

Get deletion time of incidence.

Parameters:
incidence incidence to check
Returns:
valid deletion time of incidence in UTC if incidence has been deleted otherwise KDateTime()

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.

Parameters:
list inserted incidences
after list only incidences inserted after or at given datetime
notebookUid list only incidences for given notebook
Returns:
true if execution was scheduled; false otherwise

Implements mKCal::ExtendedStorage.

int SqliteStorage::journalCount (  )  [virtual]

Get count of journals.

Returns:
count of journals

Implements mKCal::ExtendedStorage.

bool SqliteStorage::load (  )  [virtual]
bool SqliteStorage::load ( const QString &  uid,
const KDateTime &  recurrenceId = KDateTime() 
) [virtual]

Load incidence by uid into the memory.

Parameters:
uid is uid of incidence
recurrenceid is recurrenceid of incidence, default null
Returns:
true if the load was successful; false otherwise.

Implements mKCal::ExtendedStorage.

bool SqliteStorage::load ( const QDate &  date  )  [virtual]

Load incidences at given date into the memory.

Parameters:
date date
Returns:
true if the load was successful and specific date wasn't already loaded; false otherwise.

Implements mKCal::ExtendedStorage.

bool SqliteStorage::load ( const QDate &  start,
const QDate &  end 
) [virtual]

Load incidences between given dates into the memory.

Parameters:
start is the starting date
end is the ending date
Returns:
true if the load was successful and specific dates wasn't already loaded; false otherwise.

Implements mKCal::ExtendedStorage.

bool SqliteStorage::loadAttendeeIncidences (  )  [virtual]

Load incidences that have attendee.

Returns:
true if the load was successful; false otherwise.

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.

Parameters:
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
Returns:
number of loaded todos, or -1 on error

Implements mKCal::ExtendedStorage.

int mKCal::SqliteStorage::loadContactIncidences ( const KCalCore::Person::Ptr &  person,
int  limit,
KDateTime *  last 
) [virtual]
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.

Returns:
ordered list of persons

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.

Parameters:
geoLatitude latitude
geoLongitude longitude
diffLatitude maximum latitudinal difference
diffLongitude maximum longitudinal difference
Returns:
true if the load was successful; false otherwise.

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.

Returns:
true if the load was successful; false otherwise.

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.

Parameters:
notebookUid is uid of notebook
Returns:
true if the load was successful; false otherwise.

Implements mKCal::ExtendedStorage.

bool SqliteStorage::loadNotebooks (  )  [protected, virtual]
int SqliteStorage::loadOldInvitationIncidences ( int  limit,
KDateTime *  last 
) [virtual]
bool SqliteStorage::loadPlainIncidences (  )  [virtual]

Load plain incidences (no startdate and no enddate).

Returns:
true if the load was successful; false otherwise.

Implements mKCal::ExtendedStorage.

bool SqliteStorage::loadRecurringIncidences (  )  [virtual]

Load recurring incidences.

Returns:
true if the load was successful; false otherwise.

Implements mKCal::ExtendedStorage.

int SqliteStorage::loadUncompletedTodos (  )  [virtual]

Load all uncompleted todos.

Returns:
number of loaded todos, or -1 on error

Implements mKCal::ExtendedStorage.

int SqliteStorage::loadUnreadInvitationIncidences (  )  [virtual]

Load all unread incidences that are related to an invitation.

Returns:
number of loaded incidences, or -1 on error

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!

Parameters:
list modified incidences
after list only incidences modified after or at given datetime
notebookUid list only incidences for given notebook
Returns:
true if execution was scheduled; false otherwise

Implements mKCal::ExtendedStorage.

bool SqliteStorage::modifyNotebook ( const Notebook::Ptr nb,
DBOperation  dbop,
bool  signal = true 
) [protected, virtual]
const QList< int > SqliteStorage::modifyNotebookErrors (  ) 

List of errors after last notebook modification.

Returns:
sqlite error codes.
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.

Parameters:
incidence The incidence that has been opened
Returns:
True if sucessful; false otherwise

Implements mKCal::ExtendedStorage.

bool SqliteStorage::open (  )  [virtual]
void SqliteStorage::queryFinished (  )  [slot]
bool SqliteStorage::reloadNotebooks (  )  [protected, virtual]
bool SqliteStorage::save (  )  [virtual]
const QList< int > SqliteStorage::saveErrors (  ) 

List of errors after last save operation.

Returns:
sqlite error codes.
int SqliteStorage::todoCount (  )  [virtual]

Get count of todos.

Returns:
count of todos

Implements mKCal::ExtendedStorage.

sqlite3_int64 SqliteStorage::toLocalOriginTime ( KDateTime  dt  ) 

Convert local datetime to seconds relative to the origin.

Parameters:
dt datetime
Returns:
seconds relative to origin
sqlite3_int64 SqliteStorage::toOriginTime ( KDateTime  dt  ) 

Convert datetime to seconds relative to the origin.

Parameters:
dt datetime
Returns:
seconds relative to origin
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.

Parameters:
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.


The documentation for this class was generated from the following files:

Generated on Tue Jul 5 2011 16:40:27 for libmkcal by doxygen 1.7.1