KCalendarCore

freebusyperiod.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 2001 Cornelius Schumacher <[email protected]>
5  SPDX-FileCopyrightText: 2007 David Jarvie <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 /**
10  @file
11  This file is part of the API for handling calendar data and
12  defines the FreeBusyPeriod class.
13 
14  @brief
15  Represents a period of time.
16 
17  @author Cornelius Schumacher <[email protected]>
18 */
19 
20 #include "freebusyperiod.h"
21 
22 using namespace KCalendarCore;
23 
24 //@cond PRIVATE
25 class Q_DECL_HIDDEN KCalendarCore::FreeBusyPeriod::Private
26 {
27 public:
28  Private()
29  : mType(Unknown)
30  {
31  }
32 
33  QString mSummary;
34  QString mLocation;
35  FreeBusyType mType;
36 };
37 //@endcond
38 
40  : Period()
41  , d(new KCalendarCore::FreeBusyPeriod::Private())
42 {
43 }
44 
46  : Period(start, end)
47  , d(new KCalendarCore::FreeBusyPeriod::Private())
48 {
49 }
50 
52  : Period(start, duration)
53  , d(new KCalendarCore::FreeBusyPeriod::Private())
54 {
55 }
56 
58  : Period(period)
59  , d(new KCalendarCore::FreeBusyPeriod::Private(*period.d))
60 {
61 }
62 
64  : Period(period)
65  , d(new KCalendarCore::FreeBusyPeriod::Private())
66 {
67 }
68 
70 {
71  delete d;
72 }
73 
75 {
76  // check for self assignment
77  if (&other == this) {
78  return *this;
79  }
80 
81  Period::operator=(other);
82  *d = *other.d;
83  return *this;
84 }
85 
87 {
88  return d->mSummary;
89 }
90 
91 void FreeBusyPeriod::setSummary(const QString &summary)
92 {
93  d->mSummary = summary;
94 }
95 
97 {
98  return d->mLocation;
99 }
100 
102 {
103  d->mLocation = location;
104 }
105 
106 FreeBusyPeriod::FreeBusyType FreeBusyPeriod::type() const
107 {
108  return d->mType;
109 }
110 
111 void FreeBusyPeriod::setType(FreeBusyPeriod::FreeBusyType type)
112 {
113  d->mType = type;
114 }
115 
117 {
118  KCalendarCore::Period periodParent = static_cast<KCalendarCore::Period>(period);
119  stream << periodParent;
120  stream << period.summary() << period.location() << static_cast<int>(period.type());
121  return stream;
122 }
123 
125 {
126  KCalendarCore::Period periodParent;
127  QString summary;
128  QString location;
129  int type;
130 
131  stream >> periodParent >> summary >> location >> type;
132 
133  period = periodParent;
134  period.setLocation(location);
135  period.setSummary(summary);
136  period.setType(static_cast<FreeBusyPeriod::FreeBusyType>(type));
137  return stream;
138 }
FreeBusyType type() const
Returns free/busy type.
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Alarm serializer.
Definition: alarm.cpp:820
Represents a span of time measured in seconds or days.
Definition: duration.h:43
void setType(FreeBusyType type)
Sets the free/busy type.
The period can be defined by either a start time and an end time or by a start time and a duration.
Definition: period.h:37
Namespace for all KCalendarCore types.
Definition: alarm.h:36
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Alarm deserializer.
Definition: alarm.cpp:833
Q_SCRIPTABLE Q_NOREPLY void start()
FreeBusyPeriod & operator=(const FreeBusyPeriod &other)
Sets this period equal to the other one.
~FreeBusyPeriod()
Destroys a period.
FreeBusyPeriod()
Constructs a period without a duration.
Period & operator=(const Period &other)
Sets this period equal to the other one.
Definition: period.cpp:89
Represents a period of time.
QString location() const
Returns the period location.
void setSummary(const QString &summary)
Sets the period summary.
QString summary() const
Returns the period summary.
void setLocation(const QString &location)
Sets the period location.
The period can be defined by either a start time and an end time or by a start time and a duration.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:00:45 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.