File indexing completed on 2024-04-21 03:52:50

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   SPDX-FileCopyrightText: 2005 Rafal Rzepecki <divide@users.sourceforge.net>
0007   SPDX-FileCopyrightText: 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
0008   SPDX-FileContributor: Alvaro Manera <alvaro.manera@nokia.com>
0009 
0010   SPDX-License-Identifier: LGPL-2.0-or-later
0011 */
0012 /**
0013   @file
0014   This file is part of the API for handling calendar data and
0015   defines the IncidenceBase class.
0016 
0017   @author Cornelius Schumacher \<schumacher@kde.org\>
0018   @author Reinhold Kainhofer \<reinhold@kainhofer.com\>
0019   @author Rafal Rzepecki \<divide@users.sourceforge.net\>
0020 
0021   @glossary @anchor incidence @b incidence:
0022   General term for a calendar component.
0023   Examples are events, to-dos, and journals.
0024 
0025   @glossary @anchor event @b event:
0026   An @ref incidence that has a start and end time, typically representing some
0027   occurrence of social or personal importance. May be recurring.
0028   Examples are appointments, meetings, or holidays.
0029 
0030   @glossary @anchor to-do @b to-do:
0031   An @ref incidence that has an optional start time and an optional due time
0032   typically representing some undertaking to be performed. May be recurring.
0033   Examples are "fix the bug" or "pay the bills".
0034 
0035   @glossary @anchor todo @b todo:
0036   See @ref to-do.
0037 
0038   @glossary @anchor journal @b journal:
0039   An @ref incidence with a start date that represents a diary or daily record
0040   of one's activities. May @b not be recurring.
0041 */
0042 
0043 #ifndef KCALCORE_INCIDENCEBASE_H
0044 #define KCALCORE_INCIDENCEBASE_H
0045 
0046 #include "attendee.h"
0047 #include "customproperties.h"
0048 #include "duration.h"
0049 #include "person.h"
0050 
0051 #include <QDataStream>
0052 #include <QDateTime>
0053 #include <QSet>
0054 #include <QSharedPointer>
0055 #include <QUrl>
0056 
0057 class QUrl;
0058 class QDate;
0059 class QTimeZone;
0060 
0061 namespace KCalendarCore
0062 {
0063 /** List of dates */
0064 typedef QList<QDate> DateList;
0065 
0066 /** List of times */
0067 typedef QList<QDateTime> DateTimeList;
0068 
0069 class Event;
0070 class Todo;
0071 class Journal;
0072 class FreeBusy;
0073 class Visitor;
0074 class IncidenceBasePrivate;
0075 
0076 /**
0077   @brief
0078   An abstract class that provides a common base for all calendar incidence
0079   classes.
0080 
0081   define: organizer (person)
0082   define: uid (same as the attendee uid?)
0083 
0084   Several properties are not allowed for VFREEBUSY objects (see rfc:2445),
0085   so they are not in IncidenceBase. The hierarchy is:
0086 
0087   IncidenceBase
0088   + FreeBusy
0089   + Incidence
0090     + Event
0091     + Todo
0092     + Journal
0093 
0094   So IncidenceBase contains all properties that are common to all classes,
0095   and Incidence contains all additional properties that are common to
0096   Events, Todos and Journals, but are not allowed for FreeBusy entries.
0097 */
0098 class KCALENDARCORE_EXPORT IncidenceBase : public CustomProperties
0099 {
0100     Q_GADGET
0101     Q_PROPERTY(QString uid READ uid WRITE setUid)
0102     Q_PROPERTY(QDateTime lastModified READ lastModified WRITE setLastModified)
0103     Q_PROPERTY(QDateTime dtStart READ dtStart WRITE setDtStart)
0104     Q_PROPERTY(bool allDay READ allDay WRITE setAllDay)
0105     Q_PROPERTY(KCalendarCore::Person organizer READ organizer WRITE setOrganizer)
0106     Q_PROPERTY(QList<KCalendarCore::Attendee> attendees READ attendees)
0107     Q_PROPERTY(QUrl url READ url WRITE setUrl)
0108 
0109 public:
0110     /**
0111       A shared pointer to an IncidenceBase.
0112     */
0113     typedef QSharedPointer<IncidenceBase> Ptr;
0114 
0115     /**
0116       The different types of incidences, per RFC2445.
0117       @see type(), typeStr()
0118     */
0119     enum IncidenceType {
0120         TypeEvent = 0, /**< Type is an event */
0121         TypeTodo, /**< Type is a to-do */
0122         TypeJournal, /**< Type is a journal */
0123         TypeFreeBusy, /**< Type is a free/busy */
0124         TypeUnknown, /**< Type unknown */
0125     };
0126 
0127     /**
0128       The different types of incidence date/times roles.
0129       @see dateTime()
0130     */
0131     enum DateTimeRole {
0132         RoleAlarmStartOffset = 0, /**< Role for an incidence alarm's starting offset date/time */
0133         RoleAlarmEndOffset, /**< Role for an incidence alarm's ending offset date/time */
0134         RoleSort, /**< Role for an incidence's date/time used when sorting */
0135         RoleCalendarHashing, /**< Role for looking up an incidence in a Calendar */
0136         RoleStartTimeZone, /**< Role for determining an incidence's starting timezone */
0137         RoleEndTimeZone, /**< Role for determining an incidence's ending timezone */
0138         RoleEndRecurrenceBase,
0139         RoleEnd, /**< Role for determining an incidence's dtEnd, will return
0140                     an invalid QDateTime if the incidence does not support dtEnd */
0141         RoleDisplayEnd, /**< Role used for display purposes, represents the end boundary
0142                            if an incidence supports dtEnd */
0143         RoleAlarm, /**< Role for determining the date/time of the first alarm.
0144                       Returns invalid time if the incidence doesn't have any alarm */
0145         RoleRecurrenceStart, /**< Role for determining the start of the recurrence.
0146                                 Currently that's DTSTART for an event and DTDUE for a to-do.
0147                                 (NOTE: If the incidence is a to-do, recurrence should be
0148                                 calculated having DTSTART for a reference, not DT-DUE.
0149                                 This is one place KCalendarCore isn't compliant with RFC2445) */
0150         RoleDisplayStart, /**< Role for display purposes, represents the start boundary of an
0151                              incidence. To-dos return dtDue here, for historical reasons */
0152         RoleDnD, /**< Role for determining new start and end dates after a DnD */
0153     };
0154 
0155     /**
0156       The different types of incidence fields.
0157     */
0158     enum Field {
0159         FieldDtStart, ///< Field representing the DTSTART component.
0160         FieldDtEnd, ///< Field representing the DTEND component.
0161         FieldLastModified, ///< Field representing the LAST-MODIFIED component.
0162         FieldDescription, ///< Field representing the DESCRIPTION component.
0163         FieldSummary, ///< Field representing the SUMMARY component.
0164         FieldLocation, ///< Field representing the LOCATION component.
0165         FieldCompleted, ///< Field representing the COMPLETED component.
0166         FieldPercentComplete, ///< Field representing the PERCENT-COMPLETE component.
0167         FieldDtDue, ///< Field representing the DUE component.
0168         FieldCategories, ///< Field representing the CATEGORIES component.
0169         FieldRelatedTo, ///< Field representing the RELATED-TO component.
0170         FieldRecurrence, ///< Field representing the EXDATE, EXRULE, RDATE, and RRULE components.
0171         FieldAttachment, ///< Field representing the ATTACH component.
0172         FieldSecrecy, ///< Field representing the CLASS component.
0173         FieldStatus, ///< Field representing the STATUS component.
0174         FieldTransparency, ///< Field representing the TRANSPARENCY component.
0175         FieldResources, ///< Field representing the RESOURCES component.
0176         FieldPriority, ///< Field representing the PRIORITY component.
0177         FieldGeoLatitude, ///< Field representing the latitude part of the GEO component.
0178         FieldGeoLongitude, ///< Field representing the longitude part of the GEO component.
0179         FieldRecurrenceId, ///< Field representing the RECURRENCE-ID component.
0180         FieldAlarms, ///< Field representing the VALARM component.
0181         FieldSchedulingId, ///< Field representing the X-KDE-LIBKCAL-ID component.
0182         FieldAttendees, ///< Field representing the ATTENDEE component.
0183         FieldOrganizer, ///< Field representing the ORGANIZER component.
0184         FieldCreated, ///< Field representing the CREATED component.
0185         FieldRevision, ///< Field representing the SEQUENCE component.
0186         FieldDuration, ///< Field representing the DURATION component.
0187         FieldContact, ///< Field representing the CONTACT component.
0188         FieldComment, ///< Field representing the COMMENT component.
0189         FieldUid, ///< Field representing the UID component.
0190         FieldUnknown, ///< Something changed. Always set when you use the assignment operator.
0191         FieldUrl, ///< Field representing the URL component.
0192         FieldConferences, ///< Field representing the CONFERENCE component.
0193         FieldColor, ///< Field representing the COLOR component.
0194     };
0195 
0196     /**
0197       The IncidenceObserver class.
0198     */
0199     class KCALENDARCORE_EXPORT IncidenceObserver
0200     {
0201     public:
0202         /**
0203           Destroys the IncidenceObserver.
0204         */
0205         virtual ~IncidenceObserver();
0206 
0207         /**
0208           The IncidenceObserver interface.
0209           This function is called before any changes are made.
0210           @param uid is the string containing the incidence @ref uid.
0211           @param recurrenceId is possible recurrenceid of incidence.
0212         */
0213         virtual void incidenceUpdate(const QString &uid, const QDateTime &recurrenceId) = 0;
0214 
0215         /**
0216           The IncidenceObserver interface.
0217           This function is called after changes are completed.
0218           @param uid is the string containing the incidence @ref uid.
0219           @param recurrenceId is possible recurrenceid of incidence.
0220         */
0221         virtual void incidenceUpdated(const QString &uid, const QDateTime &recurrenceId) = 0;
0222     };
0223 
0224     IncidenceBase() = delete;
0225 
0226     /**
0227       Constructs an empty IncidenceBase.
0228       @param p (non-null) a Private data object provided by the instantiated
0229       class (Event, Todo, Journal, FreeBusy).  It takes ownership of the object.
0230     */
0231     KCALENDARCORE_NO_EXPORT explicit IncidenceBase(IncidenceBasePrivate *p);
0232 
0233     /**
0234       Destroys the IncidenceBase.
0235     */
0236     ~IncidenceBase() override;
0237 
0238     /**
0239       Assignment operator.
0240       All data belonging to derived classes are also copied. @see assign().
0241       The caller guarantees that both types match.
0242 
0243       @code
0244       if ( i1.type() == i2.type() ) {
0245         i1 = i2;
0246       } else {
0247         qCDebug(KCALCORE_LOG) << "Invalid assignment!";
0248       }
0249       @endcode
0250 
0251       Dirty field FieldUnknown will be set.
0252 
0253       @param other is the IncidenceBase to assign.
0254      */
0255     IncidenceBase &operator=(const IncidenceBase &other);
0256 
0257     /**
0258       Compares this with IncidenceBase @p ib for equality.
0259       All data belonging to derived classes are also compared. @see equals().
0260       @param ib is the IncidenceBase to compare against.
0261       @return true if the incidences are equal; false otherwise.
0262     */
0263     bool operator==(const IncidenceBase &ib) const;
0264 
0265     /**
0266       Compares this with IncidenceBase @p ib for inequality.
0267       @param ib is the IncidenceBase to compare against.
0268       @return true if the incidences are /not/ equal; false otherwise.
0269     */
0270     bool operator!=(const IncidenceBase &ib) const;
0271 
0272     /**
0273      Accept IncidenceVisitor. A class taking part in the visitor mechanism
0274      has to provide this implementation:
0275      <pre>
0276        bool accept(Visitor &v) { return v.visit(this); }
0277      </pre>
0278 
0279      @param v is a reference to a Visitor object.
0280      @param incidence is a valid IncidenceBase object for visiting.
0281     */
0282     virtual bool accept(Visitor &v, const IncidenceBase::Ptr &incidence);
0283 
0284     /**
0285       Returns the incidence type.
0286     */
0287     virtual IncidenceType type() const = 0;
0288 
0289     /**
0290       Prints the type of incidence as a string.
0291     */
0292     virtual QByteArray typeStr() const = 0;
0293 
0294     /**
0295       Sets the unique id for the incidence to @p uid.
0296       @param uid is the string containing the incidence @ref uid.
0297       @see uid()
0298     */
0299     void setUid(const QString &uid);
0300 
0301     /**
0302       Returns the unique id (@ref uid) for the incidence.
0303       @see setUid()
0304     */
0305     Q_REQUIRED_RESULT QString uid() const;
0306 
0307     /**
0308       Returns the uri for the incidence, of form urn:x-ical:\<uid\>
0309     */
0310     Q_REQUIRED_RESULT QUrl uri() const;
0311 
0312     /**
0313       Sets the time the incidence was last modified to @p lm.
0314       It is stored as a UTC date/time.
0315 
0316       @param lm is the QDateTime when the incidence was last modified.
0317 
0318       @see lastModified()
0319     */
0320     virtual void setLastModified(const QDateTime &lm);
0321 
0322     /**
0323       Returns the time the incidence was last modified.
0324       @see setLastModified()
0325     */
0326     Q_REQUIRED_RESULT QDateTime lastModified() const;
0327 
0328     /**
0329       Sets the organizer for the incidence.
0330 
0331       @param organizer is a non-null Person to use as the incidence @ref organizer.
0332       @see organizer(), setOrganizer(const QString &)
0333     */
0334     void setOrganizer(const Person &organizer);
0335 
0336     /**
0337       Sets the incidence organizer to any string @p organizer.
0338 
0339       @param organizer is a string to use as the incidence @ref organizer.
0340       @see organizer(), setOrganizer(const Person &)
0341     */
0342     void setOrganizer(const QString &organizer);
0343 
0344     /**
0345       Returns the Person associated with this incidence.
0346       If no Person was set through setOrganizer(), a default Person()
0347       is returned.
0348       @see setOrganizer(const QString &), setOrganizer(const Person &)
0349     */
0350     Person organizer() const;
0351 
0352     /**
0353       Sets readonly status.
0354 
0355       @param readOnly if set, the incidence is read-only; else the incidence
0356       can be modified.
0357       @see isReadOnly().
0358     */
0359     virtual void setReadOnly(bool readOnly);
0360 
0361     /**
0362       Returns true the object is read-only; false otherwise.
0363       @see setReadOnly()
0364     */
0365     Q_REQUIRED_RESULT bool isReadOnly() const;
0366 
0367     /**
0368       Sets the incidence's starting date/time with a QDateTime.
0369 
0370       @param dtStart is the incidence start date/time.
0371       @see dtStart().
0372     */
0373     virtual void setDtStart(const QDateTime &dtStart);
0374 
0375     /**
0376       Returns an incidence's starting date/time as a QDateTime.
0377       @see setDtStart().
0378     */
0379     virtual QDateTime dtStart() const;
0380 
0381     /**
0382       Sets the incidence duration.
0383 
0384       @param duration the incidence duration
0385 
0386       @see duration()
0387     */
0388     virtual void setDuration(const Duration &duration);
0389 
0390     /**
0391       Returns the length of the incidence duration.
0392       @see setDuration()
0393     */
0394     Q_REQUIRED_RESULT Duration duration() const;
0395 
0396     /**
0397       Sets if the incidence has a duration.
0398       @param hasDuration true if the incidence has a duration; false otherwise.
0399       @see hasDuration()
0400     */
0401     void setHasDuration(bool hasDuration);
0402 
0403     /**
0404       Returns true if the incidence has a duration; false otherwise.
0405       @see setHasDuration()
0406     */
0407     Q_REQUIRED_RESULT bool hasDuration() const;
0408 
0409     /**
0410       Returns true or false depending on whether the incidence is all-day.
0411       i.e. has a date but no time attached to it.
0412       @see setAllDay()
0413     */
0414     Q_REQUIRED_RESULT bool allDay() const;
0415 
0416     /**
0417       Sets whether the incidence is all-day, i.e. has a date but no time
0418       attached to it.
0419 
0420       @param allDay sets whether the incidence is all-day.
0421 
0422       @see allDay()
0423     */
0424     virtual void setAllDay(bool allDay);
0425 
0426     /**
0427       Shift the times of the incidence so that they appear at the same clock
0428       time as before but in a new time zone. The shift is done from a viewing
0429       time zone rather than from the actual incidence time zone.
0430 
0431       For example, shifting an incidence whose start time is 09:00
0432       America/New York, using an old viewing time zone (@p oldSpec)
0433       of Europe/London, to a new time zone (@p newSpec) of Europe/Paris,
0434       will result in the time being shifted from 14:00 (which is the London
0435       time of the incidence start) to 14:00 Paris time.
0436 
0437       @param oldZone the time zone which provides the clock times
0438       @param newZone the new time zone
0439     */
0440     virtual void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone);
0441 
0442     /**
0443       Adds a comment to the incidence. Does not add a linefeed character; simply
0444       appends the text as specified.
0445 
0446       @param comment is the QString containing the comment to add.
0447       @see removeComment().
0448     */
0449     void addComment(const QString &comment);
0450 
0451     /**
0452       Removes a comment from the incidence. Removes the first comment whose
0453       string is an exact match for the specified string in @p comment.
0454 
0455       @param comment is the QString containing the comment to remove.
0456       @return true if match found, false otherwise.
0457       @see addComment().
0458      */
0459     Q_REQUIRED_RESULT bool removeComment(const QString &comment);
0460 
0461     /**
0462       Deletes all incidence comments.
0463     */
0464     void clearComments();
0465 
0466     /**
0467       Returns all incidence comments as a list of strings.
0468     */
0469     Q_REQUIRED_RESULT QStringList comments() const;
0470 
0471     /**
0472       Adds a contact to thieincidence. Does not add a linefeed character; simply
0473       appends the text as specified.
0474 
0475       @param contact is the QString containing the contact to add.
0476       @see removeContact().
0477     */
0478     void addContact(const QString &contact);
0479 
0480     /**
0481       Removes a contact from the incidence. Removes the first contact whose
0482       string is an exact match for the specified string in @p contact.
0483 
0484       @param contact is the QString containing the contact to remove.
0485       @return true if match found, false otherwise.
0486       @see addContact().
0487      */
0488     Q_REQUIRED_RESULT bool removeContact(const QString &contact);
0489 
0490     /**
0491       Deletes all incidence contacts.
0492     */
0493     void clearContacts();
0494 
0495     /**
0496       Returns all incidence contacts as a list of strings.
0497     */
0498     Q_REQUIRED_RESULT QStringList contacts() const;
0499 
0500     /**
0501       Add Attendee to this incidence.
0502 
0503       @param attendee the attendee to add
0504       @param doUpdate If true the Observers are notified, if false they are not.
0505     */
0506     void addAttendee(const Attendee &attendee, bool doUpdate = true);
0507 
0508     /**
0509       Removes all attendees from the incidence.
0510     */
0511     void clearAttendees();
0512 
0513     /**
0514        Set the attendees of this incidence.
0515        This replaces all previously set attendees, unlike addAttendee.
0516 
0517        @param attendees A list of attendees.
0518        @param doUpdate If true the Observers are notified, if false they are not.
0519     */
0520     void setAttendees(const Attendee::List &attendees, bool doUpdate = true);
0521 
0522     /**
0523       Returns a list of incidence attendees.
0524       All pointers in the list are valid.
0525     */
0526     Q_REQUIRED_RESULT Attendee::List attendees() const;
0527 
0528     /**
0529       Returns the number of incidence attendees.
0530     */
0531     Q_REQUIRED_RESULT int attendeeCount() const;
0532 
0533     /**
0534       Returns the attendee with the specified email address.
0535 
0536       @param email is a QString containing an email address of the
0537       form "FirstName LastName <emailaddress>".
0538       @see attendeeByMails(), attendeesByUid().
0539     */
0540     Attendee attendeeByMail(const QString &email) const;
0541 
0542     /**
0543       Returns the first incidence attendee with one of the specified
0544       email addresses.
0545 
0546       @param emails is a list of QStrings containing email addresses of the
0547       form "FirstName LastName <emailaddress>".
0548       @param email is a QString containing a single email address to search
0549       in addition to the list specified in @p emails.
0550       @see attendeeByMail(), attendeesByUid().
0551     */
0552     Attendee attendeeByMails(const QStringList &emails, const QString &email = QString()) const;
0553 
0554     /**
0555       Returns the incidence attendee with the specified attendee @acronym UID.
0556 
0557       @param uid is a QString containing an attendee @acronym UID.
0558       @see attendeeByMail(), attendeeByMails().
0559     */
0560     Attendee attendeeByUid(const QString &uid) const;
0561 
0562     /**
0563       Sets the incidences url.
0564 
0565       This property can be used to point to a more dynamic rendition of the incidence.
0566       I.e. a website related to the incidence.
0567 
0568       @param url of the incience.
0569       @see url()
0570       @since 4.12
0571     */
0572     void setUrl(const QUrl &url);
0573 
0574     /**
0575       Returns the url.
0576       @return incidences url value
0577       @see setUrl()
0578       @since 4.12
0579     */
0580     Q_REQUIRED_RESULT QUrl url() const;
0581 
0582     /**
0583       Register observer. The observer is notified when the observed object
0584       changes.
0585 
0586       @param observer is a pointer to an IncidenceObserver object that will be
0587       watching this incidence.
0588       @see unRegisterObserver()
0589     */
0590     void registerObserver(IncidenceObserver *observer);
0591 
0592     /**
0593       Unregister observer. It isn't notified anymore about changes.
0594 
0595       @param observer is a pointer to an IncidenceObserver object that will be
0596       watching this incidence.
0597       @see registerObserver().
0598     */
0599     void unRegisterObserver(IncidenceObserver *observer);
0600 
0601     /**
0602       Call this to notify the observers after the IncidenceBase object will be
0603       changed.
0604     */
0605     void update();
0606 
0607     /**
0608       Call this to notify the observers after the IncidenceBase object has
0609       changed.
0610     */
0611     void updated();
0612 
0613     /**
0614       Call this when a group of updates is going to be made. This suppresses
0615       change notifications until endUpdates() is called, at which point
0616       updated() will automatically be called.
0617     */
0618     void startUpdates();
0619 
0620     /**
0621       Call this when a group of updates is complete, to notify observers that
0622       the instance has changed. This should be called in conjunction with
0623       startUpdates().
0624     */
0625     void endUpdates();
0626 
0627     /**
0628       Returns a date/time corresponding to the specified DateTimeRole.
0629       @param role is a DateTimeRole.
0630     */
0631     virtual QDateTime dateTime(DateTimeRole role) const = 0;
0632 
0633     /**
0634       Sets the date/time corresponding to the specified DateTimeRole.
0635       @param dateTime is QDateTime value to set.
0636       @param role is a DateTimeRole.
0637     */
0638     virtual void setDateTime(const QDateTime &dateTime, DateTimeRole role) = 0;
0639 
0640     /**
0641       Returns the Akonadi specific sub MIME type of a KCalendarCore::IncidenceBase item,
0642       e.g. getting "application/x-vnd.akonadi.calendar.event" for a KCalendarCore::Event.
0643     */
0644     virtual QLatin1String mimeType() const = 0;
0645 
0646     /**
0647       Returns the incidence recurrenceId.
0648       @return incidences recurrenceId value
0649       @see setRecurrenceId().
0650     */
0651     virtual QDateTime recurrenceId() const;
0652 
0653     /**
0654        Returns a QSet with all Fields that were changed since the incidence was created
0655        or resetDirtyFields() was called.
0656 
0657        @see resetDirtyFields()
0658     */
0659     QSet<IncidenceBase::Field> dirtyFields() const;
0660 
0661     /**
0662        Sets which fields are dirty.
0663        @see dirtyFields()
0664        @since 4.8
0665      */
0666     void setDirtyFields(const QSet<IncidenceBase::Field> &);
0667 
0668     /**
0669        Resets dirty fields.
0670        @see dirtyFields()
0671     */
0672     void resetDirtyFields();
0673 
0674     /**
0675      * Constant that identifies KCalendarCore data in a binary stream.
0676      *
0677      * @since 4.12
0678      */
0679     Q_REQUIRED_RESULT static quint32 magicSerializationIdentifier();
0680 
0681 protected:
0682     /**
0683        Marks Field @p field as dirty.
0684        @param field is the Field type to mark as dirty.
0685        @see dirtyFields()
0686     */
0687     void setFieldDirty(IncidenceBase::Field field);
0688 
0689     /**
0690       @copydoc
0691       CustomProperties::customPropertyUpdate()
0692     */
0693     void customPropertyUpdate() override;
0694 
0695     /**
0696       @copydoc
0697       CustomProperties::customPropertyUpdated()
0698     */
0699     void customPropertyUpdated() override;
0700 
0701     IncidenceBase(const IncidenceBase &) = delete;
0702 
0703     /**
0704       Constructs an IncidenceBase as a copy of another IncidenceBase object.
0705       @param ib is the IncidenceBase to copy.
0706       @param p (non-null) a Private data object provided by the instantiated
0707       class (Event, Todo, Journal, FreeBusy).  It takes ownership of the object.
0708     */
0709     KCALENDARCORE_NO_EXPORT IncidenceBase(const IncidenceBase &ib, IncidenceBasePrivate *p);
0710 
0711     /**
0712       Provides polymorfic comparison for equality.
0713       Only called by IncidenceBase::operator==() which guarantees that
0714       @p incidenceBase is of the right type.
0715       @param incidenceBase is the IncidenceBase to compare against.
0716       @return true if the incidences are equal; false otherwise.
0717     */
0718     virtual bool equals(const IncidenceBase &incidenceBase) const;
0719 
0720     /**
0721       Provides polymorfic assignment.
0722       @param other is the IncidenceBase to assign.
0723     */
0724     virtual IncidenceBase &assign(const IncidenceBase &other);
0725 
0726     /**
0727      * Sub-type specific serialization.
0728      */
0729     virtual void serialize(QDataStream &out) const;
0730     /**
0731      * Sub-type specific deserialization.
0732      */
0733     virtual void deserialize(QDataStream &in);
0734 
0735     enum VirtualHook {};
0736 
0737     /**
0738       Standard trick to add virtuals later.
0739 
0740       @param id is any integer unique to this class which we will use to identify the method
0741              to be called.
0742       @param data is a pointer to some glob of data, typically a struct.
0743     */
0744     virtual void virtual_hook(VirtualHook id, void *data) = 0;
0745 
0746     /**
0747       Identifies a read-only incidence.
0748     */
0749     bool mReadOnly;
0750 
0751     Q_DECLARE_PRIVATE(IncidenceBase)
0752 
0753 protected:
0754     IncidenceBasePrivate *const d_ptr;
0755 
0756 private:
0757     friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const KCalendarCore::IncidenceBase::Ptr &);
0758 
0759     friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &stream, KCalendarCore::IncidenceBase::Ptr &);
0760 };
0761 
0762 /**
0763  * Compare two QDateTimes for extended equality.
0764  *
0765  * QDateTime::operator==() in Qt 5.12 returns true if its operands represent
0766  * the same instant in time, regardless of their time zones or TimeSpecs (and
0767  * contrary to the documentation).  This function returns true if and only if
0768  * their times, time zones, and TimeSpecs are equal, or both are invalid().
0769  *
0770  * @since 5.93
0771  */
0772 KCALENDARCORE_EXPORT bool identical(const QDateTime &dt1, const QDateTime &dt2);
0773 
0774 /**
0775  * Incidence serializer.
0776  *
0777  * @since 4.12
0778  */
0779 KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, const KCalendarCore::IncidenceBase::Ptr &);
0780 
0781 /**
0782  * Incidence deserializer.
0783  *
0784  * @since 4.12
0785  */
0786 KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, KCalendarCore::IncidenceBase::Ptr &);
0787 }
0788 
0789 Q_DECLARE_METATYPE(KCalendarCore::IncidenceBase *)
0790 Q_DECLARE_METATYPE(KCalendarCore::IncidenceBase::Ptr)
0791 
0792 #endif