File indexing completed on 2024-04-28 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 
0006   SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 /**
0009   @file
0010   This file is part of the API for handling calendar data and
0011   defines the Period class.
0012 
0013   @brief
0014   Represents a period of time.
0015 
0016   @author Cornelius Schumacher \<schumacher@kde.org\>
0017 */
0018 
0019 #ifndef KCALCORE_FREEBUSYPERIOD_H
0020 #define KCALCORE_FREEBUSYPERIOD_H
0021 
0022 #include "kcalendarcore_export.h"
0023 #include "period.h"
0024 
0025 #include <QMetaType>
0026 
0027 namespace KCalendarCore
0028 {
0029 /**
0030   The period can be defined by either a start time and an end time or
0031   by a start time and a duration.
0032 */
0033 class KCALENDARCORE_EXPORT FreeBusyPeriod : public Period
0034 {
0035 public:
0036     enum FreeBusyType {
0037         Free,
0038         Busy,
0039         BusyUnavailable,
0040         BusyTentative,
0041         Unknown,
0042     };
0043 
0044     /**
0045        List of periods.
0046      */
0047     typedef QList<FreeBusyPeriod> List;
0048 
0049     /**
0050       Constructs a period without a duration.
0051     */
0052     FreeBusyPeriod();
0053 
0054     /**
0055       Constructs a period from @p start to @p end.
0056 
0057       @param start the time the period begins.
0058       @param end the time the period ends.
0059     */
0060     FreeBusyPeriod(const QDateTime &start, const QDateTime &end);
0061 
0062     /**
0063       Constructs a period from @p start and lasting @p duration.
0064 
0065       @param start the time when the period starts.
0066       @param duration how long the period lasts.
0067     */
0068     FreeBusyPeriod(const QDateTime &start, const Duration &duration);
0069 
0070     /**
0071       Constructs a period by copying another period object
0072 
0073       @param period the period to copy
0074      */
0075 
0076     FreeBusyPeriod(const FreeBusyPeriod &period);
0077 
0078     /**
0079       Constructs a period by copying another period object
0080 
0081       @param period the period to copy
0082      */
0083 
0084     FreeBusyPeriod(const Period &period); // krazy:exclude=explicit
0085 
0086     /**
0087       Destroys a period.
0088     */
0089     ~FreeBusyPeriod();
0090 
0091     /**
0092       Sets this period equal to the @p other one.
0093 
0094       @param other is the other period to compare.
0095     */
0096     FreeBusyPeriod &operator=(const FreeBusyPeriod &other);
0097 
0098     /**
0099       Sets the period summary.
0100       @param summary is the period summary string.
0101       @see summary().
0102     */
0103     void setSummary(const QString &summary);
0104 
0105     /**
0106       Returns the period summary.
0107       @see setSummary()
0108     */
0109     Q_REQUIRED_RESULT QString summary() const;
0110 
0111     /**
0112       Sets the period location.
0113       @param location is the period location string.
0114       @see location().
0115     */
0116     void setLocation(const QString &location);
0117 
0118     /**
0119       Returns the period location.
0120       @see setLocation()
0121     */
0122     Q_REQUIRED_RESULT QString location() const;
0123 
0124     /**
0125       Sets the free/busy type.
0126       @param type is the type of free/busy period
0127       @see type().
0128       @since 5.0
0129     */
0130     void setType(FreeBusyType type);
0131 
0132     /**
0133       Returns free/busy type
0134       @see setType().
0135       @since 5.0
0136     */
0137     Q_REQUIRED_RESULT FreeBusyType type() const;
0138 
0139 private:
0140     //@cond PRIVATE
0141     class Private;
0142     Private *const d;
0143     //@endcond
0144 
0145     friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const KCalendarCore::FreeBusyPeriod &period);
0146     friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &stream, KCalendarCore::FreeBusyPeriod &period);
0147 };
0148 
0149 /** Write @p period to the datastream @p stream, in binary format. */
0150 KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &stream, const KCalendarCore::FreeBusyPeriod &period);
0151 
0152 /** Read a Period object into @p period from @p stream, in binary format. */
0153 KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &stream, KCalendarCore::FreeBusyPeriod &period);
0154 }
0155 
0156 //@cond PRIVATE
0157 Q_DECLARE_METATYPE(KCalendarCore::FreeBusyPeriod)
0158 //@endcond
0159 
0160 #endif