File indexing completed on 2024-04-28 07:41:17

0001 /*
0002   This file is part of the kcalcore library.
0003 
0004   SPDX-FileCopyrightText: 2001-2003 Cornelius Schumacher <schumacher@kde.org>
0005   SPDX-FileCopyrightText: 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
0006 
0007   SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 /**
0010   @file
0011   This file is part of the API for handling calendar data and
0012   defines the Incidence class.
0013 
0014   @author Cornelius Schumacher \<schumacher@kde.org\>
0015   @author Reinhold Kainhofer \<reinhold@kainhofer.com\>
0016 */
0017 
0018 #ifndef KCALCORE_INCIDENCE_H
0019 #define KCALCORE_INCIDENCE_H
0020 
0021 #include "alarm.h"
0022 #include "attachment.h"
0023 #include "conference.h"
0024 #include "incidencebase.h"
0025 #include "kcalendarcore_export.h"
0026 #include "recurrence.h"
0027 
0028 #include <QMetaType>
0029 
0030 //@cond PRIVATE
0031 // Value used to signal invalid/unset latitude or longitude.
0032 #define INVALID_LATLON 255.0 // krazy:exclude=defines (part of the API)
0033 //@endcond
0034 
0035 namespace KCalendarCore
0036 {
0037 
0038 class IncidencePrivate;
0039 
0040 /**
0041   @brief
0042   Provides the abstract base class common to non-FreeBusy (Events, To-dos,
0043   Journals) calendar components known as incidences.
0044 
0045   Several properties are not allowed for VFREEBUSY objects (see rfc:2445),
0046   so they are not in IncidenceBase. The hierarchy is:
0047 
0048   IncidenceBase
0049   + FreeBusy
0050   + Incidence
0051     + Event
0052     + Todo
0053     + Journal
0054 
0055   So IncidenceBase contains all properties that are common to all classes,
0056   and Incidence contains all additional properties that are common to
0057   Events, Todos and Journals, but are not allowed for FreeBusy entries.
0058 */
0059 class KCALENDARCORE_EXPORT Incidence : public IncidenceBase, public Recurrence::RecurrenceObserver
0060 {
0061     Q_GADGET
0062     Q_PROPERTY(QString description READ description WRITE setDescription)
0063     Q_PROPERTY(QString summary READ summary WRITE setSummary)
0064     Q_PROPERTY(QString location READ location WRITE setLocation)
0065     Q_PROPERTY(bool hasGeo READ hasGeo)
0066     Q_PROPERTY(float geoLatitude READ geoLatitude WRITE setGeoLatitude)
0067     Q_PROPERTY(float geoLongitude READ geoLongitude WRITE setGeoLongitude)
0068     Q_PROPERTY(QStringList categories READ categories WRITE setCategories)
0069     Q_PROPERTY(int priority READ priority WRITE setPriority)
0070     Q_PROPERTY(QDateTime created READ created WRITE setCreated)
0071     Q_PROPERTY(KCalendarCore::Incidence::Secrecy secrecy READ secrecy WRITE setSecrecy)
0072     Q_PROPERTY(KCalendarCore::Incidence::Status status READ status WRITE setStatus)
0073     Q_PROPERTY(QList<KCalendarCore::Attachment> attachments READ attachments)
0074     Q_PROPERTY(QList<KCalendarCore::Conference> conferences READ conferences)
0075 public:
0076     /**
0077       The different types of overall incidence status or confirmation.
0078       The meaning is specific to the incidence type in context.
0079     */
0080     enum Status {
0081         StatusNone, /**< No status */
0082         StatusTentative, /**< event is tentative */
0083         StatusConfirmed, /**< event is definite */
0084         StatusCompleted, /**< to-do completed */
0085         StatusNeedsAction, /**< to-do needs action */
0086         StatusCanceled, /**< event or to-do canceled; journal removed */
0087         StatusInProcess, /**< to-do in process */
0088         StatusDraft, /**< journal is draft */
0089         StatusFinal, /**< journal is final */
0090         StatusX, /**< a non-standard status string */
0091     };
0092     Q_ENUM(Status)
0093 
0094     /**
0095       The different types of incidence access classifications.
0096     */
0097     enum Secrecy {
0098         SecrecyPublic, /**< Not secret (default) */
0099         SecrecyPrivate, /**< Secret to the owner */
0100         SecrecyConfidential, /**< Secret to the owner and some others */
0101     };
0102     Q_ENUM(Secrecy)
0103 
0104     /**
0105        The different types of RELTYPE values specified by the RFC.
0106        Only RelTypeParent is supported for now.
0107     */
0108     enum RelType {
0109         RelTypeParent, /**< The related incidence is a parent. */
0110         RelTypeChild, /**< The related incidence is a child. */
0111         RelTypeSibling, /**< The related incidence is a peer. */
0112     };
0113 
0114     /**
0115       A shared pointer to an Incidence.
0116     */
0117     typedef QSharedPointer<Incidence> Ptr;
0118 
0119     /**
0120       List of incidences.
0121     */
0122     typedef QList<Ptr> List;
0123 
0124     Incidence() = delete;
0125 
0126     /**
0127       Constructs an empty incidence.
0128       @param p (non-null) a Private data object provided by the instantiated
0129       class (Event, Todo, Journal, FreeBusy). It passes ownership of the object
0130       to IncidenceBase.
0131     */
0132     Incidence(IncidencePrivate *p);
0133 
0134     /**
0135       Destroys an incidence.
0136     */
0137     ~Incidence() override;
0138 
0139     /**
0140       Returns an exact copy of this incidence. The returned object is owned
0141       by the caller.
0142 
0143       Dirty fields are cleared.
0144     */
0145     virtual Incidence *clone() const = 0;
0146 
0147     /**
0148       Returns a unique identifier for a specific instance of an incidence.
0149 
0150       Due to the recurrence-id, the uid is not unique for a KCalendarCore::Incidence.
0151       @since 4.11
0152     */
0153     Q_REQUIRED_RESULT QString instanceIdentifier() const;
0154 
0155     /**
0156       Set readonly state of incidence.
0157 
0158       @param readonly If true, the incidence is set to readonly, if false the
0159                       incidence is set to readwrite.
0160     */
0161     void setReadOnly(bool readonly) override;
0162 
0163     /**
0164       @copydoc IncidenceBase::setLastModified().
0165     */
0166     void setLastModified(const QDateTime &lm) override;
0167 
0168     /**
0169       Set localOnly state of incidence.
0170       A local only incidence can be updated but it will not increase the revision
0171       number neither the modified date.
0172 
0173       @param localonly If true, the incidence is set to localonly, if false the
0174                       incidence is set to normal stat.
0175     */
0176     void setLocalOnly(bool localonly);
0177 
0178     /**
0179       Get the localOnly status.
0180       @return true if Local only, false otherwise.
0181 
0182       @see setLocalOnly()
0183     */
0184     Q_REQUIRED_RESULT bool localOnly() const;
0185 
0186     /**
0187       @copydoc IncidenceBase::setAllDay().
0188     */
0189     void setAllDay(bool allDay) override;
0190 
0191     /**
0192       Recreate incidence. The incidence is made a new unique incidence, but already stored
0193       information is preserved. Sets unique id, creation date, last
0194       modification date and revision number.
0195     */
0196     void recreate();
0197 
0198     /**
0199       Sets the incidence creation date/time. It is stored as a UTC date/time.
0200 
0201       @param dt is the creation date/time.
0202       @see created().
0203     */
0204     void setCreated(const QDateTime &dt);
0205 
0206     /**
0207       Returns the incidence creation date/time.
0208       @see setCreated().
0209     */
0210     Q_REQUIRED_RESULT QDateTime created() const;
0211 
0212     /**
0213       Sets the number of revisions this incidence has seen.
0214 
0215       @param rev is the incidence revision number.
0216       @see revision().
0217     */
0218     void setRevision(int rev);
0219 
0220     /**
0221       Returns the number of revisions this incidence has seen.
0222       @see setRevision().
0223     */
0224     Q_REQUIRED_RESULT int revision() const;
0225 
0226     /**
0227       Sets the incidence starting date/time.
0228 
0229       @param dt is the starting date/time.
0230       @see IncidenceBase::dtStart().
0231     */
0232     void setDtStart(const QDateTime &dt) override;
0233 
0234     /**
0235       @copydoc IncidenceBase::shiftTimes()
0236     */
0237     void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone) override;
0238 
0239     /**
0240       Sets the incidence description.
0241 
0242       @param description is the incidence description string.
0243       @param isRich if true indicates the description string contains richtext.
0244       @see description().
0245     */
0246     void setDescription(const QString &description, bool isRich);
0247 
0248     /**
0249       Sets the incidence description and tries to guess if the description
0250       is rich text.
0251 
0252       @param description is the incidence description string.
0253       @see description().
0254     */
0255     void setDescription(const QString &description);
0256 
0257     /**
0258       Returns the incidence description.
0259       @see setDescription().
0260       @see richDescription().
0261     */
0262     Q_REQUIRED_RESULT QString description() const;
0263 
0264     /**
0265       Returns the incidence description in rich text format.
0266       @see setDescription().
0267       @see description().
0268     */
0269     Q_REQUIRED_RESULT QString richDescription() const;
0270 
0271     /**
0272       Returns true if incidence description contains RichText; false otherwise.
0273       @see setDescription(), description().
0274     */
0275     Q_REQUIRED_RESULT bool descriptionIsRich() const;
0276 
0277     /**
0278       Sets the incidence summary.
0279 
0280       @param summary is the incidence summary string.
0281       @param isRich if true indicates the summary string contains richtext.
0282       @see summary().
0283     */
0284     void setSummary(const QString &summary, bool isRich);
0285 
0286     /**
0287       Sets the incidence summary and tries to guess if the summary is richtext.
0288 
0289       @param summary is the incidence summary string.
0290       @see summary().
0291     */
0292     void setSummary(const QString &summary);
0293 
0294     /**
0295       Returns the incidence summary.
0296       @see setSummary().
0297       @see richSummary().
0298     */
0299     Q_REQUIRED_RESULT QString summary() const;
0300 
0301     /**
0302       Returns the incidence summary in rich text format.
0303       @see setSummary().
0304       @see summary().
0305     */
0306     Q_REQUIRED_RESULT QString richSummary() const;
0307 
0308     /**
0309       Returns true if incidence summary contains RichText; false otherwise.
0310       @see setSummary(), summary().
0311     */
0312     Q_REQUIRED_RESULT bool summaryIsRich() const;
0313 
0314     /**
0315       Sets the incidence location. Do _not_ use with journals.
0316 
0317       @param location is the incidence location string.
0318       @param isRich if true indicates the location string contains richtext.
0319       @see location().
0320     */
0321     void setLocation(const QString &location, bool isRich);
0322 
0323     /**
0324       Sets the incidence location and tries to guess if the location is
0325       richtext. Do _not_ use with journals.
0326 
0327       @param location is the incidence location string.
0328       @see location().
0329     */
0330     void setLocation(const QString &location);
0331 
0332     /**
0333       Returns the incidence location. Do _not_ use with journals.
0334       @see setLocation().
0335       @see richLocation().
0336     */
0337     Q_REQUIRED_RESULT QString location() const;
0338 
0339     /**
0340       Returns the incidence location in rich text format.
0341       @see setLocation().
0342       @see location().
0343     */
0344     Q_REQUIRED_RESULT QString richLocation() const;
0345 
0346     /**
0347       Returns true if incidence location contains RichText; false otherwise.
0348       @see setLocation(), location().
0349     */
0350     Q_REQUIRED_RESULT bool locationIsRich() const;
0351 
0352     /**
0353       Sets the incidence category list.
0354 
0355       @param categories is a list of category strings.
0356       @see setCategories( const QString &), categories().
0357     */
0358     void setCategories(const QStringList &categories);
0359 
0360     /**
0361       Sets the incidence category list based on a comma delimited string.
0362 
0363       @param catStr is a QString containing a list of categories which
0364       are delimited by a comma character.
0365       @see setCategories( const QStringList &), categories().
0366     */
0367     void setCategories(const QString &catStr);
0368 
0369     /**
0370       Returns the incidence categories as a list of strings.
0371       @see setCategories( const QStringList &), setCategories( const QString &).
0372     */
0373     Q_REQUIRED_RESULT QStringList categories() const;
0374 
0375     /**
0376       Returns the incidence categories as a comma separated string.
0377       @see categories().
0378     */
0379     Q_REQUIRED_RESULT QString categoriesStr() const;
0380 
0381     /**
0382       Relates another incidence to this one, by UID. This function should only
0383       be used when constructing a calendar before the related incidence exists.
0384 
0385       @param uid is a QString containing a UID for another incidence.
0386       @param relType specifies the relation type.
0387 
0388       @warning KCalendarCore only supports one related-to field per reltype for now.
0389 
0390       @see relatedTo().
0391     */
0392     void setRelatedTo(const QString &uid, RelType relType = RelTypeParent);
0393 
0394     /**
0395       Returns a UID string for the incidence that is related to this one.
0396       This function should only be used when constructing a calendar before
0397       the related incidence exists.
0398 
0399       @warning KCalendarCore only supports one related-to field per reltype for now.
0400 
0401       @param relType specifies the relation type.
0402 
0403       @see setRelatedTo().
0404     */
0405     Q_REQUIRED_RESULT QString relatedTo(RelType relType = RelTypeParent) const;
0406 
0407     /**
0408       Set the incidence color, as added in RFC7986.
0409 
0410       @param colorName a named color as defined in CSS3 color name, see
0411        https://www.w3.org/TR/css-color-3/#svg-color.
0412       @since: 5.76
0413      */
0414     void setColor(const QString &colorName);
0415 
0416     /**
0417       Returns the color, if any is defined, for this incidence.
0418 
0419       @since: 5.76
0420      */
0421     Q_REQUIRED_RESULT QString color() const;
0422 
0423     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0424     // %%%%%  Convenience wrappers for property handling
0425     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0426     /**
0427        Returns true if the alternative (=text/html) description is
0428        available.
0429        @see setAltDescription(), altDescription()
0430     */
0431     Q_REQUIRED_RESULT bool hasAltDescription() const;
0432     /**
0433       Sets the incidence's alternative (=text/html) description. If
0434       the text is empty, the property is removed.
0435 
0436       @param altdescription is the incidence altdescription string.
0437       @see altAltdescription().
0438     */
0439     void setAltDescription(const QString &altdescription);
0440 
0441     /**
0442       Returns the incidence alternative (=text/html) description.
0443       @see setAltDescription().
0444     */
0445     Q_REQUIRED_RESULT QString altDescription() const;
0446 
0447     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0448     // %%%%%  Recurrence-related methods
0449     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0450 
0451     /**
0452       Returns the recurrence rule associated with this incidence. If there is
0453       none, returns an appropriate (non-0) object.
0454     */
0455     Recurrence *recurrence() const;
0456 
0457     /**
0458       Removes all recurrence and exception rules and dates.
0459     */
0460     void clearRecurrence();
0461 
0462     /**
0463       @copydoc Recurrence::recurs()
0464     */
0465     Q_REQUIRED_RESULT bool recurs() const;
0466 
0467     /**
0468       @copydoc Recurrence::recurrenceType()
0469     */
0470     Q_REQUIRED_RESULT ushort recurrenceType() const;
0471 
0472     /**
0473       @copydoc Recurrence::recursOn()
0474     */
0475     virtual bool recursOn(const QDate &date, const QTimeZone &timeZone) const;
0476 
0477     /**
0478       @copydoc Recurrence::recursAt()
0479     */
0480     Q_REQUIRED_RESULT bool recursAt(const QDateTime &dt) const;
0481 
0482     /**
0483       Calculates the start date/time for all recurrences that happen at some
0484       time on the given date (might start before that date, but end on or
0485       after the given date).
0486 
0487       @param date the date when the incidence should occur
0488       @param timeSpec time specification for @p date.
0489       @return the start date/time of all occurrences that overlap with the
0490       given date; an empty list if the incidence does not overlap with the
0491       date at all.
0492     */
0493     virtual QList<QDateTime> startDateTimesForDate(const QDate &date, const QTimeZone &timeZone) const;
0494 
0495     /**
0496       Calculates the start date/time for all recurrences that happen at the
0497       given time.
0498 
0499       @param datetime the date/time when the incidence should occur.
0500       @return the start date/time of all occurrences that overlap with the
0501       given date/time; an empty list if the incidence does not happen at the
0502       given time at all.
0503     */
0504     Q_REQUIRED_RESULT virtual QList<QDateTime> startDateTimesForDateTime(const QDateTime &datetime) const;
0505 
0506     /**
0507       Returns the end date/time of the incidence occurrence if it starts at
0508       specified date/time.
0509 
0510       @param startDt is the specified starting date/time.
0511       @return the corresponding end date/time for the occurrence; or the start
0512       date/time if the end date/time is invalid; or the end date/time if
0513       the start date/time is invalid.
0514     */
0515     Q_REQUIRED_RESULT virtual QDateTime endDateForStart(const QDateTime &startDt) const;
0516 
0517     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0518     // %%%%%  Attachment-related methods
0519     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0520 
0521     /**
0522       Adds an attachment to the incidence.
0523 
0524       @param attachment a valid Attachment object.
0525     */
0526     void addAttachment(const Attachment &attachment);
0527 
0528     /**
0529       Removes all attachments of the specified MIME type from the incidence.
0530       The memory used by all the removed attachments is freed.
0531 
0532       @param mime is a QString containing the MIME type.
0533       @see deleteAttachment().
0534     */
0535     void deleteAttachments(const QString &mime);
0536 
0537     /**
0538       Returns a list of all incidence attachments.
0539       @see attachments( const QString &).
0540     */
0541     Q_REQUIRED_RESULT Attachment::List attachments() const;
0542 
0543     /**
0544       Returns a list of all incidence attachments with the specified MIME type.
0545 
0546       @param mime is a QString containing the MIME type.
0547       @see attachments().
0548     */
0549     Q_REQUIRED_RESULT Attachment::List attachments(const QString &mime) const;
0550 
0551     /**
0552       Removes all attachments and frees the memory used by them.
0553       @see deleteAttachments( const QString &).
0554     */
0555     void clearAttachments();
0556 
0557     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0558     // %%%%%  Secrecy and Status methods
0559     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0560 
0561     /**
0562       Sets the incidence #Secrecy.
0563 
0564       @param secrecy is the incidence #Secrecy to set.
0565       @see secrecy(), secrecyStr().
0566     */
0567     void setSecrecy(Secrecy secrecy);
0568 
0569     /**
0570       Returns the incidence #Secrecy.
0571       @see setSecrecy(), secrecyStr().
0572     */
0573     Q_REQUIRED_RESULT Secrecy secrecy() const;
0574 
0575     /**
0576       Sets the incidence status to a standard #Status value.
0577       Events, Todos, and Journals each have a different set of
0578       valid statuses.  Note that StatusX cannot be specified.
0579       Invalid statuses are logged and ignored.
0580 
0581       @param status is the incidence #Status to set.
0582       @see status(), setCustomStatus().
0583     */
0584     void setStatus(Status status);
0585 
0586     /**
0587       Sets the incidence #Status to a non-standard status value.
0588 
0589       @param status is a non-standard status string. If empty,
0590       the incidence #Status will be set to StatusNone.
0591       @see setStatus(), status() customStatus().
0592     */
0593     void setCustomStatus(const QString &status);
0594 
0595     /**
0596        Returns the non-standard status value.
0597        @see setCustomStatus().
0598     */
0599     Q_REQUIRED_RESULT QString customStatus() const;
0600 
0601     /**
0602       Returns the incidence #Status.
0603       @see setStatus(), setCustomStatus(), statusStr().
0604     */
0605     Q_REQUIRED_RESULT Status status() const;
0606 
0607     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0608     // %%%%%  Other methods
0609     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0610 
0611     /**
0612       Sets a list of incidence resources. (Note: resources in this context
0613       means items used by the incidence such as money, fuel, hours, etc).
0614 
0615       @param resources is a list of resource strings.
0616       @see resources().
0617     */
0618     void setResources(const QStringList &resources);
0619 
0620     /**
0621       Returns the incidence resources as a list of strings.
0622       @see setResources().
0623     */
0624     Q_REQUIRED_RESULT QStringList resources() const;
0625 
0626     /**
0627       Sets the incidences priority. The priority must be an integer value
0628       between 0 and 9, where 0 is undefined, 1 is the highest, and 9 is the
0629       lowest priority (decreasing order).
0630 
0631       @param priority is the incidence priority to set.
0632       @see priority().
0633     */
0634     void setPriority(int priority);
0635 
0636     /**
0637       Returns the incidence priority.
0638       @see setPriority().
0639     */
0640     Q_REQUIRED_RESULT int priority() const;
0641 
0642     /**
0643       Returns true if the incidence has geo data, otherwise return false.
0644       @see setHasGeo(), setGeoLatitude(float), setGeoLongitude(float).
0645     */
0646     Q_REQUIRED_RESULT bool hasGeo() const;
0647 
0648     /**
0649       Set the incidence's geoLatitude.
0650       @param geolatitude is the incidence geolatitude to set; a value between -90.0 and 90.0,
0651       or INVALID_LATLON (or NaN, which is treated as INVALID_LATLON).
0652       @see geoLatitude().
0653     */
0654     void setGeoLatitude(float geolatitude);
0655 
0656     /**
0657       Returns the incidence's geoLatitude as a value between -90.0 and 90.0 or INVALID_LATLON.
0658       If either of geoLatitude() and geoLongitude() are INVALID_LATLON, then both are, and hasGeo() is false.
0659       @return incidences geolatitude value
0660       @see setGeoLatitude().
0661     */
0662     Q_REQUIRED_RESULT float geoLatitude() const;
0663 
0664     /**
0665       Set the incidence's geoLongitude.
0666       @param geolongitude is the incidence geolongitude to set; a value between -180.0 and 180.0,
0667       or INVALID_LATLON (or NaN, which is treated as INVALID_LATLON).
0668       @see geoLongitude().
0669     */
0670     void setGeoLongitude(float geolongitude);
0671 
0672     /**
0673       Returns the incidence's geoLongitude as a value between -180.0 and 180.0 or INVALID_LATLON.
0674       If either of geoLatitude() and geoLongitude() are INVALID_LATLON, then both are, and hasGeo() is false.
0675       @return incidences geolongitude value
0676       @see setGeoLongitude().
0677     */
0678     Q_REQUIRED_RESULT float geoLongitude() const;
0679 
0680     /**
0681       Returns true if the incidence has recurrenceId, otherwise return false.
0682       @see setRecurrenceId(QDateTime)
0683     */
0684     Q_REQUIRED_RESULT bool hasRecurrenceId() const;
0685 
0686     /**
0687       Set the incidences recurrenceId.
0688       This field indicates that this is an exception to a recurring incidence.
0689       The uid of this incidence MUST be the same as the one of the recurring main incidence.
0690       @param recurrenceId is the incidence recurrenceId to set
0691       @see recurrenceId().
0692     */
0693     void setRecurrenceId(const QDateTime &recurrenceId);
0694 
0695     /**
0696       Returns the incidence recurrenceId.
0697       @return incidences recurrenceId value
0698       @see setRecurrenceId().
0699     */
0700     Q_REQUIRED_RESULT QDateTime recurrenceId() const override;
0701 
0702     /**
0703       Set to true if the exception also applies to all future occurrences.
0704       This option is only relevant if the incidence has a recurrenceId set.
0705       @param thisAndFuture value
0706       @see thisAndFuture(), setRecurrenceId()
0707       @since 4.11
0708     */
0709     void setThisAndFuture(bool thisAndFuture);
0710 
0711     /**
0712       Returns true if the exception also applies to all future occurrences.
0713       @return incidences thisAndFuture value
0714       @see setThisAndFuture()
0715       @since 4.11
0716     */
0717     Q_REQUIRED_RESULT bool thisAndFuture() const;
0718 
0719     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0720     // %%%%%  Alarm-related methods
0721     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0722 
0723     /**
0724       Returns a list of all incidence alarms.
0725     */
0726     Q_REQUIRED_RESULT Alarm::List alarms() const;
0727 
0728     /**
0729       Create a new incidence alarm.
0730     */
0731     Alarm::Ptr newAlarm();
0732 
0733     /**
0734       Adds an alarm to the incidence.
0735 
0736       @param alarm is a pointer to a valid Alarm object.
0737       @see removeAlarm().
0738     */
0739     void addAlarm(const Alarm::Ptr &alarm);
0740 
0741     /**
0742       Removes the specified alarm from the incidence.
0743 
0744       @param alarm is a pointer to a valid Alarm object.
0745       @see addAlarm().
0746     */
0747     void removeAlarm(const Alarm::Ptr &alarm);
0748 
0749     /**
0750       Removes all alarms.
0751       @see removeAlarm().
0752     */
0753     void clearAlarms();
0754 
0755     /**
0756       Returns true if any of the incidence alarms are enabled; false otherwise.
0757     */
0758     Q_REQUIRED_RESULT bool hasEnabledAlarms() const;
0759 
0760     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0761     // %%%%% Conferences-related method
0762     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0763 
0764     /**
0765      * Returns list of all incidence conferencing methods.
0766      * @since 5.77
0767      */
0768     Q_REQUIRED_RESULT Conference::List conferences() const;
0769 
0770     /**
0771      * Replaces all conferences in the incidence with given @p conferences
0772      *
0773      * @param conferences New conferences to store in the incidence.
0774      * @since 5.77
0775      */
0776     void setConferences(const Conference::List &conferences);
0777 
0778     /**
0779      * Adds a conference to the incidence.
0780      *
0781      * @param conferene A conference to add.
0782      * @since 5.77
0783      */
0784     void addConference(const Conference &conference);
0785 
0786     /**
0787      * Removes all conferences from the incidence.
0788      * @since 5.77
0789      */
0790     void clearConferences();
0791 
0792     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0793     // %%%%%  Other methods
0794     // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0795 
0796     /**
0797       Set the incidence scheduling ID. Do _not_ use with journals.
0798       This is used for accepted invitations as the place to store the UID
0799       of the invitation. It is later used again if updates to the
0800       invitation comes in.
0801       If we did not set a new UID on incidences from invitations, we can
0802       end up with more than one resource having events with the same UID,
0803       if you have access to other peoples resources.
0804 
0805       While constructing an incidence, when setting the scheduling ID,
0806       you will always want to set the incidence UID too. Instead of calling
0807       setUID() separately, you can pass the UID through @p uid so both
0808       members are changed in one atomic operation ( don't forget that
0809       setUID() emits incidenceUpdated() and whoever catches that signal
0810       will have an half-initialized incidence, therefore, always set
0811       the schedulingID and UID at the same time, and never with two separate
0812       calls).
0813 
0814       @param sid is a QString containing the scheduling ID.
0815       @param uid is a QString containing the incidence UID to set, if not
0816              specified, the current UID isn't changed, and this parameter
0817              is ignored.
0818       @see schedulingID().
0819     */
0820     void setSchedulingID(const QString &sid, const QString &uid = QString());
0821 
0822     /**
0823       Returns the incidence scheduling ID. Do _not_ use with journals.
0824       If a scheduling ID is not set, then return the incidence UID.
0825       @see setSchedulingID().
0826     */
0827     Q_REQUIRED_RESULT QString schedulingID() const;
0828 
0829     /**
0830       Observer interface for the recurrence class. If the recurrence is
0831       changed, this method will be called for the incidence the recurrence
0832       object belongs to.
0833 
0834       @param recurrence is a pointer to a valid Recurrence object.
0835     */
0836     void recurrenceUpdated(Recurrence *recurrence) override;
0837 
0838     /**
0839       Returns the name of the icon that best represents this incidence.
0840 
0841       @param recurrenceId Some recurring incidences might use a different icon,
0842       for example, completed to-do occurrences. Use this parameter to identify
0843       the specific occurrence in a recurring serie.
0844     */
0845     virtual QLatin1String iconName(const QDateTime &recurrenceId = {}) const = 0;
0846 
0847     /**
0848      * Returns true if the incidence type supports groupware communication.
0849      * @since 4.10
0850      */
0851     virtual bool supportsGroupwareCommunication() const = 0;
0852 
0853     /**
0854       Returns the list of possible mime types in an Incidence object:
0855           "text/calendar"
0856           "application/x-vnd.akonadi.calendar.event"
0857           "application/x-vnd.akonadi.calendar.todo"
0858           "application/x-vnd.akonadi.calendar.journal"
0859 
0860       @since 4.12
0861      */
0862     Q_REQUIRED_RESULT static QStringList mimeTypes();
0863 
0864 protected:
0865     Incidence(const Incidence &) = delete;
0866 
0867     /**
0868       @param other is the incidence to copy.
0869       @param p (non-null) a Private data object provided by the instantiated
0870       class (Event, Todo, Journal, FreeBusy). It passes ownership of the object
0871       to IncidenceBase.
0872     */
0873     Incidence(const Incidence &other, IncidencePrivate *p);
0874 
0875     /**
0876       Compares this with Incidence @p incidence for equality.
0877       @param incidence is the Incidence to compare against.
0878       @return true if the incidences are equal; false otherwise.
0879     */
0880     bool equals(const IncidenceBase &incidence) const override;
0881 
0882     /**
0883       @copydoc IncidenceBase::assign()
0884     */
0885     IncidenceBase &assign(const IncidenceBase &other) override;
0886 
0887     void serialize(QDataStream &out) const override;
0888     void deserialize(QDataStream &in) override;
0889 
0890 private:
0891     /**
0892       Disabled, not polymorphic.
0893       Use IncidenceBase::operator= which is safe because it calls
0894       virtual function assign.
0895       @param other is another Incidence object to assign to this one.
0896      */
0897     Incidence &operator=(const Incidence &other) = delete;
0898 
0899 protected:
0900     Q_DECLARE_PRIVATE(Incidence)
0901 };
0902 
0903 }
0904 
0905 //@cond PRIVATE
0906 inline size_t qHash(const QSharedPointer<KCalendarCore::Incidence> &key, size_t seed = 0)
0907 {
0908     return qHash(key.data(), seed);
0909 }
0910 //@endcond
0911 
0912 //@cond PRIVATE
0913 Q_DECLARE_TYPEINFO(KCalendarCore::Incidence::Ptr, Q_RELOCATABLE_TYPE);
0914 Q_DECLARE_METATYPE(KCalendarCore::Incidence *)
0915 //@endcond
0916 
0917 #endif