diff --git a/src/calendar.h b/src/calendar.h index 381b1c7c0..a96377d01 100644 --- a/src/calendar.h +++ b/src/calendar.h @@ -1,1413 +1,1411 @@ /* This file is part of the kcalcore library. Copyright (c) 1998 Preston Brown Copyright (c) 2001,2003,2004 Cornelius Schumacher Copyright (C) 2003-2004 Reinhold Kainhofer Copyright (c) 2006 David Jarvie This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** @file This file is part of the API for handling calendar data and defines the Calendar class. @author Preston Brown \ @author Cornelius Schumacher \ @author Reinhold Kainhofer \ @author David Jarvie \ */ /* TODO: KDE5: This API needs serious cleaning up: - Most (all) methods aren't async ( deleteIncidence(), addIncidence(), load(), save(), ... ) so it's not very easy to make a derived class that loads from akonadi. - It has too many methods. Why do we need fooEvent()/fooJournal()/fooTodo() when fooIncidence() should be enough. */ #ifndef KCALCORE_CALENDAR_H #define KCALCORE_CALENDAR_H #include "kcalcore_export.h" #include "event.h" #include "customproperties.h" #include "incidence.h" #include "journal.h" #include "todo.h" #include #include #include /** Namespace for all KCalCore types. */ namespace KCalCore { class CalFilter; class Person; class ICalFormat; /** Calendar Incidence sort directions. */ enum SortDirection { SortDirectionAscending, /**< Sort in ascending order (first to last) */ SortDirectionDescending /**< Sort in descending order (last to first) */ }; /** Calendar Event sort keys. */ enum EventSortField { EventSortUnsorted, /**< Do not sort Events */ EventSortStartDate, /**< Sort Events chronologically, by start date */ EventSortEndDate, /**< Sort Events chronologically, by end date */ EventSortSummary /**< Sort Events alphabetically, by summary */ }; /** Calendar Todo sort keys. */ enum TodoSortField { TodoSortUnsorted, /**< Do not sort Todos */ TodoSortStartDate, /**< Sort Todos chronologically, by start date */ TodoSortDueDate, /**< Sort Todos chronologically, by due date */ TodoSortPriority, /**< Sort Todos by priority */ TodoSortPercentComplete, /**< Sort Todos by percentage completed */ TodoSortSummary, /**< Sort Todos alphabetically, by summary */ TodoSortCreated /**< Sort Todos chronologically, by creation date */ }; /** Calendar Journal sort keys. */ enum JournalSortField { JournalSortUnsorted, /**< Do not sort Journals */ JournalSortDate, /**< Sort Journals chronologically by date */ JournalSortSummary /**< Sort Journals alphabetically, by summary */ }; /** @brief Represents the main calendar class. A calendar contains information like incidences (events, to-dos, journals), alarms, time zones, and other useful information. This is an abstract base class defining the interface to a calendar. It is implemented by subclasses like MemoryCalendar, which use different methods to store and access the data. Ownership of Incidences: Incidence ownership is handled by the following policy: as soon as an incidence (or any other subclass of IncidenceBase) is added to the Calendar by an add...() method it is owned by the Calendar object. The Calendar takes care of deleting the incidence using the delete...() methods. All Incidences returned by the query functions are returned as pointers so that changes to the returned Incidences are immediately visible in the Calendar. Do Not attempt to 'delete' any Incidence object you get from Calendar -- use the delete...() methods. */ class KCALCORE_EXPORT Calendar : public QObject, public CustomProperties, public IncidenceBase::IncidenceObserver { Q_OBJECT Q_PROPERTY(QString productId READ productId WRITE setProductId) public: /** A shared pointer to a Calendar */ typedef QSharedPointer Ptr; /** Constructs a calendar with a specified time zone @p timeZone. The time zone is used as the default for creating or modifying incidences in the Calendar. The time zone does not alter existing incidences. @param timeZone time specification */ explicit Calendar(const QTimeZone &timeZone); /** Construct Calendar object using a time zone ID. The time zone ID is used as the default for creating or modifying incidences in the Calendar. The time zone does not alter existing incidences. @param timeZoneId is a string containing a time zone ID, which is assumed to be valid. If no time zone is found, the viewing time specification is set to local time zone. @e Example: "Europe/Berlin" */ explicit Calendar(const QByteArray &timeZoneId); /** Destroys the calendar. */ ~Calendar() override; /** Sets the calendar Product ID to @p id. @param id is a string containing the Product ID. @see productId() const */ void setProductId(const QString &id); /** Returns the calendar's Product ID. @see setProductId() */ Q_REQUIRED_RESULT QString productId() const; /** Sets the owner of the calendar to @p owner. @param owner is a Person object. Must be a non-null pointer. @see owner() */ void setOwner(const Person::Ptr &owner); /** Returns the owner of the calendar. @return the owner Person object. @see setOwner() */ Q_REQUIRED_RESULT Person::Ptr owner() const; /** Sets the default time specification zone used for creating or modifying incidences in the Calendar. @param timeZone The time zone */ void setTimeZone(const QTimeZone &timeZone); /** Get the time zone used for creating or modifying incidences in the Calendar. @return time specification */ Q_REQUIRED_RESULT QTimeZone timeZone() const; /** Sets the time zone ID used for creating or modifying incidences in the Calendar. This method has no effect on existing incidences. @param timeZoneId is a string containing a time zone ID, which is assumed to be valid. The time zone ID is used to set the time zone for viewing Incidence date/times. If no time zone is found, the viewing time specification is set to local time zone. @e Example: "Europe/Berlin" @see setTimeZone() */ void setTimeZoneId(const QByteArray &timeZoneId); /** Returns the time zone ID used for creating or modifying incidences in the calendar. @return the string containing the time zone ID, or empty string if the creation/modification time specification is not a time zone. */ Q_REQUIRED_RESULT QByteArray timeZoneId() const; /** Shifts the times of all incidences so that they appear at the same clock time as before but in a new time zone. The shift is done from a viewing time zone rather than from the actual incidence time zone. For example, shifting an incidence whose start time is 09:00 America/New York, using an old viewing time zone (@p oldSpec) of Europe/London, to a new time zone (@p newSpec) of Europe/Paris, will result in the time being shifted from 14:00 (which is the London time of the incidence start) to 14:00 Paris time. @param oldZone the time zone which provides the clock times @param newZone the new time zone - - @see isLocalTime() */ void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone); /** Sets if the calendar has been modified. @param modified is true if the calendar has been modified since open or last save. @see isModified() */ void setModified(bool modified); /** Determine the calendar's modification status. @return true if the calendar has been modified since open or last save. @see setModified() */ Q_REQUIRED_RESULT bool isModified() const; /** Clears out the current calendar, freeing all used memory etc. */ virtual void close() = 0; /** Syncs changes in memory to persistent storage. @return true if the save was successful; false otherwise. Base implementation returns true. */ virtual bool save(); /** Loads the calendar contents from storage. This requires that the calendar has been previously loaded (initialized). @return true if the reload was successful; otherwise false. Base implementation returns true. */ virtual bool reload(); /** Determine if the calendar is currently being saved. @return true if the calendar is currently being saved; false otherwise. */ virtual bool isSaving() const; /** Returns a list of all categories used by Incidences in this Calendar. @return a QStringList containing all the categories. */ Q_REQUIRED_RESULT QStringList categories() const; // Incidence Specific Methods // /** Call this to tell the calendar that you're adding a batch of incidences. So it doesn't, for example, ask the destination for each incidence. @see endBatchAdding() */ virtual void startBatchAdding(); /** Tells the Calendar that you stoped adding a batch of incidences. @see startBatchAdding() */ virtual void endBatchAdding(); /** @return true if batch adding is in progress */ Q_REQUIRED_RESULT bool batchAdding() const; /** Inserts an Incidence into the calendar. @param incidence is a pointer to the Incidence to insert. @return true if the Incidence was successfully inserted; false otherwise. @see deleteIncidence() */ virtual bool addIncidence(const Incidence::Ptr &incidence); /** Removes an Incidence from the calendar. @param incidence is a pointer to the Incidence to remove. @return true if the Incidence was successfully removed; false otherwise. @see addIncidence() */ virtual bool deleteIncidence(const Incidence::Ptr &incidence); /** Returns a filtered list of all Incidences for this Calendar. @return the list of all filtered Incidences. */ virtual Incidence::List incidences() const; /** Returns a filtered list of all Incidences which occur on the given date. @param date request filtered Incidence list for this QDate only. @return the list of filtered Incidences occurring on the specified date. */ virtual Incidence::List incidences(const QDate &date) const; /** Returns an unfiltered list of all Incidences for this Calendar. @return the list of all unfiltered Incidences. */ virtual Incidence::List rawIncidences() const; /** Returns an unfiltered list of all exceptions of this recurring incidence. @param incidence incidence to check @return the list of all unfiltered exceptions. */ virtual Incidence::List instances(const Incidence::Ptr &incidence) const; // Notebook Specific Methods // /** Clears notebook associations from hash-tables for incidences. Called when in-memory content of the calendar is cleared. */ virtual void clearNotebookAssociations(); /** Associate notebook for an incidence. @param incidence incidence @param notebook notebook uid @return true if the operation was successful; false otherwise. */ virtual bool setNotebook(const Incidence::Ptr &incidence, const QString ¬ebook); /** Get incidence's notebook. @param incidence incidence @return notebook uid */ virtual QString notebook(const Incidence::Ptr &incidence) const; /** Get incidence's notebook. @param uid is a unique identifier string @return notebook uid */ virtual QString notebook(const QString &uid) const; /** List all uids of notebooks currently in the memory. @return list of uids of notebooks */ virtual QStringList notebooks() const; /** Check if calendar knows about the given notebook. This means that it will be saved by one of the attached storages. @param notebook notebook uid @return true if calendar has valid notebook */ Q_REQUIRED_RESULT bool hasValidNotebook(const QString ¬ebook) const; /** Add notebook information into calendar. Is usually called by storages only. @param notebook notebook uid @param isVisible notebook visibility @return true if operation succeeded @see isVisible() */ Q_REQUIRED_RESULT bool addNotebook(const QString ¬ebook, bool isVisible); /** Update notebook information in calendar. Is usually called by storages only. @param notebook notebook uid @param isVisible notebook visibility @return true if operation succeeded @see isVisible() */ Q_REQUIRED_RESULT bool updateNotebook(const QString ¬ebook, bool isVisible); /** Delete notebook information from calendar. Is usually called by storages only. @param notebook notebook uid @return true if operation succeeded @see isVisible() */ Q_REQUIRED_RESULT bool deleteNotebook(const QString ¬ebook); /** set DefaultNotebook information to calendar. @param notebook notebook uid @return true if operation was successful; false otherwise. */ Q_REQUIRED_RESULT bool setDefaultNotebook(const QString ¬ebook); /** Get uid of default notebook. @return notebook uid */ Q_REQUIRED_RESULT QString defaultNotebook() const; /** Check if incidence is visible. @param incidence is a pointer to the Incidence to check for visibility. @return true if incidence is visible, false otherwise */ Q_REQUIRED_RESULT bool isVisible(const Incidence::Ptr &incidence) const; /** List all notebook incidences in the memory. @param notebook is the notebook uid. @return a list of incidences for the notebook. */ virtual Incidence::List incidences(const QString ¬ebook) const; /** List all possible duplicate incidences. @param incidence is the incidence to check. @return a list of duplicate incidences. */ virtual Incidence::List duplicates(const Incidence::Ptr &incidence); /** Returns the Incidence associated with the given unique identifier. @param uid is a unique identifier string. @param recurrenceId is possible recurrenceid of incidence, default is null @return a pointer to the Incidence. A null pointer is returned if no such Incidence exists. */ Incidence::Ptr incidence(const QString &uid, const QDateTime &recurrenceId = {}) const; /** Returns the deleted Incidence associated with the given unique identifier. @param uid is a unique identifier string. @param recurrenceId is possible recurrenceid of incidence, default is null @return a pointer to the Incidence. A null pointer is returned if no such Incidence exists. */ Incidence::Ptr deleted(const QString &uid, const QDateTime &recurrenceId = {}) const; /** Delete all incidences that are instances of recurring incidence @p incidence. @param incidence is a pointer to a deleted Incidence @return true if delete was successful; false otherwise */ virtual bool deleteIncidenceInstances(const Incidence::Ptr &incidence) = 0; /** Returns the Incidence associated with the given scheduling identifier. @param sid is a unique scheduling identifier string. @return a pointer to the Incidence. A null pointer is returned if no such Incidence exists. */ virtual Incidence::Ptr incidenceFromSchedulingID(const QString &sid) const; /** Searches all events and todos for an incidence with this scheduling identifier. Returns a list of matching results. @param sid is a unique scheduling identifier string. */ virtual Incidence::List incidencesFromSchedulingID(const QString &sid) const; /** Create a merged list of Events, Todos, and Journals. @param events is an Event list to merge. @param todos is a Todo list to merge. @param journals is a Journal list to merge. @return a list of merged Incidences. */ static Incidence::List mergeIncidenceList(const Event::List &events, const Todo::List &todos, const Journal::List &journals); /** Flag that a change to a Calendar Incidence is starting. @param incidence is a pointer to the Incidence that will be changing. */ virtual bool beginChange(const Incidence::Ptr &incidence); /** Flag that a change to a Calendar Incidence has completed. @param incidence is a pointer to the Incidence that was changed. */ virtual bool endChange(const Incidence::Ptr &incidence); /** Creates an exception for an occurrence from a recurring Incidence. The returned exception is not automatically inserted into the calendar. @param incidence is a pointer to a recurring Incidence. @param recurrenceId specifies the specific occurrence for which the exception applies. @param thisAndFuture specifies if the exception applies only this specific occcurrence or also to all future occurrences. @return a pointer to a new exception incidence with @param recurrenceId set. @since 4.11 */ static Incidence::Ptr createException(const Incidence::Ptr &incidence, const QDateTime &recurrenceId, bool thisAndFuture = false); // Event Specific Methods // /** Inserts an Event into the calendar. @param event is a pointer to the Event to insert. @return true if the Event was successfully inserted; false otherwise. @see deleteEvent() */ virtual bool addEvent(const Event::Ptr &event) = 0; /** Removes an Event from the calendar. @param event is a pointer to the Event to remove. @return true if the Event was successfully remove; false otherwise. - @see addEvent(), deleteAllEvents() + @see addEvent() */ virtual bool deleteEvent(const Event::Ptr &event) = 0; /** Delete all events that are instances of recurring event @p event. @param event is a pointer to a deleted Event @return true if delete was successful; false otherwise */ virtual bool deleteEventInstances(const Event::Ptr &event) = 0; /** Sort a list of Events. @param eventList is a pointer to a list of Events. @param sortField specifies the EventSortField. @param sortDirection specifies the SortDirection. @return a list of Events sorted as specified. */ static Event::List sortEvents(const Event::List &eventList, EventSortField sortField, SortDirection sortDirection); /** Returns a sorted, filtered list of all Events for this Calendar. @param sortField specifies the EventSortField. @param sortDirection specifies the SortDirection. @return the list of all filtered Events sorted as specified. */ virtual Event::List events(EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const; /** Returns a filtered list of all Events which occur on the given timestamp. @param dt request filtered Event list for this QDateTime only. @return the list of filtered Events occurring on the specified timestamp. */ Q_REQUIRED_RESULT Event::List events(const QDateTime &dt) const; /** Returns a filtered list of all Events occurring within a date range. @param start is the starting date. @param end is the ending date. @param timeZone time zone to interpret @p start and @p end, or the calendar's default time zone if none is specified @param inclusive if true only Events which are completely included within the date range are returned. @return the list of filtered Events occurring within the specified date range. */ Q_REQUIRED_RESULT Event::List events(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const; /** Returns a sorted, filtered list of all Events which occur on the given date. The Events are sorted according to @a sortField and @a sortDirection. @param date request filtered Event list for this QDate only. @param timeZone time zone to interpret @p start and @p end, or the calendar's default time zone if none is specified @param sortField specifies the EventSortField. @param sortDirection specifies the SortDirection. @return the list of sorted, filtered Events occurring on @a date. */ Q_REQUIRED_RESULT Event::List events(const QDate &date, const QTimeZone &timeZone = {}, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const; /** Returns a sorted, unfiltered list of all Events for this Calendar. @param sortField specifies the EventSortField. @param sortDirection specifies the SortDirection. @return the list of all unfiltered Events sorted as specified. */ virtual Event::List rawEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0; /** Returns an unfiltered list of all Events which occur on the given timestamp. @param dt request unfiltered Event list for this QDateTime only. @return the list of unfiltered Events occurring on the specified timestamp. */ virtual Event::List rawEventsForDate(const QDateTime &dt) const = 0; /** Returns an unfiltered list of all Events occurring within a date range. @param start is the starting date @param end is the ending date @param timeZone time zone to interpret @p start and @p end, or the calendar's default time zone if none is specified @param inclusive if true only Events which are completely included within the date range are returned. @return the list of unfiltered Events occurring within the specified date range. */ virtual Event::List rawEvents(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const = 0; /** Returns a sorted, unfiltered list of all Events which occur on the given date. The Events are sorted according to @a sortField and @a sortDirection. @param date request unfiltered Event list for this QDate only @param timeZone time zone to interpret @p date, or the calendar's default time zone if none is specified @param sortField specifies the EventSortField @param sortDirection specifies the SortDirection @return the list of sorted, unfiltered Events occurring on @p date */ virtual Event::List rawEventsForDate( const QDate &date, const QTimeZone &timeZone = {}, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0; /** Returns the Event associated with the given unique identifier. @param uid is a unique identifier string. @param recurrenceId is possible recurrenceId of event, default is null @return a pointer to the Event. A null pointer is returned if no such Event exists. */ virtual Event::Ptr event(const QString &uid, const QDateTime &recurrenceId = {}) const = 0; /** Returns the deleted Event associated with the given unique identifier. @param uid is a unique identifier string. @param recurrenceId is possible recurrenceId of event, default is null @return a pointer to the deleted Event. A null pointer is returned if no such deleted Event exists, or if deletion tracking is disabled. @see deletionTracking() */ virtual Event::Ptr deletedEvent(const QString &uid, const QDateTime &recurrenceId = {}) const = 0; /** Returns a sorted, unfiltered list of all deleted Events for this Calendar. @param sortField specifies the EventSortField. @param sortDirection specifies the SortDirection. @return the list of all unfiltered deleted Events sorted as specified. An empty list is returned if deletion tracking is disabled. @see deletionTracking() */ virtual Event::List deletedEvents( EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0; /** Returns a sorted, unfiltered list of all possible instances for this recurring Event. @param event event to check for. Caller guarantees it's of type Event. @param sortField specifies the EventSortField. @param sortDirection specifies the SortDirection. @return the list of all unfiltered event instances sorted as specified. */ virtual Event::List eventInstances( const Incidence::Ptr &event, EventSortField sortField = EventSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0; // Todo Specific Methods // /** Inserts a Todo into the calendar. @param todo is a pointer to the Todo to insert. @return true if the Todo was successfully inserted; false otherwise. @see deleteTodo() */ virtual bool addTodo(const Todo::Ptr &todo) = 0; /** Removes a Todo from the calendar. @param todo is a pointer to the Todo to remove. @return true if the Todo was successfully removed; false otherwise. - @see addTodo(), deleteAllTodos() + @see addTodo() */ virtual bool deleteTodo(const Todo::Ptr &todo) = 0; /** Delete all to-dos that are instances of recurring to-do @p todo. @param todo is a pointer to a deleted Todo @return true if delete was successful; false otherwise */ virtual bool deleteTodoInstances(const Todo::Ptr &todo) = 0; /** Sort a list of Todos. @param todoList is a pointer to a list of Todos. @param sortField specifies the TodoSortField. @param sortDirection specifies the SortDirection. @return a list of Todos sorted as specified. */ static Todo::List sortTodos(const Todo::List &todoList, TodoSortField sortField, SortDirection sortDirection); /** Returns a sorted, filtered list of all Todos for this Calendar. @param sortField specifies the TodoSortField. @param sortDirection specifies the SortDirection. @return the list of all filtered Todos sorted as specified. */ virtual Todo::List todos(TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const; /** Returns a filtered list of all Todos which are due on the specified date. @param date request filtered Todos due on this QDate. @return the list of filtered Todos due on the specified date. */ virtual Todo::List todos(const QDate &date) const; /** Returns a filtered list of all Todos occurring within a date range. @param start is the starting date @param end is the ending date @param timeZone time zone to interpret @p start and @p end, or the calendar's default time zone if none is specified @param inclusive if true only Todos which are completely included within the date range are returned. @return the list of filtered Todos occurring within the specified date range. */ virtual Todo::List todos(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const; /** Returns a sorted, unfiltered list of all Todos for this Calendar. @param sortField specifies the TodoSortField. @param sortDirection specifies the SortDirection. @return the list of all unfiltered Todos sorted as specified. */ virtual Todo::List rawTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0; /** Returns an unfiltered list of all Todos which due on the specified date. @param date request unfiltered Todos due on this QDate. @return the list of unfiltered Todos due on the specified date. */ virtual Todo::List rawTodosForDate(const QDate &date) const = 0; /** Returns an unfiltered list of all Todos occurring within a date range. @param start is the starting date @param end is the ending date @param timeZone time zone to interpret @p start and @p end, or the calendar's default time zone if none is specified @param inclusive if true only Todos which are completely included within the date range are returned. @return the list of unfiltered Todos occurring within the specified date range. */ virtual Todo::List rawTodos(const QDate &start, const QDate &end, const QTimeZone &timeZone = {}, bool inclusive = false) const = 0; /** Returns the Todo associated with the given unique identifier. @param uid is a unique identifier string. @param recurrenceId is possible recurrenceId of todo, default is null @return a pointer to the Todo. A null pointer is returned if no such Todo exists. */ virtual Todo::Ptr todo(const QString &uid, const QDateTime &recurrenceId = {}) const = 0; /** Returns the deleted Todo associated with the given unique identifier. @param uid is a unique identifier string. @param recurrenceId is possible recurrenceId of todo, default is null @return a pointer to the deleted Todo. A null pointer is returned if no such deleted Todo exists or if deletion tracking is disabled. @see deletionTracking() */ virtual Todo::Ptr deletedTodo(const QString &uid, const QDateTime &recurrenceId = {}) const = 0; /** Returns a sorted, unfiltered list of all deleted Todos for this Calendar. @param sortField specifies the TodoSortField. @param sortDirection specifies the SortDirection. @return the list of all unfiltered deleted Todos sorted as specified. An empty list is returned if deletion tracking is disabled. @see deletionTracking() */ virtual Todo::List deletedTodos( TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0; /** Returns a sorted, unfiltered list of all possible instances for this recurring Todo. @param todo todo to check for. Caller guarantees it's of type Todo. @param sortField specifies the TodoSortField. @param sortDirection specifies the SortDirection. @return the list of all unfiltered todo instances sorted as specified. */ virtual Todo::List todoInstances( const Incidence::Ptr &todo, TodoSortField sortField = TodoSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0; // Journal Specific Methods // /** Inserts a Journal into the calendar. @param journal is a pointer to the Journal to insert. @return true if the Journal was successfully inserted; false otherwise. @see deleteJournal() */ virtual bool addJournal(const Journal::Ptr &journal) = 0; /** Removes a Journal from the calendar. @param journal is a pointer to the Journal to remove. @return true if the Journal was successfully removed; false otherwise. - @see addJournal(), deleteAllJournals() + @see addJournal() */ virtual bool deleteJournal(const Journal::Ptr &journal) = 0; /** Delete all journals that are instances of recurring journal @p journal. @param journal is a pointer to a deleted Journal @return true if delete was successful; false otherwise */ virtual bool deleteJournalInstances(const Journal::Ptr &journal) = 0; /** Sort a list of Journals. @param journalList is a pointer to a list of Journals. @param sortField specifies the JournalSortField. @param sortDirection specifies the SortDirection. @return a list of Journals sorted as specified. */ static Journal::List sortJournals(const Journal::List &journalList, JournalSortField sortField, SortDirection sortDirection); /** Returns a sorted, filtered list of all Journals for this Calendar. @param sortField specifies the JournalSortField. @param sortDirection specifies the SortDirection. @return the list of all filtered Journals sorted as specified. */ virtual Journal::List journals( JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const; /** Returns a filtered list of all Journals for on the specified date. @param date request filtered Journals for this QDate only. @return the list of filtered Journals for the specified date. */ virtual Journal::List journals(const QDate &date) const; /** Returns a sorted, unfiltered list of all Journals for this Calendar. @param sortField specifies the JournalSortField. @param sortDirection specifies the SortDirection. @return the list of all unfiltered Journals sorted as specified. */ virtual Journal::List rawJournals( JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0; /** Returns an unfiltered list of all Journals for on the specified date. @param date request unfiltered Journals for this QDate only. @return the list of unfiltered Journals for the specified date. */ virtual Journal::List rawJournalsForDate(const QDate &date) const = 0; /** Returns the Journal associated with the given unique identifier. @param uid is a unique identifier string. @param recurrenceId is possible recurrenceId of journal, default is null @return a pointer to the Journal. A null pointer is returned if no such Journal exists. */ virtual Journal::Ptr journal(const QString &uid, const QDateTime &recurrenceId = {}) const = 0; /** Returns the deleted Journal associated with the given unique identifier. @param uid is a unique identifier string. @param recurrenceId is possible recurrenceId of journal, default is null @return a pointer to the deleted Journal. A null pointer is returned if no such deleted Journal exists or if deletion tracking is disabled. @see deletionTracking() */ virtual Journal::Ptr deletedJournal(const QString &uid, const QDateTime &recurrenceId = {}) const = 0; /** Returns a sorted, unfiltered list of all deleted Journals for this Calendar. @param sortField specifies the JournalSortField. @param sortDirection specifies the SortDirection. @return the list of all unfiltered deleted Journals sorted as specified. An empty list is returned if deletion tracking is disabled. @see deletionTracking() */ virtual Journal::List deletedJournals( JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0; /** Returns a sorted, unfiltered list of all instances for this recurring Journal. @param journal journal to check for. Caller guarantees it's of type Journal. @param sortField specifies the JournalSortField. @param sortDirection specifies the SortDirection. @return the list of all unfiltered journal instances sorted as specified. */ virtual Journal::List journalInstances( const Incidence::Ptr &journal, JournalSortField sortField = JournalSortUnsorted, SortDirection sortDirection = SortDirectionAscending) const = 0; // Relations Specific Methods // /** Setup Relations for an Incidence. @param incidence is a pointer to the Incidence to have a Relation setup. */ virtual void setupRelations(const Incidence::Ptr &incidence); /** Removes all Relations from an Incidence. @param incidence is a pointer to the Incidence to have a Relation removed. */ virtual void removeRelations(const Incidence::Ptr &incidence); /** Checks if @p ancestor is an ancestor of @p incidence @param ancestor is the incidence we are testing to be an ancestor. @param incidence is the incidence we are testing to be descended from @p ancestor. */ bool isAncestorOf(const Incidence::Ptr &ancestor, const Incidence::Ptr &incidence) const; /** Returns a list of incidences that have a relation of RELTYPE parent to incidence @p uid. @param uid The parent identifier whos children we want to obtain. */ Incidence::List relations(const QString &uid) const; // Filter Specific Methods // /** Sets the calendar filter. @param filter a pointer to a CalFilter object which will be used to filter Calendar Incidences. The Calendar takes ownership of @p filter. @see filter() */ void setFilter(CalFilter *filter); /** Returns the calendar filter. @return a pointer to the calendar CalFilter. A null pointer is returned if no such CalFilter exists. @see setFilter() */ CalFilter *filter() const; // Alarm Specific Methods // /** Returns a list of Alarms within a time range for this Calendar. @param from is the starting timestamp. @param to is the ending timestamp. @param excludeBlockedAlarms if true, alarms belonging to blocked collections aren't returned. @return the list of Alarms for the for the specified time range. */ virtual Alarm::List alarms(const QDateTime &from, const QDateTime &to, bool excludeBlockedAlarms = false) const = 0; // Observer Specific Methods // /** @class CalendarObserver The CalendarObserver class. */ class KCALCORE_EXPORT CalendarObserver //krazy:exclude=dpointer { public: /** Destructor. */ virtual ~CalendarObserver(); /** Notify the Observer that a Calendar has been modified. @param modified set if the calendar has been modified. @param calendar is a pointer to the Calendar object that is being observed. */ virtual void calendarModified(bool modified, Calendar *calendar); /** Notify the Observer that an Incidence has been inserted. @param incidence is a pointer to the Incidence that was inserted. */ virtual void calendarIncidenceAdded(const Incidence::Ptr &incidence); /** Notify the Observer that an Incidence has been modified. @param incidence is a pointer to the Incidence that was modified. */ virtual void calendarIncidenceChanged(const Incidence::Ptr &incidence); /** Notify the Observer that an Incidence will be removed. @param incidence is a pointer to the Incidence that will be removed. */ virtual void calendarIncidenceAboutToBeDeleted(const Incidence::Ptr &incidence); /** Notify the Observer that an Incidence has been removed. @param incidence is a pointer to the Incidence that was removed. @param calendar is a pointer to the calendar where the incidence was part of, because the incidence was deleted, there is now way to determine the calendar @since 4.83.0 */ virtual void calendarIncidenceDeleted(const Incidence::Ptr &incidence, const Calendar *calendar); /** Notify the Observer that an addition of Incidence has been canceled. @param incidence is a pointer to the Incidence that was removed. */ virtual void calendarIncidenceAdditionCanceled(const Incidence::Ptr &incidence); }; /** Registers an Observer for this Calendar. @param observer is a pointer to an Observer object that will be watching this Calendar. @see unregisterObserver() */ void registerObserver(CalendarObserver *observer); /** Unregisters an Observer for this Calendar. @param observer is a pointer to an Observer object that has been watching this Calendar. @see registerObserver() */ void unregisterObserver(CalendarObserver *observer); using QObject::event; // prevent warning about hidden virtual method protected: /** The Observer interface. So far not implemented. @param uid is the UID for the Incidence that has been updated. @param recurrenceId is possible recurrenceid of incidence. */ void incidenceUpdated(const QString &uid, const QDateTime &recurrenceId) override; /** Let Calendar subclasses set the time specification. @param timeZone is the time specification (time zone, etc.) for viewing Incidence dates.\n */ virtual void doSetTimeZone(const QTimeZone &timeZone); /** Let Calendar subclasses notify that they inserted an Incidence. @param incidence is a pointer to the Incidence object that was inserted. */ void notifyIncidenceAdded(const Incidence::Ptr &incidence); /** Let Calendar subclasses notify that they modified an Incidence. @param incidence is a pointer to the Incidence object that was modified. */ void notifyIncidenceChanged(const Incidence::Ptr &incidence); /** Let Calendar subclasses notify that they will remove an Incidence. @param incidence is a pointer to the Incidence object that will be removed. */ void notifyIncidenceAboutToBeDeleted(const Incidence::Ptr &incidence); /** Let Calendar subclasses notify that they removed an Incidence. @param incidence is a pointer to the Incidence object that has been removed. */ void notifyIncidenceDeleted(const Incidence::Ptr &incidence); /** Let Calendar subclasses notify that they canceled addition of an Incidence. @param incidence is a pointer to the Incidence object that addition as canceled. */ void notifyIncidenceAdditionCanceled(const Incidence::Ptr &incidence); /** @copydoc CustomProperties::customPropertyUpdated() */ void customPropertyUpdated() override; /** Let Calendar subclasses notify that they enabled an Observer. @param enabled if true tells the calendar that a subclass has enabled an Observer. */ void setObserversEnabled(bool enabled); /** Appends alarms of incidence in interval to list of alarms. @param alarms is a List of Alarms to be appended onto. @param incidence is a pointer to an Incidence containing the Alarm to be appended. @param from is the lower range of the next Alarm repitition. @param to is the upper range of the next Alarm repitition. */ void appendAlarms(Alarm::List &alarms, const Incidence::Ptr &incidence, const QDateTime &from, const QDateTime &to) const; /** Appends alarms of recurring events in interval to list of alarms. @param alarms is a List of Alarms to be appended onto. @param incidence is a pointer to an Incidence containing the Alarm to be appended. @param from is the lower range of the next Alarm repitition. @param to is the upper range of the next Alarm repitition. */ void appendRecurringAlarms(Alarm::List &alarms, const Incidence::Ptr &incidence, const QDateTime &from, const QDateTime &to) const; /** Enables or disabled deletion tracking. Default is true. @see deletedEvent() @see deletedTodo() @see deletedJournal() @since 4.11 */ void setDeletionTracking(bool enable); /** Returns if deletion tracking is enabled. Default is true. @since 4.11 */ bool deletionTracking() const; /** @copydoc IncidenceBase::virtual_hook() */ virtual void virtual_hook(int id, void *data); Q_SIGNALS: /** Emitted when setFilter() is called. @since 4.11 */ void filterChanged(); private: friend class ICalFormat; //@cond PRIVATE class Private; Private *const d; //@endcond Q_DISABLE_COPY(Calendar) }; } #endif diff --git a/src/incidence.h b/src/incidence.h index c1a03693d..f4774459c 100644 --- a/src/incidence.h +++ b/src/incidence.h @@ -1,897 +1,897 @@ /* This file is part of the kcalcore library. Copyright (c) 2001-2003 Cornelius Schumacher Copyright (C) 2003-2004 Reinhold Kainhofer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /** @file This file is part of the API for handling calendar data and defines the Incidence class. @author Cornelius Schumacher \ @author Reinhold Kainhofer \ */ #ifndef KCALCORE_INCIDENCE_H #define KCALCORE_INCIDENCE_H #include "kcalcore_export.h" #include "alarm.h" #include "attachment.h" #include "incidencebase.h" #include "recurrence.h" #include //@cond PRIVATE // Value used to signal invalid/unset latitude or longitude. #define INVALID_LATLON 255.0 //krazy:exclude=defines (part of the API) //@endcond namespace KCalCore { /** @brief Provides the abstract base class common to non-FreeBusy (Events, To-dos, Journals) calendar components known as incidences. Several properties are not allowed for VFREEBUSY objects (see rfc:2445), so they are not in IncidenceBase. The hierarchy is: IncidenceBase + FreeBusy + Incidence + Event + Todo + Journal So IncidenceBase contains all properties that are common to all classes, and Incidence contains all additional properties that are common to Events, Todos and Journals, but are not allowed for FreeBusy entries. */ class KCALCORE_EXPORT Incidence : public IncidenceBase, public Recurrence::RecurrenceObserver { Q_GADGET Q_PROPERTY(QString description READ description WRITE setDescription) Q_PROPERTY(QString summary READ summary WRITE setSummary) Q_PROPERTY(QString location READ location WRITE setLocation) Q_PROPERTY(QStringList categories READ categories WRITE setCategories) Q_PROPERTY(int priority READ priority WRITE setPriority) Q_PROPERTY(QDateTime created READ created WRITE setCreated) Q_PROPERTY(KCalCore::Incidence::Secrecy secrecy READ secrecy WRITE setSecrecy) public: /** The different types of overall incidence status or confirmation. The meaning is specific to the incidence type in context. */ enum Status { StatusNone, /**< No status */ StatusTentative, /**< event is tentative */ StatusConfirmed, /**< event is definite */ StatusCompleted, /**< to-do completed */ StatusNeedsAction, /**< to-do needs action */ StatusCanceled, /**< event or to-do canceled; journal removed */ StatusInProcess, /**< to-do in process */ StatusDraft, /**< journal is draft */ StatusFinal, /**< journal is final */ StatusX /**< a non-standard status string */ }; /** The different types of incidence access classifications. */ enum Secrecy { SecrecyPublic, /**< Not secret (default) */ SecrecyPrivate, /**< Secret to the owner */ SecrecyConfidential /**< Secret to the owner and some others */ }; Q_ENUM(Secrecy) /** The different types of RELTYPE values specified by the RFC. Only RelTypeParent is supported for now. */ enum RelType { RelTypeParent, /**< The related incidence is a parent. */ RelTypeChild, /**< The related incidence is a child. */ RelTypeSibling /**< The related incidence is a peer. */ }; /** A shared pointer to an Incidence. */ typedef QSharedPointer Ptr; /** List of incidences. */ typedef QVector List; /** Constructs an empty incidence.* */ Incidence(); /** Destroys an incidence. */ ~Incidence() override; /** Returns an exact copy of this incidence. The returned object is owned by the caller. Dirty fields are cleared. */ virtual Incidence *clone() const = 0; /** Returns a unique identifier for a specific instance of an incidence. Due to the recurrence-id, the uid is not unique for a KCalCore::Incidence. @since 4.11 */ Q_REQUIRED_RESULT QString instanceIdentifier() const; /** Set readonly state of incidence. @param readonly If true, the incidence is set to readonly, if false the incidence is set to readwrite. */ void setReadOnly(bool readonly) override; /** @copydoc IncidenceBase::setLastModified(). */ void setLastModified(const QDateTime &lm) override; /** Set localOnly state of incidence. A local only incidence can be updated but it will not increase the revision number neither the modified date. @param localonly If true, the incidence is set to localonly, if false the incidence is set to normal stat. */ void setLocalOnly(bool localonly); /** Get the localOnly status. @return true if Local only, false otherwise. @see setLocalOnly() */ Q_REQUIRED_RESULT bool localOnly() const; /** @copydoc IncidenceBase::setAllDay(). */ void setAllDay(bool allDay) override; /** Recreate incidence. The incidence is made a new unique incidence, but already stored information is preserved. Sets unique id, creation date, last modification date and revision number. */ void recreate(); /** Sets the incidence creation date/time. It is stored as a UTC date/time. @param dt is the creation date/time. @see created(). */ void setCreated(const QDateTime &dt); /** Returns the incidence creation date/time. @see setCreated(). */ Q_REQUIRED_RESULT QDateTime created() const; /** Sets the number of revisions this incidence has seen. @param rev is the incidence revision number. @see revision(). */ void setRevision(int rev); /** Returns the number of revisions this incidence has seen. @see setRevision(). */ Q_REQUIRED_RESULT int revision() const; /** Sets the incidence starting date/time. @param dt is the starting date/time. @see IncidenceBase::dtStart(). */ void setDtStart(const QDateTime &dt) override; /** @copydoc IncidenceBase::shiftTimes() */ void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone) override; /** Sets the incidence description. @param description is the incidence description string. @param isRich if true indicates the description string contains richtext. @see description(). */ void setDescription(const QString &description, bool isRich); /** Sets the incidence description and tries to guess if the description is rich text. @param description is the incidence description string. @see description(). */ void setDescription(const QString &description); /** Returns the incidence description. @see setDescription(). @see richDescription(). */ Q_REQUIRED_RESULT QString description() const; /** Returns the incidence description in rich text format. @see setDescription(). @see description(). */ Q_REQUIRED_RESULT QString richDescription() const; /** Returns true if incidence description contains RichText; false otherwise. @see setDescription(), description(). */ Q_REQUIRED_RESULT bool descriptionIsRich() const; /** Sets the incidence summary. @param summary is the incidence summary string. @param isRich if true indicates the summary string contains richtext. @see summary(). */ void setSummary(const QString &summary, bool isRich); /** Sets the incidence summary and tries to guess if the summary is richtext. @param summary is the incidence summary string. @see summary(). */ void setSummary(const QString &summary); /** Returns the incidence summary. @see setSummary(). @see richSummary(). */ Q_REQUIRED_RESULT QString summary() const; /** Returns the incidence summary in rich text format. @see setSummary(). @see summary(). */ Q_REQUIRED_RESULT QString richSummary() const; /** Returns true if incidence summary contains RichText; false otherwise. @see setSummary(), summary(). */ Q_REQUIRED_RESULT bool summaryIsRich() const; /** Sets the incidence location. Do _not_ use with journals. @param location is the incidence location string. @param isRich if true indicates the location string contains richtext. @see location(). */ void setLocation(const QString &location, bool isRich); /** Sets the incidence location and tries to guess if the location is richtext. Do _not_ use with journals. @param location is the incidence location string. @see location(). */ void setLocation(const QString &location); /** Returns the incidence location. Do _not_ use with journals. @see setLocation(). @see richLocation(). */ Q_REQUIRED_RESULT QString location() const; /** Returns the incidence location in rich text format. @see setLocation(). @see location(). */ Q_REQUIRED_RESULT QString richLocation() const; /** Returns true if incidence location contains RichText; false otherwise. @see setLocation(), location(). */ Q_REQUIRED_RESULT bool locationIsRich() const; /** Sets the incidence category list. @param categories is a list of category strings. @see setCategories( const QString &), categories(). */ void setCategories(const QStringList &categories); /** Sets the incidence category list based on a comma delimited string. @param catStr is a QString containing a list of categories which are delimited by a comma character. @see setCategories( const QStringList &), categories(). */ void setCategories(const QString &catStr); /** Returns the incidence categories as a list of strings. - @see setCategories( const QStringList &), setCategories( Const QString &). + @see setCategories( const QStringList &), setCategories( const QString &). */ Q_REQUIRED_RESULT QStringList categories() const; /** Returns the incidence categories as a comma separated string. @see categories(). */ Q_REQUIRED_RESULT QString categoriesStr() const; /** Relates another incidence to this one, by UID. This function should only be used when constructing a calendar before the related incidence exists. @param uid is a QString containing a UID for another incidence. @param relType specifies the relation type. @warning KCalCore only supports one related-to field per reltype for now. @see relatedTo(). */ void setRelatedTo(const QString &uid, RelType relType = RelTypeParent); /** Returns a UID string for the incidence that is related to this one. This function should only be used when constructing a calendar before the related incidence exists. @warning KCalCore only supports one related-to field per reltype for now. @param relType specifies the relation type. @see setRelatedTo(). */ Q_REQUIRED_RESULT QString relatedTo(RelType relType = RelTypeParent) const; // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%% Convenience wrappers for property handling // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /** Returns true if the alternative (=text/html) description is available. @see setAltDescription(), altDescription() */ Q_REQUIRED_RESULT bool hasAltDescription() const; /** Sets the incidence's alternative (=text/html) description. If the text is empty, the property is removed. @param altdescription is the incidence altdescription string. @see altAltdescription(). */ void setAltDescription(const QString &altdescription); /** Returns the incidence alternative (=text/html) description. @see setAltDescription(). */ Q_REQUIRED_RESULT QString altDescription() const; // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%% Recurrence-related methods // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /** Returns the recurrence rule associated with this incidence. If there is none, returns an appropriate (non-0) object. */ Recurrence *recurrence() const; /** Removes all recurrence and exception rules and dates. */ void clearRecurrence(); /** @copydoc Recurrence::recurs() */ Q_REQUIRED_RESULT bool recurs() const; /** @copydoc Recurrence::recurrenceType() */ Q_REQUIRED_RESULT ushort recurrenceType() const; /** @copydoc Recurrence::recursOn() */ virtual bool recursOn(const QDate &date, const QTimeZone &timeZone) const; /** @copydoc Recurrence::recursAt() */ Q_REQUIRED_RESULT bool recursAt(const QDateTime &dt) const; /** Calculates the start date/time for all recurrences that happen at some time on the given date (might start before that date, but end on or after the given date). @param date the date when the incidence should occur @param timeSpec time specification for @p date. @return the start date/time of all occurrences that overlap with the given date; an empty list if the incidence does not overlap with the date at all. */ virtual QList startDateTimesForDate(const QDate &date, const QTimeZone &timeZone) const; /** Calculates the start date/time for all recurrences that happen at the given time. @param datetime the date/time when the incidence should occur. @return the start date/time of all occurrences that overlap with the given date/time; an empty list if the incidence does not happen at the given time at all. */ Q_REQUIRED_RESULT virtual QList startDateTimesForDateTime(const QDateTime &datetime) const; /** Returns the end date/time of the incidence occurrence if it starts at specified date/time. @param startDt is the specified starting date/time. @return the corresponding end date/time for the occurrence; or the start date/time if the end date/time is invalid; or the end date/time if the start date/time is invalid. */ Q_REQUIRED_RESULT virtual QDateTime endDateForStart(const QDateTime &startDt) const; // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%% Attachment-related methods // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /** Adds an attachment to the incidence. @param attachment is a pointer to a valid Attachment object. @see deleteAttachment(). */ void addAttachment(const Attachment::Ptr &attachment); /** Removes the specified attachment from the incidence. Additionally, the memory used by the attachment is freed. @param attachment is a pointer to a valid Attachment object. @see addAttachment(), deleteAttachments(). */ void deleteAttachment(const Attachment::Ptr &attachment); /** Removes all attachments of the specified MIME type from the incidence. The memory used by all the removed attachments is freed. @param mime is a QString containing the MIME type. @see deleteAttachment(). */ void deleteAttachments(const QString &mime); /** Returns a list of all incidence attachments. @see attachments( const QString &). */ Q_REQUIRED_RESULT Attachment::List attachments() const; /** Returns a list of all incidence attachments with the specified MIME type. @param mime is a QString containing the MIME type. @see attachments(). */ Q_REQUIRED_RESULT Attachment::List attachments(const QString &mime) const; /** Removes all attachments and frees the memory used by them. @see deleteAttachment( Attachment::Ptr), deleteAttachments( const QString &). */ void clearAttachments(); /** Writes the data in the attachment @p attachment to a temporary file and returns the local name of the temporary file. @param attachment is a pointer to a valid Attachment instance. @return a string containing the name of the temporary file containing the attachment. @see clearTempFiles(). */ Q_REQUIRED_RESULT QString writeAttachmentToTempFile(const Attachment::Ptr &attachment) const; /** Deletes all temporary files used by attachments and frees any memory in use by them. @see writeAttachmentToTempFile(). */ void clearTempFiles(); // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%% Secrecy and Status methods // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /** Sets the incidence #Secrecy. @param secrecy is the incidence #Secrecy to set. @see secrecy(), secrecyStr(). */ void setSecrecy(Secrecy secrecy); /** Returns the incidence #Secrecy. @see setSecrecy(), secrecyStr(). */ Q_REQUIRED_RESULT Secrecy secrecy() const; /** Sets the incidence status to a standard #Status value. Note that StatusX cannot be specified. @param status is the incidence #Status to set. @see status(), setCustomStatus(). */ void setStatus(Status status); /** Sets the incidence #Status to a non-standard status value. @param status is a non-standard status string. If empty, the incidence #Status will be set to StatusNone. @see setStatus(), status() customStatus(). */ void setCustomStatus(const QString &status); /** Returns the non-standard status value. @see setCustomStatus(). */ Q_REQUIRED_RESULT QString customStatus() const; /** Returns the incidence #Status. @see setStatus(), setCustomStatus(), statusStr(). */ Q_REQUIRED_RESULT Status status() const; // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%% Other methods // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /** Sets a list of incidence resources. (Note: resources in this context means items used by the incidence such as money, fuel, hours, etc). @param resources is a list of resource strings. @see resources(). */ void setResources(const QStringList &resources); /** Returns the incidence resources as a list of strings. @see setResources(). */ Q_REQUIRED_RESULT QStringList resources() const; /** Sets the incidences priority. The priority must be an integer value between 0 and 9, where 0 is undefined, 1 is the highest, and 9 is the lowest priority (decreasing order). @param priority is the incidence priority to set. @see priority(). */ void setPriority(int priority); /** Returns the incidence priority. @see setPriority(). */ Q_REQUIRED_RESULT int priority() const; /** Returns true if the incidence has geo data, otherwise return false. @see setHasGeo(), setGeoLatitude(float), setGeoLongitude(float). */ Q_REQUIRED_RESULT bool hasGeo() const; /** Sets if the incidence has geo data. @param hasGeo true if incidence has geo data, otherwise false @see hasGeo(), geoLatitude(), geoLongitude(). */ void setHasGeo(bool hasGeo); /** Set the incidences geoLatitude. @param geolatitude is the incidence geolatitude to set @see geoLatitude(). */ void setGeoLatitude(float geolatitude); /** Returns the incidence geoLatidude. @return incidences geolatitude value @see setGeoLatitude(). */ Q_REQUIRED_RESULT float geoLatitude() const; /** Set the incidencesgeoLongitude. @param geolongitude is the incidence geolongitude to set @see geoLongitude(). */ void setGeoLongitude(float geolongitude); /** Returns the incidence geoLongitude. @return incidences geolongitude value @see setGeoLongitude(). */ Q_REQUIRED_RESULT float geoLongitude() const; /** Returns true if the incidence has recurrenceId, otherwise return false. @see setRecurrenceId(QDateTime) */ Q_REQUIRED_RESULT bool hasRecurrenceId() const; /** Set the incidences recurrenceId. This field indicates that this is an exception to a recurring incidence. The uid of this incidence MUST be the same as the one of the recurring main incidence. @param recurrenceId is the incidence recurrenceId to set @see recurrenceId(). */ void setRecurrenceId(const QDateTime &recurrenceId); /** Returns the incidence recurrenceId. @return incidences recurrenceId value @see setRecurrenceId(). */ Q_REQUIRED_RESULT QDateTime recurrenceId() const override; /** Set to true if the exception also applies to all future occurrences. This option is only relevant if the incidence has a recurrenceId set. @param thisAndFuture value @see thisAndFuture(), setRecurrenceId() @since 4.11 */ void setThisAndFuture(bool thisAndFuture); /** Returns true if the exception also applies to all future occurrences. @return incidences thisAndFuture value @see setThisAndFuture() @since 4.11 */ Q_REQUIRED_RESULT bool thisAndFuture() const; // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%% Alarm-related methods // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /** Returns a list of all incidence alarms. */ Q_REQUIRED_RESULT Alarm::List alarms() const; /** Create a new incidence alarm. */ Alarm::Ptr newAlarm(); /** Adds an alarm to the incidence. @param alarm is a pointer to a valid Alarm object. @see removeAlarm(). */ void addAlarm(const Alarm::Ptr &alarm); /** Removes the specified alarm from the incidence. @param alarm is a pointer to a valid Alarm object. @see addAlarm(). */ void removeAlarm(const Alarm::Ptr &alarm); /** Removes all alarms. @see removeAlarm(). */ void clearAlarms(); /** Returns true if any of the incidence alarms are enabled; false otherwise. */ Q_REQUIRED_RESULT bool hasEnabledAlarms() const; // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%% Other methods // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /** Set the incidence scheduling ID. Do _not_ use with journals. This is used for accepted invitations as the place to store the UID of the invitation. It is later used again if updates to the invitation comes in. If we did not set a new UID on incidences from invitations, we can end up with more than one resource having events with the same UID, if you have access to other peoples resources. While constructing an incidence, when setting the scheduling ID, you will always want to set the incidence UID too. Instead of calling setUID() separately, you can pass the UID through @p uid so both members are changed in one atomic operation ( don't forget that setUID() emits incidenceUpdated() and whoever catches that signal will have an half-initialized incidence, therefore, always set the schedulingID and UID at the same time, and never with two separate calls). @param sid is a QString containing the scheduling ID. @param uid is a QString containing the incidence UID to set, if not specified, the current UID isn't changed, and this parameter is ignored. @see schedulingID(). */ void setSchedulingID(const QString &sid, const QString &uid = QString()); /** Returns the incidence scheduling ID. Do _not_ use with journals. If a scheduling ID is not set, then return the incidence UID. @see setSchedulingID(). */ Q_REQUIRED_RESULT QString schedulingID() const; /** Observer interface for the recurrence class. If the recurrence is changed, this method will be called for the incidence the recurrence object belongs to. @param recurrence is a pointer to a valid Recurrence object. */ void recurrenceUpdated(Recurrence *recurrence) override; /** Returns the name of the icon that best represents this incidence. @param recurrenceId Some recurring incidences might use a different icon, for example, completed to-do occurrences. Use this parameter to identify the specific occurrence in a recurring serie. */ virtual QLatin1String iconName(const QDateTime &recurrenceId = {}) const = 0; /** * Returns true if the incidence type supports groupware communication. * @since 4.10 */ virtual bool supportsGroupwareCommunication() const = 0; /** Returns the list of possible mime types in an Incidence object: "text/calendar" "application/x-vnd.akonadi.calendar.event" "application/x-vnd.akonadi.calendar.todo" "application/x-vnd.akonadi.calendar.journal" @since 4.12 */ Q_REQUIRED_RESULT static QStringList mimeTypes(); protected: /** Copy constructor. @param other is the incidence to copy. */ Incidence(const Incidence &other); /** Compares this with Incidence @p incidence for equality. @param incidence is the Incidence to compare against. @return true if the incidences are equal; false otherwise. */ bool equals(const IncidenceBase &incidence) const override; /** @copydoc IncidenceBase::assign() */ IncidenceBase &assign(const IncidenceBase &other) override; void serialize(QDataStream &out); void deserialize(QDataStream &in); private: /** Disabled, not polymorphic. Use IncidenceBase::operator= which is safe because it calls virtual function assign. @param other is another Incidence object to assign to this one. */ Incidence &operator=(const Incidence &other); //@cond PRIVATE class Private; Private *const d; //@endcond }; } //@cond PRIVATE inline uint qHash(const QSharedPointer &key) { return qHash(key.data()); } //@endcond //@cond PRIVATE Q_DECLARE_TYPEINFO(KCalCore::Incidence::Ptr, Q_MOVABLE_TYPE); Q_DECLARE_METATYPE(KCalCore::Incidence *) //@endcond #endif