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 
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;
128  int type;
129 
130  stream >> periodParent >> summary >> location >> type;
131 
132  period = periodParent;
133  period.setLocation(location);
134  period.setSummary(summary);
135  period.setType(static_cast<FreeBusyPeriod::FreeBusyType>(type));
136  return stream;
137 }
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Alarm serializer.
Definition: alarm.cpp:821
QDateTime end() const
Returns when this period ends.
Definition: period.cpp:104
~FreeBusyPeriod()
Destroys a period.
FreeBusyPeriod()
Constructs a period without a duration.
FreeBusyType type() const
Returns free/busy type.
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Alarm deserializer.
Definition: alarm.cpp:834
QString summary() const
Returns the period summary.
void setLocation(const QString &location)
Sets the period location.
Duration duration() const
Returns the duration of the period.
Definition: period.cpp:109
Represents a span of time measured in seconds or days.
Definition: duration.h:43
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
void setSummary(const QString &summary)
Sets the period summary.
FreeBusyPeriod & operator=(const FreeBusyPeriod &other)
Sets this period equal to the other one.
QDateTime start() const
Returns when this period starts.
Definition: period.cpp:99
Period & operator=(const Period &other)
Sets this period equal to the other one.
Definition: period.cpp:88
void setType(FreeBusyType type)
Sets the free/busy type.
QString location() const
Returns the period location.
This file is part of the API for handling calendar data and defines the Period class.
The period can be defined by either a start time and an end time or by a start time and a duration...
Namespace for all KCalendarCore types.
Definition: alarm.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Apr 22 2021 22:51:06 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.