extendedstorage.h
Go to the documentation of this file.
1/*
2 This file is part of the mkcal library.
3
4 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
5 Contact: Alvaro Manera <alvaro.manera@nokia.com>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
30
31#ifndef MKCAL_EXTENDEDSTORAGE_H
32#define MKCAL_EXTENDEDSTORAGE_H
33
34#include "mkcal_export.h"
35#include "extendedcalendar.h"
37#include "notebook.h"
38
39#include <KCalendarCore/CalStorage>
40#include <KCalendarCore/Calendar>
41
42namespace KCalendarCore {
43class Incidence;
44}
45
46class MkcalTool;
47class tst_load;
48
49namespace mKCal {
50
62 : public QObject, public KCalendarCore::Calendar::CalendarObserver
63{
64 Q_OBJECT
65
66public:
67
75
79 typedef QSharedPointer<ExtendedStorage> Ptr;
80
96 explicit ExtendedStorage(const ExtendedCalendar::Ptr &cal, bool validateNotebooks = true);
97
101 virtual ~ExtendedStorage();
102
107 ExtendedCalendar::Ptr calendar() const;
108
113 virtual bool open() = 0;
114
119 virtual bool load() = 0;
120
127 virtual bool load(const QString &uid) = 0;
128
137 bool loadSeries(const QString &uid);
138
153 bool load(const QString &uid, const QDateTime &recurrenceId);
154
168 virtual bool load(const QDate &date);
169
179 virtual bool load(const QDate &start, const QDate &end) = 0;
180
189 virtual bool loadIncidenceInstance(const QString &instanceIdentifier);
190
197 virtual bool loadNotebookIncidences(const QString &notebookUid) = 0;
198
210 virtual bool purgeDeletedIncidences(const KCalendarCore::Incidence::List &list,
211 const QString &notebook = QString()) = 0;
212
217 virtual bool save() = 0;
218
228 virtual bool save(DeleteAction deleteAction) = 0;
229
234 virtual bool close();
235
236 // Internal Calendar Listener Methods //
237
242 virtual void calendarModified(bool modified, KCalendarCore::Calendar *calendar) = 0;
243
248 virtual void calendarIncidenceAdded(const KCalendarCore::Incidence::Ptr &incidence) = 0;
249
254 virtual void calendarIncidenceChanged(const KCalendarCore::Incidence::Ptr &incidence) = 0;
255
260 virtual void calendarIncidenceDeleted(const KCalendarCore::Incidence::Ptr &incidence, const KCalendarCore::Calendar *calendar) = 0;
261
266 virtual void calendarIncidenceAdditionCanceled(const KCalendarCore::Incidence::Ptr &incidence) = 0;
267
268 // Synchronization Specific Methods //
269
282 virtual bool insertedIncidences(KCalendarCore::Incidence::List *list,
283 const QDateTime &after = QDateTime(),
284 const QString &notebookUid = QString()) = 0;
285
296 virtual bool modifiedIncidences(KCalendarCore::Incidence::List *list,
297 const QDateTime &after = QDateTime(),
298 const QString &notebookUid = QString()) = 0;
299
308 virtual bool deletedIncidences(KCalendarCore::Incidence::List *list,
309 const QDateTime &after = QDateTime(),
310 const QString &notebookUid = QString()) = 0;
311
319 virtual bool allIncidences(KCalendarCore::Incidence::List *list,
320 const QString &notebookUid = QString()) = 0;
321
343 virtual bool search(const QString &key, QStringList *identifiers, int limit = 0) = 0;
344
351 virtual QDateTime incidenceDeletedDate(const KCalendarCore::Incidence::Ptr &incidence) = 0;
352
353 // Observer Specific Methods //
354
364
374
375 // Notebook Methods //
376
388 bool addNotebook(const Notebook::Ptr &nb);
389
397 bool updateNotebook(const Notebook::Ptr &nb);
398
406 bool deleteNotebook(const Notebook::Ptr &nb);
407
414 bool setDefaultNotebook(const Notebook::Ptr &nb);
415
422
429 Notebook::Ptr notebook(const QString &uid) const;
430
437
446
454 bool validateNotebooks() const;
455
463 bool isValidNotebook(const QString &notebookUid) const;
464
476 Notebook::Ptr createDefaultNotebook(QString name = QString(),
477 QString color = QString());
478
486 virtual void virtual_hook(int id, void *data) = 0;
487
488protected:
489 virtual bool loadNotebooks() = 0;
490 virtual bool insertNotebook(const Notebook::Ptr &nb) = 0;
491 virtual bool modifyNotebook(const Notebook::Ptr &nb) = 0;
492 virtual bool eraseNotebook(const Notebook::Ptr &nb) = 0;
493
494 bool getLoadDates(const QDate &start, const QDate &end,
495 QDateTime *loadStart, QDateTime *loadEnd) const;
496
497 void addLoadedRange(const QDate &start, const QDate &end) const;
498 bool isRecurrenceLoaded() const;
499 void setIsRecurrenceLoaded(bool loaded);
500
501 void emitStorageModified(const QString &info);
502 void emitStorageFinished(bool error, const QString &info);
503 void emitStorageUpdated(const KCalendarCore::Incidence::List &added,
504 const KCalendarCore::Incidence::List &modified,
505 const KCalendarCore::Incidence::List &deleted);
506
507private:
508 //@cond PRIVATE
509 Q_DISABLE_COPY(ExtendedStorage)
510 class Private;
511 Private *const d;
512 //@endcond
513
514 friend class ::MkcalTool;
515 friend class ::tst_load;
516};
517
518}
519
520#endif
QSharedPointer< ExtendedStorage > Ptr
A shared pointer to a ExtendedStorage.
Definition extendedstorage.h:79
void addLoadedRange(const QDate &start, const QDate &end) const
Definition extendedstorage.cpp:215
virtual bool open()=0
bool deleteNotebook(const Notebook::Ptr &nb)
Delete notebook from storage.
Definition extendedstorage.cpp:422
Notebook::Ptr createDefaultNotebook(QString name=QString(), QString color=QString())
Creates and sets a default notebook.
Definition extendedstorage.cpp:536
virtual bool purgeDeletedIncidences(const KCalendarCore::Incidence::List &list, const QString &notebook=QString())=0
Remove from storage all incidences that have been previously marked as deleted and that matches the U...
virtual bool close()
Definition extendedstorage.cpp:174
virtual bool load()=0
virtual bool load(const QString &uid)=0
Load all incidences sharing the same uid into the memory.
virtual bool loadNotebookIncidences(const QString &notebookUid)=0
Load incidences of one notebook into the memory.
virtual void calendarIncidenceDeleted(const KCalendarCore::Incidence::Ptr &incidence, const KCalendarCore::Calendar *calendar)=0
virtual bool load(const QDate &start, const QDate &end)=0
Load incidences between given dates into the memory.
void setValidateNotebooks(bool validateNotebooks)
Determine if notebooks should be validated in saves and loads.
Definition extendedstorage.cpp:508
void emitStorageModified(const QString &info)
Definition extendedstorage.cpp:334
virtual bool loadIncidenceInstance(const QString &instanceIdentifier)
Load the incidence matching the given identifier.
Definition extendedstorage.cpp:266
void unregisterObserver(ExtendedStorageObserver *observer)
Unregisters an Observer for this Storage.
Definition extendedstorage.cpp:329
bool setDefaultNotebook(const Notebook::Ptr &nb)
setDefaultNotebook to the storage.
Definition extendedstorage.cpp:476
virtual bool search(const QString &key, QStringList *identifiers, int limit=0)=0
Get all incidences from storage that match key.
bool validateNotebooks() const
Returns true if notebooks should be validated in saves and loads.
Definition extendedstorage.cpp:513
virtual QDateTime incidenceDeletedDate(const KCalendarCore::Incidence::Ptr &incidence)=0
Get deletion time of incidence.
ExtendedStorage(const ExtendedCalendar::Ptr &cal, bool validateNotebooks=true)
Constructs a new ExtendedStorage object.
Definition extendedstorage.cpp:157
void setIsRecurrenceLoaded(bool loaded)
Definition extendedstorage.cpp:247
bool isRecurrenceLoaded() const
Definition extendedstorage.cpp:242
virtual void calendarModified(bool modified, KCalendarCore::Calendar *calendar)=0
ExtendedCalendar::Ptr calendar() const
Definition extendedstorage.cpp:169
bool addNotebook(const Notebook::Ptr &nb)
Add new notebook to the storage.
Definition extendedstorage.cpp:376
virtual bool save(DeleteAction deleteAction)=0
This is an overload of save() method.
void registerObserver(ExtendedStorageObserver *observer)
Registers an Observer for this Storage.
Definition extendedstorage.cpp:322
bool isValidNotebook(const QString &notebookUid) const
Returns true if the given notebook is valid for the storage.
Definition extendedstorage.cpp:518
virtual bool loadNotebooks()=0
DeleteAction
Action to be performed on save for deleted incidences.
Definition extendedstorage.h:71
@ MarkDeleted
Definition extendedstorage.h:72
@ PurgeDeleted
Definition extendedstorage.h:73
bool getLoadDates(const QDate &start, const QDate &end, QDateTime *loadStart, QDateTime *loadEnd) const
Definition extendedstorage.cpp:179
virtual bool allIncidences(KCalendarCore::Incidence::List *list, const QString &notebookUid=QString())=0
Get all incidences from storage.
virtual bool save()=0
Notebook::List notebooks()
List all notebooks.
Definition extendedstorage.cpp:498
virtual bool modifiedIncidences(KCalendarCore::Incidence::List *list, const QDateTime &after=QDateTime(), const QString &notebookUid=QString())=0
Get modified incidences from storage.
bool updateNotebook(const Notebook::Ptr &nb)
Update notebook parameters.
Definition extendedstorage.cpp:395
virtual void calendarIncidenceChanged(const KCalendarCore::Incidence::Ptr &incidence)=0
bool loadSeries(const QString &uid)
Load all incidences sharing the same uid into the memory.
Definition extendedstorage.cpp:252
virtual bool modifyNotebook(const Notebook::Ptr &nb)=0
virtual void calendarIncidenceAdditionCanceled(const KCalendarCore::Incidence::Ptr &incidence)=0
virtual bool eraseNotebook(const Notebook::Ptr &nb)=0
Notebook::Ptr notebook(const QString &uid) const
Search for notebook.
Definition extendedstorage.cpp:503
void emitStorageUpdated(const KCalendarCore::Incidence::List &added, const KCalendarCore::Incidence::List &modified, const KCalendarCore::Incidence::List &deleted)
Definition extendedstorage.cpp:360
virtual void calendarIncidenceAdded(const KCalendarCore::Incidence::Ptr &incidence)=0
virtual void virtual_hook(int id, void *data)=0
Standard trick to add virtuals later.
virtual bool insertedIncidences(KCalendarCore::Incidence::List *list, const QDateTime &after=QDateTime(), const QString &notebookUid=QString())=0
Get inserted incidences from storage.
virtual bool deletedIncidences(KCalendarCore::Incidence::List *list, const QDateTime &after=QDateTime(), const QString &notebookUid=QString())=0
Get deleted incidences from storage.
void emitStorageFinished(bool error, const QString &info)
Definition extendedstorage.cpp:353
virtual bool insertNotebook(const Notebook::Ptr &nb)=0
Notebook::Ptr defaultNotebook()
defaultNotebook.
Definition extendedstorage.cpp:493
The ExtendedStorageObserver class.
Definition extendedstorageobserver.h:47
QSharedPointer< Notebook > Ptr
A shared pointer to a Notebook object.
Definition notebook.h:51
QList< Ptr > List
List of notebooks.
Definition notebook.h:61
This file is part of the API for handling calendar data and defines the ExtendedCalendar class.
This file is part of the API for handling calendar data and defines the ExtendedStorageObserver to be...
#define MKCAL_EXPORT
Definition mkcal_export.h:29
Definition extendedstorage.h:42
Definition extendedstorage.h:49
This file is part of the API for handling calendar data and defines the Notebook class.

Generated on for libextendedkcal by doxygen 1.16.1