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#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
63 : public QObject, public KCalendarCore::Calendar::CalendarObserver
64#else
65 : public KCalendarCore::CalStorage, public KCalendarCore::Calendar::CalendarObserver
66#endif
67{
68 Q_OBJECT
69
70public:
71
79
83 typedef QSharedPointer<ExtendedStorage> Ptr;
84
100 explicit ExtendedStorage(const ExtendedCalendar::Ptr &cal, bool validateNotebooks = true);
101
105 virtual ~ExtendedStorage();
106
107#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
112 ExtendedCalendar::Ptr calendar() const;
113#endif
114
119 virtual bool open() = 0;
120
125 virtual bool load() = 0;
126
133 virtual bool load(const QString &uid) = 0;
134
143 bool loadSeries(const QString &uid);
144
159 bool load(const QString &uid, const QDateTime &recurrenceId);
160
174 virtual bool load(const QDate &date);
175
185 virtual bool load(const QDate &start, const QDate &end) = 0;
186
195 virtual bool loadIncidenceInstance(const QString &instanceIdentifier);
196
203 virtual bool loadNotebookIncidences(const QString &notebookUid) = 0;
204
216 virtual bool purgeDeletedIncidences(const KCalendarCore::Incidence::List &list,
217 const QString &notebook = QString()) = 0;
218
223 virtual bool save() = 0;
224
234 virtual bool save(DeleteAction deleteAction) = 0;
235
240 virtual bool close();
241
242 // Internal Calendar Listener Methods //
243
248 virtual void calendarModified(bool modified, KCalendarCore::Calendar *calendar) = 0;
249
254 virtual void calendarIncidenceAdded(const KCalendarCore::Incidence::Ptr &incidence) = 0;
255
260 virtual void calendarIncidenceChanged(const KCalendarCore::Incidence::Ptr &incidence) = 0;
261
266 virtual void calendarIncidenceDeleted(const KCalendarCore::Incidence::Ptr &incidence, const KCalendarCore::Calendar *calendar) = 0;
267
272 virtual void calendarIncidenceAdditionCanceled(const KCalendarCore::Incidence::Ptr &incidence) = 0;
273
274 // Synchronization Specific Methods //
275
288 virtual bool insertedIncidences(KCalendarCore::Incidence::List *list,
289 const QDateTime &after = QDateTime(),
290 const QString &notebookUid = QString()) = 0;
291
302 virtual bool modifiedIncidences(KCalendarCore::Incidence::List *list,
303 const QDateTime &after = QDateTime(),
304 const QString &notebookUid = QString()) = 0;
305
314 virtual bool deletedIncidences(KCalendarCore::Incidence::List *list,
315 const QDateTime &after = QDateTime(),
316 const QString &notebookUid = QString()) = 0;
317
325 virtual bool allIncidences(KCalendarCore::Incidence::List *list,
326 const QString &notebookUid = QString()) = 0;
327
349 virtual bool search(const QString &key, QStringList *identifiers, int limit = 0) = 0;
350
357 virtual QDateTime incidenceDeletedDate(const KCalendarCore::Incidence::Ptr &incidence) = 0;
358
359 // Observer Specific Methods //
360
370
380
381 // Notebook Methods //
382
394 bool addNotebook(const Notebook::Ptr &nb);
395
403 bool updateNotebook(const Notebook::Ptr &nb);
404
412 bool deleteNotebook(const Notebook::Ptr &nb);
413
420 bool setDefaultNotebook(const Notebook::Ptr &nb);
421
428
435 Notebook::Ptr notebook(const QString &uid) const;
436
443
452
460 bool validateNotebooks() const;
461
469 bool isValidNotebook(const QString &notebookUid) const;
470
482 Notebook::Ptr createDefaultNotebook(QString name = QString(),
483 QString color = QString());
484
492 virtual void virtual_hook(int id, void *data) = 0;
493
494protected:
495 virtual bool loadNotebooks() = 0;
496 virtual bool insertNotebook(const Notebook::Ptr &nb) = 0;
497 virtual bool modifyNotebook(const Notebook::Ptr &nb) = 0;
498 virtual bool eraseNotebook(const Notebook::Ptr &nb) = 0;
499
500 bool getLoadDates(const QDate &start, const QDate &end,
501 QDateTime *loadStart, QDateTime *loadEnd) const;
502
503 void addLoadedRange(const QDate &start, const QDate &end) const;
504 bool isRecurrenceLoaded() const;
505 void setIsRecurrenceLoaded(bool loaded);
506
507 void emitStorageModified(const QString &info);
508 void emitStorageFinished(bool error, const QString &info);
509 void emitStorageUpdated(const KCalendarCore::Incidence::List &added,
510 const KCalendarCore::Incidence::List &modified,
511 const KCalendarCore::Incidence::List &deleted);
512
513private:
514 //@cond PRIVATE
515 Q_DISABLE_COPY(ExtendedStorage)
516 class Private;
517 Private *const d;
518 //@endcond
519
520 friend class ::MkcalTool;
521 friend class ::tst_load;
522};
523
524}
525
526#endif
QSharedPointer< ExtendedStorage > Ptr
A shared pointer to a ExtendedStorage.
Definition extendedstorage.h:83
void addLoadedRange(const QDate &start, const QDate &end) const
Definition extendedstorage.cpp:230
virtual bool open()=0
bool deleteNotebook(const Notebook::Ptr &nb)
Delete notebook from storage.
Definition extendedstorage.cpp:437
Notebook::Ptr createDefaultNotebook(QString name=QString(), QString color=QString())
Creates and sets a default notebook.
Definition extendedstorage.cpp:551
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:189
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:523
void emitStorageModified(const QString &info)
Definition extendedstorage.cpp:349
virtual bool loadIncidenceInstance(const QString &instanceIdentifier)
Load the incidence matching the given identifier.
Definition extendedstorage.cpp:281
void unregisterObserver(ExtendedStorageObserver *observer)
Unregisters an Observer for this Storage.
Definition extendedstorage.cpp:344
bool setDefaultNotebook(const Notebook::Ptr &nb)
setDefaultNotebook to the storage.
Definition extendedstorage.cpp:491
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:528
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:165
void setIsRecurrenceLoaded(bool loaded)
Definition extendedstorage.cpp:262
bool isRecurrenceLoaded() const
Definition extendedstorage.cpp:257
virtual void calendarModified(bool modified, KCalendarCore::Calendar *calendar)=0
ExtendedCalendar::Ptr calendar() const
Definition extendedstorage.cpp:183
bool addNotebook(const Notebook::Ptr &nb)
Add new notebook to the storage.
Definition extendedstorage.cpp:391
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:337
bool isValidNotebook(const QString &notebookUid) const
Returns true if the given notebook is valid for the storage.
Definition extendedstorage.cpp:533
virtual bool loadNotebooks()=0
DeleteAction
Action to be performed on save for deleted incidences.
Definition extendedstorage.h:75
@ MarkDeleted
Definition extendedstorage.h:76
@ PurgeDeleted
Definition extendedstorage.h:77
bool getLoadDates(const QDate &start, const QDate &end, QDateTime *loadStart, QDateTime *loadEnd) const
Definition extendedstorage.cpp:194
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:513
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:410
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:267
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:518
void emitStorageUpdated(const KCalendarCore::Incidence::List &added, const KCalendarCore::Incidence::List &modified, const KCalendarCore::Incidence::List &deleted)
Definition extendedstorage.cpp:375
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:368
virtual bool insertNotebook(const Notebook::Ptr &nb)=0
Notebook::Ptr defaultNotebook()
defaultNotebook.
Definition extendedstorage.cpp:508
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